Seamly2D
Code documentation
dialogmdatabase.h
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2017 Seamly, LLC *
4  * *
5  * https://github.com/fashionfreedom/seamly2d *
6  * *
7  ***************************************************************************
8  **
9  ** Seamly2D is free software: you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation, either version 3 of the License, or
12  ** (at your option) any later version.
13  **
14  ** Seamly2D is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** You should have received a copy of the GNU General Public License
20  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21  **
22  **************************************************************************
23 
24  ************************************************************************
25  **
26  ** @file dialogmdatabase.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 26 7, 2015
29  **
30  ** @brief
31  ** @copyright
32  ** This source code is part of the Valentine project, a pattern making
33  ** program, whose allow create and modeling patterns of clothing.
34  ** Copyright (C) 2015 Seamly2D project
35  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36  **
37  ** Seamly2D is free software: you can redistribute it and/or modify
38  ** it under the terms of the GNU General Public License as published by
39  ** the Free Software Foundation, either version 3 of the License, or
40  ** (at your option) any later version.
41  **
42  ** Seamly2D is distributed in the hope that it will be useful,
43  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
44  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  ** GNU General Public License for more details.
46  **
47  ** You should have received a copy of the GNU General Public License
48  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49  **
50  *************************************************************************/
51 
52 #ifndef DIALOGMDATABASE_H
53 #define DIALOGMDATABASE_H
54 
55 #include <QDialog>
56 
57 namespace Ui
58 {
59  class DialogMDataBase;
60 }
61 
62 class QTreeWidgetItem;
63 
64 class MeasurementDatabaseDialog : public QDialog
65 {
66  Q_OBJECT
67 
68 public:
69  explicit MeasurementDatabaseDialog(const QStringList &measurements, QWidget *parent = nullptr);
70  explicit MeasurementDatabaseDialog(QWidget *parent = nullptr);
71  virtual ~MeasurementDatabaseDialog() Q_DECL_OVERRIDE;
72 
73  void retranslateGroups();
74 
75  QStringList getNewMeasurementNames() const;
76  static QString imageUrl(const QString &number);
77 
78 protected:
79  virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
80  virtual bool eventFilter(QObject *target, QEvent *event) Q_DECL_OVERRIDE;
81 
82 private slots:
83  void updateChecks(QTreeWidgetItem *item, int column);
84  void showDescription(QTreeWidgetItem *item, int column);
85  void treeContextMenu(const QPoint &pos);
86  void recheckState();
87 
88 private:
89  Q_DISABLE_COPY(MeasurementDatabaseDialog)
90  Ui::DialogMDataBase *ui;
91  bool selectMode;
92  QStringList measurements;
93  QStringList newMeasurements;
94 
95  const QString groupAText = "A. " + MeasurementDatabaseDialog::tr("Direct Height", "Measurement section");
96  const QString groupBText = "B. " + MeasurementDatabaseDialog::tr("Direct Width", "Measurement section");
97  const QString groupCText = "C. " + MeasurementDatabaseDialog::tr("Indentation", "Measurement section");
98  const QString groupDText = "D. " + MeasurementDatabaseDialog::tr("Hand", "Measurement section");
99  const QString groupEText = "E. " + MeasurementDatabaseDialog::tr("Foot", "Measurement section");
100  const QString groupFText = "F. " + MeasurementDatabaseDialog::tr("Head", "Measurement section");
101  const QString groupGText = "G. " + MeasurementDatabaseDialog::tr("Circumference and Arc", "Measurement section");
102  const QString groupHText = "H. " + MeasurementDatabaseDialog::tr("Vertical", "Measurement section");
103  const QString groupIText = "I. " + MeasurementDatabaseDialog::tr("Horizontal", "Measurement section");
104  const QString groupJText = "J. " + MeasurementDatabaseDialog::tr("Bust", "Measurement section");
105  const QString groupKText = "K. " + MeasurementDatabaseDialog::tr("Balance", "Measurement section");
106  const QString groupLText = "L. " + MeasurementDatabaseDialog::tr("Arm", "Measurement section");
107  const QString groupMText = "M. " + MeasurementDatabaseDialog::tr("Leg", "Measurement section");
108  const QString groupNText = "N. " + MeasurementDatabaseDialog::tr("Crotch and Rise", "Measurement section");
109  const QString groupOText = "O. " + MeasurementDatabaseDialog::tr("Men & Tailoring", "Measurement section");
110  const QString groupPText = "P. " + MeasurementDatabaseDialog::tr("Historical & Specialty", "Measurement section");
111  const QString groupQText = "Q. " + MeasurementDatabaseDialog::tr("Patternmaking measurements", "Measurement section");
112 
113  QTreeWidgetItem *groupA;
114  QTreeWidgetItem *groupB;
115  QTreeWidgetItem *groupC;
116  QTreeWidgetItem *groupD;
117  QTreeWidgetItem *groupE;
118  QTreeWidgetItem *groupF;
119  QTreeWidgetItem *groupG;
120  QTreeWidgetItem *groupH;
121  QTreeWidgetItem *groupI;
122  QTreeWidgetItem *groupJ;
123  QTreeWidgetItem *groupK;
124  QTreeWidgetItem *groupL;
125  QTreeWidgetItem *groupM;
126  QTreeWidgetItem *groupN;
127  QTreeWidgetItem *groupO;
128  QTreeWidgetItem *groupP;
129  QTreeWidgetItem *groupQ;
130 
131  void initDataBase(const QStringList &measurements = QStringList());
132  void initGroup(QTreeWidgetItem **group, const QString &groupName, const QStringList &groupList,
133  const QStringList &measurementList = QStringList());
134 
135  Q_REQUIRED_RESULT QTreeWidgetItem *addMeasurementGroup(const QString &text);
136 
137  void addMeasurement(QTreeWidgetItem *group, const QString &groupName,
138  const QStringList &newMeasurements);
139 
140  void readSettings();
141  void writeSettings();
142  void filterGroups(const QString searchString);
143  void filterGroup(QTreeWidgetItem *group, const QString &searchString);
144 
145  void retranslateGroup(QTreeWidgetItem *group, const QString &groupName,
146  const QStringList &measurements);
147  void retranslateMeasurement(QTreeWidgetItem *group, int index, const QString &name);
148 
149  void changeCheckState(QTreeWidgetItem *group, Qt::CheckState state);
150  Qt::CheckState globalCheckState() const;
151 };
152 
153 #endif // DIALOGMDATABASE_H
void addMeasurement(QTreeWidgetItem *group, const QString &groupName, const QStringList &newMeasurements)
QTreeWidgetItem * groupB
void filterGroup(QTreeWidgetItem *group, const QString &searchString)
QTreeWidgetItem * groupH
QTreeWidgetItem * groupP
void updateChecks(QTreeWidgetItem *item, int column)
QTreeWidgetItem * groupM
QStringList getNewMeasurementNames() const
QTreeWidgetItem * groupE
void initDataBase(const QStringList &measurements=QStringList())
virtual bool eventFilter(QObject *target, QEvent *event) Q_DECL_OVERRIDE
Qt::CheckState globalCheckState() const
Q_REQUIRED_RESULT QTreeWidgetItem * addMeasurementGroup(const QString &text)
Ui::DialogMDataBase * ui
QTreeWidgetItem * groupD
QTreeWidgetItem * groupL
QTreeWidgetItem * groupC
QTreeWidgetItem * groupQ
QTreeWidgetItem * groupN
void changeCheckState(QTreeWidgetItem *group, Qt::CheckState state)
MeasurementDatabaseDialog(const QStringList &measurements, QWidget *parent=nullptr)
QTreeWidgetItem * groupJ
void treeContextMenu(const QPoint &pos)
QTreeWidgetItem * groupI
QTreeWidgetItem * groupG
QTreeWidgetItem * groupF
void retranslateMeasurement(QTreeWidgetItem *group, int index, const QString &name)
void retranslateGroup(QTreeWidgetItem *group, const QString &groupName, const QStringList &measurements)
virtual void changeEvent(QEvent *event) Q_DECL_OVERRIDE
virtual ~MeasurementDatabaseDialog() Q_DECL_OVERRIDE
QTreeWidgetItem * groupA
QTreeWidgetItem * groupO
void showDescription(QTreeWidgetItem *item, int column)
void filterGroups(const QString searchString)
void initGroup(QTreeWidgetItem **group, const QString &groupName, const QStringList &groupList, const QStringList &measurementList=QStringList())
QTreeWidgetItem * groupK
static QString imageUrl(const QString &number)
@ Height