From 853d907725739d944fd01f9dbf76bf2389477b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Thu, 22 Jun 2017 13:24:39 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/libs@243 a8b55f48-bf90-11e4-a774-851b48703e85 --- cd_utils/cdutils_core.cpp | 30 +++++++------ cd_utils/cdutils_core.h | 1 + qcd_utils/pult/cd_pult.cpp | 71 ++++-------------------------- qcd_utils/pult/cd_pult.h | 7 --- qcd_utils/pult/cd_pult.ui | 88 +++++++++----------------------------- 5 files changed, 47 insertions(+), 150 deletions(-) diff --git a/cd_utils/cdutils_core.cpp b/cd_utils/cdutils_core.cpp index e2e21e6..5c83e47 100644 --- a/cd_utils/cdutils_core.cpp +++ b/cd_utils/cdutils_core.cpp @@ -62,8 +62,7 @@ CDCore::CDCore() { /*PIString s(app_config); connection.configureFromString(&s); connection.start();*/ - k_.name = "__root__"; - k_.alias = "root"; + initRoot(k_); CONNECTU(&datatr, sendRequest, this, dtSendRequest) CONNECTU(&datatr, receiveFinished, this, dtReceiveFinished) @@ -99,22 +98,20 @@ void CDCore::k_write(PIIODevice * d) { void CDCore::k_read(PIIODevice * d) { PIConfig conf(d, PIIODevice::ReadOnly); k_.read(&(conf.rootEntry())); - k_.makePath(); + initRoot(k_); K_ChangedGlobal(); - PIVector ds = connection.allDevices(); -// piForeach(PIIODevice * d, ds) { -// if (d) -// piCoutObj << d->constructFullPath() << d->isOpened(); -// } + /*PIVector ds = connection.allDevices(); + piForeach(PIIODevice * d, ds) { + if (d) + piCoutObj << d->constructFullPath() << d->isOpened(); + }*/ } void CDCore::k_parse(PIIODevice * d) { k_ = CDParser::parse(d, CDType::cdK); - k_.makePath(); + initRoot(k_); K_ChangedGlobal(); - k_.name = "__root__"; - k_.alias = "root"; } @@ -130,8 +127,7 @@ void CDCore::k_update(PIIODevice * d, UpdateModeFlags mode) { uk.update(k_, mode); //piCout << k_.count() << uk.count(); k_ = uk; - k_.makePath(); - k_.calculate(); + initRoot(k_); K_ChangedGlobal(); } @@ -261,6 +257,14 @@ void CDCore::xTimerTick() { } +void CDCore::initRoot(CDSection & r) { + r.name = "__root__"; + r.alias = "root"; + r.makePath(); + r.calculate(); +} + + void CDCore::dtSendRequest(PIByteArray &data) { connection.writeByName("cd", data); // piCoutObj << "send" << data.size() << ret; diff --git a/cd_utils/cdutils_core.h b/cd_utils/cdutils_core.h index 87756b4..07d0f43 100644 --- a/cd_utils/cdutils_core.h +++ b/cd_utils/cdutils_core.h @@ -62,6 +62,7 @@ private: EVENT_HANDLER1(void, dtReceiveFinished, bool, ok); EVENT_HANDLER(void, sendThread); EVENT_HANDLER(void, xTimerTick); + void initRoot(CDSection & r); static const char app_config[], pult_config[]; PIConnection connection; diff --git a/qcd_utils/pult/cd_pult.cpp b/qcd_utils/pult/cd_pult.cpp index dbf8018..8e06458 100644 --- a/qcd_utils/pult/cd_pult.cpp +++ b/qcd_utils/pult/cd_pult.cpp @@ -18,7 +18,7 @@ config(piqt(config_), QIODevice::ReadWrite) { ui->configWidget->setQPIConfig(&config); ui->configWidget->expandAll(); ui->list->viewport()->installEventFilter(this); - ui->treeK->viewport()->installEventFilter(this); + ui->treeCDK->viewport()->installEventFilter(this); ui->scrollArea->setAutoFillBackground(false); ui->scrollAreaWidgetContents->setAutoFillBackground(false); ui->widget->setAutoFillBackground(false); @@ -42,20 +42,16 @@ config(piqt(config_), QIODevice::ReadWrite) { QColor col; ui->graphic->setGraphicsCount(0); //renew(); - ui->treeK->setColumnWidth(0, 60); + /*ui->treeK->setColumnWidth(0, 60); ui->treeK->setColumnWidth(1, 250); ui->treeK->setColumnWidth(3, 100); - ui->treeK->setColumnWidth(4, 100); + ui->treeK->setColumnWidth(4, 100);*/ //ui->table->setK(coeffsK.k()->data(), coeffsK.count()); //addToList(trUtf8("Read K file \"%1\": %2 coeffs, %3 bytes").arg(PI2QString(coeffs.fileName())).arg(K.size_s()).arg(coeffs.k_content.size_s()), Qt::darkMagenta); /*CONNECT(void, &coeffs, sendFailed, this, pip_sendFailed); CONNECT(void, &coeffs, sendSucceed, this, pip_sendSucceed); CONNECT(void, &coeffs, receiveFailed, this, pip_receiveFailed); CONNECT(void, &coeffs, receiveSucceed, this, pip_receiveSucceed);*/ - kmodel = new CDKItemModel(); - ui->treeCDK->setModel(kmodel); - delegate = new CDKDelegate(); - ui->treeCDK->setItemDelegateForColumn(4, delegate); CONNECTU(&K, sended, this, pip_sendSucceed); CONNECTU(&K, sendFailed, this, pip_sendFailed); CONNECTU(&K, received, this, pip_receiveSucceed); @@ -106,7 +102,7 @@ bool CD_Pult::eventFilter(QObject * o, QEvent * e) { } return QMainWindow::eventFilter(o, e); } - if (o == ui->treeK->viewport()) { + if (o == ui->treeCDK->viewport()) { if (e->type() == QEvent::ContextMenu) { clear_target = 1; log_menu.popup(((QContextMenuEvent*)e)->globalPos()); @@ -178,7 +174,7 @@ void CD_Pult::on_actionClear_triggered() { void CD_Pult::clearSelected() { - QList si = ui->treeK->selectedItems(); + /*QList si = ui->treeK->selectedItems(); ui->treeK->setUpdatesEnabled(false); ui->treeK->blockSignals(true); foreach (QTreeWidgetItem * i, si) { @@ -191,7 +187,7 @@ void CD_Pult::clearSelected() { if (ui->checkKAutoCalculate->isChecked()) { QApplication::processEvents(); //calculate(); - } + }*/ } @@ -414,53 +410,6 @@ bool stringComp(const QString & s1, const QString & s2) { void CD_Pult::updateTree(bool move) { - int sp = ui->treeK->verticalScrollBar()->value(); - QApplication::setOverrideCursor(Qt::WaitCursor); - //qDebug() << "fill tree ..."; - ui->treeK->clear(); - ui->treeK->setUpdatesEnabled(false); - eval.clearCustomVariables(); - CDSection r = K.root(); - makeTreeSection(r, ui->treeK->invisibleRootItem()); - /*for (int i = 0; i < K.size_s(); ++i) { - QTreeWidgetItem * ti = new QTreeWidgetItem(); - KDesc kd = kdesc[i]; - QString kn = QString("k%1").arg(i); - knames[kn] = i; - knames_sort << kn; - if (eval.content.findVariable(kn) < 0) - eval.content.addVariable(kn, 0., false); - if (!kd.name.isEmpty()) { - knames[kd.name] = i; - knames_sort << kd.name; - eval.content.addVariable(kd.name, 0., false); - } - if (move && !kd.name.isEmpty()) { - if (prev_val.contains(kd.name)) - coeffs.setFormula(i, Q2PIString(prev_val[kd.name])); - } - ti->setText(0, QString::number(i)); - ti->setText(1, kd.name); - ti->setText(2, PI2QString(coeffs.formula(i))); - ti->setText(3, QString::number(K[i])); - ti->setText(4, typeName(kd.type)); - ti->setText(5, kd.comment); - ui->treeK->addTopLevelItem(ti); - }*/ - eval.content.sortVariables(); - //qDebug() << "fill tree ok"; - //qDebug() << "sort ..."; - qSort(knames_sort.begin(), knames_sort.end(), stringComp); - //qDebug() << "names" << knames_sort; - //qDebug() << "sort ok"; - QApplication::restoreOverrideCursor(); - ui->treeK->setUpdatesEnabled(true); - ui->treeK->verticalScrollBar()->setValue(sp); - //calculate(); - filterTree(); - kmodel->rebuildModel(); - ui->treeCDK->expandAll(); - for (int i=0; i<6; i++) ui->treeCDK->resizeColumnToContents(i); } @@ -484,7 +433,7 @@ void CD_Pult::updateCommands() { void CD_Pult::filterTree() { - bool hn = ui->checkKHideNormal->isChecked(); + /*bool hn = ui->checkKHideNormal->isChecked(); bool hs = ui->checkKHideExpressions->isChecked(); bool ok = false; QString fl = ui->lineKSearch->text(); @@ -507,7 +456,7 @@ void CD_Pult::filterTree() { if (!ok) ti->setHidden(true); } - } + }*/ } @@ -535,10 +484,6 @@ void CD_Pult::markNormal(QTreeWidgetItem * item) { void CD_Pult::progress(int val, int max) { - if (ctm.elapsed() < 50) return; - ctm.restart(); - ui->progress->setValue(qRound(val * 100. / max)); - QApplication::processEvents(); } diff --git a/qcd_utils/pult/cd_pult.h b/qcd_utils/pult/cd_pult.h index 56b1326..8c2d274 100644 --- a/qcd_utils/pult/cd_pult.h +++ b/qcd_utils/pult/cd_pult.h @@ -62,16 +62,9 @@ private: PIString config_, name_x, name_c; PIString kdesc_file, cdesc_file, xdesc_file; QMenu log_menu; - QTime tm, ctm; QTimer timer_diag; - QMap knames; - QSet calculated; - QStringList knames_sort; - QPIEvaluator eval; SessionManager session; QPIConfig config; - CDKItemModel * kmodel; - CDKDelegate * delegate; //QVector k, x; int clear_target, timer; bool needWrite, isPause, need_update, show_x; diff --git a/qcd_utils/pult/cd_pult.ui b/qcd_utils/pult/cd_pult.ui index 3ac47b1..7cd129f 100644 --- a/qcd_utils/pult/cd_pult.ui +++ b/qcd_utils/pult/cd_pult.ui @@ -283,68 +283,7 @@ - - - Qt::CustomContextMenu - - - QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed - - - true - - - QAbstractItemView::ExtendedSelection - - - QAbstractItemView::ScrollPerPixel - - - QAbstractItemView::ScrollPerPixel - - - 6 - - - 200 - - - 20 - - - - Index - - - - - Name - - - - - Type - - - - - Expression - - - - - Calculated - - - - - Comment - - - - - - + QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed @@ -432,8 +371,8 @@ 0 0 - 100 - 30 + 819 + 613 @@ -1248,15 +1187,30 @@ QFrame
graphic.h
+ + CLineEdit + QLineEdit +
clineedit.h
+
QPIConfigWidget QTreeWidget
qpiconfigwidget.h
- CLineEdit - QLineEdit -
clineedit.h
+ CDKView + QTreeView +
qcd_kview.h
+ + busyStatusChanged(bool) + sendK() + receiveK() + saveK() + loadK() + clear() + clearK() + refresh() +