Engauge Digitizer  2
DlgSettingsCurveAddRemove.h
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #ifndef DLG_SETTINGS_CURVE_ADD_REMOVE_H
8 #define DLG_SETTINGS_CURVE_ADD_REMOVE_H
9 
10 #include "DlgSettingsAbstractBase.h"
11 #include <QItemSelection>
12 #include <QModelIndex>
13 
14 class CurveNameList;
15 class QGridLayout;
16 class QListView;
17 class QPushButton;
18 class QTableView;
19 
24 {
25  Q_OBJECT;
26 
27 public:
30  virtual ~DlgSettingsCurveAddRemove();
31 
32  virtual void createOptionalSaveDefault (QHBoxLayout *layout);
33  virtual QWidget *createSubPanel ();
35 
36 private slots:
37  void slotDataChanged (const QModelIndex &topLeft,
38  const QModelIndex &bottomRight,
39  const QVector<int> &roles);
40  void slotNew ();
41  void slotRemove ();
42  void slotResetDefault();
43  void slotSaveDefault();
44  void slotSelectionChanged (QItemSelection, QItemSelection);
45 
46 protected:
47  virtual void handleOk ();
48 
49 private:
50 
51  void appendCurveName (const QString &curveNameNew,
52  const QString &curveNameOriginal,
53  int numPoints);
54  void createButtons (QGridLayout *layout, int &row);
55  void createListCurves (QGridLayout *layout, int &row);
56  bool endsWithNumber (const QString &str) const;
57  void insertCurveName (int row,
58  const QString &curveNameNew,
59  const QString &curveNameOriginal,
60  int numPoints);
61  int newIndexFromSelection () const;
62  QString nextCurveName () const; // Pick good curve name to go at currentRow()
63  int numberAtEnd (const QString &str) const;
64  void removeSelectedCurves();
65  void selectCurveName (const QString &curveWanted);
66  void updateControls ();
67 
68  CurveNameList *m_curveNameList; // Model for m_listCurves
69 
70 #ifdef DLG_SETTINGS_DEBUG
71  QTableView *m_listCurves; // While debugging, the 3 columns in each row are visible to make the operations more clear
72 #else
73  QListView *m_listCurves; // Use QListView instead of QListWidget so validators can be used
74 #endif
75 
76  QPushButton *m_btnAdd;
77  QPushButton *m_btnRemove;
78  QPushButton *m_btnRename;
79 
80  QPushButton *m_btnResetDefault;
81  QPushButton *m_btnSaveDefault;
82 };
83 
84 #endif // DLG_SETTINGS_CURVE_ADD_REMOVE_H
virtual void createOptionalSaveDefault(QHBoxLayout *layout)
Let subclass define an optional Save As Default button.
virtual QWidget * createSubPanel()
Create dialog-specific panel to which base class will add Ok and Cancel buttons.
Dialog for editing curve names settings.
void load(CmdMediator &cmdMediator)
Load settings from Document.
Command queue stack.
Definition: CmdMediator.h:23
Abstract base class for all Settings dialogs.
Model for DlgSettingsCurveAddRemove and CmdSettingsCurveAddRemove.
Definition: CurveNameList.h:16
MainWindow & mainWindow()
Get method for MainWindow.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Definition: MainWindow.h:83
DlgSettingsCurveAddRemove(MainWindow &mainWindow)
Single constructor.
CmdMediator & cmdMediator()
Provide access to Document information wrapped inside CmdMediator.
virtual void handleOk()
Process slotOk.