1 /*
2   TasksView.h
3 
4   This file is part of Charm, a task-based time tracking application.
5 
6   Copyright (C) 2014-2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
7 
8   Author: Frank Osterfeld <frank.osterfeld@kdab.com>
9 
10   This program is free software; you can redistribute it and/or modify
11   it under the terms of the GNU General Public License as published by
12   the Free Software Foundation, either version 2 of the License, or
13   (at your option) any later version.
14 
15   This program is distributed in the hope that it will be useful,
16   but WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   GNU General Public License for more details.
19 
20   You should have received a copy of the GNU General Public License
21   along with this program.  If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #ifndef TASKSVIEW_H
25 #define TASKSVIEW_H
26 
27 #include <QWidget>
28 #include <QAction>
29 
30 #include <Core/Event.h>
31 #include <Core/State.h>
32 #include <Core/CommandEmitterInterface.h>
33 #include <Core/UIStateInterface.h>
34 
35 #include <QDialog>
36 
37 class QMenu;
38 class TasksViewDelegate;
39 class QToolBar;
40 class QTreeView;
41 
42 class TasksView : public QDialog, public UIStateInterface
43 {
44     Q_OBJECT
45 
46 public:
47     explicit TasksView (QWidget *parent = nullptr);
48     ~TasksView() override;
49 
50     void populateEditMenu(QMenu *);
51 
52 public Q_SLOTS:
53     void commitCommand(CharmCommand *) override;
54 
55     void stateChanged(State previous) override;
56     void configurationChanged() override;
57 
58     void restoreGuiState() override;
59     void saveGuiState() override;
60 
61 Q_SIGNALS:
62     // FIXME connect to MainWindow
63     void saveConfiguration();
64     void emitCommand(CharmCommand *) override;
65     void emitCommandRollback(CharmCommand *) override;
66 
67 private Q_SLOTS:
68     void actionNewTask();
69     void actionNewSubTask();
70     void actionEditTask();
71     void actionDeleteTask();
72     void slotFiltertextChanged(const QString &filtertext);
73     void taskPrefilteringChanged();
74     void slotContextMenuRequested(const QPoint &);
75 
76     void slotEventActivated(EventId);
77     void slotEventDeactivated(EventId);
78     // this method is called every time the UI actions need update, for
79     // example when the current index changes:
80     void configureUi();
81 
82 private:
83 
84     // helper to retrieve selected task:
85     Task selectedTask();
86     void addTaskHelper(const Task &parent);
87 
88     QToolBar *m_toolBar;
89     TasksViewDelegate *m_delegate;
90     QAction m_actionNewTask;
91     QAction m_actionNewSubTask;
92     QAction m_actionEditTask;
93     QAction m_actionDeleteTask;
94     QAction m_actionExpandTree;
95     QAction m_actionCollapseTree;
96     QAction *m_showCurrentOnly;
97     QAction *m_showSubscribedOnly;
98     QTreeView *m_treeView;
99 };
100 
101 #endif
102