code format
This commit is contained in:
@@ -1,20 +1,22 @@
|
||||
#include "qcd_core.h"
|
||||
#include "cdutils_k.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_k.h"
|
||||
#include "piqt.h"
|
||||
#include <QWidget>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QGroupBox>
|
||||
#include <QSpinBox>
|
||||
#include <QSlider>
|
||||
#include <QScrollBar>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QGroupBox>
|
||||
#include <QLineEdit>
|
||||
#include <spinslider.h>
|
||||
#include <QScrollBar>
|
||||
#include <QSlider>
|
||||
#include <QSpinBox>
|
||||
#include <QWidget>
|
||||
#include <clineedit.h>
|
||||
#include <evalspinbox.h>
|
||||
#include <qvariantedit.h>
|
||||
#include <qcd_view.h>
|
||||
#include <qvariantedit.h>
|
||||
#include <spinslider.h>
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
@@ -40,8 +42,6 @@ __QCore_Initializer__::~__QCore_Initializer__() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QCDCore::QCDCore() {
|
||||
setObjectName("QCDCore");
|
||||
setName("QCDCore");
|
||||
@@ -50,8 +50,7 @@ QCDCore::QCDCore() {
|
||||
}
|
||||
|
||||
|
||||
QCDCore::~QCDCore() {
|
||||
}
|
||||
QCDCore::~QCDCore() {}
|
||||
|
||||
|
||||
void QCDCore::K_ChangedGlobal() {
|
||||
@@ -60,10 +59,10 @@ void QCDCore::K_ChangedGlobal() {
|
||||
|
||||
|
||||
void QCDCore::slotBool(bool v) {
|
||||
QWidget * w = (QWidget*)sender();
|
||||
QWidget * w = (QWidget *)sender();
|
||||
if (!w || updating) return;
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
QList<PIDeque<int>> pathes = binded_widgets.values(w);
|
||||
foreach(const PIDeque<int> & path, pathes)
|
||||
K[path].setValue(PIString::fromBool(v));
|
||||
K.calculate();
|
||||
emit updateViewRequest();
|
||||
@@ -71,40 +70,40 @@ void QCDCore::slotBool(bool v) {
|
||||
|
||||
|
||||
void QCDCore::slotInt(int v) {
|
||||
QWidget * w = (QWidget*)sender();
|
||||
QWidget * w = (QWidget *)sender();
|
||||
if (!w || updating) return;
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
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();
|
||||
QWidget * w = (QWidget *)sender();
|
||||
if (!w || updating) return;
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
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();
|
||||
QWidget * w = (QWidget *)sender();
|
||||
if (!w || updating) return;
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
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();
|
||||
QWidget * w = (QWidget *)sender();
|
||||
if (!w || updating) return;
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
QList<PIDeque<int>> pathes = binded_widgets.values(w);
|
||||
foreach(const PIDeque<int> & path, pathes)
|
||||
K[path].setVariantValue(Q2PIVariant(v));
|
||||
finishEdit(pathes);
|
||||
}
|
||||
@@ -112,21 +111,21 @@ void QCDCore::slotVariant(QVariant v) {
|
||||
|
||||
void QCDCore::slotDestroyed(QObject * o) {
|
||||
if (!o) return;
|
||||
if (!binded_widgets.contains((QWidget*)o)) return;
|
||||
binded_widgets.remove((QWidget*)o);
|
||||
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 * >());
|
||||
// K.root().makePath();
|
||||
return bindWidgets(wnd->findChildren<QWidget *>());
|
||||
}
|
||||
|
||||
|
||||
int QCDCore::bindWidgets(QList<QWidget * > wl) {
|
||||
int QCDCore::bindWidgets(QList<QWidget *> wl) {
|
||||
int ret = 0;
|
||||
foreach (QWidget * w, wl)
|
||||
foreach(QWidget * w, wl)
|
||||
if (bindWidget(w)) ++ret;
|
||||
return ret;
|
||||
}
|
||||
@@ -140,8 +139,8 @@ bool QCDCore::bindWidget(QWidget * w) {
|
||||
bindView(w);
|
||||
return false;
|
||||
}
|
||||
PIVector<CDType * > ak = K.root().children();
|
||||
piForeachC (CDType * k, ak) {
|
||||
PIVector<CDType *> ak = K.root().children();
|
||||
piForeachC(CDType * k, ak) {
|
||||
if (!on.endsWith(PI2QString(k->pathString().join("_")))) continue;
|
||||
if (bindWidget(w, *k)) return true;
|
||||
}
|
||||
@@ -151,9 +150,9 @@ bool QCDCore::bindWidget(QWidget * w) {
|
||||
|
||||
bool QCDCore::bindWidget(QWidget * w, const CDType & k) {
|
||||
if (!w) return false;
|
||||
//piCout << "bind..." << k.name() << k.path();
|
||||
// piCout << "bind..." << k.name() << k.path();
|
||||
QString cn = w->metaObject()->className();
|
||||
bool ok = false;
|
||||
bool ok = false;
|
||||
if (cn == "QCheckBox" || cn == "QGroupBox") {
|
||||
connect(w, SIGNAL(toggled(bool)), this, SLOT(slotBool(bool)), Qt::UniqueConnection);
|
||||
ok = true;
|
||||
@@ -177,17 +176,17 @@ bool QCDCore::bindWidget(QWidget * w, const CDType & k) {
|
||||
if (cn == "CDView") {
|
||||
bindView(w);
|
||||
}
|
||||
connect(w, SIGNAL(destroyed(QObject*)), this, SLOT(slotDestroyed(QObject*)), Qt::UniqueConnection);
|
||||
connect(w, SIGNAL(destroyed(QObject *)), this, SLOT(slotDestroyed(QObject *)), Qt::UniqueConnection);
|
||||
setWidgetValue(w, k);
|
||||
if (!ok) return false;
|
||||
//piCout << k.name() << k.path() << "ok";
|
||||
// piCout << k.name() << k.path() << "ok";
|
||||
binded_widgets.insert(w, k.path());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::updateBindedWidgets() {
|
||||
QMultiMapIterator<QWidget * , PIDeque<int> > it(binded_widgets);
|
||||
QMultiMapIterator<QWidget *, PIDeque<int>> it(binded_widgets);
|
||||
QWidgetList to_remove;
|
||||
updating = true;
|
||||
while (it.hasNext()) {
|
||||
@@ -197,14 +196,14 @@ void QCDCore::updateBindedWidgets() {
|
||||
else
|
||||
setWidgetValue(w, K[it.value()]);
|
||||
}
|
||||
foreach (QWidget * w, to_remove)
|
||||
foreach(QWidget * w, to_remove)
|
||||
unbindWidget(w);
|
||||
updating = false;
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::bindView(QWidget * v) {
|
||||
CDView * w = qobject_cast<CDView * >(v);
|
||||
CDView * w = qobject_cast<CDView *>(v);
|
||||
if (!w) return;
|
||||
connect(this, SIGNAL(updateViewRequest()), w, SLOT(refreshValues()), Qt::UniqueConnection);
|
||||
}
|
||||
@@ -213,24 +212,24 @@ void QCDCore::bindView(QWidget * v) {
|
||||
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()));
|
||||
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) {
|
||||
void QCDCore::finishEdit(const QList<PIDeque<int>> & pathes) {
|
||||
K.calculate();
|
||||
if (direct_on) {
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
foreach(const PIDeque<int> & path, pathes)
|
||||
K.directChange(K[path]);
|
||||
}
|
||||
emit updateViewRequest();
|
||||
@@ -239,13 +238,13 @@ void QCDCore::finishEdit(const QList<PIDeque<int> > & pathes) {
|
||||
|
||||
int QCDCore::unbindWindow(QWidget * wnd) {
|
||||
if (!wnd) return 0;
|
||||
return unbindWidgets(wnd->findChildren<QWidget * >());
|
||||
return unbindWidgets(wnd->findChildren<QWidget *>());
|
||||
}
|
||||
|
||||
|
||||
int QCDCore::unbindWidgets(QList<QWidget * > wl) {
|
||||
int QCDCore::unbindWidgets(QList<QWidget *> wl) {
|
||||
int ret = 0;
|
||||
foreach (QWidget * w, wl)
|
||||
foreach(QWidget * w, wl)
|
||||
if (unbindWidget(w)) ++ret;
|
||||
return ret;
|
||||
}
|
||||
@@ -253,29 +252,25 @@ int QCDCore::unbindWidgets(QList<QWidget * > wl) {
|
||||
|
||||
bool QCDCore::unbindWidget(QWidget * w) {
|
||||
if (!w) return false;
|
||||
//qDebug() << "unbind" << w;
|
||||
// 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 == "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();
|
||||
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();
|
||||
// qDebug() << "remove a" << binded_widgets.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void QCDCore::unbindAllWidgets() {
|
||||
QList<QWidget * > bwk = binded_widgets.keys();
|
||||
foreach (QWidget * w, bwk) {
|
||||
QList<QWidget *> bwk = binded_widgets.keys();
|
||||
foreach(QWidget * w, bwk) {
|
||||
unbindWidget(w);
|
||||
}
|
||||
binded_widgets.clear();
|
||||
@@ -283,7 +278,7 @@ void QCDCore::unbindAllWidgets() {
|
||||
|
||||
|
||||
void QCDCore::updateBindedWidget(const CDType & k_) {
|
||||
QMultiMapIterator<QWidget * , PIDeque<int> > it(binded_widgets);
|
||||
QMultiMapIterator<QWidget *, PIDeque<int>> it(binded_widgets);
|
||||
updating = true;
|
||||
while (it.hasNext()) {
|
||||
QWidget * w = it.next().key();
|
||||
|
||||
@@ -1,31 +1,32 @@
|
||||
/*
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
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 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.
|
||||
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/>.
|
||||
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 "cd_qt_export.h"
|
||||
#include "cdutils_types.h"
|
||||
#include "piobject.h"
|
||||
|
||||
#include <QMultiMap>
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
class QCDCore;
|
||||
@@ -40,27 +41,29 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class CD_QT_EXPORT QCDCore: public QObject, public PIObject
|
||||
{
|
||||
class CD_QT_EXPORT QCDCore
|
||||
: public QObject
|
||||
, public PIObject {
|
||||
Q_OBJECT
|
||||
PIOBJECT(QCDCore);
|
||||
friend class __QCore_Initializer__;
|
||||
|
||||
public:
|
||||
static QCDCore * instance() {return __QCore_Initializer__::__instance__;}
|
||||
static QCDCore * instance() { return __QCore_Initializer__::__instance__; }
|
||||
|
||||
int bindWindow(QWidget * wnd);
|
||||
int bindWidgets(QList<QWidget * > wl);
|
||||
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);
|
||||
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;}
|
||||
void setDirectKEnabled(bool yes) { direct_on = yes; }
|
||||
bool isDirectKEnabled() const { return direct_on; }
|
||||
|
||||
private:
|
||||
QCDCore();
|
||||
@@ -68,10 +71,10 @@ private:
|
||||
|
||||
void bindView(QWidget * v);
|
||||
void setWidgetValue(QWidget * w, const CDUtils::CDType & k);
|
||||
void finishEdit(const QList<PIDeque<int> > & pathes);
|
||||
void finishEdit(const QList<PIDeque<int>> & pathes);
|
||||
EVENT_HANDLER(void, K_ChangedGlobal);
|
||||
|
||||
QMultiMap<QWidget * , PIDeque<int> > binded_widgets;
|
||||
QMultiMap<QWidget *, PIDeque<int>> binded_widgets;
|
||||
bool updating, direct_on;
|
||||
|
||||
private slots:
|
||||
@@ -80,14 +83,13 @@ private slots:
|
||||
void slotDouble(double v);
|
||||
void slotText(QString v);
|
||||
void slotVariant(QVariant v);
|
||||
void slotDestroyed(QObject * );
|
||||
void slotDestroyed(QObject *);
|
||||
|
||||
public slots:
|
||||
void updateBindedWidgets();
|
||||
|
||||
signals:
|
||||
void updateViewRequest();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "qcd_graphic.h"
|
||||
#include "ui_qcd_graphic.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "graphic.h"
|
||||
#include "piqt.h"
|
||||
#include "ui_qcd_graphic.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
@@ -1,37 +1,38 @@
|
||||
/*
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
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 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.
|
||||
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/>.
|
||||
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 "cd_qt_export.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <evalspinbox.h>
|
||||
#include <pistring.h>
|
||||
#include "cd_qt_export.h"
|
||||
|
||||
namespace CDUtils {
|
||||
class CDType;
|
||||
class CDSection;
|
||||
}
|
||||
class CDType;
|
||||
class CDSection;
|
||||
} // namespace CDUtils
|
||||
|
||||
namespace Ui {
|
||||
class CDGraphicWidget;
|
||||
class CDGraphicWidget;
|
||||
}
|
||||
|
||||
class Graphic;
|
||||
@@ -42,6 +43,7 @@ class CD_QT_EXPORT CDGraphicWidget: public QWidget {
|
||||
Q_OBJECT
|
||||
friend class CDGraphics;
|
||||
friend class GDockWidget;
|
||||
|
||||
public:
|
||||
CDGraphicWidget(QWidget * p = 0);
|
||||
|
||||
@@ -60,7 +62,6 @@ private:
|
||||
private slots:
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "qcd_modedialog.h"
|
||||
|
||||
#include "ui_qcd_modedialog.h"
|
||||
|
||||
|
||||
@@ -22,14 +23,11 @@ CDUtils::UpdateModeFlags QCDModeDialog::mode() const {
|
||||
}
|
||||
|
||||
|
||||
void QCDModeDialog::changeEvent(QEvent *e) {
|
||||
void QCDModeDialog::changeEvent(QEvent * e) {
|
||||
QDialog::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case QEvent::LanguageChange: ui->retranslateUi(this); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,36 +1,37 @@
|
||||
/*
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
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 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.
|
||||
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/>.
|
||||
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 "cd_qt_export.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <cdutils_types.h>
|
||||
|
||||
namespace Ui {
|
||||
class QCDModeDialog;
|
||||
class QCDModeDialog;
|
||||
}
|
||||
|
||||
class CD_QT_EXPORT QCDModeDialog: public QDialog
|
||||
{
|
||||
class CD_QT_EXPORT QCDModeDialog: public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QCDModeDialog(QWidget * parent = 0);
|
||||
~QCDModeDialog();
|
||||
@@ -38,14 +39,13 @@ public:
|
||||
CDUtils::UpdateModeFlags mode() const;
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
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,28 +1,30 @@
|
||||
#include "qcd_model.h"
|
||||
#include "cdutils_interface.h"
|
||||
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_interface.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "piqt.h"
|
||||
#include <QDebug>
|
||||
#include "qad_types.h"
|
||||
#include "qvariantedit.h"
|
||||
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
#include <QMimeData>
|
||||
#include <QPainter>
|
||||
#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;
|
||||
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;
|
||||
expanded = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,19 +36,23 @@ CDItem::~CDItem() {
|
||||
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));
|
||||
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 (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;
|
||||
@@ -58,31 +64,31 @@ QVariant CDItem::data(int column, int role) const {
|
||||
}
|
||||
if (role != Qt::DisplayRole && role != Qt::EditRole) return QVariant();
|
||||
PIDeque<int> path = buildPath();
|
||||
CDSection & rs = interface->section(path);
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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();
|
||||
@@ -96,8 +102,10 @@ QVariant CDItem::value(CDType & t, int role) const {
|
||||
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();
|
||||
if (role == Qt::EditRole)
|
||||
return QVariant::fromValue<QAD::Enum>(et);
|
||||
else
|
||||
return et.selectedName();
|
||||
}
|
||||
return PI2QString(t.value());
|
||||
}
|
||||
@@ -113,15 +121,9 @@ bool CDItem::setData(int column, const QVariant & value) {
|
||||
}
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -166,8 +168,7 @@ QString CDItem::stringType(const PIString & t) const {
|
||||
|
||||
QAD::Enum CDItem::xModeEnum(int v) const {
|
||||
QAD::Enum ret;
|
||||
ret << QAD::Enumerator(CDType::X_Current, "Current")
|
||||
<< QAD::Enumerator(CDType::X_All_Avg, "All, Averaging");
|
||||
ret << QAD::Enumerator(CDType::X_Current, "Current") << QAD::Enumerator(CDType::X_All_Avg, "All, Averaging");
|
||||
ret.selectValue(v);
|
||||
return ret;
|
||||
}
|
||||
@@ -175,12 +176,11 @@ QAD::Enum CDItem::xModeEnum(int v) const {
|
||||
|
||||
// CDKDelegate
|
||||
|
||||
CDDelegate::CDDelegate(QObject *parent) : QStyledItemDelegate(parent) {
|
||||
}
|
||||
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);
|
||||
CDItem * item = ((CDItemModel *)index.model())->getItem(index);
|
||||
if (item) {
|
||||
if (item->itemType() == CDItem::ItemCDType && item->interface->cdType() == CDType::cdC) {
|
||||
QStyleOptionButton bo;
|
||||
@@ -188,15 +188,14 @@ void CDDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option,
|
||||
bo.fontMetrics = option.fontMetrics;
|
||||
bo.palette = option.palette;
|
||||
bo.rect = option.rect;
|
||||
bo.state = option.state;// & ~(QStyle::State_HasFocus | QStyle::State_MouseOver);
|
||||
bo.state = option.state; // & ~(QStyle::State_HasFocus | QStyle::State_MouseOver);
|
||||
bo.text = item->data(1, Qt::DisplayRole).toString();
|
||||
QWidget * v = (QWidget*)(painter->device());
|
||||
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;
|
||||
// bo.state |= QStyle::State_MouseOver;
|
||||
if (qApp->mouseButtons().testFlag(Qt::LeftButton)) bo.state |= QStyle::State_On;
|
||||
}
|
||||
}
|
||||
qApp->style()->drawControl(QStyle::CE_PushButton, &bo, painter);
|
||||
@@ -204,37 +203,37 @@ void CDDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option,
|
||||
}
|
||||
}
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
|
||||
}
|
||||
|
||||
|
||||
QWidget * CDDelegate::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);
|
||||
}
|
||||
|
||||
|
||||
void CDDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const {
|
||||
QVariantEdit *edit = static_cast<QVariantEdit*>(editor);
|
||||
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();
|
||||
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);
|
||||
} else
|
||||
model->setData(index, v, Qt::EditRole);
|
||||
}
|
||||
|
||||
|
||||
void CDDelegate::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);
|
||||
}
|
||||
|
||||
|
||||
QSize CDDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
QSize CDDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const {
|
||||
QSize s = QStyledItemDelegate::sizeHint(option, index);
|
||||
s.setWidth(s.width() + 20);
|
||||
return s;
|
||||
@@ -243,9 +242,9 @@ QSize CDDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex
|
||||
|
||||
// CDItemModel
|
||||
|
||||
CDItemModel::CDItemModel(int type_, QObject *parent) : QAbstractItemModel(parent) {
|
||||
CDItemModel::CDItemModel(int type_, QObject * parent): QAbstractItemModel(parent) {
|
||||
interface = new Interface((CDType::cdT)type_);
|
||||
root = 0;
|
||||
root = 0;
|
||||
internalRebuild();
|
||||
}
|
||||
|
||||
@@ -256,7 +255,7 @@ CDItemModel::~CDItemModel() {
|
||||
}
|
||||
|
||||
|
||||
QVariant CDItemModel::data(const QModelIndex &index, int role) const {
|
||||
QVariant CDItemModel::data(const QModelIndex & index, int role) const {
|
||||
if (!index.isValid()) return QVariant();
|
||||
CDItem * item = getItem(index);
|
||||
return item->data(index.column(), role);
|
||||
@@ -266,30 +265,32 @@ QVariant CDItemModel::data(const QModelIndex &index, int role) const {
|
||||
QVariant CDItemModel::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||
switch (section) {
|
||||
case 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 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");
|
||||
case cValue: return tr("Value");
|
||||
case cComment: return tr("Comment");
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
QModelIndex CDItemModel::index(int row, int column, const QModelIndex &parent) const {
|
||||
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();
|
||||
if (c)
|
||||
return createIndex(row, column, c);
|
||||
else
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
|
||||
QModelIndex CDItemModel::parent(const QModelIndex &index) const {
|
||||
QModelIndex CDItemModel::parent(const QModelIndex & index) const {
|
||||
if (!index.isValid()) return QModelIndex();
|
||||
CDItem * c = getItem(index);
|
||||
CDItem * p = c->parent_;
|
||||
@@ -298,13 +299,13 @@ QModelIndex CDItemModel::parent(const QModelIndex &index) const {
|
||||
}
|
||||
|
||||
|
||||
int CDItemModel::rowCount(const QModelIndex &parent) const {
|
||||
int CDItemModel::rowCount(const QModelIndex & parent) const {
|
||||
CDItem * p = getItem(parent);
|
||||
return p->childs.count();
|
||||
}
|
||||
|
||||
|
||||
int CDItemModel::columnCount(const QModelIndex &parent) const {
|
||||
int CDItemModel::columnCount(const QModelIndex & parent) const {
|
||||
return cLastColumn;
|
||||
}
|
||||
|
||||
@@ -312,23 +313,18 @@ int CDItemModel::columnCount(const QModelIndex &parent) const {
|
||||
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);
|
||||
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 (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;
|
||||
if (index.column() == cXMode || index.column() == cXAvg) f |= Qt::ItemIsEditable;
|
||||
if (index.column() == cName_Cmd) f |= Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled;
|
||||
}
|
||||
}
|
||||
return f;
|
||||
@@ -350,15 +346,15 @@ bool CDItemModel::setData(const QModelIndex & index, const QVariant & value, int
|
||||
}
|
||||
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);
|
||||
// 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);
|
||||
bool result = item->setData(index.column(), value);
|
||||
if (result) {
|
||||
QModelIndex rin(CDItemModel::index(index.row(), cExpression, index.parent()));
|
||||
emit dataChanged(rin, rin);
|
||||
@@ -371,13 +367,12 @@ bool CDItemModel::setData(const QModelIndex & index, const QVariant & value, int
|
||||
QMimeData * CDItemModel::mimeData(const QModelIndexList & indexes) const {
|
||||
if (indexes.size() == 1) {
|
||||
QModelIndex index = indexes[0];
|
||||
if (index.isValid()/* && interface->cdType() == CDType::cdX*/) {
|
||||
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())));
|
||||
mime->setText(PI2QString(CDCore::instance()->typeLetter(interface->cdType()) + CDCore::pathToString(t.path())));
|
||||
return mime;
|
||||
}
|
||||
}
|
||||
@@ -394,13 +389,13 @@ void CDItemModel::rebuildModel() {
|
||||
|
||||
|
||||
void CDItemModel::buildItem(CDItem * it, CDSection & r) {
|
||||
//piCout << "build item" << r.name << r.alias;
|
||||
// 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();
|
||||
auto j = r.s.makeIterator();
|
||||
while (j.next()) {
|
||||
it->childs << new CDItem(interface, j.key(), CDItem::ItemCDSection, it);
|
||||
buildItem(it->childs.back(), j.value());
|
||||
@@ -415,17 +410,17 @@ void CDItemModel::updateModel() {
|
||||
|
||||
|
||||
void CDItemModel::internalRebuild() {
|
||||
//qDebug() << "[CDKItemModel]" << "internalRebuild()";
|
||||
// qDebug() << "[CDKItemModel]" << "internalRebuild()";
|
||||
if (root) delete root;
|
||||
root = new CDItem(interface, 0, CDItem::ItemCDSection, 0);
|
||||
root = new CDItem(interface, 0, CDItem::ItemCDSection, 0);
|
||||
CDSection & r = interface->root();
|
||||
buildItem(root, r);
|
||||
}
|
||||
|
||||
|
||||
CDItem * CDItemModel::getItem(const QModelIndex &index) const {
|
||||
CDItem * CDItemModel::getItem(const QModelIndex & index) const {
|
||||
if (index.isValid()) {
|
||||
CDItem * item = static_cast<CDItem*>(index.internalPointer());
|
||||
CDItem * item = static_cast<CDItem *>(index.internalPointer());
|
||||
if (item) return item;
|
||||
}
|
||||
return root;
|
||||
@@ -435,27 +430,27 @@ CDItem * CDItemModel::getItem(const QModelIndex &index) const {
|
||||
QModelIndex CDItemModel::indexByPath(const PIDeque<int> & path, int column) const {
|
||||
if (path.isEmpty()) return QModelIndex();
|
||||
CDItem * item = root;
|
||||
//piCout << path << "...";
|
||||
bool ok = false;
|
||||
// piCout << path << "...";
|
||||
bool ok = false;
|
||||
for (int i = 0; i < path.size_s() - 1; ++i) {
|
||||
ok = false;
|
||||
foreach (CDItem * j, item->childs)
|
||||
foreach(CDItem * j, item->childs)
|
||||
if (j->type_ == CDItem::ItemCDSection && j->index_ == path[i]) {
|
||||
item = j;
|
||||
ok = true;
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
if (!ok) return QModelIndex();
|
||||
}
|
||||
ok = false;
|
||||
foreach (CDItem * j, item->childs)
|
||||
foreach(CDItem * j, item->childs)
|
||||
if (j->type_ == CDItem::ItemCDType && j->index_ == path.back()) {
|
||||
item = j;
|
||||
ok = true;
|
||||
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();
|
||||
// piCout << path << Q2PIString(item->data(cName_Cmd, Qt::DisplayRole).toString()) << getItem(ret)->buildPath();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,51 +1,52 @@
|
||||
/*
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
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 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.
|
||||
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/>.
|
||||
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 "cd_qt_export.h"
|
||||
#include "pistring.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QItemDelegate>
|
||||
#include <QStyledItemDelegate>
|
||||
#include "pistring.h"
|
||||
#include "cd_qt_export.h"
|
||||
|
||||
namespace CDUtils {
|
||||
class CDType;
|
||||
class CDSection;
|
||||
class Interface;
|
||||
class CDType;
|
||||
class CDSection;
|
||||
class Interface;
|
||||
|
||||
enum Column {
|
||||
cID ,
|
||||
cName_Cmd ,
|
||||
cType ,
|
||||
cXMode ,
|
||||
cXAvg ,
|
||||
cExpression,
|
||||
cValue ,
|
||||
cComment ,
|
||||
cLastColumn,
|
||||
};
|
||||
}
|
||||
enum Column {
|
||||
cID,
|
||||
cName_Cmd,
|
||||
cType,
|
||||
cXMode,
|
||||
cXAvg,
|
||||
cExpression,
|
||||
cValue,
|
||||
cComment,
|
||||
cLastColumn,
|
||||
};
|
||||
} // namespace CDUtils
|
||||
|
||||
namespace QAD {
|
||||
struct Enum;
|
||||
struct Enum;
|
||||
}
|
||||
|
||||
class CDItemModel;
|
||||
@@ -54,16 +55,20 @@ class CDItemModel;
|
||||
class CD_QT_EXPORT CDItem {
|
||||
friend class CDItemModel;
|
||||
friend class CDView;
|
||||
|
||||
public:
|
||||
enum CDItemType{ItemCDType, ItemCDSection};
|
||||
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_;}
|
||||
CDItemType itemType() const { return type_; }
|
||||
PIDeque<int> buildPath() const;
|
||||
int index() const {return index_;}
|
||||
int index() const { return index_; }
|
||||
|
||||
CDUtils::Interface * interface;
|
||||
bool expanded;
|
||||
@@ -79,42 +84,42 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class CD_QT_EXPORT CDDelegate : public QStyledItemDelegate
|
||||
{
|
||||
class CD_QT_EXPORT CDDelegate: public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CDDelegate(QObject *parent = 0);
|
||||
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;
|
||||
|
||||
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 CD_QT_EXPORT CDItemModel : public QAbstractItemModel {
|
||||
class CD_QT_EXPORT CDItemModel: public QAbstractItemModel {
|
||||
Q_OBJECT
|
||||
friend class CDView;
|
||||
|
||||
public:
|
||||
explicit CDItemModel(int type_, QObject *parent = 0);
|
||||
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);
|
||||
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);
|
||||
void buildItem(CDItem * it, CDUtils::CDSection & r);
|
||||
|
||||
public slots:
|
||||
void rebuildModel();
|
||||
@@ -127,7 +132,6 @@ private:
|
||||
CDItem * root;
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // QCD_MODEL_H
|
||||
|
||||
@@ -1,30 +1,32 @@
|
||||
#include "qcd_view.h"
|
||||
|
||||
#include "cdutils_c.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_m.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "pifile.h"
|
||||
#include "piqt.h"
|
||||
#include "qcd_model.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QMouseEvent>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "cdutils_c.h"
|
||||
#include "cdutils_m.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "qcd_view.h"
|
||||
#include "qcd_model.h"
|
||||
#include "piqt.h"
|
||||
#include "pifile.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
CDView::CDView(QWidget * parent) : QTreeView(parent) {
|
||||
type_ = -1;
|
||||
CDView::CDView(QWidget * parent): QTreeView(parent) {
|
||||
type_ = -1;
|
||||
model_ = 0;
|
||||
proxy_ = 0;
|
||||
connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(indexClicked(QModelIndex)));
|
||||
connect(this, SIGNAL(_qcd_sendFailed()), this, SLOT(cd_sendFailed()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_sendSucceed()), this, SLOT(cd_sendSucceed()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_receiveFailed()), this, SLOT(cd_receiveFailed()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(indexClicked(QModelIndex)));
|
||||
connect(this, SIGNAL(_qcd_sendFailed()), this, SLOT(cd_sendFailed()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_sendSucceed()), this, SLOT(cd_sendSucceed()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_receiveFailed()), this, SLOT(cd_receiveFailed()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_receiveSucceed()), this, SLOT(cd_receiveSucceed()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_receivedX()), this, SLOT(cd_receivedX()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_changedGlobal()), this, SLOT(cd_changedGlobal()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_receivedX()), this, SLOT(cd_receivedX()), Qt::QueuedConnection);
|
||||
connect(this, SIGNAL(_qcd_changedGlobal()), this, SLOT(cd_changedGlobal()), Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,46 +46,44 @@ void CDView::setType(int cdt) {
|
||||
type_ = cdt;
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK:
|
||||
CONNECTU(&K, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&K, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&K, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&K, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&K, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&K, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&K, receiveFailed, this, pi_cd_receiveFailed);
|
||||
CONNECTU(&K, changedGlobal, this, pi_cd_changedGlobal);
|
||||
break;
|
||||
case CDType::cdX:
|
||||
CONNECTU(&X, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&X, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&X, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&X, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&X, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&X, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&X, receiveFailed, this, pi_cd_receiveFailed);
|
||||
CONNECTU(&X, receivedX, this, pi_cd_receivedX);
|
||||
CONNECTU(&X, receivedX, this, pi_cd_receivedX);
|
||||
CONNECTU(&X, changedGlobal, this, pi_cd_changedGlobal);
|
||||
break;
|
||||
case CDType::cdC:
|
||||
CONNECTU(&C, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&C, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&C, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&C, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&C, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&C, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&C, receiveFailed, this, pi_cd_receiveFailed);
|
||||
CONNECTU(&C, changedGlobal, this, pi_cd_changedGlobal);
|
||||
break;
|
||||
case CDType::cdM:
|
||||
CONNECTU(&M, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&M, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&M, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&M, sended, this, pi_cd_sendSucceed);
|
||||
CONNECTU(&M, sendFailed, this, pi_cd_sendFailed);
|
||||
CONNECTU(&M, received, this, pi_cd_receiveSucceed);
|
||||
CONNECTU(&M, receiveFailed, this, pi_cd_receiveFailed);
|
||||
CONNECTU(&M, changedGlobal, this, pi_cd_changedGlobal);
|
||||
CONNECTU(&M, messageReceived, this, pi_cd_messageReceived);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CDView::mousePressEvent(QMouseEvent * e) {
|
||||
if (type_ == CDType::cdC) {
|
||||
QModelIndex i = indexAt(e->pos());
|
||||
if (i.isValid() && i.column() == cName_Cmd)
|
||||
update(i);
|
||||
if (i.isValid() && i.column() == cName_Cmd) update(i);
|
||||
}
|
||||
QTreeView::mousePressEvent(e);
|
||||
}
|
||||
@@ -92,8 +92,7 @@ void CDView::mousePressEvent(QMouseEvent * e) {
|
||||
void CDView::mouseReleaseEvent(QMouseEvent * e) {
|
||||
if (type_ == CDType::cdC) {
|
||||
QModelIndex i = indexAt(e->pos());
|
||||
if (i.isValid() && i.column() == cName_Cmd)
|
||||
update(i);
|
||||
if (i.isValid() && i.column() == cName_Cmd) update(i);
|
||||
}
|
||||
QTreeView::mouseReleaseEvent(e);
|
||||
}
|
||||
@@ -101,8 +100,7 @@ void CDView::mouseReleaseEvent(QMouseEvent * e) {
|
||||
|
||||
void CDView::currentChanged(const QModelIndex & cur, const QModelIndex & prev) {
|
||||
if (type_ == CDType::cdC) {
|
||||
if (prev.isValid() && prev.column() == cName_Cmd)
|
||||
update(prev);
|
||||
if (prev.isValid() && prev.column() == cName_Cmd) update(prev);
|
||||
}
|
||||
QTreeView::currentChanged(cur, prev);
|
||||
}
|
||||
@@ -121,30 +119,28 @@ void CDView::refresh() {
|
||||
proxy_->setSourceModel(model_);
|
||||
setModel(proxy_);
|
||||
setItemDelegateForColumn(type_ == CDType::cdC ? cName_Cmd : cValue, new CDDelegate());
|
||||
if (type_ == CDType::cdX)
|
||||
setItemDelegateForColumn(cXMode, new CDDelegate());
|
||||
if (type_ == CDType::cdX) setItemDelegateForColumn(cXMode, new CDDelegate());
|
||||
}
|
||||
model_->rebuildModel();
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK:
|
||||
setColumnHidden(cXMode, true);
|
||||
setColumnHidden(cXAvg, true);
|
||||
break;
|
||||
case CDType::cdX:
|
||||
setColumnHidden(cExpression, true);
|
||||
setColumnHidden(cXMode, true);
|
||||
setColumnHidden(cXAvg, true);
|
||||
break;
|
||||
case CDType::cdX: setColumnHidden(cExpression, true); break;
|
||||
case CDType::cdC:
|
||||
case CDType::cdM:
|
||||
setColumnHidden(cType, true);
|
||||
setColumnHidden(cXMode, true);
|
||||
setColumnHidden(cXAvg, true);
|
||||
setColumnHidden(cType, true);
|
||||
setColumnHidden(cXMode, true);
|
||||
setColumnHidden(cXAvg, true);
|
||||
setColumnHidden(cExpression, true);
|
||||
setColumnHidden(cValue, true);
|
||||
setColumnHidden(cValue, true);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
expandAll();
|
||||
for (int i = 0; i < model_->columnCount(); i++) resizeColumnToContents(i);
|
||||
for (int i = 0; i < model_->columnCount(); i++)
|
||||
resizeColumnToContents(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +251,7 @@ void CDView::load() {
|
||||
|
||||
|
||||
void CDView::clear() {
|
||||
//piCout << "clearK";
|
||||
// piCout << "clearK";
|
||||
switch ((CDType::cdT)type_) {
|
||||
case CDType::cdK: K.root() = CDSection(); break;
|
||||
case CDType::cdX: X.root() = CDSection(); break;
|
||||
@@ -310,7 +306,7 @@ void CDView::indexClicked(const QModelIndex & i) {
|
||||
CDType & t(model_->interface->section(item->buildPath())[item->index()]);
|
||||
C.sendCommand(t);
|
||||
emit commandSended(PI2QString(t.pathString().join(".")));
|
||||
//piCout << t;
|
||||
// piCout << t;
|
||||
qDebug() << PI2QString(t.pathString().join("."));
|
||||
}
|
||||
|
||||
@@ -346,16 +342,16 @@ void CDView::cd_receiveSucceed() {
|
||||
|
||||
void CDView::cd_receivedX() {
|
||||
X.lock();
|
||||
PIVector<PIDeque<int> > xl = X.enabledList();
|
||||
//piCout << "X" << xl.size();
|
||||
piForeachC (PIDeque<int> & x, xl) {
|
||||
PIVector<PIDeque<int>> xl = X.enabledList();
|
||||
// piCout << "X" << xl.size();
|
||||
piForeachC(PIDeque<int> & x, xl) {
|
||||
CDType & t(X[x]);
|
||||
//piCout << t;
|
||||
//piCout << t.path();
|
||||
// piCout << t;
|
||||
// piCout << t.path();
|
||||
if (t.cd_type() != CDType::cdX) continue;
|
||||
update(model_->indexByPath(t.path(), cValue));
|
||||
//piCout << CDCore::pathToString(t.path()) << t.toDouble() << "model";
|
||||
//qDebug() << "val" << model_->data(model_->indexByPath(t.path(), cValue), Qt::DisplayRole).toDouble();
|
||||
// piCout << CDCore::pathToString(t.path()) << t.toDouble() << "model";
|
||||
// qDebug() << "val" << model_->data(model_->indexByPath(t.path(), cValue), Qt::DisplayRole).toDouble();
|
||||
}
|
||||
X.unlock();
|
||||
emit receivedX();
|
||||
@@ -368,8 +364,10 @@ void CDView::cd_changedGlobal() {
|
||||
|
||||
|
||||
void CDView::pi_cd_messageReceived(PIDeque<int> path, int type, PIString msg) {
|
||||
QMetaObject::invokeMethod(this, "messageReceived", Qt::QueuedConnection,
|
||||
Q_ARG(QString, PI2QString(CDCore::pathToString(path))),
|
||||
Q_ARG(int, type),
|
||||
Q_ARG(QString, PI2QString(msg)));
|
||||
QMetaObject::invokeMethod(this,
|
||||
"messageReceived",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(QString, PI2QString(CDCore::pathToString(path))),
|
||||
Q_ARG(int, type),
|
||||
Q_ARG(QString, PI2QString(msg)));
|
||||
}
|
||||
|
||||
@@ -1,43 +1,46 @@
|
||||
/*
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
QCD Utils - Qt bindings/utilites for CD Utils
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
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 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.
|
||||
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/>.
|
||||
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 "cd_qt_export.h"
|
||||
#include "piobject.h"
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
namespace CDUtils {
|
||||
class CDType;
|
||||
class CDSection;
|
||||
}
|
||||
class CDType;
|
||||
class CDSection;
|
||||
} // namespace CDUtils
|
||||
|
||||
class CDItemModel;
|
||||
class QSortFilterProxyModel;
|
||||
|
||||
class CD_QT_EXPORT CDView: public QTreeView, public PIObject
|
||||
{
|
||||
class CD_QT_EXPORT CDView
|
||||
: public QTreeView
|
||||
, public PIObject {
|
||||
Q_OBJECT
|
||||
PIOBJECT(CDView);
|
||||
|
||||
public:
|
||||
explicit CDView(QWidget *parent = 0);
|
||||
explicit CDView(QWidget * parent = 0);
|
||||
~CDView();
|
||||
|
||||
void setType(int cdt);
|
||||
@@ -47,11 +50,11 @@ public:
|
||||
CDUtils::CDSection * root();
|
||||
QString typeLetter() const;
|
||||
|
||||
CDItemModel * CDModel() {return model_;}
|
||||
CDItemModel * CDModel() { return model_; }
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent * ) override;
|
||||
void mouseReleaseEvent(QMouseEvent * ) override;
|
||||
void mousePressEvent(QMouseEvent *) override;
|
||||
void mouseReleaseEvent(QMouseEvent *) override;
|
||||
void currentChanged(const QModelIndex & cur, const QModelIndex & prev) override;
|
||||
|
||||
public slots:
|
||||
@@ -77,12 +80,12 @@ private slots:
|
||||
|
||||
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_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_;
|
||||
@@ -101,13 +104,12 @@ signals:
|
||||
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_sendFailed(); // PRIVATE
|
||||
void _qcd_sendSucceed(); // PRIVATE
|
||||
void _qcd_receiveFailed(); // PRIVATE
|
||||
void _qcd_receiveSucceed(); // PRIVATE
|
||||
void _qcd_receivedX(); // PRIVATE
|
||||
void _qcd_changedGlobal(); // PRIVATE
|
||||
|
||||
void _qcd_receivedX(); // PRIVATE
|
||||
void _qcd_changedGlobal(); // PRIVATE
|
||||
};
|
||||
|
||||
#endif // QCD_VIEW_H
|
||||
|
||||
Reference in New Issue
Block a user