summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libs/aggregation/aggregate.cpp32
-rw-r--r--src/libs/aggregation/aggregate.h3
-rw-r--r--src/plugins/find/currentdocumentfind.cpp46
-rw-r--r--src/plugins/find/currentdocumentfind.h4
4 files changed, 68 insertions, 17 deletions
diff --git a/src/libs/aggregation/aggregate.cpp b/src/libs/aggregation/aggregate.cpp
index a4c00e8638..03f23e629b 100644
--- a/src/libs/aggregation/aggregate.cpp
+++ b/src/libs/aggregation/aggregate.cpp
@@ -232,15 +232,18 @@ void Aggregate::add(QObject *component)
{
if (!component)
return;
- QWriteLocker locker(&lock());
- Aggregate *parentAggregation = aggregateMap().value(component);
- if (parentAggregation == this)
- return;
- if (parentAggregation)
- parentAggregation->remove(component);
- m_components.append(component);
- connect(component, SIGNAL(destroyed(QObject*)), this, SLOT(deleteSelf(QObject*)));
- aggregateMap().insert(component, this);
+ {
+ QWriteLocker locker(&lock());
+ Aggregate *parentAggregation = aggregateMap().value(component);
+ if (parentAggregation == this)
+ return;
+ if (parentAggregation)
+ parentAggregation->remove(component);
+ m_components.append(component);
+ connect(component, SIGNAL(destroyed(QObject*)), this, SLOT(deleteSelf(QObject*)));
+ aggregateMap().insert(component, this);
+ }
+ emit changed();
}
/*!
@@ -254,8 +257,11 @@ void Aggregate::remove(QObject *component)
{
if (!component)
return;
- QWriteLocker locker(&lock());
- aggregateMap().remove(component);
- m_components.removeAll(component);
- disconnect(component, SIGNAL(destroyed(QObject*)), this, SLOT(deleteSelf(QObject*)));
+ {
+ QWriteLocker locker(&lock());
+ aggregateMap().remove(component);
+ m_components.removeAll(component);
+ disconnect(component, SIGNAL(destroyed(QObject*)), this, SLOT(deleteSelf(QObject*)));
+ }
+ emit changed();
}
diff --git a/src/libs/aggregation/aggregate.h b/src/libs/aggregation/aggregate.h
index 6bd36dffa5..c3240f8de0 100644
--- a/src/libs/aggregation/aggregate.h
+++ b/src/libs/aggregation/aggregate.h
@@ -74,6 +74,9 @@ public:
static Aggregate *parentAggregate(QObject *obj);
static QReadWriteLock &lock();
+signals:
+ void changed();
+
private slots:
void deleteSelf(QObject *obj);
diff --git a/src/plugins/find/currentdocumentfind.cpp b/src/plugins/find/currentdocumentfind.cpp
index 728a73dec5..0ca72b834a 100644
--- a/src/plugins/find/currentdocumentfind.cpp
+++ b/src/plugins/find/currentdocumentfind.cpp
@@ -154,8 +154,14 @@ void CurrentDocumentFind::updateCandidateFindFilter(QWidget *old, QWidget *now)
if (!impl)
candidate = candidate->parentWidget();
}
+ if (m_candidateWidget)
+ disconnect(Aggregation::Aggregate::parentAggregate(m_candidateWidget), SIGNAL(changed()),
+ this, SLOT(candidateAggregationChanged()));
m_candidateWidget = candidate;
m_candidateFind = impl;
+ if (m_candidateWidget)
+ connect(Aggregation::Aggregate::parentAggregate(m_candidateWidget), SIGNAL(changed()),
+ this, SLOT(candidateAggregationChanged()));
emit candidateChanged();
}
@@ -166,11 +172,18 @@ void CurrentDocumentFind::acceptCandidate()
removeFindSupportConnections();
if (m_currentFind)
m_currentFind->highlightAll(QString(), 0);
+
+ if (m_currentWidget)
+ disconnect(Aggregation::Aggregate::parentAggregate(m_currentWidget), SIGNAL(changed()),
+ this, SLOT(aggregationChanged()));
m_currentWidget = m_candidateWidget;
+ connect(Aggregation::Aggregate::parentAggregate(m_currentWidget), SIGNAL(changed()),
+ this, SLOT(aggregationChanged()));
+
m_currentFind = m_candidateFind;
if (m_currentFind) {
connect(m_currentFind, SIGNAL(changed()), this, SIGNAL(changed()));
- connect(m_currentFind, SIGNAL(destroyed(QObject*)), SLOT(findSupportDestroyed()));
+ connect(m_currentFind, SIGNAL(destroyed(QObject*)), SLOT(clearFindSupport()));
}
if (m_currentWidget)
m_currentWidget->installEventFilter(this);
@@ -181,13 +194,13 @@ void CurrentDocumentFind::removeFindSupportConnections()
{
if (m_currentFind) {
disconnect(m_currentFind, SIGNAL(changed()), this, SIGNAL(changed()));
- disconnect(m_currentFind, SIGNAL(destroyed(QObject*)), this, SLOT(findSupportDestroyed()));
+ disconnect(m_currentFind, SIGNAL(destroyed(QObject*)), this, SLOT(clearFindSupport()));
}
if (m_currentWidget)
m_currentWidget->removeEventFilter(this);
}
-void CurrentDocumentFind::findSupportDestroyed()
+void CurrentDocumentFind::clearFindSupport()
{
removeFindSupportConnections();
m_currentWidget = 0;
@@ -213,3 +226,30 @@ bool CurrentDocumentFind::eventFilter(QObject *obj, QEvent *event)
}
return QObject::eventFilter(obj, event);
}
+
+void CurrentDocumentFind::aggregationChanged()
+{
+ if (m_currentWidget) {
+ QPointer<IFindSupport> currentFind = Aggregation::query<IFindSupport>(m_currentWidget);
+ if (currentFind != m_currentFind) {
+ // There's a change in the find support
+ if (currentFind) {
+ m_candidateWidget = m_currentWidget;
+ m_candidateFind = currentFind;
+ acceptCandidate();
+ }
+ else {
+ clearFindSupport();
+ m_currentFind = 0;
+ }
+ }
+ }
+}
+
+void CurrentDocumentFind::candidateAggregationChanged()
+{
+ if (m_candidateWidget && m_candidateWidget!=m_currentWidget) {
+ m_candidateFind = Aggregation::query<IFindSupport>(m_candidateWidget);
+ emit candidateChanged();
+ }
+}
diff --git a/src/plugins/find/currentdocumentfind.h b/src/plugins/find/currentdocumentfind.h
index 6e3def7791..f104ef5f4b 100644
--- a/src/plugins/find/currentdocumentfind.h
+++ b/src/plugins/find/currentdocumentfind.h
@@ -75,7 +75,9 @@ signals:
private slots:
void updateCandidateFindFilter(QWidget *old, QWidget *now);
- void findSupportDestroyed();
+ void clearFindSupport();
+ void aggregationChanged();
+ void candidateAggregationChanged();
private:
void removeFindSupportConnections();