code format
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "qpiconfigvaluewidget.h"
|
||||
|
||||
#include "qpievaluator_p.h"
|
||||
|
||||
|
||||
@@ -35,44 +36,175 @@ ConfigValueWidget::ConfigValueWidget(QWidget * parent): QWidget(parent), lay(QBo
|
||||
|
||||
void ConfigValueWidget::setType(const QString & t) {
|
||||
hideAll();
|
||||
type = t.left(1);
|
||||
type = t.left(1);
|
||||
active = false;
|
||||
if (type == "e") {QStringList en_sl = QPIEvaluator::inBrackets(comment).split(';');
|
||||
if (en_sl.size()>1) {
|
||||
w_enum.show(); w_enum.addItems(en_sl); setValue(value); active = true; return;
|
||||
} else {type = "s";}}
|
||||
if (type == "s") {w_string.show(); setValue(value); active = true; return;}
|
||||
if (type == "l") {w_list.show(); setValue(value); active = true; return;}
|
||||
if (type == "b") {w_bool.show(); setValue(value); active = true; return;}
|
||||
if (type == "n") {w_integer.show(); setValue(value); active = true; return;}
|
||||
if (type == "f") {w_float.show(); setValue(value); active = true; return;}
|
||||
if (type == "c") {w_color.show(); setValue(value); active = true; return;}
|
||||
if (type == "r") {w_rect.show(); w_rect.setDecimals(0); setValue(value); active = true; return;}
|
||||
if (type == "a") {w_rect.show(); w_rect.setDecimals(3); setValue(value); active = true; return;}
|
||||
if (type == "p") {w_point.show(); w_point.setDecimals(0); setValue(value); active = true; return;}
|
||||
if (type == "v") {w_point.show(); w_point.setDecimals(3); setValue(value); active = true; return;}
|
||||
if (type == "i") {w_ip.show(); setValue(value); active = true; return;}
|
||||
if (type == "F") {w_path.show(); setValue(value); active = true; return;}
|
||||
if (type == "D") {w_path.show(); setValue(value); active = true; return;}
|
||||
if (type == "e") {
|
||||
QStringList en_sl = QPIEvaluator::inBrackets(comment).split(';');
|
||||
if (en_sl.size() > 1) {
|
||||
w_enum.show();
|
||||
w_enum.addItems(en_sl);
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
} else {
|
||||
type = "s";
|
||||
}
|
||||
}
|
||||
if (type == "s") {
|
||||
w_string.show();
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "l") {
|
||||
w_list.show();
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "b") {
|
||||
w_bool.show();
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "n") {
|
||||
w_integer.show();
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "f") {
|
||||
w_float.show();
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "c") {
|
||||
w_color.show();
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "r") {
|
||||
w_rect.show();
|
||||
w_rect.setDecimals(0);
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "a") {
|
||||
w_rect.show();
|
||||
w_rect.setDecimals(3);
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "p") {
|
||||
w_point.show();
|
||||
w_point.setDecimals(0);
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "v") {
|
||||
w_point.show();
|
||||
w_point.setDecimals(3);
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "i") {
|
||||
w_ip.show();
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "F") {
|
||||
w_path.show();
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "D") {
|
||||
w_path.show();
|
||||
setValue(value);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ConfigValueWidget::setValue(const QString & v) {
|
||||
value = v;
|
||||
value = v;
|
||||
active = false;
|
||||
if (type == "l") {w_list.setValue(v.split("%|%")); active = true; return;}
|
||||
if (type == "b") {w_bool.setChecked(v.toInt() > 0 || v.toLower().trimmed() == "true"); active = true; return;}
|
||||
if (type == "n") {w_integer.setValue(QString2int(v)); active = true; return;}
|
||||
if (type == "f") {w_float.setValue(v.toDouble()); active = true; return;}
|
||||
if (type == "c") {w_color.setColor(QString2QColor(v)); active = true; return;}
|
||||
if (type == "r") {w_rect.setValue(QString2QRectF(v)); active = true; return;}
|
||||
if (type == "a") {w_rect.setValue(QString2QRectF(v)); active = true; return;}
|
||||
if (type == "p") {w_point.setValue(QString2QPointF(v)); active = true; return;}
|
||||
if (type == "v") {w_point.setValue(QString2QPointF(v)); active = true; return;}
|
||||
if (type == "i") {w_ip.setIP(v); active = true; return;}
|
||||
if (type == "e") {w_enum.setCurrentIndex(w_enum.findText(v)); active = true; return;}
|
||||
if (type == "F") {w_path.is_dir = false; w_path.setValue(v); active = true; return;}
|
||||
if (type == "D") {w_path.is_dir = true; w_path.setValue(v); active = true; return;}
|
||||
if (type == "l") {
|
||||
w_list.setValue(v.split("%|%"));
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "b") {
|
||||
w_bool.setChecked(v.toInt() > 0 || v.toLower().trimmed() == "true");
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "n") {
|
||||
w_integer.setValue(QString2int(v));
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "f") {
|
||||
w_float.setValue(v.toDouble());
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "c") {
|
||||
w_color.setColor(QString2QColor(v));
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "r") {
|
||||
w_rect.setValue(QString2QRectF(v));
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "a") {
|
||||
w_rect.setValue(QString2QRectF(v));
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "p") {
|
||||
w_point.setValue(QString2QPointF(v));
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "v") {
|
||||
w_point.setValue(QString2QPointF(v));
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "i") {
|
||||
w_ip.setIP(v);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "e") {
|
||||
w_enum.setCurrentIndex(w_enum.findText(v));
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "F") {
|
||||
w_path.is_dir = false;
|
||||
w_path.setValue(v);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
if (type == "D") {
|
||||
w_path.is_dir = true;
|
||||
w_path.setValue(v);
|
||||
active = true;
|
||||
return;
|
||||
}
|
||||
w_string.setText(v);
|
||||
active = true;
|
||||
}
|
||||
@@ -80,19 +212,71 @@ void ConfigValueWidget::setValue(const QString & v) {
|
||||
|
||||
void ConfigValueWidget::valueChanged() {
|
||||
if (!active) return;
|
||||
if (type == "l") {value = w_list.value().join("%|%"); emit changed(this, value); return;}
|
||||
if (type == "b") {value = w_bool.isChecked() ? "true" : "false"; emit changed(this, value); return;}
|
||||
if (type == "n") {value = QString::number(w_integer.value()); emit changed(this, value); return;}
|
||||
if (type == "f") {value = QString::number(w_float.value()); emit changed(this, value); return;}
|
||||
if (type == "c") {value = QColor2QString(w_color.color()); emit changed(this, value); return;}
|
||||
if (type == "r") {value = QRectF2QString(w_rect.value()); emit changed(this, value); return;}
|
||||
if (type == "a") {value = QRectF2QString(w_rect.value()); emit changed(this, value); return;}
|
||||
if (type == "p") {value = QPointF2QString(w_point.value()); emit changed(this, value); return;}
|
||||
if (type == "v") {value = QPointF2QString(w_point.value()); emit changed(this, value); return;}
|
||||
if (type == "i") {value = w_ip.IP(); emit changed(this, value); return;}
|
||||
if (type == "e") {value = w_enum.currentText(); emit changed(this, value); return;}
|
||||
if (type == "F") {value = w_path.value(); emit changed(this, value); return;}
|
||||
if (type == "D") {value = w_path.value(); emit changed(this, value); return;}
|
||||
if (type == "l") {
|
||||
value = w_list.value().join("%|%");
|
||||
emit changed(this, value);
|
||||
return;
|
||||
}
|
||||
if (type == "b") {
|
||||
value = w_bool.isChecked() ? "true" : "false";
|
||||
emit changed(this, value);
|
||||
return;
|
||||
}
|
||||
if (type == "n") {
|
||||
value = QString::number(w_integer.value());
|
||||
emit changed(this, value);
|
||||
return;
|
||||
}
|
||||
if (type == "f") {
|
||||
value = QString::number(w_float.value());
|
||||
emit changed(this, value);
|
||||
return;
|
||||
}
|
||||
if (type == "c") {
|
||||
value = QColor2QString(w_color.color());
|
||||
emit changed(this, value);
|
||||
return;
|
||||
}
|
||||
if (type == "r") {
|
||||
value = QRectF2QString(w_rect.value());
|
||||
emit changed(this, value);
|
||||
return;
|
||||
}
|
||||
if (type == "a") {
|
||||
value = QRectF2QString(w_rect.value());
|
||||
emit changed(this, value);
|
||||
return;
|
||||
}
|
||||
if (type == "p") {
|
||||
value = QPointF2QString(w_point.value());
|
||||
emit changed(this, value);
|
||||
return;
|
||||
}
|
||||
if (type == "v") {
|
||||
value = QPointF2QString(w_point.value());
|
||||
emit changed(this, value);
|
||||
return;
|
||||
}
|
||||
if (type == "i") {
|
||||
value = w_ip.IP();
|
||||
emit changed(this, value);
|
||||
return;
|
||||
}
|
||||
if (type == "e") {
|
||||
value = w_enum.currentText();
|
||||
emit changed(this, value);
|
||||
return;
|
||||
}
|
||||
if (type == "F") {
|
||||
value = w_path.value();
|
||||
emit changed(this, value);
|
||||
return;
|
||||
}
|
||||
if (type == "D") {
|
||||
value = w_path.value();
|
||||
emit changed(this, value);
|
||||
return;
|
||||
}
|
||||
value = w_string.text();
|
||||
emit changed(this, value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user