diff --git a/libs/qcd/CMakeLists.txt b/libs/qcd/CMakeLists.txt deleted file mode 100644 index f3e84e8..0000000 --- a/libs/qcd/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -piqt_library(qcd_utils "Gui" "pip;qad_utils;qad_widgets;qad_graphic;cd_utils;piqt") diff --git a/libs/qcd/qcd_core.cpp b/libs/qcd/qcd_core.cpp deleted file mode 100644 index 95511a8..0000000 --- a/libs/qcd/qcd_core.cpp +++ /dev/null @@ -1,297 +0,0 @@ -#include "qcd_core.h" -#include "cdutils_k.h" -#include "cdutils_core.h" -#include "piqt.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -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 > pathes = binded_widgets.values(w); - foreach (const PIDeque & 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 > pathes = binded_widgets.values(w); - foreach (const PIDeque & path, pathes) - K[path].setValue(PIString::fromNumber(v)); - finishEdit(pathes); -} - - -void QCDCore::slotDouble(double v) { - QWidget * w = (QWidget*)sender(); - if (!w || updating) return; - QList > pathes = binded_widgets.values(w); - foreach (const PIDeque & path, pathes) - K[path].setValue(PIString::fromNumber(v)); - finishEdit(pathes); -} - - -void QCDCore::slotText(QString v) { - QWidget * w = (QWidget*)sender(); - if (!w || updating) return; - QList > pathes = binded_widgets.values(w); - foreach (const PIDeque & path, pathes) - K[path].setValue(Q2PIString(v)); - finishEdit(pathes); -} - - -void QCDCore::slotVariant(QVariant v) { - QWidget * w = (QWidget*)sender(); - if (!w || updating) return; - QList > pathes = binded_widgets.values(w); - foreach (const PIDeque & 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()); -} - - -int QCDCore::bindWidgets(QList 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 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 > 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(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(w)->setChecked(k.toBool()); - if (cn == "QGroupBox") qobject_cast(w)->setChecked(k.toBool()); - if (cn == "QSpinBox") qobject_cast(w)->setValue(k.toInt()); - if (cn == "QSlider") qobject_cast(w)->setValue(k.toInt()); - if (cn == "QScrollBar") qobject_cast(w)->setValue(k.toInt()); - if (cn == "QDoubleSpinBox") qobject_cast(w)->setValue(k.toDouble()); - if (cn == "SpinSlider") qobject_cast(w)->setValue(k.toDouble()); - if (cn == "QLineEdit") qobject_cast(w)->setText(PI2QString(k.value())); - if (cn == "CLineEdit") qobject_cast(w)->setText(PI2QString(k.value())); - if (cn == "EvalSpinBox") qobject_cast(w)->setValue(k.toDouble()); - if (cn == "QVariantEdit") qobject_cast(w)->setValue(PI2QVariant(k.variantValue())); -} - - -void QCDCore::finishEdit(const QList > & pathes) { - K.calculate(); - if (direct_on) { - foreach (const PIDeque & path, pathes) - K.directChange(K[path]); - } - emit updateViewRequest(); -} - - -int QCDCore::unbindWindow(QWidget * wnd) { - if (!wnd) return 0; - return unbindWidgets(wnd->findChildren()); -} - - -int QCDCore::unbindWidgets(QList 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 > bwm = binded_widgets; - QMapIterator > it(bwm); - while (it.hasNext()) { - QWidget * w = it.next().key(); - unbindWidget(w); - } - binded_widgets.clear(); -} - - -void QCDCore::updateBindedWidget(const CDType & k_) { - QMapIterator > 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; -} diff --git a/libs/qcd/qcd_core.h b/libs/qcd/qcd_core.h deleted file mode 100644 index 64695ff..0000000 --- a/libs/qcd/qcd_core.h +++ /dev/null @@ -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 . -*/ - -#ifndef QCD_CORE_H -#define QCD_CORE_H - -#include -#include -#include -#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 wl); - bool bindWidget(QWidget * w); - bool bindWidget(QWidget * w, const CDUtils::CDType & k); - - int unbindWindow(QWidget * wnd); - int unbindWidgets(QList 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 > & pathes); - EVENT_HANDLER(void, K_ChangedGlobal); - - QMultiMap > 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 diff --git a/libs/qcd/qcd_graphic.cpp b/libs/qcd/qcd_graphic.cpp deleted file mode 100644 index c53a9ae..0000000 --- a/libs/qcd/qcd_graphic.cpp +++ /dev/null @@ -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; -} diff --git a/libs/qcd/qcd_graphic.h b/libs/qcd/qcd_graphic.h deleted file mode 100644 index 68b7fd8..0000000 --- a/libs/qcd/qcd_graphic.h +++ /dev/null @@ -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 . -*/ - -#ifndef QCD_GRAPHIC_H -#define QCD_GRAPHIC_H - -#include -#include -#include -#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 diff --git a/libs/qcd/qcd_graphic.ui b/libs/qcd/qcd_graphic.ui deleted file mode 100644 index f08198f..0000000 --- a/libs/qcd/qcd_graphic.ui +++ /dev/null @@ -1,169 +0,0 @@ - - - CDGraphicWidget - - - - 0 - 0 - 470 - 380 - - - - CD Pult - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Graphic::Autofit|Graphic::BorderInputs|Graphic::Clear|Graphic::Configure|Graphic::CursorAxis|Graphic::Fullscreen|Graphic::Legend|Graphic::OnlyExpandY|Graphic::Pause|Graphic::Save - - - false - - - false - - - 100.000000000000000 - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - History: - - - - - - - 100.000000000000000 - - - - - - - Qt::Horizontal - - - - 1 - 20 - - - - - - - - Visible: - - - - - - - -1.000000000000000 - - - - - - - Qt::Horizontal - - - - 1 - 20 - - - - - - - - - - - - Graphic - QFrame -
graphic.h
-
- - EvalSpinBox - QWidget -
evalspinbox.h
-
-
- - - - evalHistory - valueChanged(double) - graphic - setHistorySize(double) - - - 148 - 363 - - - 156 - 297 - - - - - evalVisible - valueChanged(double) - graphic - setMaxVisibleTime(double) - - - 345 - 361 - - - 342 - 337 - - - - -
diff --git a/libs/qcd/qcd_modedialog.cpp b/libs/qcd/qcd_modedialog.cpp deleted file mode 100644 index c6e2bb6..0000000 --- a/libs/qcd/qcd_modedialog.cpp +++ /dev/null @@ -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); -} diff --git a/libs/qcd/qcd_modedialog.h b/libs/qcd/qcd_modedialog.h deleted file mode 100644 index dc57713..0000000 --- a/libs/qcd/qcd_modedialog.h +++ /dev/null @@ -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 . -*/ - -#ifndef QCD_MODEDIALOG_H -#define QCD_MODEDIALOG_H - -#include -#include -#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 diff --git a/libs/qcd/qcd_modedialog.ui b/libs/qcd/qcd_modedialog.ui deleted file mode 100644 index 38c2dff..0000000 --- a/libs/qcd/qcd_modedialog.ui +++ /dev/null @@ -1,98 +0,0 @@ - - - QCDModeDialog - - - - 0 - 0 - 251 - 152 - - - - Update description mode - - - - - - Save by index - - - - - - - Save by name - - - - - - - Merge - - - - - - - Qt::Vertical - - - - 20 - 1 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - QCDModeDialog - accept() - - - 106 - 131 - - - 101 - 146 - - - - - buttonBox - rejected() - QCDModeDialog - reject() - - - 182 - 127 - - - 169 - 146 - - - - - diff --git a/libs/qcd/qcd_model.cpp b/libs/qcd/qcd_model.cpp deleted file mode 100644 index 2b1f203..0000000 --- a/libs/qcd/qcd_model.cpp +++ /dev/null @@ -1,460 +0,0 @@ -#include "qcd_model.h" -#include "cdutils_interface.h" -#include "cdutils_core.h" -#include "cdutils_x.h" -#include "piqt.h" -#include -#include -#include -#include -#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 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(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 CDItem::buildPath() const { - PIDeque 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(editor); - edit->setValue(index.model()->data(index, Qt::EditRole)); -} - - -void CDDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { - QVariantEdit *edit = static_cast(editor); - QVariant v = edit->value(); - if (v.canConvert()) { - QAD::Enum et = v.value(); - 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(index.internalPointer()); - if (item) return item; - } - return root; -} - - -QModelIndex CDItemModel::indexByPath(const PIDeque & 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; -} diff --git a/libs/qcd/qcd_model.h b/libs/qcd/qcd_model.h deleted file mode 100644 index 506f0f0..0000000 --- a/libs/qcd/qcd_model.h +++ /dev/null @@ -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 . -*/ - -#ifndef QCD_MODEL_H -#define QCD_MODEL_H - -#include -#include -#include -#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 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 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 & 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 diff --git a/libs/qcd/qcd_view.cpp b/libs/qcd/qcd_view.cpp deleted file mode 100644 index 619c46e..0000000 --- a/libs/qcd/qcd_view.cpp +++ /dev/null @@ -1,371 +0,0 @@ -#include -#include -#include -#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 > xl = X.enabledList(); - //piCout << "X" << xl.size(); - piForeachC (PIDeque & 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 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))); -} diff --git a/libs/qcd/qcd_view.h b/libs/qcd/qcd_view.h deleted file mode 100644 index ff3d68a..0000000 --- a/libs/qcd/qcd_view.h +++ /dev/null @@ -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 . -*/ - -#ifndef QCD_VIEW_H -#define QCD_VIEW_H - -#include -#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, 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 diff --git a/utils/cd_pult/CMakeLists.txt b/utils/cd_pult/CMakeLists.txt deleted file mode 100644 index 1ffaae3..0000000 --- a/utils/cd_pult/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -project(cd_pult) -if(APPLE) - set(APP_ICON "") -elseif(WIN32) - set(APP_ICON "") -else() - set(APP_ICON "") -endif() -set(APP_INFO "CD Pult") -piqt_application(${PROJECT_NAME} "Gui;Widgets" "qad_utils;qad_widgets;qad_graphic;qad_application;qcd_utils;piqt_utils") -if (Qt5_FOUND) - import_version(${PROJ_NAME}5 ${PROJECT_NAME}) - deploy_target(${PROJECT_NAME}5 DEPLOY_DIR ${CMAKE_CURRENT_BINARY_DIR} DESTINATION ${ROOT_DIR}/release) -endif() diff --git a/utils/cd_pult/cddirectk.cpp b/utils/cd_pult/cddirectk.cpp deleted file mode 100644 index ce7e756..0000000 --- a/utils/cd_pult/cddirectk.cpp +++ /dev/null @@ -1,312 +0,0 @@ -#include "cddirectk.h" -#include "ui_cddirectk_type_dialog.h" -#include "cdutils_core.h" -#include "cdutils_k.h" -#include "qcd_core.h" -#include "qcd_model.h" -#include "graphic.h" -#include "piqt.h" -#include "qvariantedit.h" -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace CDUtils; - - -KDockWidget::KDockWidget(QString title, QMainWindow * p): QDockWidget(title, p) { - da = p; - menu = new QMenu(this); - QAction * a = new QAction(QIcon(":/icons/document-edit.png"), "Rename ...", this); - connect(a, SIGNAL(triggered(bool)), this, SLOT(rename())); - dactions << a; - a = new QAction(QIcon(":/icons/edit-delete.png"), "Remove", this); - connect(a, SIGNAL(triggered(bool)), this, SIGNAL(removeRequest())); - dactions << a; - menu_k = new QMenu(this); - menu_k->setTitle(tr("Remove K")); - lay = new QFormLayout(); - lay->setContentsMargins(0, qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin), 0, 0); - lay->setLabelAlignment(Qt::AlignRight | Qt::AlignVCenter); - QWidget * w = new QWidget(); - w->setAcceptDrops(true); - w->installEventFilter(this); - w->setLayout(lay); - setWidget(w); - type_dialog = new CDDirectKTypeDialog(); -} - - -void KDockWidget::addK(const CDType & t, CDDirectKTypeDialog::TypeInfo ti) { - if (t.cd_type() != CDType::cdK) return; - PIDeque xp = t.path(); - if (k_list.contains(xp)) return; - k_list << xp; - info_list << ti; - //piCout << "add" << xp; - QWidget * ve = ti.create(); - //qDebug() << "add" << ve; - lay->addRow(PI2QString(t.pathString().join(".")) + ":", ve); - QCDCore::instance()->bindWidget(ve, t); - //ve->setValue(); -} - - -QByteArray KDockWidget::save() const { - ChunkStream cs; - cs.add(1, windowTitle()) - .add(2, getList(k_list)) - .add(3, info_list); - return cs.data(); -} - - -void KDockWidget::load(QByteArray ba) { - clear(); - if (ba.isEmpty()) return; - ChunkStream cs(ba); - PIVector > list; - QVector ilist; - while (!cs.atEnd()) { - switch (cs.read()) { - case 1: setWindowTitle(cs.getData()); break; - case 2: list = setList(cs.getData()); break; - case 3: ilist = cs.getData >(); break; - default: break; - } - } - ilist.resize(list.size()); - for (int i = 0; i < list.size_s(); ++i) { - addK(K[list[i]], ilist[i]); - } -} - - -void KDockWidget::clear() { - while (lay->rowCount() > 0) - removeRow(0); - k_list.clear(); - info_list.clear(); -} - - -void KDockWidget::changedGlobal() { - //piCout << "changedGlobal ..." << k_list.size_s() << info_list.size() << lay->count() << lay->rowCount(); - for (int i = 0; i < k_list.size_s(); ++i) { - //piCout << "update" << i << "0"; - if (!K.exists(k_list[i])) { - k_list.remove(i); - info_list.remove(i); - removeRow(i); - --i; - continue; - } - //piCout << "update" << i << "1"; - QLabel * lbl = qobject_cast(lay->itemAt(i, QFormLayout::LabelRole)->widget()); - //piCout << "update" << i << "2"; - if (lbl) lbl->setText(PI2QString(K[k_list[i]].pathString().join(".")) + ":"); - //piCout << "update" << i << "3"; - } - //piCout << "changedGlobal ok"; -} - - -bool KDockWidget::eventFilter(QObject * o, QEvent * e) { - //if (o == graphic->viewport()) { - switch (e->type()) { - case QEvent::DragMove: { - QDragMoveEvent * de = (QDragMoveEvent*)e; - const QMimeData * mime = de->mimeData(); - if (!mime) break; - if (!mime->text().startsWith("k")) break; - de->setDropAction(Qt::CopyAction); - de->accept(); - return true; - } break; - case QEvent::DragEnter: { - QDragEnterEvent * de = (QDragEnterEvent*)e; - const QMimeData * mime = de->mimeData(); - if (!mime) break; - if (!mime->text().startsWith("k")) break; - de->setDropAction(Qt::CopyAction); - de->accept(); - return true; - } break; - case QEvent::Drop: { - QDropEvent * de = (QDropEvent*)e; - const QMimeData * mime = de->mimeData(); - if (!mime) break; - //qDebug() << "drop" << mime->text(); - if (!mime->text().startsWith("k")) break; - CDDirectKTypeDialog::TypeInfo ti; - CDType & k(K[CDCore::stringToPath(Q2PIString(mime->text().mid(1)))]); - if (k.type().left(1) == "n" || k.type().left(1) == "f") { - if (type_dialog->exec() == QDialog::Accepted) - ti = type_dialog->getType(); - else - return true; - } - addK(k, ti); - de->accept(); - return true; - } break; - default: break; - } - //} - return QWidget::eventFilter(o, e); -} - - -void KDockWidget::contextMenuEvent(QContextMenuEvent * e) { - qDeleteAll(menu_k->actions()); - menu_k->clear(); - for (int i = 0; i < k_list.size_s(); ++i) { - QAction * a = new QAction(PI2QString(K[k_list[i]].pathString().join(".")), this); - a->setData(i); - connect(a, SIGNAL(triggered(bool)), this, SLOT(removeK())); - menu_k->addAction(a); - } - QMenu * mwm = da->createPopupMenu(); - menu->clear(); - menu->addActions(dactions); - menu->addMenu(menu_k); - menu->addSeparator(); - menu->addActions(mwm->actions()); - menu->popup(e->globalPos()); - mwm->deleteLater(); -} - - -void KDockWidget::removeRow(int r) { - if (r < 0 || r >= lay->rowCount()) return; -#if QT_VERSION >= 0x050800 - QFormLayout::TakeRowResult rr = lay->takeRow(r); - if (rr.fieldItem) {delete rr.fieldItem->widget(); delete rr.fieldItem;} - if (rr.labelItem) {delete rr.labelItem->widget(); delete rr.labelItem;} -#else - piForTimes (2) { - QLayoutItem * i = lay->itemAt(r+r); - lay->removeItem(i); - if (i) {delete i->widget(); delete i;} - } -#endif -} - - -void KDockWidget::rename() { - QString nn = QInputDialog::getText(this, tr("Rename area"), tr("New area name:"), - QLineEdit::Normal, windowTitle()); - if (nn.isEmpty()) return; - setWindowTitle(nn); -} - - -void KDockWidget::removeK() { - QAction * a = qobject_cast(sender()); - if (!a) return; - int ind = a->data().toInt(); - if (ind < 0 || ind >= k_list.size_s()) return; - k_list.remove(ind); - if (ind >= 0 && ind < info_list.size()) - info_list.remove(ind); - removeRow(ind); -} - - - - -CDDirectK::CDDirectK(QWidget * parent) : QWidget(parent), Ui::CDDirectK() { - setupUi(this); - da = new QMainWindow(); - da->setWindowFlags(frame->windowFlags()); - da->setDockNestingEnabled(true); - layoutMain->addWidget(da); -} - - -CDDirectK::~CDDirectK() { -} - - -void CDDirectK::reset() { - qDeleteAll(docks); - docks.clear(); -} - - -QByteArray CDDirectK::save() const { - ChunkStream cs; - QVector dstates; - foreach (KDockWidget * d, docks) { - dstates << d->save(); - } - cs.add(1, docks.size()) - .add(2, dstates) - .add(3, da->saveState()); - return cs.data(); -} - - -void CDDirectK::load(QByteArray ba) { - reset(); - if (ba.isEmpty()) return; - ChunkStream cs(ba); - while (!cs.atEnd()) { - switch (cs.read()) { - case 1: { - int s = cs.getData(); - piForTimes (s) - addArea(); - } break; - case 2: { - QVector dstates = cs.getData >(); - for (int i = 0; i < piMini(dstates.size(), docks.size()); ++i) - docks[i]->load(dstates[i]); - } break; - case 3: da->restoreState(cs.getData()); break; - default: break; - } - } -} - - -void CDDirectK::addArea() { - KDockWidget * dw = new KDockWidget(QString("area %1").arg(docks.size()), da); - connect(dw, SIGNAL(removeRequest()), this, SLOT(removeArea())); - da->addDockWidget(Qt::RightDockWidgetArea, dw); - docks << dw; - for (int i = 0; i < docks.size(); ++i) - docks[i]->setObjectName(QString("dock_%1").arg(i)); -} - - -void CDDirectK::changedGlobal() { - foreach (KDockWidget * d, docks) - d->changedGlobal(); -} - - -void CDDirectK::removeArea() { - KDockWidget * d = qobject_cast(sender()); - if (!d) return; - docks.removeAll(d); - d->deleteLater(); - for (int i = 0; i < docks.size(); ++i) - docks[i]->setObjectName(QString("dock_%1").arg(i)); -} - - -void CDDirectK::on_buttonAdd_clicked() { - addArea(); -} - - -void CDDirectK::on_buttonRemoveAll_clicked() { - qDeleteAll(docks); - docks.clear(); -} diff --git a/utils/cd_pult/cddirectk.h b/utils/cd_pult/cddirectk.h deleted file mode 100644 index 47ade06..0000000 --- a/utils/cd_pult/cddirectk.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef CDDIRECTK_H -#define CDDIRECTK_H - -#include "cdgraphics.h" -#include "ui_cddirectk.h" -#include "cddirectk_type_dialog.h" - -class QFormLayout; - - -class KDockWidget: public QDockWidget { - Q_OBJECT -public: - KDockWidget(QString title = QString(), QMainWindow * p = 0); - - void addK(const CDUtils::CDType & t, CDDirectKTypeDialog::TypeInfo ti); - QByteArray save() const; - void load(QByteArray ba); - void clear(); - void changedGlobal(); - - QFormLayout * lay; - -private: - bool eventFilter(QObject * o, QEvent * e); - void contextMenuEvent(QContextMenuEvent * e); - void removeRow(int r); - - QMenu * menu, * menu_k; - QList dactions; - QMainWindow * da; - CDDirectKTypeDialog * type_dialog; - PIVector > k_list; - QVector info_list; - -private slots: - void rename(); - void removeK(); - -signals: - void removeRequest(); - -}; - - - - -class CDDirectK: public QWidget, public Ui::CDDirectK -{ - Q_OBJECT -public: - explicit CDDirectK(QWidget *parent = 0); - ~CDDirectK(); - - void reset(); - QByteArray save() const; - void load(QByteArray ba); - -private: - void addArea(); - - QList docks; - QMainWindow * da; - -public slots: - void changedGlobal(); - -private slots: - void removeArea(); - void on_buttonAdd_clicked(); - void on_buttonRemoveAll_clicked(); - -signals: - -}; - -#endif // CDDIRECTK_H diff --git a/utils/cd_pult/cddirectk.ui b/utils/cd_pult/cddirectk.ui deleted file mode 100644 index 731498b..0000000 --- a/utils/cd_pult/cddirectk.ui +++ /dev/null @@ -1,85 +0,0 @@ - - - CDDirectK - - - - 0 - 0 - 624 - 411 - - - - CD Pult - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - - - Add new - - - - :/icons/list-add.png:/icons/list-add.png - - - - - - - Remove all - - - - :/icons/edit-delete.png:/icons/edit-delete.png - - - - - - - Qt::Horizontal - - - - 1 - 20 - - - - - - - - - - - - - - diff --git a/utils/cd_pult/cddirectk_type_dialog.cpp b/utils/cd_pult/cddirectk_type_dialog.cpp deleted file mode 100644 index c6be2fa..0000000 --- a/utils/cd_pult/cddirectk_type_dialog.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "cddirectk_type_dialog.h" -#include "cdutils_core.h" -#include "qcd_core.h" -#include "qcd_model.h" -#include "piqt.h" -#include "spinslider.h" -#include "qvariantedit.h" - - -CDDirectKTypeDialog::CDDirectKTypeDialog(QWidget * parent) : QDialog(parent), Ui::CDDirectKTypeDialog() { - setupUi(this); -} - - -CDDirectKTypeDialog::~CDDirectKTypeDialog() { -} - - -CDDirectKTypeDialog::TypeInfo CDDirectKTypeDialog::getType() const { - if (!groupBox->isChecked()) return TypeInfo(); - TypeInfo ret; - ret.type = comboType->currentIndex(); - ret.params_d[0] = evalMin->value(); - ret.params_d[1] = evalMax->value(); - ret.params_d[2] = spinDecimals->value(); - ret.params_d[3] = evalStep->value(); - ret.params_s[0] = linePrefix->text(); - ret.params_s[1] = lineSuffix->text(); - return ret; -} - - - - -CDDirectKTypeDialog::TypeInfo::TypeInfo(int type_) { - type = type_; - params_d.resize(4); - params_s.resize(2); -} - - -QWidget * CDDirectKTypeDialog::TypeInfo::create() { - params_d.resize(4); - params_s.resize(2); - switch (type) { - case 0: { - QDoubleSpinBox * ret = new QDoubleSpinBox(); - ret->setMinimum(params_d[0]); - ret->setMaximum(params_d[1]); - ret->setDecimals(params_d[2]); - ret->setSingleStep(params_d[3]); - ret->setPrefix(params_s[0]); - ret->setSuffix(params_s[1]); - return ret; - } break; - case 1: { - QSlider * ret = new QSlider(Qt::Horizontal); - ret->setMinimum(params_d[0]); - ret->setMaximum(params_d[1]); - ret->setSingleStep(params_d[3]); - return ret; - } break; - case 2: { - SpinSlider * ret = new SpinSlider(); - ret->setMinimum(params_d[0]); - ret->setMaximum(params_d[1]); - ret->setDecimals(params_d[2]); - ret->setSingleStep(params_d[3]); - ret->setPrefix(params_s[0]); - ret->setSuffix(params_s[1]); - return ret; - } break; - default: break; - } - return new QVariantEdit(); -} diff --git a/utils/cd_pult/cddirectk_type_dialog.h b/utils/cd_pult/cddirectk_type_dialog.h deleted file mode 100644 index 9881864..0000000 --- a/utils/cd_pult/cddirectk_type_dialog.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef CDDIRECTK_TYPE_DIALOG_H -#define CDDIRECTK_TYPE_DIALOG_H - -#include -#include "ui_cddirectk_type_dialog.h" - - -class CDDirectKTypeDialog: public QDialog, public Ui::CDDirectKTypeDialog -{ - Q_OBJECT -public: - explicit CDDirectKTypeDialog(QWidget * parent = 0); - ~CDDirectKTypeDialog(); - - struct TypeInfo { - TypeInfo(int type_ = -1); - QWidget * create(); - int type; - QVector params_d; - QVector params_s; - }; - - TypeInfo getType() const; - -private: - -public slots: - -private slots: - -signals: - -}; - -inline QDataStream & operator <<(QDataStream & s, const CDDirectKTypeDialog::TypeInfo & v) { - s << v.type << v.params_d << v.params_s; - return s; -} -inline QDataStream & operator >>(QDataStream & s, CDDirectKTypeDialog::TypeInfo & v) { - s >> v.type >> v.params_d >> v.params_s; - return s; -} - -#endif // CDDIRECTK_TYPE_DIALOG_H diff --git a/utils/cd_pult/cddirectk_type_dialog.ui b/utils/cd_pult/cddirectk_type_dialog.ui deleted file mode 100644 index 0b5ec15..0000000 --- a/utils/cd_pult/cddirectk_type_dialog.ui +++ /dev/null @@ -1,232 +0,0 @@ - - - CDDirectKTypeDialog - - - - 0 - 0 - 275 - 310 - - - - CD Pult - - - - - - Custom - - - true - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Type: - - - - - - - - Spin - - - - - Slider - - - - - SpinSlider - - - - - - - - Min: - - - - - - - - - - Max: - - - - - - - 100.000000000000000 - - - - - - - Decimals: - - - - - - - - - - Single step: - - - - - - - 1.000000000000000 - - - - - - - Prefix: - - - - - - - - - - Suffix: - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 1 - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - CLineEdit - QLineEdit -
clineedit.h
-
- - EvalSpinBox - QWidget -
evalspinbox.h
-
-
- - - - groupBox - toggled(bool) - widget - setEnabled(bool) - - - 86 - 49 - - - 94 - 91 - - - - - buttonBox - accepted() - CDDirectKTypeDialog - accept() - - - 297 - 285 - - - 315 - 280 - - - - - buttonBox - rejected() - CDDirectKTypeDialog - reject() - - - 281 - 290 - - - 283 - 307 - - - - -
diff --git a/utils/cd_pult/cdgraphics.cpp b/utils/cd_pult/cdgraphics.cpp deleted file mode 100644 index b067683..0000000 --- a/utils/cd_pult/cdgraphics.cpp +++ /dev/null @@ -1,354 +0,0 @@ -#include "cdgraphics.h" -//#include "ui_qcd_graphic.h" -#include "cdutils_core.h" -#include "cdutils_x.h" -#include "qcd_core.h" -#include "qcd_model.h" -#include "qcd_graphic.h" -#include "graphic.h" -#include "piqt.h" -#include -#include -#include -#include -#include -#include -#include - -using namespace CDUtils; - - -QStringList CDUtils::getList(const PIVector > & x_list) { - QStringList ret; - piForeachC (PIDeque & p, x_list) - ret << PI2QString(CDCore::pathToString(p)); - return ret; -} - - -PIVector > CDUtils::setList(const QStringList & l) { - PIVector > ret; - foreach (QString s, l) - ret << CDCore::stringToPath(Q2PIString(s)); - return ret; -} - - - - -GDockWidget::GDockWidget(QString title, QMainWindow * p): QDockWidget(title, p) { - da = p; - menu = new QMenu(this); - QAction * a = new QAction(QIcon(":/icons/document-edit.png"), "Rename ...", this); - connect(a, SIGNAL(triggered(bool)), this, SLOT(rename())); - dactions << a; - a = new QAction(QIcon(":/icons/edit-delete.png"), "Remove", this); - connect(a, SIGNAL(triggered(bool)), this, SIGNAL(removeRequest())); - dactions << a; - menu_x = new QMenu(this); - menu_x->setTitle(tr("Remove X")); - graphic = new CDGraphicWidget(); - graphic->graphic()->viewport()->setAcceptDrops(true); - graphic->graphic()->viewport()->installEventFilter(this); - setWidget(graphic); -} - - -void GDockWidget::addX(const CDType & t) { - if (t.cd_type() != CDType::cdX) return; - PIDeque xp = t.path(); - if (x_list.contains(xp)) return; - x_list << xp; - int gind = graphic->graphic()->graphicsCount(); - graphic->graphic()->setGraphicsCount(gind + 1); - graphic->graphic()->setGraphicName(PI2QString(t.pathString().join(".")), gind); -} - - -void GDockWidget::drawX(const PIMap > & data) { - for (int i = 0; i < x_list.size_s(); ++i) { - PIString sp = CDCore::pathToString(x_list[i]); - const PIVector & ch(data[sp]); - for (int j = 0; j < ch.size_s(); ++j) - graphic->graphic()->addPoint(ch[j], i, false); - } - graphic->graphic()->updateGraphics(); -} - - -QByteArray GDockWidget::save() const { - ChunkStream cs; - cs.add(1, windowTitle()) - .add(2, getList(x_list)) - .add(3, graphic->graphic()->save()) - .add(4, graphic->evalSpinBoxHistory()->expression()) - .add(5, graphic->evalSpinBoxVisible()->expression()); - return cs.data(); -} - - -void GDockWidget::load(QByteArray ba) { - if (ba.isEmpty()) return; - ChunkStream cs(ba); - while (!cs.atEnd()) { - switch (cs.read()) { - case 1: setWindowTitle(cs.getData()); break; - case 2: x_list = setList(cs.getData()); break; - case 3: graphic->graphic()->load(cs.getData()); break; - case 4: graphic->evalSpinBoxHistory()->setExpression(cs.getData()); break; - case 5: graphic->evalSpinBoxVisible()->setExpression(cs.getData()); break; - default: break; - } - } -} - - -void GDockWidget::changedGlobal() { - for (int i = 0; i < x_list.size_s(); ++i) { - if (!X.exists(x_list[i])) { - x_list.remove(i); - graphic->graphic()->removeGraphic(i); - --i; - continue; - } - graphic->graphic()->setGraphicName(PI2QString(X[x_list[i]].pathString().join(".")), i); - } -} - - -bool GDockWidget::eventFilter(QObject * o, QEvent * e) { - //if (o == graphic->viewport()) { - switch (e->type()) { - case QEvent::DragMove: { - QDragMoveEvent * de = (QDragMoveEvent*)e; - const QMimeData * mime = de->mimeData(); - //qDebug() << "enter" << mime; - if (!mime) break; - if (!mime->text().startsWith("x")) break; - de->setDropAction(Qt::CopyAction); - de->accept(); - return true; - } break; - case QEvent::DragEnter: { - QDragEnterEvent * de = (QDragEnterEvent*)e; - const QMimeData * mime = de->mimeData(); - //qDebug() << "enter" << mime; - if (!mime) break; - if (!mime->text().startsWith("x")) break; - de->setDropAction(Qt::CopyAction); - de->accept(); - return true; - } break; - case QEvent::Drop: { - QDropEvent * de = (QDropEvent*)e; - const QMimeData * mime = de->mimeData(); - if (!mime) break; - //qDebug() << "drop" << mime->text(); - if (!mime->text().startsWith("x")) break; - addX(X[CDCore::stringToPath(Q2PIString(mime->text().mid(1)))]); - de->accept(); - return true; - } break; - default: break; - } - //} - return QWidget::eventFilter(o, e); -} - - -void GDockWidget::contextMenuEvent(QContextMenuEvent * e) { - if (graphic->graphic()->underMouse()) return; - qDeleteAll(menu_x->actions()); - menu_x->clear(); - for (int i = 0; i < graphic->graphic()->graphicsCount(); ++i) { - QPixmap icon(da->iconSize()); - icon.fill(graphic->graphic()->graphic(i).pen.color()); - QAction * a = new QAction(QIcon(icon), graphic->graphic()->graphic(i).name, this); - a->setData(i); - connect(a, SIGNAL(triggered(bool)), this, SLOT(removeX())); - menu_x->addAction(a); - } - QMenu * mwm = da->createPopupMenu(); - menu->clear(); - menu->addActions(dactions); - menu->addMenu(menu_x); - menu->addSeparator(); - menu->addActions(mwm->actions()); - menu->popup(e->globalPos()); - mwm->deleteLater(); -} - - -CDGraphicWidget * GDockWidget::viewportGraphic(QObject * o) const { - if (!o) return 0; - while (!qobject_cast(o) && o) - o = o->parent(); - return qobject_cast(o); -} - - -void GDockWidget::rename() { - QString nn = QInputDialog::getText(this, tr("Rename area"), tr("New area name:"), - QLineEdit::Normal, windowTitle()); - if (nn.isEmpty()) return; - setWindowTitle(nn); -} - - -void GDockWidget::removeX() { - QAction * a = qobject_cast(sender()); - if (!a) return; - int ind = a->data().toInt(); - if (ind < 0 || ind >= x_list.size_s()) return; - x_list.remove(ind); - graphic->graphic()->removeGraphic(ind); -} - - - - -CDGraphics::CDGraphics(QWidget * parent) : QWidget(parent), Ui::CDGraphics() { - setupUi(this); - da = new QMainWindow(); - da->setWindowFlags(frame->windowFlags()); - da->setDockNestingEnabled(true); - layoutMain->addWidget(da); -} - - -CDGraphics::~CDGraphics() { -} - - -void CDGraphics::reset() { - qDeleteAll(docks); - docks.clear(); -} - - -QByteArray CDGraphics::save() const { - ChunkStream cs; - QVector dstates; - foreach (GDockWidget * d, docks) { - dstates << d->save(); - } - cs.add(1, docks.size()) - .add(2, dstates) - .add(3, da->saveState()); - X.lock(); - cs.add(4, getList(X.enabledList())); - X.unlock(); - cs.add(5, buttonConfigVisible->isChecked()); - return cs.data(); -} - - -void CDGraphics::load(QByteArray ba) { - reset(); - if (ba.isEmpty()) return; - ChunkStream cs(ba); - while (!cs.atEnd()) { - switch (cs.read()) { - case 1: { - int s = cs.getData(); - piForTimes (s) - addGraphic(); - } break; - case 2: { - QVector dstates = cs.getData >(); - for (int i = 0; i < piMini(dstates.size(), docks.size()); ++i) - docks[i]->load(dstates[i]); - } break; - case 3: da->restoreState(cs.getData()); break; - case 4: - X.lock(); - X.setEnabledList(setList(cs.getData())); - X.unlock(); - break; - case 5: - buttonConfigVisible->setChecked(cs.getData()); - break; - default: break; - } - } -} - - -GDockWidget * CDGraphics::graphicDock(Graphic * o) const { - if (!o) return 0; - foreach (GDockWidget * d, docks) - if (d->widget() == o) - return d; - return 0; -} - - -void CDGraphics::addGraphic() { - GDockWidget * dw = new GDockWidget(QString("area %1").arg(docks.size()), da); - connect(dw, SIGNAL(removeRequest()), this, SLOT(removeGraphic())); - connect(buttonConfigVisible, SIGNAL(toggled(bool)), dw->graphic, SLOT(setConfigVisible(bool))); - connect(buttonLegendVisible, SIGNAL(clicked(bool)), dw->graphic->graphic(), SLOT(setLegendVisible(bool))); - connect(buttonBorderInputsVisible, SIGNAL(clicked(bool)), dw->graphic->graphic(), SLOT(setBorderInputsVisible(bool))); - connect(buttonPause, SIGNAL(clicked(bool)), dw->graphic->graphic(), SLOT(setPaused(bool))); - dw->graphic->setConfigVisible(buttonConfigVisible->isChecked()); - dw->graphic->graphic()->setLegendVisible(buttonLegendVisible->isChecked()); - dw->graphic->graphic()->setBorderInputsVisible(buttonBorderInputsVisible->isChecked()); - da->addDockWidget(Qt::RightDockWidgetArea, dw); - docks << dw; - for (int i = 0; i < docks.size(); ++i) - docks[i]->setObjectName(QString("dock_%1").arg(i)); -} - - -void CDGraphics::receivedX() { - PIMap > data; - X.lock(); - PIVector > x_list = X.enabledList(); - PIVector ch; - piForeachC (PIDeque & p, x_list) { - CDType & t(X[p]); - if (t.xmode_rec() == CDType::X_Current) - ch.resize(1).fill(t.toDouble()); - else - ch = t.history; - t.history.clear(); - data[CDCore::pathToString(t.path())] = ch; - } - //piCout << data; - X.unlock(); - foreach (GDockWidget * d, docks) - d->drawX(data); -} - - -void CDGraphics::changedGlobal() { - foreach (GDockWidget * d, docks) - d->changedGlobal(); -} - - -void CDGraphics::removeGraphic() { - GDockWidget * d = qobject_cast(sender()); - if (!d) return; - docks.removeAll(d); - d->deleteLater(); - for (int i = 0; i < docks.size(); ++i) - docks[i]->setObjectName(QString("dock_%1").arg(i)); -} - - -void CDGraphics::on_buttonAdd_clicked() { - addGraphic(); -} - - -void CDGraphics::on_buttonClear_clicked() { - foreach (GDockWidget * d, docks) - d->graphic->graphic()->clear(); -} - - -void CDGraphics::on_buttonRemoveAll_clicked() { - qDeleteAll(docks); - docks.clear(); -} diff --git a/utils/cd_pult/cdgraphics.h b/utils/cd_pult/cdgraphics.h deleted file mode 100644 index 51e3483..0000000 --- a/utils/cd_pult/cdgraphics.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef CDGRAPHICS_H -#define CDGRAPHICS_H - -#include -#include -#include -#include "ui_cdgraphics.h" -#include "qcd_graphic.h" -#include - -namespace CDUtils { - class CDType; - class CDSection; - QStringList getList(const PIVector > & x_list); - PIVector > setList(const QStringList & l); -} - -class QMainWindow; -class Graphic; - - - - -class GDockWidget: public QDockWidget { - Q_OBJECT -public: - GDockWidget(QString title = QString(), QMainWindow * p = 0); - - void addX(const CDUtils::CDType & t); - void drawX(const PIMap > & data); - QByteArray save() const; - void load(QByteArray ba); - void changedGlobal(); - - CDGraphicWidget * graphic; - -private: - bool eventFilter(QObject * o, QEvent * e); - void contextMenuEvent(QContextMenuEvent * e); - CDGraphicWidget * viewportGraphic(QObject * o) const; - - QMenu * menu, * menu_x; - QList dactions; - QMainWindow * da; - PIVector > x_list; - -private slots: - void rename(); - void removeX(); - -signals: - void removeRequest(); - -}; - - - - -class CDGraphics : public QWidget, public Ui::CDGraphics -{ - Q_OBJECT -public: - explicit CDGraphics(QWidget *parent = 0); - ~CDGraphics(); - - void reset(); - QByteArray save() const; - void load(QByteArray ba); - -private: - GDockWidget * graphicDock(Graphic * o) const; - void addXToGraphic(const QString & xp, Graphic * g); - void addGraphic(); - - QList docks; - QMainWindow * da; - -public slots: - void receivedX(); - void changedGlobal(); - -private slots: - void removeGraphic(); - void on_buttonAdd_clicked(); - void on_buttonClear_clicked(); - void on_buttonRemoveAll_clicked(); - -signals: - -}; - -#endif // CDGRAPHICS_H diff --git a/utils/cd_pult/cdgraphics.ui b/utils/cd_pult/cdgraphics.ui deleted file mode 100644 index 6a40b06..0000000 --- a/utils/cd_pult/cdgraphics.ui +++ /dev/null @@ -1,168 +0,0 @@ - - - CDGraphics - - - - 0 - 0 - 624 - 411 - - - - CD Pult - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::StyledPanel - - - - 0 - - - 0 - - - - - Add new - - - - :/icons/list-add.png:/icons/list-add.png - - - - - - - Clear all - - - - :/icons/edit-clear.png:/icons/edit-clear.png - - - - - - - Remove all - - - - :/icons/edit-delete.png:/icons/edit-delete.png - - - - - - - Remove all - - - - :/icons/layer-visible-off.png - :/icons/layer-visible-on.png:/icons/layer-visible-off.png - - - true - - - true - - - - - - - Remove all - - - - :/icons/legend.png:/icons/legend.png - - - true - - - true - - - - - - - Remove all - - - - :/icons/media-playback-pause.png:/icons/media-playback-pause.png - - - true - - - false - - - - - - - Remove all - - - - :/icons/border-line.png:/icons/border-line.png - - - true - - - false - - - - - - - Qt::Horizontal - - - - 1 - 20 - - - - - - - - - - - - - - - - - diff --git a/utils/cd_pult/cdpult.qrc b/utils/cd_pult/cdpult.qrc deleted file mode 100644 index 08a59ac..0000000 --- a/utils/cd_pult/cdpult.qrc +++ /dev/null @@ -1,16 +0,0 @@ - - - ../../../qad/icons/dialog-information.png - ../../../qad/icons/dialog-cancel.png - ../../../qad/icons/dialog-ok-apply.png - ../../../qad/icons/document-revert.png - ../../../qad/icons/view-refresh.png - ../../../qad/icons/format-stroke-color.png - icons/db-export.png - icons/db-import.png - icons/timer.png - icons/flame.png - icons/Apps-accessories-calculator-icon.png - icons/accessories-text-editor.png - - diff --git a/utils/cd_pult/cdpultwindow.cpp b/utils/cd_pult/cdpultwindow.cpp deleted file mode 100644 index c388c5a..0000000 --- a/utils/cd_pult/cdpultwindow.cpp +++ /dev/null @@ -1,292 +0,0 @@ -#include "edockwidget.h" -#include "cdpultwindow.h" -#include "cdutils_core.h" -#include "cdutils_k.h" -#include "cdutils_x.h" -#include "cdutils_m.h" -#include "qcd_core.h" -#include "qcd_view.h" -#include "qcd_model.h" -#include "qcd_modedialog.h" -#include "chunkstream.h" -#include "qvariantedit.h" -#include "piqt.h" -#include "piqt_highlighter.h" -#include "qcodeedit.h" -#include -#include -#include -#include - -using namespace CDUtils; - - -CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), Ui::CDPultWindow() { - setupUi(this); - centralWidget()->hide(); - setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); - CDCore::instance()->initPult(); - def_config = codeConfig->text(); - checkDefaultConfig->setChecked(true); - new ConfigHighlighter(codeConfig->document()); - widgetK->setType(CDUtils::CDType::cdK); - widgetX->setType(CDUtils::CDType::cdX); - widgetC->setType(CDUtils::CDType::cdC); - widgetM->setType(CDUtils::CDType::cdM); - editFileK->setValue(QVariant::fromValue(QAD::File("", "*.dat"))); - editFileX->setValue(QVariant::fromValue(QAD::File("", "*.dat"))); - editFileC->setValue(QVariant::fromValue(QAD::File("", "*.dat"))); - editFileM->setValue(QVariant::fromValue(QAD::File("", "*.dat"))); - log_icons[CDViewWidget::OKIcon] = QIcon(":/icons/dialog-ok-apply.png"); - log_icons[CDViewWidget::FailIcon] = QIcon(":/icons/dialog-cancel.png"); - log_icons[CDViewWidget::WaitIcon] = QIcon(":/icons/timer.png"); - setRecentMenu(menuOpen_recent); - ribbon = new Ribbon(this); - session.setFile("session_cdpult.conf"); - session.addEntry(this); - session.addEntry(ribbon->tabWidget()); - session.load(); - reset(); - connect(widgetK, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString))); - connect(widgetX, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString))); - connect(widgetC, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString))); - connect(widgetM, SIGNAL(addToLog(CDViewWidget::LogIcon,QString)), this, SLOT(addToLog(CDViewWidget::LogIcon,QString))); - connect(widgetK->view, SIGNAL(changedGlobal()), widgetDirectK, SLOT(changedGlobal())); - connect(widgetX->view, SIGNAL(changedGlobal()), widgetGraphics, SLOT(changedGlobal())); - connect(widgetX->view, SIGNAL(receivedX()), widgetGraphics, SLOT(receivedX())); - connect(widgetM->view, SIGNAL(messageReceived(QString,int,QString)), this, SLOT(messageReceived(QString,int,QString))); - QCDCore::instance()->bindWidget(widgetK->view); - QCDCore::instance()->setDirectKEnabled(true); - X.start(); - if (windowState() == Qt::WindowMinimized) - setWindowState(Qt::WindowNoState); -} - - -CDPultWindow::~CDPultWindow() { -} - - -void CDPultWindow::loadFile(const QString & fp) { - load(fp); -} - - -void CDPultWindow::apply(bool sessions) { - CDCore::instance()->stop(); - widgetK->setFile(editFileK->value().value().file); - widgetX->setFile(editFileX->value().value().file); - widgetC->setFile(editFileC->value().value().file); - widgetM->setFile(editFileM->value().value().file); - if (checkDefaultConfig->isChecked()) - CDCore::instance()->initPult(); - else - CDCore::instance()->init(Q2PIString(codeConfig->text()), true); - widgetX->view->startX(); - if (sessions) { - widgetGraphics->load(session_gr); - widgetDirectK->load(session_dk); - if (!session_mw.isEmpty()) - restoreState(session_mw); - X.lock(); - PIVector > x_list = X.enabledList(); - X.unlock(); - piForeachC (PIDeque & p, x_list) - X.enable(X[p]); - ((CDItemModel*)widgetX->view->model())->updateModel(); - widgetX->view->expandAll(); - } - dockCDKView->setVisible(checkHasK->isChecked()); - dockCDXView->setVisible(checkHasX->isChecked()); - dockCDCView->setVisible(checkHasC->isChecked()); - dockCDMView->setVisible(checkHasM->isChecked()); - QMetaObject::invokeMethod(this, "changedDock", Qt::QueuedConnection); -} - - -void CDPultWindow::closeEvent(QCloseEvent *e) { - EMainWindow::closeEvent(e); - if (!e->isAccepted()) - return; - QApplication::closeAllWindows(); - session.save(); - session.setFile(QString()); -} - - -void CDPultWindow::reset(bool full) { - setWindowTitle(QString("CD Pult")); - widgetK->reset(); - setChanged(false); -} - - -bool CDPultWindow::load(const QString & path) { - qApp->setOverrideCursor(Qt::WaitCursor); - QPIConfig conf(path, QIODevice::ReadOnly); - QAD::File f = editFileK->value().value(); - checkSyncFiles->setChecked(false); - editFileK->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_k").toString(), f.filter))); - editFileX->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_x").toString(), f.filter))); - editFileC->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_c").toString(), f.filter))); - editFileM->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_m").toString(), f.filter))); - checkSyncFiles->setChecked(conf.getValue("sync_files").toBool()); - lineSessionName->setText(conf.getValue("session_name").toString()); - last_icon = conf.getValue("icon_path").toString(); - setAppIcon(conf.getValue("icon").toByteArray()); - checkHasK->setChecked(conf.getValue("has_k").toBool()); - checkHasX->setChecked(conf.getValue("has_x").toBool()); - checkHasC->setChecked(conf.getValue("has_c").toBool()); - checkHasM->setChecked(conf.getValue("has_m").toBool()); - checkDefaultConfig->setChecked(conf.getValue("default_config").toBool()); - codeConfig->setText(QByteArray2QString(conf.getValue("config").toByteArray())); - if (codeConfig->text().isEmpty()) - codeConfig->setText(def_config); - session_gr = conf.getValue("session_gr").toByteArray(); - session_dk = conf.getValue("session_dk").toByteArray(); - session_mw = conf.getValue("session_mw").toByteArray(); - setChanged(false); - file_name = path; - apply(true); - qApp->restoreOverrideCursor(); - return true; -} - - -bool CDPultWindow::save(const QString & path) { - session_gr = widgetGraphics->save(); - session_dk = widgetDirectK->save(); - session_mw = saveState(); - QPIConfig conf(path, QIODevice::ReadWrite); - conf.clear(); - conf.setValue("file_k", editFileK->value().value().file); - conf.setValue("file_x", editFileX->value().value().file); - conf.setValue("file_c", editFileC->value().value().file); - conf.setValue("file_m", editFileM->value().value().file); - conf.setValue("sync_files", checkSyncFiles->isChecked()); - conf.setValue("session_name", lineSessionName->text()); - conf.setValue("icon_path", last_icon); - conf.setValue("icon", appIcon()); - conf.setValue("has_k", checkHasK->isChecked()); - conf.setValue("has_x", checkHasX->isChecked()); - conf.setValue("has_c", checkHasC->isChecked()); - conf.setValue("has_m", checkHasM->isChecked()); - conf.setValue("default_config", checkDefaultConfig->isChecked()); - conf.setValue("config", QString2QByteArray(codeConfig->text())); - conf.setValue("session_gr", session_gr); - conf.setValue("session_dk", session_dk); - conf.setValue("session_mw", session_mw); - file_name = path; - return true; - - //widgetK->setFile(path); - //widgetK->save(); -} - - -void CDPultWindow::loadingSession(QPIConfig & conf) { - setRecentFiles(conf.getValue("recent files").toStringList()); -} - - -void CDPultWindow::savingSession(QPIConfig & conf) { - conf.setValue("recent files", recentFiles()); -} - - -QByteArray CDPultWindow::appIcon() const { - QByteArray ret; - if (icon.isNull()) return ret; - QBuffer buff(&ret); - buff.open(QIODevice::WriteOnly); - icon.save(&buff, "png"); - //qDebug() << "s" << ret.size(); - return ret; -} - - -void CDPultWindow::setAppIcon(QByteArray ba) { - if (ba.isEmpty()) { - icon = QImage(); - setWindowIcon(QIcon()); - return; - } - //qDebug() << "l" << ba.size(); - icon = QImage::fromData(ba); - setWindowIcon(QIcon(QPixmap::fromImage(icon))); - //qDebug() << QApplication::windowIcon().availableSizes(); -} - - -void CDPultWindow::addToLog(CDViewWidget::LogIcon icon, const QString & msg) { - QListWidgetItem * ni = new QListWidgetItem(log_icons[icon], "(" + QTime::currentTime().toString() + ") " + msg); - bool s = listLog->verticalScrollBar()->value() == listLog->verticalScrollBar()->maximum(); - listLog->addItem(ni); - if (s) listLog->scrollToBottom(); -} - - -void CDPultWindow::messageReceived(QString path, int type, QString msg) { - MessageType mt = (MessageType)type; - const CDType & t(M.root()[CDCore::stringToPath(Q2PIString(path))]); - if (t.cd_type() != CDType::cdM) return; - if (mt == MessageBox) - QMessageBox::information(this, windowTitle(), QString("[%1]\n%2").arg(PI2QString(t.name()), msg)); -} - - -void CDPultWindow::on_editFileK_valueChanged(const QVariant & p) { - if (!checkSyncFiles->isChecked()) return; - QFileInfo fi(p.value().file); - if (fi.path().isEmpty()) return; - QString n = fi.baseName(); - QString xn(n), cn(n), mn(n); - if (n.contains("k")) { - xn.replace(n.indexOf("k"), 1, "x"); - cn.replace(n.indexOf("k"), 1, "c"); - mn.replace(n.indexOf("k"), 1, "m"); - } else { - xn += "_x"; - cn += "_c"; - mn += "_m"; - } - QString ext = fi.suffix(), dot, dir; - QString kfn(fi.filePath()); - if (!ext.isEmpty()) { - kfn.chop(ext.size()); - if (kfn.endsWith(".")) { - kfn.chop(1); - dot = "."; - } - } - if (!fi.path().isEmpty() && fi.path() != ".") { - dir = fi.path(); - if (!dir.endsWith("/")) - dir += "/"; - } - QAD::File f = editFileK->value().value(); - f.file = dir + xn + dot + ext; editFileX->setValue(QVariant::fromValue(f)); - f.file = dir + cn + dot + ext; editFileC->setValue(QVariant::fromValue(f)); - f.file = dir + mn + dot + ext; editFileM->setValue(QVariant::fromValue(f)); -} - - -void CDPultWindow::on_buttonSessionApply_clicked() { - apply(false); -} - - -void CDPultWindow::on_lineSessionName_textChanged(const QString & t) { - setWindowTitle(QString("CD Pult - %1").arg(t)); -} - - -void CDPultWindow::on_buttonIcon_clicked() { - QList ifl = QImageReader::supportedImageFormats(); - QStringList sfl; foreach (QByteArray s, ifl) sfl << ("*." + QString(s).toLower()); - QString f = QFileDialog::getOpenFileName(this, tr("Select icon"), last_icon, tr("Images") + " (" + sfl.join(" ") + ")"); - if (f.isEmpty()) return; - last_icon = f; - icon = QImage(last_icon); - setWindowIcon(QIcon(QPixmap::fromImage(icon))); -} diff --git a/utils/cd_pult/cdpultwindow.h b/utils/cd_pult/cdpultwindow.h deleted file mode 100644 index dad2c2b..0000000 --- a/utils/cd_pult/cdpultwindow.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef CDPULTWINDOW_H -#define CDPULTWINDOW_H - -#include "emainwindow.h" -#include "ui_cdpultwindow.h" -#include "cdviewwidget.h" -#include "ribbon.h" -#include "piobject.h" - - -class CDPultWindow : public EMainWindow, public Ui::CDPultWindow -{ - Q_OBJECT - Q_ENUMS(LogIcon) -public: - - explicit CDPultWindow(QWidget *parent = 0); - ~CDPultWindow(); - void loadFile(const QString & fp); - void apply(bool sessions); - -private: - - void closeEvent(QCloseEvent *); - void reset(bool full = false); - bool load(const QString & path); - bool save(const QString & path); - QString loadFilter() {return "Pult session(*.conf)";} - QString saveFilter() {return loadFilter();} - void loadingSession(QPIConfig & conf); - void savingSession(QPIConfig & conf); - - QByteArray appIcon() const; - void setAppIcon(QByteArray ba); - - Ribbon * ribbon; - QMap log_icons; - QByteArray session_gr, session_dk, session_mw; - QString def_config, last_icon; - QImage icon; - -private slots: - void addToLog(CDViewWidget::LogIcon icon, const QString & msg); - void messageReceived(QString path, int type, QString msg); - - void on_editFileK_valueChanged(const QVariant & p); - void on_buttonSessionApply_clicked(); - - void on_lineSessionName_textChanged(const QString & t); - void on_buttonIcon_clicked(); -}; - -#endif // CDPULTWINDOW_H diff --git a/utils/cd_pult/cdpultwindow.ui b/utils/cd_pult/cdpultwindow.ui deleted file mode 100644 index ee0273c..0000000 --- a/utils/cd_pult/cdpultwindow.ui +++ /dev/null @@ -1,612 +0,0 @@ - - - CDPultWindow - - - - 0 - 0 - 798 - 593 - - - - CD Pult - - - true - - - QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks - - - - - - 0 - 0 - 798 - 24 - - - - - Main - - - - Open recent - - - - :/icons/document-open-recent.png:/icons/document-open-recent.png - - - - - - - - - - - - - :/icons/document-edit.png:/icons/document-edit.png - - - K - - - 1 - - - - - 0 - - - - - - - - - - - :/icons/dialog-information.png:/icons/dialog-information.png - - - Log - - - 8 - - - - - - - QAbstractItemView::NoEditTriggers - - - false - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - QAbstractItemView::ScrollPerPixel - - - QAbstractItemView::ScrollPerPixel - - - - - - - - - - :/icons/qvariantedit.png:/icons/qvariantedit.png - - - X - - - 1 - - - - - - - - - - - - - :/icons/configure.png:/icons/configure.png - - - Session - - - 2 - - - - - - - Apply - - - - :/icons/dialog-ok-apply.png:/icons/dialog-ok-apply.png - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - Name: - - - - - - - - - - - - Select icon... - - - - :/icons/view-preview.png:/icons/view-preview.png - - - - - - - - - K file: - - - - - - - - - - X file: - - - - - - - - - - C file: - - - - - - - - - - Sync files - - - - - - - - - K - - - - - - - X - - - - - - - C - - - - - - - M - - - - - - - - - Default config - - - - - - - M file: - - - - - - - - - - - - - 0 - 0 - - - - include = ip.conf -[connection] -device.cd = eth://udp:${ip.pult}:27002:${ip.app}:27001 #s -[] - - - - - DejaVu Sans Mono - 9 - - - - - - - - - - - :/icons/legend.png:/icons/legend.png - - - C - - - 1 - - - - - - - - - - - - - :/icons/format-stroke-color.png:/icons/format-stroke-color.png - - - Graphics - - - 8 - - - - - - - - - - - - - :/icons/tools-wizard.png:/icons/tools-wizard.png - - - Direct K - - - 8 - - - - - - - - - - - - - :/icons/accessories-text-editor.png:/icons/accessories-text-editor.png - - - M - - - 1 - - - - - - - - - - - - - :/icons/document-open.png:/icons/document-open.png - - - Open... - - - Ctrl+O - - - - - - :/icons/document-save.png:/icons/document-save.png - - - Save - - - Ctrl+S - - - - - - :/icons/document-save-as.png:/icons/document-save-as.png - - - Save As... - - - Ctrl+Shift+S - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - EMainWindow - QMainWindow -
emainwindow.h
- 1 -
- - CLineEdit - QLineEdit -
clineedit.h
-
- - QCodeEdit - QWidget -
qcodeedit.h
-
- - QVariantEdit - QWidget -
qvariantedit.h
-
- - EDockWidget - QDockWidget -
edockwidget.h
- 1 -
- - CDViewWidget - QWidget -
cdviewwidget.h
- 1 -
- - CDGraphics - QWidget -
cdgraphics.h
- 1 -
- - CDDirectK - QWidget -
cddirectk.h
- 1 -
-
- - - - - - - - - actionSave - triggered() - CDPultWindow - saveFile() - - - -1 - -1 - - - 399 - 299 - - - - - actionSaveAs - triggered() - CDPultWindow - saveAsFile() - - - -1 - -1 - - - 399 - 299 - - - - - actionOpen - triggered() - CDPultWindow - openFile() - - - -1 - -1 - - - 399 - 299 - - - - - checkSyncFiles - toggled(bool) - editFileX - setDisabled(bool) - - - 786 - 220 - - - 786 - 151 - - - - - checkSyncFiles - toggled(bool) - editFileC - setDisabled(bool) - - - 786 - 220 - - - 786 - 172 - - - - - checkDefaultConfig - toggled(bool) - codeConfig - setDisabled(bool) - - - 786 - 276 - - - 581 - 304 - - - - - checkSyncFiles - toggled(bool) - editFileM - setDisabled(bool) - - - 767 - 205 - - - 767 - 187 - - - - -
diff --git a/utils/cd_pult/cdviewwidget.cpp b/utils/cd_pult/cdviewwidget.cpp deleted file mode 100644 index 67fa124..0000000 --- a/utils/cd_pult/cdviewwidget.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "cdviewwidget.h" -#include "cdutils_core.h" -#include "qcd_core.h" -#include "qcd_model.h" -#include "qcd_modedialog.h" -#include "qvariantedit.h" -#include - - -CDViewWidget::CDViewWidget(QWidget * parent) : QWidget(parent), Ui::CDViewWidget() { - qRegisterMetaType("CDViewWidget::LogIcon"); - setupUi(this); - connect(view, SIGNAL(sendSucceed()), this, SLOT(sended())); - connect(view, SIGNAL(receiveSucceed()), this, SLOT(received())); - connect(view, SIGNAL(sendFailed()), this, SLOT(sendFailed())); - connect(view, SIGNAL(receiveFailed()), this, SLOT(receiveFailed())); -} - - -CDViewWidget::~CDViewWidget() { -} - - -void CDViewWidget::reset() { - setFile(""); -} - - -void CDViewWidget::setType(int t) { - view->setType((CDUtils::CDType::cdT)t); - tl_u = view->typeLetter().toUpper(); - tl_l = view->typeLetter().toLower(); - view->refresh(); -} - - -void CDViewWidget::setFile(const QString & f) { - view->setFile(f); - view->load(); -} - - -void CDViewWidget::on_buttonSend_clicked() { - if (view->inProgress()) {addToLog(WaitIcon, "processing..."); return;} - addToLog(WaitIcon, "Sending " + tl_u + "..."); - view->send(); -} - - -void CDViewWidget::on_buttonReceive_clicked() { - if (view->inProgress()) {addToLog(WaitIcon, "processing..."); return;} - addToLog(WaitIcon, "Receiving " + tl_u + "..."); - view->receive(); -} - - -void CDViewWidget::on_buttonLoad_clicked() { - view->load(); -} - - -void CDViewWidget::on_buttonSave_clicked() { - view->save(); -} - - -void CDViewWidget::on_buttonParse_clicked() { - QString path = QFileDialog::getOpenFileName(this, "Select header file", "", - QString("%1 Description(%2_description.h);;Headers(*.h)").arg(tl_u, tl_l)); - if (path.isEmpty()) return; - CDUtils::UpdateModeFlags mode = CDUtils::SaveByName; - if (!view->root()->isEmpty()) { - QCDModeDialog cdm; - if (cdm.exec() != QDialog::Accepted) return; - mode = cdm.mode(); - } - view->buildFromHeader(path, mode); -} diff --git a/utils/cd_pult/cdviewwidget.h b/utils/cd_pult/cdviewwidget.h deleted file mode 100644 index 9b1abb1..0000000 --- a/utils/cd_pult/cdviewwidget.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef CDVIEWWIDGET_H -#define CDVIEWWIDGET_H - -#include -#include "ui_cdviewwidget.h" - - -class CDViewWidget : public QWidget, public Ui::CDViewWidget -{ - Q_OBJECT -public: - explicit CDViewWidget(QWidget *parent = 0); - ~CDViewWidget(); - - enum LogIcon {NoIcon, OKIcon, FailIcon, WaitIcon}; - - void reset(); - void setType(int t); - void setFile(const QString & f); - -private: - QString tl_u, tl_l; - -private slots: - void sended() {addToLog(OKIcon, tl_u + " " + tr("sended succesfull"));} - void received() {addToLog(OKIcon, tl_u + " " + tr("received succesfull"));} - void sendFailed() {addToLog(FailIcon, tl_u + " " + tr("NOT sended"));} - void receiveFailed() {addToLog(FailIcon, tl_u + " " + tr("NOT received"));} - void on_buttonSend_clicked(); - void on_buttonReceive_clicked(); - void on_buttonLoad_clicked(); - void on_buttonSave_clicked(); - void on_buttonParse_clicked(); - //void on_buttonCalculate_clicked(); - -signals: - void addToLog(CDViewWidget::LogIcon icon, const QString & msg); - -}; - -#endif // CDVIEWWIDGET_H diff --git a/utils/cd_pult/cdviewwidget.ui b/utils/cd_pult/cdviewwidget.ui deleted file mode 100644 index eb2d44c..0000000 --- a/utils/cd_pult/cdviewwidget.ui +++ /dev/null @@ -1,176 +0,0 @@ - - - CDViewWidget - - - - 0 - 0 - 689 - 459 - - - - CD Pult - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - Send - - - - :/icons/flame.png:/icons/flame.png - - - - - - - Receive - - - - :/icons/document-revert.png:/icons/document-revert.png - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 20 - 20 - - - - - - - - Load - - - - :/icons/document-open.png:/icons/document-open.png - - - - - - - Save - - - - :/icons/document-save.png:/icons/document-save.png - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 20 - 20 - - - - - - - - Update description ... - - - - :/icons/view-refresh.png:/icons/view-refresh.png - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 1 - 20 - - - - - - - - - - - - Qt::CustomContextMenu - - - QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed - - - true - - - QAbstractItemView::DragOnly - - - QAbstractItemView::ScrollPerPixel - - - QAbstractItemView::ScrollPerPixel - - - - - - - - CDView - QTreeView -
qcd_view.h
-
-
- - - - - -
diff --git a/utils/cd_pult/icons/Apps-accessories-calculator-icon.png b/utils/cd_pult/icons/Apps-accessories-calculator-icon.png deleted file mode 100644 index 37a3035..0000000 Binary files a/utils/cd_pult/icons/Apps-accessories-calculator-icon.png and /dev/null differ diff --git a/utils/cd_pult/icons/accessories-text-editor.png b/utils/cd_pult/icons/accessories-text-editor.png deleted file mode 100644 index 1d9dca2..0000000 Binary files a/utils/cd_pult/icons/accessories-text-editor.png and /dev/null differ diff --git a/utils/cd_pult/icons/db-export.png b/utils/cd_pult/icons/db-export.png deleted file mode 100644 index 7cfba88..0000000 Binary files a/utils/cd_pult/icons/db-export.png and /dev/null differ diff --git a/utils/cd_pult/icons/db-import.png b/utils/cd_pult/icons/db-import.png deleted file mode 100644 index 85bc121..0000000 Binary files a/utils/cd_pult/icons/db-import.png and /dev/null differ diff --git a/utils/cd_pult/icons/flame.png b/utils/cd_pult/icons/flame.png deleted file mode 100644 index d267f72..0000000 Binary files a/utils/cd_pult/icons/flame.png and /dev/null differ diff --git a/utils/cd_pult/icons/timer.png b/utils/cd_pult/icons/timer.png deleted file mode 100644 index c0b8361..0000000 Binary files a/utils/cd_pult/icons/timer.png and /dev/null differ diff --git a/utils/cd_pult/main.cpp b/utils/cd_pult/main.cpp deleted file mode 100644 index 505f4d0..0000000 --- a/utils/cd_pult/main.cpp +++ /dev/null @@ -1,373 +0,0 @@ -#include -#include "cdpultwindow.h" - -template -class PIHash { - //template friend PIByteArray & operator >>(PIByteArray & s, PIHash & v); - //template friend PIByteArray & operator <<(PIByteArray & s, const PIHash & v); -public: - PIHash() {;} - PIHash(const PIHash & other) {*this = other;} - virtual ~PIHash() {;} - - PIHash & operator =(const PIHash & other) { - if (this == &other) return *this; - clear(); - pih_content = other.pih_content; - return *this; - } - - typedef T mapped_type; - typedef Key key_type; - typedef PIPair value_type; -/* - class iterator { - friend class PIHash; - private: - iterator(const PIHash * v, ssize_t p): parent(v), pos(p) {} - const PIHash * parent; - ssize_t pos; - public: - iterator(): parent(0), pos(0) {} - const Key & key() const {return const_cast * >(parent)->_key(pos);} - T & value() {return const_cast * >(parent)->_value(pos);} - void operator ++() {++pos;} - void operator ++(int) {++pos;} - void operator --() {--pos;} - void operator --(int) {--pos;} - bool operator ==(const iterator & it) const {return (pos == it.pos);} - bool operator !=(const iterator & it) const {return (pos != it.pos);} - }; - - class reverse_iterator { - friend class PIHash; - private: - reverse_iterator(const PIHash * v, ssize_t p): parent(v), pos(p) {} - const PIHash * parent; - ssize_t pos; - public: - reverse_iterator(): parent(0), pos(0) {} - const Key & key() const {return const_cast * >(parent)->_key(pos);} - T & value() const {return const_cast * >(parent)->_value(pos);} - void operator ++() {--pos;} - void operator ++(int) {--pos;} - void operator --() {++pos;} - void operator --(int) {++pos;} - bool operator ==(const reverse_iterator & it) const {return (pos == it.pos);} - bool operator !=(const reverse_iterator & it) const {return (pos != it.pos);} - }; -*/ - class const_iterator { - friend class PIHash; - private: - const_iterator(const PIHash * v, ssize_t p): parent(v), pos(p), bpos(0) { - if (pos == 0) { - pos = -1; - nextPos(); - } - } - void nextPos() { - while (++pos < parent->pih_content.size_s()) { - if (!parent->pih_content[pos].isEmpty()) - return; - } - } - const PIHash * parent; - ssize_t pos, bpos; - public: - const_iterator(): parent(0), pos(0) {} - //const value_type operator *() const {return parent->_pair(pos);} - //const value_type* operator ->() const {cval = parent->_pair(pos); return &cval;} - const Key & key() const {return const_cast * >(parent)->pih_content[pos][bpos].key;} - const T & value() const {return const_cast * >(parent)->pih_content[pos][bpos].value;} - void operator ++() { - if (pos < parent->pih_content.size_s()) { - if (bpos >= parent->pih_content[pos].size_s() - 1) { - bpos = 0; - nextPos(); - } else - ++bpos; - } else { - bpos = 0; - ++pos; - } - printf(" ++: %d %d\n", pos, bpos); - } - //void operator ++(int) {++pos;} - void operator --() { - --pos; - } - //void operator --(int) {--pos;} - bool operator ==(const const_iterator & it) const {return (pos == it.pos && bpos == it.bpos);} - bool operator !=(const const_iterator & it) const {return !(*this == it);} - mutable value_type cval; - }; -/* - class const_reverse_iterator { - friend class PIHash; - private: - const_reverse_iterator(const PIHash * v, ssize_t p): parent(v), pos(p) {} - const PIHash * parent; - ssize_t pos; - public: - const_reverse_iterator(): parent(0), pos(0) {} - const value_type operator *() const {return parent->_pair(pos);} - const value_type* operator ->() const {cval = parent->_pair(pos); return &cval;} - void operator ++() {--pos;} - void operator ++(int) {--pos;} - void operator --() {++pos;} - void operator --(int) {++pos;} - bool operator ==(const const_reverse_iterator & it) const {return (pos == it.pos);} - bool operator !=(const const_reverse_iterator & it) const {return (pos != it.pos);} - mutable value_type cval; - }; -*/ - //iterator begin() {return iterator(this, 0);} - //iterator end() {return iterator(this, size());} - const_iterator begin() const {return const_iterator(this, 0);} - const_iterator end() const {return const_iterator(this, size());} - const_iterator constBegin() const {return const_iterator(this, 0);} - const_iterator constEnd() const {return const_iterator(this, size());} - //reverse_iterator rbegin() {return reverse_iterator(this, size() - 1);} - //reverse_iterator rend() {return reverse_iterator(this, -1);} - //const_reverse_iterator rbegin() const {return const_reverse_iterator(this, size() - 1);} - //const_reverse_iterator rend() const {return const_reverse_iterator(this, -1);} - //const_reverse_iterator constRbegin() const {return const_reverse_iterator(this, size() - 1);} - //const_reverse_iterator constRend() const {return const_reverse_iterator(this, -1);} - - size_t size() const {return pih_content.size();} - int size_s() const {return pih_content.size_s();} - size_t length() const {return pih_content.size();} - size_t capacity() const {return pih_content.size();} - bool isEmpty() const {return (pih_content.size() == 0);} - - T & operator [](const Key & key) { - if (pih_content.isEmpty()) _rehash(1); - uint k = piHash(key); - int i = _index(k); - if (i < pih_content.size_s()) { - PIVector & hv(pih_content[i]); - if (hv.size_s() == 1) { - if (hv[0].key == k) - return hv[0].value; - } - for (int j = 0; j < hv.size_s(); ++j) - if (hv[j].key == k) - return hv[j].value; - } - if (pih_content[i].size_s() >= 4) - _rehash(pih_content.size_s() * 2); - i = _index(k); - pih_content[i] << HashEntry(k); - return pih_content[i].back().value; - } - const T operator [](const Key & key) const {return value(key);} - T & at(const Key & key) {return (*this)[key];} - const T at(const Key & key) const {return (*this)[key];} - - PIHash & operator <<(const PIHash & other) { - if (other.isEmpty()) return *this; - for (int i = 0; i < other.pih_content.size_s(); ++i) - for (int j = 0; j < other.pih_content[i].size_s(); ++j) - insert(other.pih_content[i][j].key, other.pih_content[i][j].value); - return *this; - } - - bool operator ==(const PIHash & t) const {return (pih_content == t.pih_content);} - bool operator !=(const PIHash & t) const {return (pih_content != t.pih_content);} - bool contains(const Key & key) const { - bool f(false); - _find(key, f); - return f; - } - - PIHash & reserve(size_t new_size) {_rehash(new_size); return *this;} - - PIHash & remove(const Key & key) { - uint k = piHash(key); - int i = _index(k); - if (i >= pih_content.size_s()) return *this; - PIVector & hv(pih_content[i]); - for (int j = 0; j < hv.size_s(); ++j) - if (hv[j].key == k) { - hv.remove(j); - --j; - } - return *this; - } - PIHash & erase(const Key & key) {return remove(key);} - PIHash & clear() {pih_content.clear(); return *this;} - - void swap(PIHash & other) { - pih_content.swap(other.pih_content); - } - - PIHash & insert(const Key & key, const T & value) { - (*this)[key] = value; - return *this; - } - const T value(const Key & key, const T & default_ = T()) const { - uint k = piHash(key); - int i = _index(k); - if (i >= pih_content.size_s()) return default_; - const PIVector & hv(pih_content[i]); - for (int j = 0; j < hv.size_s(); ++j) - if (hv[j].key == k) - return hv[j].value; - return default_; - } - PIVector values() const { - PIVector ret; - for (int i = 0; i < pih_content.size_s(); ++i) - for (int j = 0; j < pih_content[i].size_s(); ++j) - ret << pih_content[i][j].value; - return ret; - } - /*Key key(const T & value_, const Key & default_ = Key()) const { - for (int i = 0; i < pih_content.size_s(); ++i) - for (int j = 0; j < pih_content[i].size_s(); ++j) - if (pih_content[i][j].value == value_) - return pih_content[i][j].key; - return default_; - } - PIVector keys() const { - PIVector ret; - for (int i = 0; i < pih_content.size_s(); ++i) - for (int j = 0; j < pih_content[i].size_s(); ++j) - ret << pih_content[i][j].key; - return ret; - }*/ - - /*void dump() { - piCout << "PIHash" << size() << "entries" << PICoutManipulators::NewLine << "content:"; - for (size_t i = 0; i < pih_content.size(); ++i) - piCout << PICoutManipulators::Tab << i << ":" << pih_content[i]; - piCout << "index:"; - for (size_t i = 0; i < pim_index.size(); ++i) - piCout << PICoutManipulators::Tab << i << ":" << pim_index[i].key << "->" << pim_index[i].index; - }*/ - -protected: - struct HashEntry { - HashEntry(uint k = 0, const T & v = T()): key(k), value(v) {;} - uint key; - T value; - bool operator ==(const HashEntry & s) const {return key == s.key;} - bool operator !=(const HashEntry & s) const {return key != s.key;} - bool operator <(const HashEntry & s) const {return key < s.key;} - bool operator >(const HashEntry & s) const {return key > s.key;} - }; - /*template friend PIByteArray & operator >>(PIByteArray & s, PIDeque::HashEntry> & v); - template friend PIByteArray & operator <<(PIByteArray & s, const PIDeque::HashEntry> & v); - - const value_type _pair(ssize_t index) const { - if (index < 0 || index >= pim_index.size_s()) - return value_type(); - //piCout << "_pair" << index << pim_index[index].index; - return value_type(pim_index[index].key, pih_content[pim_index[index].index]); - } - Key & _key(ssize_t index) {return pim_index[index].key;} - T & _value(ssize_t index) {return pih_content[pim_index[index].index];}*/ - - inline size_t asize(size_t s) { - if (s == 0) return 0; - if (pih_content.size() + pih_content.size() >= s && pih_content.size() < s) - return pih_content.size() + pih_content.size(); - ssize_t t = 0, s_ = s - 1; - while (s_ >> t) ++t; - return (1 << t); - } - int _index(const uint & k) const { - return k % pih_content.size_s(); - } - void _rehash(int ns) { - ns = asize(ns); - if (pih_content.size_s() == ns) return; - PIVector > nhc; - nhc.resize(ns); - for (int i = 0; i < pih_content.size_s(); ++i) { - for (int j = 0; j < pih_content[i].size_s(); ++j) { - HashEntry & e(pih_content[i][j]); - int ni = e.key % ns; - nhc[ni] << e; - } - } - pih_content.swap(nhc); - } - - PIVector > pih_content; -}; - - -uint qHash(const PIString & v, uint seed = 0) {return piHash(v);} - - -#include "logview.h" -int main(int argc, char *argv[]) { - QApplication a(argc, argv); -#if QT_VERSION >= 0x050000 - a.setAttribute(Qt::AA_UseHighDpiPixmaps, true); -#endif - //################################ - /*QHash h2; - QMap m2; - PIString prefix = "1234567890"; - PITimeMeasurer tm; - double el = 0.; - - tm.reset(); - for (int i=0; i<10000; ++i) { - h2[prefix + PIString::fromNumber(i)+"1234567890"] = PIString::fromNumber(randomi()); - } - el = tm.elapsed_m(); piCout << el << h2.capacity(); - - tm.reset(); - for (int i=0; i<10000; ++i) { - m2[prefix + PIString::fromNumber(i)+"1234567890"] = PIString::fromNumber(randomi()); - } - el = tm.elapsed_m(); piCout << el; - piCout << "*********"; - - PIString _s; - tm.reset(); - for (int i=0; i<10000; ++i) { - _s = h2.value(prefix + PIString::fromNumber(i)+"1234567890"); - } - el = tm.elapsed_m(); piCout << el << h2.capacity(); - - tm.reset(); - for (int i=0; i<10000; ++i) { - _s = m2.value(prefix + PIString::fromNumber(i)+"1234567890"); - } - el = tm.elapsed_m(); piCout << el; - - return 0;*/ - //################################ -//1245hghgfhfdgshrgnhdsgfhjshdszdgsdgnjedghrbnlcvleabjmbassfdggfhbnsjkgnfdvfdsdfojbwasv213443gr2t4sfth - /*LogView lw; - lw.setLogFont(QFont("dejavu sans mono", 9)); - lw.registerCategory("Warning", "Warning", QImage(":/icons/flame.png"), Qt::darkYellow); - lw.registerCategory("Error", "Error", QImage(":/icons/dialog-cancel.png"), Qt::darkRed, true); - //lw.setLinesLimit(12); - lw.show(); - piForTimes(100) - lw.addText(QString("row %1").arg(_i100)); - lw.addText("-- Up-to-date: C:/sdk/MinGW/x32/i686-w64-mingw32/include/qglengine/scene_tree.h"); - lw.addText("-- Up-to-date: C:/sdk/MinGW/x32/i686-w64-mingw32/include/qglengine/scene_tree.h"); - lw.addText("-- Up-to-date: C:/sdk/MinGW/x32/i686-w64-mingw32/include/qglengine/view_editor.h"); - lw.addText("-- Up-to-date: C:/sdk/MinGW/x32/i686-w64-mingw32/include/qglengine/material_map_editor.h\n" - "-- Up-to-date: C:/sdk/MinGW/x32/i686-w64-mingw32/include/qglengine/materials_editor\n" - "-- Up-to-date: C:/sdk/MinGW/x32/i686-w64-mingw32/include/qglengine/object_editor.h"); - lw.addText("[Warning] sdfkjhdfgj"); - lw.addText("[Error] gbflknwed"); - QLineEdit * le = new QLineEdit(); - QObject::connect(le, &QLineEdit::returnPressed, [&](){lw.addText(le->text());}); - le->show(); - return a.exec();*/ - - CDPultWindow w; - w.show(); - if (a.arguments().size() > 1) - w.loadFile(a.arguments()[1]); - return a.exec(); -}