forked from qt-creator/qt-creator
WelcomeScreen Delay loading of ExamplesModel.
...until the Help system is is initialized properly. Change-Id: I70b629d246f418629623f09de0d270bf355b71de Reviewed-on: http://codereview.qt.nokia.com/1021 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Robert Löhning <robert.loehning@nokia.com>
This commit is contained in:
committed by
Robert Löhning
parent
5de373a974
commit
a5624a47a1
@@ -39,6 +39,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/helpmanager.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -67,7 +68,9 @@ ExamplesListModel::ExamplesListModel(QObject *parent) :
|
||||
setRoleNames(roleNames);
|
||||
|
||||
connect(QtVersionManager::instance(), SIGNAL(updateExamples(QString,QString,QString)),
|
||||
SLOT(readNewsItems(QString,QString,QString)));
|
||||
SLOT(cacheExamplesPath(QString,QString,QString)));
|
||||
connect(Core::HelpManager::instance(), SIGNAL(setupFinished()),
|
||||
SLOT(helpInitialized()));
|
||||
}
|
||||
|
||||
QList<ExampleItem> ExamplesListModel::parseExamples(QXmlStreamReader* reader, const QString& projectsOffset)
|
||||
@@ -337,6 +340,20 @@ QVariant ExamplesListModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
}
|
||||
|
||||
void ExamplesListModel::cacheExamplesPath(const QString &examplesPath, const QString &demosPath, const QString &sourcePath)
|
||||
{
|
||||
m_cache = QMakePathCache(examplesPath, demosPath, sourcePath);
|
||||
}
|
||||
|
||||
void ExamplesListModel::helpInitialized()
|
||||
{
|
||||
disconnect(this, SLOT(cacheExamplesPath(QString, QString, QString)));
|
||||
connect(QtVersionManager::instance(), SIGNAL(updateExamples(QString,QString,QString)),
|
||||
SLOT(readNewsItems(QString,QString,QString)));
|
||||
readNewsItems(m_cache.examplesPath, m_cache.demosPath, m_cache.examplesPath);
|
||||
}
|
||||
|
||||
|
||||
ExamplesListModelFilter::ExamplesListModelFilter(QObject *parent) :
|
||||
QSortFilterProxyModel(parent), m_showTutorialsOnly(true)
|
||||
{
|
||||
|
@@ -60,6 +60,15 @@ struct ExampleItem {
|
||||
bool hasSourceCode;
|
||||
};
|
||||
|
||||
struct QMakePathCache {
|
||||
QString examplesPath;
|
||||
QString demosPath;
|
||||
QString sourcePath;
|
||||
QMakePathCache() {}
|
||||
QMakePathCache(const QString &_examplesPath, const QString &_demosPath, const QString &_sourcePath)
|
||||
: examplesPath(_examplesPath), demosPath(_demosPath), sourcePath(_sourcePath) {}
|
||||
};
|
||||
|
||||
class ExamplesListModel : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -71,12 +80,15 @@ public:
|
||||
|
||||
QStringList tags() const { return m_tags; }
|
||||
|
||||
public slots:
|
||||
void readNewsItems(const QString &examplesPath, const QString &demosPath, const QString &sourcePath);
|
||||
|
||||
signals:
|
||||
void tagsUpdated();
|
||||
|
||||
public slots:
|
||||
void readNewsItems(const QString &examplesPath, const QString &demosPath, const QString &sourcePath);
|
||||
void cacheExamplesPath(const QString &examplesPath, const QString &demosPath, const QString &sourcePath);
|
||||
void helpInitialized();
|
||||
|
||||
private:
|
||||
QList<ExampleItem> parseExamples(QXmlStreamReader* reader, const QString& projectsOffset);
|
||||
QList<ExampleItem> parseDemos(QXmlStreamReader* reader, const QString& projectsOffset);
|
||||
@@ -85,6 +97,8 @@ private:
|
||||
QStringList exampleSources() const;
|
||||
QList<ExampleItem> exampleItems;
|
||||
QStringList m_tags;
|
||||
QMakePathCache m_cache;
|
||||
|
||||
};
|
||||
|
||||
class ExamplesListModelFilter : public QSortFilterProxyModel {
|
||||
|
@@ -68,8 +68,6 @@ signals:
|
||||
public slots:
|
||||
void openSplitHelp(const QUrl &help);
|
||||
void openProject(const QString& projectFile, const QStringList& additionalFilesToOpen, const QUrl& help);
|
||||
|
||||
public slots:
|
||||
void updateTagsModel();
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user