1 | /* This file is part of the KDE project |
2 | Copyright (C) 1998, 1999, 2000 Torben Weis <weis@kde.org> |
3 | Copyright (C) 2002 - 2010 Dag Andersen <danders@get2net.dk> |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | * Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef KPTVIEW_H |
22 | #define KPTVIEW_H |
23 | |
24 | #include "kplato_export.h" |
25 | |
26 | #include <KoView.h> |
27 | |
28 | #include "kptcontext.h" |
29 | #include "kptviewbase.h" |
30 | |
31 | #include <QMenu> |
32 | #include <QDockWidget> |
33 | #include <QTimer> |
34 | #include <QMap> |
35 | #include <QPointer> |
36 | #include <QPrintDialog> |
37 | |
38 | #include <kconfigdialog.h> |
39 | #include <kparts/event.h> |
40 | |
41 | class QStackedWidget; |
42 | class QSplitter; |
43 | class KUndo2Command; |
44 | |
45 | class KAction; |
46 | class KToggleAction; |
47 | class QLabel; |
48 | class KConfigSkeleton; |
49 | class KConfigSkeletonItem; |
50 | |
51 | class KoView; |
52 | |
53 | namespace KPlato |
54 | { |
55 | |
56 | class View; |
57 | class ViewBase; |
58 | class ViewListItem; |
59 | class ViewListWidget; |
60 | struct ViewInfo; |
61 | class AccountsView; |
62 | class GanttView; |
63 | class PertEditor; |
64 | class ResourceView; |
65 | class AccountsEditor; |
66 | class TaskEditor; |
67 | class CalendarEditor; |
68 | class ScheduleEditor; |
69 | class ScheduleManager; |
70 | class CalculateScheduleCmd; |
71 | class ResourceAssignmentView; |
72 | class TaskStatusView; |
73 | class TaskModuleModel; |
74 | class Calendar; |
75 | class MainDocument; |
76 | class Part; |
77 | class Node; |
78 | class Project; |
79 | class Task; |
80 | class MainSchedule; |
81 | class Schedule; |
82 | class Resource; |
83 | class ResourceGroup; |
84 | class Relation; |
85 | class Context; |
86 | class ViewAdaptor; |
87 | class HtmlView; |
88 | class ReportView; |
89 | class ReportWidget; |
90 | |
91 | class ReportDesignDialog; |
92 | |
93 | class DockWidget; |
94 | |
95 | class ConfigDialog : public KConfigDialog |
96 | { |
97 | Q_OBJECT |
98 | public: |
99 | ConfigDialog( QWidget *parent, const QString &name, KConfigSkeleton *config ); |
100 | |
101 | protected slots: |
102 | /// Return true if any widget has changed |
103 | virtual bool hasChanged(); |
104 | /** |
105 | * Update the settings from the dialog. |
106 | * Virtual function for custom additions. |
107 | * |
108 | * Example use: User clicks Ok or Apply button in a configure dialog. |
109 | */ |
110 | virtual void updateSettings(); |
111 | |
112 | /** |
113 | * Update the dialog based on the settings. |
114 | * Virtual function for custom additions. |
115 | * |
116 | * Example use: Initialisation of dialog. |
117 | * Example use: User clicks Reset button in a configure dialog. |
118 | */ |
119 | virtual void updateWidgets(); |
120 | |
121 | /** |
122 | * Update the dialog based on the default settings. |
123 | * Virtual function for custom additions. |
124 | * |
125 | * Example use: User clicks Defaults button in a configure dialog. |
126 | */ |
127 | virtual void updateWidgetsDefault(); |
128 | |
129 | /** |
130 | * Returns whether the current state of the dialog is |
131 | * the same as the default configuration. |
132 | */ |
133 | virtual bool isDefault(); |
134 | |
135 | private: |
136 | KConfigSkeleton *m_config; |
137 | QMap<QString, QByteArray> m_signalsmap; |
138 | QMap<QWidget*, KConfigSkeletonItem*> m_itemmap; |
139 | QMap<QString, QByteArray> m_propertymap; |
140 | }; |
141 | |
142 | //------------- |
143 | class KPLATO_EXPORT View : public KoView |
144 | { |
145 | Q_OBJECT |
146 | |
147 | public: |
148 | explicit View(KoPart *part, MainDocument *doc, QWidget *parent = 0); |
149 | ~View(); |
150 | |
151 | MainDocument *getPart() const; |
152 | |
153 | KoPart *getKoPart() const; |
154 | |
155 | Project& getProject() const; |
156 | |
157 | QMenu *( const QString& name ); |
158 | |
159 | virtual bool loadContext(); |
160 | virtual void saveContext( QDomElement &context ) const; |
161 | |
162 | /// Load the workpackage from @p url into @p project. Return true if successful, else false. |
163 | bool loadWorkPackage( Project &project, const KUrl &url ); |
164 | |
165 | QWidget *canvas() const; |
166 | |
167 | KoPageLayout pageLayout() const; |
168 | |
169 | ScheduleManager *currentScheduleManager() const; |
170 | long activeScheduleId() const; |
171 | void setActiveSchedule( long id ); |
172 | |
173 | /// Returns the default view information like standard name and tooltip for view type @p type |
174 | ViewInfo defaultViewInfo( const QString &type ) const; |
175 | /// Returns the default category information like standard name and tooltip for category type @p type |
176 | ViewInfo defaultCategoryInfo( const QString &type ) const; |
177 | |
178 | ViewBase *createTaskEditor( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
179 | ViewBase *createResourceEditor( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
180 | ViewBase *createAccountsEditor( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
181 | ViewBase *createCalendarEditor( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
182 | ViewBase *createScheduleHandler( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
183 | ScheduleEditor *createScheduleEditor( QWidget *parent ); |
184 | ViewBase *createScheduleEditor( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
185 | ViewBase *createDependencyEditor( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
186 | ViewBase *createPertEditor( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
187 | ViewBase *createProjectStatusView( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
188 | ViewBase *createPerformanceStatusView( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
189 | ViewBase *createTaskStatusView( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
190 | ViewBase *createTaskView( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
191 | ViewBase *createTaskWorkPackageView( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
192 | ViewBase *createGanttView( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
193 | ViewBase *createMilestoneGanttView( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
194 | ViewBase *createResourceAppointmentsView( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
195 | ViewBase *createResourceAppointmentsGanttView( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
196 | ViewBase *createAccountsView( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
197 | ViewBase *createResourceAssignmentView( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
198 | ViewBase *createChartView( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
199 | ViewBase *createReportView( ViewListItem *cat, const QString &tag, const QString &name = QString(), const QString &tip = QString(), int index = -1 ); |
200 | |
201 | KoPrintJob * createPrintJob(); |
202 | QPrintDialog* createPrintDialog(KoPrintJob*, QWidget*); |
203 | |
204 | virtual KoZoomController *zoomController() const { |
205 | return 0; |
206 | } |
207 | |
208 | signals: |
209 | void currentScheduleManagerChanged( ScheduleManager *sm ); |
210 | |
211 | public slots: |
212 | void slotUpdate(); |
213 | void slotCreateTemplate(); |
214 | void slotCreateNewProject(); |
215 | void slotEditResource(); |
216 | void slotEditResource( Resource *resource ); |
217 | void slotEditCut(); |
218 | void slotEditCopy(); |
219 | void slotEditPaste(); |
220 | void slotRefreshView(); |
221 | void slotViewSelector( bool show ); |
222 | |
223 | void slotAddTask(); |
224 | void slotAddSubTask(); |
225 | void slotAddMilestone(); |
226 | void slotAddSubMilestone(); |
227 | void slotProjectEdit(); |
228 | void slotDefineWBS(); |
229 | void slotCurrencyConfig(); |
230 | |
231 | void slotCreateView(); |
232 | |
233 | void slotConfigure(); |
234 | void slotIntroduction(); |
235 | |
236 | void slotAddRelation( Node *par, Node *child ); |
237 | void slotModifyRelation( Relation *rel ); |
238 | void slotAddRelation( Node *par, Node *child, int linkType ); |
239 | void slotModifyRelation( Relation *rel, int linkType ); |
240 | void slotModifyRelation(); |
241 | void slotDeleteRelation(); |
242 | |
243 | void slotRenameNode( Node *node, const QString& name ); |
244 | |
245 | void ( const QString& , const QPoint &pos ); |
246 | void ( const QString& , const QPoint &pos, ViewListItem *item ); |
247 | |
248 | void addViewListItem( const ViewListItem *item, const ViewListItem *parent, int index ); |
249 | void removeViewListItem( const ViewListItem *item ); |
250 | |
251 | protected slots: |
252 | void slotGuiActivated( ViewBase *view, bool ); |
253 | void slotViewActivated( ViewListItem*, ViewListItem* ); |
254 | void slotPlugScheduleActions(); |
255 | void slotViewSchedule( QAction *act ); |
256 | void slotScheduleChanged( MainSchedule* ); |
257 | void slotScheduleAdded( const MainSchedule * ); |
258 | void slotScheduleRemoved( const MainSchedule * ); |
259 | void slotSelectionChanged( ScheduleManager *sm ); |
260 | |
261 | void slotAddScheduleManager( Project *project ); |
262 | void slotDeleteScheduleManager( Project *project, ScheduleManager *sm ); |
263 | void slotMoveScheduleManager( ScheduleManager *sm, ScheduleManager *parent, int index ); |
264 | void slotCalculateSchedule( Project*, ScheduleManager* ); |
265 | void slotBaselineSchedule( Project *project, ScheduleManager *sm ); |
266 | |
267 | void slotProjectWorktime(); |
268 | |
269 | void slotOpenNode(); |
270 | void slotOpenNode( Node *node ); |
271 | void slotTaskProgress(); |
272 | void slotTaskDescription(); |
273 | void slotDeleteTask( QList<Node*> lst ); |
274 | void slotDeleteTask( Node *node ); |
275 | void slotDeleteTask(); |
276 | void slotIndentTask(); |
277 | void slotUnindentTask(); |
278 | void slotMoveTaskUp(); |
279 | void slotMoveTaskDown(); |
280 | |
281 | void slotConnectNode(); |
282 | |
283 | void slotDeleteResource( Resource *resource ); |
284 | void slotDeleteResourceGroup( ResourceGroup *group ); |
285 | void slotDeleteResourceObjects( QObjectList ); |
286 | |
287 | void slotCurrentChanged( int ); |
288 | |
289 | void slotInsertFile(); |
290 | |
291 | void slotWorkPackageLoaded(); |
292 | void slotMailWorkpackage( Node *node, Resource *resource = 0 ); |
293 | void slotMailWorkpackages( const QList<Node*> &nodes, Resource *resource = 0 ); |
294 | |
295 | void slotOpenUrlRequest( HtmlView *v, const KUrl &url ); |
296 | |
297 | void slotProjectCalculated( ScheduleManager *sm ); |
298 | |
299 | void slotUpdateViewInfo( ViewListItem *itm ); |
300 | |
301 | void slotOpenReportFile(); |
302 | void slotModifyReportDefinition( KUndo2Command *cmd ); |
303 | |
304 | void saveTaskModule( const KUrl &url, Project *project ); |
305 | void removeTaskModule( const KUrl &url ); |
306 | |
307 | protected: |
308 | virtual void guiActivateEvent( bool activated ); |
309 | virtual void updateReadWrite( bool readwrite ); |
310 | |
311 | QList<QAction*> sortedActionList(); |
312 | QAction *addScheduleAction( Schedule *sch ); |
313 | void setLabel( ScheduleManager *sm = 0 ); |
314 | Task *currentTask() const; |
315 | Node *currentNode() const; |
316 | Resource *currentResource(); |
317 | ResourceGroup *currentResourceGroup(); |
318 | Calendar *currentCalendar(); |
319 | void updateView( QWidget *widget ); |
320 | |
321 | ViewBase *currentView() const; |
322 | |
323 | ViewBase *createWelcomeView(); |
324 | |
325 | private slots: |
326 | void slotActionDestroyed( QObject *o ); |
327 | void slotViewListItemRemoved( ViewListItem *item ); |
328 | void slotViewListItemInserted( ViewListItem *item, ViewListItem *parent, int index ); |
329 | |
330 | void slotCreateReportView( ReportDesignDialog *dlg ); |
331 | |
332 | void slotProjectEditFinished( int result ); |
333 | void slotTaskEditFinished( int result ); |
334 | void slotSummaryTaskEditFinished( int result ); |
335 | void slotEditResourceFinished( int result ); |
336 | void slotProjectWorktimeFinished( int result ); |
337 | void slotDefineWBSFinished( int result ); |
338 | void slotCurrencyConfigFinished( int result ); |
339 | void slotInsertFileFinished( int result ); |
340 | void slotAddSubTaskFinished( int result ); |
341 | void slotAddTaskFinished( int result ); |
342 | void slotAddSubMilestoneFinished( int result ); |
343 | void slotAddMilestoneFinished( int result ); |
344 | void slotTaskProgressFinished( int result ); |
345 | void slotMilestoneProgressFinished( int result ); |
346 | void slotTaskDescriptionFinished( int result ); |
347 | void slotAddRelationFinished( int result ); |
348 | void slotModifyRelationFinished( int result ); |
349 | void slotReportDesignFinished( int result ); |
350 | void slotOpenReportFileFinished( int result ); |
351 | void slotCreateViewFinished( int result ); |
352 | |
353 | void slotRemoveCommands(); |
354 | |
355 | void hideToolDocker(); |
356 | void initiateViews(); |
357 | void slotViewScheduleManager(); |
358 | |
359 | private: |
360 | void createViews(); |
361 | ViewBase *createView( ViewListItem *cat, const QString &type, const QString &tag, const QString &name, const QString &tip, int index = -1 ); |
362 | |
363 | QString standardTaskStatusReport() const; |
364 | |
365 | private: |
366 | QSplitter *m_sp; |
367 | QStackedWidget *m_tab; |
368 | |
369 | ViewListWidget *m_viewlist; |
370 | ViewListItem *m_viewlistItem; // requested popupmenu item |
371 | |
372 | //QDockWidget *m_toolbox; |
373 | |
374 | int m_viewGrp; |
375 | int m_defaultFontSize; |
376 | int m_currentEstimateType; |
377 | |
378 | bool m_updateAccountsview; |
379 | bool m_updateResourceAssignmentView; |
380 | bool m_updatePertEditor; |
381 | |
382 | QLabel *m_estlabel; |
383 | |
384 | ViewAdaptor* m_dbus; |
385 | |
386 | QActionGroup *m_scheduleActionGroup; |
387 | QMap<QAction*, Schedule*> m_scheduleActions; |
388 | // if multiple changes occur, only issue the last change |
389 | bool m_trigged; |
390 | ScheduleManager *m_nextScheduleManager; |
391 | |
392 | QMultiMap<ScheduleManager*, CalculateScheduleCmd*> m_calculationcommands; |
393 | QList<KUndo2Command*> m_undocommands; |
394 | |
395 | bool m_readWrite; |
396 | |
397 | QList<DockWidget*> m_dockers; |
398 | |
399 | // ------ File |
400 | QAction *actionCreateTemplate; |
401 | QAction *actionCreateNewProject; |
402 | |
403 | // ------ Edit |
404 | QAction *actionCut; |
405 | QAction *actionCopy; |
406 | QAction *actionPaste; |
407 | |
408 | // ------ View |
409 | KToggleAction *actionViewSelector; |
410 | |
411 | // ------ Insert |
412 | // ------ Project |
413 | KAction *actionEditMainProject; |
414 | |
415 | // ------ Tools |
416 | KAction *actionEditStandardWorktime; |
417 | KAction *actionDefineWBS; |
418 | KAction *actionInsertFile; |
419 | KAction *actionCurrencyConfig; |
420 | |
421 | KAction *actionOpenReportFile; |
422 | |
423 | // ------ Settings |
424 | KAction *actionConfigure; |
425 | |
426 | // ------ Help |
427 | KAction *actionIntroduction; |
428 | |
429 | // ------ Popup |
430 | KAction *actionOpenNode; |
431 | KAction *actionTaskProgress; |
432 | KAction *actionTaskDescription; |
433 | KAction *actionDeleteTask; |
434 | KAction *actionIndentTask; |
435 | KAction *actionUnindentTask; |
436 | KAction *actionMoveTaskUp; |
437 | KAction *actionMoveTaskDown; |
438 | |
439 | KAction *actionEditResource; |
440 | KAction *actionEditRelation; |
441 | KAction *actionDeleteRelation; |
442 | |
443 | //Test |
444 | KAction *actNoInformation; |
445 | |
446 | QMap<ViewListItem*, QAction*> m_reportActionMap; |
447 | |
448 | KoPart *m_partpart; |
449 | }; |
450 | |
451 | |
452 | } //Kplato namespace |
453 | |
454 | #endif |
455 | |