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

View File

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

View File

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

View File

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

View File

@ -932,6 +932,20 @@ void VAbstractPattern::SetImage(const QString &text)
emit patternChanged(false); 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 QString VAbstractPattern::GetVersion() const
{ {

View File

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