Tweaks to auto objects and fixup filesyncdialog compile
This commit is contained in:
@@ -21,23 +21,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <QCheckBox>
|
||||
#include "modeledit/modeledit.h"
|
||||
#include "genericpanel.h"
|
||||
|
||||
class AutoCheckBox: public QCheckBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AutoCheckBox(QWidget *parent = 0):
|
||||
explicit AutoCheckBox(QWidget * parent = nullptr):
|
||||
QCheckBox(parent),
|
||||
field(NULL),
|
||||
panel(NULL),
|
||||
field(nullptr),
|
||||
panel(nullptr),
|
||||
lock(false)
|
||||
{
|
||||
connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)));
|
||||
}
|
||||
|
||||
void setField(bool & field, ModelPanel * panel=NULL)
|
||||
void setField(bool & field, GenericPanel * panel = nullptr)
|
||||
{
|
||||
this->field = &field;
|
||||
this->panel = panel;
|
||||
@@ -51,26 +51,31 @@ class AutoCheckBox: public QCheckBox
|
||||
|
||||
void updateValue()
|
||||
{
|
||||
if (!field)
|
||||
return;
|
||||
lock = true;
|
||||
if (field) {
|
||||
setChecked(*field);
|
||||
}
|
||||
setChecked(*field);
|
||||
lock = false;
|
||||
}
|
||||
|
||||
signals:
|
||||
void currentDataChanged(bool value);
|
||||
|
||||
protected slots:
|
||||
void onToggled(bool checked)
|
||||
{
|
||||
if (panel && panel->lock)
|
||||
return;
|
||||
if (field && !lock) {
|
||||
*field = checked;
|
||||
if (panel) {
|
||||
emit currentDataChanged(checked);
|
||||
if (panel)
|
||||
emit panel->modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
bool * field;
|
||||
ModelPanel * panel;
|
||||
bool lock;
|
||||
bool *field = nullptr;
|
||||
GenericPanel *panel = nullptr;
|
||||
bool lock = false;
|
||||
};
|
||||
|
||||
@@ -28,8 +28,13 @@ class AutoComboBox: public QComboBox
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AutoComboBox(QWidget *parent = nullptr):
|
||||
QComboBox(parent)
|
||||
explicit AutoComboBox(QWidget * parent = nullptr):
|
||||
QComboBox(parent),
|
||||
field(nullptr),
|
||||
panel(nullptr),
|
||||
next(0),
|
||||
lock(false),
|
||||
hasModel(false)
|
||||
{
|
||||
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
|
||||
}
|
||||
@@ -69,14 +74,14 @@ class AutoComboBox: public QComboBox
|
||||
}
|
||||
}
|
||||
|
||||
void setField(unsigned int & field, GenericPanel * panel=nullptr)
|
||||
void setField(unsigned int & field, GenericPanel * panel = nullptr)
|
||||
{
|
||||
this->field = (int *)&field;
|
||||
this->panel = panel;
|
||||
updateValue();
|
||||
}
|
||||
|
||||
void setField(int & field, GenericPanel * panel=nullptr)
|
||||
void setField(int & field, GenericPanel * panel = nullptr)
|
||||
{
|
||||
this->field = &field;
|
||||
this->panel = panel;
|
||||
@@ -122,16 +127,16 @@ class AutoComboBox: public QComboBox
|
||||
const int val = itemData(index).toInt();
|
||||
if (field && !lock) {
|
||||
*field = val;
|
||||
emit currentDataChanged(val);
|
||||
if (panel)
|
||||
emit panel->modified();
|
||||
}
|
||||
emit currentDataChanged(val);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
int * field = nullptr;
|
||||
GenericPanel * panel = nullptr;
|
||||
int *field = nullptr;
|
||||
GenericPanel *panel = nullptr;
|
||||
int next = 0;
|
||||
bool lock = false;
|
||||
bool hasModel = false;
|
||||
|
||||
Reference in New Issue
Block a user