00001 #ifndef COSTCENTRECHILD_H 00002 #define COSTCENTRECHILD_H 00003 00004 #include <QDomDocument> 00005 #include <QComboBox> 00006 00007 #include "childwindow.h" 00008 #include "../Models/costcentremodel.h" 00009 #include "../Models/costcentrefiltermodel.h" 00010 00011 QT_BEGIN_NAMESPACE 00012 class QTableView; 00013 class QItemSelection; 00014 class QItemSelectionModel; 00015 QT_END_NAMESPACE 00016 00017 class CostCentreChild : public ChildWindow 00018 { 00019 Q_OBJECT 00020 00021 public: 00022 CostCentreChild(); 00023 00024 void setModel(CostCentreModel *model); 00025 virtual CostCentreModel* model() const 00026 { 00027 return table; 00028 } 00029 00030 void setCostTypeModel(CostTypeModel *costtype); 00031 CostTypeModel* costTypeModel() const 00032 { 00033 return table->costTypeModel; 00034 } 00035 00036 void setProxyModel(CostCentreFilterModel *model); 00037 CostCentreFilterModel *proxyModel() const 00038 { 00039 return filterModel; 00040 } 00041 00042 void newFile(); 00043 bool loadDocument(const QDomElement fileName); 00044 00045 void addPosition(QStringList); 00046 void addCostCentre(QString name, int type); 00047 00048 void setBase(QString columnName, QString); 00049 void setBase(int column, QString); 00050 00051 QTableView* tableViewWidget() const 00052 { 00053 return tableView; 00054 } 00055 00056 private: 00057 void createControls(); 00058 void createCostCentreTypeDelegate(); 00059 void createActions(); 00060 00061 bool maybeSave(); 00062 00063 void removePosition(); 00064 void removeCostCentre(); 00065 00066 QTableView *tableView; 00067 CostCentreModel *table; 00068 CostCentreFilterModel *filterModel; 00069 00070 QAction *deleteAction; 00071 QAction *editAction; 00072 00073 private slots: 00074 void removeSelection(); 00075 void editEntry(); 00076 void enableEditRemoveActions(bool); 00077 void costTypeRowChanged(int rowid); 00078 void costTypeRowRemoved(int rowid); 00079 00080 protected: 00081 void closeEvent(QCloseEvent *event); 00082 00083 signals: 00084 void setMdiAreaEnabled(bool); 00085 void editInformationAvailable(const CostCentreModel *table, const QModelIndexList affectedRows); 00086 }; 00087 00088 class CostCentreTypeComboBox : public QComboBox 00089 { 00090 Q_OBJECT 00091 Q_PROPERTY(QString type READ type WRITE setType USER true) 00092 00093 public: 00094 CostCentreTypeComboBox(QWidget *widget = 0); 00095 00096 QString type() const; 00097 void setType(QString c); 00098 00099 private: 00100 void populateList(); 00101 }; 00102 00103 #endif