summaryrefslogtreecommitdiffstats
path: root/src/collectionfieldsdialog.h
blob: 6231e6336033e46f388adb1ea208f8b4a0f08a53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/***************************************************************************
    copyright            : (C) 2003-2006 by Robby Stephenson
    email                : [email protected]
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of version 2 of the GNU General Public License as  *
 *   published by the Free Software Foundation;                            *
 *                                                                         *
 ***************************************************************************/

#ifndef COLLECTIONFIELDSDIALOG_H
#define COLLECTIONFIELDSDIALOG_H

class KComboBox;
class KLineEdit;
class KPushButton;

class TQRadioButton;
class TQCheckBox;
class TQPainter;

#include "datavectors.h"
#include "gui/listboxtext.h"

#include <kdialogbase.h>

#include <tqmap.h>

namespace Tellico {
  namespace Data {
    class Collection;
  }

class FieldListBox : public GUI::ListBoxText {
public:
  FieldListBox(TQListBox* listbox, Data::FieldPtr field);
  FieldListBox(TQListBox* listbox, Data::FieldPtr field, TQListBoxItem* after);

  Data::FieldPtr field() const { return m_field; }
  void setField(Data::FieldPtr field) { m_field = field; }

private:
  Data::FieldPtr m_field;
};

/**
 * @author Robby Stephenson
 */
class CollectionFieldsDialog : public KDialogBase {
Q_OBJECT
  

public:
  /**
   * The constructor sets up the dialog.
   *
   * @param coll A pointer to the collection parent of all the attributes
   * @param parent A pointer to the parent widget
   * @param name The widget name
   */
  CollectionFieldsDialog(Data::CollPtr coll, TQWidget* parent, const char* name=0);
  ~CollectionFieldsDialog();

signals:
  void signalCollectionModified();

protected slots:
  virtual void slotOk();
  virtual void slotApply();
  virtual void slotDefault();

private slots:
  void slotNew();
  void slotDelete();
  void slotMoveUp();
  void slotMoveDown();
  void slotTypeChanged(const TQString& type);
  void slotHighlightedChanged(int index);
  void slotModified();
  bool slotShowExtendedProperties();
  void slotSelectInitial();

private:
  void applyChanges();
  void updateField();
  void updateTitle(const TQString& title);
  bool checkValues();
  FieldListBox* findItem(const TQListBox* box, Data::FieldPtr field);
  TQStringList newTypesAllowed(int type);

  Data::CollPtr m_coll;
  Data::CollPtr m_defaultCollection;
  Data::FieldVec m_copiedFields;
  Data::FieldVec m_newFields;
  Data::FieldPtr m_currentField;
  bool m_modified;
  bool m_updatingValues;
  bool m_reordered;
  int m_oldIndex;

  TQListBox* m_fieldsBox;
  KPushButton* m_btnNew;
  KPushButton* m_btnDelete;
  KPushButton* m_btnUp;
  KPushButton* m_btnDown;

  KLineEdit* m_titleEdit;
  KComboBox* m_typeCombo;
  KLineEdit* m_allowEdit;
  KLineEdit* m_defaultEdit;
  KComboBox* m_catCombo;
  KLineEdit* m_descEdit;
  KPushButton* m_btnExtended;

  TQRadioButton* m_formatNone;
  TQRadioButton* m_formatPlain;
  TQRadioButton* m_formatTitle;
  TQRadioButton* m_formatName;
  TQCheckBox* m_complete;
  TQCheckBox* m_multiple;
  TQCheckBox* m_grouped;
};

} // end namespace
#endif