You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
189 lines
4.2 KiB
C++
189 lines
4.2 KiB
C++
#pragma once
|
|
|
|
#include <QPixmap>
|
|
#include <QVector>
|
|
#include <QString>
|
|
#include <QHash>
|
|
#include <QVector>
|
|
#include <QSet>
|
|
#include <QAbstractScrollArea>
|
|
|
|
#include "ZxDynamic.h"
|
|
#include "ZxPtyItem.h"
|
|
#include "iProperty_global.h"
|
|
|
|
class ZxPtyFileManager;
|
|
class ZxPtyAttributeFile;
|
|
class ZxXpfNode;
|
|
|
|
class I_PROPERTY_EXPORT ZxPtyPano
|
|
: public QAbstractScrollArea
|
|
, virtual public IxPtyPano
|
|
, virtual public IxDynObj
|
|
{
|
|
Q_OBJECT
|
|
ZX_DECLARE_DYNAMIC
|
|
|
|
public:
|
|
|
|
explicit ZxPtyPano();
|
|
~ZxPtyPano();
|
|
|
|
virtual void paintEvent(QPaintEvent *);
|
|
virtual void mousePressEvent(QMouseEvent *);
|
|
virtual void mouseDoubleClickEvent(QMouseEvent* e);
|
|
virtual void mouseReleaseEvent(QMouseEvent *);
|
|
virtual void mouseMoveEvent(QMouseEvent *);
|
|
virtual void resizeEvent(QResizeEvent *);
|
|
|
|
virtual IxPtyItem* addGroup(const QString& key, bool expand = true, bool visible = true);
|
|
virtual IxPtyItem* add(ZX_PROPERTY_CHANGED_CALLBACK callback, const QString& key, const QVariant& var, IxPtyItem::ItemType type = IxPtyItem::typeDefault);
|
|
|
|
virtual void beginSession(const QString& configName, IxInterface* pSessionOwner);
|
|
virtual void endSession();
|
|
|
|
virtual void beginObject(IxPtySource* p);
|
|
virtual void endObject();
|
|
|
|
virtual IxPtyItem* findPropertyItem(const QString& sKey);
|
|
|
|
virtual void clear(IxInterface* pSessionOwner);
|
|
|
|
// 获取当前配置文件. 这个文件是根据上层应用模块设置的配置名来加载的, 每次填表都会更新.
|
|
ZxPtyAttributeFile* getAttributeFile();
|
|
|
|
IxPtySource* getCurObject() { return m_pObject; }
|
|
|
|
signals:
|
|
|
|
void helpMessage(const QString& help);
|
|
|
|
protected slots:
|
|
void onConfigReloaded();
|
|
|
|
private:
|
|
|
|
void paintGrid(QPainter& painter);
|
|
void paintHeader(QPainter& painter);
|
|
void paintGroups(QPainter& painter);
|
|
void paintItems(QPainter& painter);
|
|
void onActiveItemChanged(ZxPtyItem* item);
|
|
|
|
enum HitTestPart
|
|
{
|
|
htNone,
|
|
htExpander,
|
|
htLeftCol,
|
|
htRightCol,
|
|
htSplit
|
|
};
|
|
|
|
class HitTestResult
|
|
{
|
|
public:
|
|
int row;
|
|
HitTestPart part;
|
|
bool isValid() const;
|
|
int col();
|
|
};
|
|
|
|
private:
|
|
|
|
void updateLayout();
|
|
void doLayout();
|
|
|
|
ZxPtyItem* getOrCreate(const QString& key, const QVariant& initVar, bool* bJustCreated);
|
|
|
|
ZxXpfNode* getItemConfig(const QString& key);
|
|
// ZxXpfNode* getParentItemConfig(ZxXpfNode* pItemConfig);
|
|
|
|
int indentWidth() const;
|
|
|
|
int getAndIncObjectSn();
|
|
|
|
QRect getLeftRect(int virtualRow);
|
|
QRect getRightRect(int virtualRow);
|
|
|
|
HitTestResult hitTest(int x, int y);
|
|
|
|
void expand(ZxPtyItem* p);
|
|
void collapse(ZxPtyItem* p);
|
|
|
|
void activateItem(ZxPtyItem* p);
|
|
void clearItems();
|
|
|
|
int getVerticalScrollPos() const;
|
|
void scrollContentsBy(int dx, int dy);
|
|
|
|
int right() const;
|
|
void updateItem(ZxPtyItem* item); // 刷新重绘
|
|
|
|
void saveXSplit();
|
|
void loadXSplit();
|
|
|
|
void normalizeXSplit();
|
|
IxPtyItemEditor* createEditor(const QString& name);
|
|
|
|
void releaseEditor(IxPtyItemEditor* p);
|
|
|
|
private:
|
|
|
|
bool m_bNeedLayout;
|
|
|
|
QVector<ZxPtyItem*> m_vecRealRows;
|
|
QVector<ZxPtyItem*> m_vecVirtualRows;
|
|
|
|
QHash<QString, ZxPtyItem*> m_map;
|
|
ZxPtyFileManager* m_pConfigManager;
|
|
mutable ZxPtyAttributeFile* m_pAttribueFile;
|
|
mutable QString m_sConfig;
|
|
|
|
int m_nSessionId;
|
|
IxInterface* m_pSessionOwner;
|
|
|
|
IxPtySource* m_pObject;
|
|
int m_nObjectCount;
|
|
IxPtyItem* m_pCurrentItem;
|
|
|
|
QHash<QString, int> m_objectSn;
|
|
bool m_bInitializingSession;
|
|
|
|
int m_xSplit;
|
|
QPixmap m_pixExpand;
|
|
QPixmap m_pixCollapse;
|
|
friend class ZxPtyItem;
|
|
QColor m_groupBackColor[3];
|
|
QColor m_groupFrontColor[3];
|
|
QColor m_frameBackColor;
|
|
double m_dNextItemOrder;
|
|
bool m_bClearEntered;
|
|
|
|
// static QSet<ZxPtyPano*> _setAllPtyPanos;
|
|
QList<ZxPtyItem*> itemsToBeDeleted;
|
|
bool m_bHitSplit;
|
|
// 控件池, 避免反复创建/删除, 否则Debug版会比较卡
|
|
typedef QVector<IxPtyItemEditor*> ItemEditorVector;
|
|
QHash<QString, ItemEditorVector> m_editorPool;
|
|
|
|
int m_nROW_HEIGHT;
|
|
int m_nINDENT_WIDTH;
|
|
int m_nINDENT_ICON_WIDTH;
|
|
int m_nINDENT_ICON_MARGIN_H;
|
|
int m_nINDENT_ICON_MARGIN_V;
|
|
int m_nLEFT_PADDING;
|
|
int m_nRIGHT_PADDING;
|
|
int m_nBOTTOM_PADDING;
|
|
int m_nCELL_PADDING_V;
|
|
int m_nCELL_PADDING_H;
|
|
int m_nCELL_SPACING;
|
|
|
|
friend class ZxPtyFileManager;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|