kexi

pixmapcollection.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
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 KFORMDESIGNERPIXMAPCOLLECTION_H
00021 #define KFORMDESIGNERPIXMAPCOLLECTION_H
00022 
00023 #include <qobject.h>
00024 #include <qmap.h>
00025 #include <qpair.h>
00026 #include <qintdict.h>
00027 #include <qtoolbutton.h>
00028 
00029 #include <kicontheme.h>
00030 #include <kdialogbase.h>
00031 #include <kiconview.h>
00032 #include <kurl.h>
00033 
00034 class QPixmap;
00035 class KIconView;
00036 class KIconButton;
00037 class KLineEdit;
00038 class QDomNode;
00039 
00040 typedef QMap<QString, QPair<QString, int> > PixmapMap;
00041 
00043 class KEXIEXTWIDGETS_EXPORT PixmapCollection : public QObject
00044 {
00045     Q_OBJECT
00046 
00047     public:
00048         PixmapCollection(const QString &collectionName, QObject *parent = 0, const char *name = 0);
00049         ~PixmapCollection() {;}
00050 
00051         QString addPixmapPath(const KURL &url);
00052         QString addPixmapName(const QString &name, int size = KIcon::SizeMedium);
00053         void removePixmap(const QString &name);
00054 
00055         bool   contains(const QString &name);
00056         QPixmap  getPixmap(const QString &name);
00057 
00058         void save(QDomNode parentNode);
00059         void load(QDomNode node);
00060 
00061         QString collectionName() {return m_name; }
00062 
00063     signals:
00064         void itemRenamed(const QString &oldName, const QString &newName);
00065         void itemRemoved(const QString &name);
00066 
00067     protected:
00068         QString  m_name;
00069         PixmapMap  m_pixmaps;
00070 
00071     friend class PixmapCollectionEditor;
00072     friend class PixmapCollectionChooser;
00073 };
00074 
00076 class KEXIEXTWIDGETS_EXPORT PixmapCollectionEditor : public KDialogBase
00077 {
00078     Q_OBJECT
00079 
00080     public:
00081         PixmapCollectionEditor(PixmapCollection *collection, QWidget *parent = 0);
00082         ~PixmapCollectionEditor() {;}
00083 
00084     protected:
00085         QPixmap getPixmap(const QString &name);
00086         void createIconViewItem(const QString &name);
00087 
00088     protected slots:
00089         void newItemByPath();
00090         void newItemByName();
00091         void removeItem();
00092         void renameItem();
00093         void renameCollectionItem(QIconViewItem *item, const QString &name);
00094         void displayMenu(QIconViewItem *item, const QPoint &p);
00095 
00096     private:
00097         enum { BNewItemPath = 101, BNewItemName, BDelItem};
00098         KIconView  *m_iconView;
00099         QIntDict<QToolButton>  m_buttons;
00100         PixmapCollection  *m_collection;
00101 };
00102 
00104 class KEXIEXTWIDGETS_EXPORT PixmapCollectionChooser : public KDialogBase
00105 {
00106     Q_OBJECT
00107 
00108     public:
00109         PixmapCollectionChooser(PixmapCollection *collection, const QString &selectedItem, QWidget *parent = 0);
00110         ~PixmapCollectionChooser() {;}
00111 
00112         QPixmap  pixmap();
00113         QString  pixmapName();
00114 
00115     protected:
00116         QPixmap getPixmap(const QString &name);
00117     protected slots:
00118         virtual void slotUser1();
00119 
00120     private:
00121         PixmapCollection  *m_collection;
00122         KIconView  *m_iconView;
00123 };
00124 
00126 class KEXIEXTWIDGETS_EXPORT LoadIconDialog : public KDialogBase
00127 {
00128     Q_OBJECT
00129 
00130     public:
00131         LoadIconDialog(QWidget *parent = 0);
00132         ~LoadIconDialog() {;}
00133 
00134         int iconSize();
00135         QString iconName();
00136 
00137     protected slots:
00138         void changeIconSize(int);
00139         void updateIconName(QString);
00140         void setIcon(const QString &);
00141 
00142     private:
00143         KLineEdit *m_nameInput;
00144         KIconButton *m_button;
00145 };
00146 
00148 class KEXIEXTWIDGETS_EXPORT PixmapIconViewItem : public KIconViewItem
00149 {
00150     public:
00151         PixmapIconViewItem(KIconView *parent, const QString &text, const QPixmap &icon)
00152         : KIconViewItem(parent, text, icon)  { m_name = text; }
00153         ~PixmapIconViewItem() {;}
00154 
00155         void setName(const QString &name) { m_name = name; }
00156         QString name() { return m_name;}
00157 
00158     private:
00159         QString  m_name;
00160 };
00161 
00162 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys