From d62554aababddcf515b514dd51977aaaf0e247df Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 25 Aug 2012 16:34:00 +0300 Subject: [PATCH] Minor code clean up --- src/mainwindow.cpp | 4 ++-- src/qtlibtorrent/torrentmodel.cpp | 15 ++++++++------- src/qtlibtorrent/trackerinfos.h | 16 +++++++++++----- src/qtsingleapp/qtlockedfile.cpp | 4 ++-- src/webui/httpresponsegenerator.h | 2 +- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 364f5ddc3..d5da3f68b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -107,7 +107,7 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa // Setting icons #if defined(Q_WS_X11) if (Preferences().useSystemIconTheme()) - setWindowIcon(QIcon::fromTheme("qbittorrent", QString::fromUtf8(":/Icons/skin/qbittorrent32.png"))); + setWindowIcon(QIcon::fromTheme("qbittorrent", QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent32.png")))); else #else setWindowIcon(QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent32.png"))); @@ -712,7 +712,7 @@ void MainWindow::toggleVisibility(QSystemTrayIcon::ActivationReason e) { return; } // Make sure the window is not minimized - setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive); + setWindowState(windowState() & (~Qt::WindowMinimized | Qt::WindowActive)); // Then show it show(); raise(); diff --git a/src/qtlibtorrent/torrentmodel.cpp b/src/qtlibtorrent/torrentmodel.cpp index 0b007868e..5e3891c6e 100644 --- a/src/qtlibtorrent/torrentmodel.cpp +++ b/src/qtlibtorrent/torrentmodel.cpp @@ -37,14 +37,15 @@ using namespace libtorrent; TorrentModelItem::TorrentModelItem(const QTorrentHandle &h) + : m_torrent(h) + , m_addedTime(TorrentPersistentData::getAddedDate(h.hash())) + , m_seedTime(TorrentPersistentData::getSeedDate(h.hash())) + , m_label(TorrentPersistentData::getLabel(h.hash())) + , m_name(TorrentPersistentData::getName(h.hash())) + , m_hash(h.hash()) { - m_torrent = h; - m_hash = h.hash(); - m_name = TorrentPersistentData::getName(h.hash()); - if (m_name.isEmpty()) m_name = h.name(); - m_addedTime = TorrentPersistentData::getAddedDate(h.hash()); - m_seedTime = TorrentPersistentData::getSeedDate(h.hash()); - m_label = TorrentPersistentData::getLabel(h.hash()); + if (m_name.isEmpty()) + m_name = h.name(); } TorrentModelItem::State TorrentModelItem::state() const diff --git a/src/qtlibtorrent/trackerinfos.h b/src/qtlibtorrent/trackerinfos.h index f501542a8..5fe5be2b7 100644 --- a/src/qtlibtorrent/trackerinfos.h +++ b/src/qtlibtorrent/trackerinfos.h @@ -40,13 +40,19 @@ public: unsigned long num_peers; //TrackerInfos() {} - TrackerInfos(const TrackerInfos &b) { - name_or_url = b.name_or_url; + TrackerInfos(const TrackerInfos &b) + : name_or_url(b.name_or_url) + , last_message(b.last_message) + , num_peers(b.num_peers) + { Q_ASSERT(!name_or_url.isEmpty()); - last_message = b.last_message; - num_peers = b.num_peers; } - TrackerInfos(QString name_or_url): name_or_url(name_or_url), last_message(""), num_peers(0) { + + TrackerInfos(QString name_or_url) + : name_or_url(name_or_url) + , last_message("") + , num_peers(0) + { } }; diff --git a/src/qtsingleapp/qtlockedfile.cpp b/src/qtsingleapp/qtlockedfile.cpp index 2cf080584..29d080d6a 100644 --- a/src/qtsingleapp/qtlockedfile.cpp +++ b/src/qtsingleapp/qtlockedfile.cpp @@ -88,12 +88,12 @@ */ QtLockedFile::QtLockedFile() : QFile() + , m_lock_mode(NoLock) { #ifdef Q_OS_WIN wmutex = 0; rmutex = 0; #endif - m_lock_mode = NoLock; } /*! @@ -105,12 +105,12 @@ QtLockedFile::QtLockedFile() */ QtLockedFile::QtLockedFile(const QString &name) : QFile(name) + , m_lock_mode(NoLock) { #ifdef Q_OS_WIN wmutex = 0; rmutex = 0; #endif - m_lock_mode = NoLock; } /*! diff --git a/src/webui/httpresponsegenerator.h b/src/webui/httpresponsegenerator.h index ef71cf645..ba46f4a22 100644 --- a/src/webui/httpresponsegenerator.h +++ b/src/webui/httpresponsegenerator.h @@ -37,7 +37,7 @@ class HttpResponseGenerator : public QHttpResponseHeader { - public: +public: void setMessage(const QByteArray& message); void setMessage(const QString& message); void setContentTypeByExt(const QString& ext);