Browse Source

Coding style changes

adaptive-webui-19844
Christophe Dumez 13 years ago
parent
commit
06ccae591e
  1. 2
      src/mainwindow.cpp
  2. 50
      src/preferences/options_imp.cpp
  3. 2
      src/previewlistdelegate.h
  4. 2
      src/properties/peerlistdelegate.h
  5. 4
      src/properties/proplistdelegate.h
  6. 16
      src/qtlibtorrent/qbtsession.cpp
  7. 2
      src/qtlibtorrent/qtorrenthandle.cpp
  8. 2
      src/rss/feedlistwidget.cpp
  9. 26
      src/rss/rssfeed.cpp
  10. 2
      src/searchengine/searchlistdelegate.h
  11. 2
      src/transferlistdelegate.h
  12. 2
      src/transferlistwidget.cpp

2
src/mainwindow.cpp

@ -602,7 +602,7 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(const QTorrentHandle &h
} }
} }
void MainWindow::handleDownloadFromUrlFailure(QString url, QString reason) const{ void MainWindow::handleDownloadFromUrlFailure(QString url, QString reason) const {
// Display a message box // Display a message box
showNotificationBaloon(tr("Url download error"), tr("Couldn't download file at url: %1, reason: %2.").arg(url).arg(reason)); showNotificationBaloon(tr("Url download error"), tr("Couldn't download file at url: %1, reason: %2.").arg(url).arg(reason));
} }

50
src/preferences/options_imp.cpp

