1 /********************************************************************************************** 2 Copyright (C) 2017 Norbert Truchsess <norbert.truchsess@t-online.de> 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 18 **********************************************************************************************/ 19 20 #ifndef CSELECTDOUBLELISTWIDGET_H 21 #define CSELECTDOUBLELISTWIDGET_H 22 23 #include "ui_ISelectDoubleListWidget.h" 24 25 class CSelectDoubleListWidget : public QWidget, private Ui::ISelectDoubleListWidget 26 { 27 Q_OBJECT 28 public: 29 class IItemFilter 30 { 31 public: 32 virtual bool shouldBeMoved(QListWidgetItem* item) = 0; 33 }; 34 35 CSelectDoubleListWidget(QWidget* parent, IItemFilter* filter = nullptr); 36 virtual ~CSelectDoubleListWidget(); 37 38 void setAvailable(const QList<QListWidgetItem*>& available); 39 void setSelected(const QList<QListWidgetItem*>& selected) const; 40 void setLabelAvailable(const QString& label) const; 41 void setLabelSelected(const QString& label) const; 42 void setFilter(IItemFilter* const& filter); 43 const QList<QListWidgetItem*> selected() const; 44 void clear(); 45 46 void sortAvailable(); 47 48 private slots: 49 void slotSelectedClicked(const QModelIndex& index) const; 50 void slotAvailableClicked(const QModelIndex& index) const; 51 void slotAdd() const; 52 void slotRemove() const; 53 void slotUp() const; 54 void slotDown() const; 55 56 private: 57 void updateButtons() const; 58 59 QList<QListWidgetItem*> available; 60 IItemFilter* filter; 61 }; 62 #endif //CSELECTDOUBLELISTWIDGET_H 63