Seamly2D
Code documentation
tmainwindow.h
Go to the documentation of this file.
1 /******************************************************************************
2  * @file tmainwindow.h
3  ** @author Douglas S Caskey
4  ** @date 13 May, 2023
5  **
6  ** @brief
7  ** @copyright
8  ** This source code is part of the Seamly2D project, a pattern making
9  ** program to create and model patterns of clothing.
10  ** Copyright (C) 2017-2023 Seamly2D project
11  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
12  **
13  ** Seamly2D is free software: you can redistribute it and/or modify
14  ** it under the terms of the GNU General Public License as published by
15  ** the Free Software Foundation, either version 3 of the License, or
16  ** (at your option) any later version.
17  **
18  ** Seamly2D is distributed in the hope that it will be useful,
19  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
20  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  ** GNU General Public License for more details.
22  **
23  ** You should have received a copy of the GNU General Public License
24  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
25  **
26  *************************************************************************/
27 
28  /************************************************************************
29  **
30  ** @file tmainwindow.h
31  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
32  ** @date 10 7, 2015
33  **
34  ** @brief
35  ** @copyright
36  ** This source code is part of the Valentina project, a pattern making
37  ** program, whose allow create and modeling patterns of clothing.
38  ** Copyright (C) 2015 Valentina project
39  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
40  **
41  ** Valentina is free software: you can redistribute it and/or modify
42  ** it under the terms of the GNU General Public License as published by
43  ** the Free Software Foundation, either version 3 of the License, or
44  ** (at your option) any later version.
45  **
46  ** Valentina is distributed in the hope that it will be useful,
47  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
48  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49  ** GNU General Public License for more details.
50  **
51  ** You should have received a copy of the GNU General Public License
52  ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
53  **
54  *************************************************************************/
55 
56 #ifndef TMAINWINDOW_H
57 #define TMAINWINDOW_H
58 
59 #include <QTableWidget>
60 
61 #include "../vmisc/def.h"
62 #include "../vmisc/vlockguard.h"
63 #include "../vformat/vmeasurements.h"
64 #include "../vmisc/vtablesearch.h"
65 #include "../vwidgets/vabstractmainwindow.h"
67 
68 namespace Ui
69 {
70  class TMainWindow;
71 }
72 
73 class QLabel;
74 class MeShortcutsDialog;
75 
77 {
78  Q_OBJECT
79 
80 public:
81  explicit TMainWindow(QWidget *parent = nullptr);
82  virtual ~TMainWindow() Q_DECL_OVERRIDE;
83 
84  QString CurrentFile() const;
85 
86  void RetranslateTable();
87 
88  void SetBaseMHeight(int height);
89  void SetBaseMSize(int size);
90  void SetPUnit(Unit unit);
91 
92  bool LoadFile(const QString &path);
93 
94 public slots:
95  virtual void ShowToolTip(const QString &toolTip) Q_DECL_OVERRIDE;
96  virtual void zoomToSelected() Q_DECL_OVERRIDE;
97  virtual void updateGroups() Q_DECL_OVERRIDE;
98 
99 protected:
100  virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
101  virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
102  virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
103  virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
104  virtual void exportToCSVData(const QString &fileName, const DialogExportToCSV &dialog) Q_DECL_FINAL;
105  void handleExportToCSV();
106 
107 private slots:
108  void FileNew();
109  void OpenIndividual();
110  void OpenMultisize();
111  void OpenTemplate();
112  void CreateFromExisting();
113  void Preferences();
114  void ToolBarStyles();
115 
116  void print();
117  void printPages(QPrinter *printer);
118 
119  bool FileSave();
120  bool FileSaveAs();
121  void AboutToShowWindowMenu();
122  void ShowWindow() const;
123 
124 #if defined(Q_OS_MAC)
125  void AboutToShowDockMenu();
126  void OpenAt(QAction *where);
127 #endif //defined(Q_OS_MAC)
128 
129  void SaveGivenName();
130  void SaveFamilyName();
131  void SaveEmail();
132  void SaveGender(int index);
133  void SaveBirthDate(const QDate & date);
134  void SaveNotes();
135  void SavePMSystem(int index);
136 
137  void Remove();
138  void MoveTop();
139  void MoveUp();
140  void MoveDown();
141  void MoveBottom();
142  void Fx();
143 
144  void AddCustom();
145  void AddKnown();
146  void ImportFromPattern();
147 
148  void ChangedSize(int index);
149  void ChangedHeight(int index);
150 
151  void ShowMData();
152 
153  void DeployFormula();
154 
155  void SaveMName(const QString &text);
156  void SaveMValue();
157  void SaveMBaseValue(double value);
158  void SaveMSizeIncrease(double value);
159  void SaveMHeightIncrease(double value);
160  void SaveMDescription();
161  void SaveMFullName();
162 
163  void PatternUnitChanged(int index);
164 
165 private:
166  Q_DISABLE_COPY(TMainWindow)
173  qreal currentSize;
175  QString curFile;
176  QComboBox *gradationHeights;
177  QComboBox *gradationSizes;
178  QComboBox *comboBoxUnits;
180  std::shared_ptr<VLockGuard<char>> lock;
189  enum { MaxRecentFiles = 5 };
191  QAction *separatorAct;
193 
194  void SetupMenu();
195  void InitWindow();
196  void InitTable();
197  void SetDecimals();
198  void InitUnits();
199  void InitComboBoxUnits();
200  void InitGender(QComboBox *gender);
201 
202  void ShowNewMData(bool fresh);
203  void ShowUnits();
204  void ShowHeaderUnits(QTableWidget *table, int column, const QString &unit);
206 
207  void MeasurementsWasSaved(bool saved);
208  void SetCurrentFile(const QString &fileName);
209  bool SaveMeasurements(const QString &fileName, QString &error);
210 
211  bool MaybeSave();
212 
213  QTableWidgetItem *AddCell(const QString &text, int row, int column, int aligment, bool ok = true);
214 
215  Q_REQUIRED_RESULT QComboBox *SetGradationList(QLabel *label, const QStringList &list);
216 
217  void SetDefaultHeight(int value);
218  void SetDefaultSize(int value);
219 
220  void RefreshData(bool freshCall = false);
221  void RefreshTable(bool freshCall = false);
222 
223  QString GetCustomName() const;
224  QString ClearCustomName(const QString &name) const;
225 
226  bool EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label);
227  QString getMeasurementNumber(const QString &name);
228  void ShowMDiagram(const QString &name);
229 
230  void Open(const QString &pathTo, const QString &filter);
231  void UpdatePadlock(bool ro);
232  void MeasurementGUI();
233  void Controls();
234  void MFields(bool enabled);
235  void UpdateWindowTitle();
236 
237  void ReadSettings();
238  void WriteSettings();
239 
240  QStringList FilterMeasurements(const QStringList &mNew, const QStringList &mFilter);
241 
242  void UpdatePatternUnit();
243 
244  bool LoadFromExistingFile(const QString &path);
245 
246  void CreateWindowMenu(QMenu *menu);
247 
248  bool IgnoreLocking(int error, const QString &path);
249 
250  template <class T>
251  void HackWidget(T **widget);
252  void copyToClipboard();
253 };
254 
255 #endif // TMAINWINDOW_H
void SetBaseMSize(int size)
QString GetCustomName() const
bool FileSave()
void FileNew()
bool EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label)
QString ClearCustomName(const QString &name) const
void SetDefaultHeight(int value)
void CreateWindowMenu(QMenu *menu)
QLabel * labelGradationSizes
Definition: tmainwindow.h:183
QString CurrentFile() const
QAction * actionDockDiagram
Definition: tmainwindow.h:185
QString curFile
Definition: tmainwindow.h:175
virtual void exportToCSVData(const QString &fileName, const DialogExportToCSV &dialog) Q_DECL_FINAL
void InitTable()
int formulaBaseHeight
Definition: tmainwindow.h:179
QComboBox * gradationSizes
Definition: tmainwindow.h:177
void UpdateRecentFileActions()
VContainer * data
Definition: tmainwindow.h:169
void ReadSettings()
void SetupMenu()
void SaveBirthDate(const QDate &date)
QStringList FilterMeasurements(const QStringList &mNew, const QStringList &mFilter)
qreal currentSize
Definition: tmainwindow.h:173
bool dockDiagramVisible
Definition: tmainwindow.h:186
void printPages(QPrinter *printer)
void ShowNewMData(bool fresh)
Ui::TMainWindow * ui
Definition: tmainwindow.h:167
void InitWindow()
void OpenMultisize()
QVector< QObject * > hackedWidgets
Definition: tmainwindow.h:192
virtual void zoomToSelected() Q_DECL_OVERRIDE
void PatternUnitChanged(int index)
void OpenIndividual()
void UpdateWindowTitle()
void RefreshTable(bool freshCall=false)
void SaveMFullName()
QAction * recentFileActs[MaxRecentFiles]
Definition: tmainwindow.h:190
void SavePMSystem(int index)
void ShowHeaderUnits(QTableWidget *table, int column, const QString &unit)
void SetDefaultSize(int value)
void SaveMValue()
void InitGender(QComboBox *gender)
VMeasurements * individualMeasurements
Definition: tmainwindow.h:168
void WriteSettings()
bool LoadFile(const QString &path)
void SaveMName(const QString &text)
void MFields(bool enabled)
void ShowUnits()
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
virtual void changeEvent(QEvent *event) Q_DECL_OVERRIDE
void HackWidget(T **widget)
void InitComboBoxUnits()
virtual void ShowToolTip(const QString &toolTip) Q_DECL_OVERRIDE
bool isInitialized
Definition: tmainwindow.h:187
void MoveBottom()
void AddCustom()
void SaveEmail()
QTableWidgetItem * AddCell(const QString &text, int row, int column, int aligment, bool ok=true)
void SetDecimals()
void OpenTemplate()
QComboBox * gradationHeights
Definition: tmainwindow.h:176
void SetPUnit(Unit unit)
qreal currentHeight
Definition: tmainwindow.h:174
void handleExportToCSV()
void MeasurementsWasSaved(bool saved)
void SaveGivenName()
void SetBaseMHeight(int height)
MeasurementsType mType
Definition: tmainwindow.h:172
bool LoadFromExistingFile(const QString &path)
QAction * separatorAct
Definition: tmainwindow.h:191
void SaveMDescription()
void SetCurrentFile(const QString &fileName)
void RefreshData(bool freshCall=false)
void ImportFromPattern()
void SaveMBaseValue(double value)
QComboBox * comboBoxUnits
Definition: tmainwindow.h:178
void ShowMData()
TMainWindow(QWidget *parent=nullptr)
Q_REQUIRED_RESULT QComboBox * SetGradationList(QLabel *label, const QStringList &list)
void SaveFamilyName()
void SaveMSizeIncrease(double value)
void ChangedHeight(int index)
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE
void ShowMDiagram(const QString &name)
void UpdatePatternUnit()
virtual ~TMainWindow() Q_DECL_OVERRIDE
void copyToClipboard()
copyToClipboard copy dialog selection to clipboard as comma separated values.
void SaveGender(int index)
bool SaveMeasurements(const QString &fileName, QString &error)
void CreateFromExisting()
void AboutToShowWindowMenu()
void RetranslateTable()
void MeasurementGUI()
void SaveNotes()
void ShowWindow() const
bool mIsReadOnly
Definition: tmainwindow.h:188
virtual void updateGroups() Q_DECL_OVERRIDE
void Preferences()
void UpdatePadlock(bool ro)
void InitUnits()
QString getMeasurementNumber(const QString &name)
QLabel * labelPatternUnit
Definition: tmainwindow.h:184
std::shared_ptr< VLockGuard< char > > lock
Definition: tmainwindow.h:180
void SaveMHeightIncrease(double value)
bool MaybeSave()
bool FileSaveAs()
QLabel * labelGradationHeights
Definition: tmainwindow.h:182
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE
void DeployFormula()
void ChangedSize(int index)
QSharedPointer< VTableSearch > search
Definition: tmainwindow.h:181
bool IgnoreLocking(int error, const QString &path)
void ToolBarStyles()
void Open(const QString &pathTo, const QString &filter)
The VContainer class container of all variables.
Definition: vcontainer.h:141
MeasurementsType
Definition: def.h:104
Unit
Definition: def.h:105