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:
Daniel Molkentin
2011-07-01 18:28:56 +02:00
committed by Robert Löhning
parent 5de373a974
commit a5624a47a1
3 changed files with 34 additions and 5 deletions

View File

@@ -39,6 +39,7 @@
#include <QDebug> #include <QDebug>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/helpmanager.h>
#include <qtsupport/qtversionmanager.h> #include <qtsupport/qtversionmanager.h>
#include <algorithm> #include <algorithm>
@@ -67,7 +68,9 @@ ExamplesListModel::ExamplesListModel(QObject *parent) :
setRoleNames(roleNames); setRoleNames(roleNames);
connect(QtVersionManager::instance(), SIGNAL(updateExamples(QString,QString,QString)), 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) 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) : ExamplesListModelFilter::ExamplesListModelFilter(QObject *parent) :
QSortFilterProxyModel(parent), m_showTutorialsOnly(true) QSortFilterProxyModel(parent), m_showTutorialsOnly(true)
{ {

View File

@@ -60,6 +60,15 @@ struct ExampleItem {
bool hasSourceCode; 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 { class ExamplesListModel : public QAbstractListModel {
Q_OBJECT Q_OBJECT
public: public:
@@ -71,12 +80,15 @@ public:
QStringList tags() const { return m_tags; } QStringList tags() const { return m_tags; }
public slots:
void readNewsItems(const QString &examplesPath, const QString &demosPath, const QString &sourcePath);
signals: signals:
void tagsUpdated(); 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: private:
QList<ExampleItem> parseExamples(QXmlStreamReader* reader, const QString& projectsOffset); QList<ExampleItem> parseExamples(QXmlStreamReader* reader, const QString& projectsOffset);
QList<ExampleItem> parseDemos(QXmlStreamReader* reader, const QString& projectsOffset); QList<ExampleItem> parseDemos(QXmlStreamReader* reader, const QString& projectsOffset);
@@ -85,6 +97,8 @@ private:
QStringList exampleSources() const; QStringList exampleSources() const;
QList<ExampleItem> exampleItems; QList<ExampleItem> exampleItems;
QStringList m_tags; QStringList m_tags;
QMakePathCache m_cache;
}; };
class ExamplesListModelFilter : public QSortFilterProxyModel { class ExamplesListModelFilter : public QSortFilterProxyModel {

View File

@@ -68,8 +68,6 @@ signals:
public slots: public slots:
void openSplitHelp(const QUrl &help); void openSplitHelp(const QUrl &help);
void openProject(const QString& projectFile, const QStringList& additionalFilesToOpen, const QUrl& help); void openProject(const QString& projectFile, const QStringList& additionalFilesToOpen, const QUrl& help);
public slots:
void updateTagsModel(); void updateTagsModel();
private: private: