From 73b49673c2a5b36ee562ebf95a890b19927607ec Mon Sep 17 00:00:00 2001 From: Arno Date: Thu, 4 Jan 2018 09:25:20 +0100 Subject: More renaming for new ItemSelectionWidget Use item instead of directory in var and function names to make clear that this a general purpose widget. Introduce a mode, so we can hide the browse button if we're not selecting directories. Make the label configurable and use different icons for folders or other items. --- itemselectionwidget.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'itemselectionwidget.h') diff --git a/itemselectionwidget.h b/itemselectionwidget.h index 0b8b48b..f78b9d1 100644 --- a/itemselectionwidget.h +++ b/itemselectionwidget.h @@ -2,6 +2,7 @@ #define DIRSELECTIONWIDGET_H #include +#include class QStandardItemModel; class QListView; @@ -11,19 +12,21 @@ class ItemSelectionWidget : public QWidget { Q_OBJECT public: - explicit ItemSelectionWidget(QWidget *parent = nullptr); - const QStringList directories() const; - void setDirectories(const QStringList &dirs); + enum Mode { Item, Directories }; + explicit ItemSelectionWidget(int mode, QString labelText, QWidget *parent = nullptr); + const QStringList items() const; + void setItems(const QStringList &items); public slots: void browseDir(); - void addDir(); - void removeDir(); + void addItem(); + void removeItem(); private: QStandardItemModel *mModel; QListView *mView; - QLineEdit *mDir; + QLineEdit *mItem; + QIcon mIcon; }; #endif // DIRSELECTIONWIDGET_H -- cgit v1.2.3-70-g09d2