git-svn-id: svn://db.shs.com.ru/libs@586 a8b55f48-bf90-11e4-a774-851b48703e85
26
test/qcd_utils/pult/CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
project(cd_pult)
|
||||
find_qt(${QtVersions} Core Gui OpenGL)
|
||||
qt_sources(SRC)
|
||||
qt_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM)
|
||||
qt_add_executable(${PROJECT_NAME} WIN32 out_CPP)
|
||||
qt_target_link_libraries(${PROJECT_NAME} qad_utils qad_widgets qad_graphic qad_application qcd_utils piqt_utils)
|
||||
message(STATUS "Building ${PROJECT_NAME}")
|
||||
if(LIB)
|
||||
if(WIN32)
|
||||
qt_install(TARGETS ${PROJECT_NAME} DESTINATION ${MINGW_BIN})
|
||||
else()
|
||||
if(APPLE)
|
||||
qt_install(TARGETS ${PROJECT_NAME} DESTINATION /usr/local/bin)
|
||||
else()
|
||||
if (DEFINED ANDROID_PLATFORM)
|
||||
qt_install(TARGETS ${PROJECT_NAME} DESTINATION ${ANDROID_SYSTEM_LIBRARY_PATH}/usr/bin)
|
||||
else()
|
||||
qt_install(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
#message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
|
||||
else()
|
||||
qt_install(TARGETS ${PROJECT_NAME} DESTINATION bin)
|
||||
#message(STATUS "Install ${PROJECT_NAME} to local \"bin\"")
|
||||
endif()
|
||||
312
test/qcd_utils/pult/cddirectk.cpp
Normal file
@@ -0,0 +1,312 @@
|
||||
#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 <QFormLayout>
|
||||
#include <QMimeData>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDragMoveEvent>
|
||||
#include <QDropEvent>
|
||||
#include <QMainWindow>
|
||||
#include <QDockWidget>
|
||||
#include <QInputDialog>
|
||||
|
||||
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(trUtf8("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<int> 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<PIDeque<int> > list;
|
||||
QVector<CDDirectKTypeDialog::TypeInfo> ilist;
|
||||
while (!cs.atEnd()) {
|
||||
switch (cs.read()) {
|
||||
case 1: setWindowTitle(cs.getData<QString>()); break;
|
||||
case 2: list = setList(cs.getData<QStringList>()); break;
|
||||
case 3: ilist = cs.getData<QVector<CDDirectKTypeDialog::TypeInfo> >(); 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<QLabel*>(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, trUtf8("Rename area"), trUtf8("New area name:"),
|
||||
QLineEdit::Normal, windowTitle());
|
||||
if (nn.isEmpty()) return;
|
||||
setWindowTitle(nn);
|
||||
}
|
||||
|
||||
|
||||
void KDockWidget::removeK() {
|
||||
QAction * a = qobject_cast<QAction * >(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<QByteArray> 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<int>();
|
||||
piForTimes (s)
|
||||
addArea();
|
||||
} break;
|
||||
case 2: {
|
||||
QVector<QByteArray> dstates = cs.getData<QVector<QByteArray> >();
|
||||
for (int i = 0; i < piMini(dstates.size(), docks.size()); ++i)
|
||||
docks[i]->load(dstates[i]);
|
||||
} break;
|
||||
case 3: da->restoreState(cs.getData<QByteArray>()); 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<KDockWidget * >(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();
|
||||
}
|
||||
77
test/qcd_utils/pult/cddirectk.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#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<QAction*> dactions;
|
||||
QMainWindow * da;
|
||||
CDDirectKTypeDialog * type_dialog;
|
||||
PIVector<PIDeque<int> > k_list;
|
||||
QVector<CDDirectKTypeDialog::TypeInfo> 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<KDockWidget * > docks;
|
||||
QMainWindow * da;
|
||||
|
||||
public slots:
|
||||
void changedGlobal();
|
||||
|
||||
private slots:
|
||||
void removeArea();
|
||||
void on_buttonAdd_clicked();
|
||||
void on_buttonRemoveAll_clicked();
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // CDDIRECTK_H
|
||||
85
test/qcd_utils/pult/cddirectk.ui
Normal file
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDDirectK</class>
|
||||
<widget class="QWidget" name="CDDirectK">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>624</width>
|
||||
<height>411</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>CD Pult</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="layoutMain" stretch="0">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonAdd">
|
||||
<property name="toolTip">
|
||||
<string>Add new</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonRemoveAll">
|
||||
<property name="toolTip">
|
||||
<string>Remove all</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../qad/application/qad_application.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
76
test/qcd_utils/pult/cddirectk_type_dialog.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
#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();
|
||||
}
|
||||
44
test/qcd_utils/pult/cddirectk_type_dialog.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef CDDIRECTK_TYPE_DIALOG_H
|
||||
#define CDDIRECTK_TYPE_DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#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<double> params_d;
|
||||
QVector<QString> 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
|
||||
232
test/qcd_utils/pult/cddirectk_type_dialog.ui
Normal file
@@ -0,0 +1,232 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDDirectKTypeDialog</class>
|
||||
<widget class="QDialog" name="CDDirectKTypeDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>275</width>
|
||||
<height>310</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>CD Pult</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Custom</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboType">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Spin</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Slider</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>SpinSlider</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Min:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="EvalSpinBox" name="evalMin"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Max:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="EvalSpinBox" name="evalMax">
|
||||
<property name="value">
|
||||
<double>100.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Decimals:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="spinDecimals"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Single step:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="EvalSpinBox" name="evalStep">
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Prefix:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="CLineEdit" name="linePrefix"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Suffix:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="CLineEdit" name="lineSuffix"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>clineedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>EvalSpinBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>evalspinbox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>groupBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>widget</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>86</x>
|
||||
<y>49</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>94</x>
|
||||
<y>91</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CDDirectKTypeDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>297</x>
|
||||
<y>285</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>315</x>
|
||||
<y>280</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CDDirectKTypeDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>281</x>
|
||||
<y>290</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>283</x>
|
||||
<y>307</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
353
test/qcd_utils/pult/cdgraphics.cpp
Normal file
@@ -0,0 +1,353 @@
|
||||
#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 "graphic.h"
|
||||
#include "piqt.h"
|
||||
#include <QMimeData>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDragMoveEvent>
|
||||
#include <QDropEvent>
|
||||
#include <QMainWindow>
|
||||
#include <QDockWidget>
|
||||
#include <QInputDialog>
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
QStringList CDUtils::getList(const PIVector<PIDeque<int> > & x_list) {
|
||||
QStringList ret;
|
||||
piForeachC (PIDeque<int> & p, x_list)
|
||||
ret << PI2QString(CDCore::pathToString(p));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
PIVector<PIDeque<int> > CDUtils::setList(const QStringList & l) {
|
||||
PIVector<PIDeque<int> > 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(trUtf8("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<int> 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<PIString, PIVector<double> > & data) {
|
||||
for (int i = 0; i < x_list.size_s(); ++i) {
|
||||
PIString sp = CDCore::pathToString(x_list[i]);
|
||||
const PIVector<double> & 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->ui->evalHistory->expression())
|
||||
.add(5, graphic->ui->evalVisible->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<QString>()); break;
|
||||
case 2: x_list = setList(cs.getData<QStringList>()); break;
|
||||
case 3: graphic->graphic()->load(cs.getData<QByteArray>()); break;
|
||||
case 4: graphic->ui->evalHistory->setExpression(cs.getData<QString>()); break;
|
||||
case 5: graphic->ui->evalVisible->setExpression(cs.getData<QString>()); 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<CDGraphicWidget*>(o) && o)
|
||||
o = o->parent();
|
||||
return qobject_cast<CDGraphicWidget*>(o);
|
||||
}
|
||||
|
||||
|
||||
void GDockWidget::rename() {
|
||||
QString nn = QInputDialog::getText(this, trUtf8("Rename area"), trUtf8("New area name:"),
|
||||
QLineEdit::Normal, windowTitle());
|
||||
if (nn.isEmpty()) return;
|
||||
setWindowTitle(nn);
|
||||
}
|
||||
|
||||
|
||||
void GDockWidget::removeX() {
|
||||
QAction * a = qobject_cast<QAction * >(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<QByteArray> 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<int>();
|
||||
piForTimes (s)
|
||||
addGraphic();
|
||||
} break;
|
||||
case 2: {
|
||||
QVector<QByteArray> dstates = cs.getData<QVector<QByteArray> >();
|
||||
for (int i = 0; i < piMini(dstates.size(), docks.size()); ++i)
|
||||
docks[i]->load(dstates[i]);
|
||||
} break;
|
||||
case 3: da->restoreState(cs.getData<QByteArray>()); break;
|
||||
case 4:
|
||||
X.lock();
|
||||
X.setEnabledList(setList(cs.getData<QStringList>()));
|
||||
X.unlock();
|
||||
break;
|
||||
case 5:
|
||||
buttonConfigVisible->setChecked(cs.getData<bool>());
|
||||
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<PIString, PIVector<double> > data;
|
||||
X.lock();
|
||||
PIVector<PIDeque<int> > x_list = X.enabledList();
|
||||
PIVector<double> ch;
|
||||
piForeachC (PIDeque<int> & 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<GDockWidget * >(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();
|
||||
}
|
||||
92
test/qcd_utils/pult/cdgraphics.h
Normal file
@@ -0,0 +1,92 @@
|
||||
#ifndef CDGRAPHICS_H
|
||||
#define CDGRAPHICS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QDockWidget>
|
||||
#include <QMenu>
|
||||
#include "ui_cdgraphics.h"
|
||||
#include "qcd_graphic.h"
|
||||
#include <pistring.h>
|
||||
|
||||
namespace CDUtils {
|
||||
class CDType;
|
||||
class CDSection;
|
||||
QStringList getList(const PIVector<PIDeque<int> > & x_list);
|
||||
PIVector<PIDeque<int> > 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<PIString, PIVector<double> > & 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<QAction*> dactions;
|
||||
QMainWindow * da;
|
||||
PIVector<PIDeque<int> > 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<GDockWidget * > 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
|
||||
168
test/qcd_utils/pult/cdgraphics.ui
Normal file
@@ -0,0 +1,168 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDGraphics</class>
|
||||
<widget class="QWidget" name="CDGraphics">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>624</width>
|
||||
<height>411</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>CD Pult</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="layoutMain" stretch="0">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonAdd">
|
||||
<property name="toolTip">
|
||||
<string>Add new</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/utils/qad_utils.qrc">
|
||||
<normaloff>:/icons/list-add.png</normaloff>:/icons/list-add.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonClear">
|
||||
<property name="toolTip">
|
||||
<string>Clear all</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/utils/qad_utils.qrc">
|
||||
<normaloff>:/icons/edit-clear.png</normaloff>:/icons/edit-clear.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonRemoveAll">
|
||||
<property name="toolTip">
|
||||
<string>Remove all</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/utils/qad_utils.qrc">
|
||||
<normaloff>:/icons/edit-delete.png</normaloff>:/icons/edit-delete.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonConfigVisible">
|
||||
<property name="toolTip">
|
||||
<string>Remove all</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/layer-visible-off.png</normaloff>
|
||||
<normalon>:/icons/layer-visible-on.png</normalon>:/icons/layer-visible-off.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonLegendVisible">
|
||||
<property name="toolTip">
|
||||
<string>Remove all</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/widgets/qad_widgets.qrc">
|
||||
<normaloff>:/icons/legend.png</normaloff>:/icons/legend.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonPause">
|
||||
<property name="toolTip">
|
||||
<string>Remove all</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/graphic/qad_graphic.qrc">
|
||||
<normaloff>:/icons/media-playback-pause.png</normaloff>:/icons/media-playback-pause.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonBorderInputsVisible">
|
||||
<property name="toolTip">
|
||||
<string>Remove all</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/widgets/qad_widgets.qrc">
|
||||
<normaloff>:/icons/border-line.png</normaloff>:/icons/border-line.png</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../qad/utils/qad_utils.qrc"/>
|
||||
<include location="../../qad/widgets/qad_widgets.qrc"/>
|
||||
<include location="../../qad/application/qad_application.qrc"/>
|
||||
<include location="../../qad/graphic/qad_graphic.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
16
test/qcd_utils/pult/cdpult.qrc
Normal file
@@ -0,0 +1,16 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>icons/db-export.png</file>
|
||||
<file>icons/db-import.png</file>
|
||||
<file>icons/Apps-accessories-calculator-icon.png</file>
|
||||
<file>icons/dialog-information.png</file>
|
||||
<file>icons/dialog-cancel.png</file>
|
||||
<file>icons/dialog-ok-apply.png</file>
|
||||
<file>icons/timer.png</file>
|
||||
<file>icons/document-revert.png</file>
|
||||
<file>icons/flame.png</file>
|
||||
<file>icons/view-refresh.png</file>
|
||||
<file>icons/format-stroke-color.png</file>
|
||||
<file>icons/accessories-text-editor.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
292
test/qcd_utils/pult/cdpultwindow.cpp
Normal file
@@ -0,0 +1,292 @@
|
||||
#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 <QFileDialog>
|
||||
#include <QScrollBar>
|
||||
#include <QImageReader>
|
||||
#include <QMessageBox>
|
||||
|
||||
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<QAD::File>().file);
|
||||
widgetX->setFile(editFileX->value().value<QAD::File>().file);
|
||||
widgetC->setFile(editFileC->value().value<QAD::File>().file);
|
||||
widgetM->setFile(editFileM->value().value<QAD::File>().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<PIDeque<int> > x_list = X.enabledList();
|
||||
X.unlock();
|
||||
piForeachC (PIDeque<int> & 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<QAD::File>();
|
||||
checkSyncFiles->setChecked(false);
|
||||
editFileK->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_k").value(), f.filter)));
|
||||
editFileX->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_x").value(), f.filter)));
|
||||
editFileC->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_c").value(), f.filter)));
|
||||
editFileM->setValue(QVariant::fromValue(QAD::File(conf.getValue("file_m").value(), f.filter)));
|
||||
checkSyncFiles->setChecked(conf.getValue("sync_files"));
|
||||
lineSessionName->setText(conf.getValue("session_name"));
|
||||
last_icon = conf.getValue("icon_path", "").value();
|
||||
setAppIcon(conf.getValue("icon", QByteArray()));
|
||||
checkHasK->setChecked(conf.getValue("has_k"));
|
||||
checkHasX->setChecked(conf.getValue("has_x"));
|
||||
checkHasC->setChecked(conf.getValue("has_c"));
|
||||
checkHasM->setChecked(conf.getValue("has_m"));
|
||||
checkDefaultConfig->setChecked(conf.getValue("default_config"));
|
||||
codeConfig->setText(QByteArray2QString(conf.getValue("config", QByteArray())));
|
||||
if (codeConfig->text().isEmpty())
|
||||
codeConfig->setText(def_config);
|
||||
session_gr = conf.getValue("session_gr", QByteArray());
|
||||
session_dk = conf.getValue("session_dk", QByteArray());
|
||||
session_mw = conf.getValue("session_mw", QByteArray());
|
||||
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<QAD::File>().file);
|
||||
conf.setValue("file_x", editFileX->value().value<QAD::File>().file);
|
||||
conf.setValue("file_c", editFileC->value().value<QAD::File>().file);
|
||||
conf.setValue("file_m", editFileM->value().value<QAD::File>().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", QStringList()));
|
||||
}
|
||||
|
||||
|
||||
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<QAD::File>().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<QAD::File>();
|
||||
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<QByteArray> 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)));
|
||||
}
|
||||
53
test/qcd_utils/pult/cdpultwindow.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#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<CDViewWidget::LogIcon, QIcon> 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
|
||||
612
test/qcd_utils/pult/cdpultwindow.ui
Normal file
@@ -0,0 +1,612 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDPultWindow</class>
|
||||
<widget class="EMainWindow" name="CDPultWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>798</width>
|
||||
<height>593</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>CD Pult</string>
|
||||
</property>
|
||||
<property name="dockNestingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dockOptions">
|
||||
<set>QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks</set>
|
||||
</property>
|
||||
<widget class="QWidget" name="central"/>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>798</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuMain">
|
||||
<property name="title">
|
||||
<string>Main</string>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuOpen_recent">
|
||||
<property name="title">
|
||||
<string>Open recent</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/document-open-recent.png</normaloff>:/icons/document-open-recent.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="menuOpen_recent"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSaveAs"/>
|
||||
</widget>
|
||||
<addaction name="menuMain"/>
|
||||
</widget>
|
||||
<widget class="EDockWidget" name="dockCDKView">
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/document-edit.png</normaloff>:/icons/document-edit.png</iconset>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>K</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>1</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="CDViewWidget" name="widgetK" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="EDockWidget" name="dockLog">
|
||||
<property name="windowIcon">
|
||||
<iconset resource="cdpult.qrc">
|
||||
<normaloff>:/icons/dialog-information.png</normaloff>:/icons/dialog-information.png</iconset>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Log</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>8</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listLog">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="EDockWidget" name="dockCDXView">
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../qad/widgets/qad_widgets.qrc">
|
||||
<normaloff>:/icons/qvariantedit.png</normaloff>:/icons/qvariantedit.png</iconset>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>X</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>1</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents_3">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="CDViewWidget" name="widgetX" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="EDockWidget" name="dockSession">
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/configure.png</normaloff>:/icons/configure.png</iconset>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Session</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>2</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonSessionApply">
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/widgets/qad_widgets.qrc">
|
||||
<normaloff>:/icons/dialog-ok-apply.png</normaloff>:/icons/dialog-ok-apply.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="CLineEdit" name="lineSessionName"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonIcon">
|
||||
<property name="toolTip">
|
||||
<string>Select icon...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/view-preview.png</normaloff>:/icons/view-preview.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>K file:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QVariantEdit" name="editFileK"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>X file:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QVariantEdit" name="editFileX"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>C file:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QVariantEdit" name="editFileC"/>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkSyncFiles">
|
||||
<property name="text">
|
||||
<string>Sync files</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkHasK">
|
||||
<property name="text">
|
||||
<string>K</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkHasX">
|
||||
<property name="text">
|
||||
<string>X</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkHasC">
|
||||
<property name="text">
|
||||
<string>C</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkHasM">
|
||||
<property name="text">
|
||||
<string>M</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkDefaultConfig">
|
||||
<property name="text">
|
||||
<string>Default config</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>M file:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QVariantEdit" name="editFileM"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCodeEdit" name="codeConfig">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>include = ip.conf
|
||||
[connection]
|
||||
device.cd = eth://udp:${ip.pult}:27002:${ip.app}:27001 #s
|
||||
[]
|
||||
</string>
|
||||
</property>
|
||||
<property name="editorFont">
|
||||
<font>
|
||||
<family>DejaVu Sans Mono</family>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="EDockWidget" name="dockCDCView">
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../qad/blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/legend.png</normaloff>:/icons/legend.png</iconset>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>C</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>1</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents_5">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="CDViewWidget" name="widgetC" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="EDockWidget" name="dockGraphics">
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../qad/blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/format-stroke-color.png</normaloff>:/icons/format-stroke-color.png</iconset>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Graphics</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>8</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents_6">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="CDGraphics" name="widgetGraphics" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="EDockWidget" name="dockDirectK">
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../qad/widgets/qad_widgets.qrc">
|
||||
<normaloff>:/icons/tools-wizard.png</normaloff>:/icons/tools-wizard.png</iconset>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Direct K</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>8</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents_7">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="CDDirectK" name="widgetDirectK" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="EDockWidget" name="dockCDMView">
|
||||
<property name="windowIcon">
|
||||
<iconset resource="cdpult.qrc">
|
||||
<normaloff>:/icons/accessories-text-editor.png</normaloff>:/icons/accessories-text-editor.png</iconset>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>M</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>1</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents_8">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<widget class="CDViewWidget" name="widgetM" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<action name="actionOpen">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+O</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSaveAs">
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/document-save-as.png</normaloff>:/icons/document-save-as.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save As...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Shift+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSaveAs"/>
|
||||
<addaction name="menuMain"/>
|
||||
<addaction name="menuOpen_recent"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>EMainWindow</class>
|
||||
<extends>QMainWindow</extends>
|
||||
<header>emainwindow.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CLineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>clineedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QCodeEdit</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qcodeedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QVariantEdit</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qvariantedit.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>EDockWidget</class>
|
||||
<extends>QDockWidget</extends>
|
||||
<header>edockwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CDViewWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>cdviewwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CDGraphics</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>cdgraphics.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CDDirectK</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>cddirectk.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../qad/application/qad_application.qrc"/>
|
||||
<include location="../../qad/blockview/qad_blockview.qrc"/>
|
||||
<include location="../../qad/widgets/qad_widgets.qrc"/>
|
||||
<include location="cdpult.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>actionSave</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>CDPultWindow</receiver>
|
||||
<slot>saveFile()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
<y>299</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionSaveAs</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>CDPultWindow</receiver>
|
||||
<slot>saveAsFile()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
<y>299</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionOpen</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>CDPultWindow</receiver>
|
||||
<slot>openFile()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
<y>299</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkSyncFiles</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>editFileX</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>786</x>
|
||||
<y>220</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>786</x>
|
||||
<y>151</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkSyncFiles</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>editFileC</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>786</x>
|
||||
<y>220</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>786</x>
|
||||
<y>172</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkDefaultConfig</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>codeConfig</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>786</x>
|
||||
<y>276</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>581</x>
|
||||
<y>304</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>checkSyncFiles</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>editFileM</receiver>
|
||||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>767</x>
|
||||
<y>205</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>767</x>
|
||||
<y>187</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
78
test/qcd_utils/pult/cdviewwidget.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
#include "cdviewwidget.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_model.h"
|
||||
#include "qcd_modedialog.h"
|
||||
#include "qvariantedit.h"
|
||||
#include <QFileDialog>
|
||||
|
||||
|
||||
CDViewWidget::CDViewWidget(QWidget * parent) : QWidget(parent), Ui::CDViewWidget() {
|
||||
qRegisterMetaType<CDViewWidget::LogIcon>("CDViewWidget::LogIcon");
|
||||
setupUi(this);
|
||||
connect(view, SIGNAL(sendSucceed()), this, SLOT(sended()));
|
||||
connect(view, SIGNAL(receiveSucceed()), this, SLOT(received()));
|
||||
connect(view, SIGNAL(sendFailed()), this, SLOT(sendFailed()));
|
||||
connect(view, SIGNAL(receiveFailed()), this, SLOT(receiveFailed()));
|
||||
}
|
||||
|
||||
|
||||
CDViewWidget::~CDViewWidget() {
|
||||
}
|
||||
|
||||
|
||||
void CDViewWidget::reset() {
|
||||
setFile("");
|
||||
}
|
||||
|
||||
|
||||
void CDViewWidget::setType(int t) {
|
||||
view->setType((CDUtils::CDType::cdT)t);
|
||||
tl_u = view->typeLetter().toUpper();
|
||||
tl_l = view->typeLetter().toLower();
|
||||
view->refresh();
|
||||
}
|
||||
|
||||
|
||||
void CDViewWidget::setFile(const QString & f) {
|
||||
view->setFile(f);
|
||||
view->load();
|
||||
}
|
||||
|
||||
|
||||
void CDViewWidget::on_buttonSend_clicked() {
|
||||
if (view->inProgress()) {addToLog(WaitIcon, "processing..."); return;}
|
||||
addToLog(WaitIcon, "Sending " + tl_u + "...");
|
||||
view->send();
|
||||
}
|
||||
|
||||
|
||||
void CDViewWidget::on_buttonReceive_clicked() {
|
||||
if (view->inProgress()) {addToLog(WaitIcon, "processing..."); return;}
|
||||
addToLog(WaitIcon, "Receiving " + tl_u + "...");
|
||||
view->receive();
|
||||
}
|
||||
|
||||
|
||||
void CDViewWidget::on_buttonLoad_clicked() {
|
||||
view->load();
|
||||
}
|
||||
|
||||
|
||||
void CDViewWidget::on_buttonSave_clicked() {
|
||||
view->save();
|
||||
}
|
||||
|
||||
|
||||
void CDViewWidget::on_buttonParse_clicked() {
|
||||
QString path = QFileDialog::getOpenFileName(this, "Select header file", "",
|
||||
QString("%1 Description(%2_description.h);;Headers(*.h)").arg(tl_u, tl_l));
|
||||
if (path.isEmpty()) return;
|
||||
CDUtils::UpdateModeFlags mode = CDUtils::SaveByName;
|
||||
if (!view->root()->isEmpty()) {
|
||||
QCDModeDialog cdm;
|
||||
if (cdm.exec() != QDialog::Accepted) return;
|
||||
mode = cdm.mode();
|
||||
}
|
||||
view->buildFromHeader(path, mode);
|
||||
}
|
||||
41
test/qcd_utils/pult/cdviewwidget.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef CDVIEWWIDGET_H
|
||||
#define CDVIEWWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "ui_cdviewwidget.h"
|
||||
|
||||
|
||||
class CDViewWidget : public QWidget, public Ui::CDViewWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CDViewWidget(QWidget *parent = 0);
|
||||
~CDViewWidget();
|
||||
|
||||
enum LogIcon {NoIcon, OKIcon, FailIcon, WaitIcon};
|
||||
|
||||
void reset();
|
||||
void setType(int t);
|
||||
void setFile(const QString & f);
|
||||
|
||||
private:
|
||||
QString tl_u, tl_l;
|
||||
|
||||
private slots:
|
||||
void sended() {addToLog(OKIcon, tl_u + " " + tr("sended succesfull"));}
|
||||
void received() {addToLog(OKIcon, tl_u + " " + tr("received succesfull"));}
|
||||
void sendFailed() {addToLog(FailIcon, tl_u + " " + tr("NOT sended"));}
|
||||
void receiveFailed() {addToLog(FailIcon, tl_u + " " + tr("NOT received"));}
|
||||
void on_buttonSend_clicked();
|
||||
void on_buttonReceive_clicked();
|
||||
void on_buttonLoad_clicked();
|
||||
void on_buttonSave_clicked();
|
||||
void on_buttonParse_clicked();
|
||||
//void on_buttonCalculate_clicked();
|
||||
|
||||
signals:
|
||||
void addToLog(CDViewWidget::LogIcon icon, const QString & msg);
|
||||
|
||||
};
|
||||
|
||||
#endif // CDVIEWWIDGET_H
|
||||
176
test/qcd_utils/pult/cdviewwidget.ui
Normal file
@@ -0,0 +1,176 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDViewWidget</class>
|
||||
<widget class="QWidget" name="CDViewWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>689</width>
|
||||
<height>459</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>CD Pult</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonSend">
|
||||
<property name="text">
|
||||
<string>Send</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="cdpult.qrc">
|
||||
<normaloff>:/icons/flame.png</normaloff>:/icons/flame.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonReceive">
|
||||
<property name="text">
|
||||
<string>Receive</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="cdpult.qrc">
|
||||
<normaloff>:/icons/document-revert.png</normaloff>:/icons/document-revert.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonLoad">
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/document-open.png</normaloff>:/icons/document-open.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonSave">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../qad/application/qad_application.qrc">
|
||||
<normaloff>:/icons/document-save.png</normaloff>:/icons/document-save.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonParse">
|
||||
<property name="text">
|
||||
<string>Update description ...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="cdpult.qrc">
|
||||
<normaloff>:/icons/view-refresh.png</normaloff>:/icons/view-refresh.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="CDView" name="view">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragOnly</enum>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CDView</class>
|
||||
<extends>QTreeView</extends>
|
||||
<header>qcd_view.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../qad/application/qad_application.qrc"/>
|
||||
<include location="cdpult.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
BIN
test/qcd_utils/pult/icons/Apps-accessories-calculator-icon.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
test/qcd_utils/pult/icons/accessories-text-editor.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
test/qcd_utils/pult/icons/db-export.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
test/qcd_utils/pult/icons/db-import.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
test/qcd_utils/pult/icons/dialog-cancel.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
test/qcd_utils/pult/icons/dialog-information.png
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
test/qcd_utils/pult/icons/dialog-ok-apply.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
test/qcd_utils/pult/icons/document-revert.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
test/qcd_utils/pult/icons/flame.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
test/qcd_utils/pult/icons/format-stroke-color.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
test/qcd_utils/pult/icons/timer.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
test/qcd_utils/pult/icons/view-refresh.png
Normal file
|
After Width: | Height: | Size: 40 KiB |
56
test/qcd_utils/pult/main.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include <QApplication>
|
||||
#include "cdpultwindow.h"
|
||||
|
||||
|
||||
inline uint qHash(const PIString &t) {
|
||||
return t.hash();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
#if QT_VERSION >= 0x050000
|
||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
||||
#endif
|
||||
//################################
|
||||
QHash<int, PIString> h2;
|
||||
QMap<int, PIString> m2;
|
||||
PIVector<int> keys;
|
||||
PIString prefix = "1234567890fgbjyfjyjbghjkbgkbgjgsfh jhfgj ghfjhjfjf";
|
||||
PITimeMeasurer tm;
|
||||
double el = 0.;
|
||||
for (int i=0; i<100000; ++i) keys << randomi();
|
||||
piCout << keys.size();
|
||||
|
||||
tm.reset();
|
||||
for (int i=0; i<100000; ++i) {
|
||||
h2[keys[i]] = prefix;
|
||||
}
|
||||
el = tm.elapsed_m(); piCout << el << h2.capacity() << h2.size();
|
||||
|
||||
tm.reset();
|
||||
for (int i=0; i<100000; ++i) {
|
||||
m2[keys[i]] = prefix;
|
||||
}
|
||||
el = tm.elapsed_m(); piCout << el;
|
||||
piCout << "*********";
|
||||
|
||||
PIString _s;
|
||||
tm.reset();
|
||||
for (int i=0; i<100000; ++i) {
|
||||
_s = h2.value(keys[i]);
|
||||
}
|
||||
el = tm.elapsed_m(); piCout << el << h2.capacity();
|
||||
|
||||
tm.reset();
|
||||
for (int i=0; i<100000; ++i) {
|
||||
_s = m2.value(keys[i]);
|
||||
}
|
||||
el = tm.elapsed_m(); piCout << el;
|
||||
//################################
|
||||
CDPultWindow w;
|
||||
w.show();
|
||||
if (a.arguments().size() > 1)
|
||||
w.loadFile(a.arguments()[1]);
|
||||
return a.exec();
|
||||
}
|
||||