1 /*************************************************************************** 2 * This file is part of the Lime Report project * 3 * Copyright (C) 2015 by Alexander Arin * 4 * arin_a@bk.ru * 5 * * 6 ** GNU General Public License Usage ** 7 * * 8 * This library is free software: you can redistribute it and/or modify * 9 * it under the terms of the GNU General Public License as published by * 10 * the Free Software Foundation, either version 3 of the License, or * 11 * (at your option) any later version. * 12 * You should have received a copy of the GNU General Public License * 13 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 14 * * 15 ** GNU Lesser General Public License ** 16 * * 17 * This library is free software: you can redistribute it and/or modify * 18 * it under the terms of the GNU Lesser General Public License as * 19 * published by the Free Software Foundation, either version 3 of the * 20 * License, or (at your option) any later version. * 21 * You should have received a copy of the GNU Lesser General Public * 22 * License along with this library. * 23 * If not, see <http://www.gnu.org/licenses/>. * 24 * * 25 * This library is distributed in the hope that it will be useful, * 26 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 28 * GNU General Public License for more details. * 29 ****************************************************************************/ 30 #ifndef LRCOMBOBOXEDITOR_H 31 #define LRCOMBOBOXEDITOR_H 32 33 #include <QWidget> 34 #include <QComboBox> 35 //#include <QPushButton> 36 37 class QToolButton; 38 39 namespace LimeReport{ 40 41 class InternalComboBox :public QComboBox{ 42 Q_OBJECT 43 public: QComboBox(parent)44 InternalComboBox(QWidget* parent=0):QComboBox(parent),m_popup(false){} showPopup()45 void showPopup(){m_popup = true;QComboBox::showPopup();} hidePopup()46 void hidePopup(){QComboBox::hidePopup(); m_popup = false;} isPopup()47 bool isPopup(){return m_popup;} 48 private: 49 bool m_popup; 50 51 }; 52 53 class ComboBoxEditor : public QWidget 54 { 55 Q_OBJECT 56 public: 57 //explicit ComboBoxEditor(QWidget *parent = 0); 58 ComboBoxEditor(QWidget *parent=0, bool clearable=false); 59 void addItems(const QStringList& values); 60 void setTextValue(const QString& value); 61 QString text(); 62 void setEditable(bool value); 63 signals: 64 void editingFinished(); 65 void currentIndexChanged(const QString&); 66 protected: 67 void resizeEvent(QResizeEvent *e); 68 private slots: 69 void slotClearButtonClicked(); 70 void slotCurrentIndexChanged(const QString& value); 71 private: 72 bool eventFilter(QObject *target, QEvent *event); 73 InternalComboBox* m_comboBox; 74 QToolButton* m_buttonClear; 75 bool m_settingValues; 76 }; 77 78 } // namespace LimeReport 79 80 #endif // LRCOMBOBOXEDITOR_H 81