1 /***************************************************************************
2     Copyright (C) 2003-2009 Robby Stephenson <robby@periapsis.org>
3  ***************************************************************************/
4 
5 /***************************************************************************
6  *                                                                         *
7  *   This program is free software; you can redistribute it and/or         *
8  *   modify it under the terms of the GNU General Public License as        *
9  *   published by the Free Software Foundation; either version 2 of        *
10  *   the License or (at your option) version 3 or any later version        *
11  *   accepted by the membership of KDE e.V. (or its successor approved     *
12  *   by the membership of KDE e.V.), which shall act as a proxy            *
13  *   defined in Section 14 of version 3 of the license.                    *
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 
25 #ifndef TELLICO_COLLECTIONFIELDSDIALOG_H
26 #define TELLICO_COLLECTIONFIELDSDIALOG_H
27 
28 #include "datavectors.h"
29 
30 #include <QDialog>
31 
32 class KComboBox;
33 
34 class QPushButton;
35 class QLineEdit;
36 class QListWidget;
37 class QRadioButton;
38 class QCheckBox;
39 class QDialogButtonBox;
40 
41 namespace Tellico {
42   namespace Data {
43     class Collection;
44   }
45   namespace GUI {
46     class ComboBox;
47   }
48 
49 class FieldListItem;
50 
51 /**
52  * @author Robby Stephenson
53  */
54 class CollectionFieldsDialog : public QDialog {
55 Q_OBJECT
56 
57 public:
58   /**
59    * The constructor sets up the dialog.
60    *
61    * @param coll A pointer to the collection parent of all the attributes
62    * @param parent A pointer to the parent widget
63    */
64   CollectionFieldsDialog(Data::CollPtr coll, QWidget* parent);
65   ~CollectionFieldsDialog();
66 
67   void setNotifyKernel(bool notify);
68 
69 Q_SIGNALS:
70   void signalCollectionModified();
71 
72 protected Q_SLOTS:
73   void slotOk();
74   void slotApply();
75   void slotDefault();
76   void slotHelp();
77 
78 private Q_SLOTS:
79   void slotNew();
80   void slotDelete();
81   void slotMoveUp();
82   void slotMoveDown();
83   void slotTypeChanged(const QString& type);
84   void slotHighlightedChanged(int index);
85   void slotModified();
86   bool slotShowExtendedProperties();
87   void slotSelectInitial();
88   void slotDerivedChecked(bool checked);
89   void resetToCurrent();
90 
91 private:
92   void applyChanges();
93   void updateField();
94   void updateTitle(const QString& title);
95   bool checkValues();
96   FieldListItem* findItem(Data::FieldPtr field);
97   QStringList newTypesAllowed(int type);
98   void populate(Data::FieldPtr field);
99 
100   Data::CollPtr m_coll;
101   Data::CollPtr m_defaultCollection;
102   Data::FieldList m_copiedFields;
103   Data::FieldList m_newFields;
104   Data::FieldPtr m_currentField;
105   bool m_modified;
106   bool m_updatingValues;
107   bool m_reordered;
108   int m_oldIndex;
109   enum NotifyMode { NotifyKernel, NoNotification };
110   NotifyMode m_notifyMode;
111 
112   QListWidget* m_fieldsWidget;
113   QPushButton* m_btnNew;
114   QPushButton* m_btnDelete;
115   QPushButton* m_btnUp;
116   QPushButton* m_btnDown;
117 
118   QLineEdit* m_titleEdit;
119   KComboBox* m_typeCombo;
120   KComboBox* m_catCombo;
121   QLineEdit* m_descEdit;
122   QLineEdit* m_derivedEdit;
123   QLineEdit* m_defaultEdit;
124   QCheckBox* m_derived;
125   QLineEdit* m_allowEdit;
126   QPushButton* m_btnExtended;
127 
128   GUI::ComboBox* m_formatCombo;
129   QCheckBox* m_complete;
130   QCheckBox* m_multiple;
131   QCheckBox* m_grouped;
132   QDialogButtonBox* m_buttonBox;
133 };
134 
135 } // end namespace
136 #endif
137