git-svn-id: svn://db.shs.com.ru/libs@81 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -31,7 +31,7 @@ if (NOT DEFINED ENV{QNX_HOST})
|
|||||||
qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw)
|
qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw)
|
||||||
qt4_wrap_ui(CUIS ${UIS})
|
qt4_wrap_ui(CUIS ${UIS})
|
||||||
qt4_add_resources(RESS ${RES})
|
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)
|
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)
|
find_package(OpenGL REQUIRED)
|
||||||
list(APPEND LIBS ${OPENGL_LIBRARIES})
|
list(APPEND LIBS ${OPENGL_LIBRARIES})
|
||||||
|
|||||||
@@ -16,25 +16,21 @@ double randomn(double dv, double sv) {
|
|||||||
void BrickBase::Parameter::setValue(const PIVariant & v, bool withType) {
|
void BrickBase::Parameter::setValue(const PIVariant & v, bool withType) {
|
||||||
value = v;
|
value = v;
|
||||||
if (withType) {
|
if (withType) {
|
||||||
switch (v.type()) {
|
PIString tn = v.typeName();
|
||||||
case PIVariant::Bool: type = BrickBase::Bool; return;
|
if (tn == "bool") {type = BrickBase::Bool; return;}
|
||||||
case PIVariant::Char: type = BrickBase::Integer; return;
|
if (tn == "char") {type = BrickBase::Integer; return;}
|
||||||
case PIVariant::Short: type = BrickBase::Integer; return;
|
if (tn == "uchar") {type = BrickBase::Integer; return;}
|
||||||
case PIVariant::Int: type = BrickBase::Integer; return;
|
if (tn == "short") {type = BrickBase::Integer; return;}
|
||||||
case PIVariant::Long: type = BrickBase::Integer; return;
|
if (tn == "ushort") {type = BrickBase::Integer; return;}
|
||||||
case PIVariant::LLong: type = BrickBase::Integer; return;
|
if (tn == "int") {type = BrickBase::Integer; return;}
|
||||||
case PIVariant::UChar: type = BrickBase::Integer; return;
|
if (tn == "uint") {type = BrickBase::Integer; return;}
|
||||||
case PIVariant::UShort: type = BrickBase::Integer; return;
|
if (tn == "llong") {type = BrickBase::Integer; return;}
|
||||||
case PIVariant::UInt: type = BrickBase::Integer; return;
|
if (tn == "ullong") {type = BrickBase::Integer; return;}
|
||||||
case PIVariant::ULong: type = BrickBase::Integer; return;
|
if (tn == "float") {type = BrickBase::Float; return;}
|
||||||
case PIVariant::ULLong: type = BrickBase::Integer; return;
|
if (tn == "double") {type = BrickBase::Float; return;}
|
||||||
case PIVariant::Float: type = BrickBase::Float; return;
|
if (tn == "ldouble") {type = BrickBase::Float; return;}
|
||||||
case PIVariant::Double: type = BrickBase::Float; return;
|
if (tn == "PIString") {type = BrickBase::String; return;}
|
||||||
case PIVariant::LDouble: type = BrickBase::Float; return;
|
if (tn == "PIStringList") {type = BrickBase::String; return;}
|
||||||
case PIVariant::String: type = BrickBase::String; return;
|
|
||||||
case PIVariant::StringList: type = BrickBase::String; return;
|
|
||||||
default: break;
|
|
||||||
};
|
|
||||||
}/* else {
|
}/* else {
|
||||||
switch (v.type()) {
|
switch (v.type()) {
|
||||||
case PIVariant::Bool: value.vBool = v.vBool; return;
|
case PIVariant::Bool: value.vBool = v.vBool; return;
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ void EMainWindow::openFile() {
|
|||||||
|
|
||||||
bool EMainWindow::saveFile(bool ask) {
|
bool EMainWindow::saveFile(bool ask) {
|
||||||
if (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::Cancel) return false;
|
||||||
if (ret == QMessageBox::Save) return saveFile();
|
if (ret == QMessageBox::Save) return saveFile();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ void BlockView::_init() {
|
|||||||
scene_->setSceneRect(-2500, -2500, 5000, 5000);
|
scene_->setSceneRect(-2500, -2500, 5000, 5000);
|
||||||
scene_->setItemIndexMethod(QGraphicsScene::NoIndex);
|
scene_->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||||
scene_->installEventFilter(this);
|
scene_->installEventFilter(this);
|
||||||
scene_->addItem(&sel_rect);
|
|
||||||
scene_->addItem(&tmp_bus);
|
scene_->addItem(&tmp_bus);
|
||||||
widget_thumb.setParent(this);
|
widget_thumb.setParent(this);
|
||||||
//widget_thumb.setAutoFillBackground(true);
|
//widget_thumb.setAutoFillBackground(true);
|
||||||
@@ -369,6 +368,7 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
|||||||
sel_rect.setRect(QRectF(scene_point, me->scenePos()).normalized());
|
sel_rect.setRect(QRectF(scene_point, me->scenePos()).normalized());
|
||||||
if (fmm_drag) {
|
if (fmm_drag) {
|
||||||
if (mm_ci == 0) {
|
if (mm_ci == 0) {
|
||||||
|
scene_->addItem(&sel_rect);
|
||||||
sel_rect.show();
|
sel_rect.show();
|
||||||
if (!mm_mods.testFlag(Qt::ControlModifier))
|
if (!mm_mods.testFlag(Qt::ControlModifier))
|
||||||
clearSelection();
|
clearSelection();
|
||||||
@@ -516,6 +516,8 @@ bool BlockView::eventFilter(QObject * o, QEvent * e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sel_rect.hide();
|
sel_rect.hide();
|
||||||
|
if (sel_rect.scene())
|
||||||
|
scene_->removeItem(&sel_rect);
|
||||||
mm_drag = false;
|
mm_drag = false;
|
||||||
mm_ci = 0;
|
mm_ci = 0;
|
||||||
unsetCursor();
|
unsetCursor();
|
||||||
|
|||||||
@@ -35,7 +35,24 @@ void SQLRecordWidget::setRecord(const QSqlRecord & q, bool full_update) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (val == 0) continue;
|
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<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<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()));
|
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(";"));
|
qobject_cast<StringListEdit * >(val)->setValue(s.isEmpty() ? QStringList() : s.split(";"));
|
||||||
}
|
}
|
||||||
if (qobject_cast<QComboBox * >(val)) {
|
if (qobject_cast<QComboBox * >(val)) {
|
||||||
QList<QPair<int, QString> > & rv(relations[f.name()]);
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
int sv(f.value().toInt(&ok));
|
int sv(f.value().toInt(&ok));
|
||||||
if (!ok)
|
if (!ok)
|
||||||
((QComboBox*)val)->setCurrentIndex(-1);
|
((QComboBox*)val)->setCurrentIndex(-1);
|
||||||
else {
|
else {
|
||||||
|
QList<QPair<int, QString> > & rv(relations[f.name()]);
|
||||||
for (int j = 0; j < rv.size(); ++j) {
|
for (int j = 0; j < rv.size(); ++j) {
|
||||||
if (sv == rv[j].first) {
|
if (sv == rv[j].first) {
|
||||||
((QComboBox*)val)->setCurrentIndex(j);
|
((QComboBox*)val)->setCurrentIndex(j);
|
||||||
@@ -102,18 +119,22 @@ void SQLRecordWidget::createWidgets(const QSqlRecord & q) {
|
|||||||
QPair<QString, QString> ctr = trColumn(f.name());
|
QPair<QString, QString> ctr = trColumn(f.name());
|
||||||
QWidget * val = 0;
|
QWidget * val = 0;
|
||||||
if (relations.contains(f.name())) {
|
if (relations.contains(f.name())) {
|
||||||
val = new QComboBox();
|
if (ro) {
|
||||||
QList<QPair<int, QString> > & rv(relations[f.name()]);
|
val = new QLineEdit();
|
||||||
bool ok = false;
|
} else {
|
||||||
int sv(f.value().toInt(&ok));
|
val = new QComboBox();
|
||||||
for (int j = 0; j < rv.size(); ++j) {
|
QList<QPair<int, QString> > & rv(relations[f.name()]);
|
||||||
((QComboBox*)val)->addItem(rv[j].second, rv[j].first);
|
bool ok = false;
|
||||||
if (ok)
|
int sv(f.value().toInt(&ok));
|
||||||
if (sv == rv[j].first)
|
for (int j = 0; j < rv.size(); ++j) {
|
||||||
((QComboBox*)val)->setCurrentIndex(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 {
|
} else {
|
||||||
switch (fieldType(f)) {
|
switch (fieldType(f)) {
|
||||||
case QVariant::Int:
|
case QVariant::Int:
|
||||||
@@ -166,6 +187,7 @@ void SQLRecordWidget::updateWidgets() {
|
|||||||
if (qobject_cast<QDoubleSpinBox * >(w)) qobject_cast<QDoubleSpinBox * >(w)->setReadOnly(ro);
|
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<ColorButton * >(w)) qobject_cast<ColorButton * >(w)->setEnabled(!ro);
|
||||||
if (qobject_cast<StringListEdit * >(w)) qobject_cast<StringListEdit * >(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))
|
if (qobject_cast<StringListEdit * >(w))
|
||||||
ret += "'" + qobject_cast<StringListEdit * >(w)->value().join(";") + "'";
|
ret += "'" + qobject_cast<StringListEdit * >(w)->value().join(";") + "'";
|
||||||
if (qobject_cast<QComboBox * >(w)) {
|
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;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user