git-svn-id: svn://db.shs.com.ru/libs@380 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -1,11 +1,60 @@
|
||||
#include "cdgraphics.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_model.h"
|
||||
#include "graphic.h"
|
||||
#include "piqt.h"
|
||||
#include <QMimeData>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDragMoveEvent>
|
||||
#include <QDropEvent>
|
||||
#include <QMainWindow>
|
||||
#include <QDockWidget>
|
||||
#include <QInputDialog>
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
GDockWidget::GDockWidget(QString title, QMainWindow * p): QDockWidget(title, p) {
|
||||
da = p;
|
||||
menu = new QMenu(this);
|
||||
QAction * a = new QAction(QIcon(":/icons/document-edit.png"), "Rename ...", this);
|
||||
connect(a, SIGNAL(triggered(bool)), this, SLOT(rename()));
|
||||
dactions << a;
|
||||
a = new QAction(QIcon(":/icons/edit-delete.png"), "Remove", this);
|
||||
connect(a, SIGNAL(triggered(bool)), this, SIGNAL(removeRequest()));
|
||||
dactions << a;
|
||||
}
|
||||
|
||||
|
||||
void GDockWidget::contextMenuEvent(QContextMenuEvent * e) {
|
||||
QMenu * mwm = da->createPopupMenu();
|
||||
menu->clear();
|
||||
menu->addActions(dactions);
|
||||
menu->addSeparator();
|
||||
menu->addActions(mwm->actions());
|
||||
menu->popup(e->globalPos());
|
||||
mwm->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
void GDockWidget::rename() {
|
||||
QString nn = QInputDialog::getText(this, trUtf8("Rename area"), trUtf8("New area name:"),
|
||||
QLineEdit::Normal, windowTitle());
|
||||
if (nn.isEmpty()) return;
|
||||
setWindowTitle(nn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
CDGraphics::CDGraphics(QWidget * parent) : QWidget(parent), Ui::CDGraphics() {
|
||||
setupUi(this);
|
||||
da = new QMainWindow();
|
||||
da->setWindowFlags(frame->windowFlags());
|
||||
da->setDockNestingEnabled(true);
|
||||
layoutMain->addWidget(da);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,3 +64,97 @@ CDGraphics::~CDGraphics() {
|
||||
|
||||
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<Graphic*>(o) && o)
|
||||
o = o->parent();
|
||||
return qobject_cast<Graphic*>(o);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
connect(dw, SIGNAL(removeRequest()), this, SLOT(removeGraphic()));
|
||||
dw->setWidget(g);
|
||||
da->addDockWidget(Qt::RightDockWidgetArea, dw);
|
||||
docks << dw;
|
||||
graphics << g;
|
||||
}
|
||||
|
||||
|
||||
void CDGraphics::removeGraphic() {
|
||||
GDockWidget * d = qobject_cast<GDockWidget * >(sender());
|
||||
if (!d) return;
|
||||
Graphic * g = qobject_cast<Graphic * >(d->widget());
|
||||
docks.removeAll(d);
|
||||
graphics.removeAll(g);
|
||||
g->deleteLater();
|
||||
d->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
void CDGraphics::addXToGraphic(const QString & xp, Graphic * g) {
|
||||
qDebug() << "addGraphic" << xp << g;
|
||||
if (xp.isEmpty() || !g) 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();
|
||||
}
|
||||
|
||||
|
||||
void CDGraphics::on_buttonRemoveAll_clicked() {
|
||||
qDeleteAll(graphics);
|
||||
qDeleteAll(docks);
|
||||
graphics.clear();
|
||||
docks.clear();
|
||||
}
|
||||
|
||||
@@ -2,8 +2,28 @@
|
||||
#define CDGRAPHICS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDockWidget>
|
||||
#include <QMenu>
|
||||
#include "ui_cdgraphics.h"
|
||||
|
||||
class QMainWindow;
|
||||
class Graphic;
|
||||
|
||||
|
||||
class GDockWidget: public QDockWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
GDockWidget(QString title = QString(), QMainWindow * p = 0);
|
||||
void contextMenuEvent(QContextMenuEvent * e);
|
||||
QMenu * menu;
|
||||
QList<QAction*> dactions;
|
||||
QMainWindow * da;
|
||||
private slots:
|
||||
void rename();
|
||||
signals:
|
||||
void removeRequest();
|
||||
};
|
||||
|
||||
|
||||
class CDGraphics : public QWidget, public Ui::CDGraphics
|
||||
{
|
||||
@@ -15,8 +35,20 @@ public:
|
||||
void reset();
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
Graphic * viewportGraphic(QObject * o) const;
|
||||
void addXToGraphic(const QString & xp, Graphic * g);
|
||||
void addGraphic();
|
||||
|
||||
QList<Graphic * > graphics;
|
||||
QList<GDockWidget * > docks;
|
||||
QMainWindow * da;
|
||||
|
||||
private slots:
|
||||
void removeGraphic();
|
||||
void on_buttonAdd_clicked();
|
||||
void on_buttonClear_clicked();
|
||||
void on_buttonRemoveAll_clicked();
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
@@ -6,14 +6,85 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>689</width>
|
||||
<height>459</height>
|
||||
<width>624</width>
|
||||
<height>411</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>CD Pult</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="layoutMain" stretch="0">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonAdd">
|
||||
<property name="toolTip">
|
||||
<string>Add new</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonClear">
|
||||
<property name="toolTip">
|
||||
<string>Clear all</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonRemoveAll">
|
||||
<property name="toolTip">
|
||||
<string>Remove all</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../qad/application/qad_application.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
<file>icons/document-revert.png</file>
|
||||
<file>icons/flame.png</file>
|
||||
<file>icons/view-refresh.png</file>
|
||||
<file>icons/format-stroke-color.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -17,6 +17,7 @@ CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), Ui::CDPultWin
|
||||
CDUtils::CDCore::instance()->initPult();
|
||||
widgetK->setType(CDUtils::CDType::cdK);
|
||||
widgetX->setType(CDUtils::CDType::cdX);
|
||||
widgetC->setType(CDUtils::CDType::cdC);
|
||||
editFileK->setValue(QVariant::fromValue(QAD::File("", "*.dat")));
|
||||
editFileX->setValue(QVariant::fromValue(QAD::File("", "*.dat")));
|
||||
editFileC->setValue(QVariant::fromValue(QAD::File("", "*.dat")));
|
||||
@@ -32,6 +33,7 @@ CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), Ui::CDPultWin
|
||||
reset();
|
||||
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)));
|
||||
if (windowState() == Qt::WindowMinimized)
|
||||
setWindowState(Qt::WindowNoState);
|
||||
}
|
||||
@@ -154,9 +156,10 @@ void CDPultWindow::on_editFileK_valueChanged(const QVariant & p) {
|
||||
void CDPultWindow::on_buttonSessionApply_clicked() {
|
||||
widgetK->setFile(editFileK->value().value<QAD::File>().file);
|
||||
widgetX->setFile(editFileX->value().value<QAD::File>().file);
|
||||
widgetC->setFile(editFileC->value().value<QAD::File>().file);
|
||||
dockCDKView->setVisible(checkHasK->isChecked());
|
||||
dockCDXView->setVisible(checkHasX->isChecked());
|
||||
//dockCDCView->setVisible(checkHasC->isChecked());
|
||||
dockCDCView->setVisible(checkHasC->isChecked());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -90,21 +90,6 @@
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listLog">
|
||||
<property name="editTriggers">
|
||||
@@ -311,6 +296,44 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="EDockWidget" name="dockCDCView">
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../qad/blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/legend.png</normaloff>:/icons/legend.png</iconset>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>C</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>1</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents_5">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="CDViewWidget" name="widgetC" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="EDockWidget" name="dockGraphics">
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../qad/blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/format-stroke-color.png</normaloff>:/icons/format-stroke-color.png</iconset>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Graphics</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>8</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents_6">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="CDGraphics" name="widgetGraphics" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<action name="actionOpen">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
@@ -418,6 +441,10 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
@@ -448,9 +475,16 @@
|
||||
<header>cdviewwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CDGraphics</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>cdgraphics.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../qad/application/qad_application.qrc"/>
|
||||
<include location="../../qad/blockview/qad_blockview.qrc"/>
|
||||
<include location="../../qad/graphic/qpicalculator/qpicalculator.qrc"/>
|
||||
<include location="../../qad/widgets/qad_widgets.qrc"/>
|
||||
<include location="cdpult.qrc"/>
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
<string>Receive</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="cdpult.qrc">
|
||||
<normaloff>:/icons/document-revert.png</normaloff>:/icons/document-revert.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -69,7 +69,7 @@
|
||||
<string>Update description ...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="cdpult.qrc">
|
||||
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -80,7 +80,7 @@
|
||||
<string>Send</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="cdpult.qrc">
|
||||
<normaloff>:/icons/flame.png</normaloff>:/icons/flame.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -97,6 +97,12 @@
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragOnly</enum>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
@@ -116,6 +122,7 @@
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../qad/application/qad_application.qrc"/>
|
||||
<include location="cdpult.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
BIN
qcd_utils/pult/icons/format-stroke-color.png
Normal file
BIN
qcd_utils/pult/icons/format-stroke-color.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -1,22 +1,23 @@
|
||||
#include "qcd_model.h"
|
||||
#include "cdutils_interface.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "piqt.h"
|
||||
#include <QDebug>
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
#include <QMimeData>
|
||||
#include "qvariantedit.h"
|
||||
#include "qad_types.h"
|
||||
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
// CDKItem
|
||||
|
||||
CDItem::CDItem(CDUtils::Interface * i, int index, CDItem::CDItemType type, CDItem *parent) {
|
||||
CDItem::CDItem(CDUtils::Interface * i, int _index, CDItem::CDItemType type, CDItem *parent) {
|
||||
interface = i;
|
||||
index_ = index;
|
||||
index_ = _index;
|
||||
parent_ = parent;
|
||||
type_ = type;
|
||||
}
|
||||
@@ -31,20 +32,25 @@ QVariant CDItem::data(int column, int role) const {
|
||||
if (role == Qt::BackgroundRole) {
|
||||
switch (type_) {
|
||||
case ItemCDType: {
|
||||
CDType & t = interface->section(buildPath())[index_];
|
||||
CDType & t(interface->section(buildPath())[index_]);
|
||||
if (t.errorString().isEmpty()) return QBrush(QColor(255, 250, 230));
|
||||
else return QBrush(QColor(255, 128, 128));
|
||||
}
|
||||
case ItemCDSection: return QBrush(QColor(230, 250, 230));
|
||||
}
|
||||
}
|
||||
if (role == Qt::CheckStateRole && type_ == ItemCDType && column == 4) {
|
||||
CDType & t = interface->section(buildPath())[index_];
|
||||
if (t.type() == "b") return t.toBool() ? Qt::Checked : Qt::Unchecked;
|
||||
else QVariant();
|
||||
if (role == Qt::CheckStateRole && type_ == ItemCDType) {
|
||||
CDType & t(interface->section(buildPath())[index_]);
|
||||
if (column == cValue && t.cd_type() == CDType::cdK) {
|
||||
if (t.type() == "b") return t.toBool() ? Qt::Checked : Qt::Unchecked;
|
||||
else QVariant();
|
||||
}
|
||||
if (column == cName_Cmd && t.cd_type() == CDType::cdX) {
|
||||
return t.isSelectedX() ? Qt::Checked : Qt::Unchecked;
|
||||
}
|
||||
}
|
||||
if (role == Qt::ToolTipRole && type_ == ItemCDType) {
|
||||
CDType & t = interface->section(buildPath())[index_];
|
||||
CDType & t(interface->section(buildPath())[index_]);
|
||||
return PI2QString(t.errorString());
|
||||
}
|
||||
if (role != Qt::DisplayRole && role != Qt::EditRole) return QVariant();
|
||||
@@ -54,12 +60,14 @@ QVariant CDItem::data(int column, int role) const {
|
||||
switch (type_) {
|
||||
case ItemCDType:
|
||||
switch (column) {
|
||||
case 0: return QString::number(index_);
|
||||
case 1: return PI2QString(rs[index_].name());
|
||||
case 2: return stringType(rs[index_].type());
|
||||
case 3: return PI2QString(rs[index_].formula());
|
||||
case 4: return value(rs[index_], role);
|
||||
case 5: return PI2QString(rs[index_].comment());
|
||||
case cID: return QString::number(index_);
|
||||
case cName_Cmd: return PI2QString(rs[index_].name());
|
||||
case cType: return stringType(rs[index_].type());
|
||||
case cXMode: return QVariant::fromValue(xModeEnum(rs[index_].xmode()));
|
||||
case cXAvg: return rs[index_].avg();
|
||||
case cExpression: return PI2QString(rs[index_].formula());
|
||||
case cValue: return value(rs[index_], role);
|
||||
case cComment: return PI2QString(rs[index_].comment());
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
@@ -67,9 +75,9 @@ QVariant CDItem::data(int column, int role) const {
|
||||
s = rs.section(index_);
|
||||
// piCout << rs.name << rs.alias << s.name << s.alias;
|
||||
switch (column) {
|
||||
case 0: return QString("[") + QString::number(index_) + QString("]");
|
||||
case 1: return PI2QString(s.alias);
|
||||
case 2: return PI2QString(s.name);
|
||||
case cID: return QString("[") + QString::number(index_) + QString("]");
|
||||
case cName_Cmd: return PI2QString(s.alias);
|
||||
case cType: return PI2QString(s.name);
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
@@ -92,11 +100,28 @@ QVariant CDItem::value(CDType t, int role) const {
|
||||
}
|
||||
|
||||
|
||||
bool CDItem::setData(int column, const QVariant &value) {
|
||||
if ((column == 3 || column == 4) && type_ == ItemCDType) {
|
||||
interface->section(buildPath())[index_].setValue(Q2PIString(value.toString()));
|
||||
interface->calculate();
|
||||
return true;
|
||||
bool CDItem::setData(int column, const QVariant & value) {
|
||||
if (type_ == ItemCDType) {
|
||||
CDType & t(interface->section(buildPath())[index_]);
|
||||
if ((column == cExpression || column == cValue) && (t.cd_type() == CDType::cdK)) {
|
||||
interface->section(buildPath())[index_].setValue(Q2PIString(value.toString()));
|
||||
interface->calculate();
|
||||
return true;
|
||||
}
|
||||
if (t.cd_type() == CDType::cdX) {
|
||||
switch (column) {
|
||||
case cName_Cmd:
|
||||
X.setEnabled(t, value.toBool());
|
||||
return true;
|
||||
case cXMode:
|
||||
t.setXMode((CDType::XMode)value.toInt());
|
||||
return true;
|
||||
case cXAvg:
|
||||
t.setAvg(piMax(value.toInt(), 1));
|
||||
return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -136,13 +161,51 @@ QString CDItem::stringType(const PIString & t) const {
|
||||
}
|
||||
|
||||
|
||||
QAD::Enum CDItem::xModeEnum(int v) const {
|
||||
QAD::Enum ret;
|
||||
ret << QAD::Enumerator(CDType::X_Current, "Current")
|
||||
<< QAD::Enumerator(CDType::X_All_Avg, "All, Averaging");
|
||||
ret.selectValue(v);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// CDKDelegate
|
||||
|
||||
CDDelegate::CDDelegate(QObject *parent) : QStyledItemDelegate(parent) {
|
||||
}
|
||||
|
||||
|
||||
QWidget *CDDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
void CDDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const {
|
||||
CDItem * item = ((CDItemModel*)index.model())->getItem(index);
|
||||
if (item) {
|
||||
if (item->itemType() == CDItem::ItemCDType && item->interface->cdType() == CDType::cdC) {
|
||||
QStyleOptionButton bo;
|
||||
bo.direction = option.direction;
|
||||
bo.fontMetrics = option.fontMetrics;
|
||||
bo.palette = option.palette;
|
||||
bo.rect = option.rect;
|
||||
bo.state = option.state;// & ~(QStyle::State_HasFocus | QStyle::State_MouseOver);
|
||||
bo.text = item->data(1, Qt::DisplayRole).toString();
|
||||
QWidget * v = (QWidget*)(painter->device());
|
||||
if (v) {
|
||||
QPoint cp = v->mapFromGlobal(QCursor::pos());
|
||||
if (bo.rect.contains(cp, true)) {
|
||||
//bo.state |= QStyle::State_MouseOver;
|
||||
if (qApp->mouseButtons().testFlag(Qt::LeftButton))
|
||||
bo.state |= QStyle::State_On;
|
||||
}
|
||||
}
|
||||
qApp->style()->drawControl(QStyle::CE_PushButton, &bo, painter);
|
||||
return;
|
||||
}
|
||||
}
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
|
||||
}
|
||||
|
||||
|
||||
QWidget * CDDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
return new QVariantEdit(parent);
|
||||
}
|
||||
|
||||
@@ -192,7 +255,7 @@ CDItemModel::~CDItemModel() {
|
||||
|
||||
QVariant CDItemModel::data(const QModelIndex &index, int role) const {
|
||||
if (!index.isValid()) return QVariant();
|
||||
CDItem *item = getItem(index);
|
||||
CDItem * item = getItem(index);
|
||||
return item->data(index.column(), role);
|
||||
}
|
||||
|
||||
@@ -200,12 +263,14 @@ QVariant CDItemModel::data(const QModelIndex &index, int role) const {
|
||||
QVariant CDItemModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||
switch (section) {
|
||||
case 0: return trUtf8("Index");
|
||||
case 1: return trUtf8("Name");
|
||||
case 2: return trUtf8("Type");
|
||||
case 3: return trUtf8("Expression");
|
||||
case 4: return trUtf8("Value");
|
||||
case 5: return trUtf8("Comment");
|
||||
case cID: return trUtf8("Index");
|
||||
case cName_Cmd: return interface->cdType() == CDType::cdC ? trUtf8("Command") : trUtf8("Name");
|
||||
case cType: return trUtf8("Type");
|
||||
case cXMode: return trUtf8("Mode");
|
||||
case cXAvg: return trUtf8("Averaging");
|
||||
case cExpression: return trUtf8("Expression");
|
||||
case cValue: return trUtf8("Value");
|
||||
case cComment: return trUtf8("Comment");
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
@@ -213,7 +278,7 @@ QVariant CDItemModel::headerData(int section, Qt::Orientation orientation, int r
|
||||
|
||||
|
||||
QModelIndex CDItemModel::index(int row, int column, const QModelIndex &parent) const {
|
||||
if (parent.isValid() && parent.column() != 0) return QModelIndex();
|
||||
if (parent.isValid() && parent.column() != cID) return QModelIndex();
|
||||
CDItem * p = getItem(parent);
|
||||
CDItem * c = p->childs.value(row, 0);
|
||||
if (c) return createIndex(row, column, c);
|
||||
@@ -226,18 +291,18 @@ QModelIndex CDItemModel::parent(const QModelIndex &index) const {
|
||||
CDItem * c = getItem(index);
|
||||
CDItem * p = c->parent_;
|
||||
if (p == root) return QModelIndex();
|
||||
return createIndex(p->parent_->childs.indexOf(p), 0, p);
|
||||
return createIndex(p->parent_->childs.indexOf(p), cID, p);
|
||||
}
|
||||
|
||||
|
||||
int CDItemModel::rowCount(const QModelIndex &parent) const {
|
||||
CDItem *p = getItem(parent);
|
||||
CDItem * p = getItem(parent);
|
||||
return p->childs.count();
|
||||
}
|
||||
|
||||
|
||||
int CDItemModel::columnCount(const QModelIndex &parent) const {
|
||||
return 6;
|
||||
return cLastColumn;
|
||||
}
|
||||
|
||||
|
||||
@@ -246,30 +311,42 @@ Qt::ItemFlags CDItemModel::flags(const QModelIndex & index) const {
|
||||
Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
CDItem * item = getItem(index);
|
||||
if (!item) return 0;
|
||||
CDType & t(interface->section(item->buildPath())[item->index_]);
|
||||
if ((index.column() == 3 || index.column() == 4) &&
|
||||
(item->type_ == CDItem::ItemCDType) &&
|
||||
(t.cd_type() == CDType::cdK))
|
||||
f |= Qt::ItemIsEditable;
|
||||
if (item->type_ == CDItem::ItemCDType && index.column() == 4) {
|
||||
if (t.type() == "b") {
|
||||
f |= Qt::ItemIsUserCheckable;
|
||||
// piCout << "ItemIsUserCheckable";
|
||||
if (item->type_ == CDItem::ItemCDType) {
|
||||
CDType & t(interface->section(item->buildPath())[item->index_]);
|
||||
if (t.cd_type() == CDType::cdK) {
|
||||
if (index.column() == cExpression || index.column() == cValue)
|
||||
f |= Qt::ItemIsEditable;
|
||||
if (index.column() == cValue && t.type() == "b")
|
||||
f |= Qt::ItemIsUserCheckable;
|
||||
}
|
||||
if (t.cd_type() == CDType::cdX) {
|
||||
if (index.column() == cXMode || index.column() == cXAvg)
|
||||
f |= Qt::ItemIsEditable;
|
||||
if (index.column() == cName_Cmd)
|
||||
f |= Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled;
|
||||
}
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
bool CDItemModel::setData(const QModelIndex & index, const QVariant &value, int role) {
|
||||
if (role == Qt::CheckStateRole && index.column() == 4) {
|
||||
bool CDItemModel::setData(const QModelIndex & index, const QVariant & value, int role) {
|
||||
if (role == Qt::CheckStateRole && (index.column() == cName_Cmd || index.column() == cValue)) {
|
||||
CDItem * item = getItem(index);
|
||||
if (item->type_ == CDItem::ItemCDType) {
|
||||
CDType t = interface->section(item->buildPath())[item->index_];
|
||||
if (t.type() == "b") {
|
||||
bool result = item->setData(index.column(), PI2QString(PIString::fromBool(value.toBool())));
|
||||
QModelIndex rin(CDItemModel::index(index.row(), 3, index.parent()));
|
||||
emit dataChanged(rin, rin);
|
||||
CDType & t(interface->section(item->buildPath())[item->index_]);
|
||||
if (index.column() == cValue && (t.cd_type() == CDType::cdK)) {
|
||||
if (t.type() == "b") {
|
||||
bool result = item->setData(index.column(), PI2QString(PIString::fromBool(value.toBool())));
|
||||
QModelIndex rin(CDItemModel::index(index.row(), cExpression, index.parent()));
|
||||
emit dataChanged(rin, rin);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (index.column() == cName_Cmd && (t.cd_type() == CDType::cdX)) {
|
||||
bool result = item->setData(index.column(), value);
|
||||
//QModelIndex rin(CDItemModel::index(index.row(), 1, index.parent()));
|
||||
//emit dataChanged(rin, rin);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -278,7 +355,7 @@ bool CDItemModel::setData(const QModelIndex & index, const QVariant &value, int
|
||||
CDItem * item = getItem(index);
|
||||
bool result = item->setData(index.column(), value);
|
||||
if (result) {
|
||||
QModelIndex rin(CDItemModel::index(index.row(), 3, index.parent()));
|
||||
QModelIndex rin(CDItemModel::index(index.row(), cExpression, index.parent()));
|
||||
emit dataChanged(rin, rin);
|
||||
emit dataChanged(index, index);
|
||||
}
|
||||
@@ -286,6 +363,23 @@ bool CDItemModel::setData(const QModelIndex & index, const QVariant &value, int
|
||||
}
|
||||
|
||||
|
||||
QMimeData * CDItemModel::mimeData(const QModelIndexList & indexes) const {
|
||||
if (indexes.size() == 1) {
|
||||
QModelIndex index = indexes[0];
|
||||
if (index.isValid() && interface->cdType() == CDType::cdX) {
|
||||
CDItem * item = getItem(index);
|
||||
if (item) {
|
||||
CDType & t(interface->section(item->buildPath())[item->index_]);
|
||||
QMimeData * mime = new QMimeData();
|
||||
mime->setText(PI2QString(CDCore::pathToString(t.path())));
|
||||
return mime;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QAbstractItemModel::mimeData(indexes);
|
||||
}
|
||||
|
||||
|
||||
void CDItemModel::rebuildModel() {
|
||||
beginResetModel();
|
||||
internalRebuild();
|
||||
|
||||
@@ -10,6 +10,18 @@ namespace CDUtils {
|
||||
class CDType;
|
||||
class CDSection;
|
||||
class Interface;
|
||||
|
||||
enum Column {
|
||||
cID ,
|
||||
cName_Cmd ,
|
||||
cType ,
|
||||
cXMode ,
|
||||
cXAvg ,
|
||||
cExpression,
|
||||
cValue ,
|
||||
cComment ,
|
||||
cLastColumn,
|
||||
};
|
||||
}
|
||||
|
||||
namespace QAD {
|
||||
@@ -23,17 +35,21 @@ class CDItem {
|
||||
friend class CDItemModel;
|
||||
public:
|
||||
enum CDItemType{ItemCDType, ItemCDSection};
|
||||
CDItem(CDUtils::Interface * interface, int index, CDItemType type, CDItem * parent);
|
||||
CDItem(CDUtils::Interface * interface, int _index, CDItemType type, CDItem * parent);
|
||||
~CDItem();
|
||||
QVariant data(int column, int role) const;
|
||||
QVariant value(CDUtils::CDType t, int role) const;
|
||||
bool setData(int column, const QVariant & value);
|
||||
|
||||
private:
|
||||
CDItemType itemType() const {return type_;}
|
||||
PIDeque<int> buildPath() const;
|
||||
QString stringType(const PIString & t) const;
|
||||
int index() const {return index_;}
|
||||
|
||||
CDUtils::Interface * interface;
|
||||
|
||||
private:
|
||||
QString stringType(const PIString & t) const;
|
||||
QAD::Enum xModeEnum(int v) const;
|
||||
|
||||
CDItem * parent_;
|
||||
int index_;
|
||||
CDItemType type_;
|
||||
@@ -47,16 +63,19 @@ class CDDelegate : public QStyledItemDelegate
|
||||
public:
|
||||
CDDelegate(QObject *parent = 0);
|
||||
|
||||
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
|
||||
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class CDItemModel : public QAbstractItemModel {
|
||||
Q_OBJECT
|
||||
friend class CDView;
|
||||
public:
|
||||
explicit CDItemModel(int type_, QObject *parent = 0);
|
||||
~CDItemModel();
|
||||
@@ -69,6 +88,8 @@ public:
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||
QMimeData * mimeData(const QModelIndexList & indexes) const;
|
||||
CDItem * getItem(const QModelIndex & index) const;
|
||||
|
||||
void buildItem(CDItem * it, CDUtils::CDSection &r);
|
||||
|
||||
@@ -78,7 +99,6 @@ public slots:
|
||||
|
||||
private:
|
||||
void internalRebuild();
|
||||
CDItem * getItem(const QModelIndex & index) const;
|
||||
|
||||
CDUtils::Interface * interface;
|
||||
CDItem * root;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <QDir>
|
||||
#include <QMouseEvent>
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "cdutils_c.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "qcd_view.h"
|
||||
#include "qcd_model.h"
|
||||
@@ -10,9 +12,10 @@
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
CDView::CDView(QWidget *parent) : QTreeView(parent) {
|
||||
CDView::CDView(QWidget * parent) : QTreeView(parent) {
|
||||
type_ = -1;
|
||||
model_ = 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);
|
||||
@@ -43,28 +46,76 @@ void CDView::setType(int cdt) {
|
||||
CONNECTU(&X, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&X, receiveFailed, this, pi_cd_receiveFailed);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
QTreeView::mousePressEvent(e);
|
||||
}
|
||||
|
||||
|
||||
void CDView::mouseReleaseEvent(QMouseEvent * e) {
|
||||
if (type_ == CDType::cdC) {
|
||||
QModelIndex i = indexAt(e->pos());
|
||||
if (i.isValid() && i.column() == cName_Cmd)
|
||||
update(i);
|
||||
}
|
||||
QTreeView::mouseReleaseEvent(e);
|
||||
}
|
||||
|
||||
|
||||
void CDView::currentChanged(const QModelIndex & cur, const QModelIndex & prev) {
|
||||
if (type_ == CDType::cdC) {
|
||||
if (prev.isValid() && prev.column() == cName_Cmd)
|
||||
update(prev);
|
||||
}
|
||||
QTreeView::currentChanged(cur, prev);
|
||||
}
|
||||
|
||||
|
||||
void CDView::refresh() {
|
||||
if (type_ < 0) return;
|
||||
if (!model_) {
|
||||
model_ = new CDItemModel(type_);
|
||||
setModel(model_);
|
||||
setItemDelegateForColumn(4, new CDDelegate());
|
||||
setItemDelegateForColumn(type_ == CDType::cdC ? cName_Cmd : cValue, 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(3, true);
|
||||
setColumnHidden(cExpression, true);
|
||||
break;
|
||||
case CDType::cdC:
|
||||
setColumnHidden(cType, true);
|
||||
setColumnHidden(cXMode, true);
|
||||
setColumnHidden(cXAvg, true);
|
||||
setColumnHidden(cExpression, true);
|
||||
setColumnHidden(cValue, true);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
expandAll();
|
||||
for (int i=0; i<6; i++) resizeColumnToContents(i);
|
||||
for (int i = 0; i < model_->columnCount(); i++) resizeColumnToContents(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +123,7 @@ void CDView::setFile(const QString & filename) {
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK: K.setFileName(Q2PIString(filename)); break;
|
||||
case CDType::cdX: X.setFileName(Q2PIString(filename)); break;
|
||||
case CDType::cdC: C.setFileName(Q2PIString(filename)); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -81,16 +133,16 @@ bool CDView::inProgress() const {
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK: return K.inProgress(); break;
|
||||
case CDType::cdX: return X.inProgress(); break;
|
||||
case CDType::cdC: return C.inProgress(); break;
|
||||
default: break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void CDView::startPing() {
|
||||
void CDView::startX(double freq) {
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK: K.startPing(); break;
|
||||
case CDType::cdX: X.startPing(); break;
|
||||
case CDType::cdX: X.start(freq); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -111,6 +163,7 @@ void CDView::send() {
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK: K.send(); break;
|
||||
case CDType::cdX: X.send(); break;
|
||||
case CDType::cdC: C.send(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -121,6 +174,7 @@ void CDView::receive() {
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK: K.request(); break;
|
||||
case CDType::cdX: X.request(); break;
|
||||
case CDType::cdC: C.request(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -130,6 +184,7 @@ void CDView::save() {
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK: K.writeFile(); break;
|
||||
case CDType::cdX: X.writeFile(); break;
|
||||
case CDType::cdC: C.writeFile(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -145,6 +200,10 @@ void CDView::load() {
|
||||
X.readFile();
|
||||
X.calculate();
|
||||
break;
|
||||
case CDType::cdC:
|
||||
C.readFile();
|
||||
C.calculate();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
refresh();
|
||||
@@ -156,6 +215,7 @@ void CDView::clear() {
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK: K.root() = CDSection(); break;
|
||||
case CDType::cdX: X.root() = CDSection(); break;
|
||||
case CDType::cdC: C.root() = CDSection(); break;
|
||||
default: break;
|
||||
}
|
||||
refresh();
|
||||
@@ -169,6 +229,7 @@ void CDView::buildFromHeader(const QString & description, int mode) {
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK: K.update(&f, mode); break;
|
||||
case CDType::cdX: X.update(&f, mode); break;
|
||||
case CDType::cdC: C.update(&f, mode); break;
|
||||
default: break;
|
||||
}
|
||||
refresh();
|
||||
@@ -179,11 +240,25 @@ void CDView::calculate() {
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK: K.calculate(); break;
|
||||
case CDType::cdX: X.calculate(); break;
|
||||
case CDType::cdC: C.calculate(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CDView::indexClicked(const QModelIndex & i) {
|
||||
if (!model_ || !i.isValid() || type_ != CDType::cdC || i.column() != cName_Cmd) return;
|
||||
CDItem * item = model_->getItem(i);
|
||||
if (!item) return;
|
||||
if (item->itemType() != CDItem::ItemCDType) return;
|
||||
CDType & t(model_->interface->section(item->buildPath())[item->index()]);
|
||||
C.sendCommand(t);
|
||||
emit commandSended(PI2QString(t.pathString().join(".")));
|
||||
//piCout << t;
|
||||
qDebug() << PI2QString(t.pathString().join("."));
|
||||
}
|
||||
|
||||
|
||||
void CDView::cd_sendFailed() {
|
||||
busyStatusChanged(false);
|
||||
emit messageStatus("send failed");
|
||||
@@ -211,4 +286,3 @@ void CDView::cd_receiveSucceed() {
|
||||
emit messageStatus("receive success");
|
||||
emit receiveSucceed();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,17 @@ public:
|
||||
void setType(int cdt);
|
||||
void setFile(const QString & filename);
|
||||
bool inProgress() const;
|
||||
void startPing();
|
||||
void startX(double freq = 20.);
|
||||
CDUtils::CDSection * root();
|
||||
QString typeLetter() const;
|
||||
|
||||
CDItemModel * CDModel() {return model_;}
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent * );
|
||||
void mouseReleaseEvent(QMouseEvent * );
|
||||
void currentChanged(const QModelIndex & cur, const QModelIndex & prev);
|
||||
|
||||
public slots:
|
||||
void refresh();
|
||||
void send();
|
||||
@@ -39,6 +44,7 @@ public slots:
|
||||
void calculate();
|
||||
|
||||
private slots:
|
||||
void indexClicked(const QModelIndex & i);
|
||||
void cd_sendFailed();
|
||||
void cd_sendSucceed();
|
||||
void cd_receiveFailed();
|
||||
@@ -59,6 +65,7 @@ signals:
|
||||
void receiveFailed();
|
||||
void receiveSucceed();
|
||||
void messageStatus(QString msg);
|
||||
void commandSended(QString msg);
|
||||
void busyStatusChanged(bool busy);
|
||||
|
||||
void _qcd_sendFailed(); // PRIVATE
|
||||
|
||||
Reference in New Issue
Block a user