diff --git a/cd_utils/cdutils_core.cpp b/cd_utils/cdutils_core.cpp index f5fcdf5..24bc582 100644 --- a/cd_utils/cdutils_core.cpp +++ b/cd_utils/cdutils_core.cpp @@ -182,7 +182,14 @@ void CDCore::init(const PIString & configuration, bool pult) { void CDCore::startX(double freq) { - x_timer.start(1000. / piMaxd(freq, 0.01)); + piCout << "start x" << x_timer.isRunning() << freq; + if (!x_timer.isRunning()) + x_timer.start(1000. / piMaxd(freq, 0.01)); +} + + +void CDCore::stopX() { + x_timer.stop(); } @@ -314,24 +321,28 @@ void CDCore::sendThread() { void CDCore::xTimerTick() { - x_mutex.lock(); + //piCout << "x tick" << x_pult_side; PIByteArray ba; + x_mutex.lock(); if (x_pult_side) { ba = makeHeader(CD_XRequest, 0); if (need_rebuild_x) { x_selected = x_.collectX(); + //piCout << "collectX" << x_selected.size(); need_rebuild_x = false; } ba << x_selected; + //piCout << "x pult send" << x_selected.size(); } else { ba = makeHeader(CD_XValues, 0); ba << x_selected; piForeachC (PIDeque & p, x_selected) { x_[p].writeX(ba); } + //piCout << "x app" << x_selected.size(); } x_mutex.unlock(); - connection.writeByName("cd", ba); + sendDirect(ba); } @@ -393,10 +404,26 @@ void CDCore::procReceivedPacket(PIByteArray & ba) { ba >> p; k_[p.path].setValue(p.value); } break; + case CD_XQuery: + X_Send(); + break; + case CD_XSend: { + piCoutObj << "X received"; + PIByteArray x; + ba >> x; + x << uchar(0); + PIString s = PIString::fromUTF8((const char *)x.data()); + PIIOString ios(&s); + cd_read(&x_, &ios); + X_Received(); + } break; case CD_XRequest: { + if (x_pult_side) break; + //break; x_mutex.lock(); x_selected.clear(); ba >> x_selected; + //piCout << "X req" << x_selected.size(); x_.setSelectedX(false); piForeachC (PIDeque & p, x_selected) { x_[p].x_enabled = true; @@ -404,12 +431,14 @@ void CDCore::procReceivedPacket(PIByteArray & ba) { x_mutex.unlock(); } break; case CD_XValues: { + if (!x_pult_side) break; x_mutex.lock(); - x_selected.clear(); - ba >> x_selected; - piForeachC (PIDeque & p, x_selected) { + PIVector > x_vals; + ba >> x_vals; + piForeachC (PIDeque & p, x_vals) { x_[p].readX(ba); } + X_ReceivedX(x_vals); /// WARNING! under mutex x_mutex.unlock(); } break; case CD_CQuery: diff --git a/cd_utils/cdutils_core.h b/cd_utils/cdutils_core.h index b541af3..e9c952e 100644 --- a/cd_utils/cdutils_core.h +++ b/cd_utils/cdutils_core.h @@ -44,7 +44,7 @@ public: EVENT(X_SendFail) EVENT(X_Received) EVENT(X_ReceiveFail) - EVENT(X_ChangedGlobal) + EVENT1(X_ReceivedX, PIVector >, pathes) EVENT_HANDLER(void, X_Send); EVENT_HANDLER(void, X_Request); @@ -52,7 +52,6 @@ public: EVENT(C_SendFail) EVENT(C_Received) EVENT(C_ReceiveFail) - EVENT(C_ChangedGlobal) EVENT_HANDLER(void, C_Send); EVENT_HANDLER(void, C_Request); @@ -66,6 +65,7 @@ public: void initPult(); void init(const PIString & configuration, bool pult = false); void startX(double freq = 20.); + void stopX(); void sendCommand(const CDType & c); void registerCHandler(const CDType & c, PIObject * o, Handler h); bool inProgress() {return sendt.isRunning();} diff --git a/cd_utils/cdutils_types.cpp b/cd_utils/cdutils_types.cpp index 8eb4c17..65e63a0 100644 --- a/cd_utils/cdutils_types.cpp +++ b/cd_utils/cdutils_types.cpp @@ -125,14 +125,16 @@ void CDType::readX(PIByteArray & ba) { switch ((XMode)t) { case X_Current: ba >> value_d; - value_i = value_d; - value_b = value_d > 0.; break; case X_All_Avg: ba >> history; + if (!history.isEmpty()) + value_d = history.back(); break; default: break; } + value_i = value_d; + value_b = value_d > 0.; } diff --git a/cd_utils/cdutils_x.cpp b/cd_utils/cdutils_x.cpp index 546589f..8d87e0f 100644 --- a/cd_utils/cdutils_x.cpp +++ b/cd_utils/cdutils_x.cpp @@ -11,6 +11,7 @@ XInterface::XInterface(): Interface(CDType::cdX) { CONNECTU(core, X_SendFail, this, sendFailed); CONNECTU(core, X_Received, this, received); CONNECTU(core, X_ReceiveFail, this, receiveFailed); + CONNECTU(core, X_ReceivedX, this, receivedX); } @@ -25,15 +26,39 @@ void XInterface::request() { void XInterface::setEnabled(const CDType & x, bool en) { - CDType & t((*s)[x.path()]); - if (t.cd_type() != CDType::cdX) return; core->x_mutex.lock(); + CDType & t((*s)[x.path()]); + if (t.cd_type() != CDType::cdX) { + core->x_mutex.unlock(); + return; + } t.x_enabled = en; + //piCout << t << "x_enabled" << en; core->need_rebuild_x = true; core->x_mutex.unlock(); } +PIVector > XInterface::enabledList() const { + return CDCore::instance()->x_selected; +} + + +void XInterface::lock() { + CDCore::instance()->x_mutex.lock(); +} + + +void XInterface::unlock() { + CDCore::instance()->x_mutex.unlock(); +} + + void XInterface::start(double freq) { core->startX(freq); } + + +void XInterface::stop() { + core->stopX(); +} diff --git a/cd_utils/cdutils_x.h b/cd_utils/cdutils_x.h index 00b5c10..b501d16 100644 --- a/cd_utils/cdutils_x.h +++ b/cd_utils/cdutils_x.h @@ -20,13 +20,18 @@ public: EVENT1(keepNamesRequest, bool*, xn) EVENT_HANDLER(void, send); EVENT_HANDLER(void, request); + EVENT1(receivedX, PIVector >, pathes) void enable(const CDType & x) {setEnabled(x, true);} void disable(const CDType & x) {setEnabled(x, false);} void setEnabled(const CDType & x, bool en); void setDisabled(const CDType & x, bool dis) {setEnabled(x, !dis);} + PIVector > enabledList() const; + void lock(); + void unlock(); void start(double freq = 20.); + void stop(); }; diff --git a/cd_utils/cdutilstest.cpp b/cd_utils/cdutilstest.cpp index 54ff877..ba102d8 100644 --- a/cd_utils/cdutilstest.cpp +++ b/cd_utils/cdutilstest.cpp @@ -15,9 +15,10 @@ class Core : public PIObject Core() { CDCore::instance()->initApp(); // piCout << "testCore"; - CONNECTU(&t, tickEvent, this, timerDone); + CONNECTU(&timer, tickEvent, this, timerDone); + CONNECTU(&X, received, this, xrecv); CONNECTU(&C, received, this, crecv); - t.start(1000); + t = 0.; } void load() { @@ -48,6 +49,11 @@ class Core : public PIObject } void test() { + X.lock(); + X[KD::Frequency] = 100; + X.section(KD::Spectrometer)[KD::Temperature_default] = sin(t); + t += 0.01; + X.unlock(); /*piCout << "count" << K.count(); piCout << K[First]; piCout << K[Second];*/ @@ -59,6 +65,11 @@ class Core : public PIObject C.connect(C.section(KD::Logs).section(KD::Spec).section(KD::Formats)[KD::Binary], this, HANDLER(cmd)); C.autoConnect(this); } + EVENT_HANDLER(void, xrecv) { + piCout << "received x"; + if (!timer.isRunning()) timer.start(10); + X.start(); + } EVENT_HANDLER(void, timerDone) {test();} EVENT_HANDLER(void, cmd) {piCout << "command cmd";} EVENT_HANDLER(void, c_Pause) {piCout << "command pause";} @@ -66,7 +77,8 @@ class Core : public PIObject private: PIFile rf; - PITimer t; + PITimer timer; + double t; }; diff --git a/qad/graphic/graphic.cpp b/qad/graphic/graphic.cpp index d687ac4..0d2f589 100644 --- a/qad/graphic/graphic.cpp +++ b/qad/graphic/graphic.cpp @@ -709,6 +709,14 @@ void Graphic::setGraphicsCount(int arg, bool update) { } +void Graphic::removeGraphic(int arg, bool update) { + if (arg < 0 || arg >= graphics.size()) return; + delete graphics[arg].pb; + graphics.remove(arg); + if (update) updateLegend(); +} + + /*void Graphic::setHistogramData(const QVector & g, int graphic) { graphics[graphic].polyline.clear(); if (g.isEmpty()) { diff --git a/qad/graphic/graphic.h b/qad/graphic/graphic.h index 6a17313..2a6fc19 100644 --- a/qad/graphic/graphic.h +++ b/qad/graphic/graphic.h @@ -301,6 +301,7 @@ public slots: void updateGraphics() {findGraphicsRect(); update();} void setCurrentGraphic(int arg) {if (arg < 0 || arg >= graphics.size()) return; curGraphic = arg;} void setGraphicsCount(int arg, bool update = true); + void removeGraphic(int arg, bool update = true); void zoom(float factor); void zoomIn() {zoom(1. / 1.2);} diff --git a/qcd_utils/pult/cdgraphics.cpp b/qcd_utils/pult/cdgraphics.cpp index f1fe2be..ae54c17 100644 --- a/qcd_utils/pult/cdgraphics.cpp +++ b/qcd_utils/pult/cdgraphics.cpp @@ -25,13 +25,76 @@ GDockWidget::GDockWidget(QString title, QMainWindow * p): QDockWidget(title, p) a = new QAction(QIcon(":/icons/edit-delete.png"), "Remove", this); connect(a, SIGNAL(triggered(bool)), this, SIGNAL(removeRequest())); dactions << a; + menu_x = new QMenu(this); + menu_x->setTitle(trUtf8("Remove X")); + graphic = new Graphic(); + graphic->setGraphicsCount(0); + graphic->setBorderInputsVisible(false); + graphic->setLegendVisible(true); + graphic->setStatusVisible(false); + graphic->setButtons(graphic->buttons() & ~(Graphic::Grid | Graphic::OnlyExpandX | Graphic::Close)); + graphic->viewport()->setAcceptDrops(true); + graphic->viewport()->installEventFilter(this); + setWidget(graphic); +} + + +void GDockWidget::addX(const CDType & t) { + if (t.cd_type() != CDType::cdX) return; + PIDeque xp = t.path(); + if (x_list.contains(xp)) return; + x_list << xp; + int gind = graphic->graphicsCount(); + graphic->setGraphicsCount(gind + 1); + graphic->setGraphicName(PI2QString(t.pathString().join(".")), gind); +} + + +bool GDockWidget::eventFilter(QObject * o, QEvent * e) { + //if (o == graphic->viewport()) { + switch (e->type()) { + case QEvent::DragEnter: { + QDragEnterEvent * de = (QDragEnterEvent*)e; + const QMimeData * mime = de->mimeData(); + //qDebug() << "enter" << mime; + if (!mime) break; + if (mime->text().isEmpty()) break; + de->setDropAction(Qt::CopyAction); + de->accept(); + return true; + } break; + case QEvent::Drop: { + QDropEvent * de = (QDropEvent*)e; + const QMimeData * mime = de->mimeData(); + if (!mime) break; + //qDebug() << "drop" << mime->text(); + if (mime->text().isEmpty()) break; + addX(X[CDCore::stringToPath(Q2PIString(mime->text()))]); + de->accept(); + return true; + } break; + default: break; + } + //} + return QWidget::eventFilter(o, e); } void GDockWidget::contextMenuEvent(QContextMenuEvent * e) { + qDeleteAll(menu_x->actions()); + menu_x->clear(); + for (int i = 0; i < graphic->graphicsCount(); ++i) { + QPixmap icon(da->iconSize()); + icon.fill(graphic->graphic(i).pen.color()); + QAction * a = new QAction(QIcon(icon), graphic->graphic(i).name, this); + a->setData(i); + connect(a, SIGNAL(triggered(bool)), this, SLOT(removeX())); + menu_x->addAction(a); + } QMenu * mwm = da->createPopupMenu(); menu->clear(); menu->addActions(dactions); + menu->addMenu(menu_x); menu->addSeparator(); menu->addActions(mwm->actions()); menu->popup(e->globalPos()); @@ -39,6 +102,14 @@ void GDockWidget::contextMenuEvent(QContextMenuEvent * e) { } +Graphic * GDockWidget::viewportGraphic(QObject * o) const { + if (!o) return 0; + while (!qobject_cast(o) && o) + o = o->parent(); + return qobject_cast(o); +} + + void GDockWidget::rename() { QString nn = QInputDialog::getText(this, trUtf8("Rename area"), trUtf8("New area name:"), QLineEdit::Normal, windowTitle()); @@ -47,6 +118,16 @@ void GDockWidget::rename() { } +void GDockWidget::removeX() { + QAction * a = qobject_cast(sender()); + if (!a) return; + int ind = a->data().toInt(); + if (ind < 0 || ind >= x_list.size_s()) return; + x_list.remove(ind); + graphic->removeGraphic(ind); +} + + CDGraphics::CDGraphics(QWidget * parent) : QWidget(parent), Ui::CDGraphics() { @@ -66,44 +147,6 @@ void CDGraphics::reset() { } -bool CDGraphics::eventFilter(QObject * o, QEvent * e) { - //if (o == graphic->viewport()) { - switch (e->type()) { - case QEvent::DragEnter: { - QDragEnterEvent * de = (QDragEnterEvent*)e; - const QMimeData * mime = de->mimeData(); - //qDebug() << "enter" << mime; - if (!mime) break; - if (mime->text().isEmpty()) break; - de->setDropAction(Qt::CopyAction); - de->accept(); - return true; - } break; - case QEvent::Drop: { - QDropEvent * de = (QDropEvent*)e; - const QMimeData * mime = de->mimeData(); - if (!mime) break; - //qDebug() << "drop" << mime->text(); - if (mime->text().isEmpty()) break; - addXToGraphic(mime->text(), viewportGraphic(o)); - de->accept(); - return true; - } break; - default: break; - } - //} - return QWidget::eventFilter(o, e); -} - - -Graphic * CDGraphics::viewportGraphic(QObject * o) const { - if (!o) return 0; - while (!qobject_cast(o) && o) - o = o->parent(); - return qobject_cast(o); -} - - GDockWidget * CDGraphics::graphicDock(Graphic * o) const { if (!o) return 0; foreach (GDockWidget * d, docks) @@ -114,57 +157,38 @@ GDockWidget * CDGraphics::graphicDock(Graphic * o) const { void CDGraphics::addGraphic() { - Graphic * g = new Graphic(); - g->setGraphicsCount(0); - g->setBorderInputsVisible(false); - g->setLegendVisible(true); - g->viewport()->setAcceptDrops(true); - g->viewport()->installEventFilter(this); - GDockWidget * dw = new GDockWidget(QString("graphics %1").arg(graphics.size()), da); + GDockWidget * dw = new GDockWidget(QString("area %1").arg(docks.size()), da); connect(dw, SIGNAL(removeRequest()), this, SLOT(removeGraphic())); - dw->setWidget(g); da->addDockWidget(Qt::RightDockWidgetArea, dw); docks << dw; - graphics << g; +} + + +void CDGraphics::receivedX() { + } void CDGraphics::removeGraphic() { GDockWidget * d = qobject_cast(sender()); if (!d) return; - Graphic * g = qobject_cast(d->widget()); docks.removeAll(d); - graphics.removeAll(g); - g->deleteLater(); d->deleteLater(); } -void CDGraphics::addXToGraphic(const QString & xp, Graphic * g) { - qDebug() << "addGraphic" << xp << g; - GDockWidget * d = graphicDock(g); - if (xp.isEmpty() || !g || !d) return; - CDType & t(X[CDCore::stringToPath(Q2PIString(xp))]); - int gind = g->graphicsCount(); - g->setGraphicsCount(gind + 1); - g->setGraphicName(PI2QString(t.pathString().join(".")), gind); -} - - void CDGraphics::on_buttonAdd_clicked() { addGraphic(); } void CDGraphics::on_buttonClear_clicked() { - foreach (Graphic * g, graphics) - g->clear(); + foreach (GDockWidget * d, docks) + d->graphic->clear(); } void CDGraphics::on_buttonRemoveAll_clicked() { - qDeleteAll(graphics); qDeleteAll(docks); - graphics.clear(); docks.clear(); } diff --git a/qcd_utils/pult/cdgraphics.h b/qcd_utils/pult/cdgraphics.h index 6d70b62..3bbde11 100644 --- a/qcd_utils/pult/cdgraphics.h +++ b/qcd_utils/pult/cdgraphics.h @@ -5,27 +5,50 @@ #include #include #include "ui_cdgraphics.h" +#include + +namespace CDUtils { + class CDType; + class CDSection; +} class QMainWindow; class Graphic; + + class GDockWidget: public QDockWidget { Q_OBJECT public: GDockWidget(QString title = QString(), QMainWindow * p = 0); + + void addX(const CDUtils::CDType & t); + + Graphic * graphic; + private: + bool eventFilter(QObject * o, QEvent * e); void contextMenuEvent(QContextMenuEvent * e); - QMenu * menu; + Graphic * viewportGraphic(QObject * o) const; + + QMenu * menu, * menu_x; QList dactions; QMainWindow * da; + PIVector > x_list; + private slots: void rename(); + void removeX(); + signals: void removeRequest(); + }; + + class CDGraphics : public QWidget, public Ui::CDGraphics { Q_OBJECT @@ -36,16 +59,16 @@ public: void reset(); private: - bool eventFilter(QObject * o, QEvent * e); - Graphic * viewportGraphic(QObject * o) const; GDockWidget * graphicDock(Graphic * o) const; void addXToGraphic(const QString & xp, Graphic * g); void addGraphic(); - QList graphics; QList docks; QMainWindow * da; +public slots: + void receivedX(); + private slots: void removeGraphic(); void on_buttonAdd_clicked(); diff --git a/qcd_utils/pult/cdpultwindow.cpp b/qcd_utils/pult/cdpultwindow.cpp index 33dfa8a..5360013 100644 --- a/qcd_utils/pult/cdpultwindow.cpp +++ b/qcd_utils/pult/cdpultwindow.cpp @@ -3,6 +3,7 @@ #include "cdutils_k.h" #include "cdutils_core.h" #include "qcd_core.h" +#include "qcd_view.h" #include "qcd_model.h" #include "qcd_modedialog.h" #include "chunkstream.h" @@ -34,6 +35,7 @@ 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(widgetX->view, SIGNAL(receivedX()), widgetGraphics, SLOT(receivedX())); if (windowState() == Qt::WindowMinimized) setWindowState(Qt::WindowNoState); } @@ -160,6 +162,7 @@ void CDPultWindow::on_buttonSessionApply_clicked() { dockCDKView->setVisible(checkHasK->isChecked()); dockCDXView->setVisible(checkHasX->isChecked()); dockCDCView->setVisible(checkHasC->isChecked()); + widgetX->view->startX(); } diff --git a/qcd_utils/pult/cdpultwindow.ui b/qcd_utils/pult/cdpultwindow.ui index bacf238..4eca223 100644 --- a/qcd_utils/pult/cdpultwindow.ui +++ b/qcd_utils/pult/cdpultwindow.ui @@ -17,7 +17,7 @@ true - QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks|QMainWindow::VerticalTabs + QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks diff --git a/qcd_utils/qcd_model.cpp b/qcd_utils/qcd_model.cpp index a0e31ab..86a66ed 100644 --- a/qcd_utils/qcd_model.cpp +++ b/qcd_utils/qcd_model.cpp @@ -20,6 +20,7 @@ CDItem::CDItem(CDUtils::Interface * i, int _index, CDItem::CDItemType type, CDIt index_ = _index; parent_ = parent; type_ = type; + item_count = 0; } @@ -387,12 +388,13 @@ void CDItemModel::rebuildModel() { } -void CDItemModel::buildItem(CDItem *it, CDSection & r) { +void CDItemModel::buildItem(CDItem * it, CDSection & r) { //piCout << "build item" << r.name << r.alias; PIMap::iterator i; for (i = r.cd.begin(); i != r.cd.end(); ++i) { it->childs << new CDItem(interface, i.key(), CDItem::ItemCDType, it); } + it->item_count = it->childs.size(); PIMap::iterator j; for (j = r.s.begin(); j != r.s.end(); ++j) { it->childs << new CDItem(interface, j.key(), CDItem::ItemCDSection, it); @@ -423,3 +425,32 @@ CDItem * CDItemModel::getItem(const QModelIndex &index) const { } return root; } + + +QModelIndex CDItemModel::indexByPath(const PIDeque & path, int column) const { + if (path.isEmpty()) return QModelIndex(); + CDItem * item = root; + //piCout << path << "..."; + bool ok = false; + for (int i = 0; i < path.size_s() - 1; ++i) { + ok = false; + foreach (CDItem * j, item->childs) + if (j->type_ == CDItem::ItemCDSection && j->index_ == path[i]) { + item = j; + ok = true; + break; + } + if (!ok) return QModelIndex(); + } + ok = false; + foreach (CDItem * j, item->childs) + if (j->type_ == CDItem::ItemCDType && j->index_ == path.back()) { + item = j; + ok = true; + break; + } + if (!ok || !item->parent_) return QModelIndex(); + QModelIndex ret = createIndex(item->parent_->childs.indexOf(item), column, item); + //piCout << path << Q2PIString(item->data(cName_Cmd, Qt::DisplayRole).toString()) << getItem(ret)->buildPath(); + return ret; +} diff --git a/qcd_utils/qcd_model.h b/qcd_utils/qcd_model.h index 29c9204..f5e28c5 100644 --- a/qcd_utils/qcd_model.h +++ b/qcd_utils/qcd_model.h @@ -33,6 +33,7 @@ class CDItemModel; class CDItem { friend class CDItemModel; + friend class CDView; public: enum CDItemType{ItemCDType, ItemCDSection}; CDItem(CDUtils::Interface * interface, int _index, CDItemType type, CDItem * parent); @@ -51,7 +52,7 @@ private: QAD::Enum xModeEnum(int v) const; CDItem * parent_; - int index_; + int index_, item_count; CDItemType type_; QList childs; }; @@ -80,9 +81,9 @@ public: explicit CDItemModel(int type_, QObject *parent = 0); ~CDItemModel(); - QVariant data(const QModelIndex &index, int role) const; + QVariant data(const QModelIndex & index, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const; QModelIndex parent(const QModelIndex &index) const; int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; @@ -90,6 +91,7 @@ public: bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); QMimeData * mimeData(const QModelIndexList & indexes) const; CDItem * getItem(const QModelIndex & index) const; + QModelIndex indexByPath(const PIDeque & path, int column = CDUtils::cID) const; void buildItem(CDItem * it, CDUtils::CDSection &r); diff --git a/qcd_utils/qcd_view.cpp b/qcd_utils/qcd_view.cpp index daae036..5c99b86 100644 --- a/qcd_utils/qcd_view.cpp +++ b/qcd_utils/qcd_view.cpp @@ -20,6 +20,7 @@ CDView::CDView(QWidget * parent) : QTreeView(parent) { connect(this, SIGNAL(_qcd_sendSucceed()), this, SLOT(cd_sendSucceed()), Qt::QueuedConnection); 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); } @@ -45,6 +46,7 @@ void CDView::setType(int cdt) { CONNECTU(&X, sendFailed, this, pi_cd_sendFailed); CONNECTU(&X, received, this, pi_cd_receiveSucceed); CONNECTU(&X, receiveFailed, this, pi_cd_receiveFailed); + CONNECTU(&X, receivedX, this, pi_cd_receivedX); break; case CDType::cdC: CONNECTU(&C, sended, this, pi_cd_sendSucceed); @@ -286,3 +288,19 @@ void CDView::cd_receiveSucceed() { emit messageStatus("receive success"); emit receiveSucceed(); } + + +void CDView::cd_receivedX() { + X.lock(); + PIVector > xl = X.enabledList(); + //piCout << "X" << xl.size(); + piForeachC (PIDeque & x, xl) { + CDType & t(X[x]); + //piCout << t; + //piCout << t.path(); + if (t.cd_type() != CDType::cdX) continue; + update(model_->indexByPath(t.path(), cValue)); + } + X.unlock(); + emit receivedX(); +} diff --git a/qcd_utils/qcd_view.h b/qcd_utils/qcd_view.h index 815f864..76634b9 100644 --- a/qcd_utils/qcd_view.h +++ b/qcd_utils/qcd_view.h @@ -49,12 +49,14 @@ private slots: void cd_sendSucceed(); void cd_receiveFailed(); void cd_receiveSucceed(); + void cd_receivedX(); private: EVENT_HANDLER(void, pi_cd_sendFailed) {emit _qcd_sendFailed();} EVENT_HANDLER(void, pi_cd_sendSucceed) {emit _qcd_sendSucceed();} 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();} CDItemModel * model_; int type_; @@ -64,6 +66,7 @@ signals: void sendSucceed(); void receiveFailed(); void receiveSucceed(); + void receivedX(); void messageStatus(QString msg); void commandSended(QString msg); void busyStatusChanged(bool busy); @@ -72,6 +75,7 @@ signals: void _qcd_sendSucceed(); // PRIVATE void _qcd_receiveFailed(); // PRIVATE void _qcd_receiveSucceed(); // PRIVATE + void _qcd_receivedX(); // PRIVATE };