git-svn-id: svn://db.shs.com.ru/libs@243 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -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<PIIODevice * > ds = connection.allDevices();
|
||||
// piForeach(PIIODevice * d, ds) {
|
||||
// if (d)
|
||||
// piCoutObj << d->constructFullPath() << d->isOpened();
|
||||
// }
|
||||
/*PIVector<PIIODevice * > 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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<QTreeWidgetItem * > si = ui->treeK->selectedItems();
|
||||
/*QList<QTreeWidgetItem * > 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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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<QString, int> knames;
|
||||
QSet<int> calculated;
|
||||
QStringList knames_sort;
|
||||
QPIEvaluator eval;
|
||||
SessionManager session;
|
||||
QPIConfig config;
|
||||
CDKItemModel * kmodel;
|
||||
CDKDelegate * delegate;
|
||||
//QVector<float> k, x;
|
||||
int clear_target, timer;
|
||||
bool needWrite, isPause, need_update, show_x;
|
||||
|
||||
@@ -283,68 +283,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="treeK">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<attribute name="headerDefaultSectionSize">
|
||||
<number>200</number>
|
||||
</attribute>
|
||||
<attribute name="headerMinimumSectionSize">
|
||||
<number>20</number>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Index</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Expression</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Calculated</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Comment</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeCDK">
|
||||
<widget class="CDKView" name="treeCDK">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
|
||||
</property>
|
||||
@@ -432,8 +371,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
<width>819</width>
|
||||
<height>613</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
@@ -1248,15 +1187,30 @@
|
||||
<extends>QFrame</extends>
|
||||
<header>graphic.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>clineedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QPIConfigWidget</class>
|
||||
<extends>QTreeWidget</extends>
|
||||
<header>qpiconfigwidget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>clineedit.h</header>
|
||||
<class>CDKView</class>
|
||||
<extends>QTreeView</extends>
|
||||
<header location="global">qcd_kview.h</header>
|
||||
<slots>
|
||||
<signal>busyStatusChanged(bool)</signal>
|
||||
<slot>sendK()</slot>
|
||||
<slot>receiveK()</slot>
|
||||
<slot>saveK()</slot>
|
||||
<slot>loadK()</slot>
|
||||
<slot>clear()</slot>
|
||||
<slot>clearK()</slot>
|
||||
<slot>refresh()</slot>
|
||||
</slots>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
|
||||
Reference in New Issue
Block a user