Resolved issue #619. Non writable directory prevents opening.
--HG-- branch : develop
This commit is contained in:
parent
4831d263b9
commit
7d78a0f63f
|
@ -54,6 +54,7 @@
|
||||||
- [#88] New feature: Variable width seam allowances.
|
- [#88] New feature: Variable width seam allowances.
|
||||||
- [#280] New tool: 'Hem' in Detail mode.
|
- [#280] New tool: 'Hem' in Detail mode.
|
||||||
- [#509] Improve feature: Support internal Paths in Detail tool.
|
- [#509] Improve feature: Support internal Paths in Detail tool.
|
||||||
|
- [#619] Non writable directory prevents opening.
|
||||||
|
|
||||||
# Version 0.4.6
|
# Version 0.4.6
|
||||||
- [#594] Broken export on Mac.
|
- [#594] Broken export on Mac.
|
||||||
|
|
|
@ -95,6 +95,7 @@ TMainWindow::TMainWindow(QWidget *parent)
|
||||||
actionDockDiagram(nullptr),
|
actionDockDiagram(nullptr),
|
||||||
dockDiagramVisible(true),
|
dockDiagramVisible(true),
|
||||||
isInitialized(false),
|
isInitialized(false),
|
||||||
|
mIsReadOnly(false),
|
||||||
recentFileActs(),
|
recentFileActs(),
|
||||||
separatorAct(nullptr),
|
separatorAct(nullptr),
|
||||||
hackedWidgets()
|
hackedWidgets()
|
||||||
|
@ -128,9 +129,7 @@ TMainWindow::TMainWindow(QWidget *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupMenu();
|
SetupMenu();
|
||||||
|
UpdateWindowTitle();
|
||||||
setWindowTitle(tr("untitled %1").arg(qApp->MainWindows().size()+1));
|
|
||||||
|
|
||||||
ReadSettings();
|
ReadSettings();
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
|
@ -269,20 +268,14 @@ bool TMainWindow::LoadFile(const QString &path)
|
||||||
if (mType == MeasurementsType::Standard)
|
if (mType == MeasurementsType::Standard)
|
||||||
{
|
{
|
||||||
VVSTConverter converter(path);
|
VVSTConverter converter(path);
|
||||||
converter.Convert();
|
m->setXMLContent(converter.Convert());// Read again after conversion
|
||||||
|
|
||||||
VDomDocument::ValidateXML(VVSTConverter::CurrentSchema, path);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VVITConverter converter(path);
|
VVITConverter converter(path);
|
||||||
converter.Convert();
|
m->setXMLContent(converter.Convert());// Read again after conversion
|
||||||
|
|
||||||
VDomDocument::ValidateXML(VVITConverter::CurrentSchema, path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m->setXMLContent(path);// Read again after conversion
|
|
||||||
|
|
||||||
if (not m->IsDefinedKnownNamesValid())
|
if (not m->IsDefinedKnownNamesValid())
|
||||||
{
|
{
|
||||||
VException e(tr("File contains invalid known measurement(s)."));
|
VException e(tr("File contains invalid known measurement(s)."));
|
||||||
|
@ -298,6 +291,9 @@ bool TMainWindow::LoadFile(const QString &path)
|
||||||
ui->labelToolTip->setVisible(false);
|
ui->labelToolTip->setVisible(false);
|
||||||
ui->tabWidget->setVisible(true);
|
ui->tabWidget->setVisible(true);
|
||||||
|
|
||||||
|
mIsReadOnly = m->IsReadOnly();
|
||||||
|
UpdatePadlock(mIsReadOnly);
|
||||||
|
|
||||||
SetCurrentFile(path);
|
SetCurrentFile(path);
|
||||||
|
|
||||||
InitWindow();
|
InitWindow();
|
||||||
|
@ -309,7 +305,7 @@ bool TMainWindow::LoadFile(const QString &path)
|
||||||
ui->tableWidget->selectRow(0);
|
ui->tableWidget->selectRow(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUIReadOnly(m->ReadOnly()); // Keep last
|
MeasurementGUI();
|
||||||
}
|
}
|
||||||
catch (VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
|
@ -367,12 +363,15 @@ void TMainWindow::FileNew()
|
||||||
m = new VMeasurements(mUnit, data);
|
m = new VMeasurements(mUnit, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mIsReadOnly = m->IsReadOnly();
|
||||||
|
UpdatePadlock(mIsReadOnly);
|
||||||
|
|
||||||
SetCurrentFile("");
|
SetCurrentFile("");
|
||||||
MeasurementsWasSaved(false);
|
MeasurementsWasSaved(false);
|
||||||
|
|
||||||
InitWindow();
|
InitWindow();
|
||||||
|
|
||||||
GUIReadOnly(m->ReadOnly()); // Keep last
|
MeasurementGUI();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -608,45 +607,93 @@ bool TMainWindow::eventFilter(QObject *object, QEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::FileSave()
|
bool TMainWindow::FileSave()
|
||||||
{
|
{
|
||||||
if (curFile.isEmpty())
|
if (curFile.isEmpty() || mIsReadOnly)
|
||||||
{
|
{
|
||||||
return FileSaveAs();
|
return FileSaveAs();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qt_ntfs_permission_lookup++; // turn checking on
|
||||||
|
#endif /*Q_OS_WIN32*/
|
||||||
|
const bool isFileWritable = QFileInfo(curFile).isWritable();
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qt_ntfs_permission_lookup--; // turn it off again
|
||||||
|
#endif /*Q_OS_WIN32*/
|
||||||
|
|
||||||
|
if (not isFileWritable)
|
||||||
|
{
|
||||||
|
QMessageBox messageBox(this);
|
||||||
|
messageBox.setIcon(QMessageBox::Question);
|
||||||
|
messageBox.setText(tr("The measurements document has no write permissions."));
|
||||||
|
messageBox.setInformativeText("Do you want to change the premissions?");
|
||||||
|
messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
|
||||||
|
messageBox.setDefaultButton(QMessageBox::Yes);
|
||||||
|
|
||||||
|
if (messageBox.exec() == QMessageBox::Yes)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qt_ntfs_permission_lookup++; // turn checking on
|
||||||
|
#endif /*Q_OS_WIN32*/
|
||||||
|
bool changed = QFile::setPermissions(curFile,
|
||||||
|
QFileInfo(curFile).permissions() | QFileDevice::WriteUser);
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qt_ntfs_permission_lookup--; // turn it off again
|
||||||
|
#endif /*Q_OS_WIN32*/
|
||||||
|
|
||||||
|
if (not changed)
|
||||||
|
{
|
||||||
|
QMessageBox messageBox(this);
|
||||||
|
messageBox.setIcon(QMessageBox::Warning);
|
||||||
|
messageBox.setText(tr("Cannot set permissions for %1 to writable.").arg(curFile));
|
||||||
|
messageBox.setInformativeText(tr("Could not save the file."));
|
||||||
|
messageBox.setDefaultButton(QMessageBox::Ok);
|
||||||
|
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
messageBox.exec();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString error;
|
QString error;
|
||||||
if (not SaveMeasurements(curFile, error))
|
if (not SaveMeasurements(curFile, error))
|
||||||
{
|
{
|
||||||
QMessageBox messageBox;
|
QMessageBox messageBox;
|
||||||
messageBox.setIcon(QMessageBox::Warning);
|
messageBox.setIcon(QMessageBox::Warning);
|
||||||
messageBox.setInformativeText(tr("Could not save file"));
|
messageBox.setText(tr("Could not save the file"));
|
||||||
messageBox.setDefaultButton(QMessageBox::Ok);
|
messageBox.setDefaultButton(QMessageBox::Ok);
|
||||||
messageBox.setDetailedText(error);
|
messageBox.setDetailedText(error);
|
||||||
messageBox.setStandardButtons(QMessageBox::Ok);
|
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||||
messageBox.exec();
|
messageBox.exec();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::FileSaveAs()
|
bool TMainWindow::FileSaveAs()
|
||||||
{
|
{
|
||||||
QString filters;
|
QString filters;
|
||||||
QString fName = tr("measurements");
|
QString fName = tr("measurements");
|
||||||
QString suffix;
|
QString suffix;
|
||||||
if (mType == MeasurementsType::Individual)
|
if (mType == MeasurementsType::Individual)
|
||||||
{
|
{
|
||||||
filters = tr("Individual measurements (*.vit)");
|
filters = tr("Individual measurements") + QLatin1String(" (*.vit)");
|
||||||
suffix = "vit";
|
suffix = QLatin1String("vit");
|
||||||
fName += "." + suffix;
|
fName += QLatin1String(".") + suffix;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
filters = tr("Standard measurements (*.vst)");
|
filters = tr("Standard measurements") + QLatin1String(" (*.vst)");
|
||||||
suffix = "vst";
|
suffix = QLatin1String("vst");
|
||||||
fName += "." + suffix;
|
fName += QLatin1String(".") + suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString dir;
|
QString dir;
|
||||||
|
@ -654,30 +701,30 @@ void TMainWindow::FileSaveAs()
|
||||||
{
|
{
|
||||||
if (mType == MeasurementsType::Individual)
|
if (mType == MeasurementsType::Individual)
|
||||||
{
|
{
|
||||||
dir = qApp->TapeSettings()->GetPathIndividualMeasurements() + "/" + fName;
|
dir = qApp->TapeSettings()->GetPathIndividualMeasurements() + QLatin1String("/") + fName;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dir = qApp->TapeSettings()->GetPathStandardMeasurements() + "/" + fName;
|
dir = qApp->TapeSettings()->GetPathStandardMeasurements() + QLatin1String("/") + fName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dir = QFileInfo(curFile).absolutePath() + "/" + fName;
|
dir = QFileInfo(curFile).absolutePath() + QLatin1String("/") + fName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir, filters);
|
QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir, filters);
|
||||||
|
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFileInfo f( fileName );
|
QFileInfo f( fileName );
|
||||||
if (f.suffix().isEmpty() && f.suffix() != suffix)
|
if (f.suffix().isEmpty() && f.suffix() != suffix)
|
||||||
{
|
{
|
||||||
fileName += "." + suffix;
|
fileName += QLatin1String(".") + suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QFileInfo(fileName).exists())
|
if (QFileInfo(fileName).exists())
|
||||||
|
@ -688,11 +735,16 @@ void TMainWindow::FileSaveAs()
|
||||||
{
|
{
|
||||||
qCCritical(tMainWindow, "%s",
|
qCCritical(tMainWindow, "%s",
|
||||||
qUtf8Printable(tr("Failed to lock. This file already opened in another window.")));
|
qUtf8Printable(tr("Failed to lock. This file already opened in another window.")));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadOnly(false);
|
// Need for restoring previous state in case of failure
|
||||||
|
const bool readOnly = m->IsReadOnly();
|
||||||
|
|
||||||
|
m->SetReadOnly(false);
|
||||||
|
mIsReadOnly = false;
|
||||||
|
|
||||||
QString error;
|
QString error;
|
||||||
bool result = SaveMeasurements(fileName, error);
|
bool result = SaveMeasurements(fileName, error);
|
||||||
if (result == false)
|
if (result == false)
|
||||||
|
@ -705,16 +757,23 @@ void TMainWindow::FileSaveAs()
|
||||||
messageBox.setStandardButtons(QMessageBox::Ok);
|
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||||
messageBox.exec();
|
messageBox.exec();
|
||||||
|
|
||||||
return;
|
// Restore previous state
|
||||||
|
m->SetReadOnly(readOnly);
|
||||||
|
mIsReadOnly = readOnly;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdatePadlock(false);
|
||||||
|
UpdateWindowTitle();
|
||||||
|
|
||||||
VlpCreateLock(lock, fileName);
|
VlpCreateLock(lock, fileName);
|
||||||
if (not lock->IsLocked())
|
if (not lock->IsLocked())
|
||||||
{
|
{
|
||||||
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("Failed to lock. This file already opened in another window. "
|
qCCritical(tMainWindow, "%s", qUtf8Printable(tr("Failed to lock. This file already opened in another window. "
|
||||||
"Expect collissions when run 2 copies of the program.")));
|
"Expect collissions when run 2 copies of the program.")));
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -925,15 +984,6 @@ void TMainWindow::SavePMSystem(int index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void TMainWindow::ReadOnly(bool ro)
|
|
||||||
{
|
|
||||||
m->SetReadOnly(ro);
|
|
||||||
MeasurementsWasSaved(false);
|
|
||||||
|
|
||||||
GUIReadOnly(ro);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::Remove()
|
void TMainWindow::Remove()
|
||||||
{
|
{
|
||||||
|
@ -1247,19 +1297,12 @@ void TMainWindow::ImportFromPattern()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
qt_ntfs_permission_lookup++; // turn checking on
|
|
||||||
#endif /*Q_OS_WIN32*/
|
|
||||||
|
|
||||||
QStringList measurements;
|
QStringList measurements;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
VPatternConverter converter(mPath);
|
VPatternConverter converter(mPath);
|
||||||
converter.Convert();
|
|
||||||
|
|
||||||
VDomDocument::ValidateXML(VPatternConverter::CurrentSchema, mPath);
|
|
||||||
QScopedPointer<VLitePattern> doc(new VLitePattern());
|
QScopedPointer<VLitePattern> doc(new VLitePattern());
|
||||||
doc->setXMLContent(mPath);
|
doc->setXMLContent(converter.Convert());
|
||||||
measurements = doc->ListMeasurements();
|
measurements = doc->ListMeasurements();
|
||||||
}
|
}
|
||||||
catch (VException &e)
|
catch (VException &e)
|
||||||
|
@ -1269,10 +1312,6 @@ void TMainWindow::ImportFromPattern()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
qt_ntfs_permission_lookup--; // turn it off again
|
|
||||||
#endif /*Q_OS_WIN32*/
|
|
||||||
|
|
||||||
measurements = FilterMeasurements(measurements, m->ListAll());
|
measurements = FilterMeasurements(measurements, m->ListAll());
|
||||||
|
|
||||||
qint32 currentRow;
|
qint32 currentRow;
|
||||||
|
@ -1410,7 +1449,7 @@ void TMainWindow::ShowMData()
|
||||||
ui->plainTextEditFormula->blockSignals(false);
|
ui->plainTextEditFormula->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
MeasurementReadOnly(m->ReadOnly());
|
MeasurementGUI();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1779,7 +1818,23 @@ void TMainWindow::SetupMenu()
|
||||||
ui->actionSaveAs->setShortcuts(QKeySequence::SaveAs);
|
ui->actionSaveAs->setShortcuts(QKeySequence::SaveAs);
|
||||||
|
|
||||||
connect(ui->actionExportToCSV, &QAction::triggered, this, &TMainWindow::ExportToCSV);
|
connect(ui->actionExportToCSV, &QAction::triggered, this, &TMainWindow::ExportToCSV);
|
||||||
connect(ui->actionReadOnly, &QAction::triggered, this, &TMainWindow::ReadOnly);
|
connect(ui->actionReadOnly, &QAction::triggered, RECEIVER(this)[this](bool ro)
|
||||||
|
{
|
||||||
|
if (not mIsReadOnly)
|
||||||
|
{
|
||||||
|
m->SetReadOnly(ro);
|
||||||
|
MeasurementsWasSaved(false);
|
||||||
|
UpdatePadlock(ro);
|
||||||
|
UpdateWindowTitle();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (QAction *action = qobject_cast< QAction * >(this->sender()))
|
||||||
|
{
|
||||||
|
action->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
connect(ui->actionPreferences, &QAction::triggered, this, &TMainWindow::Preferences);
|
connect(ui->actionPreferences, &QAction::triggered, this, &TMainWindow::Preferences);
|
||||||
|
|
||||||
for (int i = 0; i < MaxRecentFiles; ++i)
|
for (int i = 0; i < MaxRecentFiles; ++i)
|
||||||
|
@ -1975,11 +2030,11 @@ void TMainWindow::InitWindow()
|
||||||
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, [this] (){search->FindPrevious();});
|
connect(ui->toolButtonFindPrevious, &QToolButton::clicked, [this] (){search->FindPrevious();});
|
||||||
connect(ui->toolButtonFindNext, &QToolButton::clicked, [this] (){search->FindNext();});
|
connect(ui->toolButtonFindNext, &QToolButton::clicked, [this] (){search->FindNext();});
|
||||||
|
|
||||||
connect(search.data(), &VTableSearch::HasResult, [this] (bool state)
|
connect(search.data(), &VTableSearch::HasResult, RECEIVER(this)[this] (bool state)
|
||||||
{
|
{
|
||||||
ui->toolButtonFindPrevious->setEnabled(state);
|
ui->toolButtonFindPrevious->setEnabled(state);
|
||||||
});
|
});
|
||||||
connect(search.data(), &VTableSearch::HasResult, [this] (bool state)
|
connect(search.data(), &VTableSearch::HasResult, RECEIVER(this)[this] (bool state)
|
||||||
{
|
{
|
||||||
ui->toolButtonFindNext->setEnabled(state);
|
ui->toolButtonFindNext->setEnabled(state);
|
||||||
});
|
});
|
||||||
|
@ -1990,7 +2045,6 @@ void TMainWindow::InitWindow()
|
||||||
ui->actionAddCustom->setEnabled(true);
|
ui->actionAddCustom->setEnabled(true);
|
||||||
ui->actionAddKnown->setEnabled(true);
|
ui->actionAddKnown->setEnabled(true);
|
||||||
ui->actionImportFromPattern->setEnabled(true);
|
ui->actionImportFromPattern->setEnabled(true);
|
||||||
ui->actionReadOnly->setEnabled(true);
|
|
||||||
ui->actionSaveAs->setEnabled(true);
|
ui->actionSaveAs->setEnabled(true);
|
||||||
|
|
||||||
#if QT_VERSION > QT_VERSION_CHECK(5, 1, 0)
|
#if QT_VERSION > QT_VERSION_CHECK(5, 1, 0)
|
||||||
|
@ -2073,18 +2127,15 @@ void TMainWindow::ShowHeaderUnits(QTableWidget *table, int column, const QString
|
||||||
void TMainWindow::MeasurementsWasSaved(bool saved)
|
void TMainWindow::MeasurementsWasSaved(bool saved)
|
||||||
{
|
{
|
||||||
setWindowModified(!saved);
|
setWindowModified(!saved);
|
||||||
ui->actionSave->setEnabled(!saved);
|
not mIsReadOnly ? ui->actionSave->setEnabled(!saved): ui->actionSave->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::SetCurrentFile(const QString &fileName)
|
void TMainWindow::SetCurrentFile(const QString &fileName)
|
||||||
{
|
{
|
||||||
curFile = fileName;
|
curFile = fileName;
|
||||||
QString shownName = QFileInfo(curFile).fileName();
|
|
||||||
if (curFile.isEmpty())
|
if (curFile.isEmpty())
|
||||||
{
|
{
|
||||||
shownName = tr("untitled");
|
|
||||||
mType == MeasurementsType::Standard ? shownName += QLatin1String(".vst") : shownName += QLatin1String(".vit");
|
|
||||||
ui->lineEditPathToFile->setText(tr("<Empty>"));
|
ui->lineEditPathToFile->setText(tr("<Empty>"));
|
||||||
ui->lineEditPathToFile->setToolTip(tr("File was not saved yet."));
|
ui->lineEditPathToFile->setToolTip(tr("File was not saved yet."));
|
||||||
ui->lineEditPathToFile->setCursorPosition(0);
|
ui->lineEditPathToFile->setCursorPosition(0);
|
||||||
|
@ -2107,33 +2158,8 @@ void TMainWindow::SetCurrentFile(const QString &fileName)
|
||||||
settings->SetRecentFileList(files);
|
settings->SetRecentFileList(files);
|
||||||
UpdateRecentFileActions();
|
UpdateRecentFileActions();
|
||||||
}
|
}
|
||||||
shownName += "[*]";
|
|
||||||
setWindowTitle(shownName);
|
|
||||||
setWindowFilePath(curFile);
|
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
UpdateWindowTitle();
|
||||||
static QIcon fileIcon = QIcon(QApplication::applicationDirPath() +
|
|
||||||
QLatin1String("/../Resources/measurements.icns"));
|
|
||||||
QIcon icon;
|
|
||||||
if (not curFile.isEmpty())
|
|
||||||
{
|
|
||||||
if (not isWindowModified())
|
|
||||||
{
|
|
||||||
icon = fileIcon;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
static QIcon darkIcon;
|
|
||||||
|
|
||||||
if (darkIcon.isNull())
|
|
||||||
{
|
|
||||||
darkIcon = QIcon(darkenPixmap(fileIcon.pixmap(16, 16)));
|
|
||||||
}
|
|
||||||
icon = darkIcon;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setWindowIcon(icon);
|
|
||||||
#endif //defined(Q_OS_MAC)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -2167,7 +2193,7 @@ bool TMainWindow::MaybeSave()
|
||||||
messageBox->setDefaultButton(QMessageBox::Yes);
|
messageBox->setDefaultButton(QMessageBox::Yes);
|
||||||
messageBox->setEscapeButton(QMessageBox::Cancel);
|
messageBox->setEscapeButton(QMessageBox::Cancel);
|
||||||
|
|
||||||
messageBox->setButtonText(QMessageBox::Yes, curFile.isEmpty() ? tr("Save...") : tr("Save"));
|
messageBox->setButtonText(QMessageBox::Yes, curFile.isEmpty() || mIsReadOnly ? tr("Save...") : tr("Save"));
|
||||||
messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
|
messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
|
||||||
|
|
||||||
messageBox->setWindowModality(Qt::ApplicationModal);
|
messageBox->setWindowModality(Qt::ApplicationModal);
|
||||||
|
@ -2176,8 +2202,14 @@ bool TMainWindow::MaybeSave()
|
||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
case QMessageBox::Yes:
|
case QMessageBox::Yes:
|
||||||
FileSave();
|
if (mIsReadOnly)
|
||||||
return true;
|
{
|
||||||
|
return FileSaveAs();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return FileSave();
|
||||||
|
}
|
||||||
case QMessageBox::No:
|
case QMessageBox::No:
|
||||||
return true;
|
return true;
|
||||||
case QMessageBox::Cancel:
|
case QMessageBox::Cancel:
|
||||||
|
@ -2364,16 +2396,6 @@ void TMainWindow::RefreshTable()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::Controls()
|
void TMainWindow::Controls()
|
||||||
{
|
{
|
||||||
if (m->ReadOnly())
|
|
||||||
{
|
|
||||||
ui->toolButtonRemove->setEnabled(false);
|
|
||||||
ui->toolButtonTop->setEnabled(false);
|
|
||||||
ui->toolButtonUp->setEnabled(false);
|
|
||||||
ui->toolButtonDown->setEnabled(false);
|
|
||||||
ui->toolButtonBottom->setEnabled(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ui->tableWidget->rowCount() > 0)
|
if (ui->tableWidget->rowCount() > 0)
|
||||||
{
|
{
|
||||||
ui->toolButtonRemove->setEnabled(true);
|
ui->toolButtonRemove->setEnabled(true);
|
||||||
|
@ -2449,6 +2471,63 @@ void TMainWindow::MFields(bool enabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TMainWindow::UpdateWindowTitle()
|
||||||
|
{
|
||||||
|
QString showName;
|
||||||
|
bool isFileWritable = true;
|
||||||
|
if (not curFile.isEmpty())
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qt_ntfs_permission_lookup++; // turn checking on
|
||||||
|
#endif /*Q_OS_WIN32*/
|
||||||
|
isFileWritable = QFileInfo(curFile).isWritable();
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qt_ntfs_permission_lookup--; // turn it off again
|
||||||
|
#endif /*Q_OS_WIN32*/
|
||||||
|
showName = StrippedName(curFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
showName = tr("untitled %1").arg(qApp->MainWindows().size()+1);
|
||||||
|
mType == MeasurementsType::Standard ? showName += QLatin1String(".vst") : showName += QLatin1String(".vit");
|
||||||
|
}
|
||||||
|
|
||||||
|
showName += QLatin1String("[*]");
|
||||||
|
|
||||||
|
if (mIsReadOnly || not isFileWritable)
|
||||||
|
{
|
||||||
|
showName += QLatin1String(" (") + tr("read only") + QLatin1String(")");
|
||||||
|
}
|
||||||
|
|
||||||
|
setWindowTitle(showName);
|
||||||
|
setWindowFilePath(curFile);
|
||||||
|
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
static QIcon fileIcon = QIcon(QApplication::applicationDirPath() +
|
||||||
|
QLatin1String("/../Resources/measurements.icns"));
|
||||||
|
QIcon icon;
|
||||||
|
if (not curFile.isEmpty())
|
||||||
|
{
|
||||||
|
if (not isWindowModified())
|
||||||
|
{
|
||||||
|
icon = fileIcon;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
static QIcon darkIcon;
|
||||||
|
|
||||||
|
if (darkIcon.isNull())
|
||||||
|
{
|
||||||
|
darkIcon = QIcon(darkenPixmap(fileIcon.pixmap(16, 16)));
|
||||||
|
}
|
||||||
|
icon = darkIcon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setWindowIcon(icon);
|
||||||
|
#endif //defined(Q_OS_MAC)
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString TMainWindow::ClearCustomName(const QString &name) const
|
QString TMainWindow::ClearCustomName(const QString &name) const
|
||||||
{
|
{
|
||||||
|
@ -2530,7 +2609,7 @@ void TMainWindow::Open(const QString &pathTo, const QString &filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::GUIReadOnly(bool ro)
|
void TMainWindow::UpdatePadlock(bool ro)
|
||||||
{
|
{
|
||||||
ui->actionReadOnly->setChecked(ro);
|
ui->actionReadOnly->setChecked(ro);
|
||||||
if (ro)
|
if (ro)
|
||||||
|
@ -2542,90 +2621,26 @@ void TMainWindow::GUIReadOnly(bool ro)
|
||||||
ui->actionReadOnly->setIcon(QIcon("://tapeicon/24x24/padlock_opened.png"));
|
ui->actionReadOnly->setIcon(QIcon("://tapeicon/24x24/padlock_opened.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->actionAddCustom->setDisabled(ro);
|
ui->actionReadOnly->setDisabled(mIsReadOnly);
|
||||||
ui->actionAddKnown->setDisabled(ro);
|
|
||||||
|
|
||||||
ui->plainTextEditNotes->setReadOnly(ro);
|
|
||||||
|
|
||||||
if (mType == MeasurementsType::Individual)
|
|
||||||
{
|
|
||||||
ui->lineEditGivenName->setReadOnly(ro);
|
|
||||||
ui->lineEditFamilyName->setReadOnly(ro);
|
|
||||||
ui->dateEditBirthDate->setReadOnly(ro);
|
|
||||||
ui->comboBoxGender->setDisabled(ro);
|
|
||||||
ui->lineEditEmail->setReadOnly(ro);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->comboBoxPMSystem->setDisabled(ro);
|
|
||||||
|
|
||||||
MeasurementReadOnly(ro);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::MeasurementReadOnly(bool ro)
|
void TMainWindow::MeasurementGUI()
|
||||||
{
|
{
|
||||||
if (ro == false)
|
if (const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName))
|
||||||
{
|
{
|
||||||
if (const QTableWidgetItem *nameField = ui->tableWidget->item(ui->tableWidget->currentRow(), ColumnName))
|
const bool isCustom = not (nameField->text().indexOf(CustomMSign) == 0);
|
||||||
{
|
ui->lineEditName->setReadOnly(isCustom);
|
||||||
if (nameField->text().indexOf(CustomMSign) == 0) // Check if custom
|
ui->plainTextEditDescription->setReadOnly(isCustom);
|
||||||
{
|
ui->lineEditFullName->setReadOnly(isCustom);
|
||||||
ui->lineEditName->setReadOnly(ro);
|
|
||||||
ui->plainTextEditDescription->setReadOnly(ro);
|
|
||||||
ui->lineEditFullName->setReadOnly(ro);
|
|
||||||
|
|
||||||
// Need to block signals for QLineEdit in readonly mode because it still emits
|
|
||||||
// QLineEdit::editingFinished signal.
|
|
||||||
ui->lineEditName->blockSignals(ro);
|
|
||||||
ui->lineEditFullName->blockSignals(ro);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // known measurement
|
|
||||||
ui->lineEditName->setReadOnly(not ro);
|
|
||||||
ui->plainTextEditDescription->setReadOnly(not ro);
|
|
||||||
ui->lineEditFullName->setReadOnly(not ro);
|
|
||||||
|
|
||||||
// Need to block signals for QLineEdit in readonly mode because it still emits
|
|
||||||
// QLineEdit::editingFinished signal.
|
|
||||||
ui->lineEditName->blockSignals(not ro);
|
|
||||||
ui->lineEditFullName->blockSignals(not ro);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->lineEditName->setReadOnly(ro);
|
|
||||||
ui->plainTextEditDescription->setReadOnly(ro);
|
|
||||||
ui->lineEditFullName->setReadOnly(ro);
|
|
||||||
|
|
||||||
// Need to block signals for QLineEdit in readonly mode because it still emits
|
// Need to block signals for QLineEdit in readonly mode because it still emits
|
||||||
// QLineEdit::editingFinished signal.
|
// QLineEdit::editingFinished signal.
|
||||||
ui->lineEditName->blockSignals(ro);
|
ui->lineEditName->blockSignals(isCustom);
|
||||||
ui->lineEditFullName->blockSignals(ro);
|
ui->lineEditFullName->blockSignals(isCustom);
|
||||||
}
|
|
||||||
|
|
||||||
if (mType == MeasurementsType::Individual)
|
Controls(); // Buttons remove, up, down
|
||||||
{
|
|
||||||
ui->plainTextEditFormula->setReadOnly(ro);
|
|
||||||
|
|
||||||
// Need to block signals for QLineEdit in readonly mode because it still emits QLineEdit::editingFinished
|
|
||||||
// signal.
|
|
||||||
ui->lineEditGivenName->blockSignals(ro);
|
|
||||||
ui->lineEditFamilyName->blockSignals(ro);
|
|
||||||
ui->lineEditEmail->blockSignals(ro);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->doubleSpinBoxBaseValue->setReadOnly(ro);
|
|
||||||
ui->doubleSpinBoxInSizes->setReadOnly(ro);
|
|
||||||
ui->doubleSpinBoxInHeights->setReadOnly(ro);
|
|
||||||
}
|
|
||||||
|
|
||||||
Controls(); // Buttons remove, up, down
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -2733,13 +2748,9 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VVITConverter converter(path);
|
VVITConverter converter(path);
|
||||||
converter.Convert();
|
m->setXMLContent(converter.Convert());// Read again after conversion
|
||||||
|
|
||||||
VDomDocument::ValidateXML(VVITConverter::CurrentSchema, path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m->setXMLContent(path);// Read again after conversion
|
|
||||||
|
|
||||||
if (not m->IsDefinedKnownNamesValid())
|
if (not m->IsDefinedKnownNamesValid())
|
||||||
{
|
{
|
||||||
VException e(tr("File contains invalid known measurement(s)."));
|
VException e(tr("File contains invalid known measurement(s)."));
|
||||||
|
@ -2767,7 +2778,9 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
|
||||||
|
|
||||||
lock.reset();// Now we can unlock the file
|
lock.reset();// Now we can unlock the file
|
||||||
|
|
||||||
GUIReadOnly(m->ReadOnly()); // Keep last
|
mIsReadOnly = m->IsReadOnly();
|
||||||
|
UpdatePadlock(mIsReadOnly);
|
||||||
|
MeasurementGUI();
|
||||||
}
|
}
|
||||||
catch (VException &e)
|
catch (VException &e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,8 +78,8 @@ private slots:
|
||||||
void CreateFromExisting();
|
void CreateFromExisting();
|
||||||
void Preferences();
|
void Preferences();
|
||||||
|
|
||||||
void FileSave();
|
bool FileSave();
|
||||||
void FileSaveAs();
|
bool FileSaveAs();
|
||||||
void ExportToCSV();
|
void ExportToCSV();
|
||||||
void AboutToShowWindowMenu();
|
void AboutToShowWindowMenu();
|
||||||
void ShowWindow() const;
|
void ShowWindow() const;
|
||||||
|
@ -96,7 +96,6 @@ private slots:
|
||||||
void SaveBirthDate(const QDate & date);
|
void SaveBirthDate(const QDate & date);
|
||||||
void SaveNotes();
|
void SaveNotes();
|
||||||
void SavePMSystem(int index);
|
void SavePMSystem(int index);
|
||||||
void ReadOnly(bool ro);
|
|
||||||
|
|
||||||
void Remove();
|
void Remove();
|
||||||
void MoveTop();
|
void MoveTop();
|
||||||
|
@ -147,6 +146,7 @@ private:
|
||||||
QAction *actionDockDiagram;
|
QAction *actionDockDiagram;
|
||||||
bool dockDiagramVisible;
|
bool dockDiagramVisible;
|
||||||
bool isInitialized;
|
bool isInitialized;
|
||||||
|
bool mIsReadOnly;
|
||||||
enum { MaxRecentFiles = 5 };
|
enum { MaxRecentFiles = 5 };
|
||||||
QAction *recentFileActs[MaxRecentFiles];
|
QAction *recentFileActs[MaxRecentFiles];
|
||||||
QAction *separatorAct;
|
QAction *separatorAct;
|
||||||
|
@ -185,10 +185,11 @@ private:
|
||||||
void ShowMDiagram(const QString &name);
|
void ShowMDiagram(const QString &name);
|
||||||
|
|
||||||
void Open(const QString &pathTo, const QString &filter);
|
void Open(const QString &pathTo, const QString &filter);
|
||||||
void GUIReadOnly(bool ro);
|
void UpdatePadlock(bool ro);
|
||||||
void MeasurementReadOnly(bool ro);
|
void MeasurementGUI();
|
||||||
void Controls();
|
void Controls();
|
||||||
void MFields(bool enabled);
|
void MFields(bool enabled);
|
||||||
|
void UpdateWindowTitle();
|
||||||
|
|
||||||
void ReadSettings();
|
void ReadSettings();
|
||||||
void WriteSettings();
|
void WriteSettings();
|
||||||
|
|
|
@ -924,7 +924,6 @@
|
||||||
<addaction name="actionSave"/>
|
<addaction name="actionSave"/>
|
||||||
<addaction name="actionAddKnown"/>
|
<addaction name="actionAddKnown"/>
|
||||||
<addaction name="actionAddCustom"/>
|
<addaction name="actionAddCustom"/>
|
||||||
<addaction name="actionReadOnly"/>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusBar"/>
|
<widget class="QStatusBar" name="statusBar"/>
|
||||||
<widget class="QToolBar" name="toolBarGradation">
|
<widget class="QToolBar" name="toolBarGradation">
|
||||||
|
|
|
@ -380,20 +380,14 @@ QSharedPointer<VMeasurements> MainWindow::OpenMeasurementFile(const QString &pat
|
||||||
if (m->Type() == MeasurementsType::Standard)
|
if (m->Type() == MeasurementsType::Standard)
|
||||||
{
|
{
|
||||||
VVSTConverter converter(path);
|
VVSTConverter converter(path);
|
||||||
converter.Convert();
|
m->setXMLContent(converter.Convert());// Read again after conversion
|
||||||
|
|
||||||
VDomDocument::ValidateXML(VVSTConverter::CurrentSchema, path);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VVITConverter converter(path);
|
VVITConverter converter(path);
|
||||||
converter.Convert();
|
m->setXMLContent(converter.Convert());// Read again after conversion
|
||||||
|
|
||||||
VDomDocument::ValidateXML(VVITConverter::CurrentSchema, path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m->setXMLContent(path);// Read again after conversion
|
|
||||||
|
|
||||||
if (not m->IsDefinedKnownNamesValid())
|
if (not m->IsDefinedKnownNamesValid())
|
||||||
{
|
{
|
||||||
VException e(tr("Measurement file contains invalid known measurement(s)."));
|
VException e(tr("Measurement file contains invalid known measurement(s)."));
|
||||||
|
@ -2406,7 +2400,7 @@ bool MainWindow::SaveAs()
|
||||||
const bool result = SavePattern(fileName, error);
|
const bool result = SavePattern(fileName, error);
|
||||||
if (result == false)
|
if (result == false)
|
||||||
{
|
{
|
||||||
QMessageBox messageBox;
|
QMessageBox messageBox(this);
|
||||||
messageBox.setIcon(QMessageBox::Warning);
|
messageBox.setIcon(QMessageBox::Warning);
|
||||||
messageBox.setInformativeText(tr("Could not save file"));
|
messageBox.setInformativeText(tr("Could not save file"));
|
||||||
messageBox.setDefaultButton(QMessageBox::Ok);
|
messageBox.setDefaultButton(QMessageBox::Ok);
|
||||||
|
@ -2449,25 +2443,69 @@ bool MainWindow::SaveAs()
|
||||||
*/
|
*/
|
||||||
bool MainWindow::Save()
|
bool MainWindow::Save()
|
||||||
{
|
{
|
||||||
if (curFile.isEmpty())
|
if (curFile.isEmpty() || patternReadOnly)
|
||||||
{
|
{
|
||||||
return SaveAs();
|
return SaveAs();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qt_ntfs_permission_lookup++; // turn checking on
|
||||||
|
#endif /*Q_OS_WIN32*/
|
||||||
|
const bool isFileWritable = QFileInfo(curFile).isWritable();
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qt_ntfs_permission_lookup--; // turn it off again
|
||||||
|
#endif /*Q_OS_WIN32*/
|
||||||
|
|
||||||
|
if (not isFileWritable)
|
||||||
|
{
|
||||||
|
QMessageBox messageBox(this);
|
||||||
|
messageBox.setIcon(QMessageBox::Question);
|
||||||
|
messageBox.setText(tr("The document has no write permissions."));
|
||||||
|
messageBox.setInformativeText("Do you want to change the premissions?");
|
||||||
|
messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
|
||||||
|
messageBox.setDefaultButton(QMessageBox::Yes);
|
||||||
|
|
||||||
|
if (messageBox.exec() == QMessageBox::Yes)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qt_ntfs_permission_lookup++; // turn checking on
|
||||||
|
#endif /*Q_OS_WIN32*/
|
||||||
|
bool changed = QFile::setPermissions(curFile,
|
||||||
|
QFileInfo(curFile).permissions() | QFileDevice::WriteUser);
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qt_ntfs_permission_lookup--; // turn it off again
|
||||||
|
#endif /*Q_OS_WIN32*/
|
||||||
|
|
||||||
|
if (not changed)
|
||||||
|
{
|
||||||
|
QMessageBox messageBox(this);
|
||||||
|
messageBox.setIcon(QMessageBox::Warning);
|
||||||
|
messageBox.setText(tr("Cannot set permissions for %1 to writable.").arg(curFile));
|
||||||
|
messageBox.setInformativeText(tr("Could not save the file."));
|
||||||
|
messageBox.setDefaultButton(QMessageBox::Ok);
|
||||||
|
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
messageBox.exec();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString error;
|
QString error;
|
||||||
bool result = SavePattern(curFile, error);
|
bool result = SavePattern(curFile, error);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
QString autofile = curFile + autosavePrefix;
|
QFile::remove(curFile + autosavePrefix);
|
||||||
QFile file(autofile);
|
|
||||||
file.remove();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QMessageBox messageBox;
|
QMessageBox messageBox(this);
|
||||||
messageBox.setIcon(QMessageBox::Warning);
|
messageBox.setIcon(QMessageBox::Warning);
|
||||||
messageBox.setInformativeText(tr("Could not save file"));
|
messageBox.setText(tr("Could not save the file"));
|
||||||
messageBox.setDefaultButton(QMessageBox::Ok);
|
messageBox.setDefaultButton(QMessageBox::Ok);
|
||||||
messageBox.setDetailedText(error);
|
messageBox.setDetailedText(error);
|
||||||
messageBox.setStandardButtons(QMessageBox::Ok);
|
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||||
|
@ -2559,10 +2597,6 @@ void MainWindow::Clear()
|
||||||
#endif
|
#endif
|
||||||
CleanLayout();
|
CleanLayout();
|
||||||
listDetails.clear(); // don't move to CleanLayout()
|
listDetails.clear(); // don't move to CleanLayout()
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
qt_ntfs_permission_lookup--; // turn it off again
|
|
||||||
#endif /*Q_OS_WIN32*/
|
|
||||||
qApp->getUndoStack()->clear();
|
qApp->getUndoStack()->clear();
|
||||||
toolOptions->ClearPropertyBrowser();
|
toolOptions->ClearPropertyBrowser();
|
||||||
toolOptions->itemClicked(nullptr);
|
toolOptions->itemClicked(nullptr);
|
||||||
|
@ -2698,8 +2732,6 @@ void MainWindow::FullParseFile()
|
||||||
GlobalChangePP(patternPiece);
|
GlobalChangePP(patternPiece);
|
||||||
|
|
||||||
SetEnableTool(comboBoxDraws->count() > 0);
|
SetEnableTool(comboBoxDraws->count() > 0);
|
||||||
patternReadOnly = doc->IsReadOnly();
|
|
||||||
SetEnableWidgets(true);
|
|
||||||
detailsWidget->UpdateList();
|
detailsWidget->UpdateList();
|
||||||
|
|
||||||
VMainGraphicsView::NewSceneRect(sceneDraw, qApp->getSceneView());
|
VMainGraphicsView::NewSceneRect(sceneDraw, qApp->getSceneView());
|
||||||
|
@ -3272,7 +3304,7 @@ bool MainWindow::MaybeSave()
|
||||||
messageBox->setEscapeButton(QMessageBox::Cancel);
|
messageBox->setEscapeButton(QMessageBox::Cancel);
|
||||||
|
|
||||||
messageBox->setButtonText(QMessageBox::Yes,
|
messageBox->setButtonText(QMessageBox::Yes,
|
||||||
curFile.isEmpty() || doc->IsReadOnly() ? tr("Save...") : tr("Save"));
|
curFile.isEmpty() || patternReadOnly ? tr("Save...") : tr("Save"));
|
||||||
messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
|
messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
|
||||||
|
|
||||||
messageBox->setWindowModality(Qt::ApplicationModal);
|
messageBox->setWindowModality(Qt::ApplicationModal);
|
||||||
|
@ -3281,7 +3313,7 @@ bool MainWindow::MaybeSave()
|
||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
case QMessageBox::Yes:
|
case QMessageBox::Yes:
|
||||||
if (doc->IsReadOnly())
|
if (patternReadOnly)
|
||||||
{
|
{
|
||||||
return SaveAs();
|
return SaveAs();
|
||||||
}
|
}
|
||||||
|
@ -3910,18 +3942,11 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
||||||
VMainGraphicsView::NewSceneRect(sceneDraw, ui->view);
|
VMainGraphicsView::NewSceneRect(sceneDraw, ui->view);
|
||||||
VMainGraphicsView::NewSceneRect(sceneDetails, ui->view);
|
VMainGraphicsView::NewSceneRect(sceneDetails, ui->view);
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
qt_ntfs_permission_lookup++; // turn checking on
|
|
||||||
#endif /*Q_OS_WIN32*/
|
|
||||||
|
|
||||||
qApp->setOpeningPattern();//Begin opening file
|
qApp->setOpeningPattern();//Begin opening file
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
VPatternConverter converter(fileName);
|
VPatternConverter converter(fileName);
|
||||||
converter.Convert();
|
doc->setXMLContent(converter.Convert());
|
||||||
|
|
||||||
VDomDocument::ValidateXML(VPatternConverter::CurrentSchema, fileName);
|
|
||||||
doc->setXMLContent(fileName);
|
|
||||||
if (!customMeasureFile.isEmpty())
|
if (!customMeasureFile.isEmpty())
|
||||||
{
|
{
|
||||||
doc->SetPath(RelativeMPath(fileName, customMeasureFile));
|
doc->SetPath(RelativeMPath(fileName, customMeasureFile));
|
||||||
|
@ -3984,14 +4009,12 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
qt_ntfs_permission_lookup--; // turn it off again
|
|
||||||
#endif /*Q_OS_WIN32*/
|
|
||||||
|
|
||||||
FullParseFile();
|
FullParseFile();
|
||||||
|
|
||||||
if (guiEnabled)
|
if (guiEnabled)
|
||||||
{ // No errors occurred
|
{ // No errors occurred
|
||||||
|
patternReadOnly = doc->IsReadOnly();
|
||||||
|
SetEnableWidgets(true);
|
||||||
setCurrentFile(fileName);
|
setCurrentFile(fileName);
|
||||||
helpLabel->setText(tr("File loaded"));
|
helpLabel->setText(tr("File loaded"));
|
||||||
qCDebug(vMainWindow, "File loaded.");
|
qCDebug(vMainWindow, "File loaded.");
|
||||||
|
@ -4297,20 +4320,14 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS
|
||||||
if (patternType == MeasurementsType::Standard)
|
if (patternType == MeasurementsType::Standard)
|
||||||
{
|
{
|
||||||
VVSTConverter converter(mPath);
|
VVSTConverter converter(mPath);
|
||||||
converter.Convert();
|
m->setXMLContent(converter.Convert());// Read again after conversion
|
||||||
|
|
||||||
VDomDocument::ValidateXML(VVSTConverter::CurrentSchema, mPath);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VVITConverter converter(mPath);
|
VVITConverter converter(mPath);
|
||||||
converter.Convert();
|
m->setXMLContent(converter.Convert());// Read again after conversion
|
||||||
|
|
||||||
VDomDocument::ValidateXML(VVITConverter::CurrentSchema, mPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m->setXMLContent(mPath);// Read again after conversion
|
|
||||||
|
|
||||||
if (not m->IsDefinedKnownNamesValid())
|
if (not m->IsDefinedKnownNamesValid())
|
||||||
{
|
{
|
||||||
VException e(tr("Measurement file contains invalid known measurement(s)."));
|
VException e(tr("Measurement file contains invalid known measurement(s)."));
|
||||||
|
@ -4630,13 +4647,26 @@ QString MainWindow::GetMeasurementFileName()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void MainWindow::UpdateWindowTitle()
|
void MainWindow::UpdateWindowTitle()
|
||||||
{
|
{
|
||||||
if (not patternReadOnly)
|
bool isFileWritable = true;
|
||||||
|
if (not curFile.isEmpty())
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qt_ntfs_permission_lookup++; // turn checking on
|
||||||
|
#endif /*Q_OS_WIN32*/
|
||||||
|
isFileWritable = QFileInfo(curFile).isWritable();
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qt_ntfs_permission_lookup--; // turn it off again
|
||||||
|
#endif /*Q_OS_WIN32*/
|
||||||
|
}
|
||||||
|
|
||||||
|
if (not patternReadOnly && isFileWritable)
|
||||||
{
|
{
|
||||||
setWindowTitle(GetPatternFileName()+GetMeasurementFileName());
|
setWindowTitle(GetPatternFileName()+GetMeasurementFileName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setWindowTitle(GetPatternFileName()+GetMeasurementFileName() + " " + tr("(read only)"));
|
setWindowTitle(GetPatternFileName()+GetMeasurementFileName() + QLatin1String(" (") + tr("read only") +
|
||||||
|
QLatin1String(")"));
|
||||||
}
|
}
|
||||||
setWindowFilePath(curFile);
|
setWindowFilePath(curFile);
|
||||||
|
|
||||||
|
|
|
@ -49,17 +49,13 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VAbstractConverter::VAbstractConverter(const QString &fileName)
|
VAbstractConverter::VAbstractConverter(const QString &fileName)
|
||||||
:VDomDocument(), ver(0x0), fileName(fileName)
|
: VDomDocument(),
|
||||||
|
m_ver(0x0),
|
||||||
|
m_convertedFileName(fileName),
|
||||||
|
m_tmpFile()
|
||||||
{
|
{
|
||||||
QFileInfo info(fileName);
|
setXMLContent(m_convertedFileName);// Throw an exception on error
|
||||||
if (info.isSymLink() && not info.isWritable())
|
m_ver = GetVersion(GetVersionStr());
|
||||||
{
|
|
||||||
ReplaceSymLink();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->setXMLContent(fileName);
|
|
||||||
const QString version = GetVersionStr();
|
|
||||||
ver = GetVersion(version);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -67,34 +63,29 @@ VAbstractConverter::~VAbstractConverter()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractConverter::Convert()
|
QString VAbstractConverter::Convert()
|
||||||
{
|
{
|
||||||
if (ver == MaxVer())
|
if (m_ver == MaxVer())
|
||||||
{
|
{
|
||||||
return;
|
return m_convertedFileName;
|
||||||
}
|
|
||||||
|
|
||||||
QString error;
|
|
||||||
const QString backupFileName = fileName + QLatin1String(".backup");
|
|
||||||
if (SafeCopy(fileName, backupFileName, error) == false)
|
|
||||||
{
|
|
||||||
const QString errorMsg(tr("Error creating a backup file: %1.").arg(error));
|
|
||||||
throw VException(errorMsg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReserveFile();
|
ReserveFile();
|
||||||
|
|
||||||
if (ver <= MaxVer())
|
if (m_tmpFile.open())
|
||||||
{
|
{
|
||||||
ApplyPatches();
|
m_convertedFileName = m_tmpFile.fileName();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DowngradeToCurrentMaxVersion();
|
const QString errorMsg(tr("Error openning a temp file file: %1.").arg(m_tmpFile.errorString()));
|
||||||
|
throw VException(errorMsg);
|
||||||
}
|
}
|
||||||
|
m_tmpFile.close();
|
||||||
|
|
||||||
QFile file(backupFileName);
|
m_ver < MaxVer() ? ApplyPatches() : DowngradeToCurrentMaxVersion();
|
||||||
file.remove();
|
|
||||||
|
return m_convertedFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -180,31 +171,25 @@ void VAbstractConverter::ReserveFile() const
|
||||||
//It's not possible in all cases make conversion without lose data.
|
//It's not possible in all cases make conversion without lose data.
|
||||||
//For such cases we will store old version in a reserve file.
|
//For such cases we will store old version in a reserve file.
|
||||||
QString error;
|
QString error;
|
||||||
QFileInfo info(fileName);
|
QFileInfo info(m_convertedFileName);
|
||||||
const QString reserveFileName = QString("%1/%2(v%3).%4")
|
const QString reserveFileName = QString("%1/%2(v%3).%4.bak")
|
||||||
.arg(info.absoluteDir().absolutePath())
|
.arg(info.absoluteDir().absolutePath())
|
||||||
.arg(info.baseName())
|
.arg(info.baseName())
|
||||||
.arg(GetVersionStr())
|
.arg(GetVersionStr())
|
||||||
.arg(info.completeSuffix());
|
.arg(info.completeSuffix());
|
||||||
if (not SafeCopy(fileName, reserveFileName, error))
|
if (not SafeCopy(m_convertedFileName, reserveFileName, error))
|
||||||
{
|
{
|
||||||
const QString errorMsg(tr("Error creating a reserv copy: %1.").arg(error));
|
#ifdef Q_OS_WIN32
|
||||||
throw VException(errorMsg);
|
qt_ntfs_permission_lookup++; // turn checking on
|
||||||
}
|
#endif /*Q_OS_WIN32*/
|
||||||
}
|
const bool isFileWritable = info.isWritable();
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
qt_ntfs_permission_lookup--; // turn it off again
|
||||||
|
#endif /*Q_OS_WIN32*/
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
if (not IsReadOnly() && isFileWritable)
|
||||||
void VAbstractConverter::ReplaceSymLink() const
|
|
||||||
{
|
|
||||||
// See issue #582. Issue with standard path to shared data on Linux
|
|
||||||
// https://bitbucket.org/dismine/valentina/issues/582/issue-with-standard-path-to-shared-data-on
|
|
||||||
QFileInfo info(fileName);
|
|
||||||
if (info.isSymLink() && not info.isWritable())
|
|
||||||
{
|
|
||||||
QString error;
|
|
||||||
if (not SafeCopy(info.symLinkTarget(), fileName, error))
|
|
||||||
{
|
{
|
||||||
const QString errorMsg(tr("Error replacing a symlink by real file: %1.").arg(error));
|
const QString errorMsg(tr("Error creating a reserv copy: %1.").arg(error));
|
||||||
throw VException(errorMsg);
|
throw VException(errorMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,19 +276,19 @@ void VAbstractConverter::ValidateInputFile(const QString ¤tSchema) const
|
||||||
QString schema;
|
QString schema;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
schema = XSDSchema(ver);
|
schema = XSDSchema(m_ver);
|
||||||
}
|
}
|
||||||
catch(const VException &e)
|
catch(const VException &e)
|
||||||
{
|
{
|
||||||
if (ver < MinVer())
|
if (m_ver < MinVer())
|
||||||
{ // Version less than minimally supported version. Can't do anything.
|
{ // Version less than minimally supported version. Can't do anything.
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
else if (ver > MaxVer())
|
else if (m_ver > MaxVer())
|
||||||
{ // Version bigger than maximum supported version. We still have a chance to open the file.
|
{ // Version bigger than maximum supported version. We still have a chance to open the file.
|
||||||
try
|
try
|
||||||
{ // Try to open like the current version.
|
{ // Try to open like the current version.
|
||||||
ValidateXML(currentSchema, fileName);
|
ValidateXML(currentSchema, m_convertedFileName);
|
||||||
}
|
}
|
||||||
catch(const VException &exp)
|
catch(const VException &exp)
|
||||||
{ // Nope, we can't.
|
{ // Nope, we can't.
|
||||||
|
@ -319,14 +304,14 @@ void VAbstractConverter::ValidateInputFile(const QString ¤tSchema) const
|
||||||
return; // All is fine and we can try to convert to current max version.
|
return; // All is fine and we can try to convert to current max version.
|
||||||
}
|
}
|
||||||
|
|
||||||
ValidateXML(schema, fileName);
|
ValidateXML(schema, m_convertedFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractConverter::Save() const
|
void VAbstractConverter::Save() const
|
||||||
{
|
{
|
||||||
QString error;
|
QString error;
|
||||||
if (SaveDocument(fileName, error) == false)
|
if (SaveDocument(m_convertedFileName, error) == false)
|
||||||
{
|
{
|
||||||
VException e(error);
|
VException e(error);
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QTemporaryFile>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
#include "vdomdocument.h"
|
#include "vdomdocument.h"
|
||||||
|
@ -52,14 +53,15 @@ public:
|
||||||
explicit VAbstractConverter(const QString &fileName);
|
explicit VAbstractConverter(const QString &fileName);
|
||||||
virtual ~VAbstractConverter() Q_DECL_OVERRIDE;
|
virtual ~VAbstractConverter() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
void Convert();
|
QString Convert();
|
||||||
virtual bool SaveDocument(const QString &fileName, QString &error) const Q_DECL_OVERRIDE;
|
virtual bool SaveDocument(const QString &fileName, QString &error) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
static int GetVersion(const QString &version);
|
static int GetVersion(const QString &version);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int ver;
|
int m_ver;
|
||||||
QString fileName;
|
QString m_convertedFileName;
|
||||||
|
|
||||||
|
|
||||||
void ValidateInputFile(const QString ¤tSchema) const;
|
void ValidateInputFile(const QString ¤tSchema) const;
|
||||||
Q_NORETURN void InvalidVersion(int ver) const;
|
Q_NORETURN void InvalidVersion(int ver) const;
|
||||||
|
@ -76,6 +78,8 @@ protected:
|
||||||
virtual void ApplyPatches() =0;
|
virtual void ApplyPatches() =0;
|
||||||
virtual void DowngradeToCurrentMaxVersion() =0;
|
virtual void DowngradeToCurrentMaxVersion() =0;
|
||||||
|
|
||||||
|
virtual bool IsReadOnly() const =0;
|
||||||
|
|
||||||
void Replace(QString &formula, const QString &newName, int position, const QString &token, int &bias) const;
|
void Replace(QString &formula, const QString &newName, int position, const QString &token, int &bias) const;
|
||||||
void CorrectionsPositions(int position, int bias, QMap<int, QString> &tokens) const;
|
void CorrectionsPositions(int position, int bias, QMap<int, QString> &tokens) const;
|
||||||
static void BiasTokens(int position, int bias, QMap<int, QString> &tokens);
|
static void BiasTokens(int position, int bias, QMap<int, QString> &tokens);
|
||||||
|
@ -83,12 +87,13 @@ protected:
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VAbstractConverter)
|
Q_DISABLE_COPY(VAbstractConverter)
|
||||||
|
|
||||||
|
QTemporaryFile m_tmpFile;
|
||||||
|
|
||||||
QString GetVersionStr() const;
|
QString GetVersionStr() const;
|
||||||
|
|
||||||
static void ValidateVersion(const QString &version);
|
static void ValidateVersion(const QString &version);
|
||||||
|
|
||||||
void ReserveFile() const;
|
void ReserveFile() const;
|
||||||
void ReplaceSymLink() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VABSTRACTCONVERTER_H
|
#endif // VABSTRACTCONVERTER_H
|
||||||
|
|
|
@ -124,7 +124,8 @@ const QString VDomDocument::TagVersion = QStringLiteral("version");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VDomDocument::VDomDocument()
|
VDomDocument::VDomDocument()
|
||||||
: QDomDocument(), map(QHash<QString, QDomElement>())
|
: QDomDocument(),
|
||||||
|
map()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -804,12 +805,11 @@ bool VDomDocument::SafeCopy(const QString &source, const QString &destination, Q
|
||||||
#endif /*Q_OS_WIN32*/
|
#endif /*Q_OS_WIN32*/
|
||||||
|
|
||||||
QTemporaryFile destFile(destination + QLatin1String(".XXXXXX"));
|
QTemporaryFile destFile(destination + QLatin1String(".XXXXXX"));
|
||||||
destFile.setAutoRemove(false);
|
destFile.setAutoRemove(false);// Will be renamed to be destination file
|
||||||
// cppcheck-suppress ConfigurationNotChecked
|
// cppcheck-suppress ConfigurationNotChecked
|
||||||
if (not destFile.open())
|
if (not destFile.open())
|
||||||
{
|
{
|
||||||
error = destFile.errorString();
|
error = destFile.errorString();
|
||||||
result = false;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -850,6 +850,10 @@ bool VDomDocument::SafeCopy(const QString &source, const QString &destination, Q
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error = sourceFile.errorString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
|
|
|
@ -133,10 +133,11 @@ static const QString strSeamAllowance = QStringLiteral("seamAllowanc
|
||||||
static const QString strNodeType = QStringLiteral("nodeType");
|
static const QString strNodeType = QStringLiteral("nodeType");
|
||||||
static const QString strDet = QStringLiteral("det");
|
static const QString strDet = QStringLiteral("det");
|
||||||
static const QString strTypeObject = QStringLiteral("typeObject");
|
static const QString strTypeObject = QStringLiteral("typeObject");
|
||||||
|
static const QString strReadOnly = QStringLiteral("readOnly");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPatternConverter::VPatternConverter(const QString &fileName)
|
VPatternConverter::VPatternConverter(const QString &fileName)
|
||||||
:VAbstractConverter(fileName)
|
: VAbstractConverter(fileName)
|
||||||
{
|
{
|
||||||
ValidateInputFile(CurrentSchema);
|
ValidateInputFile(CurrentSchema);
|
||||||
}
|
}
|
||||||
|
@ -207,124 +208,105 @@ QString VPatternConverter::XSDSchema(int ver) const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPatternConverter::ApplyPatches()
|
void VPatternConverter::ApplyPatches()
|
||||||
{
|
{
|
||||||
try
|
switch (m_ver)
|
||||||
{
|
{
|
||||||
switch (ver)
|
case (0x000100):
|
||||||
{
|
ToV0_1_1();
|
||||||
case (0x000100):
|
ValidateXML(XSDSchema(0x000101), m_convertedFileName);
|
||||||
ToV0_1_1();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000101), fileName);
|
case (0x000101):
|
||||||
V_FALLTHROUGH
|
ToV0_1_2();
|
||||||
case (0x000101):
|
ValidateXML(XSDSchema(0x000102), m_convertedFileName);
|
||||||
ToV0_1_2();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000102), fileName);
|
case (0x000102):
|
||||||
V_FALLTHROUGH
|
ToV0_1_3();
|
||||||
case (0x000102):
|
ValidateXML(XSDSchema(0x000103), m_convertedFileName);
|
||||||
ToV0_1_3();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000103), fileName);
|
case (0x000103):
|
||||||
V_FALLTHROUGH
|
ToV0_1_4();
|
||||||
case (0x000103):
|
ValidateXML(XSDSchema(0x000104), m_convertedFileName);
|
||||||
ToV0_1_4();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000104), fileName);
|
case (0x000104):
|
||||||
V_FALLTHROUGH
|
ToV0_2_0();
|
||||||
case (0x000104):
|
ValidateXML(XSDSchema(0x000200), m_convertedFileName);
|
||||||
ToV0_2_0();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000200), fileName);
|
case (0x000200):
|
||||||
V_FALLTHROUGH
|
ToV0_2_1();
|
||||||
case (0x000200):
|
ValidateXML(XSDSchema(0x000201), m_convertedFileName);
|
||||||
ToV0_2_1();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000201), fileName);
|
case (0x000201):
|
||||||
V_FALLTHROUGH
|
ToV0_2_2();
|
||||||
case (0x000201):
|
ValidateXML(XSDSchema(0x000202), m_convertedFileName);
|
||||||
ToV0_2_2();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000202), fileName);
|
case (0x000202):
|
||||||
V_FALLTHROUGH
|
ToV0_2_3();
|
||||||
case (0x000202):
|
ValidateXML(XSDSchema(0x000203), m_convertedFileName);
|
||||||
ToV0_2_3();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000203), fileName);
|
case (0x000203):
|
||||||
V_FALLTHROUGH
|
ToV0_2_4();
|
||||||
case (0x000203):
|
ValidateXML(XSDSchema(0x000204), m_convertedFileName);
|
||||||
ToV0_2_4();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000204), fileName);
|
case (0x000204):
|
||||||
V_FALLTHROUGH
|
ToV0_2_5();
|
||||||
case (0x000204):
|
ValidateXML(XSDSchema(0x000205), m_convertedFileName);
|
||||||
ToV0_2_5();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000205), fileName);
|
case (0x000205):
|
||||||
V_FALLTHROUGH
|
ToV0_2_6();
|
||||||
case (0x000205):
|
ValidateXML(XSDSchema(0x000206), m_convertedFileName);
|
||||||
ToV0_2_6();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000206), fileName);
|
case (0x000206):
|
||||||
V_FALLTHROUGH
|
ToV0_2_7();
|
||||||
case (0x000206):
|
ValidateXML(XSDSchema(0x000207), m_convertedFileName);
|
||||||
ToV0_2_7();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000207), fileName);
|
case (0x000207):
|
||||||
V_FALLTHROUGH
|
ToV0_3_0();
|
||||||
case (0x000207):
|
ValidateXML(XSDSchema(0x000300), m_convertedFileName);
|
||||||
ToV0_3_0();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000300), fileName);
|
case (0x000300):
|
||||||
V_FALLTHROUGH
|
ToV0_3_1();
|
||||||
case (0x000300):
|
ValidateXML(XSDSchema(0x000301), m_convertedFileName);
|
||||||
ToV0_3_1();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000301), fileName);
|
case (0x000301):
|
||||||
V_FALLTHROUGH
|
ToV0_3_2();
|
||||||
case (0x000301):
|
ValidateXML(XSDSchema(0x000302), m_convertedFileName);
|
||||||
ToV0_3_2();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000302), fileName);
|
case (0x000302):
|
||||||
V_FALLTHROUGH
|
ToV0_3_3();
|
||||||
case (0x000302):
|
ValidateXML(XSDSchema(0x000303), m_convertedFileName);
|
||||||
ToV0_3_3();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000303), fileName);
|
case (0x000303):
|
||||||
V_FALLTHROUGH
|
ToV0_3_4();
|
||||||
case (0x000303):
|
ValidateXML(XSDSchema(0x000304), m_convertedFileName);
|
||||||
ToV0_3_4();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000304), fileName);
|
case (0x000304):
|
||||||
V_FALLTHROUGH
|
ToV0_3_5();
|
||||||
case (0x000304):
|
ValidateXML(XSDSchema(0x000305), m_convertedFileName);
|
||||||
ToV0_3_5();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000305), fileName);
|
case (0x000305):
|
||||||
V_FALLTHROUGH
|
ToV0_3_6();
|
||||||
case (0x000305):
|
ValidateXML(XSDSchema(0x000306), m_convertedFileName);
|
||||||
ToV0_3_6();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000306), fileName);
|
case (0x000306):
|
||||||
V_FALLTHROUGH
|
ToV0_3_7();
|
||||||
case (0x000306):
|
ValidateXML(XSDSchema(0x000307), m_convertedFileName);
|
||||||
ToV0_3_7();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000307), fileName);
|
case (0x000307):
|
||||||
V_FALLTHROUGH
|
ToV0_3_8();
|
||||||
case (0x000307):
|
ValidateXML(XSDSchema(0x000308), m_convertedFileName);
|
||||||
ToV0_3_8();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000308), fileName);
|
case (0x000308):
|
||||||
V_FALLTHROUGH
|
ToV0_3_9();
|
||||||
case (0x000308):
|
ValidateXML(XSDSchema(0x000309), m_convertedFileName);
|
||||||
ToV0_3_9();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000309), fileName);
|
case (0x000309):
|
||||||
V_FALLTHROUGH
|
ToV0_4_0();
|
||||||
case (0x000309):
|
ValidateXML(XSDSchema(0x000400), m_convertedFileName);
|
||||||
ToV0_4_0();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000400), fileName);
|
case (0x000400):
|
||||||
V_FALLTHROUGH
|
break;
|
||||||
case (0x000400):
|
default:
|
||||||
break;
|
InvalidVersion(m_ver);
|
||||||
default:
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (VException &e)
|
|
||||||
{
|
|
||||||
QString error;
|
|
||||||
const QString backupFileName = fileName + QLatin1String(".backup");
|
|
||||||
if (SafeCopy(backupFileName, fileName, error) == false)
|
|
||||||
{
|
|
||||||
const QString errorMsg(tr("Error restoring backup file: %1.").arg(error));
|
|
||||||
VException excep(errorMsg);
|
|
||||||
excep.AddMoreInformation(e.ErrorMessage());
|
|
||||||
throw excep;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile file(backupFileName);
|
|
||||||
file.remove();
|
|
||||||
|
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,6 +317,27 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VPatternConverter::IsReadOnly() const
|
||||||
|
{
|
||||||
|
// Check if attribute readOnly was not changed in file format
|
||||||
|
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 4, 0),
|
||||||
|
"Check attribute readOnly.");
|
||||||
|
|
||||||
|
// Possibly in future attribute readOnly will change position etc.
|
||||||
|
// For now position is the same for all supported format versions.
|
||||||
|
// But don't forget to keep all versions of attribute until we support that format versions
|
||||||
|
|
||||||
|
const QDomElement pattern = documentElement();
|
||||||
|
|
||||||
|
if (pattern.isNull())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GetParametrBool(pattern, strReadOnly, falseStr);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPatternConverter::ToV0_1_1()
|
void VPatternConverter::ToV0_1_1()
|
||||||
{
|
{
|
||||||
|
@ -1095,7 +1098,7 @@ void VPatternConverter::TagMeasurementsToV0_2_0()
|
||||||
ms.removeAttribute(strType);
|
ms.removeAttribute(strType);
|
||||||
ms.removeAttribute(strPath);
|
ms.removeAttribute(strPath);
|
||||||
|
|
||||||
QDomText newNodeText = createTextNode(QFileInfo(fileName).absoluteDir().relativeFilePath(path));
|
QDomText newNodeText = createTextNode(QFileInfo(m_convertedFileName).absoluteDir().relativeFilePath(path));
|
||||||
ms.appendChild(newNodeText);
|
ms.appendChild(newNodeText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,8 @@ protected:
|
||||||
virtual void ApplyPatches() Q_DECL_OVERRIDE;
|
virtual void ApplyPatches() Q_DECL_OVERRIDE;
|
||||||
virtual void DowngradeToCurrentMaxVersion() Q_DECL_OVERRIDE;
|
virtual void DowngradeToCurrentMaxVersion() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
virtual bool IsReadOnly() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VPatternConverter)
|
Q_DISABLE_COPY(VPatternConverter)
|
||||||
static const QString PatternMinVerStr;
|
static const QString PatternMinVerStr;
|
||||||
|
|
|
@ -60,6 +60,8 @@ const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/in
|
||||||
//VVITConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
//VVITConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||||
//VVITConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
//VVITConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||||
|
|
||||||
|
static const QString strTagRead_Only = QStringLiteral("read-only");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VVITConverter::VVITConverter(const QString &fileName)
|
VVITConverter::VVITConverter(const QString &fileName)
|
||||||
:VAbstractMConverter(fileName)
|
:VAbstractMConverter(fileName)
|
||||||
|
@ -95,48 +97,29 @@ QString VVITConverter::XSDSchema(int ver) const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VVITConverter::ApplyPatches()
|
void VVITConverter::ApplyPatches()
|
||||||
{
|
{
|
||||||
try
|
switch (m_ver)
|
||||||
{
|
{
|
||||||
switch (ver)
|
case (0x000200):
|
||||||
{
|
ToV0_3_0();
|
||||||
case (0x000200):
|
ValidateXML(XSDSchema(0x000300), m_convertedFileName);
|
||||||
ToV0_3_0();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000300), fileName);
|
case (0x000300):
|
||||||
V_FALLTHROUGH
|
ToV0_3_1();
|
||||||
case (0x000300):
|
ValidateXML(XSDSchema(0x000301), m_convertedFileName);
|
||||||
ToV0_3_1();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000301), fileName);
|
case (0x000301):
|
||||||
V_FALLTHROUGH
|
ToV0_3_2();
|
||||||
case (0x000301):
|
ValidateXML(XSDSchema(0x000302), m_convertedFileName);
|
||||||
ToV0_3_2();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000302), fileName);
|
case (0x000302):
|
||||||
V_FALLTHROUGH
|
ToV0_3_3();
|
||||||
case (0x000302):
|
ValidateXML(XSDSchema(0x000303), m_convertedFileName);
|
||||||
ToV0_3_3();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000303), fileName);
|
case (0x000303):
|
||||||
V_FALLTHROUGH
|
break;
|
||||||
case (0x000303):
|
default:
|
||||||
break;
|
InvalidVersion(m_ver);
|
||||||
default:
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (VException &e)
|
|
||||||
{
|
|
||||||
QString error;
|
|
||||||
const QString backupFileName = fileName + QLatin1String(".backup");
|
|
||||||
if (SafeCopy(backupFileName, fileName, error) == false)
|
|
||||||
{
|
|
||||||
const QString errorMsg(tr("Error restoring backup file: %1.").arg(error));
|
|
||||||
VException excep(errorMsg);
|
|
||||||
excep.AddMoreInformation(e.ErrorMessage());
|
|
||||||
throw excep;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile file(backupFileName);
|
|
||||||
file.remove();
|
|
||||||
|
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +130,20 @@ void VVITConverter::DowngradeToCurrentMaxVersion()
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VVITConverter::IsReadOnly() const
|
||||||
|
{
|
||||||
|
// Check if attribute read-only was not changed in file format
|
||||||
|
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == CONVERTER_VERSION_CHECK(0, 3, 3),
|
||||||
|
"Check attribute read-only.");
|
||||||
|
|
||||||
|
// Possibly in future attribute read-only will change position etc.
|
||||||
|
// For now position is the same for all supported format versions.
|
||||||
|
// But don't forget to keep all versions of attribute until we support that format versions
|
||||||
|
|
||||||
|
return UniqueTagText(strTagRead_Only, falseStr) == trueStr;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VVITConverter::AddNewTagsForV0_3_0()
|
void VVITConverter::AddNewTagsForV0_3_0()
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,6 +67,7 @@ protected:
|
||||||
virtual QString XSDSchema(int ver) const Q_DECL_OVERRIDE;
|
virtual QString XSDSchema(int ver) const Q_DECL_OVERRIDE;
|
||||||
virtual void ApplyPatches() Q_DECL_OVERRIDE;
|
virtual void ApplyPatches() Q_DECL_OVERRIDE;
|
||||||
virtual void DowngradeToCurrentMaxVersion() Q_DECL_OVERRIDE;
|
virtual void DowngradeToCurrentMaxVersion() Q_DECL_OVERRIDE;
|
||||||
|
virtual bool IsReadOnly() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VVITConverter)
|
Q_DISABLE_COPY(VVITConverter)
|
||||||
|
|
|
@ -60,6 +60,8 @@ const QString VVSTConverter::CurrentSchema = QStringLiteral("://schema/st
|
||||||
//VVSTConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
//VVSTConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||||
//VVSTConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
//VVSTConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||||
|
|
||||||
|
static const QString strTagRead_Only = QStringLiteral("read-only");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VVSTConverter::VVSTConverter(const QString &fileName)
|
VVSTConverter::VVSTConverter(const QString &fileName)
|
||||||
:VAbstractMConverter(fileName)
|
:VAbstractMConverter(fileName)
|
||||||
|
@ -95,48 +97,29 @@ QString VVSTConverter::XSDSchema(int ver) const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VVSTConverter::ApplyPatches()
|
void VVSTConverter::ApplyPatches()
|
||||||
{
|
{
|
||||||
try
|
switch (m_ver)
|
||||||
{
|
{
|
||||||
switch (ver)
|
case (0x000300):
|
||||||
{
|
ToV0_4_0();
|
||||||
case (0x000300):
|
ValidateXML(XSDSchema(0x000400), m_convertedFileName);
|
||||||
ToV0_4_0();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000400), fileName);
|
case (0x000400):
|
||||||
V_FALLTHROUGH
|
ToV0_4_1();
|
||||||
case (0x000400):
|
ValidateXML(XSDSchema(0x000401), m_convertedFileName);
|
||||||
ToV0_4_1();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000401), fileName);
|
case (0x000401):
|
||||||
V_FALLTHROUGH
|
ToV0_4_2();
|
||||||
case (0x000401):
|
ValidateXML(XSDSchema(0x000402), m_convertedFileName);
|
||||||
ToV0_4_2();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000402), fileName);
|
case (0x000402):
|
||||||
V_FALLTHROUGH
|
ToV0_4_3();
|
||||||
case (0x000402):
|
ValidateXML(XSDSchema(0x000403), m_convertedFileName);
|
||||||
ToV0_4_3();
|
V_FALLTHROUGH
|
||||||
ValidateXML(XSDSchema(0x000403), fileName);
|
case (0x000403):
|
||||||
V_FALLTHROUGH
|
break;
|
||||||
case (0x000403):
|
default:
|
||||||
break;
|
InvalidVersion(m_ver);
|
||||||
default:
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (VException &e)
|
|
||||||
{
|
|
||||||
QString error;
|
|
||||||
const QString backupFileName = fileName + QLatin1String(".backup");
|
|
||||||
if (SafeCopy(backupFileName, fileName, error) == false)
|
|
||||||
{
|
|
||||||
const QString errorMsg(tr("Error restoring backup file: %1.").arg(error));
|
|
||||||
VException excep(errorMsg);
|
|
||||||
excep.AddMoreInformation(e.ErrorMessage());
|
|
||||||
throw excep;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile file(backupFileName);
|
|
||||||
file.remove();
|
|
||||||
|
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +130,20 @@ void VVSTConverter::DowngradeToCurrentMaxVersion()
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool VVSTConverter::IsReadOnly() const
|
||||||
|
{
|
||||||
|
// Check if attribute read-only was not changed in file format
|
||||||
|
Q_STATIC_ASSERT_X(VVSTConverter::MeasurementMaxVer == CONVERTER_VERSION_CHECK(0, 4, 3),
|
||||||
|
"Check attribute read-only.");
|
||||||
|
|
||||||
|
// Possibly in future attribute read-only will change position etc.
|
||||||
|
// For now position is the same for all supported format versions.
|
||||||
|
// But don't forget to keep all versions of attribute until we support that format versions
|
||||||
|
|
||||||
|
return UniqueTagText(strTagRead_Only, falseStr) == trueStr;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VVSTConverter::AddNewTagsForV0_4_0()
|
void VVSTConverter::AddNewTagsForV0_4_0()
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,6 +67,7 @@ protected:
|
||||||
virtual QString XSDSchema(int ver) const Q_DECL_OVERRIDE;
|
virtual QString XSDSchema(int ver) const Q_DECL_OVERRIDE;
|
||||||
virtual void ApplyPatches() Q_DECL_OVERRIDE;
|
virtual void ApplyPatches() Q_DECL_OVERRIDE;
|
||||||
virtual void DowngradeToCurrentMaxVersion() Q_DECL_OVERRIDE;
|
virtual void DowngradeToCurrentMaxVersion() Q_DECL_OVERRIDE;
|
||||||
|
virtual bool IsReadOnly() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VVSTConverter)
|
Q_DISABLE_COPY(VVSTConverter)
|
||||||
|
|
|
@ -373,7 +373,7 @@ QString VMeasurements::Notes() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VMeasurements::SetNotes(const QString &text)
|
void VMeasurements::SetNotes(const QString &text)
|
||||||
{
|
{
|
||||||
if (not ReadOnly())
|
if (not IsReadOnly())
|
||||||
{
|
{
|
||||||
setTagText(TagNotes, text);
|
setTagText(TagNotes, text);
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,7 @@ QString VMeasurements::FamilyName() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VMeasurements::SetFamilyName(const QString &text)
|
void VMeasurements::SetFamilyName(const QString &text)
|
||||||
{
|
{
|
||||||
if (not ReadOnly())
|
if (not IsReadOnly())
|
||||||
{
|
{
|
||||||
setTagText(TagFamilyName, text);
|
setTagText(TagFamilyName, text);
|
||||||
}
|
}
|
||||||
|
@ -403,7 +403,7 @@ QString VMeasurements::GivenName() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VMeasurements::SetGivenName(const QString &text)
|
void VMeasurements::SetGivenName(const QString &text)
|
||||||
{
|
{
|
||||||
if (not ReadOnly())
|
if (not IsReadOnly())
|
||||||
{
|
{
|
||||||
setTagText(TagGivenName, text);
|
setTagText(TagGivenName, text);
|
||||||
}
|
}
|
||||||
|
@ -418,7 +418,7 @@ QDate VMeasurements::BirthDate() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VMeasurements::SetBirthDate(const QDate &date)
|
void VMeasurements::SetBirthDate(const QDate &date)
|
||||||
{
|
{
|
||||||
if (not ReadOnly())
|
if (not IsReadOnly())
|
||||||
{
|
{
|
||||||
setTagText(TagBirthDate, date.toString("yyyy-MM-dd"));
|
setTagText(TagBirthDate, date.toString("yyyy-MM-dd"));
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ GenderType VMeasurements::Gender() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VMeasurements::SetGender(const GenderType &gender)
|
void VMeasurements::SetGender(const GenderType &gender)
|
||||||
{
|
{
|
||||||
if (not ReadOnly())
|
if (not IsReadOnly())
|
||||||
{
|
{
|
||||||
setTagText(TagGender, GenderToStr(gender));
|
setTagText(TagGender, GenderToStr(gender));
|
||||||
}
|
}
|
||||||
|
@ -448,7 +448,7 @@ QString VMeasurements::PMSystem() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VMeasurements::SetPMSystem(const QString &system)
|
void VMeasurements::SetPMSystem(const QString &system)
|
||||||
{
|
{
|
||||||
if (not ReadOnly())
|
if (not IsReadOnly())
|
||||||
{
|
{
|
||||||
setTagText(TagPMSystem, ClearPMCode(system));
|
setTagText(TagPMSystem, ClearPMCode(system));
|
||||||
}
|
}
|
||||||
|
@ -463,23 +463,16 @@ QString VMeasurements::Email() const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VMeasurements::SetEmail(const QString &text)
|
void VMeasurements::SetEmail(const QString &text)
|
||||||
{
|
{
|
||||||
if (not ReadOnly())
|
if (not IsReadOnly())
|
||||||
{
|
{
|
||||||
setTagText(TagEmail, text);
|
setTagText(TagEmail, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
bool VMeasurements::ReadOnly() const
|
bool VMeasurements::IsReadOnly() const
|
||||||
{
|
{
|
||||||
if (UniqueTagText(TagReadOnly, "false") == "true")
|
return UniqueTagText(TagReadOnly, falseStr) == trueStr;
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -487,11 +480,11 @@ void VMeasurements::SetReadOnly(bool ro)
|
||||||
{
|
{
|
||||||
if (ro)
|
if (ro)
|
||||||
{
|
{
|
||||||
setTagText(TagReadOnly, "true");
|
setTagText(TagReadOnly, trueStr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setTagText(TagReadOnly, "false");
|
setTagText(TagReadOnly, falseStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ public:
|
||||||
QString Email() const;
|
QString Email() const;
|
||||||
void SetEmail(const QString &text);
|
void SetEmail(const QString &text);
|
||||||
|
|
||||||
bool ReadOnly() const;
|
bool IsReadOnly() const;
|
||||||
void SetReadOnly(bool ro);
|
void SetReadOnly(bool ro);
|
||||||
|
|
||||||
void SetMName(const QString &name, const QString &text);
|
void SetMName(const QString &name, const QString &text);
|
||||||
|
|
|
@ -125,18 +125,6 @@ VAbstractApplication::VAbstractApplication(int &argc, char **argv)
|
||||||
// Connect this slot with VApplication::aboutToQuit.
|
// Connect this slot with VApplication::aboutToQuit.
|
||||||
Settings()->sync();
|
Settings()->sync();
|
||||||
});
|
});
|
||||||
|
|
||||||
#if !defined(Q_OS_WIN)
|
|
||||||
QDir standardPath(VCommonSettings::unixStandardSharePath);
|
|
||||||
const QDir localdata (QDir::homePath() + QDir::separator() + VCommonSettings::valentinaUnixHomeFolder);
|
|
||||||
if (standardPath.exists() && not localdata.exists())
|
|
||||||
{
|
|
||||||
if (localdata.mkdir(localdata.absolutePath()))
|
|
||||||
{
|
|
||||||
SymlinkCopyDirRecursive(standardPath.absolutePath(), localdata.absolutePath(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // !defined(Q_OS_WIN)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -406,54 +394,3 @@ void VAbstractApplication::ClearTranslation()
|
||||||
delete pmsTranslator;
|
delete pmsTranslator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
bool VAbstractApplication::SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool replaceOnConflit)
|
|
||||||
{
|
|
||||||
QDir dir;
|
|
||||||
dir.setPath(fromDir);
|
|
||||||
|
|
||||||
foreach (QString copyFile, dir.entryList(QDir::Files))
|
|
||||||
{
|
|
||||||
const QString from = fromDir + QDir::separator() + copyFile;
|
|
||||||
const QString to = toDir + QDir::separator() + copyFile;
|
|
||||||
|
|
||||||
if (QFile::exists(to))
|
|
||||||
{
|
|
||||||
if (replaceOnConflit)
|
|
||||||
{
|
|
||||||
if (QFile::remove(to) == false)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (QFile::link(from, to) == false)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (QString copyDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
|
||||||
{
|
|
||||||
const QString from = fromDir + QDir::separator() + copyDir;
|
|
||||||
const QString to = toDir + QDir::separator() + copyDir;
|
|
||||||
|
|
||||||
if (dir.mkpath(to) == false)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SymlinkCopyDirRecursive(from, to, replaceOnConflit) == false)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
|
@ -149,8 +149,6 @@ private:
|
||||||
bool openingPattern;
|
bool openingPattern;
|
||||||
|
|
||||||
void ClearTranslation();
|
void ClearTranslation();
|
||||||
|
|
||||||
static bool SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool replaceOnConflit);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,7 @@ const QString VCommonSettings::SettingUserDefinedMaterials = QStringLitera
|
||||||
static const QString commonIniFilename = QStringLiteral("common");
|
static const QString commonIniFilename = QStringLiteral("common");
|
||||||
|
|
||||||
#if !defined(Q_OS_WIN)
|
#if !defined(Q_OS_WIN)
|
||||||
const QString VCommonSettings::unixStandardSharePath = QStringLiteral("/usr/share/valentina");
|
const QString VCommonSettings::unixStandardSharePath = QStringLiteral("/usr/share/valentina");
|
||||||
const QString VCommonSettings::valentinaUnixHomeFolder = QStringLiteral(".valentina");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -110,15 +109,7 @@ QString VCommonSettings::SharePath(const QString &shareItem)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QDir dir(QDir::homePath() + QDir::separator() + VCommonSettings::valentinaUnixHomeFolder + shareItem);
|
return VCommonSettings::unixStandardSharePath + shareItem;
|
||||||
if (dir.exists())
|
|
||||||
{
|
|
||||||
return dir.absolutePath();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return VCommonSettings::unixStandardSharePath + shareItem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else // Unix
|
#else // Unix
|
||||||
|
@ -132,15 +123,7 @@ QString VCommonSettings::SharePath(const QString &shareItem)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QDir dir(QDir::homePath() + QDir::separator() + VCommonSettings::valentinaUnixHomeFolder + shareItem);
|
return VCommonSettings::unixStandardSharePath + shareItem;
|
||||||
if (dir.exists())
|
|
||||||
{
|
|
||||||
return dir.absolutePath();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return VCommonSettings::unixStandardSharePath + shareItem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -128,7 +128,6 @@ public:
|
||||||
|
|
||||||
#if !defined(Q_OS_WIN)
|
#if !defined(Q_OS_WIN)
|
||||||
static const QString unixStandardSharePath;
|
static const QString unixStandardSharePath;
|
||||||
static const QString valentinaUnixHomeFolder;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user