kmiconview.h
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., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 **/ 00019 00020 #ifndef KMICONVIEW_H 00021 #define KMICONVIEW_H 00022 00023 #include <kiconview.h> 00024 #include <qptrlist.h> 00025 00026 #include "kmobject.h" 00027 00028 class KMPrinter; 00029 00030 class KMIconViewItem : public QIconViewItem, public KMObject 00031 { 00032 public: 00033 KMIconViewItem(QIconView *parent, KMPrinter *p); 00034 void updatePrinter(KMPrinter *printer = 0, int mode = QIconView::Bottom); 00035 bool isClass() const { return m_isclass; } 00036 00037 protected: 00038 virtual void paintItem(QPainter*, const QColorGroup&); 00039 virtual void calcRect(const QString& text_ = QString::null); 00040 00041 private: 00042 int m_mode; 00043 QString m_pixmap; 00044 char m_state; 00045 bool m_isclass; 00046 }; 00047 00048 class KMIconView : public KIconView 00049 { 00050 Q_OBJECT 00051 public: 00052 enum ViewMode { Big, Small }; 00053 00054 KMIconView(QWidget *parent = 0, const char *name = 0); 00055 ~KMIconView(); 00056 00057 void setPrinterList(QPtrList<KMPrinter> *list); 00058 void setPrinter(const QString&); 00059 void setPrinter(KMPrinter*); 00060 void setViewMode(ViewMode); 00061 00062 signals: 00063 void rightButtonClicked(const QString&, const QPoint&); 00064 void printerSelected(const QString&); 00065 00066 protected slots: 00067 void slotRightButtonClicked(QIconViewItem*, const QPoint&); 00068 void slotSelectionChanged(); 00069 00070 private: 00071 KMIconViewItem* findItem(KMPrinter *p); 00072 00073 private: 00074 QPtrList<KMIconViewItem> m_items; 00075 ViewMode m_mode; 00076 }; 00077 00078 #endif