colorlistbox.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #ifndef COLORLISTBOX_H
00008 #define COLORLISTBOX_H
00009
00010 #include <QListWidget>
00011 #include <QColor>
00012 #include <QPointer>
00013
00014 #include "colorsetmanager.h"
00015 #include "commonstrings.h"
00016 #include "scribusapi.h"
00017 #include "sclistboxpixmap.h"
00018 #include "scguardedptr.h"
00019 #include "sccolor.h"
00020
00021 struct SCRIBUS_API ColorPixmapValue
00022 {
00023 ScColor m_color;
00024 ScGuardedPtr<ScribusDoc> m_doc;
00025 QString m_name;
00026
00027 ColorPixmapValue();
00028 ColorPixmapValue( const ScColor& col, ScribusDoc* doc, const QString colName );
00029 ColorPixmapValue(const ColorPixmapValue& other);
00030 ColorPixmapValue& operator= (const ColorPixmapValue& other);
00031 };
00032
00033
00034 Q_DECLARE_METATYPE(ColorPixmapValue)
00035
00036 class ColorPixmapItem : public QListWidgetItem
00037 {
00038 enum {
00039 ColorPixmapUserType = UserType + 1
00040 } usrtyp;
00041 public:
00042 ColorPixmapItem( const ScColor& col, ScribusDoc* doc, const QString colName) : QListWidgetItem(NULL, ColorPixmapUserType) {
00043 setText(colName);
00044 setData(Qt::UserRole, QVariant::fromValue(ColorPixmapValue(col, doc, colName)));
00045 };
00046 ColorPixmapItem( const ColorPixmapValue& col) : QListWidgetItem(NULL, ColorPixmapUserType) {
00047 setText(col.m_name);
00048 setData(Qt::UserRole, QVariant::fromValue(col));
00049 };
00050 ColorPixmapItem( ) : QListWidgetItem(NULL, ColorPixmapUserType) {
00051 setText(CommonStrings::tr_NoneColor);
00052 setData(Qt::UserRole, QVariant::fromValue(ColorPixmapValue(ScColor(0,0,0,0), NULL, CommonStrings::tr_NoneColor)));
00053 };
00054 QListWidgetItem * clone () const { return new ColorPixmapItem(*this); }
00055 QString colorName() const { return data(Qt::UserRole).value<ColorPixmapValue>().m_name; }
00056 };
00057
00058
00059
00067 class SCRIBUS_API ColorListBox : public QListWidget
00068 {
00069 Q_OBJECT
00070
00071 public:
00072
00073 enum PixmapType
00074 {
00075 smallPixmap,
00076 widePixmap,
00077 fancyPixmap
00078 };
00079
00082 ColorListBox(QWidget * parent = 0);
00083
00084 QString currentColor() const;
00085
00091 void updateBox(ColorList& list, ColorListBox::PixmapType type);
00092
00097 void insertItems(ColorList& list, ColorListBox::PixmapType type);
00098
00101 void insertSmallPixmapItems(ColorList& list);
00102
00105 void insertWidePixmapItems(ColorList& list);
00106
00109 void insertFancyPixmapItems(ColorList& list);
00110
00112 ColorList *cList;
00113 protected:
00114 bool event(QEvent *event);
00115
00116 int m_selectedRow;
00117 };
00118
00119 #endif