New option Measurements->Unload measurements.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-10-26 13:21:49 +02:00
parent f1796eaf90
commit caa1a46b01
5 changed files with 53 additions and 9 deletions

View file

@ -1140,6 +1140,7 @@ void MainWindow::LoadIndividual()
{ {
watcher->removePath(AbsoluteMPath(curFile, doc->MPath())); watcher->removePath(AbsoluteMPath(curFile, doc->MPath()));
} }
ui->actionUnloadMeasurements->setEnabled(true);
doc->SetPath(RelativeMPath(curFile, mPath)); doc->SetPath(RelativeMPath(curFile, mPath));
watcher->addPath(mPath); watcher->addPath(mPath);
PatternWasModified(false); PatternWasModified(false);
@ -1166,6 +1167,7 @@ void MainWindow::LoadStandard()
{ {
watcher->removePath(AbsoluteMPath(curFile, doc->MPath())); watcher->removePath(AbsoluteMPath(curFile, doc->MPath()));
} }
ui->actionUnloadMeasurements->setEnabled(true);
doc->SetPath(RelativeMPath(curFile, mPath)); doc->SetPath(RelativeMPath(curFile, mPath));
watcher->addPath(mPath); watcher->addPath(mPath);
PatternWasModified(false); PatternWasModified(false);
@ -1176,6 +1178,31 @@ void MainWindow::LoadStandard()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::UnloadMeasurements()
{
if (doc->MPath().isEmpty())
{
ui->actionUnloadMeasurements->setDisabled(true);
return;
}
if (doc->ListMeasurements().isEmpty())
{
watcher->removePath(AbsoluteMPath(curFile, doc->MPath()));
doc->SetPath(QString());
PatternWasModified(false);
ui->actionShowM->setEnabled(false);
ui->actionUnloadMeasurements->setDisabled(true);
helpLabel->setText(tr("Measurements unloaded"));
}
else
{
qCWarning(vMainWindow, "%s",
qUtf8Printable(tr("Couldn't unload measurements. Some of them are used in the pattern.")));
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::CreateMeasurements() void MainWindow::CreateMeasurements()
{ {
@ -2132,6 +2159,7 @@ void MainWindow::Clear()
ui->actionShowCurveDetails->setEnabled(false); ui->actionShowCurveDetails->setEnabled(false);
ui->actionLoadIndividual->setEnabled(false); ui->actionLoadIndividual->setEnabled(false);
ui->actionLoadStandard->setEnabled(false); ui->actionLoadStandard->setEnabled(false);
ui->actionUnloadMeasurements->setEnabled(false);
ui->actionShowM->setEnabled(false); ui->actionShowM->setEnabled(false);
SetEnableTool(false); SetEnableTool(false);
qApp->setPatternUnit(Unit::Cm); qApp->setPatternUnit(Unit::Cm);
@ -2375,6 +2403,7 @@ void MainWindow::SetEnableWidgets(bool enable)
ui->actionShowCurveDetails->setEnabled(enable); ui->actionShowCurveDetails->setEnabled(enable);
ui->actionLoadIndividual->setEnabled(enable); ui->actionLoadIndividual->setEnabled(enable);
ui->actionLoadStandard->setEnabled(enable); ui->actionLoadStandard->setEnabled(enable);
ui->actionUnloadMeasurements->setEnabled(enable);
//Now we don't want allow user call context menu //Now we don't want allow user call context menu
sceneDraw->SetDisableTools(!enable, doc->GetNameActivPP()); sceneDraw->SetDisableTools(!enable, doc->GetNameActivPP());
@ -3178,6 +3207,7 @@ void MainWindow::CreateActions()
} }
connect(ui->actionSyncMeasurements, &QAction::triggered, this, &MainWindow::SyncMeasurements); connect(ui->actionSyncMeasurements, &QAction::triggered, this, &MainWindow::SyncMeasurements);
connect(ui->actionUnloadMeasurements, &QAction::triggered, this, &MainWindow::UnloadMeasurements);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -3336,6 +3366,7 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
} }
else else
{ {
ui->actionUnloadMeasurements->setEnabled(true);
watcher->addPath(path); watcher->addPath(path);
ui->actionShowM->setEnabled(true); ui->actionShowM->setEnabled(true);
} }

View file

@ -163,6 +163,7 @@ protected:
private slots: private slots:
void LoadIndividual(); void LoadIndividual();
void LoadStandard(); void LoadStandard();
void UnloadMeasurements();
void CreateMeasurements(); void CreateMeasurements();
void ShowMeasurements(); void ShowMeasurements();
void MeasurementsChanged(const QString &path); void MeasurementsChanged(const QString &path);

View file

@ -1090,6 +1090,7 @@
<addaction name="actionTable"/> <addaction name="actionTable"/>
<addaction name="actionLoadIndividual"/> <addaction name="actionLoadIndividual"/>
<addaction name="actionLoadStandard"/> <addaction name="actionLoadStandard"/>
<addaction name="actionUnloadMeasurements"/>
<addaction name="actionCreateNew"/> <addaction name="actionCreateNew"/>
<addaction name="actionShowM"/> <addaction name="actionShowM"/>
<addaction name="actionSyncMeasurements"/> <addaction name="actionSyncMeasurements"/>
@ -1991,6 +1992,20 @@
<string notr="true"/> <string notr="true"/>
</property> </property>
</action> </action>
<action name="actionUnloadMeasurements">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Unload measurements</string>
</property>
<property name="toolTip">
<string>Unload measurements if they was not used in a pattern file.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<customwidgets> <customwidgets>
@ -2004,8 +2019,8 @@
<tabstop>toolButtonSplinePath</tabstop> <tabstop>toolButtonSplinePath</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="share/resources/toolicon.qrc"/>
<include location="../../libs/vmisc/share/resources/icon.qrc"/> <include location="../../libs/vmisc/share/resources/icon.qrc"/>
<include location="share/resources/toolicon.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View file

@ -457,12 +457,6 @@ QString VAbstractPattern::MPath() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetPath(const QString &path) void VAbstractPattern::SetPath(const QString &path)
{ {
if (path.isEmpty())
{
qDebug()<<"Path to measurements is empty"<<Q_FUNC_INFO;
return;
}
if (setTagText(TagMeasurements, path)) if (setTagText(TagMeasurements, path))
{ {
emit patternChanged(false); emit patternChanged(false);

View file

@ -691,8 +691,11 @@ bool VDomDocument::setTagText(const QString &tag, const QString &text)
{ {
QDomElement parent = domElement.parentNode().toElement(); QDomElement parent = domElement.parentNode().toElement();
QDomElement newTag = createElement(tag); QDomElement newTag = createElement(tag);
const QDomText newTagText = createTextNode(text); if (not text.isEmpty())
newTag.appendChild(newTagText); {
const QDomText newTagText = createTextNode(text);
newTag.appendChild(newTagText);
}
parent.replaceChild(newTag, domElement); parent.replaceChild(newTag, domElement);
return true; return true;