git-svn-id: svn://db.shs.com.ru/libs@238 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -118,16 +118,16 @@ void CDCore::k_parse(PIIODevice * d) {
|
||||
}
|
||||
|
||||
|
||||
void CDCore::k_update(PIIODevice * d) {
|
||||
void CDCore::k_update(PIIODevice * d, UpdateModeFlags mode) {
|
||||
CDSection uk = k_;
|
||||
k_parse(d);
|
||||
bool kn = true;
|
||||
/*bool kn = true;
|
||||
if (!uk.isEmpty())
|
||||
if (!uk.isSameStructure(k_)) {
|
||||
piCout << "ask for save names";
|
||||
K_KeepNamesRequest(&kn);
|
||||
}
|
||||
uk.update(k_, kn);
|
||||
}*/
|
||||
uk.update(k_, mode);
|
||||
//piCout << k_.count() << uk.count();
|
||||
k_ = uk;
|
||||
k_.makePath();
|
||||
|
||||
@@ -35,14 +35,13 @@ public:
|
||||
EVENT(K_Received)
|
||||
EVENT(K_ReceiveFail)
|
||||
EVENT(K_ChangedGlobal)
|
||||
EVENT1(K_KeepNamesRequest, bool*, kn)
|
||||
EVENT_HANDLER(void, K_Send);
|
||||
EVENT_HANDLER(void, K_Request);
|
||||
|
||||
void k_write(PIIODevice * d);
|
||||
void k_read(PIIODevice * d);
|
||||
void k_parse(PIIODevice * d);
|
||||
void k_update(PIIODevice * d);
|
||||
void k_update(PIIODevice * d, UpdateModeFlags mode);
|
||||
void k_calculate();
|
||||
void initApp();
|
||||
void initPult();
|
||||
|
||||
@@ -17,7 +17,6 @@ KInterface::KInterface() {
|
||||
CONNECTU(core, K_SendFail, this, sendFailed);
|
||||
CONNECTU(core, K_Received, this, received);
|
||||
CONNECTU(core, K_ReceiveFail, this, receiveFailed);
|
||||
CONNECTU(core, K_KeepNamesRequest, this, keepNamesRequest);
|
||||
}
|
||||
|
||||
|
||||
@@ -127,8 +126,8 @@ void KInterface::parse(PIIODevice * d) {
|
||||
}
|
||||
|
||||
|
||||
void KInterface::update(PIIODevice * d) {
|
||||
core->k_update(d);
|
||||
void KInterface::update(PIIODevice * d, UpdateModeFlags mode) {
|
||||
core->k_update(d, mode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
void write(PIIODevice * d);
|
||||
void read(PIIODevice * d);
|
||||
void parse(PIIODevice * d);
|
||||
void update(PIIODevice * d);
|
||||
void update(PIIODevice * d, UpdateModeFlags mode = SaveByName);
|
||||
void calculate();
|
||||
|
||||
PIString appConfig();
|
||||
|
||||
@@ -375,16 +375,70 @@ void CDSection::read(const void * ep) {
|
||||
}
|
||||
|
||||
|
||||
void CDSection::update(CDSection & v, bool keep_names) {
|
||||
// piCout << "[CDSection] update start";
|
||||
PIMap<PIString, PIString> prev_k_f;
|
||||
PISet<int> used;
|
||||
PIMap<int, CDType>::iterator i;
|
||||
//piCout << "before" << k.size() << v.k.size();
|
||||
if (keep_names) {
|
||||
for (i = k.begin(); i != k.end(); ++i)
|
||||
prev_k_f[i.value().name_] = i.value().formula();
|
||||
void CDSection::update(CDSection & v, UpdateModeFlags mode) {
|
||||
if (mode[SaveByIndex] && mode[SaveByName]) {
|
||||
piCout << "[CDSection] update error: SaveByIndex | SaveByName mode is denied!";
|
||||
return;
|
||||
}
|
||||
//piCout << "[CDSection] update start";
|
||||
//piCout << "before" << k.size() << v.k.size();
|
||||
|
||||
PIMap<int, PIString> prev_k_f_bi;
|
||||
PIMap<PIString, PIString> prev_k_f_bn;
|
||||
PIMap<int, CDType>::iterator i;
|
||||
if (mode[SaveByIndex]) {
|
||||
for (i = k.begin(); i != k.end(); ++i)
|
||||
prev_k_f_bi[i.key()] = i.value().formula();
|
||||
}
|
||||
if (mode[SaveByName]) {
|
||||
for (i = k.begin(); i != k.end(); ++i)
|
||||
prev_k_f_bn[i.value().name_] = i.value().formula();
|
||||
}
|
||||
if (!mode[Merge])
|
||||
k.clear();
|
||||
for (i = v.k.begin(); i != v.k.end(); ++i) {
|
||||
int id = i.key();
|
||||
PIString n = i.value().name();
|
||||
k[id] = i.value();
|
||||
if (mode[SaveByIndex]) {
|
||||
if (prev_k_f_bi.contains(id))
|
||||
k[id].setFormula(prev_k_f_bi[id]);
|
||||
}
|
||||
if (mode[SaveByName]) {
|
||||
if (prev_k_f_bn.contains(n))
|
||||
k[id].setFormula(prev_k_f_bn[n]);
|
||||
}
|
||||
}
|
||||
|
||||
PIMap<int, CDSection> prev_s_bi;
|
||||
PIMap<PIString, CDSection> prev_s_bn;
|
||||
PIMap<int, CDSection>::iterator j;
|
||||
if (mode[SaveByIndex]) {
|
||||
for (j = s.begin(); j != s.end(); ++j)
|
||||
prev_s_bi[j.key()] = j.value();
|
||||
}
|
||||
if (mode[SaveByName]) {
|
||||
for (j = s.begin(); j != s.end(); ++j)
|
||||
prev_s_bn[j.value().alias] = j.value();
|
||||
}
|
||||
if (!mode[Merge])
|
||||
s.clear();
|
||||
for (j = v.s.begin(); j != v.s.end(); ++j) {
|
||||
int id = j.key();
|
||||
PIString n = j.value().alias;
|
||||
s[id] = j.value();
|
||||
if (mode[SaveByIndex]) {
|
||||
if (prev_s_bi.contains(id))
|
||||
s[id] = prev_s_bi[id];
|
||||
}
|
||||
if (mode[SaveByName]) {
|
||||
if (prev_s_bn.contains(n))
|
||||
s[id] = prev_s_bn[n];
|
||||
}
|
||||
s[id].update(j.value(), mode);
|
||||
}
|
||||
|
||||
/*PISet<int> used;
|
||||
for (i = k.begin(); i != k.end(); ++i) {
|
||||
if (v.k.contains(i.key())) {
|
||||
PIString f = k[i.key()].formula_;
|
||||
@@ -393,10 +447,10 @@ void CDSection::update(CDSection & v, bool keep_names) {
|
||||
k[i.key()] = cdt;
|
||||
used << i.key();
|
||||
}
|
||||
if (keep_names) {
|
||||
if (mode) {
|
||||
CDType & ck(k[i.key()]);
|
||||
if (prev_k_f.contains(ck.name_))
|
||||
ck.setFormula(prev_k_f[ck.name_]);
|
||||
if (prev_k_f_bn.contains(ck.name_))
|
||||
ck.setFormula(prev_k_f_bn[ck.name_]);
|
||||
}
|
||||
}
|
||||
//piCout << " after" << k.size();
|
||||
@@ -404,19 +458,19 @@ void CDSection::update(CDSection & v, bool keep_names) {
|
||||
if (!used.contains(i.key()))
|
||||
k[i.key()] = i.value();
|
||||
CDType & ck(k[i.key()]);
|
||||
ck.setFormula(prev_k_f.value(ck.name_));
|
||||
ck.setFormula(prev_k_f_bn.value(ck.name_));
|
||||
}
|
||||
used.clear();
|
||||
PIMap<int, CDSection>::iterator j;
|
||||
for (j = s.begin(); j != s.end(); ++j) {
|
||||
if (v.s.contains(j.key()))
|
||||
j.value().update(v.s[j.key()], keep_names);
|
||||
j.value().update(v.s[j.key()], mode);
|
||||
used << j.key();
|
||||
}
|
||||
for (j = v.s.begin(); j != v.s.end(); ++j) {
|
||||
if (!used.contains(j.key()))
|
||||
s[j.key()] = j.value();
|
||||
}
|
||||
}*/
|
||||
// piCout << "[CDSection] update end";
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,14 @@ namespace CDUtils {
|
||||
|
||||
class CDSection;
|
||||
|
||||
enum UpdateMode {
|
||||
SaveByIndex = 0x01,
|
||||
SaveByName = 0x02,
|
||||
Merge = 0x04
|
||||
};
|
||||
|
||||
typedef PIFlags<UpdateMode> UpdateModeFlags;
|
||||
|
||||
class CDType {
|
||||
friend class CDSection;
|
||||
public:
|
||||
@@ -97,7 +105,7 @@ protected:
|
||||
}
|
||||
void write(PIIODevice * d, const PIString & prefix = PIString());
|
||||
void read(const void * ep);
|
||||
void update(CDSection & v, bool keep_names);
|
||||
void update(CDSection & v, UpdateModeFlags mode = SaveByName);
|
||||
bool isSameStructure(CDSection & v);
|
||||
void prepareCalculate();
|
||||
void calculateRecursive(PIEvaluator * e);
|
||||
|
||||
@@ -165,7 +165,10 @@ void Form::on_pushButton_4_clicked() {
|
||||
|
||||
|
||||
void Form::on_pushButton_6_clicked() {
|
||||
ui->treeView->buildFromHeader(QFileDialog::getOpenFileName(this, trUtf8("Select *.h file with K description"), "k_description.h", "C/C++ header files(*.h *.hpp);;All files(*)"));
|
||||
QString fn = QFileDialog::getOpenFileName(this, trUtf8("Select *.h file with K description"), "k_description.h", "C/C++ header files(*.h *.hpp);;All files(*)");
|
||||
if (fn.isEmpty()) return;
|
||||
if (mode_dlg.exec() == QDialog::Rejected) return;
|
||||
ui->treeView->buildFromHeader(fn, mode_dlg.mode());
|
||||
/*piCout << K.root()["Radar_WaveFreqTune"];
|
||||
piCout << K.root()["11.NVA_PulseGenFineTune"];
|
||||
piCout << K.root()[".NVA.NVA_PulseGenFineTune"];
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define FORM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <qcd_modedialog.h>
|
||||
|
||||
namespace Ui {
|
||||
class Form;
|
||||
@@ -22,7 +23,9 @@ private slots:
|
||||
void on_buttonCalc_clicked();
|
||||
|
||||
private:
|
||||
Ui::Form *ui;
|
||||
Ui::Form * ui;
|
||||
QCDModeDialog mode_dlg;
|
||||
|
||||
};
|
||||
|
||||
#endif // FORM_H
|
||||
|
||||
@@ -80,11 +80,11 @@ void CDKView::clearK() {
|
||||
}
|
||||
|
||||
|
||||
void CDKView::buildFromHeader(const QString &kdescription) {
|
||||
void CDKView::buildFromHeader(const QString &kdescription, int mode) {
|
||||
if (kdescription.isEmpty()) return;
|
||||
PIString kdesc_file = Q2PIString(QDir::current().relativeFilePath(kdescription));
|
||||
PIFile f(kdesc_file, PIIODevice::ReadOnly);
|
||||
K.update(&f);
|
||||
K.update(&f, mode);
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public slots:
|
||||
void saveK();
|
||||
void loadK();
|
||||
void clearK();
|
||||
void buildFromHeader(const QString & kdescription);
|
||||
void buildFromHeader(const QString & kdescription, int mode = 2);
|
||||
void calculateK();
|
||||
|
||||
private slots:
|
||||
|
||||
46
qcd_utils/qcd_modedialog.cpp
Normal file
46
qcd_utils/qcd_modedialog.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "qcd_modedialog.h"
|
||||
#include "ui_qcd_modedialog.h"
|
||||
|
||||
|
||||
QCDModeDialog::QCDModeDialog(QWidget * parent): QDialog(parent) {
|
||||
ui = new Ui::QCDModeDialog();
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
|
||||
QCDModeDialog::~QCDModeDialog() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
CDUtils::UpdateModeFlags QCDModeDialog::mode() const {
|
||||
CDUtils::UpdateModeFlags ret = 0;
|
||||
if (ui->checkSaveIndex->isChecked()) ret |= CDUtils::SaveByIndex;
|
||||
if (ui->checkSaveName->isChecked()) ret |= CDUtils::SaveByName;
|
||||
if (ui->checkMerge->isChecked()) ret |= CDUtils::Merge;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void QCDModeDialog::changeEvent(QEvent *e) {
|
||||
QDialog::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QCDModeDialog::on_checkSaveIndex_clicked(bool checked) {
|
||||
if (!checked) return;
|
||||
ui->checkSaveName->setChecked(false);
|
||||
}
|
||||
|
||||
|
||||
void QCDModeDialog::on_checkSaveName_clicked(bool checked) {
|
||||
if (!checked) return;
|
||||
ui->checkSaveIndex->setChecked(false);
|
||||
}
|
||||
31
qcd_utils/qcd_modedialog.h
Normal file
31
qcd_utils/qcd_modedialog.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef QCD_MODEDIALOG_H
|
||||
#define QCD_MODEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <cdutils_types.h>
|
||||
|
||||
namespace Ui {
|
||||
class QCDModeDialog;
|
||||
}
|
||||
|
||||
class QCDModeDialog: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QCDModeDialog(QWidget * parent = 0);
|
||||
~QCDModeDialog();
|
||||
|
||||
CDUtils::UpdateModeFlags mode() const;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
Ui::QCDModeDialog * ui;
|
||||
|
||||
private slots:
|
||||
void on_checkSaveIndex_clicked(bool checked);
|
||||
void on_checkSaveName_clicked(bool checked);
|
||||
|
||||
};
|
||||
|
||||
#endif // QCD_MODEDIALOG_H
|
||||
85
qcd_utils/qcd_modedialog.ui
Normal file
85
qcd_utils/qcd_modedialog.ui
Normal file
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QCDModeDialog</class>
|
||||
<widget class="QDialog" name="QCDModeDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>251</width>
|
||||
<height>152</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Update description mode</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkSaveIndex">
|
||||
<property name="text">
|
||||
<string>Save by index</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkSaveName">
|
||||
<property name="text">
|
||||
<string>Save by name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkMerge">
|
||||
<property name="text">
|
||||
<string>Merge</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>QCDModeDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>106</x>
|
||||
<y>131</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>101</x>
|
||||
<y>146</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>QCDModeDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>182</x>
|
||||
<y>127</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>169</x>
|
||||
<y>146</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user