Skip to content
This repository has been archived by the owner on Sep 23, 2019. It is now read-only.

Commit

Permalink
Some classes are using qnam singleton.
Browse files Browse the repository at this point in the history
  • Loading branch information
minimoog committed Apr 27, 2011
1 parent 351926f commit 5f22421
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 37 deletions.
5 changes: 2 additions & 3 deletions mainwindow.cpp
Expand Up @@ -20,7 +20,6 @@

#include "mainwindow.h"
#include <QtDebug>
#include <QNetworkAccessManager>
#include <QSettings>
#include <QMenu>
#include <QCloseEvent>
Expand All @@ -45,14 +44,14 @@
#include "usertimelinelistmodel.h"
#include "conversationlistmodel.h"
#include "userlogins.h"
#include "namsingleton.h"

MainWindow::MainWindow(QWidget *parent) :
QmlApplicationViewer(parent),
m_netManager(new QNetworkAccessManager(this)),
m_oauthTwitter(new OAuthTwitter(this)),
m_userStream(new QTweetUserStream(this))
{
m_oauthTwitter->setNetworkAccessManager(m_netManager);
m_oauthTwitter->setNetworkAccessManager(NAMSingleton::instance()->qnam());
m_userStream->setOAuthTwitter(m_oauthTwitter);

qApp->setOrganizationName("QTwitdget");
Expand Down
2 changes: 0 additions & 2 deletions mainwindow.h
Expand Up @@ -25,7 +25,6 @@
#include <QSystemTrayIcon>
#include "qmlapplicationviewer.h"

class QNetworkAccessManager;
class NetworkAccessManagerFactory;
class OAuthTwitter;
class QTweetUserStream;
Expand Down Expand Up @@ -79,7 +78,6 @@ private slots:
void readSettings();
void writeSettings();

QNetworkAccessManager *m_netManager;
OAuthTwitter *m_oauthTwitter;
QTweetUserStream *m_userStream;

Expand Down
23 changes: 2 additions & 21 deletions shortenedurl.cpp
Expand Up @@ -21,7 +21,7 @@
#include "shortenedurl.h"
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include "namsingleton.h"

/**
* Constructor
Expand All @@ -31,25 +31,6 @@ ShortenedUrl::ShortenedUrl(QObject *parent)
{
}

/**
* Constructor
* @param netManager network Access Manager
* @param parent parent
*/
ShortenedUrl::ShortenedUrl(QNetworkAccessManager *netManager, QObject *parent)
: QObject(parent)
{
m_netManager = netManager;
}

/**
* Sets network access manager
*/
void ShortenedUrl::setNetworkAccessManager(QNetworkAccessManager *netManager)
{
m_netManager = netManager;
}

/**
* Shortens url
* @param url url to shorten
Expand All @@ -65,7 +46,7 @@ void ShortenedUrl::shortUrl(const QString &url)

QNetworkRequest req(urlService);

QNetworkReply *reply = m_netManager->get(req);
QNetworkReply *reply = NAMSingleton::instance()->qnam()->get(req);
reply->setProperty("longurl", QVariant(url));
connect(reply, SIGNAL(finished()), this, SLOT(finished()));
}
Expand Down
6 changes: 0 additions & 6 deletions shortenedurl.h
Expand Up @@ -23,8 +23,6 @@

#include <QUrl>

class QNetworkAccessManager;

/**
* Class for shortening url
* @remarks Uses bit.ly services
Expand All @@ -34,8 +32,6 @@ class ShortenedUrl : public QObject
Q_OBJECT
public:
ShortenedUrl(QObject *parent = 0);
ShortenedUrl(QNetworkAccessManager *netManager, QObject *parent = 0);
void setNetworkAccessManager(QNetworkAccessManager *netManager);
void shortUrl(const QString& url);

signals:
Expand All @@ -48,8 +44,6 @@ class ShortenedUrl : public QObject
private slots:
void finished();

private:
QNetworkAccessManager *m_netManager;
};

#endif //SHORTENEDEURL_H
4 changes: 2 additions & 2 deletions shorturlsitem.cpp
Expand Up @@ -28,7 +28,7 @@
* Constructor
*/
ShortUrlsItem::ShortUrlsItem(QObject *parent) :
QObject(parent), m_netManager(new QNetworkAccessManager(this))
QObject(parent)
{
}

Expand All @@ -51,7 +51,7 @@ void ShortUrlsItem::shortUrls(const QString &textWithUrls)
QString matchedUrl = textWithUrls.mid(pos, rx.matchedLength());

if (!matchedUrl.contains("http://bit.ly/")) {
ShortenedUrl *shortenedUrl = new ShortenedUrl(m_netManager, this);
ShortenedUrl *shortenedUrl = new ShortenedUrl(this);
shortenedUrl->shortUrl(matchedUrl);
connect(shortenedUrl, SIGNAL(finishedShortingUrl(QString,QString)),
this, SLOT(finishedShortingUrl(QString,QString)));
Expand Down
3 changes: 0 additions & 3 deletions shorturlsitem.h
Expand Up @@ -23,8 +23,6 @@

#include <QObject>

class QNetworkAccessManager;

class ShortUrlsItem : public QObject
{
Q_OBJECT
Expand All @@ -40,7 +38,6 @@ private slots:
void finishedShortingUrl(const QString& shortUrl, const QString& longUrl);

private:
QNetworkAccessManager* m_netManager;
QString m_textWithUrls;
};

Expand Down

0 comments on commit 5f22421

Please sign in to comment.