git-svn-id: svn://db.shs.com.ru/libs@161 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -24,7 +24,7 @@ qt4_wrap_cpp(CMOCS ${MOCS} OPTIONS -nw)
|
||||
qt4_wrap_ui(CUIS ${UIS})
|
||||
qt4_add_resources(RESS ${RES})
|
||||
add_library(${PROJECT_NAME} SHARED ${CPPS} ${CMOCS} ${CUIS} ${RESS} ${MOCS})
|
||||
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${PIP_LIBRARY} qad_widgets cd_utils piqt)
|
||||
set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${PIP_LIBRARY} qad_utils qad_widgets cd_utils piqt)
|
||||
target_link_libraries(${PROJECT_NAME} ${LIBS})
|
||||
|
||||
if (NOT DEFINED ENV{QNX_HOST})
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_kmodel.h"
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
@@ -34,6 +35,7 @@ void Form::on_pushButton_4_clicked() {
|
||||
ui->treeView->loadK();
|
||||
ui->treeView->setKFile("");
|
||||
qDebug() << QCDCore::instance()->bindWindow(this);
|
||||
QCDCore::instance()->bindWidget(ui->spinRadar_Antenna_SwitchRate, K["NVA.NVA_FrameStitch"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -59,8 +59,9 @@ void QCDCore::K_ChangedGlobal() {
|
||||
void QCDCore::slotBool(bool v) {
|
||||
QWidget * w = (QWidget*)sender();
|
||||
if (!w || updating) return;
|
||||
PIDeque<int> path = binded_widgets.value(w);
|
||||
CDCore::instance()->k()[path].setValue(PIString::fromBool(v));
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
CDCore::instance()->k()[path].setValue(PIString::fromBool(v));
|
||||
emit updateViewRequest();
|
||||
}
|
||||
|
||||
@@ -68,8 +69,9 @@ void QCDCore::slotBool(bool v) {
|
||||
void QCDCore::slotInt(int v) {
|
||||
QWidget * w = (QWidget*)sender();
|
||||
if (!w || updating) return;
|
||||
PIDeque<int> path = binded_widgets.value(w);
|
||||
CDCore::instance()->k()[path].setValue(PIString::fromNumber(v));
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
CDCore::instance()->k()[path].setValue(PIString::fromNumber(v));
|
||||
emit updateViewRequest();
|
||||
}
|
||||
|
||||
@@ -77,8 +79,9 @@ void QCDCore::slotInt(int v) {
|
||||
void QCDCore::slotDouble(double v) {
|
||||
QWidget * w = (QWidget*)sender();
|
||||
if (!w || updating) return;
|
||||
PIDeque<int> path = binded_widgets.value(w);
|
||||
CDCore::instance()->k()[path].setValue(PIString::fromNumber(v));
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
CDCore::instance()->k()[path].setValue(PIString::fromNumber(v));
|
||||
emit updateViewRequest();
|
||||
}
|
||||
|
||||
@@ -86,8 +89,9 @@ void QCDCore::slotDouble(double v) {
|
||||
void QCDCore::slotText(QString v) {
|
||||
QWidget * w = (QWidget*)sender();
|
||||
if (!w || updating) return;
|
||||
PIDeque<int> path = binded_widgets.value(w);
|
||||
CDCore::instance()->k()[path].setValue(Q2PIString(v));
|
||||
QList<PIDeque<int> > pathes = binded_widgets.values(w);
|
||||
foreach (const PIDeque<int> & path, pathes)
|
||||
CDCore::instance()->k()[path].setValue(Q2PIString(v));
|
||||
emit updateViewRequest();
|
||||
}
|
||||
|
||||
@@ -124,7 +128,7 @@ bool QCDCore::bindWidget(QWidget * w) {
|
||||
}
|
||||
|
||||
|
||||
bool QCDCore::bindWidget(QWidget * w, const CDType & k) {
|
||||
bool QCDCore::bindWidget(QWidget * w, const CDType k) {
|
||||
if (!w) return false;
|
||||
QString cn = w->metaObject()->className();
|
||||
bool ok = false;
|
||||
@@ -148,7 +152,8 @@ bool QCDCore::bindWidget(QWidget * w, const CDType & k) {
|
||||
bindView(w);
|
||||
}
|
||||
if (!ok) return false;
|
||||
binded_widgets[w] = k.path();
|
||||
piCout << k.name() << k.path();
|
||||
binded_widgets.insert(w, k.path());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define QCD_CORE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QMultiMap>
|
||||
#include "piobject.h"
|
||||
#include "cdutils_types.h"
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
int bindWindow(QWidget * wnd);
|
||||
int bindWidgets(QList<QWidget * > wl);
|
||||
bool bindWidget(QWidget * w);
|
||||
bool bindWidget(QWidget * w, const CDUtils::CDType & k);
|
||||
bool bindWidget(QWidget * w, const CDUtils::CDType k);
|
||||
|
||||
int unbindWindow(QWidget * wnd);
|
||||
int unbindWidgets(QList<QWidget * > wl);
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
void bindView(QWidget * v);
|
||||
EVENT_HANDLER(void, K_ChangedGlobal);
|
||||
|
||||
QMap<QWidget * , PIDeque<int> > binded_widgets;
|
||||
QMultiMap<QWidget * , PIDeque<int> > binded_widgets;
|
||||
bool updating;
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -5,10 +5,20 @@
|
||||
#include <QBrush>
|
||||
#include <QColor>
|
||||
#include "qvariantedit.h"
|
||||
#include "qad_types.h"
|
||||
|
||||
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
QList<QAD::Enumerator> CDEnum2QADEnum(const PIVector<CDType::Enumerator> & el) {
|
||||
QList<QAD::Enumerator> ret;
|
||||
piForeachC (CDType::Enumerator & e, el)
|
||||
ret << QAD::Enumerator(e.first, PI2QString(e.second));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
CDKItemModel::CDKItemModel(QObject *parent) : QAbstractItemModel(parent) {
|
||||
root = 0;
|
||||
internalRebuild();
|
||||
@@ -223,11 +233,11 @@ QVariant CDKItem::value(CDType t, int role) const {
|
||||
if (t.type() == "n") return t.toInt();
|
||||
if (t.type() == "b") return t.toBool();
|
||||
if (t.type() == "e") {
|
||||
QVariantEdit::EnumType et;
|
||||
et.enum_list = PI2QStringList(t.enumValues());
|
||||
et.value = et.enum_list.at(t.toInt());//et.enum_list.indexOf("");
|
||||
if (role == Qt::EditRole)return QVariant::fromValue<QVariantEdit::EnumType>(et);
|
||||
else return et.value;
|
||||
QAD::Enum et;
|
||||
et.enum_list = CDEnum2QADEnum(t.enumValues());
|
||||
et.selectValue(t.toInt());
|
||||
if (role == Qt::EditRole) return QVariant::fromValue<QAD::Enum>(et);
|
||||
else return et.selectedName();
|
||||
}
|
||||
return PI2QString(t.value());
|
||||
}
|
||||
@@ -296,9 +306,9 @@ void CDKDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
void CDKDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
|
||||
QVariantEdit *edit = static_cast<QVariantEdit*>(editor);
|
||||
QVariant v = edit->value();
|
||||
if (v.canConvert<QVariantEdit::EnumType>()) {
|
||||
QVariantEdit::EnumType et = v.value<QVariantEdit::EnumType>();
|
||||
model->setData(index, et.enum_list.indexOf(et.value), Qt::EditRole);
|
||||
if (v.canConvert<QAD::Enum>()) {
|
||||
QAD::Enum et = v.value<QAD::Enum>();
|
||||
model->setData(index, et.selectedValue(), Qt::EditRole);
|
||||
} else model->setData(index, v, Qt::EditRole);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace CDUtils {
|
||||
class CDSection;
|
||||
class CDType;
|
||||
}
|
||||
namespace QAD {
|
||||
class Enum;
|
||||
}
|
||||
class CDKItemModel;
|
||||
|
||||
class CDKItem {
|
||||
|
||||
Reference in New Issue
Block a user