OpenCurves  0.9
ColoursView Class Reference

Dialog used to edit the colours used to display plots. More...

#include <coloursview.h>

Inheritance diagram for ColoursView:

Public Types

enum  Columns { ColHex, ColColour }
 Column index definitions.
 

Public Slots

void editColour (int colourIndex)
 Opens a colour dialog to edit the colour at the given index. More...
 

Public Member Functions

 ColoursView (QWidget *parent=nullptr)
 Constructor. More...
 
 ~ColoursView ()
 Destructor.
 
void setColours (const QVector< QRgb > &colours)
 Sets the list of colours to edit. More...
 
const QVector< QRgb > & colours () const
 Retrieves the list of colours. More...
 

Protected Slots

void addItem ()
 Adds a new colour entry to the colour list, opening a colour selection dialog. More...
 
void removeItem ()
 Removes the currently selected colour from the list. More...
 
void resetColours ()
 Reset to the default colour set. More...
 
void resetActionTriggered ()
 Handler for actions on the reset context menu. More...
 
void cellSelectionChange ()
 Remaps selection of ColColour to the corresponding ColHex. More...
 
void edited (QTableWidgetItem *item)
 Handles editing of entries in the colour table (hexadecimal column only). More...
 
void cellDoubleClick (int row, int column)
 Respond to cell double clicks on colours by showing the colour dialog. More...
 

Protected Member Functions

virtual void showEvent (QShowEvent *event)
 Handles the dialog show event by populating the colours table. More...
 
void populateColourTable ()
 Populate the colours UI control from _colours.
 

Detailed Description

Dialog used to edit the colours used to display plots.

Displays colours in a table with a hexadecimal cell and a cell filled with the final colour. Colours can be added and removed, but there must always be at least one colour.

After editing, the final colour list is available via colours().

Constructor & Destructor Documentation

ColoursView::ColoursView ( QWidget *  parent = nullptr)
explicit

Constructor.

Parameters
parentParent widget.

Member Function Documentation

void ColoursView::addItem ( )
protectedslot

Adds a new colour entry to the colour list, opening a colour selection dialog.

Bound to the add button.

void ColoursView::cellDoubleClick ( int  row,
int  column 
)
protectedslot

Respond to cell double clicks on colours by showing the colour dialog.

Only responds to clicks on the colour column. Bound to the table's cellDoubleClicked() signal.

Parameters
rowThe row index of the clicked cell.
columnThe column index of the clicked cell.
void ColoursView::cellSelectionChange ( )
protectedslot

Remaps selection of ColColour to the corresponding ColHex.

This method ensures that the ColColour cannot remain selected by deselecting cells in this column, and selecting the corresponding ColHex cell. This is simply to prevent drawing the colour column with the wrong colour.

For example, on Windows platforms the selected cell is always drawn with a system colour (commonly blue). This would result in the colour cell showing the wrong colour (blue) instead of the colour it represents. We avoid this by remapping the selection.

const QVector<QRgb>& ColoursView::colours ( ) const
inline

Retrieves the list of colours.

This is the edited list after the dialog is closed.

Returns
The edited colour list.

Referenced by setColours().

void ColoursView::editColour ( int  colourIndex)
slot

Opens a colour dialog to edit the colour at the given index.

Does nothing if colourIndex is out of range.

This opens a colour selection dialog initialised with the colour at colourIndex. The colour is unmodified if the editing dialog is cancelled.

Parameters
colourIndexThe index of the colour to edit. Ignores out of range values.
void ColoursView::edited ( QTableWidgetItem *  item)
protectedslot

Handles editing of entries in the colour table (hexadecimal column only).

Only accepts editing of the hexadecimal value column, ignoring any others.

Bound to the table's itemChanged() signal.

Parameters
itemThe table item being edited.
void ColoursView::removeItem ( )
protectedslot

Removes the currently selected colour from the list.

Bound to the remove button.

void ColoursView::resetActionTriggered ( )
protectedslot

Handler for actions on the reset context menu.

Resets to the colour set associated with the triggering action.

void ColoursView::resetColours ( )
protectedslot

Reset to the default colour set.

The default colours are taken from ocurves::DefaultColours.

void ColoursView::setColours ( const QVector< QRgb > &  colours)
inline

Sets the list of colours to edit.

Parameters
coloursThe initial list of available colours.

References colours().

virtual void ColoursView::showEvent ( QShowEvent *  event)
protectedvirtual

Handles the dialog show event by populating the colours table.

Parameters
eventEvent details.

The documentation for this class was generated from the following file: