Added delete button

--HG--
branch : feature
This commit is contained in:
Valentina Zhuravska 2016-03-15 20:32:52 +02:00
parent ae66acd4d6
commit d2e0c7822f
6 changed files with 32 additions and 3 deletions

View File

@ -65,6 +65,7 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
connect(ui->plainTextEditTechNotes, &QPlainTextEdit::textChanged, this, &DialogPatternProperties::DescEdited);
InitImage();
connect(ui->deleteImageButton, &QPushButton::clicked, this, &DialogPatternProperties::DeleteImage);
connect(ui->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, this, &DialogPatternProperties::Ok);
connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this,
@ -649,5 +650,11 @@ void DialogPatternProperties::SetNewImage()
// save our image to file.val
doc->SetImage(iconBase64);
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::DeleteImage()
{
doc->DeleteImage();
ui->imageLabel->setText("Change image");
}

View File

@ -64,6 +64,7 @@ private slots:
void ToggleComboBox();
void DefValueChanged();
void SecurityValueChanged();
void DeleteImage();
private:
Q_DISABLE_COPY(DialogPatternProperties)
Ui::DialogPatternProperties *ui;

View File

@ -106,6 +106,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteImageButton">
<property name="text">
<string>delete image</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -86,7 +86,6 @@ void VPattern::CreateEmptyFile()
patternElement.appendChild(createElement(TagAuthor));
patternElement.appendChild(createElement(TagDescription));
patternElement.appendChild(createElement(TagNotes));
patternElement.appendChild(createElement(TagImage));
patternElement.appendChild(createElement(TagMeasurements));
patternElement.appendChild(createElement(TagIncrements));
@ -128,7 +127,7 @@ void VPattern::Parse(const Document &parse)
SCASSERT(sceneDraw != nullptr);
SCASSERT(sceneDetail != nullptr);
QStringList tags = QStringList() << TagDraw << TagIncrements << TagAuthor << TagDescription << TagNotes
<< TagImage << TagMeasurements << TagVersion << TagGradation << TagUnit;
<< TagMeasurements << TagVersion << TagGradation << TagImage << TagUnit;
PrepareForParse(parse);
QDomNode domNode = documentElement().firstChild();
while (domNode.isNull() == false)

View File

@ -932,6 +932,20 @@ void VAbstractPattern::SetImage(const QString &text)
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::DeleteImage()
{
QDomElement pattern = documentElement();
QDomNodeList images = this->elementsByTagName(TagImage);
for (int i=0; i<images.count(); ++i)
{
QDomNode image = images.at(i);
pattern.removeChild(image);
}
modified = true;
emit patternChanged(false);
}
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetVersion() const
{

View File

@ -108,6 +108,7 @@ public:
QString GetImage() const;
void SetImage(const QString &text);
void DeleteImage();
QString GetVersion() const;
void SetVersion();