File indexing completed on 2024-05-12 16:39:27
0001 /* This file is part of the KDE project 0002 Copyright (C) 2007 - 2009 Dag Andersen <danders@get2net.dk> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef TASKWORKPACKAGEVIEW_H 0021 #define TASKWORKPACKAGEVIEW_H 0022 0023 #include "planwork_export.h" 0024 0025 #include "kptitemmodelbase.h" 0026 0027 #include "kptviewbase.h" 0028 #include "kptganttview.h" 0029 0030 #include <KGanttView> 0031 0032 #include <QSplitter> 0033 0034 class QItemSelection; 0035 0036 0037 namespace KPlato 0038 { 0039 0040 class Project; 0041 class Node; 0042 class Document; 0043 0044 } 0045 using namespace KPlato; 0046 0047 namespace KPlatoWork 0048 { 0049 class Part; 0050 class WorkPackage; 0051 0052 class TaskWorkPackageModel; 0053 0054 class PLANWORK_EXPORT TaskWorkPackageTreeView : public DoubleTreeViewBase 0055 { 0056 Q_OBJECT 0057 public: 0058 TaskWorkPackageTreeView(Part *part, QWidget *parent); 0059 0060 0061 //void setSelectionModel(QItemSelectionModel *selectionModel); 0062 0063 TaskWorkPackageModel *itemModel() const; 0064 0065 Project *project() const; 0066 void setProject(Project *project); 0067 0068 Document *currentDocument() const; 0069 Node *currentNode() const; 0070 QList<Node*> selectedNodes() const; 0071 0072 Q_SIGNALS: 0073 void sectionsMoved(); 0074 0075 protected Q_SLOTS: 0076 void slotActivated(const QModelIndex &index); 0077 void setSortOrder(int col, Qt::SortOrder order); 0078 0079 protected: 0080 void dragMoveEvent(QDragMoveEvent *event) override; 0081 }; 0082 0083 0084 class PLANWORK_EXPORT AbstractView : public QWidget, public ViewActionLists 0085 { 0086 Q_OBJECT 0087 public: 0088 AbstractView(Part *part, QWidget *parent); 0089 0090 /// reimplement 0091 virtual void updateReadWrite(bool readwrite); 0092 /// reimplement 0093 virtual Node *currentNode() const; 0094 /// reimplement 0095 virtual Document *currentDocument() const; 0096 /// reimplement 0097 virtual QList<Node*> selectedNodes() const; 0098 0099 /// Loads context info into this view. Reimplement. 0100 virtual bool loadContext(); 0101 /// Save context info from this view. Reimplement. 0102 virtual void saveContext(); 0103 0104 /// reimplement 0105 virtual KoPrintJob *createPrintJob(); 0106 0107 Q_SIGNALS: 0108 void requestPopupMenu(const QString& name, const QPoint &pos); 0109 void selectionChanged(); 0110 0111 protected Q_SLOTS: 0112 /// Builds menu from action list 0113 virtual void slotHeaderContextMenuRequested(const QPoint &pos); 0114 0115 /// Reimplement if you have index specific context menu, standard calls slotHeaderContextMenuRequested() 0116 void slotContextMenuRequested(const QModelIndex &index, const QPoint& pos); 0117 0118 /// Should not need to be reimplemented 0119 virtual void slotContextMenuRequested(KPlato::Node *node, const QPoint& pos); 0120 /// Should not need to be reimplemented 0121 virtual void slotContextMenuRequested(KPlato::Document *doc, const QPoint& pos); 0122 0123 /// Calls saveContext(), connect to this to have configuration saved 0124 virtual void sectionsMoved(); 0125 0126 protected: 0127 Part *m_part; 0128 0129 }; 0130 0131 class PLANWORK_EXPORT TaskWorkPackageView : public AbstractView 0132 { 0133 Q_OBJECT 0134 public: 0135 TaskWorkPackageView(Part *part, QWidget *parent); 0136 ~TaskWorkPackageView() override; 0137 0138 void setupGui(); 0139 0140 TaskWorkPackageModel *itemModel() const { return m_view->itemModel(); } 0141 0142 void updateReadWrite(bool readwrite) override; 0143 Node *currentNode() const override; 0144 Document *currentDocument() const override; 0145 QList<Node*> selectedNodes() const override; 0146 0147 /// Loads context info into this view. Reimplement. 0148 bool loadContext() override; 0149 /// Save context info from this view. Reimplement. 0150 void saveContext() override; 0151 0152 using AbstractView::slotContextMenuRequested; 0153 0154 protected Q_SLOTS: 0155 void slotOptions(); 0156 void slotSplitView(); 0157 0158 void slotContextMenuRequested(const QModelIndex &index, const QPoint& pos); 0159 void slotSelectionChanged(const QModelIndexList &lst); 0160 0161 protected: 0162 void updateActionsEnabled(bool on); 0163 0164 private: 0165 TaskWorkPackageTreeView *m_view; 0166 0167 }; 0168 0169 //------------- 0170 class GanttItemDelegate : public KPlato::GanttItemDelegate 0171 { 0172 Q_OBJECT 0173 public: 0174 enum Brushes { Brush_Normal, Brush_Late, Brush_NotScheduled, Brush_Finished, Brush_NotReadyToStart, Brush_ReadyToStart }; 0175 0176 explicit GanttItemDelegate(QObject *parent = 0); 0177 0178 void paintGanttItem(QPainter* painter, const KGantt::StyleOptionGanttItem& opt, const QModelIndex& idx) override; 0179 QString toolTip(const QModelIndex &idx) const override; 0180 0181 protected: 0182 bool showStatus; 0183 QMap<int, QBrush> m_brushes; 0184 }; 0185 0186 class GanttView : public KPlato::GanttViewBase 0187 { 0188 Q_OBJECT 0189 public: 0190 GanttView(Part *part, QWidget *parent); 0191 ~GanttView() override; 0192 0193 TaskWorkPackageModel *itemModel() const; 0194 void setProject(Project *project); 0195 Project *project() const { return m_project; } 0196 0197 GanttItemDelegate *delegate() const { return m_ganttdelegate; } 0198 0199 QList<Node*> selectedNodes() const; 0200 Node *currentNode() const; 0201 Document *currentDocument() const; 0202 0203 /// Loads context info into this view. Reimplement. 0204 bool loadContext(const KoXmlElement &context) override; 0205 /// Save context info from this view. Reimplement. 0206 void saveContext(QDomElement &context) const override; 0207 0208 Q_SIGNALS: 0209 void headerContextMenuRequested(const QPoint&); 0210 void selectionChanged(const QModelIndexList&); 0211 void sectionsMoved(); 0212 0213 protected Q_SLOTS: 0214 void slotSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); 0215 void slotRowsInserted(const QModelIndex &parent, int start, int end); 0216 void slotRowsRemoved(const QModelIndex &parent, int start, int end); 0217 0218 void updateDateTimeGrid(KPlatoWork::WorkPackage *wp); 0219 0220 protected: 0221 Part *m_part; 0222 Project *m_project; 0223 GanttItemDelegate *m_ganttdelegate; 0224 TaskWorkPackageModel *m_itemmodel; 0225 KGantt::TreeViewRowController *m_rowController; 0226 }; 0227 0228 class PLANWORK_EXPORT TaskWPGanttView : public AbstractView 0229 { 0230 Q_OBJECT 0231 public: 0232 TaskWPGanttView(Part *part, QWidget *parent); 0233 ~TaskWPGanttView() override; 0234 0235 void setupGui(); 0236 0237 TaskWorkPackageModel *itemModel() const { return m_view->itemModel(); } 0238 0239 Node *currentNode() const override; 0240 QList<Node*> selectedNodes() const override; 0241 Document *currentDocument() const override; 0242 0243 /// Loads context info into this view. Reimplement. 0244 bool loadContext() override; 0245 /// Save context info from this view. Reimplement. 0246 void saveContext() override; 0247 0248 using AbstractView::slotContextMenuRequested; 0249 0250 protected Q_SLOTS: 0251 void slotContextMenuRequested(const QModelIndex &index, const QPoint& pos); 0252 void slotSelectionChanged(const QModelIndexList &lst); 0253 void slotOptions(); 0254 0255 private: 0256 GanttView *m_view; 0257 0258 }; 0259 0260 } //namespace KPlatoWork 0261 0262 0263 #endif