Commit 713762e1 authored by Daniel Teske's avatar Daniel Teske
Browse files

QtVersionManager::qtVersionsChanged() split list into add/remove/change



Makes it easier to do the right thing.

Change-Id: Id6c6754033b3310c6b8c68a4aacc22cbaef268ee
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 08f9d72c
......@@ -108,8 +108,8 @@ MaemoQemuManager::MaemoQemuManager(QObject *parent)
m_qemuAction->setVisible(false);
// listen to qt version changes to update the start button
connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>)),
this, SLOT(qtVersionsChanged(QList<int>)));
connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
this, SLOT(qtVersionsChanged(QList<int>,QList<int>,QList<int>)));
// listen to project add, remove and startup changes to udate start button
SessionManager *session = ProjectExplorerPlugin::instance()->session();
......@@ -178,8 +178,10 @@ bool MaemoQemuManager::qemuIsRunning() const
return m_runningQtId != INT_MIN;
}
void MaemoQemuManager::qtVersionsChanged(const QList<int> &uniqueIds)
void MaemoQemuManager::qtVersionsChanged(const QList<int> &added, const QList<int> &removed, const QList<int> &changed)
{
QList<int> uniqueIds;
uniqueIds << added << removed << changed;
QtSupport::QtVersionManager *manager = QtSupport::QtVersionManager::instance();
foreach (int uniqueId, uniqueIds) {
if (manager->isValidId(uniqueId)) {
......@@ -539,7 +541,7 @@ void MaemoQemuManager::toggleStarterButton(Target *target)
}
if (uniqueId >= 0 && (m_runtimes.isEmpty() || !m_runtimes.contains(uniqueId)))
qtVersionsChanged(QList<int>() << uniqueId);
qtVersionsChanged(QList<int>(), QList<int>(), QList<int>() << uniqueId);
bool isRunning = m_qemuProcess->state() != QProcess::NotRunning;
if (m_runningQtId == uniqueId)
......@@ -596,7 +598,7 @@ bool MaemoQemuManager::targetUsesMatchingRuntimeConfig(Target *target,
void MaemoQemuManager::notify(const QList<int> uniqueIds)
{
qtVersionsChanged(uniqueIds);
qtVersionsChanged(QList<int>(), QList<int>(), uniqueIds);
environmentChanged(); // to toggle the start button
}
......
......@@ -82,7 +82,7 @@ signals:
void qemuProcessStatus(QemuStatus, const QString &error = QString());
private slots:
void qtVersionsChanged(const QList<int> &uniqueIds);
void qtVersionsChanged(const QList<int> &addedIds, const QList<int> &removedIds, const QList<int> &changed);
void projectAdded(ProjectExplorer::Project *project);
void projectRemoved(ProjectExplorer::Project *project);
......
......@@ -241,8 +241,8 @@ QString MaemoToolChainFactory::id() const
QList<ProjectExplorer::ToolChain *> MaemoToolChainFactory::autoDetect()
{
QtSupport::QtVersionManager *vm = QtSupport::QtVersionManager::instance();
connect(vm, SIGNAL(qtVersionsChanged(QList<int>)),
this, SLOT(handleQtVersionChanges(QList<int>)));
connect(vm, SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
this, SLOT(handleQtVersionChanges(QList<int>,QList<int>,QList<int>)));
QList<int> versionList;
foreach (QtSupport::BaseQtVersion *v, vm->versions())
......@@ -266,8 +266,10 @@ ProjectExplorer::ToolChain *MaemoToolChainFactory::restore(const QVariantMap &da
return 0;
}
void MaemoToolChainFactory::handleQtVersionChanges(const QList<int> &changes)
void MaemoToolChainFactory::handleQtVersionChanges(const QList<int> &added, const QList<int> &removed, const QList<int> &changed)
{
QList<int> changes;
changes << added << removed << changed;
ProjectExplorer::ToolChainManager *tcm = ProjectExplorer::ToolChainManager::instance();
QList<ProjectExplorer::ToolChain *> tcList = createToolChainList(changes);
foreach (ProjectExplorer::ToolChain *tc, tcList)
......
......@@ -117,8 +117,8 @@ public:
ProjectExplorer::ToolChain *restore(const QVariantMap &data);
private slots:
void handleQtVersionChanges(const QList<int> &);
QList<ProjectExplorer::ToolChain *> createToolChainList(const QList<int> &);
void handleQtVersionChanges(const QList<int> &added, const QList<int> &removed, const QList<int> &changed);
QList<ProjectExplorer::ToolChain *> createToolChainList(const QList<int> &changes);
};
} // namespace Internal
......
......@@ -58,7 +58,7 @@ namespace Internal {
Qt4MaemoTargetFactory::Qt4MaemoTargetFactory(QObject *parent) :
Qt4BaseTargetFactory(parent)
{
connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>)),
connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
this, SIGNAL(canCreateTargetIdsChanged()));
}
......
......@@ -108,7 +108,7 @@ void QmlProjectRunConfiguration::ctor()
this, SLOT(changeCurrentFile(Core::IEditor*)));
QtVersionManager *qtVersions = QtVersionManager::instance();
connect(qtVersions, SIGNAL(qtVersionsChanged(QList<int>)), this, SLOT(updateQtVersions()));
connect(qtVersions, SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)), this, SLOT(updateQtVersions()));
setDisplayName(tr("QML Viewer", "QMLRunConfiguration display name."));
}
......
......@@ -114,7 +114,7 @@ QmlProjectRunConfigurationWidget::QmlProjectRunConfigurationWidget(QmlProjectRun
//
QtVersionManager *qtVersions = QtVersionManager::instance();
connect(qtVersions, SIGNAL(qtVersionsChanged(QList<int>)),
connect(qtVersions, SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
this, SLOT(updateQtVersionComboBox()));
//
......
......@@ -56,7 +56,7 @@ using ProjectExplorer::idFromMap;
Qt4DesktopTargetFactory::Qt4DesktopTargetFactory(QObject *parent) :
Qt4BaseTargetFactory(parent)
{
connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>)),
connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
this, SIGNAL(canCreateTargetIdsChanged()));
}
......
......@@ -56,7 +56,7 @@ using ProjectExplorer::idFromMap;
Qt4SimulatorTargetFactory::Qt4SimulatorTargetFactory(QObject *parent) :
Qt4BaseTargetFactory(parent)
{
connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>)),
connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
this, SIGNAL(canCreateTargetIdsChanged()));
}
......
......@@ -60,7 +60,7 @@ using namespace Qt4ProjectManager::Internal;
Qt4SymbianTargetFactory::Qt4SymbianTargetFactory(QObject *parent) :
Qt4BaseTargetFactory(parent)
{
connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>)),
connect(QtSupport::QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
this, SIGNAL(canCreateTargetIdsChanged()));
}
......
......@@ -185,8 +185,8 @@ void Qt4BuildConfiguration::ctor()
this, SLOT(proFileUpdated(Qt4ProjectManager::Qt4ProFileNode*,bool,bool)));
QtSupport::QtVersionManager *vm = QtSupport::QtVersionManager::instance();
connect(vm, SIGNAL(qtVersionsChanged(QList<int>)),
this, SLOT(qtVersionsChanged(QList<int>)));
connect(vm, SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
this, SLOT(qtVersionsChanged(QList<int>,QList<int>,QList<int>)));
}
void Qt4BuildConfiguration::emitBuildDirectoryChanged()
......@@ -458,11 +458,11 @@ MakeStep *Qt4BuildConfiguration::makeStep() const
return 0;
}
void Qt4BuildConfiguration::qtVersionsChanged(const QList<int> &changedVersions)
void Qt4BuildConfiguration::qtVersionsChanged(const QList<int> &addedVersions, const QList<int> &removedVersions, const QList<int> &changedVersions)
{
if (!changedVersions.contains(m_qtVersionId))
return;
emit environmentChanged(); // Our qt version changed, that might have changed the environment
Q_UNUSED(addedVersions);
if (removedVersions.contains(m_qtVersionId) || changedVersions.contains(m_qtVersionId))
emit environmentChanged(); // Our qt version changed, that might have changed the environment
}
// returns true if both are equal
......@@ -663,7 +663,7 @@ Qt4BuildConfigurationFactory::Qt4BuildConfigurationFactory(QObject *parent) :
update();
QtSupport::QtVersionManager *vm = QtSupport::QtVersionManager::instance();
connect(vm, SIGNAL(qtVersionsChanged(QList<int>)),
connect(vm, SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
this, SLOT(update()));
}
......
......@@ -144,7 +144,7 @@ signals:
void buildDirectoryInitialized();
private slots:
void qtVersionsChanged(const QList<int> &changedVersions);
void qtVersionsChanged(const QList<int> &addedVersions, const QList<int> &removedVersions, const QList<int> &changedVersions);
void emitBuildDirectoryChanged();
void proFileUpdated(Qt4ProjectManager::Qt4ProFileNode *, bool, bool parseInProgress);
......
......@@ -225,7 +225,7 @@ void Qt4ProjectConfigWidget::init(ProjectExplorer::BuildConfiguration *bc)
qtVersionsChanged();
QtSupport::QtVersionManager *vm = QtSupport::QtVersionManager::instance();
connect(vm, SIGNAL(qtVersionsChanged(QList<int>)),
connect(vm, SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
this, SLOT(qtVersionsChanged()));
bool shadowBuild = m_buildConfiguration->shadowBuild();
......
......@@ -77,7 +77,7 @@ ExamplesListModel::ExamplesListModel(QObject *parent) :
connect(Core::HelpManager::instance(), SIGNAL(setupFinished()),
SLOT(helpInitialized()));
connect(QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>)),
connect(QtVersionManager::instance(), SIGNAL(qtVersionsChanged(QList<int>,QList<int>,QList<int>)),
this, SLOT(handleQtVersionsChanged()));
}
......
......@@ -449,7 +449,7 @@ void QtVersionManager::addVersion(BaseQtVersion *version)
int uniqueId = version->uniqueId();
m_versions.insert(uniqueId, version);
emit qtVersionsChanged(QList<int>() << uniqueId);
emit qtVersionsChanged(QList<int>() << uniqueId, QList<int>(), QList<int>());
saveQtVersions();
}
......@@ -457,7 +457,7 @@ void QtVersionManager::removeVersion(BaseQtVersion *version)
{
QTC_ASSERT(version != 0, return);
m_versions.remove(version->uniqueId());
emit qtVersionsChanged(QList<int>() << version->uniqueId());
emit qtVersionsChanged(QList<int>(), QList<int>() << version->uniqueId(), QList<int>());
saveQtVersions();
delete version;
}
......@@ -623,6 +623,8 @@ void QtVersionManager::setNewQtVersions(QList<BaseQtVersion *> newVersions)
SortByUniqueId sortByUniqueId;
qSort(sortedNewVersions.begin(), sortedNewVersions.end(), sortByUniqueId);
QList<int> addedVersions;
QList<int> removedVersions;
QList<int> changedVersions;
// So we trying to find the minimal set of changed versions,
// iterate over both sorted list
......@@ -639,10 +641,10 @@ void QtVersionManager::setNewQtVersions(QList<BaseQtVersion *> newVersions)
int nid = (*nit)->uniqueId();
int oid = (*oit)->uniqueId();
if (nid < oid) {
changedVersions.push_back(nid);
addedVersions.push_back(nid);
++nit;
} else if (oid < nid) {
changedVersions.push_back(oid);
removedVersions.push_back(oid);
++oit;
} else {
if (!equals(*oit, *nit))
......@@ -653,12 +655,12 @@ void QtVersionManager::setNewQtVersions(QList<BaseQtVersion *> newVersions)
}
while (nit != nend) {
changedVersions.push_back((*nit)->uniqueId());
addedVersions.push_back((*nit)->uniqueId());
++nit;
}
while (oit != oend) {
changedVersions.push_back((*oit)->uniqueId());
removedVersions.push_back((*oit)->uniqueId());
++oit;
}
......@@ -667,13 +669,13 @@ void QtVersionManager::setNewQtVersions(QList<BaseQtVersion *> newVersions)
foreach (BaseQtVersion *v, sortedNewVersions)
m_versions.insert(v->uniqueId(), v);
if (!changedVersions.isEmpty())
if (!changedVersions.isEmpty() || !addedVersions.isEmpty() || !removedVersions.isEmpty())
updateDocumentation();
saveQtVersions();
if (!changedVersions.isEmpty())
emit qtVersionsChanged(changedVersions);
if (!changedVersions.isEmpty() || !addedVersions.isEmpty() || !removedVersions.isEmpty())
emit qtVersionsChanged(addedVersions, removedVersions, changedVersions);
}
// Returns the version that was used to build the project in that directory
......
......@@ -108,7 +108,7 @@ public:
signals:
// content of BaseQtVersion objects with qmake path might have changed
void dumpUpdatedFor(const Utils::FileName &qmakeCommand);
void qtVersionsChanged(const QList<int> &uniqueIds);
void qtVersionsChanged(const QList<int> &addedIds, const QList<int> &removedIds, const QList<int> &changedIds);
public slots:
void updateDumpFor(const Utils::FileName &qmakeCommand);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment