git-svn-id: svn://db.shs.com.ru/libs@379 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
17
qcd_utils/pult/cdgraphics.cpp
Normal file
17
qcd_utils/pult/cdgraphics.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include "cdgraphics.h"
|
||||||
|
#include "cdutils_core.h"
|
||||||
|
#include "qcd_core.h"
|
||||||
|
#include "qcd_model.h"
|
||||||
|
|
||||||
|
|
||||||
|
CDGraphics::CDGraphics(QWidget * parent) : QWidget(parent), Ui::CDGraphics() {
|
||||||
|
setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CDGraphics::~CDGraphics() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDGraphics::reset() {
|
||||||
|
}
|
||||||
25
qcd_utils/pult/cdgraphics.h
Normal file
25
qcd_utils/pult/cdgraphics.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef CDGRAPHICS_H
|
||||||
|
#define CDGRAPHICS_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "ui_cdgraphics.h"
|
||||||
|
|
||||||
|
|
||||||
|
class CDGraphics : public QWidget, public Ui::CDGraphics
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit CDGraphics(QWidget *parent = 0);
|
||||||
|
~CDGraphics();
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CDGRAPHICS_H
|
||||||
19
qcd_utils/pult/cdgraphics.ui
Normal file
19
qcd_utils/pult/cdgraphics.ui
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CDGraphics</class>
|
||||||
|
<widget class="QWidget" name="CDGraphics">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>689</width>
|
||||||
|
<height>459</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>CD Pult</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -7,5 +7,8 @@
|
|||||||
<file>icons/dialog-cancel.png</file>
|
<file>icons/dialog-cancel.png</file>
|
||||||
<file>icons/dialog-ok-apply.png</file>
|
<file>icons/dialog-ok-apply.png</file>
|
||||||
<file>icons/timer.png</file>
|
<file>icons/timer.png</file>
|
||||||
|
<file>icons/document-revert.png</file>
|
||||||
|
<file>icons/flame.png</file>
|
||||||
|
<file>icons/view-refresh.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -1,41 +1,43 @@
|
|||||||
#include <QCloseEvent>
|
#include "edockwidget.h"
|
||||||
#include "cdpultwindow.h"
|
#include "cdpultwindow.h"
|
||||||
#include "ui_cdpultwindow.h"
|
|
||||||
#include "cdutils_k.h"
|
#include "cdutils_k.h"
|
||||||
#include "cdutils_core.h"
|
#include "cdutils_core.h"
|
||||||
#include "qcd_core.h"
|
#include "qcd_core.h"
|
||||||
#include "qcd_kmodel.h"
|
#include "qcd_model.h"
|
||||||
#include "qcd_modedialog.h"
|
#include "qcd_modedialog.h"
|
||||||
|
#include "chunkstream.h"
|
||||||
|
#include "qvariantedit.h"
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
|
||||||
|
|
||||||
CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), ui(new Ui::CDPultWindow) {
|
CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), Ui::CDPultWindow() {
|
||||||
CDUtils::CDCore::instance()->initPult();
|
setupUi(this);
|
||||||
qRegisterMetaType<LogIcon>("LogIcon");
|
|
||||||
log_icons[OKIcon] = QIcon(":/icons/dialog-ok-apply.png");
|
|
||||||
log_icons[FailIcon] = QIcon(":/icons/dialog-cancel.png");
|
|
||||||
log_icons[WaitIcon] = QIcon(":/icons/timer.png");
|
|
||||||
ui->setupUi(this);
|
|
||||||
centralWidget()->hide();
|
centralWidget()->hide();
|
||||||
setRecentMenu(ui->menuOpen_recent);
|
CDUtils::CDCore::instance()->initPult();
|
||||||
|
widgetK->setType(CDUtils::CDType::cdK);
|
||||||
|
widgetX->setType(CDUtils::CDType::cdX);
|
||||||
|
editFileK->setValue(QVariant::fromValue(QAD::File("", "*.dat")));
|
||||||
|
editFileX->setValue(QVariant::fromValue(QAD::File("", "*.dat")));
|
||||||
|
editFileC->setValue(QVariant::fromValue(QAD::File("", "*.dat")));
|
||||||
|
log_icons[CDViewWidget::OKIcon] = QIcon(":/icons/dialog-ok-apply.png");
|
||||||
|
log_icons[CDViewWidget::FailIcon] = QIcon(":/icons/dialog-cancel.png");
|
||||||
|
log_icons[CDViewWidget::WaitIcon] = QIcon(":/icons/timer.png");
|
||||||
|
setRecentMenu(menuOpen_recent);
|
||||||
ribbon = new Ribbon(this);
|
ribbon = new Ribbon(this);
|
||||||
session.setFile("session_cdpult.conf");
|
session.setFile("session_cdpult.conf");
|
||||||
session.addEntry(this);
|
session.addEntry(this);
|
||||||
session.addEntry(ribbon->tabWidget());
|
session.addEntry(ribbon->tabWidget());
|
||||||
session.load();
|
session.load();
|
||||||
reset();
|
reset();
|
||||||
connect(ui->viewK, SIGNAL(KSendSucceed()), this, SLOT(KSended()));
|
connect(widgetK, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString)));
|
||||||
connect(ui->viewK, SIGNAL(KReceiveSucceed()), this, SLOT(KReceived()));
|
connect(widgetX, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString)));
|
||||||
connect(ui->viewK, SIGNAL(KSendFailed()), this, SLOT(KSendFailed()));
|
|
||||||
connect(ui->viewK, SIGNAL(KReceiveFailed()), this, SLOT(KReceiveFailed()));
|
|
||||||
if (windowState() == Qt::WindowMinimized)
|
if (windowState() == Qt::WindowMinimized)
|
||||||
setWindowState(Qt::WindowNoState);
|
setWindowState(Qt::WindowNoState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CDPultWindow::~CDPultWindow() {
|
CDPultWindow::~CDPultWindow() {
|
||||||
delete ui;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -44,26 +46,6 @@ void CDPultWindow::loadFile(const QString & fp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CDPultWindow::KReceived() {
|
|
||||||
addToLog(OKIcon, "K received succesfull");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDPultWindow::KSended() {
|
|
||||||
addToLog(OKIcon, "K sended succesfull");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDPultWindow::KSendFailed() {
|
|
||||||
addToLog(FailIcon, "K NOT sended");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDPultWindow::KReceiveFailed() {
|
|
||||||
addToLog(FailIcon, "K NOT received");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDPultWindow::closeEvent(QCloseEvent *e) {
|
void CDPultWindow::closeEvent(QCloseEvent *e) {
|
||||||
EMainWindow::closeEvent(e);
|
EMainWindow::closeEvent(e);
|
||||||
if (!e->isAccepted())
|
if (!e->isAccepted())
|
||||||
@@ -76,29 +58,45 @@ void CDPultWindow::closeEvent(QCloseEvent *e) {
|
|||||||
|
|
||||||
void CDPultWindow::reset(bool full) {
|
void CDPultWindow::reset(bool full) {
|
||||||
setWindowTitle(QString("CD Pult"));
|
setWindowTitle(QString("CD Pult"));
|
||||||
ui->viewK->setKFile("");
|
widgetK->reset();
|
||||||
// ui->viewK->clearK();
|
|
||||||
file_name.clear();
|
|
||||||
ui->viewK->refresh();
|
|
||||||
setChanged(false);
|
setChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CDPultWindow::load(const QString & path) {
|
bool CDPultWindow::load(const QString & path) {
|
||||||
ui->viewK->setKFile(path);
|
QPIConfig conf(path, QIODevice::ReadOnly);
|
||||||
ui->viewK->loadK();
|
QAD::File f = editFileK->value().value<QAD::File>();
|
||||||
QFileInfo fi(path);
|
checkSyncFiles->setChecked(false);
|
||||||
setWindowTitle(QString("CD Pult - %1").arg(fi.baseName()));
|
editFileK->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_k").value(), f.filter)));
|
||||||
|
editFileX->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_x").value(), f.filter)));
|
||||||
|
editFileC->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_c").value(), f.filter)));
|
||||||
|
checkSyncFiles->setChecked(conf.getValue("sync_files"));
|
||||||
|
lineSessionName->setText(conf.getValue("session_name"));
|
||||||
|
checkHasK->setChecked(conf.getValue("has_k"));
|
||||||
|
checkHasX->setChecked(conf.getValue("has_x"));
|
||||||
|
checkHasC->setChecked(conf.getValue("has_c"));
|
||||||
|
setChanged(false);
|
||||||
|
file_name = path;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CDPultWindow::save(const QString & path) {
|
bool CDPultWindow::save(const QString & path) {
|
||||||
ui->viewK->setKFile(path);
|
QPIConfig conf(path, QIODevice::ReadWrite);
|
||||||
ui->viewK->saveK();
|
conf.clear();
|
||||||
QFileInfo fi(path);
|
conf.setValue("file_k", editFileK->value().value<QAD::File>().file);
|
||||||
setWindowTitle(QString("CD Pult - %1").arg(fi.baseName()));
|
conf.setValue("file_x", editFileX->value().value<QAD::File>().file);
|
||||||
|
conf.setValue("file_c", editFileC->value().value<QAD::File>().file);
|
||||||
|
conf.setValue("sync_files", checkSyncFiles->isChecked());
|
||||||
|
conf.setValue("session_name", lineSessionName->text());
|
||||||
|
conf.setValue("has_k", checkHasK->isChecked());
|
||||||
|
conf.setValue("has_x", checkHasX->isChecked());
|
||||||
|
conf.setValue("has_c", checkHasC->isChecked());
|
||||||
|
file_name = path;
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
//widgetK->setFile(path);
|
||||||
|
//widgetK->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -112,42 +110,56 @@ void CDPultWindow::savingSession(QPIConfig & conf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CDPultWindow::addToLog(LogIcon icon, const QString & msg) {
|
void CDPultWindow::addToLog(CDViewWidget::LogIcon icon, const QString & msg) {
|
||||||
QListWidgetItem * ni = new QListWidgetItem(log_icons[icon], "(" + QTime::currentTime().toString() + ") " + msg);
|
QListWidgetItem * ni = new QListWidgetItem(log_icons[icon], "(" + QTime::currentTime().toString() + ") " + msg);
|
||||||
bool s = ui->listLog->verticalScrollBar()->value() == ui->listLog->verticalScrollBar()->maximum();
|
bool s = listLog->verticalScrollBar()->value() == listLog->verticalScrollBar()->maximum();
|
||||||
ui->listLog->addItem(ni);
|
listLog->addItem(ni);
|
||||||
if (s) ui->listLog->scrollToBottom();
|
if (s) listLog->scrollToBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CDPultWindow::on_actionSend_K_triggered() {
|
void CDPultWindow::on_editFileK_valueChanged(const QVariant & p) {
|
||||||
if (K.inProgress()) {addToLog(WaitIcon, "processing..."); return;}
|
if (!checkSyncFiles->isChecked()) return;
|
||||||
addToLog(WaitIcon, "Sending K...");
|
QFileInfo fi(p.value<QAD::File>().file);
|
||||||
ui->viewK->sendK();
|
if (fi.path().isEmpty()) return;
|
||||||
|
QString n = fi.baseName();
|
||||||
|
QString xn(n), cn(n);
|
||||||
|
if (n.contains("k")) {
|
||||||
|
xn.replace(n.indexOf("k"), 1, "x");
|
||||||
|
cn.replace(n.indexOf("k"), 1, "c");
|
||||||
|
} else {
|
||||||
|
xn += "_x";
|
||||||
|
cn += "_c";
|
||||||
|
}
|
||||||
|
QString ext = fi.suffix(), dot, dir;
|
||||||
|
QString kfn(fi.filePath());
|
||||||
|
if (!ext.isEmpty()) {
|
||||||
|
kfn.chop(ext.size());
|
||||||
|
if (kfn.endsWith(".")) {
|
||||||
|
kfn.chop(1);
|
||||||
|
dot = ".";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!fi.path().isEmpty() && fi.path() != ".") {
|
||||||
|
dir = fi.path();
|
||||||
|
if (!dir.endsWith("/"))
|
||||||
|
dir += "/";
|
||||||
|
}
|
||||||
|
QAD::File f = editFileK->value().value<QAD::File>();
|
||||||
|
f.file = dir + xn + dot + ext; editFileX->setValue(QVariant::fromValue(f));
|
||||||
|
f.file = dir + cn + dot + ext; editFileC->setValue(QVariant::fromValue(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CDPultWindow::on_actionReceive_K_triggered() {
|
void CDPultWindow::on_buttonSessionApply_clicked() {
|
||||||
if (K.inProgress()) {addToLog(WaitIcon, "processing..."); return;}
|
widgetK->setFile(editFileK->value().value<QAD::File>().file);
|
||||||
addToLog(WaitIcon, "Receiving K...");
|
widgetX->setFile(editFileX->value().value<QAD::File>().file);
|
||||||
ui->viewK->receiveK();
|
dockCDKView->setVisible(checkHasK->isChecked());
|
||||||
|
dockCDXView->setVisible(checkHasX->isChecked());
|
||||||
|
//dockCDCView->setVisible(checkHasC->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CDPultWindow::on_actionParse_triggered() {
|
void CDPultWindow::on_lineSessionName_textChanged(const QString & t) {
|
||||||
QString path = QFileDialog::getOpenFileName(this, "Select header file", "", "K Description(k_description.h);;Headers(*.h)");
|
setWindowTitle(QString("CD Pult - %1").arg(t));
|
||||||
if (path.isEmpty()) return;
|
|
||||||
CDUtils::UpdateModeFlags mode = CDUtils::SaveByName;
|
|
||||||
if (!K.root().isEmpty()) {
|
|
||||||
QCDModeDialog cdm;
|
|
||||||
if (cdm.exec() != QDialog::Accepted) return;
|
|
||||||
mode = cdm.mode();
|
|
||||||
}
|
|
||||||
ui->viewK->buildFromHeader(path, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDPultWindow::on_actionCalculate_K_triggered() {
|
|
||||||
ui->viewK->calculateK();
|
|
||||||
ui->viewK->refresh();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,20 +2,17 @@
|
|||||||
#define CDPULTWINDOW_H
|
#define CDPULTWINDOW_H
|
||||||
|
|
||||||
#include "emainwindow.h"
|
#include "emainwindow.h"
|
||||||
|
#include "ui_cdpultwindow.h"
|
||||||
|
#include "cdviewwidget.h"
|
||||||
#include "ribbon.h"
|
#include "ribbon.h"
|
||||||
#include "piobject.h"
|
#include "piobject.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
class CDPultWindow : public EMainWindow, public Ui::CDPultWindow
|
||||||
class CDPultWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CDPultWindow : public EMainWindow
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_ENUMS(LogIcon)
|
Q_ENUMS(LogIcon)
|
||||||
public:
|
public:
|
||||||
enum LogIcon {NoIcon, OKIcon, FailIcon, WaitIcon};
|
|
||||||
|
|
||||||
explicit CDPultWindow(QWidget *parent = 0);
|
explicit CDPultWindow(QWidget *parent = 0);
|
||||||
~CDPultWindow();
|
~CDPultWindow();
|
||||||
@@ -27,26 +24,20 @@ private:
|
|||||||
void reset(bool full = false);
|
void reset(bool full = false);
|
||||||
bool load(const QString & path);
|
bool load(const QString & path);
|
||||||
bool save(const QString & path);
|
bool save(const QString & path);
|
||||||
QString loadFilter() {return "CD file(*.dat)";}
|
QString loadFilter() {return "Pult session(*.conf)";}
|
||||||
QString saveFilter() {return "CD file(*.dat)";}
|
QString saveFilter() {return loadFilter();}
|
||||||
void loadingSession(QPIConfig & conf);
|
void loadingSession(QPIConfig & conf);
|
||||||
void savingSession(QPIConfig & conf);
|
void savingSession(QPIConfig & conf);
|
||||||
|
|
||||||
Ui::CDPultWindow *ui;
|
|
||||||
Ribbon * ribbon;
|
Ribbon * ribbon;
|
||||||
QMap<LogIcon, QIcon> log_icons;
|
QMap<CDViewWidget::LogIcon, QIcon> log_icons;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void KSended();
|
void addToLog(CDViewWidget::LogIcon icon, const QString & msg);
|
||||||
void KReceived();
|
void on_editFileK_valueChanged(const QVariant & p);
|
||||||
void KSendFailed();
|
void on_buttonSessionApply_clicked();
|
||||||
void KReceiveFailed();
|
|
||||||
void addToLog(LogIcon icon, const QString & msg);
|
|
||||||
void on_actionSend_K_triggered();
|
|
||||||
void on_actionReceive_K_triggered();
|
|
||||||
void on_actionParse_triggered();
|
|
||||||
void on_actionCalculate_K_triggered();
|
|
||||||
|
|
||||||
|
void on_lineSessionName_textChanged(const QString & t);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CDPULTWINDOW_H
|
#endif // CDPULTWINDOW_H
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>798</width>
|
||||||
<height>600</height>
|
<height>593</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -19,22 +19,14 @@
|
|||||||
<property name="dockOptions">
|
<property name="dockOptions">
|
||||||
<set>QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks|QMainWindow::VerticalTabs</set>
|
<set>QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks|QMainWindow::VerticalTabs</set>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="central">
|
<widget class="QWidget" name="central"/>
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QMenuBar" name="menuBar">
|
<widget class="QMenuBar" name="menuBar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>798</width>
|
||||||
<height>21</height>
|
<height>24</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuMain">
|
<widget class="QMenu" name="menuMain">
|
||||||
@@ -79,20 +71,8 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</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>
|
<item>
|
||||||
<widget class="CDKView" name="viewK"/>
|
<widget class="CDViewWidget" name="widgetK" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -106,7 +86,7 @@
|
|||||||
<string>Log</string>
|
<string>Log</string>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="dockWidgetArea">
|
<attribute name="dockWidgetArea">
|
||||||
<number>4</number>
|
<number>8</number>
|
||||||
</attribute>
|
</attribute>
|
||||||
<widget class="QWidget" name="dockWidgetContents_2">
|
<widget class="QWidget" name="dockWidgetContents_2">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
@@ -153,6 +133,184 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="EDockWidget" name="dockCDXView">
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../../qad/widgets/qad_widgets.qrc">
|
||||||
|
<normaloff>:/icons/qvariantedit.png</normaloff>:/icons/qvariantedit.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>X</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>1</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QWidget" name="dockWidgetContents_3">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="CDViewWidget" name="widgetX" native="true"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<widget class="EDockWidget" name="dockSession">
|
||||||
|
<property name="windowIcon">
|
||||||
|
<iconset resource="../../qad/application/qad_application.qrc">
|
||||||
|
<normaloff>:/icons/configure.png</normaloff>:/icons/configure.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Session</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>2</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QWidget" name="dockWidgetContents_4">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="buttonSessionLoad">
|
||||||
|
<property name="text">
|
||||||
|
<string>Load ...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../qad/application/qad_application.qrc">
|
||||||
|
<normaloff>:/icons/document-open-recent.png</normaloff>:/icons/document-open-recent.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="buttonSessionSave">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save ...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../qad/application/qad_application.qrc">
|
||||||
|
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="buttonSessionSaveAs">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save as ...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../qad/application/qad_application.qrc">
|
||||||
|
<normaloff>:/icons/document-save-as.png</normaloff>:/icons/document-save-as.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="buttonSessionApply">
|
||||||
|
<property name="text">
|
||||||
|
<string>Apply</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../qad/widgets/qad_widgets.qrc">
|
||||||
|
<normaloff>:/icons/dialog-ok-apply.png</normaloff>:/icons/dialog-ok-apply.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<property name="fieldGrowthPolicy">
|
||||||
|
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||||
|
</property>
|
||||||
|
<property name="labelAlignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="CLineEdit" name="lineSessionName"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>K file:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QVariantEdit" name="editFileK"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>X file:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QVariantEdit" name="editFileX"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>C file:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QVariantEdit" name="editFileC"/>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="checkSyncFiles">
|
||||||
|
<property name="text">
|
||||||
|
<string>Sync files</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0" colspan="2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkHasK">
|
||||||
|
<property name="text">
|
||||||
|
<string>K</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkHasX">
|
||||||
|
<property name="text">
|
||||||
|
<string>X</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkHasC">
|
||||||
|
<property name="text">
|
||||||
|
<string>C</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>1</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
<action name="actionOpen">
|
<action name="actionOpen">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../qad/application/qad_application.qrc">
|
<iconset resource="../../qad/application/qad_application.qrc">
|
||||||
@@ -167,7 +325,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionSave">
|
<action name="actionSave">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../qad/utils/qad_utils.qrc">
|
<iconset resource="../../qad/application/qad_application.qrc">
|
||||||
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -245,10 +403,7 @@
|
|||||||
<addaction name="actionParse"/>
|
<addaction name="actionParse"/>
|
||||||
<addaction name="actionCalculate_K"/>
|
<addaction name="actionCalculate_K"/>
|
||||||
<addaction name="menuMain"/>
|
<addaction name="menuMain"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="menuOpen_recent"/>
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
@@ -271,6 +426,16 @@
|
|||||||
<header>emainwindow.h</header>
|
<header>emainwindow.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>CLineEdit</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header>clineedit.h</header>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>QVariantEdit</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>qvariantedit.h</header>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>EDockWidget</class>
|
<class>EDockWidget</class>
|
||||||
<extends>QDockWidget</extends>
|
<extends>QDockWidget</extends>
|
||||||
@@ -278,16 +443,16 @@
|
|||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>CDKView</class>
|
<class>CDViewWidget</class>
|
||||||
<extends>QTreeView</extends>
|
<extends>QWidget</extends>
|
||||||
<header>qcd_kview.h</header>
|
<header>cdviewwidget.h</header>
|
||||||
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../qad/utils/qad_utils.qrc"/>
|
|
||||||
<include location="../../qad/widgets/qad_widgets.qrc"/>
|
|
||||||
<include location="../../qad/application/qad_application.qrc"/>
|
<include location="../../qad/application/qad_application.qrc"/>
|
||||||
<include location="../../qad/graphic/qpicalculator/qpicalculator.qrc"/>
|
<include location="../../qad/graphic/qpicalculator/qpicalculator.qrc"/>
|
||||||
|
<include location="../../qad/widgets/qad_widgets.qrc"/>
|
||||||
<include location="cdpult.qrc"/>
|
<include location="cdpult.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
@@ -339,5 +504,85 @@
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>checkSyncFiles</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>editFileX</receiver>
|
||||||
|
<slot>setDisabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>786</x>
|
||||||
|
<y>227</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>786</x>
|
||||||
|
<y>179</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>checkSyncFiles</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>editFileC</receiver>
|
||||||
|
<slot>setDisabled(bool)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>786</x>
|
||||||
|
<y>227</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>786</x>
|
||||||
|
<y>200</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonSessionLoad</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>CDPultWindow</receiver>
|
||||||
|
<slot>openFile()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>589</x>
|
||||||
|
<y>68</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>803</x>
|
||||||
|
<y>62</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonSessionSave</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>CDPultWindow</receiver>
|
||||||
|
<slot>saveFile()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>671</x>
|
||||||
|
<y>70</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>806</x>
|
||||||
|
<y>48</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonSessionSaveAs</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>CDPultWindow</receiver>
|
||||||
|
<slot>saveAsFile()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>754</x>
|
||||||
|
<y>66</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>805</x>
|
||||||
|
<y>106</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
78
qcd_utils/pult/cdviewwidget.cpp
Normal file
78
qcd_utils/pult/cdviewwidget.cpp
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
#include "cdviewwidget.h"
|
||||||
|
#include "cdutils_core.h"
|
||||||
|
#include "qcd_core.h"
|
||||||
|
#include "qcd_model.h"
|
||||||
|
#include "qcd_modedialog.h"
|
||||||
|
#include "qvariantedit.h"
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
|
||||||
|
CDViewWidget::CDViewWidget(QWidget * parent) : QWidget(parent), Ui::CDViewWidget() {
|
||||||
|
qRegisterMetaType<CDViewWidget::LogIcon>("CDViewWidget::LogIcon");
|
||||||
|
setupUi(this);
|
||||||
|
connect(view, SIGNAL(sendSucceed()), this, SLOT(sended()));
|
||||||
|
connect(view, SIGNAL(receiveSucceed()), this, SLOT(received()));
|
||||||
|
connect(view, SIGNAL(sendFailed()), this, SLOT(sendFailed()));
|
||||||
|
connect(view, SIGNAL(receiveFailed()), this, SLOT(receiveFailed()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CDViewWidget::~CDViewWidget() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDViewWidget::reset() {
|
||||||
|
setFile("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDViewWidget::setType(int t) {
|
||||||
|
view->setType((CDUtils::CDType::cdT)t);
|
||||||
|
tl_u = view->typeLetter().toUpper();
|
||||||
|
tl_l = view->typeLetter().toLower();
|
||||||
|
view->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDViewWidget::setFile(const QString & f) {
|
||||||
|
view->setFile(f);
|
||||||
|
view->load();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDViewWidget::on_buttonSend_clicked() {
|
||||||
|
if (view->inProgress()) {addToLog(WaitIcon, "processing..."); return;}
|
||||||
|
addToLog(WaitIcon, "Sending " + tl_u + "...");
|
||||||
|
view->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDViewWidget::on_buttonReceive_clicked() {
|
||||||
|
if (view->inProgress()) {addToLog(WaitIcon, "processing..."); return;}
|
||||||
|
addToLog(WaitIcon, "Receiving " + tl_u + "...");
|
||||||
|
view->receive();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDViewWidget::on_buttonLoad_clicked() {
|
||||||
|
view->load();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDViewWidget::on_buttonSave_clicked() {
|
||||||
|
view->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDViewWidget::on_buttonParse_clicked() {
|
||||||
|
QString path = QFileDialog::getOpenFileName(this, "Select header file", "",
|
||||||
|
QString("%1 Description(%2_description.h);;Headers(*.h)").arg(tl_u, tl_l));
|
||||||
|
if (path.isEmpty()) return;
|
||||||
|
CDUtils::UpdateModeFlags mode = CDUtils::SaveByName;
|
||||||
|
if (!view->root()->isEmpty()) {
|
||||||
|
QCDModeDialog cdm;
|
||||||
|
if (cdm.exec() != QDialog::Accepted) return;
|
||||||
|
mode = cdm.mode();
|
||||||
|
}
|
||||||
|
view->buildFromHeader(path, mode);
|
||||||
|
}
|
||||||
41
qcd_utils/pult/cdviewwidget.h
Normal file
41
qcd_utils/pult/cdviewwidget.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#ifndef CDVIEWWIDGET_H
|
||||||
|
#define CDVIEWWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include "ui_cdviewwidget.h"
|
||||||
|
|
||||||
|
|
||||||
|
class CDViewWidget : public QWidget, public Ui::CDViewWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit CDViewWidget(QWidget *parent = 0);
|
||||||
|
~CDViewWidget();
|
||||||
|
|
||||||
|
enum LogIcon {NoIcon, OKIcon, FailIcon, WaitIcon};
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
void setType(int t);
|
||||||
|
void setFile(const QString & f);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString tl_u, tl_l;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void sended() {addToLog(OKIcon, tl_u + " " + tr("sended succesfull"));}
|
||||||
|
void received() {addToLog(OKIcon, tl_u + " " + tr("received succesfull"));}
|
||||||
|
void sendFailed() {addToLog(FailIcon, tl_u + " " + tr("NOT sended"));}
|
||||||
|
void receiveFailed() {addToLog(FailIcon, tl_u + " " + tr("NOT received"));}
|
||||||
|
void on_buttonSend_clicked();
|
||||||
|
void on_buttonReceive_clicked();
|
||||||
|
void on_buttonLoad_clicked();
|
||||||
|
void on_buttonSave_clicked();
|
||||||
|
void on_buttonParse_clicked();
|
||||||
|
//void on_buttonCalculate_clicked();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void addToLog(CDViewWidget::LogIcon icon, const QString & msg);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CDVIEWWIDGET_H
|
||||||
121
qcd_utils/pult/cdviewwidget.ui
Normal file
121
qcd_utils/pult/cdviewwidget.ui
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CDViewWidget</class>
|
||||||
|
<widget class="QWidget" name="CDViewWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>689</width>
|
||||||
|
<height>459</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>CD Pult</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<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>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1">
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonSave">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../qad/application/qad_application.qrc">
|
||||||
|
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QPushButton" name="buttonLoad">
|
||||||
|
<property name="text">
|
||||||
|
<string>Load</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../qad/application/qad_application.qrc">
|
||||||
|
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonReceive">
|
||||||
|
<property name="text">
|
||||||
|
<string>Receive</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>:/icons/document-revert.png</normaloff>:/icons/document-revert.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0" colspan="2">
|
||||||
|
<widget class="QPushButton" name="buttonParse">
|
||||||
|
<property name="text">
|
||||||
|
<string>Update description ...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QPushButton" name="buttonSend">
|
||||||
|
<property name="text">
|
||||||
|
<string>Send</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>:/icons/flame.png</normaloff>:/icons/flame.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="CDView" name="view">
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollMode">
|
||||||
|
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalScrollMode">
|
||||||
|
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>CDView</class>
|
||||||
|
<extends>QTreeView</extends>
|
||||||
|
<header>qcd_view.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources>
|
||||||
|
<include location="../../qad/application/qad_application.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
BIN
qcd_utils/pult/icons/document-revert.png
Normal file
BIN
qcd_utils/pult/icons/document-revert.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
BIN
qcd_utils/pult/icons/flame.png
Normal file
BIN
qcd_utils/pult/icons/flame.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
BIN
qcd_utils/pult/icons/view-refresh.png
Normal file
BIN
qcd_utils/pult/icons/view-refresh.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
@@ -11,7 +11,7 @@
|
|||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <spinslider.h>
|
#include <spinslider.h>
|
||||||
#include <clineedit.h>
|
#include <clineedit.h>
|
||||||
#include <qcd_kview.h>
|
#include <qcd_view.h>
|
||||||
|
|
||||||
using namespace CDUtils;
|
using namespace CDUtils;
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ bool QCDCore::bindWidget(QWidget * w) {
|
|||||||
if (!w) return false;
|
if (!w) return false;
|
||||||
QString on = w->objectName();
|
QString on = w->objectName();
|
||||||
QString cn = w->metaObject()->className();
|
QString cn = w->metaObject()->className();
|
||||||
if (cn == "CDKView") {
|
if (cn == "CDView") {
|
||||||
bindView(w);
|
bindView(w);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ bool QCDCore::bindWidget(QWidget * w, const CDType k) {
|
|||||||
connect(w, SIGNAL(textChanged(QString)), this, SLOT(slotText(QString)), Qt::UniqueConnection);
|
connect(w, SIGNAL(textChanged(QString)), this, SLOT(slotText(QString)), Qt::UniqueConnection);
|
||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
if (cn == "CDKView") {
|
if (cn == "CDView") {
|
||||||
bindView(w);
|
bindView(w);
|
||||||
}
|
}
|
||||||
if (!ok) return false;
|
if (!ok) return false;
|
||||||
@@ -180,7 +180,7 @@ void QCDCore::updateBindedWidgets() {
|
|||||||
|
|
||||||
|
|
||||||
void QCDCore::bindView(QWidget * v) {
|
void QCDCore::bindView(QWidget * v) {
|
||||||
CDKView * w = qobject_cast<CDKView * >(v);
|
CDView * w = qobject_cast<CDView * >(v);
|
||||||
if (!w) return;
|
if (!w) return;
|
||||||
connect(this, SIGNAL(updateViewRequest()), w->model(), SLOT(updateModel()), Qt::UniqueConnection);
|
connect(this, SIGNAL(updateViewRequest()), w->model(), SLOT(updateModel()), Qt::UniqueConnection);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,124 +0,0 @@
|
|||||||
#include <QDir>
|
|
||||||
#include "cdutils_k.h"
|
|
||||||
#include "qcd_kview.h"
|
|
||||||
#include "qcd_kmodel.h"
|
|
||||||
#include "piqt.h"
|
|
||||||
#include "pifile.h"
|
|
||||||
|
|
||||||
using namespace CDUtils;
|
|
||||||
|
|
||||||
|
|
||||||
CDKView::CDKView(QWidget *parent) : QTreeView(parent) {
|
|
||||||
kmodel = 0;
|
|
||||||
CONNECTU(&K, sended, this, cdk_sendSucceed);
|
|
||||||
CONNECTU(&K, sendFailed, this, cdk_sendFailed);
|
|
||||||
CONNECTU(&K, received, this, cdk_receiveSucceed);
|
|
||||||
CONNECTU(&K, receiveFailed, this, cdk_receiveFailed);
|
|
||||||
connect(this, SIGNAL(_qcdk_sendFailed()), this, SLOT(k_sendFailed()), Qt::QueuedConnection);
|
|
||||||
connect(this, SIGNAL(_qcdk_sendSucceed()), this, SLOT(k_sendSucceed()), Qt::QueuedConnection);
|
|
||||||
connect(this, SIGNAL(_qcdk_receiveFailed()), this, SLOT(k_receiveFailed()), Qt::QueuedConnection);
|
|
||||||
connect(this, SIGNAL(_qcdk_receiveSucceed()), this, SLOT(k_receiveSucceed()), Qt::QueuedConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CDKView::~CDKView() {
|
|
||||||
if (kmodel) delete kmodel;
|
|
||||||
kmodel = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKView::refresh() {
|
|
||||||
if (!kmodel) {
|
|
||||||
kmodel = new CDKItemModel();
|
|
||||||
setModel(kmodel);
|
|
||||||
setItemDelegateForColumn(4, new CDKDelegate());
|
|
||||||
}
|
|
||||||
kmodel->rebuildModel();
|
|
||||||
expandAll();
|
|
||||||
for (int i=0; i<6; i++) resizeColumnToContents(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKView::setKFile(const QString &filename) {
|
|
||||||
K.setFileName(Q2PIString(filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKView::startPing() {
|
|
||||||
K.startPing();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKView::sendK() {
|
|
||||||
busyStatusChanged(true);
|
|
||||||
K.send();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKView::receiveK() {
|
|
||||||
busyStatusChanged(true);
|
|
||||||
K.request();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKView::saveK() {
|
|
||||||
K.writeFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKView::loadK() {
|
|
||||||
K.readFile();
|
|
||||||
K.calculate();
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKView::clearK() {
|
|
||||||
//piCout << "clearK";
|
|
||||||
K.root() = CDSection();
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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, mode);
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKView::calculateK() {
|
|
||||||
K.calculate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKView::k_sendFailed() {
|
|
||||||
busyStatusChanged(false);
|
|
||||||
emit messageStatus("send failed");
|
|
||||||
emit KSendFailed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKView::k_sendSucceed() {
|
|
||||||
busyStatusChanged(false);
|
|
||||||
emit messageStatus("send success");
|
|
||||||
emit KSendSucceed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKView::k_receiveFailed() {
|
|
||||||
busyStatusChanged(false);
|
|
||||||
emit messageStatus("receive failed");
|
|
||||||
emit KReceiveFailed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKView::k_receiveSucceed() {
|
|
||||||
busyStatusChanged(false);
|
|
||||||
emit messageStatus("receive success");
|
|
||||||
refresh();
|
|
||||||
emit KReceiveSucceed();
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
#ifndef QCD_KVIEW_H
|
|
||||||
#define QCD_KVIEW_H
|
|
||||||
|
|
||||||
#include "piobject.h"
|
|
||||||
#include <QTreeView>
|
|
||||||
|
|
||||||
class CDKItemModel;
|
|
||||||
|
|
||||||
class CDKView: public QTreeView, public PIObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
PIOBJECT(CDKView)
|
|
||||||
public:
|
|
||||||
explicit CDKView(QWidget *parent = 0);
|
|
||||||
~CDKView();
|
|
||||||
|
|
||||||
void setKFile(const QString & filename);
|
|
||||||
void startPing();
|
|
||||||
|
|
||||||
CDKItemModel * CDKModel() {return kmodel;}
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void refresh();
|
|
||||||
void sendK();
|
|
||||||
void receiveK();
|
|
||||||
void saveK();
|
|
||||||
void loadK();
|
|
||||||
void clearK();
|
|
||||||
void buildFromHeader(const QString & kdescription, int mode = 2);
|
|
||||||
void calculateK();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void k_sendFailed();
|
|
||||||
void k_sendSucceed();
|
|
||||||
void k_receiveFailed();
|
|
||||||
void k_receiveSucceed();
|
|
||||||
|
|
||||||
private:
|
|
||||||
EVENT_HANDLER(void, cdk_sendFailed) {emit _qcdk_sendFailed();}
|
|
||||||
EVENT_HANDLER(void, cdk_sendSucceed) {emit _qcdk_sendSucceed();}
|
|
||||||
EVENT_HANDLER(void, cdk_receiveFailed) {emit _qcdk_receiveFailed();}
|
|
||||||
EVENT_HANDLER(void, cdk_receiveSucceed) {emit _qcdk_receiveSucceed();}
|
|
||||||
|
|
||||||
CDKItemModel * kmodel;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void KSendFailed();
|
|
||||||
void KSendSucceed();
|
|
||||||
void KReceiveFailed();
|
|
||||||
void KReceiveSucceed();
|
|
||||||
void messageStatus(QString msg);
|
|
||||||
void busyStatusChanged(bool busy);
|
|
||||||
|
|
||||||
void _qcdk_sendFailed(); // PRIVATE
|
|
||||||
void _qcdk_sendSucceed(); // PRIVATE
|
|
||||||
void _qcdk_receiveFailed(); // PRIVATE
|
|
||||||
void _qcdk_receiveSucceed(); // PRIVATE
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // QCD_KVIEW_H
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "qcd_kmodel.h"
|
#include "qcd_model.h"
|
||||||
#include "cdutils_k.h"
|
#include "cdutils_interface.h"
|
||||||
|
#include "cdutils_core.h"
|
||||||
#include "piqt.h"
|
#include "piqt.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
@@ -11,173 +12,26 @@
|
|||||||
using namespace CDUtils;
|
using namespace CDUtils;
|
||||||
|
|
||||||
|
|
||||||
CDKItemModel::CDKItemModel(QObject *parent) : QAbstractItemModel(parent) {
|
|
||||||
root = 0;
|
|
||||||
internalRebuild();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CDKItemModel::~CDKItemModel() {
|
|
||||||
delete root;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QVariant CDKItemModel::data(const QModelIndex &index, int role) const {
|
|
||||||
if (!index.isValid()) return QVariant();
|
|
||||||
CDKItem *item = getItem(index);
|
|
||||||
return item->data(index.column(), role);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QVariant CDKItemModel::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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QModelIndex CDKItemModel::index(int row, int column, const QModelIndex &parent) const {
|
|
||||||
if (parent.isValid() && parent.column() != 0) return QModelIndex();
|
|
||||||
CDKItem * p = getItem(parent);
|
|
||||||
CDKItem * c = p->childs.value(row, 0);
|
|
||||||
if (c) return createIndex(row, column, c);
|
|
||||||
else return QModelIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QModelIndex CDKItemModel::parent(const QModelIndex &index) const {
|
|
||||||
if (!index.isValid()) return QModelIndex();
|
|
||||||
CDKItem * c = getItem(index);
|
|
||||||
CDKItem * p = c->parent_;
|
|
||||||
if (p == root) return QModelIndex();
|
|
||||||
return createIndex(p->parent_->childs.indexOf(p), 0, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CDKItemModel::rowCount(const QModelIndex &parent) const {
|
|
||||||
CDKItem *p = getItem(parent);
|
|
||||||
return p->childs.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CDKItemModel::columnCount(const QModelIndex &parent) const {
|
|
||||||
return 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Qt::ItemFlags CDKItemModel::flags(const QModelIndex & index) const {
|
|
||||||
if (!index.isValid()) return 0;
|
|
||||||
Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
|
||||||
CDKItem * item = getItem(index);
|
|
||||||
if ((index.column() == 3 || index.column() == 4) && item->type_ == CDKItem::ItemCDType) f |= Qt::ItemIsEditable;
|
|
||||||
if (item->type_ == CDKItem::ItemCDType && index.column() == 4) {
|
|
||||||
CDType t = K.section(item->buildPath())[item->index_];
|
|
||||||
if (t.type() == "b") {
|
|
||||||
f |= Qt::ItemIsUserCheckable;
|
|
||||||
// piCout << "ItemIsUserCheckable";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool CDKItemModel::setData(const QModelIndex & index, const QVariant &value, int role) {
|
|
||||||
if (role == Qt::CheckStateRole && index.column() == 4) {
|
|
||||||
CDKItem * item = getItem(index);
|
|
||||||
if (item->type_ == CDKItem::ItemCDType) {
|
|
||||||
CDType t = K.section(item->buildPath())[item->index_];
|
|
||||||
if (t.type() == "b") {
|
|
||||||
bool result = item->setData(index.column(), PI2QString(PIString::fromBool(value.toBool())));
|
|
||||||
QModelIndex rin(CDKItemModel::index(index.row(), 3, index.parent()));
|
|
||||||
emit dataChanged(rin, rin);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (role != Qt::EditRole) return false;
|
|
||||||
CDKItem * item = getItem(index);
|
|
||||||
bool result = item->setData(index.column(), value);
|
|
||||||
if (result) {
|
|
||||||
QModelIndex rin(CDKItemModel::index(index.row(), 3, index.parent()));
|
|
||||||
emit dataChanged(rin, rin);
|
|
||||||
emit dataChanged(index, index);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKItemModel::rebuildModel() {
|
|
||||||
beginResetModel();
|
|
||||||
internalRebuild();
|
|
||||||
endResetModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKItemModel::buildItem(CDKItem *it, CDSection & r) {
|
|
||||||
//piCout << "build item" << r.name << r.alias;
|
|
||||||
PIMap<int, CDType>::iterator i;
|
|
||||||
for (i = r.cd.begin(); i != r.cd.end(); ++i) {
|
|
||||||
it->childs << new CDKItem(i.key(), CDKItem::ItemCDType, it);
|
|
||||||
}
|
|
||||||
PIMap<int, CDSection>::iterator j;
|
|
||||||
for (j = r.s.begin(); j != r.s.end(); ++j) {
|
|
||||||
it->childs << new CDKItem(j.key(), CDKItem::ItemCDSection, it);
|
|
||||||
buildItem(it->childs.back(), j.value());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKItemModel::updateModel() {
|
|
||||||
beginResetModel();
|
|
||||||
endResetModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CDKItemModel::internalRebuild() {
|
|
||||||
//qDebug() << "[CDKItemModel]" << "internalRebuild()";
|
|
||||||
if (root) delete root;
|
|
||||||
root = new CDKItem(0, CDKItem::ItemCDSection, 0);
|
|
||||||
CDSection & r = K.root();
|
|
||||||
buildItem(root, r);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CDKItem * CDKItemModel::getItem(const QModelIndex &index) const {
|
|
||||||
if (index.isValid()) {
|
|
||||||
CDKItem * item = static_cast<CDKItem*>(index.internalPointer());
|
|
||||||
if (item) return item;
|
|
||||||
}
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// CDKItem
|
// CDKItem
|
||||||
|
|
||||||
CDKItem::CDKItem(int index, CDKItem::CDKItemType type, CDKItem *parent) {
|
CDItem::CDItem(CDUtils::Interface * i, int index, CDItem::CDItemType type, CDItem *parent) {
|
||||||
|
interface = i;
|
||||||
index_ = index;
|
index_ = index;
|
||||||
parent_ = parent;
|
parent_ = parent;
|
||||||
type_ = type;
|
type_ = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CDKItem::~CDKItem() {
|
CDItem::~CDItem() {
|
||||||
qDeleteAll(childs);
|
qDeleteAll(childs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant CDKItem::data(int column, int role) const {
|
QVariant CDItem::data(int column, int role) const {
|
||||||
if (role == Qt::BackgroundRole) {
|
if (role == Qt::BackgroundRole) {
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case ItemCDType: {
|
case ItemCDType: {
|
||||||
CDType & t = K.section(buildPath())[index_];
|
CDType & t = interface->section(buildPath())[index_];
|
||||||
if (t.errorString().isEmpty()) return QBrush(QColor(255, 250, 230));
|
if (t.errorString().isEmpty()) return QBrush(QColor(255, 250, 230));
|
||||||
else return QBrush(QColor(255, 128, 128));
|
else return QBrush(QColor(255, 128, 128));
|
||||||
}
|
}
|
||||||
@@ -185,17 +39,17 @@ QVariant CDKItem::data(int column, int role) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (role == Qt::CheckStateRole && type_ == ItemCDType && column == 4) {
|
if (role == Qt::CheckStateRole && type_ == ItemCDType && column == 4) {
|
||||||
CDType & t = K.section(buildPath())[index_];
|
CDType & t = interface->section(buildPath())[index_];
|
||||||
if (t.type() == "b") return t.toBool() ? Qt::Checked : Qt::Unchecked;
|
if (t.type() == "b") return t.toBool() ? Qt::Checked : Qt::Unchecked;
|
||||||
else QVariant();
|
else QVariant();
|
||||||
}
|
}
|
||||||
if (role == Qt::ToolTipRole && type_ == ItemCDType) {
|
if (role == Qt::ToolTipRole && type_ == ItemCDType) {
|
||||||
CDType & t = K.section(buildPath())[index_];
|
CDType & t = interface->section(buildPath())[index_];
|
||||||
return PI2QString(t.errorString());
|
return PI2QString(t.errorString());
|
||||||
}
|
}
|
||||||
if (role != Qt::DisplayRole && role != Qt::EditRole) return QVariant();
|
if (role != Qt::DisplayRole && role != Qt::EditRole) return QVariant();
|
||||||
PIDeque<int> path = buildPath();
|
PIDeque<int> path = buildPath();
|
||||||
CDSection & rs = K.section(path);
|
CDSection & rs = interface->section(path);
|
||||||
CDSection s;
|
CDSection s;
|
||||||
switch (type_) {
|
switch (type_) {
|
||||||
case ItemCDType:
|
case ItemCDType:
|
||||||
@@ -206,8 +60,7 @@ QVariant CDKItem::data(int column, int role) const {
|
|||||||
case 3: return PI2QString(rs[index_].formula());
|
case 3: return PI2QString(rs[index_].formula());
|
||||||
case 4: return value(rs[index_], role);
|
case 4: return value(rs[index_], role);
|
||||||
case 5: return PI2QString(rs[index_].comment());
|
case 5: return PI2QString(rs[index_].comment());
|
||||||
default:
|
default: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ItemCDSection:
|
case ItemCDSection:
|
||||||
@@ -217,8 +70,7 @@ QVariant CDKItem::data(int column, int role) const {
|
|||||||
case 0: return QString("[") + QString::number(index_) + QString("]");
|
case 0: return QString("[") + QString::number(index_) + QString("]");
|
||||||
case 1: return PI2QString(s.alias);
|
case 1: return PI2QString(s.alias);
|
||||||
case 2: return PI2QString(s.name);
|
case 2: return PI2QString(s.name);
|
||||||
default:
|
default: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -226,7 +78,7 @@ QVariant CDKItem::data(int column, int role) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant CDKItem::value(CDType t, int role) const {
|
QVariant CDItem::value(CDType t, int role) const {
|
||||||
if (t.type() == "f") return t.toDouble();
|
if (t.type() == "f") return t.toDouble();
|
||||||
if (t.type() == "n") return t.toInt();
|
if (t.type() == "n") return t.toInt();
|
||||||
if (t.type() == "b") return t.toBool();
|
if (t.type() == "b") return t.toBool();
|
||||||
@@ -240,19 +92,19 @@ QVariant CDKItem::value(CDType t, int role) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CDKItem::setData(int column, const QVariant &value) {
|
bool CDItem::setData(int column, const QVariant &value) {
|
||||||
if ((column == 3 || column == 4) && type_ == ItemCDType) {
|
if ((column == 3 || column == 4) && type_ == ItemCDType) {
|
||||||
K.section(buildPath())[index_].setValue(Q2PIString(value.toString()));
|
interface->section(buildPath())[index_].setValue(Q2PIString(value.toString()));
|
||||||
K.calculate();
|
interface->calculate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIDeque<int> CDKItem::buildPath() const {
|
PIDeque<int> CDItem::buildPath() const {
|
||||||
PIDeque<int> path;
|
PIDeque<int> path;
|
||||||
CDKItem * p = parent_;
|
CDItem * p = parent_;
|
||||||
while (p) {
|
while (p) {
|
||||||
path.push_front(p->index_);
|
path.push_front(p->index_);
|
||||||
p = p->parent_;
|
p = p->parent_;
|
||||||
@@ -262,7 +114,7 @@ PIDeque<int> CDKItem::buildPath() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString CDKItem::stringType(const PIString & t) const {
|
QString CDItem::stringType(const PIString & t) const {
|
||||||
QString n = PI2QString(t);
|
QString n = PI2QString(t);
|
||||||
if (n.isEmpty()) return QString("");
|
if (n.isEmpty()) return QString("");
|
||||||
switch (n[0].toLatin1()) {
|
switch (n[0].toLatin1()) {
|
||||||
@@ -286,22 +138,22 @@ QString CDKItem::stringType(const PIString & t) const {
|
|||||||
|
|
||||||
// CDKDelegate
|
// CDKDelegate
|
||||||
|
|
||||||
CDKDelegate::CDKDelegate(QObject *parent) : QStyledItemDelegate(parent) {
|
CDDelegate::CDDelegate(QObject *parent) : QStyledItemDelegate(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QWidget *CDKDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
QWidget *CDDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||||
return new QVariantEdit(parent);
|
return new QVariantEdit(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CDKDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
|
void CDDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
|
||||||
QVariantEdit *edit = static_cast<QVariantEdit*>(editor);
|
QVariantEdit *edit = static_cast<QVariantEdit*>(editor);
|
||||||
edit->setValue(index.model()->data(index, Qt::EditRole));
|
edit->setValue(index.model()->data(index, Qt::EditRole));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CDKDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
|
void CDDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
|
||||||
QVariantEdit *edit = static_cast<QVariantEdit*>(editor);
|
QVariantEdit *edit = static_cast<QVariantEdit*>(editor);
|
||||||
QVariant v = edit->value();
|
QVariant v = edit->value();
|
||||||
if (v.canConvert<QAD::Enum>()) {
|
if (v.canConvert<QAD::Enum>()) {
|
||||||
@@ -311,13 +163,169 @@ void CDKDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CDKDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
void CDDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||||
editor->setGeometry(option.rect);
|
editor->setGeometry(option.rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QSize CDKDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
QSize CDDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||||
QSize s = QStyledItemDelegate::sizeHint(option, index);
|
QSize s = QStyledItemDelegate::sizeHint(option, index);
|
||||||
s.setWidth(s.width() + 20);
|
s.setWidth(s.width() + 20);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CDItemModel
|
||||||
|
|
||||||
|
CDItemModel::CDItemModel(int type_, QObject *parent) : QAbstractItemModel(parent) {
|
||||||
|
interface = new Interface((CDType::cdT)type_);
|
||||||
|
root = 0;
|
||||||
|
internalRebuild();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CDItemModel::~CDItemModel() {
|
||||||
|
delete root;
|
||||||
|
delete interface;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant CDItemModel::data(const QModelIndex &index, int role) const {
|
||||||
|
if (!index.isValid()) return QVariant();
|
||||||
|
CDItem *item = getItem(index);
|
||||||
|
return item->data(index.column(), role);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QModelIndex CDItemModel::index(int row, int column, const QModelIndex &parent) const {
|
||||||
|
if (parent.isValid() && parent.column() != 0) return QModelIndex();
|
||||||
|
CDItem * p = getItem(parent);
|
||||||
|
CDItem * c = p->childs.value(row, 0);
|
||||||
|
if (c) return createIndex(row, column, c);
|
||||||
|
else return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QModelIndex CDItemModel::parent(const QModelIndex &index) const {
|
||||||
|
if (!index.isValid()) return QModelIndex();
|
||||||
|
CDItem * c = getItem(index);
|
||||||
|
CDItem * p = c->parent_;
|
||||||
|
if (p == root) return QModelIndex();
|
||||||
|
return createIndex(p->parent_->childs.indexOf(p), 0, p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int CDItemModel::rowCount(const QModelIndex &parent) const {
|
||||||
|
CDItem *p = getItem(parent);
|
||||||
|
return p->childs.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int CDItemModel::columnCount(const QModelIndex &parent) const {
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Qt::ItemFlags CDItemModel::flags(const QModelIndex & index) const {
|
||||||
|
if (!index.isValid()) return 0;
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CDItemModel::setData(const QModelIndex & index, const QVariant &value, int role) {
|
||||||
|
if (role == Qt::CheckStateRole && index.column() == 4) {
|
||||||
|
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);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (role != Qt::EditRole) return false;
|
||||||
|
CDItem * item = getItem(index);
|
||||||
|
bool result = item->setData(index.column(), value);
|
||||||
|
if (result) {
|
||||||
|
QModelIndex rin(CDItemModel::index(index.row(), 3, index.parent()));
|
||||||
|
emit dataChanged(rin, rin);
|
||||||
|
emit dataChanged(index, index);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDItemModel::rebuildModel() {
|
||||||
|
beginResetModel();
|
||||||
|
internalRebuild();
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDItemModel::buildItem(CDItem *it, CDSection & r) {
|
||||||
|
//piCout << "build item" << r.name << r.alias;
|
||||||
|
PIMap<int, CDType>::iterator i;
|
||||||
|
for (i = r.cd.begin(); i != r.cd.end(); ++i) {
|
||||||
|
it->childs << new CDItem(interface, i.key(), CDItem::ItemCDType, it);
|
||||||
|
}
|
||||||
|
PIMap<int, CDSection>::iterator j;
|
||||||
|
for (j = r.s.begin(); j != r.s.end(); ++j) {
|
||||||
|
it->childs << new CDItem(interface, j.key(), CDItem::ItemCDSection, it);
|
||||||
|
buildItem(it->childs.back(), j.value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDItemModel::updateModel() {
|
||||||
|
beginResetModel();
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDItemModel::internalRebuild() {
|
||||||
|
//qDebug() << "[CDKItemModel]" << "internalRebuild()";
|
||||||
|
if (root) delete root;
|
||||||
|
root = new CDItem(interface, 0, CDItem::ItemCDSection, 0);
|
||||||
|
CDSection & r = interface->root();
|
||||||
|
buildItem(root, r);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CDItem * CDItemModel::getItem(const QModelIndex &index) const {
|
||||||
|
if (index.isValid()) {
|
||||||
|
CDItem * item = static_cast<CDItem*>(index.internalPointer());
|
||||||
|
if (item) return item;
|
||||||
|
}
|
||||||
|
return root;
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef QCD_KMODEL_H
|
#ifndef QCD_MODEL_H
|
||||||
#define QCD_KMODEL_H
|
#define QCD_MODEL_H
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QItemDelegate>
|
#include <QItemDelegate>
|
||||||
@@ -7,20 +7,24 @@
|
|||||||
#include "pistring.h"
|
#include "pistring.h"
|
||||||
|
|
||||||
namespace CDUtils {
|
namespace CDUtils {
|
||||||
class CDSection;
|
|
||||||
class CDType;
|
class CDType;
|
||||||
|
class CDSection;
|
||||||
|
class Interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace QAD {
|
namespace QAD {
|
||||||
struct Enum;
|
struct Enum;
|
||||||
}
|
}
|
||||||
class CDKItemModel;
|
|
||||||
|
|
||||||
class CDKItem {
|
class CDItemModel;
|
||||||
friend class CDKItemModel;
|
|
||||||
|
|
||||||
|
class CDItem {
|
||||||
|
friend class CDItemModel;
|
||||||
public:
|
public:
|
||||||
enum CDKItemType{ItemCDType, ItemCDSection};
|
enum CDItemType{ItemCDType, ItemCDSection};
|
||||||
CDKItem(int index, CDKItemType type, CDKItem * parent);
|
CDItem(CDUtils::Interface * interface, int index, CDItemType type, CDItem * parent);
|
||||||
~CDKItem();
|
~CDItem();
|
||||||
QVariant data(int column, int role) const;
|
QVariant data(int column, int role) const;
|
||||||
QVariant value(CDUtils::CDType t, int role) const;
|
QVariant value(CDUtils::CDType t, int role) const;
|
||||||
bool setData(int column, const QVariant & value);
|
bool setData(int column, const QVariant & value);
|
||||||
@@ -29,18 +33,19 @@ private:
|
|||||||
PIDeque<int> buildPath() const;
|
PIDeque<int> buildPath() const;
|
||||||
QString stringType(const PIString & t) const;
|
QString stringType(const PIString & t) const;
|
||||||
|
|
||||||
CDKItem * parent_;
|
CDUtils::Interface * interface;
|
||||||
|
CDItem * parent_;
|
||||||
int index_;
|
int index_;
|
||||||
CDKItemType type_;
|
CDItemType type_;
|
||||||
QList<CDKItem *> childs;
|
QList<CDItem *> childs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CDKDelegate : public QStyledItemDelegate
|
class CDDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
CDKDelegate(QObject *parent = 0);
|
CDDelegate(QObject *parent = 0);
|
||||||
|
|
||||||
QWidget * createEditor(QWidget *parent, 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 setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||||
@@ -50,11 +55,11 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class CDKItemModel : public QAbstractItemModel {
|
class CDItemModel : public QAbstractItemModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CDKItemModel(QObject *parent = 0);
|
explicit CDItemModel(int type_, QObject *parent = 0);
|
||||||
~CDKItemModel();
|
~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;
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||||
@@ -65,7 +70,7 @@ public:
|
|||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||||
|
|
||||||
void buildItem(CDKItem * it, CDUtils::CDSection &r);
|
void buildItem(CDItem * it, CDUtils::CDSection &r);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void rebuildModel();
|
void rebuildModel();
|
||||||
@@ -73,12 +78,13 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void internalRebuild();
|
void internalRebuild();
|
||||||
CDKItem * getItem(const QModelIndex & index) const;
|
CDItem * getItem(const QModelIndex & index) const;
|
||||||
|
|
||||||
CDKItem * root;
|
CDUtils::Interface * interface;
|
||||||
|
CDItem * root;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QCD_KMODEL_H
|
#endif // QCD_MODEL_H
|
||||||
214
qcd_utils/qcd_view.cpp
Normal file
214
qcd_utils/qcd_view.cpp
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
#include <QDir>
|
||||||
|
#include "cdutils_k.h"
|
||||||
|
#include "cdutils_x.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;
|
||||||
|
model_ = 0;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CDView::~CDView() {
|
||||||
|
if (model_) delete model_;
|
||||||
|
model_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::setType(int cdt) {
|
||||||
|
if (cdt < 0) return;
|
||||||
|
if (type_ >= 0) return;
|
||||||
|
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, receiveFailed, this, pi_cd_receiveFailed);
|
||||||
|
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, receiveFailed, this, pi_cd_receiveFailed);
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::refresh() {
|
||||||
|
if (type_ < 0) return;
|
||||||
|
if (!model_) {
|
||||||
|
model_ = new CDItemModel(type_);
|
||||||
|
setModel(model_);
|
||||||
|
setItemDelegateForColumn(4, new CDDelegate());
|
||||||
|
}
|
||||||
|
model_->rebuildModel();
|
||||||
|
switch ((CDType::cdT)type_) {
|
||||||
|
case CDType::cdX:
|
||||||
|
setColumnHidden(3, true);
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
expandAll();
|
||||||
|
for (int i=0; i<6; i++) resizeColumnToContents(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CDView::inProgress() const {
|
||||||
|
switch ((CDType::cdT)type_) {
|
||||||
|
case CDType::cdK: return K.inProgress(); break;
|
||||||
|
case CDType::cdX: return X.inProgress(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::startPing() {
|
||||||
|
switch ((CDType::cdT)type_) {
|
||||||
|
case CDType::cdK: K.startPing(); break;
|
||||||
|
case CDType::cdX: X.startPing(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CDSection * CDView::root() {
|
||||||
|
return CDCore::instance()->root((CDType::cdT)type_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString CDView::typeLetter() const {
|
||||||
|
return PI2QString(CDCore::instance()->typeLetter((CDType::cdT)type_));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::send() {
|
||||||
|
busyStatusChanged(true);
|
||||||
|
switch ((CDType::cdT)type_) {
|
||||||
|
case CDType::cdK: K.send(); break;
|
||||||
|
case CDType::cdX: X.send(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::receive() {
|
||||||
|
busyStatusChanged(true);
|
||||||
|
switch ((CDType::cdT)type_) {
|
||||||
|
case CDType::cdK: K.request(); break;
|
||||||
|
case CDType::cdX: X.request(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::save() {
|
||||||
|
switch ((CDType::cdT)type_) {
|
||||||
|
case CDType::cdK: K.writeFile(); break;
|
||||||
|
case CDType::cdX: X.writeFile(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::load() {
|
||||||
|
switch ((CDType::cdT)type_) {
|
||||||
|
case CDType::cdK:
|
||||||
|
K.readFile();
|
||||||
|
K.calculate();
|
||||||
|
break;
|
||||||
|
case CDType::cdX:
|
||||||
|
X.readFile();
|
||||||
|
X.calculate();
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::clear() {
|
||||||
|
//piCout << "clearK";
|
||||||
|
switch ((CDType::cdT)type_) {
|
||||||
|
case CDType::cdK: K.root() = CDSection(); break;
|
||||||
|
case CDType::cdX: X.root() = CDSection(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::buildFromHeader(const QString & description, int mode) {
|
||||||
|
if (description.isEmpty()) return;
|
||||||
|
PIString desc_file = Q2PIString(QDir::current().relativeFilePath(description));
|
||||||
|
PIFile f(desc_file, PIIODevice::ReadOnly);
|
||||||
|
switch ((CDType::cdT)type_) {
|
||||||
|
case CDType::cdK: K.update(&f, mode); break;
|
||||||
|
case CDType::cdX: X.update(&f, mode); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::calculate() {
|
||||||
|
switch ((CDType::cdT)type_) {
|
||||||
|
case CDType::cdK: K.calculate(); break;
|
||||||
|
case CDType::cdX: X.calculate(); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::cd_sendFailed() {
|
||||||
|
busyStatusChanged(false);
|
||||||
|
emit messageStatus("send failed");
|
||||||
|
emit sendFailed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::cd_sendSucceed() {
|
||||||
|
busyStatusChanged(false);
|
||||||
|
emit messageStatus("send success");
|
||||||
|
emit sendSucceed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::cd_receiveFailed() {
|
||||||
|
busyStatusChanged(false);
|
||||||
|
emit messageStatus("receive failed");
|
||||||
|
emit receiveFailed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CDView::cd_receiveSucceed() {
|
||||||
|
refresh();
|
||||||
|
busyStatusChanged(false);
|
||||||
|
emit messageStatus("receive success");
|
||||||
|
emit receiveSucceed();
|
||||||
|
}
|
||||||
|
|
||||||
71
qcd_utils/qcd_view.h
Normal file
71
qcd_utils/qcd_view.h
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
#ifndef QCD_VIEW_H
|
||||||
|
#define QCD_VIEW_H
|
||||||
|
|
||||||
|
#include "piobject.h"
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
|
namespace CDUtils {
|
||||||
|
class CDType;
|
||||||
|
class CDSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
class CDItemModel;
|
||||||
|
|
||||||
|
class CDView: public QTreeView, public PIObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
PIOBJECT(CDView)
|
||||||
|
public:
|
||||||
|
explicit CDView(QWidget *parent = 0);
|
||||||
|
~CDView();
|
||||||
|
|
||||||
|
void setType(int cdt);
|
||||||
|
void setFile(const QString & filename);
|
||||||
|
bool inProgress() const;
|
||||||
|
void startPing();
|
||||||
|
CDUtils::CDSection * root();
|
||||||
|
QString typeLetter() const;
|
||||||
|
|
||||||
|
CDItemModel * CDModel() {return model_;}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void refresh();
|
||||||
|
void send();
|
||||||
|
void receive();
|
||||||
|
void save();
|
||||||
|
void load();
|
||||||
|
void clear();
|
||||||
|
void buildFromHeader(const QString & description, int mode = 2);
|
||||||
|
void calculate();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void cd_sendFailed();
|
||||||
|
void cd_sendSucceed();
|
||||||
|
void cd_receiveFailed();
|
||||||
|
void cd_receiveSucceed();
|
||||||
|
|
||||||
|
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();}
|
||||||
|
|
||||||
|
CDItemModel * model_;
|
||||||
|
int type_;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sendFailed();
|
||||||
|
void sendSucceed();
|
||||||
|
void receiveFailed();
|
||||||
|
void receiveSucceed();
|
||||||
|
void messageStatus(QString msg);
|
||||||
|
void busyStatusChanged(bool busy);
|
||||||
|
|
||||||
|
void _qcd_sendFailed(); // PRIVATE
|
||||||
|
void _qcd_sendSucceed(); // PRIVATE
|
||||||
|
void _qcd_receiveFailed(); // PRIVATE
|
||||||
|
void _qcd_receiveSucceed(); // PRIVATE
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QCD_VIEW_H
|
||||||
Reference in New Issue
Block a user