git-svn-id: svn://db.shs.com.ru/libs@398 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2018-06-07 13:32:34 +00:00
parent 6967dcc747
commit ad39a1b02e
12 changed files with 84 additions and 2 deletions

View File

@@ -114,6 +114,11 @@ int Interface::count(bool recursive) const {
}
bool Interface::exists(PIDeque<int> path) const {
return s->exists(path);
}
void Interface::setFileName(const PIString & _file) {
file_ = _file;
}

View File

@@ -33,6 +33,7 @@ public:
const PIString file() const {return file_;}
int fileSize() const {return file_size;}
CDType::cdT cdType() const {return type;}
bool exists(PIDeque<int> path) const;
void setFileName(const PIString & _file);
bool configure(const PIString & config);

View File

@@ -328,6 +328,16 @@ const CDSection CDSection::section(int v) const {
}
bool CDSection::exists(PIDeque<int> path) const {
if (path.isEmpty()) return false;
if (path.size_s() == 1) return cd.contains(path[0]);
int si = path[0];
if (!s.contains(si)) return false;
path.remove(0, 1);
return s[si].exists(path);
}
int CDSection::count(bool recursive) const {
int ret = cd.size_s();
if (recursive) {

View File

@@ -111,6 +111,7 @@ public:
const CDSection section(int v) const;
bool isEmpty() const {return cd.isEmpty() && s.isEmpty();}
bool exists(PIDeque<int> path) const;
int count(bool recursive = true) const;
int sectionsCount() const;
PIVector<int> indexes() const {return cd.keys();}

View File

@@ -93,6 +93,21 @@ void KDockWidget::clear() {
}
void KDockWidget::changedGlobal() {
for (int i = 0; i < k_list.size_s(); ++i) {
if (!K.exists(k_list[i])) {
k_list.remove(i);
info_list.remove(i);
removeRow(i);
--i;
continue;
}
QLabel * lbl = qobject_cast<QLabel*>(lay->itemAt(i, QFormLayout::LabelRole)->widget());
if (lbl) lbl->setText(PI2QString(K[k_list[i]].pathString().join(".")) + ":");
}
}
bool KDockWidget::eventFilter(QObject * o, QEvent * e) {
//if (o == graphic->viewport()) {
switch (e->type()) {
@@ -244,6 +259,12 @@ void CDDirectK::addArea() {
}
void CDDirectK::changedGlobal() {
foreach (KDockWidget * d, docks)
d->changedGlobal();
}
void CDDirectK::removeArea() {
KDockWidget * d = qobject_cast<KDockWidget * >(sender());
if (!d) return;

View File

@@ -17,6 +17,7 @@ public:
QByteArray save() const;
void load(QByteArray ba);
void clear();
void changedGlobal();
QFormLayout * lay;
@@ -62,6 +63,7 @@ private:
QMainWindow * da;
public slots:
void changedGlobal();
private slots:
void removeArea();

View File

@@ -102,6 +102,19 @@ void GDockWidget::load(QByteArray ba) {
}
void GDockWidget::changedGlobal() {
for (int i = 0; i < x_list.size_s(); ++i) {
if (!X.exists(x_list[i])) {
x_list.remove(i);
graphic->graphic()->removeGraphic(i);
--i;
continue;
}
graphic->graphic()->setGraphicName(PI2QString(X[x_list[i]].pathString().join(".")), i);
}
}
bool GDockWidget::eventFilter(QObject * o, QEvent * e) {
//if (o == graphic->viewport()) {
switch (e->type()) {
@@ -297,6 +310,12 @@ void CDGraphics::receivedX() {
}
void CDGraphics::changedGlobal() {
foreach (GDockWidget * d, docks)
d->changedGlobal();
}
void CDGraphics::removeGraphic() {
GDockWidget * d = qobject_cast<GDockWidget * >(sender());
if (!d) return;

View File

@@ -30,6 +30,7 @@ public:
void drawX(const PIMap<PIString, PIVector<double> > & data);
QByteArray save() const;
void load(QByteArray ba);
void changedGlobal();
CDGraphicWidget * graphic;
@@ -76,6 +77,7 @@ private:
public slots:
void receivedX();
void changedGlobal();
private slots:
void removeGraphic();

View File

@@ -46,6 +46,8 @@ CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), Ui::CDPultWin
connect(widgetK, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString)));
connect(widgetX, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString)));
connect(widgetC, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString)));
connect(widgetK->view, SIGNAL(changedGlobal()), widgetDirectK, SLOT(changedGlobal()));
connect(widgetX->view, SIGNAL(changedGlobal()), widgetGraphics, SLOT(changedGlobal()));
connect(widgetX->view, SIGNAL(receivedX()), widgetGraphics, SLOT(receivedX()));
QCDCore::instance()->bindWidget(widgetK->view);
QCDCore::instance()->setDirectKEnabled(true);

View File

@@ -179,7 +179,7 @@ bool QCDCore::bindWidget(QWidget * w, const CDType & k) {
connect(w, SIGNAL(destroyed(QObject*)), this, SLOT(slotDestroyed(QObject*)), Qt::UniqueConnection);
setWidgetValue(w, k);
if (!ok) return false;
piCout << k.name() << k.path();
//piCout << k.name() << k.path();
binded_widgets.insert(w, k.path());
return true;
}
@@ -187,11 +187,17 @@ bool QCDCore::bindWidget(QWidget * w, const CDType & k) {
void QCDCore::updateBindedWidgets() {
QMapIterator<QWidget * , PIDeque<int> > it(binded_widgets);
QWidgetList to_remove;
updating = true;
while (it.hasNext()) {
QWidget * w = it.next().key();
if (!K.exists(it.value()))
to_remove << w;
else
setWidgetValue(w, K[it.value()]);
}
foreach (QWidget * w, to_remove)
unbindWidget(w);
updating = false;
}

View File

@@ -21,6 +21,7 @@ CDView::CDView(QWidget * parent) : QTreeView(parent) {
connect(this, SIGNAL(_qcd_receiveFailed()), this, SLOT(cd_receiveFailed()), Qt::QueuedConnection);
connect(this, SIGNAL(_qcd_receiveSucceed()), this, SLOT(cd_receiveSucceed()), Qt::QueuedConnection);
connect(this, SIGNAL(_qcd_receivedX()), this, SLOT(cd_receivedX()), Qt::QueuedConnection);
connect(this, SIGNAL(_qcd_changedGlobal()), this, SLOT(cd_changedGlobal()), Qt::QueuedConnection);
}
@@ -40,6 +41,7 @@ void CDView::setType(int cdt) {
CONNECTU(&K, sendFailed, this, pi_cd_sendFailed);
CONNECTU(&K, received, this, pi_cd_receiveSucceed);
CONNECTU(&K, receiveFailed, this, pi_cd_receiveFailed);
CONNECTU(&K, changedGlobal, this, pi_cd_changedGlobal);
break;
case CDType::cdX:
CONNECTU(&X, sended, this, pi_cd_sendSucceed);
@@ -47,12 +49,14 @@ void CDView::setType(int cdt) {
CONNECTU(&X, received, this, pi_cd_receiveSucceed);
CONNECTU(&X, receiveFailed, this, pi_cd_receiveFailed);
CONNECTU(&X, receivedX, this, pi_cd_receivedX);
CONNECTU(&X, changedGlobal, this, pi_cd_changedGlobal);
break;
case CDType::cdC:
CONNECTU(&C, sended, this, pi_cd_sendSucceed);
CONNECTU(&C, sendFailed, this, pi_cd_sendFailed);
CONNECTU(&C, received, this, pi_cd_receiveSucceed);
CONNECTU(&C, receiveFailed, this, pi_cd_receiveFailed);
CONNECTU(&C, changedGlobal, this, pi_cd_changedGlobal);
break;
default: break;
}
@@ -312,3 +316,8 @@ void CDView::cd_receivedX() {
X.unlock();
emit receivedX();
}
void CDView::cd_changedGlobal() {
emit changedGlobal();
}

View File

@@ -51,6 +51,7 @@ private slots:
void cd_receiveFailed();
void cd_receiveSucceed();
void cd_receivedX();
void cd_changedGlobal();
private:
EVENT_HANDLER(void, pi_cd_sendFailed) {emit _qcd_sendFailed();}
@@ -58,6 +59,7 @@ private:
EVENT_HANDLER(void, pi_cd_receiveFailed) {emit _qcd_receiveFailed();}
EVENT_HANDLER(void, pi_cd_receiveSucceed) {emit _qcd_receiveSucceed();}
EVENT_HANDLER(void, pi_cd_receivedX) {emit _qcd_receivedX();}
EVENT_HANDLER(void, pi_cd_changedGlobal) {emit _qcd_changedGlobal();}
CDItemModel * model_;
int type_;
@@ -68,6 +70,7 @@ signals:
void receiveFailed();
void receiveSucceed();
void receivedX();
void changedGlobal();
void messageStatus(QString msg);
void commandSended(QString msg);
void busyStatusChanged(bool busy);
@@ -77,6 +80,7 @@ signals:
void _qcd_receiveFailed(); // PRIVATE
void _qcd_receiveSucceed(); // PRIVATE
void _qcd_receivedX(); // PRIVATE
void _qcd_changedGlobal(); // PRIVATE
};