Commit 49b55569 authored by Daniel Molkentin's avatar Daniel Molkentin Committed by Eike Ziller

Refactor: Move NAM to utils, rss model to welcome.

Change-Id: I0dddedd820e75df05c3a028e7fbb02b642c79659
Reviewed-on: http://codereview.qt.nokia.com/1902Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent d20594a7
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
namespace Utils {
namespace Internal {
#define STRINGIFY(x) #x
#define APP_VERSION $${QTCREATOR_VERSION}
#define APP_VERSION_STR STRINGIFY(APP_VERSION_STR)
} // Internal
} // Utils
......@@ -39,17 +39,17 @@
#include <sys/utsname.h>
#endif
#include "coreconstants.h"
#include "app_version.h"
/*!
\class Core::NetworkManager
\class Utils::NetworkManager
\brief Network Access Manager for use with Qt Creator.
Common initialization, Qt Creator User Agent
*/
namespace Core {
namespace Utils {
static const QString getOsString()
{
......@@ -133,7 +133,7 @@ void NetworkAccessManager::getUrl(const QUrl &url)
QNetworkReply* NetworkAccessManager::createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
{
QString agentStr = QString::fromLatin1("Qt-Creator/%1 (QNetworkAccessManager %2; %3; %4; %5 bit)")
.arg(Core::Constants::IDE_VERSION_LONG).arg(qVersion())
.arg(APP_VERSION_STR).arg(qVersion())
.arg(getOsString()).arg(QLocale::system().name())
.arg(QSysInfo::WordSize);
QNetworkRequest req(request);
......
......@@ -30,14 +30,14 @@
**
**************************************************************************/
#include "core_global.h"
#include "utils_global.h"
#include <QtCore/QUrl>
#include <QtNetwork/QNetworkAccessManager>
namespace Core {
namespace Utils {
class CORE_EXPORT NetworkAccessManager : public QNetworkAccessManager
class QTCREATOR_UTILS_EXPORT NetworkAccessManager : public QNetworkAccessManager
{
Q_OBJECT
public:
......
......@@ -87,7 +87,8 @@ SOURCES += $$PWD/environment.cpp \
$$PWD/ssh/sshremoteprocessrunner.cpp \
$$PWD/ssh/sshconnectionmanager.cpp \
$$PWD/outputformatter.cpp \
$$PWD/flowlayout.cpp
$$PWD/flowlayout.cpp \
$$PWD/networkaccessmanager.cpp
win32 {
SOURCES += \
......@@ -101,7 +102,9 @@ unix:!macx {
HEADERS += $$PWD/unixutils.h
SOURCES += $$PWD/unixutils.cpp
}
HEADERS += $$PWD/environment.h \
HEADERS += \
$$PWD/app_version.h \
$$PWD/environment.h \
$$PWD/environmentmodel.h \
$$PWD/qtcprocess.h \
$$PWD/utils_global.h \
......@@ -187,11 +190,18 @@ HEADERS += $$PWD/environment.h \
$$PWD/statuslabel.h \
$$PWD/outputformatter.h \
$$PWD/outputformat.h \
$$PWD/flowlayout.h
$$PWD/flowlayout.h \
$$PWD/networkaccessmanager.h
FORMS += $$PWD/filewizardpage.ui \
$$PWD/projectintropage.ui \
$$PWD/newclasswidget.ui \
$$PWD/submiteditorwidget.ui \
$$PWD/checkablemessagebox.ui
RESOURCES += $$PWD/utils.qrc
OTHER_FILES += $$PWD/app_version.h.in
QMAKE_SUBSTITUTES += $$PWD/app_version.h.in
......@@ -90,9 +90,7 @@ SOURCES += mainwindow.cpp \
variablechooser.cpp \
mimetypemagicdialog.cpp \
mimetypesettings.cpp \
dialogs/promptoverwritedialog.cpp \
multifeedrssmodel.cpp \
networkaccessmanager.cpp
dialogs/promptoverwritedialog.cpp
HEADERS += mainwindow.h \
editmode.h \
......@@ -184,9 +182,7 @@ HEADERS += mainwindow.h \
variablechooser.h \
mimetypemagicdialog.h \
mimetypesettings.h \
dialogs/promptoverwritedialog.h \
multifeedrssmodel.h \
networkaccessmanager.h
dialogs/promptoverwritedialog.h
FORMS += dialogs/newdialog.ui \
actionmanager/commandmappings.ui \
......
......@@ -31,10 +31,11 @@
**************************************************************************/
#include "protocol.h"
#include <utils/networkaccessmanager.h>
#include <cpptools/cpptoolsconstants.h>
#include <qmljseditor/qmljseditorconstants.h>
#include <coreplugin/icore.h>
#include <coreplugin/networkaccessmanager.h>
#include <coreplugin/dialogs/ioptionspage.h>
#include <QtNetwork/QNetworkRequest>
......@@ -193,7 +194,7 @@ QNetworkReply *NetworkAccessManagerProxy::httpPost(const QString &link, const QB
QNetworkAccessManager *NetworkAccessManagerProxy::networkAccessManager()
{
if (m_networkAccessManager.isNull())
m_networkAccessManager.reset(new Core::NetworkAccessManager);
m_networkAccessManager.reset(new Utils::NetworkAccessManager);
return m_networkAccessManager.data();
}
......
......@@ -39,7 +39,7 @@
#include <QtNetwork/QNetworkReply>
#include <coreplugin/networkaccessmanager.h>
#include <utils/networkaccessmanager.h>
enum { debug = 0 };
......@@ -529,7 +529,7 @@ void Gitorious::slotReplyFinished()
QNetworkReply *Gitorious::createRequest(const QUrl &url, int protocol, int hostIndex, int page)
{
if (!m_networkManager)
m_networkManager = new Core::NetworkAccessManager(this);
m_networkManager = new Utils::NetworkAccessManager(this);
QNetworkReply *reply = m_networkManager->get(QNetworkRequest(url));
connect(reply, SIGNAL(finished()), this, SLOT(slotReplyFinished()));
reply->setProperty(protocolPropertyC, QVariant(protocol));
......
......@@ -52,7 +52,7 @@
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkRequest>
#include <coreplugin/networkaccessmanager.h>
#include <utils/networkaccessmanager.h>
using namespace Find;
using namespace Help;
......@@ -107,7 +107,7 @@ qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen)
// -- HelpNetworkAccessManager
class HelpNetworkAccessManager : public Core::NetworkAccessManager
class HelpNetworkAccessManager : public Utils::NetworkAccessManager
{
public:
HelpNetworkAccessManager(QObject *parent);
......@@ -118,7 +118,7 @@ protected:
};
HelpNetworkAccessManager::HelpNetworkAccessManager(QObject *parent)
: Core::NetworkAccessManager(parent)
: Utils::NetworkAccessManager(parent)
{
}
......@@ -126,7 +126,7 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation op,
const QNetworkRequest &request, QIODevice* outgoingData)
{
if (!HelpViewer::isLocalUrl(request.url()))
return Core::NetworkAccessManager::createRequest(op, request, outgoingData);
return Utils::NetworkAccessManager::createRequest(op, request, outgoingData);
QString url = request.url().toString();
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
......
......@@ -37,8 +37,6 @@
#include <QtDeclarative/QDeclarativeEngine>
#include <QtDeclarative/QDeclarativeContext>
#include <coreplugin/multifeedrssmodel.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectexplorer.h>
......@@ -138,8 +136,6 @@ ProjectWelcomePage::ProjectWelcomePage() :
void ProjectWelcomePage::facilitateQml(QDeclarativeEngine *engine)
{
static const char feedGroupName[] = "Feeds";
ProjectExplorerPlugin *pePlugin = ProjectExplorer::ProjectExplorerPlugin::instance();
m_sessionModel = new SessionModel(pePlugin->session(), this);
m_projectModel = new ProjectModel(pePlugin, this);
......@@ -147,22 +143,6 @@ void ProjectWelcomePage::facilitateQml(QDeclarativeEngine *engine)
QDeclarativeContext *ctx = engine->rootContext();
ctx->setContextProperty("sessionList", m_sessionModel);
ctx->setContextProperty("projectList", m_projectModel);
Core::MultiFeedRssModel *rssModel = new Core::MultiFeedRssModel(this);
QSettings *settings = Core::ICore::instance()->settings();
if (settings->childGroups().contains(feedGroupName)) {
int size = settings->beginReadArray(feedGroupName);
for (int i = 0; i < size; ++i)
{
settings->setArrayIndex(i);
rssModel->addFeed(settings->value("url").toString());
}
settings->endArray();
} else {
rssModel->addFeed(QLatin1String("http://labs.trolltech.com/blogs/feed"));
rssModel->addFeed(QLatin1String("http://feeds.feedburner.com/TheQtBlog?format=xml"));
}
ctx->setContextProperty("aggregatedFeedsModel", rssModel);
ctx->setContextProperty("projectWelcomePage", this);
}
......
......@@ -41,7 +41,7 @@
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include <coreplugin/networkaccessmanager.h>
#include <utils/networkaccessmanager.h>
using namespace TextEditor;
using namespace Internal;
......@@ -52,7 +52,7 @@ DefinitionDownloader::DefinitionDownloader(const QUrl &url, const QString &local
void DefinitionDownloader::run()
{
Core::NetworkAccessManager manager;
Utils::NetworkAccessManager manager;
int currentAttempt = 0;
const int maxAttempts = 5;
......
......@@ -45,7 +45,7 @@
#include <QtCore/QSharedPointer>
#include <QtCore/QFutureWatcher>
#include <coreplugin/networkaccessmanager.h>
#include <utils/networkaccessmanager.h>
QT_BEGIN_NAMESPACE
class QFileInfo;
......@@ -115,7 +115,7 @@ private:
QSet<QString> m_isBuilding;
QList<DefinitionDownloader *> m_downloaders;
Core::NetworkAccessManager m_networkManager;
Utils::NetworkAccessManager m_networkManager;
QFutureWatcher<void> m_downloadWatcher;
QFutureWatcher<Core::MimeType> m_mimeTypeWatcher;
......
......@@ -39,11 +39,11 @@
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include "networkaccessmanager.h"
#include <utils/networkaccessmanager.h>
#include <QDebug>
namespace Core {
namespace Welcome {
namespace Internal {
......@@ -133,7 +133,7 @@ private:
MultiFeedRssModel::MultiFeedRssModel(QObject *parent) :
QAbstractListModel(parent),
m_networkAccessManager(new NetworkAccessManager),
m_networkAccessManager(new Utils::NetworkAccessManager),
m_articleCount(0)
{
//m_namThread = new QThread;
......
......@@ -33,7 +33,7 @@
#ifndef MULTIFEEDRSSMODEL_H
#define MULTIFEEDRSSMODEL_H
#include "core_global.h"
#include "welcome_global.h"
#include <QtCore/QAbstractListModel>
#include <QtCore/QStringList>
......@@ -42,9 +42,10 @@
QT_BEGIN_NAMESPACE
class QThread;
class QNetworkReply;
class QNetworkAccessManager;
QT_END_NAMESPACE
namespace Core {
namespace Welcome {
namespace Internal {
......@@ -67,7 +68,7 @@ class NetworkAccessManager;
enum RssRoles { TitleRole = Qt::UserRole+1, DescriptionRole, LinkRole,
PubDateRole, BlogNameRole, BlogIconRole };
class CORE_EXPORT MultiFeedRssModel : public QAbstractListModel {
class WELCOME_EXPORT MultiFeedRssModel : public QAbstractListModel {
Q_OBJECT
Q_PROPERTY(int articleCount READ articleCount WRITE setArticleCount NOTIFY articleCountChanged)
public:
......@@ -99,7 +100,7 @@ private slots:
private:
QStringList m_sites;
Internal::RssItemList m_aggregatedFeed;
NetworkAccessManager *m_networkAccessManager;
QNetworkAccessManager *m_networkAccessManager;
QThread *m_namThread;
int m_articleCount;
};
......
......@@ -6,9 +6,11 @@ include(../../qtcreatorplugin.pri)
include(welcome_dependencies.pri)
HEADERS += welcomeplugin.h \
welcome_global.h
welcome_global.h \
multifeedrssmodel.h
SOURCES += welcomeplugin.cpp
SOURCES += welcomeplugin.cpp \
multifeedrssmodel.cpp
RESOURCES += welcome.qrc
......
......@@ -31,6 +31,7 @@
**************************************************************************/
#include "welcomeplugin.h"
#include "multifeedrssmodel.h"
#include <extensionsystem/pluginmanager.h>
......@@ -39,13 +40,13 @@
#include <coreplugin/imode.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/networkaccessmanager.h>
#include <coreplugin/dialogs/iwizard.h>
#include <projectexplorer/projectexplorer.h>
#include <utils/styledbar.h>
#include <utils/iwelcomepage.h>
#include <utils/networkaccessmanager.h>
#include <QtGui/QScrollArea>
#include <QtGui/QDesktopServices>
......@@ -75,7 +76,7 @@ class NetworkAccessManagerFactory : public QDeclarativeNetworkAccessManagerFacto
{
public:
NetworkAccessManagerFactory(): QDeclarativeNetworkAccessManagerFactory() {}
QNetworkAccessManager* create(QObject *parent) { return new Core::NetworkAccessManager(parent); }
QNetworkAccessManager* create(QObject *parent) { return new Utils::NetworkAccessManager(parent); }
};
......@@ -119,6 +120,8 @@ private slots:
void modeChanged(Core::IMode*);
private:
void facilitateQml(QDeclarativeEngine *engine);
QWidget *m_modeWidget;
QDeclarativeView *m_welcomePage;
QHBoxLayout * buttonLayout;
......@@ -170,6 +173,28 @@ bool sortFunction(Utils::IWelcomePage * a, Utils::IWelcomePage *b)
return a->priority() < b->priority();
}
void WelcomeMode::facilitateQml(QDeclarativeEngine *engine)
{
static const char feedGroupName[] = "Feeds";
MultiFeedRssModel *rssModel = new MultiFeedRssModel(this);
QSettings *settings = Core::ICore::instance()->settings();
if (settings->childGroups().contains(feedGroupName)) {
int size = settings->beginReadArray(feedGroupName);
for (int i = 0; i < size; ++i)
{
settings->setArrayIndex(i);
rssModel->addFeed(settings->value("url").toString());
}
settings->endArray();
} else {
rssModel->addFeed(QLatin1String("http://labs.trolltech.com/blogs/feed"));
rssModel->addFeed(QLatin1String("http://feeds.feedburner.com/TheQtBlog?format=xml"));
}
engine->rootContext()->setContextProperty("aggregatedFeedsModel", rssModel);
}
void WelcomeMode::initPlugins()
{
QSettings *settings = Core::ICore::instance()->settings();
......@@ -186,6 +211,7 @@ void WelcomeMode::initPlugins()
engine->setOutputWarningsToStandardError(false);
engine->setNetworkAccessManagerFactory(new NetworkAccessManagerFactory);
engine->addImportPath(Core::ICore::instance()->resourcePath() + "/welcomescreen");
facilitateQml(engine);
foreach (Utils::IWelcomePage *plugin, plugins) {
plugin->facilitateQml(engine);
m_pluginList.append(plugin);
......
......@@ -35,6 +35,10 @@
#include <extensionsystem/iplugin.h>
QT_BEGIN_HEADER
class QDeclarativeEngine;
QT_END_HEADER
namespace Welcome {
namespace Internal {
......
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