code format
This commit is contained in:
@@ -1,30 +1,32 @@
|
||||
#include "qcd_view.h"
|
||||
|
||||
#include "cdutils_c.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_m.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "pifile.h"
|
||||
#include "piqt.h"
|
||||
#include "qcd_model.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QMouseEvent>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "cdutils_c.h"
|
||||
#include "cdutils_m.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "qcd_view.h"
|
||||
#include "qcd_model.h"
|
||||
#include "piqt.h"
|
||||
#include "pifile.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
CDView::CDView(QWidget * parent) : QTreeView(parent) {
|
||||
type_ = -1;
|
||||
CDView::CDView(QWidget * parent): QTreeView(parent) {
|
||||
type_ = -1;
|
||||
model_ = 0;
|
||||
proxy_ = 0;
|
||||
connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(indexClicked(QModelIndex)));
|
||||
connect(this, SIGNAL(_qcd_sendFailed()), this, SLOT(cd_sendFailed()), Qt::QueuedConnection);
|
||||
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(clicked(QModelIndex)), this, SLOT(indexClicked(QModelIndex)));
|
||||
connect(this, SIGNAL(_qcd_sendFailed()), this, SLOT(cd_sendFailed()), Qt::QueuedConnection);
|
||||
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);
|
||||
connect(this, SIGNAL(_qcd_changedGlobal()), this, SLOT(cd_changedGlobal()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_receivedX()), this, SLOT(cd_receivedX()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_changedGlobal()), this, SLOT(cd_changedGlobal()), Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,46 +46,44 @@ void CDView::setType(int cdt) {
|
||||
type_ = cdt;
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK:
|
||||
CONNECTU(&K, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&K, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&K, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&K, sended, this, pi_cd_sendSucceed);
|
||||
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);
|
||||
CONNECTU(&X, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&X, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&X, sended, this, pi_cd_sendSucceed);
|
||||
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);
|
||||
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, 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;
|
||||
case CDType::cdM:
|
||||
CONNECTU(&M, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&M, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&M, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&M, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&M, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&M, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&M, receiveFailed, this, pi_cd_receiveFailed);
|
||||
CONNECTU(&M, changedGlobal, this, pi_cd_changedGlobal);
|
||||
CONNECTU(&M, messageReceived, this, pi_cd_messageReceived);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CDView::mousePressEvent(QMouseEvent * e) {
|
||||
if (type_ == CDType::cdC) {
|
||||
QModelIndex i = indexAt(e->pos());
|
||||
if (i.isValid() && i.column() == cName_Cmd)
|
||||
update(i);
|
||||
if (i.isValid() && i.column() == cName_Cmd) update(i);
|
||||
}
|
||||
QTreeView::mousePressEvent(e);
|
||||
}
|
||||
@@ -92,8 +92,7 @@ void CDView::mousePressEvent(QMouseEvent * e) {
|
||||
void CDView::mouseReleaseEvent(QMouseEvent * e) {
|
||||
if (type_ == CDType::cdC) {
|
||||
QModelIndex i = indexAt(e->pos());
|
||||
if (i.isValid() && i.column() == cName_Cmd)
|
||||
update(i);
|
||||
if (i.isValid() && i.column() == cName_Cmd) update(i);
|
||||
}
|
||||
QTreeView::mouseReleaseEvent(e);
|
||||
}
|
||||
@@ -101,8 +100,7 @@ void CDView::mouseReleaseEvent(QMouseEvent * e) {
|
||||
|
||||
void CDView::currentChanged(const QModelIndex & cur, const QModelIndex & prev) {
|
||||
if (type_ == CDType::cdC) {
|
||||
if (prev.isValid() && prev.column() == cName_Cmd)
|
||||
update(prev);
|
||||
if (prev.isValid() && prev.column() == cName_Cmd) update(prev);
|
||||
}
|
||||
QTreeView::currentChanged(cur, prev);
|
||||
}
|
||||
@@ -121,30 +119,28 @@ void CDView::refresh() {
|
||||
proxy_->setSourceModel(model_);
|
||||
setModel(proxy_);
|
||||
setItemDelegateForColumn(type_ == CDType::cdC ? cName_Cmd : cValue, new CDDelegate());
|
||||
if (type_ == CDType::cdX)
|
||||
setItemDelegateForColumn(cXMode, new CDDelegate());
|
||||
if (type_ == CDType::cdX) setItemDelegateForColumn(cXMode, new CDDelegate());
|
||||
}
|
||||
model_->rebuildModel();
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK:
|
||||
setColumnHidden(cXMode, true);
|
||||
setColumnHidden(cXAvg, true);
|
||||
break;
|
||||
case CDType::cdX:
|
||||
setColumnHidden(cExpression, true);
|
||||
setColumnHidden(cXMode, true);
|
||||
setColumnHidden(cXAvg, true);
|
||||
break;
|
||||
case CDType::cdX: setColumnHidden(cExpression, true); break;
|
||||
case CDType::cdC:
|
||||
case CDType::cdM:
|
||||
setColumnHidden(cType, true);
|
||||
setColumnHidden(cXMode, true);
|
||||
setColumnHidden(cXAvg, true);
|
||||
setColumnHidden(cType, true);
|
||||
setColumnHidden(cXMode, true);
|
||||
setColumnHidden(cXAvg, true);
|
||||
setColumnHidden(cExpression, true);
|
||||
setColumnHidden(cValue, true);
|
||||
setColumnHidden(cValue, true);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
expandAll();
|
||||
for (int i = 0; i < model_->columnCount(); i++) resizeColumnToContents(i);
|
||||
for (int i = 0; i < model_->columnCount(); i++)
|
||||
resizeColumnToContents(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +251,7 @@ void CDView::load() {
|
||||
|
||||
|
||||
void CDView::clear() {
|
||||
//piCout << "clearK";
|
||||
// piCout << "clearK";
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK: K.root() = CDSection(); break;
|
||||
case CDType::cdX: X.root() = CDSection(); break;
|
||||
@@ -310,7 +306,7 @@ void CDView::indexClicked(const QModelIndex & i) {
|
||||
CDType & t(model_->interface->section(item->buildPath())[item->index()]);
|
||||
C.sendCommand(t);
|
||||
emit commandSended(PI2QString(t.pathString().join(".")));
|
||||
//piCout << t;
|
||||
// piCout << t;
|
||||
qDebug() << PI2QString(t.pathString().join("."));
|
||||
}
|
||||
|
||||
@@ -346,16 +342,16 @@ void CDView::cd_receiveSucceed() {
|
||||
|
||||
void CDView::cd_receivedX() {
|
||||
X.lock();
|
||||
PIVector<PIDeque<int> > xl = X.enabledList();
|
||||
//piCout << "X" << xl.size();
|
||||
piForeachC (PIDeque<int> & x, xl) {
|
||||
PIVector<PIDeque<int>> xl = X.enabledList();
|
||||
// piCout << "X" << xl.size();
|
||||
piForeachC(PIDeque<int> & x, xl) {
|
||||
CDType & t(X[x]);
|
||||
//piCout << t;
|
||||
//piCout << t.path();
|
||||
// piCout << t;
|
||||
// piCout << t.path();
|
||||
if (t.cd_type() != CDType::cdX) continue;
|
||||
update(model_->indexByPath(t.path(), cValue));
|
||||
//piCout << CDCore::pathToString(t.path()) << t.toDouble() << "model";
|
||||
//qDebug() << "val" << model_->data(model_->indexByPath(t.path(), cValue), Qt::DisplayRole).toDouble();
|
||||
// piCout << CDCore::pathToString(t.path()) << t.toDouble() << "model";
|
||||
// qDebug() << "val" << model_->data(model_->indexByPath(t.path(), cValue), Qt::DisplayRole).toDouble();
|
||||
}
|
||||
X.unlock();
|
||||
emit receivedX();
|
||||
@@ -368,8 +364,10 @@ void CDView::cd_changedGlobal() {
|
||||
|
||||
|
||||
void CDView::pi_cd_messageReceived(PIDeque<int> path, int type, PIString msg) {
|
||||
QMetaObject::invokeMethod(this, "messageReceived", Qt::QueuedConnection,
|
||||
Q_ARG(QString, PI2QString(CDCore::pathToString(path))),
|
||||
Q_ARG(int, type),
|
||||
Q_ARG(QString, PI2QString(msg)));
|
||||
QMetaObject::invokeMethod(this,
|
||||
"messageReceived",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(QString, PI2QString(CDCore::pathToString(path))),
|
||||
Q_ARG(int, type),
|
||||
Q_ARG(QString, PI2QString(msg)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user