1 /* This file is part of the KDE project
2    Copyright (C) 2005-2007 Dag Andersen <danders@get2net.dk>
3 
4    This library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Library General Public
6    License as published by the Free Software Foundation; either
7    version 2 of the License, or (at your option) any later version.
8 
9    This library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Library General Public License for more details.
13 
14    You should have received a copy of the GNU Library General Public License
15    along with this library; see the file COPYING.LIB.  If not, write to
16    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef KPTWBSDEFINITIONPANEL_H
21 #define KPTWBSDEFINITIONPANEL_H
22 
23 #include "planui_export.h"
24 
25 #include "ui_kptwbsdefinitionpanelbase.h"
26 
27 #include <QStyledItemDelegate>
28 #include <QWidget>
29 
30 class KUndo2Command;
31 
32 namespace KPlato
33 {
34 
35 class WBSDefinition;
36 class Project;
37 
38 class ComboBoxDelegate : public QStyledItemDelegate
39 {
40     Q_OBJECT
41 public:
42     explicit ComboBoxDelegate(QStringList &list, QObject *parent = 0);
43 
44     QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
45                             const QModelIndex &index) const override;
46 
47     void setEditorData(QWidget *editor, const QModelIndex &index) const override;
48     void setModelData(QWidget *editor, QAbstractItemModel *model,
49                         const QModelIndex &index) const override;
50 
51     void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
52 private:
53     QStringList m_list;
54 };
55 
56 //---------------
57 class WBSDefinitionPanel : public QWidget, public Ui_WBSDefinitionPanelBase {
58     Q_OBJECT
59 public:
60     explicit WBSDefinitionPanel(Project &project, WBSDefinition &def, QWidget *parent=0, const char *name=0);
61 
62     KUndo2Command *buildCommand();
63 
64     bool ok();
65 
66     void setStartValues();
67 
68 Q_SIGNALS:
69     void changed(bool enable);
70 
71 protected Q_SLOTS:
72     void slotChanged();
73     void slotSelectionChanged();
74     void slotRemoveBtnClicked();
75     void slotAddBtnClicked();
76     void slotLevelChanged(int);
77     void slotLevelsGroupToggled(bool on);
78 private:
79     Project &m_project;
80     WBSDefinition &m_def;
81     int selectedRow;
82 };
83 
84 } //KPlato namespace
85 
86 #endif // WBSDEFINITIONPANEL_H
87