198 lines
5.3 KiB
C++
198 lines
5.3 KiB
C++
#ifndef QTFORMULADIALOGFACTORY_H
|
|
#define QTFORMULADIALOGFACTORY_H
|
|
|
|
#include <QLabel>
|
|
#include <QToolButton>
|
|
#include <QComboBox>
|
|
#include <QTableWidget>
|
|
#include <QDialog>
|
|
#include <QPushButton>
|
|
#include <QListWidget>
|
|
#include <QSpinBox>
|
|
#include <QStack>
|
|
#include <QMap>
|
|
#include "qteditorfactory.h"
|
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
class CQtFormulaDialogfactoryPrivate;
|
|
class CQtFormulaDialogPropertyManagerPrivate;
|
|
|
|
typedef QVector<QVector<QString> > ViewData;
|
|
|
|
class QTPROPERTYBROWSER_EXPORT CQtFormulaDialogPropertyManager : public QtAbstractPropertyManager
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
CQtFormulaDialogPropertyManager(QObject *parent = 0);
|
|
~CQtFormulaDialogPropertyManager();
|
|
|
|
QString value(const QtProperty *property) const;
|
|
QStringList enumNames(const QtProperty *property) const;
|
|
QMap<int, QString> enumIcons(const QtProperty *property) const;
|
|
|
|
void setFieldDataList(const QStringList &fieldList);
|
|
void setTableDataList(const QStringList &tableList);
|
|
void setTableModelData(const ViewData &modelData);
|
|
|
|
|
|
|
|
QStringList tableDataList;
|
|
QStringList fieldDataList;
|
|
ViewData tableModelData;
|
|
//QMap<QString,QString> m_mapWellInfoFields;
|
|
//QString cellFormula;
|
|
//QString defaultDir;
|
|
//QString filter;
|
|
|
|
public Q_SLOTS:
|
|
void setValue(QtProperty *property, QString val);
|
|
/* void onGraphicsHeadCellFormula(const QString &formla);*/
|
|
|
|
Q_SIGNALS:
|
|
void valueChanged(QtProperty *property, const QVariant &);
|
|
|
|
void tableChanged(const QString &);
|
|
|
|
void fieldListChanged(const QStringList&);
|
|
void tableListChanged(const QStringList&);
|
|
void tableModelDataChanged(const ViewData&);
|
|
|
|
|
|
protected:
|
|
QString valueText(const QtProperty *property) const;
|
|
virtual void initializeProperty(QtProperty *property);
|
|
virtual void uninitializeProperty(QtProperty *property);
|
|
private:
|
|
QScopedPointer<CQtFormulaDialogPropertyManagerPrivate> d_ptr;
|
|
|
|
|
|
Q_DECLARE_PRIVATE(CQtFormulaDialogPropertyManager)
|
|
Q_DISABLE_COPY(CQtFormulaDialogPropertyManager)
|
|
};
|
|
|
|
|
|
|
|
class QTPROPERTYBROWSER_EXPORT CQtFormulaDialogPropertyManagerPrivate
|
|
{
|
|
CQtFormulaDialogPropertyManager *q_ptr;
|
|
Q_DECLARE_PUBLIC(CQtFormulaDialogPropertyManager)
|
|
public:
|
|
|
|
typedef QMap<const QtProperty *, QString> PropertyValueMap;
|
|
PropertyValueMap m_values;
|
|
};
|
|
|
|
|
|
class CQtFormulaDialogFactoryPrivate;
|
|
|
|
class QTPROPERTYBROWSER_EXPORT CQtFormulaDialogFactory : public QtAbstractEditorFactory<CQtFormulaDialogPropertyManager>
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
CQtFormulaDialogFactory(QObject *parent = 0);
|
|
~CQtFormulaDialogFactory();
|
|
|
|
protected:
|
|
void connectPropertyManager(CQtFormulaDialogPropertyManager *manager);
|
|
QWidget *createEditor(CQtFormulaDialogPropertyManager *manager, QtProperty *property,
|
|
QWidget *parent);
|
|
void disconnectPropertyManager(CQtFormulaDialogPropertyManager *manager);
|
|
private:
|
|
QScopedPointer<CQtFormulaDialogFactoryPrivate> d_ptr;
|
|
Q_DECLARE_PRIVATE(CQtFormulaDialogFactory)
|
|
Q_DISABLE_COPY(CQtFormulaDialogFactory)
|
|
Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, QString))
|
|
Q_PRIVATE_SLOT(d_func(), void slotSetValue(QString))
|
|
Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *))
|
|
|
|
};
|
|
|
|
|
|
class CQtFormulaDialogEditWidget;
|
|
class QTPROPERTYBROWSER_EXPORT CQtFormulaDialogFactoryPrivate : public EditorFactoryPrivate<CQtFormulaDialogEditWidget>
|
|
{
|
|
CQtFormulaDialogFactory *q_ptr;
|
|
Q_DECLARE_PUBLIC(CQtFormulaDialogFactory)
|
|
public:
|
|
|
|
void slotPropertyChanged(QtProperty *property, QString value);
|
|
void slotSetValue(QString value);
|
|
};
|
|
|
|
// CQtFormulaDialogEditWidget
|
|
QString GetImagePath();
|
|
class CQtFormulaDialogEditWidget : public QWidget {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
CQtFormulaDialogEditWidget(QWidget *parent);
|
|
~CQtFormulaDialogEditWidget();
|
|
|
|
bool eventFilter(QObject *obj, QEvent *ev);
|
|
QStringList tableDataList;
|
|
QStringList fieldList;
|
|
ViewData tableModelData;
|
|
QMap<QString,QString> mapWellInfoFields;
|
|
|
|
|
|
public Q_SLOTS:
|
|
void setValue(const QString &value);
|
|
void setComboxFieldDataList(const QStringList& list);
|
|
void setComboxTableDataList(const QStringList& list);
|
|
void setTableModeData(const ViewData &tableData);
|
|
void buttonClicked();
|
|
private Q_SLOTS:
|
|
|
|
void onAcceptOk();
|
|
void onCancel();
|
|
//compute slots
|
|
void onAddCompute();
|
|
void onSubtractCompute();
|
|
void onMultipyCompute();
|
|
void onDivideCompute();
|
|
// fun
|
|
void onAppend();
|
|
void onUndo();
|
|
void onCellPressed(int row, int column);
|
|
Q_SIGNALS:
|
|
void valueChanged(const QString &value);
|
|
void tableChanged(const QString &tableName);
|
|
private:
|
|
void initUI();
|
|
void showFormulaDlg();
|
|
void bindTableData();
|
|
void setComboxFieldDataList();
|
|
void setComboxTableDataList();
|
|
void initConnect();
|
|
QString buildTableFormulaRow(const QString &computeFlag="");
|
|
bool isAppendValidate(const QString &rowItem);
|
|
void appendComputeSymbol(QPushButton *button);
|
|
QString combinationFormual();
|
|
void bindCellFormula();
|
|
|
|
private:
|
|
QString m_formula;
|
|
QLabel *m_label;
|
|
QToolButton *m_button;
|
|
QComboBox *m_tableCombox,*m_fieldCombox;
|
|
|
|
QTableWidget *m_tableView;
|
|
QListWidget *m_listWidget;
|
|
QSpinBox *m_smallBox;
|
|
QPushButton *btnAccpted,*btnCancel,*btnAddCompute,*btnSubtractCompute,
|
|
*btnMultiplyCompute,*btnDivideCompute,*btnAppend,*btnUndo;
|
|
QLabel *m_lable1;
|
|
QLineEdit *editline;
|
|
QLabel*NoLabel;
|
|
QLineEdit *Noline;
|
|
QDialog *formulaDialog;
|
|
QLabel *lblTable,*lblField,*lblSmall;
|
|
QList<QString> m_computeSymbol;
|
|
};
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
#endif
|