forked from qt-creator/qt-creator
Fix filtering and sorting of Qt versions in examples browser
Use the list of filtered Qt versions instead of the global complete list
at several places.
Broke with f1bc4ade50
Task-number: QTCREATORBUG-18216
Change-Id: I274197c833d5786b279a030c3f804286382a9c2c
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -111,7 +111,7 @@ ExampleSetModel::ExampleSetModel()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExampleSetModel::recreateModel()
|
void ExampleSetModel::recreateModel(const QList<BaseQtVersion *> &qtVersions)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
clear();
|
clear();
|
||||||
@@ -129,7 +129,7 @@ void ExampleSetModel::recreateModel()
|
|||||||
extraManifestDirs.insert(set.manifestPath);
|
extraManifestDirs.insert(set.manifestPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (BaseQtVersion *version, QtVersionManager::versions()) {
|
foreach (BaseQtVersion *version, qtVersions) {
|
||||||
// sanitize away qt versions that have already been added through extra sets
|
// sanitize away qt versions that have already been added through extra sets
|
||||||
if (extraManifestDirs.contains(version->documentationPath())) {
|
if (extraManifestDirs.contains(version->documentationPath())) {
|
||||||
if (debugExamples()) {
|
if (debugExamples()) {
|
||||||
@@ -484,7 +484,7 @@ void ExampleSetModel::updateQtVersionList()
|
|||||||
if (defaultVersion && versions.contains(defaultVersion))
|
if (defaultVersion && versions.contains(defaultVersion))
|
||||||
versions.move(versions.indexOf(defaultVersion), 0);
|
versions.move(versions.indexOf(defaultVersion), 0);
|
||||||
|
|
||||||
recreateModel();
|
recreateModel(versions);
|
||||||
|
|
||||||
int currentIndex = m_selectedExampleSetIndex;
|
int currentIndex = m_selectedExampleSetIndex;
|
||||||
if (currentIndex < 0) // reset from settings
|
if (currentIndex < 0) // reset from settings
|
||||||
@@ -494,7 +494,7 @@ void ExampleSetModel::updateQtVersionList()
|
|||||||
|
|
||||||
if (currentType == ExampleSetModel::InvalidExampleSet) {
|
if (currentType == ExampleSetModel::InvalidExampleSet) {
|
||||||
// select examples corresponding to 'highest' Qt version
|
// select examples corresponding to 'highest' Qt version
|
||||||
BaseQtVersion *highestQt = findHighestQtVersion();
|
BaseQtVersion *highestQt = findHighestQtVersion(versions);
|
||||||
currentIndex = indexForQtVersion(highestQt);
|
currentIndex = indexForQtVersion(highestQt);
|
||||||
} else if (currentType == ExampleSetModel::QtExampleSet) {
|
} else if (currentType == ExampleSetModel::QtExampleSet) {
|
||||||
// try to select the previously selected Qt version, or
|
// try to select the previously selected Qt version, or
|
||||||
@@ -502,17 +502,16 @@ void ExampleSetModel::updateQtVersionList()
|
|||||||
int currentQtId = getQtId(currentIndex);
|
int currentQtId = getQtId(currentIndex);
|
||||||
BaseQtVersion *newQtVersion = QtVersionManager::version(currentQtId);
|
BaseQtVersion *newQtVersion = QtVersionManager::version(currentQtId);
|
||||||
if (!newQtVersion)
|
if (!newQtVersion)
|
||||||
newQtVersion = findHighestQtVersion();
|
newQtVersion = findHighestQtVersion(versions);
|
||||||
currentIndex = indexForQtVersion(newQtVersion);
|
currentIndex = indexForQtVersion(newQtVersion);
|
||||||
} // nothing to do for extra example sets
|
} // nothing to do for extra example sets
|
||||||
selectExampleSet(currentIndex);
|
selectExampleSet(currentIndex);
|
||||||
emit selectedExampleSetChanged(currentIndex);
|
emit selectedExampleSetChanged(currentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseQtVersion *ExampleSetModel::findHighestQtVersion() const
|
BaseQtVersion *ExampleSetModel::findHighestQtVersion(const QList<BaseQtVersion *> &versions) const
|
||||||
{
|
{
|
||||||
BaseQtVersion *newVersion = nullptr;
|
BaseQtVersion *newVersion = nullptr;
|
||||||
const QList<BaseQtVersion *> versions = QtVersionManager::versions();
|
|
||||||
for (BaseQtVersion *version : versions) {
|
for (BaseQtVersion *version : versions) {
|
||||||
if (!newVersion) {
|
if (!newVersion) {
|
||||||
newVersion = version;
|
newVersion = version;
|
||||||
|
@@ -74,10 +74,10 @@ private:
|
|||||||
int getQtId(int index) const;
|
int getQtId(int index) const;
|
||||||
int getExtraExampleSetIndex(int index) const;
|
int getExtraExampleSetIndex(int index) const;
|
||||||
|
|
||||||
BaseQtVersion *findHighestQtVersion() const;
|
BaseQtVersion *findHighestQtVersion(const QList<BaseQtVersion *> &versions) const;
|
||||||
|
|
||||||
int indexForQtVersion(BaseQtVersion *qtVersion) const;
|
int indexForQtVersion(BaseQtVersion *qtVersion) const;
|
||||||
void recreateModel();
|
void recreateModel(const QList<BaseQtVersion *> &qtVersions);
|
||||||
void updateQtVersionList();
|
void updateQtVersionList();
|
||||||
|
|
||||||
void qtVersionManagerLoaded();
|
void qtVersionManagerLoaded();
|
||||||
|
Reference in New Issue
Block a user