| # kdeprint Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kmprinterview.cpp

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
    00004  *
    00005  *  This library is free software; you can redistribute it and/or
    00006  *  modify it under the terms of the GNU Library General Public
    00007  *  License version 2 as published by the Free Software Foundation.
    00008  *
    00009  *  This library is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012  *  Library General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Library General Public License
    00015  *  along with this library; see the file COPYING.LIB.  If not, write to
    00016  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017  *  Boston, MA 02111-1307, USA.
    00018  **/
    00019
    00020 #include "kmprinterview.h"
    00021 #include "kmprinter.h"
    00022 #include "kmiconview.h"
    00023 #include "kmlistview.h"
    00024 #include "kmtimer.h"
    00025 #include "kmmanager.h"
    00026
    00027 #include <qlayout.h>
    00028 #include <qpopupmenu.h>
    00029 #include <kaction.h>
    00030 #include <klocale.h>
    00031
    00032 KMPrinterView::KMPrinterView(QWidget *parent, const char *name)
    00033 : QWidgetStack(parent,name), m_type(KMPrinterView::Icons)
    00034 {
    00035     m_iconview = new KMIconView(this);
    00036     addWidget(m_iconview,0);
    00037     m_listview = new KMListView(this);
    00038     addWidget(m_listview,1);
    00039     m_current = QString::null;
    00040     m_listset = false;
    00041
    00042     connect(m_iconview,SIGNAL(rightButtonClicked(const QString&,const QPoint&)),SIGNAL(rightButtonClicked(const QString&,const QPoint&)));
    00043     connect(m_listview,SIGNAL(rightButtonClicked(const QString&,const QPoint&)),SIGNAL(rightButtonClicked(const QString&,const QPoint&)));
    00044     connect(m_iconview,SIGNAL(printerSelected(const QString&)),SIGNAL(printerSelected(const QString&)));
    00045     connect(m_listview,SIGNAL(printerSelected(const QString&)),SIGNAL(printerSelected(const QString&)));
    00046     connect(m_iconview,SIGNAL(printerSelected(const QString&)),SLOT(slotPrinterSelected(const QString&)));
    00047     connect(m_listview,SIGNAL(printerSelected(const QString&)),SLOT(slotPrinterSelected(const QString&)));
    00048
    00049     setViewType(m_type);
    00050     setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
    00051 }
    00052
    00053 KMPrinterView::~KMPrinterView()
    00054 {
    00055 }
    00056
    00057 void KMPrinterView::setPrinterList(QPtrList<KMPrinter> *list)
    00058 {
    00059     if (m_type != KMPrinterView::Tree || list == 0)
    00060         m_iconview->setPrinterList(list);
    00061     if (m_type == KMPrinterView::Tree || list == 0)
    00062         m_listview->setPrinterList(list);
    00063     m_listset = ( list != 0 );
    00064 }
    00065
    00066 void KMPrinterView::setPrinter( KMPrinter *p )
    00067 {
    00068     if ( m_type == KMPrinterView::Tree )
    00069         m_listview->setPrinter( p );
    00070     else
    00071         m_iconview->setPrinter( p );
    00072 }
    00073
    00074 void KMPrinterView::setViewType(ViewType t)
    00075 {
    00076     m_type = t;
    00077     switch (m_type)
    00078     {
    00079         case KMPrinterView::Icons:
    00080             m_iconview->setViewMode(KMIconView::Big);
    00081             break;
    00082         case KMPrinterView::List:
    00083             m_iconview->setViewMode(KMIconView::Small);
    00084             break;
    00085         default:
    00086             break;
    00087     }
    00088     QString oldcurrent = m_current;
    00089     if ( m_listset )
    00090         setPrinterList(KMManager::self()->printerList(false));
    00091     if (m_type == KMPrinterView::Tree)
    00092     {
    00093         raiseWidget(m_listview);
    00094         m_listview->setPrinter(oldcurrent);
    00095     }
    00096     else
    00097     {
    00098         raiseWidget(m_iconview);
    00099         m_iconview->setPrinter(oldcurrent);
    00100     }
    00101 }
    00102
    00103 void KMPrinterView::slotPrinterSelected(const QString& p)
    00104 {
    00105     m_current = p;
    00106 }
    00107
    00108 QSize KMPrinterView::minimumSizeHint() const
    00109 {
    00110     return QWidgetStack::minimumSizeHint();
    00111 }
    00112
    00113 #include "kmprinterview.moc"

This file is part of the documentation for kdeprint Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:31:03 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003