MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LabelEditorDlg.hpp
1 #ifndef LABELEDITORDLG_HPP
2 #define LABELEDITORDLG_HPP
3 
4 #include <Config.hpp>
5 
6 #include <Color.hpp>
7 #include <Misc.hpp>
8 
9 #include <QAbstractListModel>
10 #include <vector>
11 #include <QDialog>
12 
13 class QAbstractButton;
14 class QPoint;
15 
17 public:
18  LabelModel(std::vector<mgx::Colorf>* colors);
19 
20  int rowCount(const QModelIndex& parent = QModelIndex()) const;
21  int columnCount(const QModelIndex& /*parent*/ = QModelIndex()) const {
22  return 1;
23  }
24 
25  Qt::ItemFlags flags(const QModelIndex& index) const;
26 
27  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
28  bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
29 
30  void apply();
31  void reset();
32 
33  void makeGray();
34  void makeRandom();
35 
36  void setNbColors(int n);
37 
38  bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex());
39  bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
40 
41 protected:
42  std::vector<mgx::Colorf>* toChange;
43  std::vector<mgx::Colorf> localCopy;
44 };
45 
46 namespace Ui {
47 class LabelEditorDlg;
48 } // namespace Ui
49 
50 class LabelEditorDlg : public QDialog {
51  Q_OBJECT
52 public:
53  LabelEditorDlg(std::vector<mgx::Colorf>* colors, QWidget* parent);
54  ~LabelEditorDlg();
55 
56 public slots:
57  void importLabels();
58  void exportLabels();
59  bool importLabels(QString filename);
60  bool exportLabels(QString filename);
61  void makeLabelCurrent();
62  void selectLabel();
63  void setCurrentLabel(int label);
64 
65 protected slots:
66  void on_buttonBox_clicked(QAbstractButton* btn);
67  void on_setNbColors_clicked();
68  void on_labelsView_doubleClicked(const QModelIndex& idx);
69  void on_labelsView_customContextMenuRequested(const QPoint& pos);
70  void on_showCurrent_clicked();
71  void on_makeGray_clicked();
72  void on_makeRandom_clicked();
73  void changeNbItems();
74 
75 signals:
76  void update();
77  void selectLabel(int label, int repeat, bool replaceSelection);
78  void makeLabelCurrent(int label);
79 
80 protected:
81  int currentLabel, selectedLabel;
82  LabelModel* _model;
83  Ui::LabelEditorDlg* ui;
84  QPushButton* importButton, *exportButton;
85  QAction* selectLabelAction, *makeLabelCurrentAction;
86 };
87 
88 #endif // LABELEDITORDLG_HPP
Misc.
index(int row, int column=0, const QModelIndex &parent=QModelIndex()
Defines the Color class template.
Definition: LabelEditorDlg.hpp:50
Definition: LabelEditorDlg.hpp:16