Little refactoring.
--HG-- branch : develop
This commit is contained in:
parent
01f4cc16c6
commit
33b0ac8b21
|
@ -50,7 +50,7 @@ DialogHistory::DialogHistory(VContainer *data, VDomDocument *doc, QWidget *paren
|
|||
connect(ui->tableWidget, &QTableWidget::cellClicked, this, &DialogHistory::cellClicked);
|
||||
connect(this, &DialogHistory::ShowHistoryTool, doc, &VDomDocument::ShowHistoryTool);
|
||||
connect(doc, &VDomDocument::ChangedCursor, this, &DialogHistory::ChangedCursor);
|
||||
connect(doc, &VDomDocument::haveChange, this, &DialogHistory::UpdateHistory);
|
||||
connect(doc, &VDomDocument::patternChanged, this, &DialogHistory::UpdateHistory);
|
||||
connect(doc, &VDomDocument::ChangedActivDraw, this, &DialogHistory::UpdateHistory);
|
||||
ShowPoint();
|
||||
}
|
||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -69,8 +69,7 @@ int main(int argc, char *argv[])
|
|||
VApplication app(argc, argv);
|
||||
|
||||
QTranslator qtTranslator;
|
||||
qtTranslator.load("qt_" + QLocale::system().name(),
|
||||
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
app.installTranslator(&qtTranslator);
|
||||
|
||||
QTranslator appTranslator;
|
||||
|
@ -85,6 +84,11 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
app.installTranslator(&appTranslator);
|
||||
|
||||
app.setApplicationDisplayName("Valentina");
|
||||
app.setApplicationName("Valentina");
|
||||
app.setOrganizationName("ValentinaTeam");
|
||||
app.setOrganizationDomain("valentinaproject.bitbucket.org");
|
||||
|
||||
MainWindow w;
|
||||
w.setWindowState(w.windowState() ^ Qt::WindowMaximized);
|
||||
app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png"));
|
||||
|
@ -106,7 +110,7 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
fileName = args.at(i+1);
|
||||
qDebug() << args.at(i)<< ":" << fileName;
|
||||
w.OpenPattern(fileName);
|
||||
w.LoadPattern(fileName);
|
||||
}
|
||||
w.show();
|
||||
break;
|
||||
|
|
|
@ -78,8 +78,8 @@ private:
|
|||
MainWindow::MainWindow(QWidget *parent)
|
||||
:QMainWindow(parent), ui(new Ui::MainWindow), pattern(0), doc(0), tool(Tool::ArrowTool), currentScene(0),
|
||||
sceneDraw(0), sceneDetails(0), mouseCoordinate(0), helpLabel(0), view(0), isInitialized(false), dialogTable(0),
|
||||
dialogTool(0), dialogHistory(0), comboBoxDraws(0), fileName(QString()), changeInFile(false),
|
||||
mode(Draw::Calculation), currentDrawIndex(0), currentToolBoxIndex(0), drawMode(true)
|
||||
dialogTool(0), dialogHistory(0), comboBoxDraws(0), curFile(QString()), mode(Draw::Calculation),
|
||||
currentDrawIndex(0), currentToolBoxIndex(0), drawMode(true)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
static const char * GENERIC_ICON_TO_CHECK = "document-open";
|
||||
|
@ -121,10 +121,10 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(ui->actionDetails, &QAction::triggered, this, &MainWindow::ActionDetails);
|
||||
connect(ui->actionNewDraw, &QAction::triggered, this, &MainWindow::ActionNewDraw);
|
||||
connect(ui->actionOptionDraw, &QAction::triggered, this, &MainWindow::OptionDraw);
|
||||
connect(ui->actionSaveAs, &QAction::triggered, this, &MainWindow::ActionSaveAs);
|
||||
connect(ui->actionSave, &QAction::triggered, this, &MainWindow::ActionSave);
|
||||
connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::ActionOpen);
|
||||
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::ActionNew);
|
||||
connect(ui->actionSaveAs, &QAction::triggered, this, &MainWindow::SaveAs);
|
||||
connect(ui->actionSave, &QAction::triggered, this, &MainWindow::Save);
|
||||
connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::Open);
|
||||
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::NewPattern);
|
||||
connect(ui->actionTable, &QAction::triggered, this, &MainWindow::ActionTable);
|
||||
connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine);
|
||||
connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine);
|
||||
|
@ -150,7 +150,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
doc = new VDomDocument(pattern, comboBoxDraws, &mode);
|
||||
doc->CreateEmptyFile();
|
||||
connect(doc, &VDomDocument::haveChange, this, &MainWindow::haveChange);
|
||||
connect(doc, &VDomDocument::patternChanged, this, &MainWindow::PatternWasModified);
|
||||
|
||||
//Autosaving file each 5 minutes
|
||||
QTimer *timer = new QTimer(this);
|
||||
|
@ -163,6 +163,10 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close);
|
||||
|
||||
ui->toolBox->setCurrentIndex(0);
|
||||
|
||||
ReadSettings();
|
||||
|
||||
setCurrentFile("");
|
||||
}
|
||||
|
||||
void MainWindow::ActionNewDraw()
|
||||
|
@ -220,7 +224,6 @@ void MainWindow::ActionNewDraw()
|
|||
VDrawTool::AddRecord(id, Tool::SinglePointTool, doc);
|
||||
SetEnableTool(true);
|
||||
SetEnableWidgets(true);
|
||||
changeInFile = true;
|
||||
|
||||
index = comboBoxDraws->findText(nameDraw);
|
||||
if ( index != -1 )
|
||||
|
@ -580,51 +583,14 @@ void MainWindow::showEvent( QShowEvent *event )
|
|||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (changeInFile == true)
|
||||
if (MaybeSave())
|
||||
{
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setText(tr("The pattern has been modified."));
|
||||
msgBox.setInformativeText(tr("Do you want to save your changes?"));
|
||||
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||
msgBox.setDefaultButton(QMessageBox::Save);
|
||||
msgBox.setIcon(QMessageBox::Question);
|
||||
int ret = msgBox.exec();
|
||||
switch (ret)
|
||||
{
|
||||
case QMessageBox::Save:
|
||||
// Save was clicked
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
ActionSaveAs();
|
||||
}
|
||||
else
|
||||
{
|
||||
ActionSave();
|
||||
}
|
||||
if (changeInFile)
|
||||
{
|
||||
// We did't save file
|
||||
event->ignore();
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have successfully saved the file
|
||||
event->accept();
|
||||
}
|
||||
break;
|
||||
case QMessageBox::Discard:
|
||||
// Don't Save was clicked
|
||||
event->accept();
|
||||
break;
|
||||
case QMessageBox::Cancel:
|
||||
// Cancel was clicked
|
||||
event->ignore();
|
||||
break;
|
||||
default:
|
||||
// should never be reached
|
||||
event->accept();
|
||||
break;
|
||||
}
|
||||
WriteSettings();
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -950,113 +916,77 @@ void MainWindow::ActionDetails(bool checked)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::ActionSaveAs()
|
||||
bool MainWindow::SaveAs()
|
||||
{
|
||||
QString filters(tr("Pattern files (*.val)"));
|
||||
QString dir = QDir::homePath() + tr("/pattern.val");
|
||||
QString fName = QFileDialog::getSaveFileName(this, tr("Save as"), dir, filters);
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir, filters);
|
||||
|
||||
if (fName.isEmpty())
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
QFileInfo f( fName );
|
||||
QFileInfo f( fileName );
|
||||
if (f.suffix().isEmpty() && f.suffix() != "val")
|
||||
{
|
||||
fName += ".val";
|
||||
fileName += ".val";
|
||||
}
|
||||
fileName = fName;
|
||||
|
||||
ActionSave();
|
||||
return SavePattern(fileName);
|
||||
}
|
||||
|
||||
void MainWindow::ActionSave()
|
||||
bool MainWindow::Save()
|
||||
{
|
||||
if (fileName.isEmpty() == false)
|
||||
if (curFile.isEmpty())
|
||||
{
|
||||
bool result = SafeSaveing(fileName);
|
||||
if (result)
|
||||
{
|
||||
ui->actionSave->setEnabled(false);
|
||||
changeInFile = false;
|
||||
QFileInfo info(fileName);
|
||||
QString title(info.fileName());
|
||||
title.append("-Valentina");
|
||||
setWindowTitle(title);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error!"));
|
||||
msgBox.setText(tr("Error saving file. Can't save file."));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::ActionOpen()
|
||||
{
|
||||
QString filter(tr("Pattern files (*.val)"));
|
||||
QString fName = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter);
|
||||
if (fName.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (fileName.isEmpty() && changeInFile == false)
|
||||
{
|
||||
OpenPattern(fName);
|
||||
|
||||
VAbstractTool::NewSceneRect(sceneDraw, view);
|
||||
VAbstractTool::NewSceneRect(sceneDetails, view);
|
||||
return SaveAs();
|
||||
}
|
||||
else
|
||||
{
|
||||
/*Open new copy application*/
|
||||
QProcess *v = new QProcess(this);
|
||||
QStringList arguments;
|
||||
arguments << "-o" << fName;
|
||||
v->startDetached(QCoreApplication::applicationFilePath (), arguments);
|
||||
delete v;
|
||||
return SavePattern(curFile);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::Open()
|
||||
{
|
||||
if (MaybeSave())
|
||||
{
|
||||
QString filter(tr("Pattern files (*.val)"));
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter);
|
||||
if (fileName.isEmpty() == false)
|
||||
{
|
||||
LoadPattern(fileName);
|
||||
|
||||
VAbstractTool::NewSceneRect(sceneDraw, view);
|
||||
VAbstractTool::NewSceneRect(sceneDetails, view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::Clear()
|
||||
{
|
||||
setWindowTitle("Valentina");
|
||||
fileName.clear();
|
||||
setCurrentFile("");
|
||||
pattern->Clear();
|
||||
doc->clear();
|
||||
sceneDraw->clear();
|
||||
sceneDetails->clear();
|
||||
CancelTool();
|
||||
comboBoxDraws->clear();
|
||||
fileName.clear();
|
||||
ui->actionOptionDraw->setEnabled(false);
|
||||
ui->actionSave->setEnabled(false);
|
||||
SetEnableTool(false);
|
||||
}
|
||||
|
||||
void MainWindow::ActionNew()
|
||||
void MainWindow::NewPattern()
|
||||
{
|
||||
QProcess *v = new QProcess(this);
|
||||
v->startDetached(QCoreApplication::applicationFilePath ());
|
||||
delete v;
|
||||
}
|
||||
|
||||
void MainWindow::haveChange()
|
||||
void MainWindow::PatternWasModified()
|
||||
{
|
||||
if (fileName.isEmpty() == false)
|
||||
{
|
||||
ui->actionSave->setEnabled(true);
|
||||
changeInFile = true;
|
||||
QFileInfo info(fileName);
|
||||
QString title(info.fileName());
|
||||
title.append("*-Valentina");
|
||||
setWindowTitle(title);
|
||||
}
|
||||
setWindowModified(doc->isPatternModified());
|
||||
ui->actionSave->setEnabled(true);
|
||||
}
|
||||
|
||||
void MainWindow::ChangedSize(const QString & text)
|
||||
|
@ -1079,7 +1009,7 @@ void MainWindow::SetEnableWidgets(bool enable)
|
|||
ui->actionDraw->setEnabled(enable);
|
||||
ui->actionDetails->setEnabled(enable);
|
||||
ui->actionOptionDraw->setEnabled(enable);
|
||||
if (enable == true && fileName.isEmpty() == false)
|
||||
if (enable == true && curFile.isEmpty() == false)
|
||||
{
|
||||
ui->actionSave->setEnabled(enable);
|
||||
}
|
||||
|
@ -1140,7 +1070,7 @@ void MainWindow::ActionLayout(bool checked)
|
|||
QPainterPath path = VEquidistant().ContourPath(idetail.key(), pattern);
|
||||
listDetails.append(new VItem(path, listDetails.size()));
|
||||
}
|
||||
emit ModelChosen(listDetails, fileName);
|
||||
emit ModelChosen(listDetails, curFile);
|
||||
}
|
||||
|
||||
void MainWindow::ClosedActionHistory()
|
||||
|
@ -1196,27 +1126,18 @@ void MainWindow::MinimumScrollBar()
|
|||
bool MainWindow::ValidatePattern(const QString &schema, const QString &fileName, QString &errorMsg, qint64 &errorLine,
|
||||
qint64 &errorColumn) const
|
||||
{
|
||||
errorLine = -1;
|
||||
errorColumn = -1;
|
||||
QFile pattern(fileName);
|
||||
if (pattern.open(QIODevice::ReadOnly) == false)
|
||||
{
|
||||
errorMsg = QString(tr("Can't open pattern file."));
|
||||
errorLine = -1;
|
||||
errorColumn = -1;
|
||||
return false;
|
||||
}
|
||||
if (schema.isEmpty())
|
||||
{
|
||||
errorMsg = QString(tr("Empty schema path."));
|
||||
errorLine = -1;
|
||||
errorColumn = -1;
|
||||
errorMsg = QString(tr("Can't open pattern file %1:\n%2.").arg(fileName).arg(pattern.errorString()));
|
||||
return false;
|
||||
}
|
||||
QFile fileSchema(schema);
|
||||
if (fileSchema.open(QIODevice::ReadOnly) == false)
|
||||
{
|
||||
errorMsg = QString(tr("Can't open schema file."));
|
||||
errorLine = -1;
|
||||
errorColumn = -1;
|
||||
errorMsg = QString(tr("Can't open schema file %1:\n%2.").arg(schema).arg(fileSchema.errorString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1252,7 +1173,7 @@ bool MainWindow::ValidatePattern(const QString &schema, const QString &fileName,
|
|||
}
|
||||
}
|
||||
|
||||
bool MainWindow::SafeSaveing(const QString &fileName) const
|
||||
bool MainWindow::SavePattern(const QString &fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1260,15 +1181,7 @@ bool MainWindow::SafeSaveing(const QString &fileName) const
|
|||
}
|
||||
catch (const VExceptionUniqueId &e)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setWindowTitle(tr("Error!"));
|
||||
msgBox.setText(tr("Error no unique id."));
|
||||
msgBox.setInformativeText(e.ErrorMessage());
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.setDetailedText(e.DetailedInformation());
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.exec();
|
||||
e.CriticalMessageBox(tr("Error no unique id."), this);
|
||||
return false;
|
||||
}
|
||||
if (fileName.isEmpty())
|
||||
|
@ -1279,7 +1192,6 @@ bool MainWindow::SafeSaveing(const QString &fileName) const
|
|||
//Writing in temporary file
|
||||
QFileInfo tempInfo(fileName);
|
||||
QString temp = tempInfo.absolutePath() + "/" + tempInfo.baseName() + ".tmp";
|
||||
qDebug()<<"file "<<fileName<<"temp file "<<temp;
|
||||
QFile tempFile(temp);
|
||||
if (tempFile.open(QIODevice::WriteOnly| QIODevice::Truncate))
|
||||
{
|
||||
|
@ -1301,7 +1213,7 @@ bool MainWindow::SafeSaveing(const QString &fileName) const
|
|||
{
|
||||
if ( tempFile.copy(patternFile.fileName()) == false )
|
||||
{
|
||||
qCritical()<<tr("Could not copy temp file to pattern file")<<Q_FUNC_INFO;
|
||||
qWarning()<<tr("Could not copy temp file to pattern file")<<Q_FUNC_INFO;
|
||||
tempOfPattern.copy(fileName);
|
||||
result = false;
|
||||
}
|
||||
|
@ -1312,33 +1224,82 @@ bool MainWindow::SafeSaveing(const QString &fileName) const
|
|||
}
|
||||
else
|
||||
{
|
||||
qCritical()<<tr("Could not remove pattern file")<<Q_FUNC_INFO;
|
||||
qWarning()<<tr("Could not remove pattern file")<<Q_FUNC_INFO;
|
||||
result = false;
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
tempFile.remove();
|
||||
setCurrentFile(fileName);
|
||||
helpLabel->setText(tr("File saved"));
|
||||
ui->actionSave->setEnabled(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void MainWindow::AutoSavePattern()
|
||||
{
|
||||
if (fileName.isEmpty() == false && changeInFile == true)
|
||||
if (curFile.isEmpty() == false && doc->isPatternModified() == true)
|
||||
{
|
||||
bool result = SafeSaveing(fileName);
|
||||
if (result)
|
||||
if (Save() == false)
|
||||
{
|
||||
ui->actionSave->setEnabled(false);
|
||||
changeInFile = false;
|
||||
QFileInfo info(fileName);
|
||||
QString title(info.fileName());
|
||||
title.append("-Valentina");
|
||||
setWindowTitle(title);
|
||||
qWarning()<<tr("Can not save pattern")<<Q_FUNC_INFO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setCurrentFile(const QString &fileName)
|
||||
{
|
||||
curFile = fileName;
|
||||
doc->setPatternModified(false);
|
||||
setWindowModified(false);
|
||||
|
||||
QString shownName = strippedName(curFile);
|
||||
if (curFile.isEmpty())
|
||||
{
|
||||
shownName = tr("untitled.val");
|
||||
}
|
||||
shownName+="[*]";
|
||||
setWindowTitle(shownName);
|
||||
}
|
||||
|
||||
QString MainWindow::strippedName(const QString &fullFileName)
|
||||
{
|
||||
return QFileInfo(fullFileName).fileName();
|
||||
}
|
||||
|
||||
void MainWindow::ReadSettings()
|
||||
{
|
||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, "ValentinaTeam", "Valentina");
|
||||
QPoint pos = settings.value("pos", QPoint(10, 10)).toPoint();
|
||||
QSize size = settings.value("size", QSize(1000, 800)).toSize();
|
||||
resize(size);
|
||||
move(pos);
|
||||
}
|
||||
|
||||
void MainWindow::WriteSettings()
|
||||
{
|
||||
QSettings settings(QSettings::IniFormat, QSettings::UserScope, "ValentinaTeam", "Valentina");
|
||||
settings.setValue("pos", pos());
|
||||
settings.setValue("size", size());
|
||||
}
|
||||
|
||||
bool MainWindow::MaybeSave()
|
||||
{
|
||||
if (doc->isPatternModified())
|
||||
{
|
||||
QMessageBox::StandardButton ret;
|
||||
ret = QMessageBox::warning(this, tr("Unsaved change"), tr("The pattern has been modified.\n"
|
||||
"Do you want to save your changes?"),
|
||||
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
||||
if (ret == QMessageBox::Save)
|
||||
return Save();
|
||||
else if (ret == QMessageBox::Cancel)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
CancelTool();
|
||||
|
@ -1350,13 +1311,8 @@ MainWindow::~MainWindow()
|
|||
delete sceneDraw;
|
||||
}
|
||||
|
||||
void MainWindow::OpenPattern(const QString &fileName)
|
||||
void MainWindow::LoadPattern(const QString &fileName)
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
qWarning()<<tr("Can't open pattern file. File name is empty")<<Q_FUNC_INFO;
|
||||
return;
|
||||
}
|
||||
QFile file(fileName);
|
||||
QString errorMsg;
|
||||
qint64 errorLine = 0;
|
||||
|
@ -1373,7 +1329,13 @@ void MainWindow::OpenPattern(const QString &fileName)
|
|||
this, &MainWindow::currentDrawChanged);
|
||||
try
|
||||
{
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
#endif
|
||||
doc->Parse(Document::FullParse, sceneDraw, sceneDetails);
|
||||
#ifndef QT_NO_CURSOR
|
||||
QApplication::restoreOverrideCursor();
|
||||
#endif
|
||||
}
|
||||
catch (const VExceptionObjectError &e)
|
||||
{
|
||||
|
@ -1463,12 +1425,10 @@ void MainWindow::OpenPattern(const QString &fileName)
|
|||
}
|
||||
else
|
||||
{
|
||||
qWarning()<<tr("Can't open pattern file.")<<Q_FUNC_INFO;
|
||||
QMessageBox::warning(this, tr("Valentina"), tr("Cannot read file %1:\n%2.")
|
||||
.arg(fileName)
|
||||
.arg(file.errorString()));
|
||||
}
|
||||
this->fileName = fileName;
|
||||
QFileInfo info(fileName);
|
||||
QString title(info.fileName());
|
||||
title.append("-Valentina");
|
||||
setWindowTitle(title);
|
||||
helpLabel->setText("");
|
||||
setCurrentFile(fileName);
|
||||
helpLabel->setText(tr("File loaded"));
|
||||
}
|
||||
|
|
|
@ -58,10 +58,10 @@ public:
|
|||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
/**
|
||||
* @brief OpenPattern open pattern file.
|
||||
* @brief LoadPattern open pattern file.
|
||||
* @param fileName name of file.
|
||||
*/
|
||||
void OpenPattern(const QString &fileName);
|
||||
void LoadPattern(const QString &curFile);
|
||||
public slots:
|
||||
/**
|
||||
* @brief mouseMove save mouse position and show user.
|
||||
|
@ -87,21 +87,23 @@ public slots:
|
|||
*/
|
||||
void ActionNewDraw();
|
||||
/**
|
||||
* @brief ActionSaveAs save as pattern file.
|
||||
* @brief SaveAs save as pattern file.
|
||||
* @return true for successes saving.
|
||||
*/
|
||||
void ActionSaveAs();
|
||||
bool SaveAs();
|
||||
/**
|
||||
* @brief ActionSave save pattern file.
|
||||
* @brief Save save pattern file.
|
||||
* @return true for successes saving.
|
||||
*/
|
||||
void ActionSave();
|
||||
bool Save();
|
||||
/**
|
||||
* @brief ActionOpen ask user select pattern file.
|
||||
* @brief Open ask user select pattern file.
|
||||
*/
|
||||
void ActionOpen();
|
||||
void Open();
|
||||
/**
|
||||
* @brief ActionNew create new empty pattern.
|
||||
* @brief NewPattern create new empty pattern.
|
||||
*/
|
||||
void ActionNew();
|
||||
void NewPattern();
|
||||
/**
|
||||
* @brief ActionTable show table with variables.
|
||||
* @param checked true - button checked.
|
||||
|
@ -129,7 +131,7 @@ public slots:
|
|||
/**
|
||||
* @brief haveChange enable action save if we have unsaved change.
|
||||
*/
|
||||
void haveChange();
|
||||
void PatternWasModified();
|
||||
/**
|
||||
* @brief ChangedSize change new size value.
|
||||
* @param text value size.
|
||||
|
@ -360,7 +362,7 @@ signals:
|
|||
* @brief ModelChosen emit after calculation all details.
|
||||
* @param listDetails list of details.
|
||||
*/
|
||||
void ModelChosen(QVector<VItem*> listDetails, const QString &fileName);
|
||||
void ModelChosen(QVector<VItem*> listDetails, const QString &curFile);
|
||||
protected:
|
||||
/**
|
||||
* @brief keyPressEvent handle key press events.
|
||||
|
@ -437,11 +439,7 @@ private:
|
|||
/**
|
||||
* @brief fileName name current pattern file.
|
||||
*/
|
||||
QString fileName;
|
||||
/**
|
||||
* @brief changeInFile true if exist change in file.
|
||||
*/
|
||||
bool changeInFile;
|
||||
QString curFile;
|
||||
/**
|
||||
* @brief mode keep current draw mode.
|
||||
*/
|
||||
|
@ -516,7 +514,7 @@ private:
|
|||
* @param errorColumn number error column.
|
||||
* @return true if validation successful.
|
||||
*/
|
||||
bool ValidatePattern(const QString &schema, const QString &fileName, QString &errorMsg, qint64 &errorLine,
|
||||
bool ValidatePattern(const QString &schema, const QString &curFile, QString &errorMsg, qint64 &errorLine,
|
||||
qint64 &errorColumn) const;
|
||||
template <typename DrawTool>
|
||||
/**
|
||||
|
@ -525,15 +523,40 @@ private:
|
|||
*/
|
||||
void ClosedDialog(int result);
|
||||
/**
|
||||
* @brief SafeSaveing safe saving pattern file.
|
||||
* @brief SavePattern save pattern file.
|
||||
* @param fileName pattern file name.
|
||||
* @return true if all is all right.
|
||||
* @return true if all is good.
|
||||
*/
|
||||
bool SafeSaveing(const QString &fileName)const;
|
||||
bool SavePattern(const QString &curFile);
|
||||
/**
|
||||
* @brief AutoSavePattern start safe saving.
|
||||
*/
|
||||
void AutoSavePattern();
|
||||
/**
|
||||
* @brief setCurrentFile the function is called to reset the state of a few variables when a file
|
||||
* is loaded or saved, or when the user starts editing a new file (in which case fileName is empty).
|
||||
* @param fileName file name.
|
||||
*/
|
||||
void setCurrentFile(const QString &fileName);
|
||||
/**
|
||||
* @brief strippedName the function call around curFile to exclude the path to the file.
|
||||
* @param fullFileName full path to the file.
|
||||
* @return file name.
|
||||
*/
|
||||
QString strippedName(const QString &fullFileName);
|
||||
/**
|
||||
* @brief ReadSettings read setting for app.
|
||||
*/
|
||||
void ReadSettings();
|
||||
/**
|
||||
* @brief WriteSettings save setting for app.
|
||||
*/
|
||||
void WriteSettings();
|
||||
/**
|
||||
* @brief MaybeSave The function is called to save pending changes.
|
||||
* @return returns true in all cases, except when the user clicks Cancel.
|
||||
*/
|
||||
bool MaybeSave();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -47,8 +47,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>150</width>
|
||||
<height>144</height>
|
||||
<width>144</width>
|
||||
<height>150</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -302,8 +302,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>150</width>
|
||||
<height>56</height>
|
||||
<width>100</width>
|
||||
<height>58</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -378,8 +378,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>150</width>
|
||||
<height>100</height>
|
||||
<width>100</width>
|
||||
<height>104</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -507,7 +507,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>150</width>
|
||||
<height>56</height>
|
||||
<height>58</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -579,8 +579,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>150</width>
|
||||
<height>56</height>
|
||||
<width>100</width>
|
||||
<height>58</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -664,7 +664,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1100</width>
|
||||
<height>21</height>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
@ -709,7 +709,6 @@
|
|||
<addaction name="actionNew"/>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSaveAs"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
|
|
|
@ -43,19 +43,19 @@
|
|||
VDomDocument::VDomDocument(VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode, QObject *parent)
|
||||
: QObject(parent), QDomDocument(), map(QHash<QString, QDomElement>()), nameActivDraw(QString()), data(data),
|
||||
tools(QHash<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0),
|
||||
comboBoxDraws(comboBoxDraws), mode(mode){}
|
||||
comboBoxDraws(comboBoxDraws), mode(mode), patternModified(false){}
|
||||
|
||||
VDomDocument::VDomDocument(const QString& name, VContainer *data, QComboBox *comboBoxDraws, Draw::Draws *mode,
|
||||
QObject *parent)
|
||||
:QObject(parent), QDomDocument(name), map(QHash<QString, QDomElement>()), nameActivDraw(QString()), data(data),
|
||||
tools(QHash<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0),
|
||||
comboBoxDraws(comboBoxDraws), mode(mode){}
|
||||
comboBoxDraws(comboBoxDraws), mode(mode), patternModified(false){}
|
||||
|
||||
VDomDocument::VDomDocument(const QDomDocumentType& doctype, VContainer *data, QComboBox *comboBoxDraws,
|
||||
Draw::Draws *mode, QObject *parent)
|
||||
:QObject(parent), QDomDocument(doctype), map(QHash<QString, QDomElement>()), nameActivDraw(QString()), data(data),
|
||||
tools(QHash<qint64, VDataTool*>()), history(QVector<VToolRecord>()), cursor(0),
|
||||
comboBoxDraws(comboBoxDraws), mode(mode){}
|
||||
comboBoxDraws(comboBoxDraws), mode(mode), patternModified(false){}
|
||||
|
||||
QDomElement VDomDocument::elementById(const QString& id)
|
||||
{
|
||||
|
@ -223,7 +223,7 @@ bool VDomDocument::SetNameDraw(const QString& name)
|
|||
{
|
||||
nameActivDraw = name;
|
||||
element.setAttribute("name", nameActivDraw);
|
||||
emit haveChange();
|
||||
emit patternChanged();
|
||||
emit ChangedNameDraw(oldName, nameActivDraw);
|
||||
return true;
|
||||
}
|
||||
|
@ -1346,13 +1346,24 @@ void VDomDocument::FullUpdateTree()
|
|||
|
||||
void VDomDocument::haveLiteChange()
|
||||
{
|
||||
emit haveChange();
|
||||
patternModified = true;
|
||||
emit patternChanged();
|
||||
}
|
||||
|
||||
void VDomDocument::ShowHistoryTool(qint64 id, Qt::GlobalColor color, bool enable)
|
||||
{
|
||||
emit ShowTool(id, color, enable);
|
||||
}
|
||||
bool VDomDocument::isPatternModified() const
|
||||
{
|
||||
return patternModified;
|
||||
}
|
||||
|
||||
void VDomDocument::setPatternModified(bool value)
|
||||
{
|
||||
patternModified = value;
|
||||
}
|
||||
|
||||
|
||||
void VDomDocument::setCursor(const qint64 &value)
|
||||
{
|
||||
|
|
|
@ -239,6 +239,8 @@ public:
|
|||
* @return id base point.
|
||||
*/
|
||||
qint64 SPointActiveDraw();
|
||||
bool isPatternModified() const;
|
||||
void setPatternModified(bool value);
|
||||
signals:
|
||||
/**
|
||||
* @brief ChangedActivDraw change active pattern peace.
|
||||
|
@ -256,9 +258,9 @@ signals:
|
|||
*/
|
||||
void FullUpdateFromFile();
|
||||
/**
|
||||
* @brief haveChange emit if we have unsaved change.
|
||||
* @brief patternChanged emit if we have unsaved change.
|
||||
*/
|
||||
void haveChange();
|
||||
void patternChanged();
|
||||
/**
|
||||
* @brief ShowTool highlight tool.
|
||||
* @param id tool id.
|
||||
|
@ -321,6 +323,10 @@ private:
|
|||
* @brief mode current draw mode.
|
||||
*/
|
||||
Draw::Draws *mode;
|
||||
/**
|
||||
* @brief fileModified true if exist change in file.
|
||||
*/
|
||||
bool patternModified;
|
||||
/**
|
||||
* @brief find find element by id.
|
||||
* @param node node.
|
||||
|
|
Loading…
Reference in New Issue
Block a user