@ -498,11 +498,11 @@ void options_imp::saveOptions() {
advancedSettings->saveAdvancedSettings(); advancedSettings->saveAdvancedSettings();
} }
bool options_imp::isFilteringEnabled() const{ bool options_imp::isFilteringEnabled() const {
return checkIPFilter->isChecked(); return checkIPFilter->isChecked();
} }
int options_imp::getProxyType() const{ int options_imp::getProxyType() const {
switch(comboProxyType->currentIndex()) { switch(comboProxyType->currentIndex()) {
case 1: case 1:
return Proxy::SOCKS4; return Proxy::SOCKS4;
@ -757,7 +757,7 @@ void options_imp::loadOptions() {
// return min & max ports // return min & max ports
// [min, max] // [min, max]
int options_imp::getPort() const{ int options_imp::getPort() const {
return spinPort->value(); return spinPort->value();
} }
@ -766,7 +766,7 @@ void options_imp::on_randomButton_clicked() {
spinPort->setValue(rand() % 64512 + 1024); spinPort->setValue(rand() % 64512 + 1024);
} }
int options_imp::getEncryptionSetting() const{ int options_imp::getEncryptionSetting() const {
return comboEncryption->currentIndex(); return comboEncryption->currentIndex();
} }
@ -782,12 +782,12 @@ int options_imp::getMaxActiveTorrents() const {
return spinMaxActiveTorrents->value(); return spinMaxActiveTorrents->value();
} }
bool options_imp::minimizeToTray() const{ bool options_imp::minimizeToTray() const {
if (!checkShowSystray->isChecked()) return false; if (!checkShowSystray->isChecked()) return false;
return checkMinimizeToSysTray->isChecked(); return checkMinimizeToSysTray->isChecked();
} }
bool options_imp::closeToTray() const{ bool options_imp::closeToTray() const {
if (!checkShowSystray->isChecked()) return false; if (!checkShowSystray->isChecked()) return false;
return checkCloseToSystray->isChecked(); return checkCloseToSystray->isChecked();
} }
@ -796,21 +796,21 @@ bool options_imp::isQueueingSystemEnabled() const {
return checkEnableQueueing->isChecked(); return checkEnableQueueing->isChecked();
} }
bool options_imp::isDHTEnabled() const{ bool options_imp::isDHTEnabled() const {
return checkDHT->isChecked(); return checkDHT->isChecked();
} }
bool options_imp::isLSDEnabled() const{ bool options_imp::isLSDEnabled() const {
return checkLSD->isChecked(); return checkLSD->isChecked();
} }
bool options_imp::isUPnPEnabled() const{ bool options_imp::isUPnPEnabled() const {
return checkUPnP->isChecked(); return checkUPnP->isChecked();
} }
// Return Download & Upload limits in kbps // Return Download & Upload limits in kbps
// [download,upload] // [download,upload]
QPair<int,int> options_imp::getGlobalBandwidthLimits() const{ QPair<int,int> options_imp::getGlobalBandwidthLimits() const {
int DL = -1, UP = -1; int DL = -1, UP = -1;
if (checkDownloadLimit->isChecked()) { if (checkDownloadLimit->isChecked()) {
DL = spinDownloadLimit->value(); DL = spinDownloadLimit->value();
@ -826,7 +826,7 @@ bool options_imp::startMinimized() const {
return checkStartMinimized->isChecked(); return checkStartMinimized->isChecked();
} }
bool options_imp::systrayIntegration() const{ bool options_imp::systrayIntegration() const {
if (!QSystemTrayIcon::isSystemTrayAvailable()) return false; if (!QSystemTrayIcon::isSystemTrayAvailable()) return false;
return checkShowSystray->isChecked(); return checkShowSystray->isChecked();
} }
@ -836,7 +836,7 @@ int options_imp::getDHTPort() const {
} }
// Return Share ratio // Return Share ratio
qreal options_imp::getMaxRatio() const{ qreal options_imp::getMaxRatio() const {
if (checkMaxRatio->isChecked()) { if (checkMaxRatio->isChecked()) {
return spinMaxRatio->value(); return spinMaxRatio->value();
} }
@ -844,7 +844,7 @@ qreal options_imp::getMaxRatio() const{
} }
// Return Save Path // Return Save Path
QString options_imp::getSavePath() const{ QString options_imp::getSavePath() const {
if (textSavePath->text().trimmed().isEmpty()) { if (textSavePath->text().trimmed().isEmpty()) {
QString save_path = Preferences().getSavePath(); QString save_path = Preferences().getSavePath();
#if defined(Q_WS_WIN) || defined(Q_OS_OS2) #if defined(Q_WS_WIN) || defined(Q_OS_OS2)
@ -864,7 +864,7 @@ bool options_imp::isTempPathEnabled() const {
} }
// Return max connections number // Return max connections number
int options_imp::getMaxConnecs() const{ int options_imp::getMaxConnecs() const {
if (!checkMaxConnecs->isChecked()) { if (!checkMaxConnecs->isChecked()) {
return -1; return -1;
}else{ }else{
@ -872,7 +872,7 @@ int options_imp::getMaxConnecs() const{
} }
} }
int options_imp::getMaxConnecsPerTorrent() const{ int options_imp::getMaxConnecsPerTorrent() const {
if (!checkMaxConnecsPerTorrent->isChecked()) { if (!checkMaxConnecsPerTorrent->isChecked()) {
return -1; return -1;
}else{ }else{
@ -880,7 +880,7 @@ int options_imp::getMaxConnecsPerTorrent() const{
} }
} }
int options_imp::getMaxUploadsPerTorrent() const{ int options_imp::getMaxUploadsPerTorrent() const {
if (!checkMaxUploadsPerTorrent->isChecked()) { if (!checkMaxUploadsPerTorrent->isChecked()) {
return -1; return -1;
}else{ }else{
@ -916,7 +916,7 @@ void options_imp::on_buttonBox_rejected() {
reject(); reject();
} }
bool options_imp::useAdditionDialog() const{ bool options_imp::useAdditionDialog() const {
return checkAdditionDialog->isChecked(); return checkAdditionDialog->isChecked();
} }
@ -971,36 +971,36 @@ bool options_imp::isDHTPortSameAsBT() const {
} }
// Proxy settings // Proxy settings
bool options_imp::isProxyEnabled() const{ bool options_imp::isProxyEnabled() const {
return comboProxyType->currentIndex(); return comboProxyType->currentIndex();
} }
bool options_imp::isProxyAuthEnabled() const{ bool options_imp::isProxyAuthEnabled() const {
return checkProxyAuth->isChecked(); return checkProxyAuth->isChecked();
} }
QString options_imp::getProxyIp() const{ QString options_imp::getProxyIp() const {
return textProxyIP->text().trimmed(); return textProxyIP->text().trimmed();
} }
unsigned short options_imp::getProxyPort() const{ unsigned short options_imp::getProxyPort() const {
return spinProxyPort->value(); return spinProxyPort->value();
} }
QString options_imp::getProxyUsername() const{ QString options_imp::getProxyUsername() const {
QString username = textProxyUsername->text(); QString username = textProxyUsername->text();
username = username.trimmed(); username = username.trimmed();
return username; return username;
} }
QString options_imp::getProxyPassword() const{ QString options_imp::getProxyPassword() const {
QString password = textProxyPassword->text(); QString password = textProxyPassword->text();
password = password.trimmed(); password = password.trimmed();
return password; return password;
} }
// Locale Settings // Locale Settings
QString options_imp::getLocale() const{ QString options_imp::getLocale() const {
return comboI18n->itemData(comboI18n->currentIndex(), Qt::UserRole).toString(); return comboI18n->itemData(comboI18n->currentIndex(), Qt::UserRole).toString();
} }
@ -1145,7 +1145,7 @@ void options_imp::on_browseTempDirButton_clicked() {
} }
// Return Filter object to apply to BT session // Return Filter object to apply to BT session
QString options_imp::getFilter() const{ QString options_imp::getFilter() const {
return textFilterPath->text(); return textFilterPath->text();
} }

2
src/previewlistdelegate.h

@ -49,7 +49,7 @@ class PreviewListDelegate: public QItemDelegate {
~PreviewListDelegate() {} ~PreviewListDelegate() {}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{ void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const {
painter->save(); painter->save();
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option); QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);

2
src/properties/peerlistdelegate.h

@ -47,7 +47,7 @@ public:
~PeerListDelegate() {} ~PeerListDelegate() {}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{ void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const {
painter->save(); painter->save();
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option); QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
switch(index.column()) { switch(index.column()) {

4
src/properties/proplistdelegate.h

@ -65,7 +65,7 @@ public:
~PropListDelegate() {} ~PropListDelegate() {}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{ void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const {
painter->save(); painter->save();
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option); QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
switch(index.column()) { switch(index.column()) {
@ -131,7 +131,7 @@ public:
painter->restore(); painter->restore();
} }
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const{ QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const {
QVariant value = index.data(Qt::FontRole); QVariant value = index.data(Qt::FontRole);
QFont fnt = value.isValid() ? qvariant_cast<QFont>(value) : option.font; QFont fnt = value.isValid() ? qvariant_cast<QFont>(value) : option.font;
QFontMetrics fontMetrics(fnt); QFontMetrics fontMetrics(fnt);

16
src/qtlibtorrent/qbtsession.cpp

@ -709,7 +709,7 @@ void QBtSession::useAlternativeSpeedsLimit(bool alternative) {
} }
// Return the torrent handle, given its hash // Return the torrent handle, given its hash
QTorrentHandle QBtSession::getTorrentHandle(const QString &hash) const{ QTorrentHandle QBtSession::getTorrentHandle(const QString &hash) const {
return QTorrentHandle(s->find_torrent(QStringToSha1(hash))); return QTorrentHandle(s->find_torrent(QStringToSha1(hash)));
} }
@ -1545,7 +1545,7 @@ bool QBtSession::enableDHT(bool b) {
return true; return true;
} }
qreal QBtSession::getRealRatio(const QString &hash) const{ qreal QBtSession::getRealRatio(const QString &hash) const {
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
if (!h.is_valid()) { if (!h.is_valid()) {
return 0.; return 0.;
@ -1690,7 +1690,7 @@ void QBtSession::addPeerBanMessage(QString ip, bool from_ipfilter) {
emit newBanMessage(msg); emit newBanMessage(msg);
} }
bool QBtSession::isFilePreviewPossible(const QString &hash) const{ bool QBtSession::isFilePreviewPossible(const QString &hash) const {
// See if there are supported files in the torrent // See if there are supported files in the torrent
const QTorrentHandle h = getTorrentHandle(hash); const QTorrentHandle h = getTorrentHandle(hash);
if (!h.is_valid() || !h.has_metadata()) { if (!h.is_valid() || !h.has_metadata()) {
@ -2550,16 +2550,16 @@ void QBtSession::recheckTorrent(const QString &hash) {
} }
} }
QHash<QString, TrackerInfos> QBtSession::getTrackersInfo(const QString &hash) const{ QHash<QString, TrackerInfos> QBtSession::getTrackersInfo(const QString &hash) const {
return trackersInfos.value(hash, QHash<QString, TrackerInfos>()); return trackersInfos.value(hash, QHash<QString, TrackerInfos>());
} }
int QBtSession::getListenPort() const{ int QBtSession::getListenPort() const {
qDebug() << Q_FUNC_INFO << s->listen_port(); qDebug() << Q_FUNC_INFO << s->listen_port();
return s->listen_port(); return s->listen_port();
} }
session_status QBtSession::getSessionStatus() const{ session_status QBtSession::getSessionStatus() const {
return s->status(); return s->status();
} }
@ -2674,14 +2674,14 @@ void QBtSession::processDownloadedFile(QString url, QString file_path) {
// Return current download rate for the BT // Return current download rate for the BT
// session. Payload means that it only take into // session. Payload means that it only take into
// account "useful" part of the rate // account "useful" part of the rate
qreal QBtSession::getPayloadDownloadRate() const{ qreal QBtSession::getPayloadDownloadRate() const {
return s->status().payload_download_rate; return s->status().payload_download_rate;
} }
// Return current upload rate for the BT // Return current upload rate for the BT
// session. Payload means that it only take into // session. Payload means that it only take into
// account "useful" part of the rate // account "useful" part of the rate
qreal QBtSession::getPayloadUploadRate() const{ qreal QBtSession::getPayloadUploadRate() const {
return s->status().payload_upload_rate; return s->status().payload_upload_rate;
} }

2
src/qtlibtorrent/qtorrenthandle.cpp

@ -807,7 +807,7 @@ void QTorrentHandle::rename_file(int index, QString name) const {
// Operators // Operators
// //
bool QTorrentHandle::operator ==(const QTorrentHandle& new_h) const{ bool QTorrentHandle::operator ==(const QTorrentHandle& new_h) const {
const QString hash = misc::toQString(torrent_handle::info_hash()); const QString hash = misc::toQString(torrent_handle::info_hash());
return (hash == new_h.hash()); return (hash == new_h.hash());
} }

2
src/rss/feedlistwidget.cpp

@ -149,7 +149,7 @@ QString FeedListWidget::getItemID(QTreeWidgetItem *item) const {
return m_rssMapping.value(item)->id(); return m_rssMapping.value(item)->id();
} }
QTreeWidgetItem* FeedListWidget::getTreeItemFromUrl(const QString &url) const{ QTreeWidgetItem* FeedListWidget::getTreeItemFromUrl(const QString &url) const {
return m_feedsItems.value(url, 0); return m_feedsItems.value(url, 0);
} }

26
src/rss/rssfeed.cpp

@ -132,7 +132,7 @@ bool RssFeed::isLoading() const {
return m_loading; return m_loading;
} }
QString RssFeed::title() const{ QString RssFeed::title() const {
return m_title; return m_title;
} }
@ -143,29 +143,24 @@ void RssFeed::rename(const QString &new_name) {
// Return the alias if the stream has one, the url if it has no alias // Return the alias if the stream has one, the url if it has no alias
QString RssFeed::displayName() const { QString RssFeed::displayName() const {
if (!m_alias.isEmpty()) { if (!m_alias.isEmpty())
//qDebug("getName() returned alias: %s", (const char*)alias.toLocal8Bit());
return m_alias; return m_alias;
} if (!m_title.isEmpty())
if (!m_title.isEmpty()) {
//qDebug("getName() returned title: %s", (const char*)title.toLocal8Bit());
return m_title; return m_title;
}
//qDebug("getName() returned url: %s", (const char*)url.toLocal8Bit());
return m_url; return m_url;
} }
QString RssFeed::url() const{ QString RssFeed::url() const {
return m_url; return m_url;
} }
QString RssFeed::icon() const{ QString RssFeed::icon() const {
if (m_downloadFailure) if (m_downloadFailure)
return ":/Icons/oxygen/unavailable.png"; return ":/Icons/oxygen/unavailable.png";
return m_icon; return m_icon;
} }
bool RssFeed::hasCustomIcon() const{ bool RssFeed::hasCustomIcon() const {
return !m_icon.startsWith(":/"); return !m_icon.startsWith(":/");
} }
@ -178,7 +173,7 @@ RssArticlePtr RssFeed::getItem(const QString &guid) const {
return m_articles.value(guid); return m_articles.value(guid);
} }
uint RssFeed::count() const{ uint RssFeed::count() const {
return m_articles.size(); return m_articles.size();
} }
@ -189,7 +184,7 @@ void RssFeed::markAsRead() {
m_manager->forwardFeedInfosChanged(m_url, displayName(), 0); m_manager->forwardFeedInfosChanged(m_url, displayName(), 0);
} }
uint RssFeed::unreadCount() const{ uint RssFeed::unreadCount() const {
uint nbUnread = 0; uint nbUnread = 0;
for (RssArticleHash::ConstIterator it=m_articles.begin(); it != m_articles.end(); it++) { for (RssArticleHash::ConstIterator it=m_articles.begin(); it != m_articles.end(); it++) {
if (!it.value()->isRead()) if (!it.value()->isRead())
@ -198,7 +193,7 @@ uint RssFeed::unreadCount() const{
return nbUnread; return nbUnread;
} }
RssArticleList RssFeed::articleList() const{ RssArticleList RssFeed::articleList() const {
return m_articles.values(); return m_articles.values();
} }
@ -213,9 +208,8 @@ RssArticleList RssFeed::unreadArticleList() const {
// download the icon from the adress // download the icon from the adress
QString RssFeed::iconUrl() const { QString RssFeed::iconUrl() const {
const QUrl siteUrl(m_url);
// XXX: This works for most sites but it is not perfect // XXX: This works for most sites but it is not perfect
return QString("http://")+siteUrl.host()+QString("/favicon.ico"); return QString("http://")+QUrl(m_url).host()+QString("/favicon.ico");
} }
void RssFeed::parseRSSChannel(QXmlStreamReader& xml) void RssFeed::parseRSSChannel(QXmlStreamReader& xml)

2
src/searchengine/searchlistdelegate.h

@ -48,7 +48,7 @@ class SearchListDelegate: public QItemDelegate {
~SearchListDelegate() {} ~SearchListDelegate() {}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{ void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const {
painter->save(); painter->save();
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option); QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
switch(index.column()) { switch(index.column()) {

2
src/transferlistdelegate.h

@ -57,7 +57,7 @@ public:
~TransferListDelegate() {} ~TransferListDelegate() {}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const{ void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const {
QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option); QStyleOptionViewItemV2 opt = QItemDelegate::setOptions(index, option);
painter->save(); painter->save();
switch(index.column()) { switch(index.column()) {

2
src/transferlistwidget.cpp

@ -155,7 +155,7 @@ void TransferListWidget::setRefreshInterval(int t) {
listModel->setRefreshInterval(t); listModel->setRefreshInterval(t);
} }
int TransferListWidget::getRowFromHash(QString hash) const{ int TransferListWidget::getRowFromHash(QString hash) const {
return listModel->torrentRow(hash); return listModel->torrentRow(hash);
} }

Loading…
Cancel
Save