forked from qt-creator/qt-creator
Add a changed signal in Aggregation
Use it to change the find and candidate find object in CurrentDocumentFind:
this will allow to replace the IFindSupport object used.
Merge-request: 115
Reviewed-by: con <qtc-committer@nokia.com>
(cherry picked from commit d3b58c2db3)
This commit is contained in:
committed by
con
parent
565158bbb4
commit
3b94093f0e
@@ -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();
|
||||
}
|
||||
|
||||
@@ -74,6 +74,9 @@ public:
|
||||
static Aggregate *parentAggregate(QObject *obj);
|
||||
static QReadWriteLock &lock();
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
|
||||
private slots:
|
||||
void deleteSelf(QObject *obj);
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,9 @@ signals:
|
||||
|
||||
private slots:
|
||||
void updateCandidateFindFilter(QWidget *old, QWidget *now);
|
||||
void findSupportDestroyed();
|
||||
void clearFindSupport();
|
||||
void aggregationChanged();
|
||||
void candidateAggregationChanged();
|
||||
|
||||
private:
|
||||
void removeFindSupportConnections();
|
||||
|
||||
Reference in New Issue
Block a user