OpenCurves  0.9
coloursview.h
1 //
2 // author Kazys Stepanas
3 //
4 // Copyright (c) CSIRO 2013
5 //
6 #ifndef COLOURSVIEW_H
7 #define COLOURSVIEW_H
8 
9 #include "ocurvesconfig.h"
10 
11 #include <QDialog>
12 
13 #include <QVector>
14 #include <QRgb>
15 
16 namespace Ui
17 {
18  class ColoursView;
19 }
20 
21 class QMenu;
22 class QTableWidgetItem;
23 
32 class ColoursView : public QDialog
33 {
34  Q_OBJECT
35 
36 public:
38  enum Columns
39  {
40  ColHex,
41  ColColour
42  };
43 
46  explicit ColoursView(QWidget *parent = nullptr);
47 
49  ~ColoursView();
50 
53  inline void setColours(const QVector<QRgb> &colours) { _colours = colours; }
54 
57  inline const QVector<QRgb> &colours() const { return _colours; }
58 
59 public slots:
65  void editColour(int colourIndex);
66 
67 protected slots:
71  void addItem();
72 
76  void removeItem();
77 
81  void resetColours();
82 
86  void resetActionTriggered();
87 
99  void cellSelectionChange();
100 
108  void edited(QTableWidgetItem *item);
109 
117  void cellDoubleClick(int row, int column);
118 
119 protected:
122  virtual void showEvent(QShowEvent *event);
123 
125  void populateColourTable();
126 
127 private:
128  Ui::ColoursView *_ui;
129  QVector<QRgb> _colours;
130  QMenu *_resetSelectionMenu;
131  bool _ignoreChanges;
132 };
133 
134 #endif // COLOURSVIEW_H
void addItem()
Adds a new colour entry to the colour list, opening a colour selection dialog.
void edited(QTableWidgetItem *item)
Handles editing of entries in the colour table (hexadecimal column only).
void resetActionTriggered()
Handler for actions on the reset context menu.
Definition: coloursview.h:16
void cellDoubleClick(int row, int column)
Respond to cell double clicks on colours by showing the colour dialog.
ColoursView(QWidget *parent=nullptr)
Constructor.
void removeItem()
Removes the currently selected colour from the list.
Columns
Column index definitions.
Definition: coloursview.h:38
void cellSelectionChange()
Remaps selection of ColColour to the corresponding ColHex.
Dialog used to edit the colours used to display plots.
Definition: coloursview.h:32
~ColoursView()
Destructor.
void setColours(const QVector< QRgb > &colours)
Sets the list of colours to edit.
Definition: coloursview.h:53
void populateColourTable()
Populate the colours UI control from _colours.
virtual void showEvent(QShowEvent *event)
Handles the dialog show event by populating the colours table.
void editColour(int colourIndex)
Opens a colour dialog to edit the colour at the given index.
const QVector< QRgb > & colours() const
Retrieves the list of colours.
Definition: coloursview.h:57
void resetColours()
Reset to the default colour set.