Plasma
combobox.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2008 Aaron Seigo <aseigo@kde.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program 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 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef PLASMA_COMBOBOX_H 00021 #define PLASMA_COMBOBOX_H 00022 00023 #include <QtGui/QGraphicsProxyWidget> 00024 00025 class KComboBox; 00026 00027 #include <plasma/plasma_export.h> 00028 00029 namespace Plasma 00030 { 00031 00032 class ComboBoxPrivate; 00033 00039 class PLASMA_EXPORT ComboBox : public QGraphicsProxyWidget 00040 { 00041 Q_OBJECT 00042 00043 Q_PROPERTY(QGraphicsWidget *parentWidget READ parentWidget) 00044 Q_PROPERTY(QString text READ text NOTIFY textChanged) 00045 Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet) 00046 Q_PROPERTY(KComboBox *nativeWidget READ nativeWidget WRITE setNativeWidget) 00047 Q_PROPERTY(int count READ count) 00048 Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) 00049 00050 public: 00051 explicit ComboBox(QGraphicsWidget *parent = 0); 00052 ~ComboBox(); 00053 00057 QString text() const; 00058 00064 void setStyleSheet(const QString &stylesheet); 00065 00069 QString styleSheet(); 00070 00077 void setNativeWidget(KComboBox *nativeWidget); 00078 00082 KComboBox *nativeWidget() const; 00083 00088 Q_INVOKABLE void addItem(const QString &text); 00089 00094 int count() const; 00095 00100 int currentIndex() const; 00101 00106 void setCurrentIndex(int index); 00107 00108 public Q_SLOTS: 00109 void clear(); 00110 00111 Q_SIGNALS: 00116 void activated(const QString &text); 00117 00123 void textChanged(const QString &text); 00124 00129 void currentIndexChanged(int index); 00130 00131 protected: 00132 void resizeEvent(QGraphicsSceneResizeEvent *event); 00133 void paint(QPainter *painter, 00134 const QStyleOptionGraphicsItem *option, 00135 QWidget *widget); 00136 void focusInEvent(QFocusEvent *event); 00137 void focusOutEvent(QFocusEvent *event); 00138 void hoverEnterEvent(QGraphicsSceneHoverEvent *event); 00139 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); 00140 void changeEvent(QEvent *event); 00141 void mousePressEvent(QGraphicsSceneMouseEvent *event); 00142 00143 00144 private: 00145 ComboBoxPrivate * const d; 00146 00147 friend class ComboBoxPrivate; 00148 Q_PRIVATE_SLOT(d, void syncBorders()) 00149 Q_PRIVATE_SLOT(d, void setPalette()) 00150 }; 00151 00152 } // namespace Plasma 00153 00154 #endif // multiple inclusion guard
KDE 4.6 API Reference