Companion switches / anas names configuration

This commit is contained in:
bsongis
2014-11-21 19:32:41 +01:00
parent 06437b2954
commit 50978c15c5
21 changed files with 1206 additions and 297 deletions
+60
View File
@@ -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_ */