Tianchi  v0.0.2 build 20130701
C++ library for Qt with VC & mingW
tctreeex.h
1 // **************************************************************************
2 // Tianchi C++ library for Qt (open source)
3 // 天池共享源码库
4 // 版权所有 (C) 天池共享源码库开发组
5 // 授权协议:请阅读天池共享源码库附带的授权协议
6 // **************************************************************************
7 // 文档说明:QTreeWidget 控件扩展
8 // ==========================================================================
9 // 开发日志:
10 // 日期 人员 说明
11 // --------------------------------------------------------------------------
12 // 2013.05.03 圣域天子 建立
13 //
14 // ==========================================================================
16 // ==========================================================================
17 #ifndef TIANCHI_TCTREEEX_H
18 #define TIANCHI_TCTREEEX_H
19 
20 #include <tianchi/tcglobal.h>
21 #include <tianchi/file/tcmsexcel.h>
22 
23 #include <QTreeWidget>
24 #include <QLabel>
25 #include <QDoubleSpinBox>
26 
27 class TcTreeExPrivate;
28 
31 class TIANCHI_API TcTreeEx
32 {
33 public:
34  enum ExportType
35  {
36  TextFile = 1
37  , MSExcel = 2
38  };
41  TcTreeEx(QTreeWidget* widget=0);
42 
45  void setWidget(QTreeWidget* widget);
46 
49  void setExportType(int type);
50 
53  void setSelectedState(int state);
54 
57  void setTextFileName(const QString& filename);
58 
61  void setMSExcelObject(TcMSExcel* excel, bool hasHeader=true, int startRow=1, int startCol=1);
62 
64  int save();
65 
66 private:
67  Q_DISABLE_COPY(TcTreeEx)
68  Q_DECLARE_PRIVATE(TcTreeEx)
69  TcTreeExPrivate* d_ptr;
70 
71 public:
72  static void createColumnMenu(QTreeWidget* widget, QWidget* object, const QString& methodName);
73 
74  static void setColumnBolds(QTreeWidget* widget);
75  static void setColumnWidth(QTreeWidget* widget, int column, int width, bool hide=false);
76  static void setColumnStyle(QTreeWidget* widget, int fontSize=8, const QString &fontName="Tahoma");
77 
78  static void CopyCellObject(QTreeWidget* view, int copyMode);
79 };
80 
81 class TIANCHI_API TcTreeItem : public QTreeWidgetItem
82 {
83 public:
84  void setCellFont(int col, bool bold=false, int alignment=Qt::AlignVCenter | Qt::AlignLeft);
85  void setCellStyle(int startCol=-1, int endCol=-1,
86  bool bold=true, int alignment=Qt::AlignVCenter | Qt::AlignRight,
87  int cellHeight=25);
88  void setCellColor(int col, QColor color);
89 
90  QLabel* createLabel(int col, const QString& htmlText, const QVariant& data=QVariant());
91  QDoubleSpinBox* createDoubleSpinBox(int col,
92  int decimals, double min, double max, double step, double value);
93  double readDoubleSpinBoxValue(int col);
94 
95  void showValue(int column, const char* text, const QVariant& data=QVariant(), int size=0);
96  void showValue(int column, const QString& text, const QVariant& data=QVariant(), int size=0);
97  void showValue(int column, const QByteArray& text, const QVariant& data=QVariant(), int size=0);
98  void showValue(int column, double value);
99  void showValue(int column, double value, int digits);
100  void showPrice(int column, double value, int digits=0);
101  void showPercent(int column, double value=0.0, int digits=0);
102 };
103 
104 #endif // TIANCHI_TCTREEEX_H