mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Search and replace : improve the search for diagram
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5565 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -246,6 +246,7 @@ void SearchAndReplaceWidget::fillItemsList()
|
||||
|
||||
QTreeWidgetItem *qtwi = new QTreeWidgetItem(m_folio_qtwi);
|
||||
qtwi->setText(0, str);
|
||||
qtwi->setData(0, Qt::UserRole, searchTerms(diagram));
|
||||
qtwi->setCheckState(0, Qt::Checked);
|
||||
m_diagram_hash.insert(qtwi, QPointer<Diagram>(diagram));
|
||||
dc += DiagramContent(diagram, false);
|
||||
@@ -356,12 +357,22 @@ void SearchAndReplaceWidget::search()
|
||||
}
|
||||
|
||||
bool match = false;
|
||||
for(QTreeWidgetItem *qtwi : ui->m_tree_widget->findItems(str, Qt::MatchContains | Qt::MatchRecursive))
|
||||
for (QTreeWidgetItem *qtwi : ui->m_tree_widget->findItems(str, Qt::MatchContains | Qt::MatchRecursive)) //Search in all items
|
||||
{
|
||||
match = true;
|
||||
qtwi->setHidden(false);
|
||||
setVisibleAllParents(qtwi);
|
||||
}
|
||||
for (QTreeWidgetItem *qtwi : m_diagram_hash.keys()) //Search for diagrams items
|
||||
{
|
||||
QStringList list = qtwi->data(0, Qt::UserRole).toStringList();
|
||||
if (!list.filter(str, Qt::CaseInsensitive).isEmpty())
|
||||
{
|
||||
match = true;
|
||||
qtwi->setHidden(false);
|
||||
setVisibleAllParents(qtwi);
|
||||
}
|
||||
}
|
||||
|
||||
QPalette background = ui->m_search_le->palette();
|
||||
background.setColor(QPalette::Base, match ? QColor("#E0FFF0") : QColor("#FFE0EF"));
|
||||
@@ -589,7 +600,31 @@ void SearchAndReplaceWidget::activateNextChecked()
|
||||
do {
|
||||
on_m_next_pb_clicked();
|
||||
} while ((ui->m_tree_widget->currentItem()->checkState(0) != Qt::Checked) &&
|
||||
ui->m_next_pb->isEnabled());
|
||||
ui->m_next_pb->isEnabled());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SearchAndReplaceWidget::searchTerms
|
||||
* @param diagram
|
||||
* @return All QStrings use as terms for search.
|
||||
*/
|
||||
QStringList SearchAndReplaceWidget::searchTerms(Diagram *diagram) const
|
||||
{
|
||||
QStringList list;
|
||||
TitleBlockProperties prop = diagram->border_and_titleblock.exportTitleBlock();
|
||||
list.append(prop.title);
|
||||
list.append(prop.author);
|
||||
list.append(prop.filename);
|
||||
list.append(prop.machine);
|
||||
list.append(prop.locmach);
|
||||
list.append(prop.indexrev);
|
||||
list.append(prop.folio);
|
||||
list.append(prop.date.toString());
|
||||
for (QString key : prop.context.keys()) {
|
||||
list.append(prop.context.value(key).toString());
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void SearchAndReplaceWidget::on_m_quit_button_clicked() {
|
||||
@@ -693,6 +728,10 @@ void SearchAndReplaceWidget::on_m_tree_widget_currentItemChanged(QTreeWidgetItem
|
||||
}
|
||||
|
||||
updateNextPreviousButtons();
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (current->checkState(0) == Qt::Checked && !m_category_qtwi.contains(current)) {
|
||||
ui->m_replace_pb->setEnabled(true);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user