kdeprint Library API Documentation

kmprinterview.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <goffioul@imec.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::setViewType(ViewType t)
00067 {
00068     m_type = t;
00069     switch (m_type)
00070     {
00071         case KMPrinterView::Icons:
00072             m_iconview->setViewMode(KMIconView::Big);
00073             break;
00074         case KMPrinterView::List:
00075             m_iconview->setViewMode(KMIconView::Small);
00076             break;
00077         default:
00078             break;
00079     }
00080     QString oldcurrent = m_current;
00081     if ( m_listset )
00082         setPrinterList(KMManager::self()->printerList(false));
00083     if (m_type == KMPrinterView::Tree)
00084     {
00085         raiseWidget(m_listview);
00086         m_listview->setPrinter(oldcurrent);
00087     }
00088     else
00089     {
00090         raiseWidget(m_iconview);
00091         m_iconview->setPrinter(oldcurrent);
00092     }
00093 }
00094 
00095 void KMPrinterView::slotPrinterSelected(const QString& p)
00096 {
00097     m_current = p;
00098 }
00099 
00100 QSize KMPrinterView::minimumSizeHint() const
00101 {
00102     return QWidgetStack::minimumSizeHint();
00103 }
00104 
00105 #include "kmprinterview.moc"
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 4 22:45:13 2004 by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2003