git-svn-id: svn://db.shs.com.ru/libs@81 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2016-02-25 13:48:19 +00:00
parent 84e62087a1
commit 5aae6c947d
5 changed files with 57 additions and 36 deletions

View File

@@ -31,7 +31,7 @@ if (NOT DEFINED ENV{QNX_HOST})
qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw)
qt4_wrap_ui(CUIS ${UIS})
qt4_add_resources(RESS ${RES})
add_executable(kx_pult ${CPPS} ${CMOCS} ${CUIS} ${RESS})
add_executable(kx_pult WIN32 ${CPPS} ${CMOCS} ${CUIS} ${RESS})
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${PIP_LIBRARY} qad_graphic qad_utils qad_widgets kx_utils)
find_package(OpenGL REQUIRED)
list(APPEND LIBS ${OPENGL_LIBRARIES})

View File

@@ -16,25 +16,21 @@ double randomn(double dv, double sv) {
void BrickBase::Parameter::setValue(const PIVariant & v, bool withType) {
value = v;
if (withType) {
switch (v.type()) {
case PIVariant::Bool: type = BrickBase::Bool; return;
case PIVariant::Char: type = BrickBase::Integer; return;
case PIVariant::Short: type = BrickBase::Integer; return;
case PIVariant::Int: type = BrickBase::Integer; return;
case PIVariant::Long: type = BrickBase::Integer; return;
case PIVariant::LLong: type = BrickBase::Integer; return;
case PIVariant::UChar: type = BrickBase::Integer; return;
case PIVariant::UShort: type = BrickBase::Integer; return;
case PIVariant::UInt: type = BrickBase::Integer; return;
case PIVariant::ULong: type = BrickBase::Integer; return;
case PIVariant::ULLong: type = BrickBase::Integer; return;
case PIVariant::Float: type = BrickBase::Float; return;
case PIVariant::Double: type = BrickBase::Float; return;
case PIVariant::LDouble: type = BrickBase::Float; return;
case PIVariant::String: type = BrickBase::String; return;
case PIVariant::StringList: type = BrickBase::String; return;
default: break;
};
PIString tn = v.typeName();
if (tn == "bool") {type = BrickBase::Bool; return;}
if (tn == "char") {type = BrickBase::Integer; return;}
if (tn == "uchar") {type = BrickBase::Integer; return;}
if (tn == "short") {type = BrickBase::Integer; return;}
if (tn == "ushort") {type = BrickBase::Integer; return;}
if (tn == "int") {type = BrickBase::Integer; return;}
if (tn == "uint") {type = BrickBase::Integer; return;}
if (tn == "llong") {type = BrickBase::Integer; return;}
if (tn == "ullong") {type = BrickBase::Integer; return;}
if (tn == "float") {type = BrickBase::Float; return;}
if (tn == "double") {type = BrickBase::Float; return;}
if (tn == "ldouble") {type = BrickBase::Float; return;}
if (tn == "PIString") {type = BrickBase::String; return;}
if (tn == "PIStringList") {type = BrickBase::String; return;}
}/* else {
switch (v.type()) {
case PIVariant::Bool: value.vBool = v.vBool; return;

View File

@@ -31,7 +31,6 @@ void BlockView::_init() {
scene_->setSceneRect(-2500, -2500, 5000, 5000);
scene_->setItemIndexMethod(QGraphicsScene::NoIndex);
scene_->installEventFilter(this);
scene_->addItem(&sel_rect);
scene_->addItem(&tmp_bus);
widget_thumb.setParent(this);
//widget_thumb.setAutoFillBackground(true);
@@ -369,6 +368,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
sel_rect.setRect(QRectF(scene_point, me->scenePos()).normalized());
if (fmm_drag) {
if (mm_ci == 0) {
scene_->addItem(&sel_rect);
sel_rect.show();
if (!mm_mods.testFlag(Qt::ControlModifier))
clearSelection();
@@ -516,6 +516,8 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
}
}
sel_rect.hide();
if (sel_rect.scene())
scene_->removeItem(&sel_rect);
mm_drag = false;
mm_ci = 0;
unsetCursor();

View File

@@ -35,7 +35,24 @@ void SQLRecordWidget::setRecord(const QSqlRecord & q, bool full_update) {
break;
}
if (val == 0) continue;
if (qobject_cast<QLineEdit * >(val)) qobject_cast<QLineEdit * >(val)->setText(f.value().toString());
if (qobject_cast<QLineEdit * >(val)) {
if (relations.contains(f.name())) {
bool ok = false;
int sv(f.value().toInt(&ok));
if (!ok)
qobject_cast<QLineEdit * >(val)->setText("");
else {
QList<QPair<int, QString> > & rv(relations[f.name()]);
for (int j = 0; j < rv.size(); ++j) {
if (sv == rv[j].first) {
qobject_cast<QLineEdit * >(val)->setText(rv[j].second);
break;
}
}
}
} else
qobject_cast<QLineEdit * >(val)->setText(f.value().toString());
}
if (qobject_cast<QCheckBox * >(val)) qobject_cast<QCheckBox * >(val)->setChecked(f.value().toBool());
if (qobject_cast<QDoubleSpinBox * >(val)) qobject_cast<QDoubleSpinBox * >(val)->setValue(f.value().toDouble());
if (qobject_cast<ColorButton * >(val)) qobject_cast<ColorButton * >(val)->setColor(QColor::fromRgba(f.value().toUInt()));
@@ -44,12 +61,12 @@ void SQLRecordWidget::setRecord(const QSqlRecord & q, bool full_update) {
qobject_cast<StringListEdit * >(val)->setValue(s.isEmpty() ? QStringList() : s.split(";"));
}
if (qobject_cast<QComboBox * >(val)) {
QList<QPair<int, QString> > & rv(relations[f.name()]);
bool ok = false;
int sv(f.value().toInt(&ok));
if (!ok)
((QComboBox*)val)->setCurrentIndex(-1);
else {
QList<QPair<int, QString> > & rv(relations[f.name()]);
for (int j = 0; j < rv.size(); ++j) {
if (sv == rv[j].first) {
((QComboBox*)val)->setCurrentIndex(j);
@@ -102,6 +119,9 @@ void SQLRecordWidget::createWidgets(const QSqlRecord & q) {
QPair<QString, QString> ctr = trColumn(f.name());
QWidget * val = 0;
if (relations.contains(f.name())) {
if (ro) {
val = new QLineEdit();
} else {
val = new QComboBox();
QList<QPair<int, QString> > & rv(relations[f.name()]);
bool ok = false;
@@ -114,6 +134,7 @@ void SQLRecordWidget::createWidgets(const QSqlRecord & q) {
}
if (!ok)
((QComboBox*)val)->setCurrentIndex(-1);
}
} else {
switch (fieldType(f)) {
case QVariant::Int:
@@ -166,6 +187,7 @@ void SQLRecordWidget::updateWidgets() {
if (qobject_cast<QDoubleSpinBox * >(w)) qobject_cast<QDoubleSpinBox * >(w)->setReadOnly(ro);
if (qobject_cast<ColorButton * >(w)) qobject_cast<ColorButton * >(w)->setEnabled(!ro);
if (qobject_cast<StringListEdit * >(w)) qobject_cast<StringListEdit * >(w)->setEnabled(!ro);
if (qobject_cast<QComboBox * >(w)) qobject_cast<QComboBox * >(w)->setEnabled(!ro);
}
}
@@ -285,7 +307,8 @@ QString SQLRecordWidget::getUpdateQuery() const {
if (qobject_cast<StringListEdit * >(w))
ret += "'" + qobject_cast<StringListEdit * >(w)->value().join(";") + "'";
if (qobject_cast<QComboBox * >(w)) {
ret += ((QComboBox*)w)->itemData(((QComboBox*)w)->currentIndex(), Qt::UserRole).toString();
QString cd = ((QComboBox*)w)->itemData(((QComboBox*)w)->currentIndex(), Qt::UserRole).toString();
ret += cd.isEmpty() ? "null" : cd;
}
}
return ret;