mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
Search and replace : Independent text item can be changed (and mass changed) through the search and replace widget.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5582 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -21,6 +21,9 @@
|
||||
#include "changeelementinformationcommand.h"
|
||||
#include "element.h"
|
||||
#include "qetapp.h"
|
||||
#include "independenttextitem.h"
|
||||
#include "diagramcommands.h"
|
||||
|
||||
|
||||
SearchAndReplaceWorker::SearchAndReplaceWorker()
|
||||
{}
|
||||
@@ -205,3 +208,39 @@ void SearchAndReplaceWorker::replaceElement(Element *element)
|
||||
list.append(element);
|
||||
replaceElement(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SearchAndReplaceWorker::replaceIndiText
|
||||
* Replace all displayed text of independent text of @list
|
||||
* Each must belong to the same project, if not this function do nothing
|
||||
* @param list
|
||||
*/
|
||||
void SearchAndReplaceWorker::replaceIndiText(QList<IndependentTextItem *> list)
|
||||
{
|
||||
if (list.isEmpty() || !list.first()->diagram()) {
|
||||
return;
|
||||
}
|
||||
QETProject *project_ = list.first()->diagram()->project();
|
||||
for (IndependentTextItem *text : list) {
|
||||
if (!text->diagram() ||
|
||||
text->diagram()->project() != project_) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
project_->undoStack()->beginMacro(QObject::tr("Chercher remplacer des textes independant"));
|
||||
for (IndependentTextItem *text : list)
|
||||
{
|
||||
QString before = text->toPlainText();
|
||||
text->setPlainText(m_indi_text);
|
||||
project_->undoStack()->push(new ChangeDiagramTextCommand(text, before, m_indi_text));
|
||||
}
|
||||
project_->undoStack()->endMacro();
|
||||
}
|
||||
|
||||
void SearchAndReplaceWorker::replaceIndiText(IndependentTextItem *text)
|
||||
{
|
||||
QList<IndependentTextItem *>list;
|
||||
list.append(text);
|
||||
replaceIndiText(list);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user