From ce4a32fe52ef09d8f5ff1dd22c001110902b60a2 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kdeprint/management/kmprinterview.cpp | 113 ++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 kdeprint/management/kmprinterview.cpp (limited to 'kdeprint/management/kmprinterview.cpp') diff --git a/kdeprint/management/kmprinterview.cpp b/kdeprint/management/kmprinterview.cpp new file mode 100644 index 000000000..89549ed94 --- /dev/null +++ b/kdeprint/management/kmprinterview.cpp @@ -0,0 +1,113 @@ +/* + * This file is part of the KDE libraries + * Copyright (c) 2001 Michael Goffioul + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + **/ + +#include "kmprinterview.h" +#include "kmprinter.h" +#include "kmiconview.h" +#include "kmlistview.h" +#include "kmtimer.h" +#include "kmmanager.h" + +#include +#include +#include +#include + +KMPrinterView::KMPrinterView(QWidget *parent, const char *name) +: QWidgetStack(parent,name), m_type(KMPrinterView::Icons) +{ + m_iconview = new KMIconView(this); + addWidget(m_iconview,0); + m_listview = new KMListView(this); + addWidget(m_listview,1); + m_current = QString::null; + m_listset = false; + + connect(m_iconview,SIGNAL(rightButtonClicked(const QString&,const QPoint&)),SIGNAL(rightButtonClicked(const QString&,const QPoint&))); + connect(m_listview,SIGNAL(rightButtonClicked(const QString&,const QPoint&)),SIGNAL(rightButtonClicked(const QString&,const QPoint&))); + connect(m_iconview,SIGNAL(printerSelected(const QString&)),SIGNAL(printerSelected(const QString&))); + connect(m_listview,SIGNAL(printerSelected(const QString&)),SIGNAL(printerSelected(const QString&))); + connect(m_iconview,SIGNAL(printerSelected(const QString&)),SLOT(slotPrinterSelected(const QString&))); + connect(m_listview,SIGNAL(printerSelected(const QString&)),SLOT(slotPrinterSelected(const QString&))); + + setViewType(m_type); + setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); +} + +KMPrinterView::~KMPrinterView() +{ +} + +void KMPrinterView::setPrinterList(QPtrList *list) +{ + if (m_type != KMPrinterView::Tree || list == 0) + m_iconview->setPrinterList(list); + if (m_type == KMPrinterView::Tree || list == 0) + m_listview->setPrinterList(list); + m_listset = ( list != 0 ); +} + +void KMPrinterView::setPrinter( KMPrinter *p ) +{ + if ( m_type == KMPrinterView::Tree ) + m_listview->setPrinter( p ); + else + m_iconview->setPrinter( p ); +} + +void KMPrinterView::setViewType(ViewType t) +{ + m_type = t; + switch (m_type) + { + case KMPrinterView::Icons: + m_iconview->setViewMode(KMIconView::Big); + break; + case KMPrinterView::List: + m_iconview->setViewMode(KMIconView::Small); + break; + default: + break; + } + QString oldcurrent = m_current; + if ( m_listset ) + setPrinterList(KMManager::self()->printerList(false)); + if (m_type == KMPrinterView::Tree) + { + raiseWidget(m_listview); + m_listview->setPrinter(oldcurrent); + } + else + { + raiseWidget(m_iconview); + m_iconview->setPrinter(oldcurrent); + } +} + +void KMPrinterView::slotPrinterSelected(const QString& p) +{ + m_current = p; +} + +QSize KMPrinterView::minimumSizeHint() const +{ + return QWidgetStack::minimumSizeHint(); +} + +#include "kmprinterview.moc" -- cgit v1.2.1