mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-01-22 05:30:06 -05:00
04e72c27de
-Add a new dialog for editing QSS stylesheets. Allow for saving, reloading and setting styles as default. --Include a dark style with the installation called dark.qss. --Also add support for themes such as Fusion. --Resize some controls to better fit with the new style. -Add an option to specify the number of random embers generated on startup. 1 is the minimum and the default. --Bug fixes -Properly enable/disable thread priority label in final render dialog in response to enable/disable of the OpenCL checkbox. -Remove all inline stylesheets. -Show xaos spinners with 6 decimal places. --Code changes -Remove redundant comparisons to nullptr, use ! instead; -Give some controls valid names instead of the auto generated ones. -DoubleSpinBoxTableItemDelegate.h: Add virtual keyword to overridden functions.
91 lines
3.0 KiB
C++
91 lines
3.0 KiB
C++
#pragma once
|
|
|
|
#include "FractoriumPch.h"
|
|
#include "DoubleSpinBox.h"
|
|
|
|
/// <summary>
|
|
/// DoubleSpinBoxTableItemDelegate class.
|
|
/// </summary>
|
|
|
|
/// <summary>
|
|
/// Used for showing a DoubleSpinBox on the cell of a QTableView when the user enters the cell to edit it.
|
|
/// </summary>
|
|
class DoubleSpinBoxTableItemDelegate
|
|
: public QItemDelegate
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
/// <summary>
|
|
/// Constructor that assigns a DoubleSpinBox.
|
|
/// </summary>
|
|
/// <param name="title">The DoubleSpinBox to use throughought the life of the object</param>
|
|
/// <param name="parent">The parent widget. Default: nullptr.</param>
|
|
explicit DoubleSpinBoxTableItemDelegate(DoubleSpinBox* spinBox, QObject* parent = nullptr)
|
|
: QItemDelegate(parent),
|
|
m_SpinBox(spinBox)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Re-parent and return the DoubleSpinBox to display when the user clicks on a cell and it enters edit mode.
|
|
/// The re-parenting is done so that the DoubleSpinBox appears directly on top of the cell.
|
|
/// </summary>
|
|
/// <param name="parent">The parent cell</param>
|
|
/// <param name="option">Unused</param>
|
|
/// <param name="index">unused</param>
|
|
/// <returns>The DoubleSpinBox member</returns>
|
|
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override
|
|
{
|
|
m_SpinBox->setParent(parent);
|
|
|
|
return m_SpinBox;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Prevent DoubleSpinBox control from being destroyed when the cell loses focus.
|
|
/// </summary>
|
|
/// <param name="editor">Unused</param>
|
|
/// <param name="index">Unused</param>
|
|
virtual void destroyEditor(QWidget* editor, const QModelIndex& index) const override
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the value of the DoubleSpinBox as well as its tableindex property.
|
|
/// </summary>
|
|
/// <param name="editor">Unused</param>
|
|
/// <param name="index">Unused</param>
|
|
virtual void setEditorData(QWidget* editor, const QModelIndex& index) const override
|
|
{
|
|
QPoint p(index.row(), index.column());
|
|
auto value = index.model()->data(index, Qt::EditRole).toDouble();
|
|
|
|
m_SpinBox->setProperty("tableindex", p);
|
|
m_SpinBox->setValue(value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the cell in the model to the value of the DoubleSpinBox.
|
|
/// </summary>
|
|
/// <param name="editor">Unused</param>
|
|
/// <param name="model">The model whose value will be set</param>
|
|
/// <param name="index">The cell index of the model</param>
|
|
virtual void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override
|
|
{
|
|
model->setData(index, m_SpinBox->value(), Qt::EditRole);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set the geometry of the DoubleSpinBox to match the cell being edited.
|
|
/// </summary>
|
|
/// <param name="editor">The DoubleSpinBox member</param>
|
|
/// <param name="option">Contains the rectangle to be used for the geometry of the DoubleSpinBox</param>
|
|
/// <param name="index">Unused</param>
|
|
virtual void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override
|
|
{
|
|
editor->setGeometry(option.rect);
|
|
}
|
|
|
|
private:
|
|
DoubleSpinBox* m_SpinBox;
|
|
}; |