2015-07-10 11:49:37 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file tmainwindow.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 10 7, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2015 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
|
|
**
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef TMAINWINDOW_H
|
|
|
|
#define TMAINWINDOW_H
|
|
|
|
|
2015-08-29 11:48:03 +02:00
|
|
|
#include <QTableWidget>
|
2015-07-10 11:49:37 +02:00
|
|
|
|
2015-07-13 12:48:29 +02:00
|
|
|
#include "../vmisc/def.h"
|
2015-09-14 13:53:49 +02:00
|
|
|
#include "../vmisc/vlockguard.h"
|
2015-07-15 09:16:59 +02:00
|
|
|
#include "../vformat/vmeasurements.h"
|
2016-06-11 18:50:20 +02:00
|
|
|
#include "../vmisc/vtablesearch.h"
|
2017-04-12 08:49:05 +02:00
|
|
|
#include "../vwidgets/vabstractmainwindow.h"
|
2015-07-13 12:48:29 +02:00
|
|
|
|
2015-07-10 11:49:37 +02:00
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class TMainWindow;
|
|
|
|
}
|
|
|
|
|
2015-07-25 08:10:56 +02:00
|
|
|
class QLabel;
|
2015-07-21 15:18:10 +02:00
|
|
|
|
2017-04-12 08:49:05 +02:00
|
|
|
class TMainWindow : public VAbstractMainWindow
|
2015-07-10 11:49:37 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-08-25 19:00:03 +02:00
|
|
|
explicit TMainWindow(QWidget *parent = nullptr);
|
2015-07-10 11:49:37 +02:00
|
|
|
virtual ~TMainWindow() Q_DECL_OVERRIDE;
|
|
|
|
|
2015-07-25 14:59:40 +02:00
|
|
|
QString CurrentFile() const;
|
|
|
|
|
2015-08-08 16:33:37 +02:00
|
|
|
void RetranslateTable();
|
|
|
|
|
2015-08-18 15:31:21 +02:00
|
|
|
void SetBaseMHeight(int height);
|
|
|
|
void SetBaseMSize(int size);
|
|
|
|
void SetPUnit(Unit unit);
|
|
|
|
|
2015-10-11 11:06:14 +02:00
|
|
|
bool LoadFile(const QString &path);
|
2015-07-15 09:16:59 +02:00
|
|
|
|
2017-04-12 08:49:05 +02:00
|
|
|
public slots:
|
|
|
|
virtual void ShowToolTip(const QString &toolTip) Q_DECL_OVERRIDE;
|
|
|
|
|
2015-07-18 15:01:57 +02:00
|
|
|
protected:
|
|
|
|
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
2015-08-08 16:33:37 +02:00
|
|
|
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
|
2015-10-29 17:20:59 +01:00
|
|
|
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
|
2016-08-23 20:24:14 +02:00
|
|
|
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
|
2017-05-12 14:09:19 +02:00
|
|
|
virtual void ExportToCSVData(const QString &fileName, const DialogExportToCSV &dialog) Q_DECL_FINAL;
|
2015-07-18 15:01:57 +02:00
|
|
|
|
2015-07-15 09:16:59 +02:00
|
|
|
private slots:
|
2016-07-18 17:09:15 +02:00
|
|
|
void FileNew();
|
|
|
|
void OpenIndividual();
|
2017-07-12 20:21:48 +02:00
|
|
|
void OpenMultisize();
|
2016-07-18 17:09:15 +02:00
|
|
|
void OpenTemplate();
|
|
|
|
void CreateFromExisting();
|
2016-07-23 11:56:22 +02:00
|
|
|
void Preferences();
|
2017-04-12 14:50:48 +02:00
|
|
|
void ToolBarStyles();
|
2016-07-18 17:09:15 +02:00
|
|
|
|
2017-02-04 12:28:47 +01:00
|
|
|
bool FileSave();
|
|
|
|
bool FileSaveAs();
|
2015-07-12 17:56:34 +02:00
|
|
|
void AboutToShowWindowMenu();
|
2016-07-18 17:09:15 +02:00
|
|
|
void ShowWindow() const;
|
2015-07-25 17:18:01 +02:00
|
|
|
|
2015-12-03 13:07:51 +01:00
|
|
|
#if defined(Q_OS_MAC)
|
2015-12-05 10:50:32 +01:00
|
|
|
void AboutToShowDockMenu();
|
2015-12-03 13:07:51 +01:00
|
|
|
void OpenAt(QAction *where);
|
|
|
|
#endif //defined(Q_OS_MAC)
|
|
|
|
|
2015-07-18 13:08:44 +02:00
|
|
|
void SaveGivenName();
|
|
|
|
void SaveFamilyName();
|
|
|
|
void SaveEmail();
|
2015-10-13 10:13:43 +02:00
|
|
|
void SaveGender(int index);
|
2015-07-18 13:08:44 +02:00
|
|
|
void SaveBirthDate(const QDate & date);
|
|
|
|
void SaveNotes();
|
2015-10-16 19:26:05 +02:00
|
|
|
void SavePMSystem(int index);
|
2015-07-22 09:01:34 +02:00
|
|
|
|
2015-07-22 08:41:04 +02:00
|
|
|
void Remove();
|
2015-10-12 16:57:11 +02:00
|
|
|
void MoveTop();
|
2015-07-22 09:01:34 +02:00
|
|
|
void MoveUp();
|
|
|
|
void MoveDown();
|
2015-10-12 16:57:11 +02:00
|
|
|
void MoveBottom();
|
2015-07-24 14:06:53 +02:00
|
|
|
void Fx();
|
2015-07-21 19:26:33 +02:00
|
|
|
|
2015-07-19 14:28:01 +02:00
|
|
|
void AddCustom();
|
|
|
|
void AddKnown();
|
2015-08-11 16:52:18 +02:00
|
|
|
void ImportFromPattern();
|
2015-07-12 17:56:34 +02:00
|
|
|
|
2015-07-21 15:18:10 +02:00
|
|
|
void ChangedSize(const QString &text);
|
|
|
|
void ChangedHeight(const QString & text);
|
|
|
|
|
2015-07-21 17:28:20 +02:00
|
|
|
void ShowMData();
|
|
|
|
|
2015-07-21 18:24:47 +02:00
|
|
|
void DeployFormula();
|
|
|
|
|
2017-04-14 09:35:44 +02:00
|
|
|
void SaveMName(const QString &text);
|
2015-07-22 11:44:31 +02:00
|
|
|
void SaveMValue();
|
2015-07-25 08:10:56 +02:00
|
|
|
void SaveMBaseValue(double value);
|
|
|
|
void SaveMSizeIncrease(double value);
|
|
|
|
void SaveMHeightIncrease(double value);
|
2015-07-22 11:44:31 +02:00
|
|
|
void SaveMDescription();
|
2015-07-25 10:54:39 +02:00
|
|
|
void SaveMFullName();
|
2015-07-22 11:44:31 +02:00
|
|
|
|
2015-08-18 13:53:30 +02:00
|
|
|
void PatternUnitChanged(int index);
|
|
|
|
|
2015-07-10 11:49:37 +02:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(TMainWindow)
|
|
|
|
Ui::TMainWindow *ui;
|
2015-07-16 11:38:54 +02:00
|
|
|
VMeasurements *m;
|
|
|
|
VContainer *data;
|
|
|
|
Unit mUnit;
|
2015-08-18 13:53:30 +02:00
|
|
|
Unit pUnit;
|
2015-07-16 11:38:54 +02:00
|
|
|
MeasurementsType mType;
|
2017-08-04 19:29:43 +02:00
|
|
|
qreal currentSize;
|
|
|
|
qreal currentHeight;
|
2015-07-18 14:39:33 +02:00
|
|
|
QString curFile;
|
2015-07-21 15:18:10 +02:00
|
|
|
QComboBox *gradationHeights;
|
|
|
|
QComboBox *gradationSizes;
|
2015-08-18 13:53:30 +02:00
|
|
|
QComboBox *comboBoxUnits;
|
2015-07-21 18:24:47 +02:00
|
|
|
int formulaBaseHeight;
|
2015-10-23 19:47:33 +02:00
|
|
|
std::shared_ptr<VLockGuard<char>> lock;
|
2015-09-15 18:49:24 +02:00
|
|
|
QSharedPointer<VTableSearch> search;
|
2015-10-16 19:26:05 +02:00
|
|
|
QLabel *labelGradationHeights;
|
|
|
|
QLabel *labelGradationSizes;
|
|
|
|
QLabel *labelPatternUnit;
|
2015-10-29 17:20:59 +01:00
|
|
|
QAction *actionDockDiagram;
|
|
|
|
bool dockDiagramVisible;
|
|
|
|
bool isInitialized;
|
2017-02-04 12:28:47 +01:00
|
|
|
bool mIsReadOnly;
|
2016-02-18 12:18:14 +01:00
|
|
|
enum { MaxRecentFiles = 5 };
|
|
|
|
QAction *recentFileActs[MaxRecentFiles];
|
|
|
|
QAction *separatorAct;
|
2016-06-19 19:31:24 +02:00
|
|
|
QVector<QObject *> hackedWidgets;
|
2015-08-01 19:09:10 +02:00
|
|
|
|
2015-07-12 16:19:53 +02:00
|
|
|
void SetupMenu();
|
2015-07-16 11:38:54 +02:00
|
|
|
void InitWindow();
|
|
|
|
void InitTable();
|
2015-07-25 08:10:56 +02:00
|
|
|
void SetDecimals();
|
2015-08-18 13:53:30 +02:00
|
|
|
void InitUnits();
|
2015-10-16 19:26:05 +02:00
|
|
|
void InitComboBoxUnits();
|
|
|
|
void InitGender(QComboBox *gender);
|
2015-07-18 14:39:33 +02:00
|
|
|
|
2017-05-23 09:45:04 +02:00
|
|
|
void ShowNewMData(bool fresh);
|
2015-07-21 18:13:09 +02:00
|
|
|
void ShowUnits();
|
|
|
|
void ShowHeaderUnits(QTableWidget *table, int column, const QString &unit);
|
2016-02-18 12:18:14 +01:00
|
|
|
void UpdateRecentFileActions();
|
2015-07-21 18:13:09 +02:00
|
|
|
|
2015-07-18 14:39:33 +02:00
|
|
|
void MeasurementsWasSaved(bool saved);
|
|
|
|
void SetCurrentFile(const QString &fileName);
|
|
|
|
bool SaveMeasurements(const QString &fileName, QString &error);
|
2015-07-18 15:01:57 +02:00
|
|
|
|
|
|
|
bool MaybeSave();
|
2015-07-19 14:28:01 +02:00
|
|
|
|
2015-09-29 16:04:24 +02:00
|
|
|
QTableWidgetItem *AddCell(const QString &text, int row, int column, int aligment, bool ok = true);
|
2015-07-21 15:18:10 +02:00
|
|
|
|
2017-07-01 20:38:26 +02:00
|
|
|
Q_REQUIRED_RESULT QComboBox *SetGradationList(QLabel *label, const QStringList &list);
|
|
|
|
|
2015-07-21 15:18:10 +02:00
|
|
|
void SetDefaultHeight(int value);
|
|
|
|
void SetDefaultSize(int value);
|
|
|
|
|
2017-04-14 11:04:03 +02:00
|
|
|
void RefreshData(bool freshCall = false);
|
|
|
|
void RefreshTable(bool freshCall = false);
|
2015-07-21 17:28:20 +02:00
|
|
|
|
2017-04-14 09:35:44 +02:00
|
|
|
QString GetCustomName() const;
|
2015-07-21 17:28:20 +02:00
|
|
|
QString ClearCustomName(const QString &name) const;
|
|
|
|
|
2015-08-25 12:35:50 +02:00
|
|
|
bool EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label);
|
2015-10-29 17:20:59 +01:00
|
|
|
void ShowMDiagram(const QString &name);
|
2015-07-25 14:59:40 +02:00
|
|
|
|
|
|
|
void Open(const QString &pathTo, const QString &filter);
|
2017-02-04 12:28:47 +01:00
|
|
|
void UpdatePadlock(bool ro);
|
|
|
|
void MeasurementGUI();
|
2015-09-09 11:45:30 +02:00
|
|
|
void Controls();
|
|
|
|
void MFields(bool enabled);
|
2017-02-04 12:28:47 +01:00
|
|
|
void UpdateWindowTitle();
|
2015-08-01 19:09:10 +02:00
|
|
|
|
|
|
|
void ReadSettings();
|
|
|
|
void WriteSettings();
|
2015-08-11 16:52:18 +02:00
|
|
|
|
|
|
|
QStringList FilterMeasurements(const QStringList &mNew, const QStringList &mFilter);
|
2015-08-18 15:31:21 +02:00
|
|
|
|
|
|
|
void UpdatePatternUnit();
|
2015-10-15 14:37:10 +02:00
|
|
|
|
|
|
|
bool LoadFromExistingFile(const QString &path);
|
2015-12-03 09:43:31 +01:00
|
|
|
|
|
|
|
void CreateWindowMenu(QMenu *menu);
|
2015-12-23 14:26:29 +01:00
|
|
|
|
|
|
|
bool IgnoreLocking(int error, const QString &path);
|
2016-06-19 19:31:24 +02:00
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void HackWidget(T **widget);
|
2015-07-10 11:49:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TMAINWINDOW_H
|