removed qcd_utils
This commit is contained in:
@@ -1 +0,0 @@
|
||||
piqt_library(qcd_utils "Gui" "pip;qad_utils;qad_widgets;qad_graphic;cd_utils;piqt")
|
||||
@@ -1,297 +0,0 @@
|
||||
#include "qcd_core.h"
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "piqt.h"
|
||||
#include <QWidget>
|
||||
#include <QCheckBox>
|
||||
#include <QGroupBox>
|
||||
#include <QSpinBox>
|
||||
#include <QSlider>
|
||||
#include <QScrollBar>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QLineEdit>
|
||||
#include <spinslider.h>
|
||||
#include <clineedit.h>
|
||||
#include <evalspinbox.h>
|
||||
#include <qvariantedit.h>
|
||||
#include <qcd_view.h>
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
int __QCore_Initializer__::count_(0);
|
||||
QCDCore * __QCore_Initializer__::__instance__(0);
|
||||
|
||||
|
||||
__QCore_Initializer__::__QCore_Initializer__() {
|
||||
count_++;
|
||||
if (count_ > 1) return;
|
||||
__instance__ = new QCDCore();
|
||||
}
|
||||
|
||||
|
||||
__QCore_Initializer__::~__QCore_Initializer__() {
|
||||
count_--;
|
||||
if (count_ > 0) return;
|
||||
if (__instance__ != 0) {
|
||||
delete __instance__;
|
||||
__instance__ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QCDCore::QCDCore() {
|
||||
setObjectName("QCDCore");
|
||||
setName("QCDCore");
|
||||
CONNECTU(&K, changedGlobal, this, K_ChangedGlobal);
|
||||
updating = direct_on = false;
|
||||
}
|
||||
|
||||
|
||||
QCDCore::~QCDCore() {
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::K_ChangedGlobal() {
|
||||
QMetaObject::invokeMethod(this, "updateBindedWidgets", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::slotBool(bool v) {
|
||||
QWidget * w = (QWidget*)sender();
|
||||
if (!w || updating) return;
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
K[path].setValue(PIString::fromBool(v));
|
||||
K.calculate();
|
||||
emit updateViewRequest();
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::slotInt(int v) {
|
||||
QWidget * w = (QWidget*)sender();
|
||||
if (!w || updating) return;
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
K[path].setValue(PIString::fromNumber(v));
|
||||
finishEdit(pathes);
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::slotDouble(double v) {
|
||||
QWidget * w = (QWidget*)sender();
|
||||
if (!w || updating) return;
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
K[path].setValue(PIString::fromNumber(v));
|
||||
finishEdit(pathes);
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::slotText(QString v) {
|
||||
QWidget * w = (QWidget*)sender();
|
||||
if (!w || updating) return;
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
K[path].setValue(Q2PIString(v));
|
||||
finishEdit(pathes);
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::slotVariant(QVariant v) {
|
||||
QWidget * w = (QWidget*)sender();
|
||||
if (!w || updating) return;
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
K[path].setVariantValue(Q2PIVariant(v));
|
||||
finishEdit(pathes);
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::slotDestroyed(QObject * o) {
|
||||
if (!o) return;
|
||||
if (!binded_widgets.contains((QWidget*)o)) return;
|
||||
binded_widgets.remove((QWidget*)o);
|
||||
}
|
||||
|
||||
|
||||
int QCDCore::bindWindow(QWidget * wnd) {
|
||||
if (!wnd) return 0;
|
||||
//K.root().makePath();
|
||||
return bindWidgets(wnd->findChildren<QWidget * >());
|
||||
}
|
||||
|
||||
|
||||
int QCDCore::bindWidgets(QList<QWidget * > wl) {
|
||||
int ret = 0;
|
||||
foreach (QWidget * w, wl)
|
||||
if (bindWidget(w)) ++ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool QCDCore::bindWidget(QWidget * w) {
|
||||
if (!w) return false;
|
||||
QString on = w->objectName();
|
||||
QString cn = w->metaObject()->className();
|
||||
if (cn == "CDView") {
|
||||
bindView(w);
|
||||
return false;
|
||||
}
|
||||
PIVector<CDType * > ak = K.root().children();
|
||||
piForeachC (CDType * k, ak) {
|
||||
if (!on.endsWith(PI2QString(k->pathString().join("_")))) continue;
|
||||
if (bindWidget(w, *k)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool QCDCore::bindWidget(QWidget * w, const CDType & k) {
|
||||
if (!w) return false;
|
||||
//piCout << "bind..." << k.name() << k.path();
|
||||
QString cn = w->metaObject()->className();
|
||||
bool ok = false;
|
||||
if (cn == "QCheckBox" || cn == "QGroupBox") {
|
||||
connect(w, SIGNAL(toggled(bool)), this, SLOT(slotBool(bool)), Qt::UniqueConnection);
|
||||
ok = true;
|
||||
}
|
||||
if (cn == "QSpinBox" || cn == "QSlider" || cn == "QScrollBar") {
|
||||
connect(w, SIGNAL(valueChanged(int)), this, SLOT(slotInt(int)), Qt::UniqueConnection);
|
||||
ok = true;
|
||||
}
|
||||
if (cn == "QDoubleSpinBox" || cn == "SpinSlider" || cn == "EvalSpinBox") {
|
||||
connect(w, SIGNAL(valueChanged(double)), this, SLOT(slotDouble(double)), Qt::UniqueConnection);
|
||||
ok = true;
|
||||
}
|
||||
if (cn == "QLineEdit" || cn == "CLineEdit") {
|
||||
connect(w, SIGNAL(textChanged(QString)), this, SLOT(slotText(QString)), Qt::UniqueConnection);
|
||||
ok = true;
|
||||
}
|
||||
if (cn == "QVariantEdit") {
|
||||
connect(w, SIGNAL(valueChanged(QVariant)), this, SLOT(slotVariant(QVariant)), Qt::UniqueConnection);
|
||||
ok = true;
|
||||
}
|
||||
if (cn == "CDView") {
|
||||
bindView(w);
|
||||
}
|
||||
connect(w, SIGNAL(destroyed(QObject*)), this, SLOT(slotDestroyed(QObject*)), Qt::UniqueConnection);
|
||||
setWidgetValue(w, k);
|
||||
if (!ok) return false;
|
||||
//piCout << k.name() << k.path() << "ok";
|
||||
binded_widgets.insert(w, k.path());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::updateBindedWidgets() {
|
||||
QMapIterator<QWidget * , PIDeque<int> > it(binded_widgets);
|
||||
QWidgetList to_remove;
|
||||
updating = true;
|
||||
while (it.hasNext()) {
|
||||
QWidget * w = it.next().key();
|
||||
if (!K.exists(it.value()))
|
||||
to_remove << w;
|
||||
else
|
||||
setWidgetValue(w, K[it.value()]);
|
||||
}
|
||||
foreach (QWidget * w, to_remove)
|
||||
unbindWidget(w);
|
||||
updating = false;
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::bindView(QWidget * v) {
|
||||
CDView * w = qobject_cast<CDView * >(v);
|
||||
if (!w) return;
|
||||
connect(this, SIGNAL(updateViewRequest()), w, SLOT(refreshValues()), Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::setWidgetValue(QWidget * w, const CDType & k) {
|
||||
if (!w) return;
|
||||
QString cn = w->metaObject()->className();
|
||||
if (cn == "QCheckBox") qobject_cast<QCheckBox*>(w)->setChecked(k.toBool());
|
||||
if (cn == "QGroupBox") qobject_cast<QGroupBox*>(w)->setChecked(k.toBool());
|
||||
if (cn == "QSpinBox") qobject_cast<QSpinBox*>(w)->setValue(k.toInt());
|
||||
if (cn == "QSlider") qobject_cast<QSlider*>(w)->setValue(k.toInt());
|
||||
if (cn == "QScrollBar") qobject_cast<QScrollBar*>(w)->setValue(k.toInt());
|
||||
if (cn == "QDoubleSpinBox") qobject_cast<QDoubleSpinBox*>(w)->setValue(k.toDouble());
|
||||
if (cn == "SpinSlider") qobject_cast<SpinSlider*>(w)->setValue(k.toDouble());
|
||||
if (cn == "QLineEdit") qobject_cast<QLineEdit*>(w)->setText(PI2QString(k.value()));
|
||||
if (cn == "CLineEdit") qobject_cast<CLineEdit*>(w)->setText(PI2QString(k.value()));
|
||||
if (cn == "EvalSpinBox") qobject_cast<EvalSpinBox*>(w)->setValue(k.toDouble());
|
||||
if (cn == "QVariantEdit") qobject_cast<QVariantEdit*>(w)->setValue(PI2QVariant(k.variantValue()));
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::finishEdit(const QList<PIDeque<int> > & pathes) {
|
||||
K.calculate();
|
||||
if (direct_on) {
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
K.directChange(K[path]);
|
||||
}
|
||||
emit updateViewRequest();
|
||||
}
|
||||
|
||||
|
||||
int QCDCore::unbindWindow(QWidget * wnd) {
|
||||
if (!wnd) return 0;
|
||||
return unbindWidgets(wnd->findChildren<QWidget * >());
|
||||
}
|
||||
|
||||
|
||||
int QCDCore::unbindWidgets(QList<QWidget * > wl) {
|
||||
int ret = 0;
|
||||
foreach (QWidget * w, wl)
|
||||
if (unbindWidget(w)) ++ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool QCDCore::unbindWidget(QWidget * w) {
|
||||
if (!w) return false;
|
||||
//qDebug() << "unbind" << w;
|
||||
if (!binded_widgets.contains(w)) return false;
|
||||
QString cn = w->metaObject()->className();
|
||||
if (cn == "QCheckBox" || cn == "QGroupBox")
|
||||
disconnect(w, SIGNAL(toggled(bool)), this, SLOT(slotBool(bool)));
|
||||
if (cn == "QSpinBox" || cn == "QSlider" || cn == "QScrollBar")
|
||||
disconnect(w, SIGNAL(valueChanged(int)), this, SLOT(slotInt(int)));
|
||||
if (cn == "QDoubleSpinBox" || cn == "SpinSlider" || cn == "EvalSpinBox")
|
||||
disconnect(w, SIGNAL(valueChanged(double)), this, SLOT(slotDouble(double)));
|
||||
if (cn == "QLineEdit" || cn == "CLineEdit")
|
||||
disconnect(w, SIGNAL(textChanged(QString)), this, SLOT(slotText(QString)));
|
||||
if (cn == "QVariantEdit")
|
||||
disconnect(w, SIGNAL(valueChanged(QVariant)), this, SLOT(slotVariant(QVariant)));
|
||||
//qDebug() << "remove b" << binded_widgets.size();
|
||||
binded_widgets.remove(w);
|
||||
//qDebug() << "remove a" << binded_widgets.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::unbindAllWidgets() {
|
||||
QMap<QWidget * , PIDeque<int> > bwm = binded_widgets;
|
||||
QMapIterator<QWidget * , PIDeque<int> > it(bwm);
|
||||
while (it.hasNext()) {
|
||||
QWidget * w = it.next().key();
|
||||
unbindWidget(w);
|
||||
}
|
||||
binded_widgets.clear();
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::updateBindedWidget(const CDType & k_) {
|
||||
QMapIterator<QWidget * , PIDeque<int> > it(binded_widgets);
|
||||
updating = true;
|
||||
while (it.hasNext()) {
|
||||
QWidget * w = it.next().key();
|
||||
const CDType & k(K[it.value()]);
|
||||
if (k.path() != k_.path()) continue;
|
||||
setWidgetValue(w, k);
|
||||
}
|
||||
updating = false;
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef QCD_CORE_H
|
||||
#define QCD_CORE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMultiMap>
|
||||
#include <QVariant>
|
||||
#include "piobject.h"
|
||||
#include "cdutils_types.h"
|
||||
#include "qcd_utils_export.h"
|
||||
|
||||
|
||||
class QCDCore;
|
||||
|
||||
|
||||
class QCD_UTILS_EXPORT __QCore_Initializer__ {
|
||||
public:
|
||||
__QCore_Initializer__();
|
||||
~__QCore_Initializer__();
|
||||
static int count_;
|
||||
static QCDCore * __instance__;
|
||||
};
|
||||
|
||||
|
||||
class QCD_UTILS_EXPORT QCDCore: public QObject, public PIObject
|
||||
{
|
||||
Q_OBJECT
|
||||
PIOBJECT(QCDCore)
|
||||
friend class __QCore_Initializer__;
|
||||
public:
|
||||
static QCDCore * instance() {return __QCore_Initializer__::__instance__;}
|
||||
|
||||
int bindWindow(QWidget * wnd);
|
||||
int bindWidgets(QList<QWidget * > wl);
|
||||
bool bindWidget(QWidget * w);
|
||||
bool bindWidget(QWidget * w, const CDUtils::CDType & k);
|
||||
|
||||
int unbindWindow(QWidget * wnd);
|
||||
int unbindWidgets(QList<QWidget * > wl);
|
||||
bool unbindWidget(QWidget * w);
|
||||
void unbindAllWidgets();
|
||||
|
||||
void updateBindedWidget(const CDUtils::CDType & k_);
|
||||
void setDirectKEnabled(bool yes) {direct_on = yes;}
|
||||
bool isDirectKEnabled() const {return direct_on;}
|
||||
|
||||
private:
|
||||
QCDCore();
|
||||
~QCDCore();
|
||||
|
||||
void bindView(QWidget * v);
|
||||
void setWidgetValue(QWidget * w, const CDUtils::CDType & k);
|
||||
void finishEdit(const QList<PIDeque<int> > & pathes);
|
||||
EVENT_HANDLER(void, K_ChangedGlobal);
|
||||
|
||||
QMultiMap<QWidget * , PIDeque<int> > binded_widgets;
|
||||
bool updating, direct_on;
|
||||
|
||||
private slots:
|
||||
void slotBool(bool v);
|
||||
void slotInt(int v);
|
||||
void slotDouble(double v);
|
||||
void slotText(QString v);
|
||||
void slotVariant(QVariant v);
|
||||
void slotDestroyed(QObject * );
|
||||
|
||||
public slots:
|
||||
void updateBindedWidgets();
|
||||
|
||||
signals:
|
||||
void updateViewRequest();
|
||||
|
||||
};
|
||||
|
||||
|
||||
static __QCore_Initializer__ __QCore_initializer__;
|
||||
|
||||
|
||||
#endif // QCD_CORE_H
|
||||
@@ -1,40 +0,0 @@
|
||||
#include "qcd_graphic.h"
|
||||
#include "ui_qcd_graphic.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "graphic.h"
|
||||
#include "piqt.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
CDGraphicWidget::CDGraphicWidget(QWidget * p): QWidget(p) {
|
||||
ui = new Ui::CDGraphicWidget();
|
||||
ui->setupUi(this);
|
||||
ui->graphic->setGraphicsCount(0);
|
||||
}
|
||||
|
||||
|
||||
Graphic * CDGraphicWidget::graphic() const {
|
||||
return ui->graphic;
|
||||
}
|
||||
|
||||
|
||||
void CDGraphicWidget::setConfigVisible(bool on) {
|
||||
ui->widgetConfig->setVisible(on);
|
||||
}
|
||||
|
||||
|
||||
bool CDGraphicWidget::isConfigVisible() const {
|
||||
return ui->widgetConfig->isVisible();
|
||||
}
|
||||
|
||||
|
||||
EvalSpinBox * CDGraphicWidget::evalSpinBoxHistory() {
|
||||
return ui->evalHistory;
|
||||
}
|
||||
|
||||
|
||||
EvalSpinBox * CDGraphicWidget::evalSpinBoxVisible() {
|
||||
return ui->evalVisible;
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef QCD_GRAPHIC_H
|
||||
#define QCD_GRAPHIC_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <evalspinbox.h>
|
||||
#include <pistring.h>
|
||||
#include "qcd_utils_export.h"
|
||||
|
||||
namespace CDUtils {
|
||||
class CDType;
|
||||
class CDSection;
|
||||
}
|
||||
|
||||
namespace Ui {
|
||||
class CDGraphicWidget;
|
||||
}
|
||||
|
||||
class Graphic;
|
||||
class Graphic;
|
||||
|
||||
|
||||
class QCD_UTILS_EXPORT CDGraphicWidget: public QWidget {
|
||||
Q_OBJECT
|
||||
friend class CDGraphics;
|
||||
friend class GDockWidget;
|
||||
public:
|
||||
CDGraphicWidget(QWidget * p = 0);
|
||||
|
||||
Graphic * graphic() const;
|
||||
bool isConfigVisible() const;
|
||||
|
||||
EvalSpinBox * evalSpinBoxHistory();
|
||||
EvalSpinBox * evalSpinBoxVisible();
|
||||
|
||||
public slots:
|
||||
void setConfigVisible(bool on);
|
||||
|
||||
private:
|
||||
Ui::CDGraphicWidget * ui;
|
||||
|
||||
private slots:
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // QCD_GRAPHIC_H
|
||||
@@ -1,169 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDGraphicWidget</class>
|
||||
<widget class="QWidget" name="CDGraphicWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>470</width>
|
||||
<height>380</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>CD Pult</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="layoutMain">
|
||||
<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="Graphic" name="graphic">
|
||||
<property name="buttons">
|
||||
<set>Graphic::Autofit|Graphic::BorderInputs|Graphic::Clear|Graphic::Configure|Graphic::CursorAxis|Graphic::Fullscreen|Graphic::Legend|Graphic::OnlyExpandY|Graphic::Pause|Graphic::Save</set>
|
||||
</property>
|
||||
<property name="borderInputsVisible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="statusVisible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="historySize">
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetConfig" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<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="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>History:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="EvalSpinBox" name="evalHistory">
|
||||
<property name="value">
|
||||
<double>100.000000000000000</double>
|
||||
</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>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Visible:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="EvalSpinBox" name="evalVisible">
|
||||
<property name="value">
|
||||
<double>-1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<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>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Graphic</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>graphic.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>EvalSpinBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>evalspinbox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>evalHistory</sender>
|
||||
<signal>valueChanged(double)</signal>
|
||||
<receiver>graphic</receiver>
|
||||
<slot>setHistorySize(double)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>148</x>
|
||||
<y>363</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>156</x>
|
||||
<y>297</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>evalVisible</sender>
|
||||
<signal>valueChanged(double)</signal>
|
||||
<receiver>graphic</receiver>
|
||||
<slot>setMaxVisibleTime(double)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>345</x>
|
||||
<y>361</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>342</x>
|
||||
<y>337</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -1,46 +0,0 @@
|
||||
#include "qcd_modedialog.h"
|
||||
#include "ui_qcd_modedialog.h"
|
||||
|
||||
|
||||
QCDModeDialog::QCDModeDialog(QWidget * parent): QDialog(parent) {
|
||||
ui = new Ui::QCDModeDialog();
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
|
||||
QCDModeDialog::~QCDModeDialog() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
CDUtils::UpdateModeFlags QCDModeDialog::mode() const {
|
||||
CDUtils::UpdateModeFlags ret = 0;
|
||||
if (ui->checkSaveIndex->isChecked()) ret |= CDUtils::SaveByIndex;
|
||||
if (ui->checkSaveName->isChecked()) ret |= CDUtils::SaveByName;
|
||||
if (ui->checkMerge->isChecked()) ret |= CDUtils::Merge;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void QCDModeDialog::changeEvent(QEvent *e) {
|
||||
QDialog::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QCDModeDialog::on_checkSaveIndex_clicked(bool checked) {
|
||||
if (!checked) return;
|
||||
ui->checkSaveName->setChecked(false);
|
||||
}
|
||||
|
||||
|
||||
void QCDModeDialog::on_checkSaveName_clicked(bool checked) {
|
||||
if (!checked) return;
|
||||
ui->checkSaveIndex->setChecked(false);
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef QCD_MODEDIALOG_H
|
||||
#define QCD_MODEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <cdutils_types.h>
|
||||
#include "qcd_utils_export.h"
|
||||
|
||||
namespace Ui {
|
||||
class QCDModeDialog;
|
||||
}
|
||||
|
||||
class QCD_UTILS_EXPORT QCDModeDialog: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QCDModeDialog(QWidget * parent = 0);
|
||||
~QCDModeDialog();
|
||||
|
||||
CDUtils::UpdateModeFlags mode() const;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
Ui::QCDModeDialog * ui;
|
||||
|
||||
private slots:
|
||||
void on_checkSaveIndex_clicked(bool checked);
|
||||
void on_checkSaveName_clicked(bool checked);
|
||||
|
||||
};
|
||||
|
||||
#endif // QCD_MODEDIALOG_H
|
||||
@@ -1,98 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QCDModeDialog</class>
|
||||
<widget class="QDialog" name="QCDModeDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>251</width>
|
||||
<height>152</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Update description mode</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkSaveIndex">
|
||||
<property name="text">
|
||||
<string>Save by index</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkSaveName">
|
||||
<property name="text">
|
||||
<string>Save by name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkMerge">
|
||||
<property name="text">
|
||||
<string>Merge</string>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>QCDModeDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>106</x>
|
||||
<y>131</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>101</x>
|
||||
<y>146</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>QCDModeDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>182</x>
|
||||
<y>127</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>169</x>
|
||||
<y>146</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -1,460 +0,0 @@
|
||||
#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) {
|
||||
interface = i;
|
||||
index_ = _index;
|
||||
parent_ = parent;
|
||||
type_ = type;
|
||||
item_count = 0;
|
||||
expanded = true;
|
||||
}
|
||||
|
||||
|
||||
CDItem::~CDItem() {
|
||||
qDeleteAll(childs);
|
||||
}
|
||||
|
||||
|
||||
QVariant CDItem::data(int column, int role) const {
|
||||
if (role == Qt::BackgroundRole) {
|
||||
switch (type_) {
|
||||
case ItemCDType: {
|
||||
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) {
|
||||
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_]);
|
||||
return PI2QString(t.errorString());
|
||||
}
|
||||
if (role != Qt::DisplayRole && role != Qt::EditRole) return QVariant();
|
||||
PIDeque<int> path = buildPath();
|
||||
CDSection & rs = interface->section(path);
|
||||
CDSection s;
|
||||
switch (type_) {
|
||||
case ItemCDType:
|
||||
switch (column) {
|
||||
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;
|
||||
case ItemCDSection:
|
||||
s = rs.section(index_);
|
||||
// piCout << rs.name << rs.alias << s.name << s.alias;
|
||||
switch (column) {
|
||||
case cID: return QString("[") + QString::number(index_) + QString("]");
|
||||
case cName_Cmd: return PI2QString(s.alias);
|
||||
case cType: return PI2QString(s.name);
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
QVariant CDItem::value(CDType & t, int role) const {
|
||||
if (t.type() == "f") return t.toDouble();
|
||||
if (t.type() == "n") return t.toInt();
|
||||
if (t.type() == "b") return t.toBool();
|
||||
if (t.type() == "e") {
|
||||
QAD::Enum et = PI2QADEnum(t.enumValues());
|
||||
et.selectValue(t.toInt());
|
||||
if (role == Qt::EditRole) return QVariant::fromValue<QAD::Enum>(et);
|
||||
else return et.selectedName();
|
||||
}
|
||||
return PI2QString(t.value());
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
PIDeque<int> CDItem::buildPath() const {
|
||||
PIDeque<int> path;
|
||||
CDItem * p = parent_;
|
||||
while (p) {
|
||||
path.push_front(p->index_);
|
||||
p = p->parent_;
|
||||
}
|
||||
path.take_front();
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
QString CDItem::stringType(const PIString & t) const {
|
||||
QString n = PI2QString(t);
|
||||
if (n.isEmpty()) return QString("");
|
||||
switch (n[0].toLatin1()) {
|
||||
case 'l': return QString("list"); break;
|
||||
case 'b': return QString("bool"); break;
|
||||
case 'n': return QString("int"); break;
|
||||
case 'f': return QString("double"); break;
|
||||
case 'c': return QString("color"); break;
|
||||
case 'r': return QString("rect"); break;
|
||||
case 'a': return QString("rect"); break;
|
||||
case 'p': return QString("point"); break;
|
||||
case 'v': return QString("vector"); break;
|
||||
case 'i': return QString("IP"); break;
|
||||
case 'e': return QString("enum"); break;
|
||||
case 'F': return QString("file"); break;
|
||||
case 'D': return QString("dir"); break;
|
||||
}
|
||||
return QString("string");
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
void CDDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
|
||||
QVariantEdit *edit = static_cast<QVariantEdit*>(editor);
|
||||
edit->setValue(index.model()->data(index, Qt::EditRole));
|
||||
}
|
||||
|
||||
|
||||
void CDDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
|
||||
QVariantEdit *edit = static_cast<QVariantEdit*>(editor);
|
||||
QVariant v = edit->value();
|
||||
if (v.canConvert<QAD::Enum>()) {
|
||||
QAD::Enum et = v.value<QAD::Enum>();
|
||||
model->setData(index, et.selectedValue(), Qt::EditRole);
|
||||
} else model->setData(index, v, Qt::EditRole);
|
||||
}
|
||||
|
||||
|
||||
void CDDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
|
||||
|
||||
QSize CDDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
QSize s = QStyledItemDelegate::sizeHint(option, index);
|
||||
s.setWidth(s.width() + 20);
|
||||
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 cID: return tr("Index");
|
||||
case cName_Cmd: return interface->cdType() == CDType::cdC ? tr("Command") : tr("Name");
|
||||
case cType: return tr("Type");
|
||||
case cXMode: return tr("Mode");
|
||||
case cXAvg: return tr("Averaging");
|
||||
case cExpression: return tr("Expression");
|
||||
case cValue: return tr("Value");
|
||||
case cComment: return tr("Comment");
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
QModelIndex CDItemModel::index(int row, int column, const QModelIndex &parent) const {
|
||||
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);
|
||||
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), cID, p);
|
||||
}
|
||||
|
||||
|
||||
int CDItemModel::rowCount(const QModelIndex &parent) const {
|
||||
CDItem * p = getItem(parent);
|
||||
return p->childs.count();
|
||||
}
|
||||
|
||||
|
||||
int CDItemModel::columnCount(const QModelIndex &parent) const {
|
||||
return cLastColumn;
|
||||
}
|
||||
|
||||
|
||||
Qt::ItemFlags CDItemModel::flags(const QModelIndex & index) const {
|
||||
if (!index.isValid()) return Qt::ItemFlags();
|
||||
Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
CDItem * item = getItem(index);
|
||||
if (!item) return Qt::ItemFlags();
|
||||
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 (index.column() == cName_Cmd)
|
||||
f |= Qt::ItemIsDragEnabled;
|
||||
}
|
||||
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() == cName_Cmd || index.column() == cValue)) {
|
||||
CDItem * item = getItem(index);
|
||||
if (item->type_ == CDItem::ItemCDType) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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(), cExpression, index.parent()));
|
||||
emit dataChanged(rin, rin);
|
||||
emit dataChanged(index, index);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
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::instance()->typeLetter(interface->cdType()) +
|
||||
CDCore::pathToString(t.path())));
|
||||
return mime;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QAbstractItemModel::mimeData(indexes);
|
||||
}
|
||||
|
||||
|
||||
void CDItemModel::rebuildModel() {
|
||||
beginResetModel();
|
||||
internalRebuild();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
|
||||
void CDItemModel::buildItem(CDItem * it, CDSection & r) {
|
||||
//piCout << "build item" << r.name << r.alias;
|
||||
auto i = r.cd.makeIterator();
|
||||
while (i.next()) {
|
||||
it->childs << new CDItem(interface, i.key(), CDItem::ItemCDType, it);
|
||||
}
|
||||
it->item_count = it->childs.size();
|
||||
auto j = r.s.makeIterator();
|
||||
while (j.next()) {
|
||||
it->childs << new CDItem(interface, j.key(), CDItem::ItemCDSection, it);
|
||||
buildItem(it->childs.back(), j.valueRef());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
QModelIndex CDItemModel::indexByPath(const PIDeque<int> & path, int column) const {
|
||||
if (path.isEmpty()) return QModelIndex();
|
||||
CDItem * item = root;
|
||||
//piCout << path << "...";
|
||||
bool ok = false;
|
||||
for (int i = 0; i < path.size_s() - 1; ++i) {
|
||||
ok = false;
|
||||
foreach (CDItem * j, item->childs)
|
||||
if (j->type_ == CDItem::ItemCDSection && j->index_ == path[i]) {
|
||||
item = j;
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
if (!ok) return QModelIndex();
|
||||
}
|
||||
ok = false;
|
||||
foreach (CDItem * j, item->childs)
|
||||
if (j->type_ == CDItem::ItemCDType && j->index_ == path.back()) {
|
||||
item = j;
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
if (!ok || !item->parent_) return QModelIndex();
|
||||
QModelIndex ret = createIndex(item->parent_->childs.indexOf(item), column, item);
|
||||
//piCout << path << Q2PIString(item->data(cName_Cmd, Qt::DisplayRole).toString()) << getItem(ret)->buildPath();
|
||||
return ret;
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef QCD_MODEL_H
|
||||
#define QCD_MODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QItemDelegate>
|
||||
#include <QStyledItemDelegate>
|
||||
#include "pistring.h"
|
||||
#include "qcd_utils_export.h"
|
||||
|
||||
namespace CDUtils {
|
||||
class CDType;
|
||||
class CDSection;
|
||||
class Interface;
|
||||
|
||||
enum Column {
|
||||
cID ,
|
||||
cName_Cmd ,
|
||||
cType ,
|
||||
cXMode ,
|
||||
cXAvg ,
|
||||
cExpression,
|
||||
cValue ,
|
||||
cComment ,
|
||||
cLastColumn,
|
||||
};
|
||||
}
|
||||
|
||||
namespace QAD {
|
||||
struct Enum;
|
||||
}
|
||||
|
||||
class CDItemModel;
|
||||
|
||||
|
||||
class QCD_UTILS_EXPORT CDItem {
|
||||
friend class CDItemModel;
|
||||
friend class CDView;
|
||||
public:
|
||||
enum CDItemType{ItemCDType, ItemCDSection};
|
||||
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);
|
||||
CDItemType itemType() const {return type_;}
|
||||
PIDeque<int> buildPath() const;
|
||||
int index() const {return index_;}
|
||||
|
||||
CDUtils::Interface * interface;
|
||||
bool expanded;
|
||||
|
||||
private:
|
||||
QString stringType(const PIString & t) const;
|
||||
QAD::Enum xModeEnum(int v) const;
|
||||
|
||||
CDItem * parent_;
|
||||
int index_, item_count;
|
||||
CDItemType type_;
|
||||
QList<CDItem *> childs;
|
||||
};
|
||||
|
||||
|
||||
class QCD_UTILS_EXPORT CDDelegate : public QStyledItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
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 QCD_UTILS_EXPORT CDItemModel : public QAbstractItemModel {
|
||||
Q_OBJECT
|
||||
friend class CDView;
|
||||
public:
|
||||
explicit CDItemModel(int type_, QObject *parent = 0);
|
||||
~CDItemModel();
|
||||
|
||||
QVariant data(const QModelIndex & index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
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;
|
||||
QModelIndex indexByPath(const PIDeque<int> & path, int column = CDUtils::cID) const;
|
||||
|
||||
void buildItem(CDItem * it, CDUtils::CDSection &r);
|
||||
|
||||
public slots:
|
||||
void rebuildModel();
|
||||
void updateModel();
|
||||
|
||||
private:
|
||||
void internalRebuild();
|
||||
|
||||
CDUtils::Interface * interface;
|
||||
CDItem * root;
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // QCD_MODEL_H
|
||||
@@ -1,371 +0,0 @@
|
||||
#include <QDir>
|
||||
#include <QMouseEvent>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "cdutils_c.h"
|
||||
#include "cdutils_m.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "qcd_view.h"
|
||||
#include "qcd_model.h"
|
||||
#include "piqt.h"
|
||||
#include "pifile.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
CDView::CDView(QWidget * parent) : QTreeView(parent) {
|
||||
type_ = -1;
|
||||
model_ = 0;
|
||||
proxy_ = 0;
|
||||
connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(indexClicked(QModelIndex)));
|
||||
connect(this, SIGNAL(_qcd_sendFailed()), this, SLOT(cd_sendFailed()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_sendSucceed()), this, SLOT(cd_sendSucceed()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_receiveFailed()), this, SLOT(cd_receiveFailed()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_receiveSucceed()), this, SLOT(cd_receiveSucceed()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_receivedX()), this, SLOT(cd_receivedX()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_changedGlobal()), this, SLOT(cd_changedGlobal()), Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
|
||||
CDView::~CDView() {
|
||||
if (model_) {
|
||||
delete model_;
|
||||
delete proxy_;
|
||||
}
|
||||
model_ = 0;
|
||||
proxy_ = 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);
|
||||
CONNECTU(&K, changedGlobal, this, pi_cd_changedGlobal);
|
||||
break;
|
||||
case CDType::cdX:
|
||||
CONNECTU(&X, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&X, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&X, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&X, receiveFailed, this, pi_cd_receiveFailed);
|
||||
CONNECTU(&X, receivedX, this, pi_cd_receivedX);
|
||||
CONNECTU(&X, changedGlobal, this, pi_cd_changedGlobal);
|
||||
break;
|
||||
case CDType::cdC:
|
||||
CONNECTU(&C, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&C, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&C, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&C, receiveFailed, this, pi_cd_receiveFailed);
|
||||
CONNECTU(&C, changedGlobal, this, pi_cd_changedGlobal);
|
||||
break;
|
||||
case CDType::cdM:
|
||||
CONNECTU(&M, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&M, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&M, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&M, receiveFailed, this, pi_cd_receiveFailed);
|
||||
CONNECTU(&M, changedGlobal, this, pi_cd_changedGlobal);
|
||||
CONNECTU(&M, messageReceived, this, pi_cd_messageReceived);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CDView::mousePressEvent(QMouseEvent * e) {
|
||||
if (type_ == CDType::cdC) {
|
||||
QModelIndex i = indexAt(e->pos());
|
||||
if (i.isValid() && i.column() == cName_Cmd)
|
||||
update(i);
|
||||
}
|
||||
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_);
|
||||
proxy_ = new QSortFilterProxyModel();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||
proxy_->setRecursiveFilteringEnabled(true);
|
||||
#endif
|
||||
proxy_->setFilterKeyColumn(-1);
|
||||
proxy_->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
proxy_->setSourceModel(model_);
|
||||
setModel(proxy_);
|
||||
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(cExpression, true);
|
||||
break;
|
||||
case CDType::cdC:
|
||||
case CDType::cdM:
|
||||
setColumnHidden(cType, true);
|
||||
setColumnHidden(cXMode, true);
|
||||
setColumnHidden(cXAvg, true);
|
||||
setColumnHidden(cExpression, true);
|
||||
setColumnHidden(cValue, true);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
expandAll();
|
||||
for (int i = 0; i < model_->columnCount(); i++) resizeColumnToContents(i);
|
||||
}
|
||||
|
||||
|
||||
void CDView::refreshValues() {
|
||||
if (!model_) return;
|
||||
model_->dataChanged(model_->index(0, 0), model_->index(model_->columnCount() - 1, model_->rowCount() - 1));
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
case CDType::cdM: M.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;
|
||||
case CDType::cdC: return C.inProgress(); break;
|
||||
case CDType::cdM: return M.inProgress(); break;
|
||||
default: break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void CDView::startX(double freq) {
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdX: X.start(freq); 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;
|
||||
case CDType::cdC: C.send(); break;
|
||||
case CDType::cdM: M.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;
|
||||
case CDType::cdC: C.request(); break;
|
||||
case CDType::cdM: M.request(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
case CDType::cdM: M.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;
|
||||
case CDType::cdC:
|
||||
C.readFile();
|
||||
C.calculate();
|
||||
break;
|
||||
case CDType::cdM:
|
||||
M.readFile();
|
||||
M.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;
|
||||
case CDType::cdC: C.root() = CDSection(); break;
|
||||
case CDType::cdM: M.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;
|
||||
case CDType::cdC: C.update(&f, mode); break;
|
||||
case CDType::cdM: M.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;
|
||||
case CDType::cdC: C.calculate(); break;
|
||||
case CDType::cdM: M.calculate(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CDView::filter(const QString & f) {
|
||||
proxy_->setFilterRegExp(QRegExp(f, Qt::CaseInsensitive));
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
void CDView::cd_receivedX() {
|
||||
X.lock();
|
||||
PIVector<PIDeque<int> > xl = X.enabledList();
|
||||
//piCout << "X" << xl.size();
|
||||
piForeachC (PIDeque<int> & x, xl) {
|
||||
CDType & t(X[x]);
|
||||
//piCout << t;
|
||||
//piCout << t.path();
|
||||
if (t.cd_type() != CDType::cdX) continue;
|
||||
update(model_->indexByPath(t.path(), cValue));
|
||||
//piCout << CDCore::pathToString(t.path()) << t.toDouble() << "model";
|
||||
//qDebug() << "val" << model_->data(model_->indexByPath(t.path(), cValue), Qt::DisplayRole).toDouble();
|
||||
}
|
||||
X.unlock();
|
||||
emit receivedX();
|
||||
}
|
||||
|
||||
|
||||
void CDView::cd_changedGlobal() {
|
||||
emit changedGlobal();
|
||||
}
|
||||
|
||||
|
||||
void CDView::pi_cd_messageReceived(PIDeque<int> path, int type, PIString msg) {
|
||||
QMetaObject::invokeMethod(this, "messageReceived", Qt::QueuedConnection,
|
||||
Q_ARG(QString, PI2QString(CDCore::pathToString(path))),
|
||||
Q_ARG(int, type),
|
||||
Q_ARG(QString, PI2QString(msg)));
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef QCD_VIEW_H
|
||||
#define QCD_VIEW_H
|
||||
|
||||
#include <QTreeView>
|
||||
#include "piobject.h"
|
||||
#include "qcd_utils_export.h"
|
||||
|
||||
namespace CDUtils {
|
||||
class CDType;
|
||||
class CDSection;
|
||||
}
|
||||
|
||||
class CDItemModel;
|
||||
class QSortFilterProxyModel;
|
||||
|
||||
class QCD_UTILS_EXPORT 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 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 refreshValues();
|
||||
void send();
|
||||
void receive();
|
||||
void save();
|
||||
void load();
|
||||
void clear();
|
||||
void buildFromHeader(const QString & description, int mode = 2);
|
||||
void calculate();
|
||||
void filter(const QString & f);
|
||||
|
||||
private slots:
|
||||
void indexClicked(const QModelIndex & i);
|
||||
void cd_sendFailed();
|
||||
void cd_sendSucceed();
|
||||
void cd_receiveFailed();
|
||||
void cd_receiveSucceed();
|
||||
void cd_receivedX();
|
||||
void cd_changedGlobal();
|
||||
|
||||
private:
|
||||
bool filterTree(const QModelIndex & ti, const QString & filter);
|
||||
EVENT_HANDLER(void, pi_cd_sendFailed) {emit _qcd_sendFailed();}
|
||||
EVENT_HANDLER(void, pi_cd_sendSucceed) {emit _qcd_sendSucceed();}
|
||||
EVENT_HANDLER(void, pi_cd_receiveFailed) {emit _qcd_receiveFailed();}
|
||||
EVENT_HANDLER(void, pi_cd_receiveSucceed) {emit _qcd_receiveSucceed();}
|
||||
EVENT_HANDLER(void, pi_cd_receivedX) {emit _qcd_receivedX();}
|
||||
EVENT_HANDLER(void, pi_cd_changedGlobal) {emit _qcd_changedGlobal();}
|
||||
EVENT_HANDLER3(void, pi_cd_messageReceived, PIDeque<int>, path, int, type, PIString, msg);
|
||||
|
||||
CDItemModel * model_;
|
||||
QSortFilterProxyModel * proxy_;
|
||||
int type_;
|
||||
|
||||
signals:
|
||||
void sendFailed();
|
||||
void sendSucceed();
|
||||
void receiveFailed();
|
||||
void receiveSucceed();
|
||||
void receivedX();
|
||||
void changedGlobal();
|
||||
void messageStatus(QString msg);
|
||||
void commandSended(QString msg);
|
||||
void messageReceived(QString path, int type, QString msg);
|
||||
void busyStatusChanged(bool busy);
|
||||
|
||||
void _qcd_sendFailed(); // PRIVATE
|
||||
void _qcd_sendSucceed(); // PRIVATE
|
||||
void _qcd_receiveFailed(); // PRIVATE
|
||||
void _qcd_receiveSucceed(); // PRIVATE
|
||||
void _qcd_receivedX(); // PRIVATE
|
||||
void _qcd_changedGlobal(); // PRIVATE
|
||||
|
||||
};
|
||||
|
||||
#endif // QCD_VIEW_H
|
||||
Reference in New Issue
Block a user