2015-07-10 11:49:37 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file tmainwindow.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 10 7, 2015
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2015-07-10 11:49:37 +02:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2015-07-10 11:49:37 +02:00
|
|
|
**
|
|
|
|
** 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;
|
2019-01-15 08:53:23 +01:00
|
|
|
} // namespace Ui
|
2015-07-10 11:49:37 +02:00
|
|
|
|
2015-07-25 08:10:56 +02:00
|
|
|
class QLabel;
|
2018-01-31 13:34:50 +01:00
|
|
|
class QxtCsvModel;
|
2020-10-05 10:45:16 +02:00
|
|
|
class VMeasurement;
|
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);
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual ~TMainWindow() override;
|
2015-07-10 11:49:37 +02:00
|
|
|
|
2015-07-25 14:59:40 +02:00
|
|
|
QString CurrentFile() const;
|
|
|
|
|
2015-08-08 16:33:37 +02:00
|
|
|
void RetranslateTable();
|
|
|
|
|
2020-10-03 06:33:56 +02:00
|
|
|
bool SetDimensionABase(int base);
|
|
|
|
bool SetDimensionBBase(int base);
|
|
|
|
bool SetDimensionCBase(int base);
|
2015-08-18 15:31:21 +02:00
|
|
|
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:
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void ShowToolTip(const QString &toolTip) override;
|
2017-04-12 08:49:05 +02:00
|
|
|
|
2015-07-18 15:01:57 +02:00
|
|
|
protected:
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual void closeEvent(QCloseEvent *event) override;
|
|
|
|
virtual void changeEvent(QEvent* event) override;
|
|
|
|
virtual bool eventFilter(QObject *object, QEvent *event) override;
|
2017-09-27 12:25:18 +02:00
|
|
|
virtual void ExportToCSVData(const QString &fileName, bool withHeader, int mib,
|
2018-06-26 14:53:48 +02:00
|
|
|
const QChar &separator) final;
|
2019-09-06 21:18:18 +02:00
|
|
|
virtual QStringList RecentFileList() const override;
|
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;
|
2018-01-31 13:34:50 +01:00
|
|
|
void ImportDataFromCSV();
|
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)
|
|
|
|
|
2017-09-19 15:07:48 +02:00
|
|
|
void SaveCustomerName();
|
2015-07-18 13:08:44 +02:00
|
|
|
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
|
|
|
|
2020-10-03 06:34:25 +02:00
|
|
|
void DimensionABaseChanged();
|
|
|
|
void DimensionBBaseChanged();
|
|
|
|
void DimensionCBaseChanged();
|
|
|
|
|
|
|
|
void GradationChanged();
|
2015-07-21 15:18:10 +02:00
|
|
|
|
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);
|
2020-10-03 17:52:31 +02:00
|
|
|
void SaveMShiftA(double value);
|
|
|
|
void SaveMShiftB(double value);
|
|
|
|
void SaveMShiftC(double value);
|
|
|
|
void SaveMCorrectionValue(double value);
|
2015-07-22 11:44:31 +02:00
|
|
|
void SaveMDescription();
|
2015-07-25 10:54:39 +02:00
|
|
|
void SaveMFullName();
|
2020-10-03 17:52:31 +02:00
|
|
|
void SaveMUnits();
|
2020-10-15 08:35:08 +02:00
|
|
|
void SaveMDimension();
|
2015-07-22 11:44:31 +02:00
|
|
|
|
2020-10-01 18:26:56 +02:00
|
|
|
void FullCircumferenceChanged(bool checked);
|
|
|
|
|
2020-10-05 10:45:16 +02:00
|
|
|
void ExportToIndividual();
|
|
|
|
|
2021-01-19 20:13:17 +01:00
|
|
|
void RestrictFirstDimesion();
|
2020-10-05 14:14:38 +02:00
|
|
|
void RestrictSecondDimesion();
|
|
|
|
void RestrictThirdDimesion();
|
|
|
|
|
2020-10-08 12:34:38 +02:00
|
|
|
void EditDimensionLabels();
|
|
|
|
|
2015-07-10 11:49:37 +02:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(TMainWindow)
|
|
|
|
Ui::TMainWindow *ui;
|
2020-10-03 06:33:56 +02:00
|
|
|
VMeasurements *m{nullptr};
|
|
|
|
VContainer *data{nullptr};
|
|
|
|
Unit mUnit{Unit::Cm};
|
|
|
|
Unit pUnit{Unit::Cm};
|
|
|
|
MeasurementsType mType{MeasurementsType::Individual};
|
2021-01-18 19:43:53 +01:00
|
|
|
qreal currentDimensionA{0};
|
|
|
|
qreal currentDimensionB{0};
|
|
|
|
qreal currentDimensionC{0};
|
2020-10-03 06:33:56 +02:00
|
|
|
QString curFile{};
|
|
|
|
QComboBox *gradationDimensionA{nullptr};
|
|
|
|
QComboBox *gradationDimensionB{nullptr};
|
|
|
|
QComboBox *gradationDimensionC{nullptr};
|
|
|
|
QComboBox *comboBoxUnits{nullptr};
|
2015-07-21 18:24:47 +02:00
|
|
|
int formulaBaseHeight;
|
2020-10-03 06:33:56 +02:00
|
|
|
QSharedPointer<VLockGuard<char>> lock{nullptr};
|
|
|
|
QSharedPointer<VTableSearch> search{};
|
|
|
|
QLabel *labelGradationDimensionA{nullptr};
|
|
|
|
QLabel *labelGradationDimensionB{nullptr};
|
|
|
|
QLabel *labelGradationDimensionC{nullptr};
|
|
|
|
QLabel *labelPatternUnit{nullptr};
|
|
|
|
bool isInitialized{false};
|
|
|
|
bool mIsReadOnly{false};
|
2020-10-03 06:34:25 +02:00
|
|
|
QTimer *gradation;
|
2019-09-06 21:18:18 +02:00
|
|
|
|
2020-10-03 06:33:56 +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();
|
2020-10-01 18:26:56 +02:00
|
|
|
void InitMenu();
|
2020-10-01 15:56:44 +02:00
|
|
|
void InitDimensionsBaseValue();
|
2020-10-03 06:34:25 +02:00
|
|
|
void InitDimensionGradation(int index, const MeasurementDimension_p &dimension, QComboBox *control);
|
|
|
|
void InitDimensionControls();
|
2020-10-03 17:52:31 +02:00
|
|
|
void InitDimesionShifts();
|
2015-07-16 11:38:54 +02:00
|
|
|
void InitTable();
|
2015-07-25 08:10:56 +02:00
|
|
|
void SetDecimals();
|
2020-10-03 17:52:31 +02:00
|
|
|
void InitPatternUnits();
|
2015-10-16 19:26:05 +02:00
|
|
|
void InitComboBoxUnits();
|
2020-10-03 17:52:31 +02:00
|
|
|
void InitMeasurementUnits();
|
2015-10-16 19:26:05 +02:00
|
|
|
void InitGender(QComboBox *gender);
|
2020-10-15 08:35:08 +02:00
|
|
|
void InitMeasurementDimension();
|
2015-07-18 14:39:33 +02:00
|
|
|
|
2021-03-26 15:27:17 +01:00
|
|
|
void RetranslateTableHeaders();
|
|
|
|
|
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);
|
|
|
|
|
2018-08-01 18:25:36 +02:00
|
|
|
void MeasurementsWereSaved(bool saved);
|
2015-07-18 14:39:33 +02:00
|
|
|
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-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;
|
|
|
|
|
2020-10-03 16:47:42 +02:00
|
|
|
bool EvalFormula(const QString &formula, bool fromUser, VContainer *data, QLabel *label, bool specialUnits);
|
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);
|
2020-10-01 18:06:20 +02:00
|
|
|
void HackDimensionBaseValue();
|
2020-10-03 17:52:31 +02:00
|
|
|
void HackDimensionShifts();
|
2018-01-31 13:34:50 +01:00
|
|
|
|
2018-02-07 10:00:25 +01:00
|
|
|
QString CheckMName(const QString &name, const QSet<QString> &importedNames) const;
|
2018-01-31 13:34:50 +01:00
|
|
|
void ShowError(const QString &text);
|
|
|
|
void RefreshDataAfterImport();
|
|
|
|
|
2020-10-10 18:31:23 +02:00
|
|
|
void ImportIndividualMeasurements(const QxtCsvModel &csv, const QVector<int> &map);
|
|
|
|
void ImportMultisizeMeasurements(const QxtCsvModel &csv, const QVector<int> &map);
|
2019-03-14 10:53:08 +01:00
|
|
|
|
|
|
|
void SetCurrentPatternUnit();
|
2020-10-01 15:56:44 +02:00
|
|
|
|
2020-10-03 06:34:25 +02:00
|
|
|
void ShowDimensionControls();
|
|
|
|
void SetDimensionBases();
|
|
|
|
void SetCurrentDimensionValues();
|
|
|
|
|
2021-01-18 19:43:53 +01:00
|
|
|
QVector<double> DimensionRestrictedValues(int index, const MeasurementDimension_p &dimension);
|
2020-10-05 10:45:16 +02:00
|
|
|
|
|
|
|
QMap<int, QSharedPointer<VMeasurement> > OrderedMeasurments() const;
|
2015-07-10 11:49:37 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TMAINWINDOW_H
|