Companion switches / anas names configuration
This commit is contained in:
@@ -12,6 +12,7 @@ set(shared_HDRS
|
||||
autocombobox.h
|
||||
autodoublespinbox.h
|
||||
autohexspinbox.h
|
||||
autolineedit.h
|
||||
genericpanel.h
|
||||
hexspinbox.h
|
||||
verticalscrollarea.h
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define AUTOCOMBOBOX_H_
|
||||
|
||||
#include <QComboBox>
|
||||
#include "modeledit/modeledit.h"
|
||||
#include "genericpanel.h"
|
||||
|
||||
class AutoComboBox: public QComboBox
|
||||
{
|
||||
@@ -35,7 +35,7 @@ class AutoComboBox: public QComboBox
|
||||
lock = false;
|
||||
}
|
||||
|
||||
void setField(unsigned int & field, ModelPanel * panel=NULL)
|
||||
void setField(unsigned int & field, GenericPanel * panel=NULL)
|
||||
{
|
||||
this->field = (int *)&field;
|
||||
this->panel = panel;
|
||||
@@ -46,7 +46,7 @@ class AutoComboBox: public QComboBox
|
||||
}
|
||||
}
|
||||
|
||||
void setField(int & field, ModelPanel * panel=NULL)
|
||||
void setField(int & field, GenericPanel * panel=NULL)
|
||||
{
|
||||
this->field = &field;
|
||||
this->panel = panel;
|
||||
@@ -70,7 +70,7 @@ class AutoComboBox: public QComboBox
|
||||
|
||||
protected:
|
||||
int * field;
|
||||
ModelPanel * panel;
|
||||
GenericPanel * panel;
|
||||
bool lock;
|
||||
};
|
||||
|
||||
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#ifndef AUTOLINEEDIT_H_
|
||||
#define AUTOLINEEDIT_H_
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QRegExpValidator>
|
||||
#include "genericpanel.h"
|
||||
|
||||
#define CHAR_FOR_NAMES_REGEX "[ A-Za-z0-9_.-,]*"
|
||||
|
||||
class AutoLineEdit: public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AutoLineEdit(QWidget *parent = 0):
|
||||
QLineEdit(parent),
|
||||
field(NULL),
|
||||
panel(NULL),
|
||||
lock(false)
|
||||
{
|
||||
QRegExp rx(CHAR_FOR_NAMES_REGEX);
|
||||
setValidator(new QRegExpValidator(rx, this));
|
||||
connect(this, SIGNAL(editingFinished()), this, SLOT(onEdited()));
|
||||
}
|
||||
|
||||
void setField(char * field, int len, GenericPanel * panel=NULL)
|
||||
{
|
||||
this->field = field;
|
||||
this->panel = panel;
|
||||
setMaxLength(len);
|
||||
updateValue();
|
||||
}
|
||||
|
||||
void updateValue()
|
||||
{
|
||||
lock = true;
|
||||
if (field) {
|
||||
setText(field);
|
||||
}
|
||||
lock = false;
|
||||
}
|
||||
|
||||
protected slots:
|
||||
void onEdited()
|
||||
{
|
||||
if (field && !lock) {
|
||||
strcpy(field, text().toAscii());
|
||||
if (panel) {
|
||||
emit panel->modified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
char * field;
|
||||
GenericPanel * panel;
|
||||
bool lock;
|
||||
};
|
||||
|
||||
#endif /* AUTOLINEEDIT_H_ */
|
||||
@@ -17,6 +17,7 @@ class GenericPanel : public QWidget
|
||||
friend class AutoDoubleSpinBox;
|
||||
friend class AutoCheckBox;
|
||||
friend class AutoHexSpinBox;
|
||||
friend class AutoLineEdit;
|
||||
|
||||
public:
|
||||
GenericPanel(QWidget *parent, ModelData * model, GeneralSettings & generalSettings, FirmwareInterface * firmware);
|
||||
|
||||
Reference in New Issue
Block a user