File indexing completed on 2024-04-28 05:08:15

0001 /***************************************************************************
0002     Copyright (C) 2003-2009 Robby Stephenson <robby@periapsis.org>
0003  ***************************************************************************/
0004 
0005 /***************************************************************************
0006  *                                                                         *
0007  *   This program is free software; you can redistribute it and/or         *
0008  *   modify it under the terms of the GNU General Public License as        *
0009  *   published by the Free Software Foundation; either version 2 of        *
0010  *   the License or (at your option) version 3 or any later version        *
0011  *   accepted by the membership of KDE e.V. (or its successor approved     *
0012  *   by the membership of KDE e.V.), which shall act as a proxy            *
0013  *   defined in Section 14 of version 3 of the license.                    *
0014  *                                                                         *
0015  *   This program is distributed in the hope that it will be useful,       *
0016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0018  *   GNU General Public License for more details.                          *
0019  *                                                                         *
0020  *   You should have received a copy of the GNU General Public License     *
0021  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
0022  *                                                                         *
0023  ***************************************************************************/
0024 
0025 #ifndef TELLICO_COLLECTIONFIELDSDIALOG_H
0026 #define TELLICO_COLLECTIONFIELDSDIALOG_H
0027 
0028 #include "datavectors.h"
0029 
0030 #include <QDialog>
0031 
0032 class KComboBox;
0033 
0034 class QPushButton;
0035 class QLineEdit;
0036 class QListWidget;
0037 class QRadioButton;
0038 class QCheckBox;
0039 class QDialogButtonBox;
0040 
0041 namespace Tellico {
0042   namespace Data {
0043     class Collection;
0044   }
0045   namespace GUI {
0046     class ComboBox;
0047   }
0048 
0049 class FieldListItem;
0050 
0051 /**
0052  * @author Robby Stephenson
0053  */
0054 class CollectionFieldsDialog : public QDialog {
0055 Q_OBJECT
0056 
0057 public:
0058   /**
0059    * The constructor sets up the dialog.
0060    *
0061    * @param coll A pointer to the collection parent of all the attributes
0062    * @param parent A pointer to the parent widget
0063    */
0064   CollectionFieldsDialog(Data::CollPtr coll, QWidget* parent);
0065   ~CollectionFieldsDialog();
0066 
0067   void setNotifyKernel(bool notify);
0068 
0069 Q_SIGNALS:
0070   void signalCollectionModified();
0071   void beginCommandGroup(const QString& name);
0072   void endCommandGroup();
0073   void addField(Tellico::Data::FieldPtr field);
0074   void modifyField(Tellico::Data::FieldPtr field);
0075   void removeField(Tellico::Data::FieldPtr field);
0076   void reorderFields(Tellico::Data::FieldList fields);
0077 
0078 protected Q_SLOTS:
0079   void slotOk();
0080   void slotApply();
0081   void slotDefault();
0082   void slotHelp();
0083 
0084 private Q_SLOTS:
0085   void slotNew();
0086   void slotDelete();
0087   void slotMoveUp();
0088   void slotMoveDown();
0089   void slotTypeChanged(const QString& type);
0090   void slotHighlightedChanged(int index);
0091   void slotModified();
0092   bool slotShowExtendedProperties();
0093   void slotSelectInitial();
0094   void slotDerivedChecked(bool checked);
0095   void resetToCurrent();
0096 
0097 private:
0098   void applyChanges();
0099   void updateField();
0100   void updateTitle(const QString& title);
0101   bool checkValues();
0102   FieldListItem* findItem(Data::FieldPtr field);
0103   QStringList newTypesAllowed(int type);
0104   void populate(Data::FieldPtr field);
0105 
0106   Data::CollPtr m_coll;
0107   Data::CollPtr m_defaultCollection;
0108   Data::FieldList m_copiedFields;
0109   Data::FieldList m_newFields;
0110   Data::FieldPtr m_currentField;
0111   bool m_modified;
0112   bool m_updatingValues;
0113   bool m_reordered;
0114   int m_oldIndex;
0115   enum NotifyMode { NotifyKernel, NoNotification };
0116   NotifyMode m_notifyMode;
0117 
0118   QListWidget* m_fieldsWidget;
0119   QPushButton* m_btnNew;
0120   QPushButton* m_btnDelete;
0121   QPushButton* m_btnUp;
0122   QPushButton* m_btnDown;
0123 
0124   QLineEdit* m_titleEdit;
0125   KComboBox* m_typeCombo;
0126   KComboBox* m_catCombo;
0127   QLineEdit* m_descEdit;
0128   QLineEdit* m_derivedEdit;
0129   QLineEdit* m_defaultEdit;
0130   QCheckBox* m_derived;
0131   QLineEdit* m_allowEdit;
0132   QPushButton* m_btnExtended;
0133 
0134   GUI::ComboBox* m_formatCombo;
0135   QCheckBox* m_complete;
0136   QCheckBox* m_multiple;
0137   QCheckBox* m_grouped;
0138   QDialogButtonBox* m_buttonBox;
0139 };
0140 
0141 } // end namespace
0142 #endif