mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cleanup: make static fields local to ComboBoxDelegate
All combobox-delegates shared a number of static status fields. In a quest to make the code more reentrant, move that to the actual object. The fields have to be defined as mutable, since they are set in const member functions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
be7365755e
commit
f9e246fed2
2 changed files with 8 additions and 9 deletions
|
@ -38,7 +38,6 @@ QSize DiveListDelegate::sizeHint(const QStyleOptionViewItem&, const QModelIndex&
|
||||||
// Gets the index of the model in the currentRow and column.
|
// Gets the index of the model in the currentRow and column.
|
||||||
// currCombo is defined below.
|
// currCombo is defined below.
|
||||||
#define IDX(_XX) mymodel->index(currCombo.currRow, (_XX))
|
#define IDX(_XX) mymodel->index(currCombo.currRow, (_XX))
|
||||||
static bool keyboardFinished = false;
|
|
||||||
|
|
||||||
StarWidgetsDelegate::StarWidgetsDelegate(QWidget *parent) : QStyledItemDelegate(parent),
|
StarWidgetsDelegate::StarWidgetsDelegate(QWidget *parent) : QStyledItemDelegate(parent),
|
||||||
parentWidget(parent)
|
parentWidget(parent)
|
||||||
|
@ -101,14 +100,6 @@ void ComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index)
|
||||||
c->lineEdit()->setSelection(0, c->lineEdit()->text().length());
|
c->lineEdit()->setSelection(0, c->lineEdit()->text().length());
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct CurrSelected {
|
|
||||||
QComboBox *comboEditor;
|
|
||||||
int currRow;
|
|
||||||
QString activeText;
|
|
||||||
QAbstractItemModel *model;
|
|
||||||
bool ignoreSelection;
|
|
||||||
} currCombo;
|
|
||||||
|
|
||||||
QWidget *ComboBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem&, const QModelIndex &index) const
|
QWidget *ComboBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem&, const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
QComboBox *comboDelegate = new QComboBox(parent);
|
QComboBox *comboDelegate = new QComboBox(parent);
|
||||||
|
|
|
@ -48,8 +48,16 @@ slots:
|
||||||
virtual void editorClosed(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) = 0;
|
virtual void editorClosed(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) = 0;
|
||||||
private:
|
private:
|
||||||
bool editable;
|
bool editable;
|
||||||
|
mutable bool keyboardFinished;
|
||||||
protected:
|
protected:
|
||||||
QAbstractItemModel *model;
|
QAbstractItemModel *model;
|
||||||
|
mutable struct CurrSelected {
|
||||||
|
QComboBox *comboEditor;
|
||||||
|
int currRow;
|
||||||
|
QString activeText;
|
||||||
|
QAbstractItemModel *model;
|
||||||
|
bool ignoreSelection;
|
||||||
|
} currCombo;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TankInfoDelegate : public ComboBoxDelegate {
|
class TankInfoDelegate : public ComboBoxDelegate {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue