diff --git a/kx_tools/CMakeLists.txt b/kx_tools/CMakeLists.txt index 7658183..a146224 100644 --- a/kx_tools/CMakeLists.txt +++ b/kx_tools/CMakeLists.txt @@ -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}) diff --git a/mbricks/brick_base.cpp b/mbricks/brick_base.cpp index 43ee10e..310a630 100644 --- a/mbricks/brick_base.cpp +++ b/mbricks/brick_base.cpp @@ -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; diff --git a/qad_application/emainwindow.cpp b/qad_application/emainwindow.cpp index d37b534..947c049 100644 --- a/qad_application/emainwindow.cpp +++ b/qad_application/emainwindow.cpp @@ -306,7 +306,7 @@ void EMainWindow::openFile() { bool EMainWindow::saveFile(bool ask) { if (ask) { - int ret = QMessageBox::question(this, windowTitle(), trUtf8("Save changes%1?").arg(!file_name.isEmpty() ? (trUtf8("in") + " \"" + file_name + "\"") : ""), QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save); + int ret = QMessageBox::question(this, windowTitle(), trUtf8("Save changes%1?").arg(!file_name.isEmpty() ? (trUtf8(" in") + " \"" + file_name + "\"") : ""), QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Save); if (ret == QMessageBox::Cancel) return false; if (ret == QMessageBox::Save) return saveFile(); return true; diff --git a/qad_blockview/blockview.cpp b/qad_blockview/blockview.cpp index 916db98..3593d93 100644 --- a/qad_blockview/blockview.cpp +++ b/qad_blockview/blockview.cpp @@ -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(); diff --git a/qad_sql_table/sql_record_widget.cpp b/qad_sql_table/sql_record_widget.cpp index 1ce2683..eac9bdc 100644 --- a/qad_sql_table/sql_record_widget.cpp +++ b/qad_sql_table/sql_record_widget.cpp @@ -35,7 +35,24 @@ void SQLRecordWidget::setRecord(const QSqlRecord & q, bool full_update) { break; } if (val == 0) continue; - if (qobject_cast(val)) qobject_cast(val)->setText(f.value().toString()); + if (qobject_cast(val)) { + if (relations.contains(f.name())) { + bool ok = false; + int sv(f.value().toInt(&ok)); + if (!ok) + qobject_cast(val)->setText(""); + else { + QList > & rv(relations[f.name()]); + for (int j = 0; j < rv.size(); ++j) { + if (sv == rv[j].first) { + qobject_cast(val)->setText(rv[j].second); + break; + } + } + } + } else + qobject_cast(val)->setText(f.value().toString()); + } if (qobject_cast(val)) qobject_cast(val)->setChecked(f.value().toBool()); if (qobject_cast(val)) qobject_cast(val)->setValue(f.value().toDouble()); if (qobject_cast(val)) qobject_cast(val)->setColor(QColor::fromRgba(f.value().toUInt())); @@ -44,12 +61,12 @@ void SQLRecordWidget::setRecord(const QSqlRecord & q, bool full_update) { qobject_cast(val)->setValue(s.isEmpty() ? QStringList() : s.split(";")); } if (qobject_cast(val)) { - QList > & rv(relations[f.name()]); bool ok = false; int sv(f.value().toInt(&ok)); if (!ok) ((QComboBox*)val)->setCurrentIndex(-1); else { + QList > & rv(relations[f.name()]); for (int j = 0; j < rv.size(); ++j) { if (sv == rv[j].first) { ((QComboBox*)val)->setCurrentIndex(j); @@ -102,18 +119,22 @@ void SQLRecordWidget::createWidgets(const QSqlRecord & q) { QPair ctr = trColumn(f.name()); QWidget * val = 0; if (relations.contains(f.name())) { - val = new QComboBox(); - QList > & rv(relations[f.name()]); - bool ok = false; - int sv(f.value().toInt(&ok)); - for (int j = 0; j < rv.size(); ++j) { - ((QComboBox*)val)->addItem(rv[j].second, rv[j].first); - if (ok) - if (sv == rv[j].first) - ((QComboBox*)val)->setCurrentIndex(j); + if (ro) { + val = new QLineEdit(); + } else { + val = new QComboBox(); + QList > & rv(relations[f.name()]); + bool ok = false; + int sv(f.value().toInt(&ok)); + for (int j = 0; j < rv.size(); ++j) { + ((QComboBox*)val)->addItem(rv[j].second, rv[j].first); + if (ok) + if (sv == rv[j].first) + ((QComboBox*)val)->setCurrentIndex(j); + } + if (!ok) + ((QComboBox*)val)->setCurrentIndex(-1); } - if (!ok) - ((QComboBox*)val)->setCurrentIndex(-1); } else { switch (fieldType(f)) { case QVariant::Int: @@ -166,6 +187,7 @@ void SQLRecordWidget::updateWidgets() { if (qobject_cast(w)) qobject_cast(w)->setReadOnly(ro); if (qobject_cast(w)) qobject_cast(w)->setEnabled(!ro); if (qobject_cast(w)) qobject_cast(w)->setEnabled(!ro); + if (qobject_cast(w)) qobject_cast(w)->setEnabled(!ro); } } @@ -285,7 +307,8 @@ QString SQLRecordWidget::getUpdateQuery() const { if (qobject_cast(w)) ret += "'" + qobject_cast(w)->value().join(";") + "'"; if (qobject_cast(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;