Prefer C++-style over C-style type casting.
Use qApp instead of QApplication/QCoreApplication::instance().
Use explicit QString::fromLatin1()/fromUtf8() where applicable.
{
ui.setupUi (this);
- ui.iconLabel->setPixmap (QApplication::windowIcon ().pixmap (48));
+ ui.iconLabel->setPixmap (qApp->windowIcon ().pixmap (48));
ui.titleLabel->setText (tr ("<big><b>Transmission %1</b></big>").arg (QString::fromUtf8 (LONG_VERSION_STRING)));
QPushButton * b;
{
tr_info inf;
tr_ctor * ctor = tr_ctorNew (NULL);
- tr_ctorSetMetainfo (ctor, (const quint8*)metainfo.constData(), metainfo.size());
+ tr_ctorSetMetainfo (ctor, reinterpret_cast<const quint8*> (metainfo.constData()), metainfo.size());
if (tr_torrentParse (ctor, &inf) == TR_PARSE_OK )
{
ret = QString::fromUtf8 (inf.name); // metainfo is required to be UTF-8
const char * password = 0;
const char * configDir = 0;
QStringList filenames;
- while ((c = tr_getopt (getUsage(), argc, (const char**)argv, opts, &optarg)))
+ while ((c = tr_getopt (getUsage(), argc, const_cast<const char**> (argv), opts, &optarg)))
{
switch (c)
{
if (myPrefs->getBool (Prefs::COMPLETE_SOUND_ENABLED))
{
#if defined (Q_OS_WIN) || defined (Q_OS_MAC)
- QApplication::beep ();
+ beep ();
#else
QProcess::execute (myPrefs->getString (Prefs::COMPLETE_SOUND_COMMAND));
#endif
void
MyApp::raise ()
{
- QApplication::alert (myWindow);
+ alert (myWindow);
}
bool
args.append (body); // body
args.append (QStringList ()); // actions - unused for plain passive popups
args.append (QVariantMap ()); // hints - unused atm
- args.append (int32_t (-1)); // use the default timeout period
+ args.append (static_cast<int32_t> (-1)); // use the default timeout period
m.setArguments (args);
QDBusMessage replyMsg = QDBusConnection::sessionBus ().call (m);
//std::cerr << qPrintable (replyMsg.errorName ()) << std::endl;
void maybeUpdateBlocklist ();
};
+#undef qApp
+#define qApp static_cast<MyApp*> (MyApp::instance ())
+
#endif
else if (sizeWhenDone == 0)
string = none;
else
- string = QString ("%1%").arg (Formatter::percentToString ( (100.0 * available) / sizeWhenDone));
+ string = QString::fromLatin1 ("%1%").arg (Formatter::percentToString ( (100.0 * available) / sizeWhenDone));
ui.availabilityValueLabel->setText (string);
// myDownloadedLabel
}
if (!txt.isEmpty ())
- codeTip += QString ("%1: %2\n").arg (ch).arg (txt);
+ codeTip += QString::fromLatin1 ("%1: %2\n").arg (ch).arg (txt);
}
if (!codeTip.isEmpty ())
item->setText (COL_UP, peer.rateToPeer.isZero () ? "" : Formatter::speedToString (peer.rateToPeer));
item->setText (COL_DOWN, peer.rateToClient.isZero () ? "" : Formatter::speedToString (peer.rateToClient));
- item->setText (COL_PERCENT, peer.progress > 0 ? QString ("%1%").arg ( (int) (peer.progress * 100.0)) : "");
+ item->setText (COL_PERCENT, peer.progress > 0 ? QString::fromLatin1 ("%1%").arg ( (int) (peer.progress * 100.0)) : "");
item->setText (COL_STATUS, code);
item->setToolTip (COL_STATUS, codeTip);
else if (role == Qt::DecorationRole && column == COL_NAME)
{
if (childCount () > 0)
- value = QApplication::style ()->standardIcon (QStyle::SP_DirOpenIcon);
+ value = qApp->style ()->standardIcon (QStyle::SP_DirOpenIcon);
else
value = Utils::guessMimeIcon (name ());
}
return;
}
- QStyle * style (QApplication::style ());
+ QStyle * style (qApp->style ());
painter->save();
QItemDelegate::drawBackground (painter, option, index);
{
QStyleOptionProgressBar p;
p.state = option.state | QStyle::State_Small;
- p.direction = QApplication::layoutDirection();
+ p.direction = qApp->layoutDirection();
p.rect = option.rect;
p.rect.setSize (QSize(option.rect.width()-2, option.rect.height()-8));
p.rect.moveCenter (option.rect.center());
- p.fontMetrics = QApplication::fontMetrics();
+ p.fontMetrics = qApp->fontMetrics();
p.minimum = 0;
p.maximum = 100;
p.textAlignment = Qt::AlignCenter;
{
QStyleOptionButton o;
o.state = option.state;
- o.direction = QApplication::layoutDirection();
+ o.direction = qApp->layoutDirection();
o.rect.setSize (QSize(20, option.rect.height()));
o.rect.moveCenter (option.rect.center());
- o.fontMetrics = QApplication::fontMetrics();
+ o.fontMetrics = qApp->fontMetrics();
switch (index.data().toInt())
{
case Qt::Unchecked: o.state |= QStyle::State_Off; break;
// space is left over...
if ((o == this) && (event->type() == QEvent::Resize))
{
- QResizeEvent * r = dynamic_cast<QResizeEvent*>(event);
+ QResizeEvent * r = static_cast<QResizeEvent*> (event);
int left = r->size().width();
const QFontMetrics fontMetrics(font());
for (int column=FIRST_VISIBLE_COLUMN; column<=LAST_VISIBLE_COLUMN; ++column)
void
FilterBar::refreshTrackers ()
{
- Favicons& favicons = dynamic_cast<MyApp*> (QApplication::instance ())->favicons;
+ Favicons& favicons = qApp->favicons;
const int firstTrackerRow = 2; // skip over the "All" and separator...
// pull info from the tracker model...
myIsBootstrapping (true)
{
QHBoxLayout * h = new QHBoxLayout (this);
- const int hmargin = qMax (int (HIG::PAD), style ()->pixelMetric (QStyle::PM_LayoutHorizontalSpacing));
+ const int hmargin = qMax (static_cast<int> (HIG::PAD), style ()->pixelMetric (QStyle::PM_LayoutHorizontalSpacing));
myCountLabel = new QLabel (this);
h->setSpacing (0);
QString
FilterBar::getCountString (int n) const
{
- return QString ("%L1").arg (n);
+ return QString::fromLatin1 ("%L1").arg (n);
}
void
double
Speed::KBps () const
{
- return _Bps / (double)speed_K;
+ return _Bps / static_cast<double> (speed_K);
}
Speed
Speed::fromKBps (double KBps)
{
- return int (KBps * speed_K);
+ return static_cast<int> (KBps * speed_K);
}
/***
Formatter::percentToString (double x)
{
char buf[128];
- return QString (tr_strpercent (buf, x, sizeof (buf)));
+ return QString::fromUtf8 (tr_strpercent (buf, x, sizeof (buf)));
}
QString
connect (&myFilterModel, SIGNAL (rowsInserted (QModelIndex, int, int)), this, SLOT (refreshActionSensitivitySoon ()));
connect (&myFilterModel, SIGNAL (rowsRemoved (QModelIndex, int, int)), this, SLOT (refreshActionSensitivitySoon ()));
- connect (ui.action_Quit, SIGNAL (triggered ()), QCoreApplication::instance (), SLOT (quit ()));
+ connect (ui.action_Quit, SIGNAL (triggered ()), qApp, SLOT (quit ()));
// torrent view
myFilterModel.setSourceModel (&myModel);
menu->addSeparator ();
menu->addAction (ui.action_Quit);
myTrayIcon.setContextMenu (menu);
- myTrayIcon.setIcon (QIcon::fromTheme ("transmission-tray-icon", QApplication::windowIcon ()));
+ myTrayIcon.setIcon (QIcon::fromTheme ("transmission-tray-icon", qApp->windowIcon ()));
connect (&myPrefs, SIGNAL (changed (int)), this, SLOT (refreshPref (int)));
connect (ui.action_ShowMainWindow, SIGNAL (triggered (bool)), this, SLOT (toggleWindows (bool)));
if (isMinimized ()) showNormal ();
//activateWindow ();
raise ();
- QApplication::setActiveWindow (this);
+ qApp->setActiveWindow (this);
}
}
b = myPrefs.getBool (key);
ui.action_TrayIcon->setChecked (b);
myTrayIcon.setVisible (b);
- dynamic_cast<MyApp*> (QCoreApplication::instance ())->setQuitOnLastWindowClosed (!b);
+ qApp->setQuitOnLastWindowClosed (!b);
refreshTrayIconSoon ();
break;
QCheckBox * b = new QCheckBox (tr ("Show &options dialog"));
b->setChecked (myPrefs.getBool (Prefs::OPTIONS_PROMPT));
b->setObjectName (SHOW_OPTIONS_CHECKBOX_NAME);
- auto l = dynamic_cast<QGridLayout*> (d->layout ());
+ auto l = qobject_cast<QGridLayout*> (d->layout ());
if (l == nullptr)
{
l = new QGridLayout;
void
TrMainWindow::openURL ()
{
- QString str = QApplication::clipboard ()->text (QClipboard::Selection);
+ QString str = qApp->clipboard ()->text (QClipboard::Selection);
if (!AddData::isSupported (str))
- str = QApplication::clipboard ()->text (QClipboard::Clipboard);
+ str = qApp->clipboard ()->text (QClipboard::Clipboard);
if (!AddData::isSupported (str))
str.clear ();
{
Options * o = new Options (mySession, myPrefs, addMe, this);
o->show ();
- QApplication::alert (o);
+ qApp->alert (o);
}
else
{
mySession.addTorrent (addMe);
- QApplication::alert (this);
+ qApp->alert (this);
}
}
}
}
- msgBox.setWindowTitle (QString (" "));
- msgBox.setText (QString ("<big><b>%1</big></b>").arg (primary_text));
+ msgBox.setWindowTitle (QLatin1String (" "));
+ msgBox.setText (QString::fromLatin1 ("<big><b>%1</big></b>").arg (primary_text));
msgBox.setInformativeText (secondary_text);
msgBox.setStandardButtons (QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton (QMessageBox::Cancel);
msgBox.setIcon (QMessageBox::Question);
// hack needed to keep the dialog from being too narrow
- auto layout = dynamic_cast<QGridLayout*>(msgBox.layout());
+ auto layout = qobject_cast<QGridLayout*> (msgBox.layout ());
if (layout == nullptr)
{
layout = new QGridLayout;
if (url.scheme () == "file")
key = QUrl::fromPercentEncoding (url.path().toUtf8());
- dynamic_cast<MyApp*> (QApplication::instance ())->addTorrent (key);
+ qApp->addTorrent (key);
}
}
}
// progress bar
const tr_metainfo_builder * b = myBuilder;
const double denom = b->pieceCount ? b->pieceCount : 1;
- myNewProgress->setValue ((int) ((100.0 * b->pieceIndex) / denom));
+ myNewProgress->setValue (static_cast<int> ((100.0 * b->pieceIndex) / denom));
// progress label
const QString top = QString::fromLocal8Bit (myBuilder->top);
if (event->type() == QEvent::Resize)
{
if (o == mySourceButton)
- refreshSource (dynamic_cast<QResizeEvent*> (event)->size ().width ());
+ refreshSource (static_cast<QResizeEvent*> (event)->size ().width ());
else if (o == myDestinationButton)
- refreshDestinationButton (dynamic_cast<QResizeEvent*> (event)->size ().width ());
+ refreshDestinationButton (static_cast<QResizeEvent*> (event)->size ().width ());
}
return false;
int64_t leftInPiece = getPieceSize (&myInfo, myVerifyPieceIndex) - myVerifyPiecePos;
int64_t leftInFile = file->length - myVerifyFilePos;
int64_t bytesThisPass = std::min (leftInFile, leftInPiece);
- bytesThisPass = std::min (bytesThisPass, (int64_t)sizeof (myVerifyBuf));
+ bytesThisPass = std::min (bytesThisPass, static_cast<int64_t> (sizeof (myVerifyBuf)));
if (myVerifyFile.isOpen () && myVerifyFile.seek (myVerifyFilePos))
{
if (!have) // everything failed
{
// did the user accidentally specify the child directory instead of the parent?
- const QStringList tokens = QString (file->name).split ('/');
+ const QStringList tokens = QString::fromUtf8 (file->name).split ('/');
if (!tokens.empty () && myLocalDestination.dirName ()==tokens.at (0))
{
// move up one directory and try again
{
case QVariant::Int:
if (tr_variantGetInt (b, &intVal))
- myValues[i].setValue (qlonglong(intVal));
+ myValues[i].setValue (static_cast<qlonglong> (intVal));
break;
case TrTypes::SortModeType:
case QVariant::Bool:
if (tr_variantGetBool (b, &boolVal))
- myValues[i].setValue (bool(boolVal));
+ myValues[i].setValue (static_cast<bool> (boolVal));
break;
case QVariant::Double:
template<typename T> T get (int key) const { return myValues[key].value<T>(); }
- void set (int key, char * value) { set (key, QString::fromUtf8 (value)); }
void set (int key, const char * value) { set (key, QString::fromUtf8 (value)); }
template<typename T> void set (int key, const T& value)
{
const QString myFilename = QFileInfo (myName).fileName ();
const QString name = QString::fromUtf8 (str);
- QMessageBox::warning (QApplication::activeWindow (),
+ QMessageBox::warning (qApp->activeWindow (),
tr ("Add Torrent"),
tr ("<p><b>Unable to add \"%1\".</b></p><p>It is a duplicate of \"%2\" which is already added.</p>").arg (myFilename).arg (name));
}
if (!i || text[i-1].isSpace ())
text[i] = text[i].toUpper ();
- QMessageBox::warning (QApplication::activeWindow (),
+ QMessageBox::warning (qApp->activeWindow (),
tr ("Error Adding Torrent"),
- QString ("<p><b>%1</b></p><p>%2</p>").arg (text).arg (myName));
+ QString::fromLatin1 ("<p><b>%1</b></p><p>%2</p>").arg (text).arg (myName));
}
deleteLater ();
/* this callback is invoked in the libtransmission thread, so we don't want
to process the response here... let's push it over to the Qt thread. */
- self->responseReceived (QByteArray ( (const char *)evbuffer_pullup (json, -1),
- (int)evbuffer_get_length (json)));
+ self->responseReceived (QByteArray (reinterpret_cast<const char *> (evbuffer_pullup (json, -1)),
+ static_cast<int> (evbuffer_get_length (json))));
}
#define REQUEST_DATA_PROPERTY_KEY "requestData"
{
QNetworkRequest request;
request.setUrl (myUrl);
- request.setRawHeader ("User-Agent", QString (QCoreApplication::instance ()->applicationName () + "/" + LONG_VERSION_STRING).toUtf8 ());
+ request.setRawHeader ("User-Agent", (qApp->applicationName () + "/" + LONG_VERSION_STRING).toUtf8 ());
request.setRawHeader ("Content-Type", "application/json; charset=UTF-8");
if (!mySessionId.isEmpty ())
{
// we got a 409 telling us our session id has expired.
// update it and resubmit the request.
- mySessionId = QString (reply->rawHeader (TR_RPC_SESSION_ID_HEADER));
+ mySessionId = QString::fromUtf8 (reply->rawHeader (TR_RPC_SESSION_ID_HEADER));
exec (reply->property (REQUEST_DATA_PROPERTY_KEY).toByteArray ().constData ());
}
else if (reply->error () != QNetworkReply::NoError)
const QString text = tr ("<p><b>Unable to rename \"%1\" as \"%2\": %3.</b></p> <p>Please correct the errors and try again.</p>").arg (path).arg (name).arg (result);
QMessageBox * d = new QMessageBox (QMessageBox::Information, title, text,
QMessageBox::Close,
- QApplication::activeWindow ());
+ qApp->activeWindow ());
connect (d, SIGNAL (rejected ()), d, SLOT (deleteLater ()));
d->show ();
}
{
// let's get the updated file list
char * req = tr_strdup_printf ("{ \"arguments\": { \"fields\": [ \"fileStats\", \"files\", \"id\", \"name\" ], \"ids\": %d }, \"method\": \"torrent-get\", \"tag\": %d }",
- int (id),
- int (TAG_SOME_TORRENTS));
+ static_cast<int> (id),
+ static_cast<int> (TAG_SOME_TORRENTS));
exec (req);
tr_free (req);
}
}
case TAG_PORT_TEST: {
- bool isOpen = 0;
+ bool isOpen = false;
if (tr_variantDictFindDict (&top, TR_KEY_arguments, &args))
tr_variantDictFindBool (args, TR_KEY_port_is_open, &isOpen);
- emit portTested ( (bool)isOpen);
+ emit portTested (isOpen);
break;
}
&& tr_variantDictFindList (args, TR_KEY_torrents, &torrents)
&& ( (child = tr_variantListChild (torrents, 0)))
&& tr_variantDictFindStr (child, TR_KEY_magnetLink, &str, NULL))
- QApplication::clipboard ()->setText (str);
+ qApp->clipboard ()->setText (str);
break;
}
tr ("Add Torrent"),
QString::fromUtf8 (str),
QMessageBox::Close,
- QApplication::activeWindow ());
+ qApp->activeWindow ());
connect (d, SIGNAL (rejected ()), d, SLOT (deleteLater ()));
d->show ();
}
{
int64_t val;
if (tr_variantGetInt (b, &val))
- myPrefs.set (i, (int)val);
+ myPrefs.set (i, static_cast<int>(val));
break;
}
case QVariant::Double:
{
bool val;
if (tr_variantGetBool (b, &val))
- myPrefs.set (i, (bool)val);
+ myPrefs.set (i, val);
break;
}
case TrTypes::FilterModeType:
{
const char * val;
if (tr_variantGetStr (b, &val, NULL))
- myPrefs.set (i, QString (val));
+ myPrefs.set (i, QString::fromUtf8 (val));
break;
}
default:
bool b;
double x;
if (tr_variantDictFindBool (d, TR_KEY_seedRatioLimited, &b))
- myPrefs.set (Prefs::RATIO_ENABLED, b ? true : false);
+ myPrefs.set (Prefs::RATIO_ENABLED, b);
if (tr_variantDictFindReal (d, TR_KEY_seedRatioLimit, &x))
myPrefs.set (Prefs::RATIO, x);
TorrentDelegateMin::sizeHint (const QStyleOptionViewItem & option,
const Torrent & tor) const
{
- const QStyle* style (QApplication::style());
+ const QStyle* style (qApp->style());
static const int iconSize (style->pixelMetric (QStyle::PM_SmallIconSize));
QFont nameFont (option.font);
const int nameWidth = nameFM.width (nameStr);
QFont statusFont (option.font);
- statusFont.setPointSize (int (option.font.pointSize() * 0.85));
+ statusFont.setPointSize (static_cast<int> (option.font.pointSize() * 0.85));
const QFontMetrics statusFM (statusFont);
const QString statusStr (shortStatusString (tor));
const int statusWidth = statusFM.width (statusStr);
const Torrent & tor) const
{
const bool isPaused (tor.isPaused());
- const QStyle * style (QApplication::style());
+ const QStyle * style (qApp->style());
static const int iconSize (style->pixelMetric (QStyle::PM_SmallIconSize));
QFont nameFont (option.font);
const QString nameStr = (isMagnet ? progressString (tor) : tor.name());
QFont statusFont (option.font);
- statusFont.setPointSize (int (option.font.pointSize() * 0.85));
+ statusFont.setPointSize (static_cast<int> (option.font.pointSize() * 0.85));
const QFontMetrics statusFM (statusFont);
const QString statusStr (shortStatusString (tor));
const QSize statusSize (statusFM.size (0, statusStr));
QSize
TorrentDelegate::sizeHint (const QStyleOptionViewItem& option, const Torrent& tor) const
{
- const QStyle* style (QApplication::style ());
+ const QStyle* style (qApp->style ());
static const int iconSize (style->pixelMetric (QStyle::PM_MessageBoxIconSize));
QFont nameFont (option.font);
const QString nameStr (tor.name ());
const int nameWidth = nameFM.width (nameStr);
QFont statusFont (option.font);
- statusFont.setPointSize (int (option.font.pointSize () * 0.9));
+ statusFont.setPointSize (static_cast<int> (option.font.pointSize () * 0.9));
const QFontMetrics statusFM (statusFont);
const QString statusStr (statusString (tor));
const int statusWidth = statusFM.width (statusStr);
{
const bool isMagnet (!tor.hasMetadata ());
myProgressBarStyle->direction = option.direction;
- myProgressBarStyle->progress = int(myProgressBarStyle->minimum + (((isMagnet ? tor.metadataPercentDone() : tor.percentDone()) * (myProgressBarStyle->maximum - myProgressBarStyle->minimum))));
+ myProgressBarStyle->progress = static_cast<int> (myProgressBarStyle->minimum + (((isMagnet ? tor.metadataPercentDone() : tor.percentDone()) * (myProgressBarStyle->maximum - myProgressBarStyle->minimum))));
}
}
const QStyleOptionViewItem & option,
const Torrent & tor) const
{
- const QStyle * style (QApplication::style ());
+ const QStyle * style (qApp->style ());
static const int iconSize (style->pixelMetric (QStyle::PM_LargeIconSize));
QFont nameFont (option.font);
nameFont.setWeight (QFont::Bold);
const QString nameStr (tor.name ());
const QSize nameSize (nameFM.size (0, nameStr));
QFont statusFont (option.font);
- statusFont.setPointSize (int (option.font.pointSize () * 0.9));
+ statusFont.setPointSize (static_cast<int> (option.font.pointSize () * 0.9));
const QFontMetrics statusFM (statusFont);
const QString statusStr (progressString (tor));
QFont progressFont (statusFont);
#endif
setInt (ID, id);
- setIcon (MIME_ICON, QApplication::style()->standardIcon (QStyle::SP_FileIcon));
+ setIcon (MIME_ICON, qApp->style()->standardIcon (QStyle::SP_FileIcon));
}
Torrent::~Torrent ()
{
const double a = ratio ();
const double b = that.ratio ();
- if ((int)a == TR_RATIO_INF && (int)b == TR_RATIO_INF) return 0;
- if ((int)a == TR_RATIO_INF) return 1;
- if ((int)b == TR_RATIO_INF) return -1;
+ if (static_cast<int> (a) == TR_RATIO_INF && static_cast<int> (b) == TR_RATIO_INF) return 0;
+ if (static_cast<int> (a) == TR_RATIO_INF) return 1;
+ if (static_cast<int> (b) == TR_RATIO_INF) return -1;
if (a < b) return -1;
if (a > b) return 1;
return 0;
{
if (tr_variantDictFindStr(child, TR_KEY_announce, &str, &len))
{
- dynamic_cast<MyApp*>(QApplication::instance())->favicons.add (QUrl(QString::fromUtf8(str)));
+ qApp->favicons.add (QUrl(QString::fromUtf8(str)));
list.append (QString::fromUtf8 (str, len));
}
}
if (tr_variantDictFindStr(child, TR_KEY_announce, &str, &len))
{
trackerStat.announce = QString::fromUtf8 (str, len);
- dynamic_cast<MyApp*>(QApplication::instance())->favicons.add (QUrl (trackerStat.announce));
+ qApp->favicons.add (QUrl (trackerStat.announce));
}
if (tr_variantDictFindInt (child, TR_KEY_announceState, &i))
QPixmap
TrackerStat::getFavicon () const
{
- MyApp * myApp = dynamic_cast<MyApp*>(QApplication::instance());
- return myApp->favicons.find (QUrl (announce));
+ return qApp->favicons.find (QUrl (announce));
}
bool isMagnet () const { return magnetTorrent; }
int pieceCount () const { return getInt (PIECE_COUNT); }
double ratio () const { return getDouble (RATIO); }
- double percentComplete () const { return haveTotal() / (double)totalSize(); }
+ double percentComplete () const { return haveTotal() / static_cast<double> (totalSize()); }
double percentDone () const { return getDouble (PERCENT_DONE); }
double metadataPercentDone () const { return getDouble (METADATA_PERCENT_DONE); }
uint64_t downloadedEver () const { return getSize (DOWNLOADED_EVER); }
bool honorsSessionLimits () const { return getBool (HONORS_SESSION_LIMITS); }
int peerLimit () const { return getInt (PEER_LIMIT); }
double seedRatioLimit () const { return getDouble (SEED_RATIO_LIMIT); }
- tr_ratiolimit seedRatioMode () const { return (tr_ratiolimit) getInt (SEED_RATIO_MODE); }
+ tr_ratiolimit seedRatioMode () const { return static_cast<tr_ratiolimit> (getInt (SEED_RATIO_MODE)); }
int seedIdleLimit () const { return getInt (SEED_IDLE_LIMIT); }
- tr_idlelimit seedIdleMode () const { return (tr_idlelimit) getInt (SEED_IDLE_MODE); }
+ tr_idlelimit seedIdleMode () const { return static_cast<tr_idlelimit> (getInt (SEED_IDLE_MODE)); }
TrackerStatsList trackerStats () const{ return myValues[TRACKERSTATS].value<TrackerStatsList>(); }
QStringList trackers() const { return myValues[TRACKERS].value<QStringList>(); }
QStringList hosts() const { return myValues[HOSTS].value<QStringList>(); }
public:
QString activityString () const;
- tr_torrent_activity getActivity () const { return (tr_torrent_activity) getInt (ACTIVITY); }
+ tr_torrent_activity getActivity () const { return static_cast<tr_torrent_activity> (getInt (ACTIVITY)); }
bool isFinished () const { return getBool (IS_FINISHED); }
bool isPaused () const { return getActivity () == TR_STATUS_STOPPED; }
bool isWaitingToVerify () const { return getActivity () == TR_STATUS_CHECK_WAIT; }
char * host = NULL;
int port = 0;
tr_urlParse (inf.st.announce.toUtf8().constData(), -1, NULL, &host, &port, NULL);
- str += QString ("%1:%2").arg (host).arg (port);
+ str += QString::fromLatin1 ("%1:%2").arg (host).arg (port);
tr_free (host);
if (!key.isEmpty()) str += " - " + key;
str += inf.st.isBackup ? "</i>" : "</b>";
switch (role)
{
case Qt::DisplayRole:
- var = QString (trackerInfo.st.announce);
+ var = trackerInfo.st.announce;
break;
case Qt::DecorationRole:
const QString filename = fileInfo.fileName ();
SHFILEINFO shellFileInfo;
- if (::SHGetFileInfoW ((const wchar_t*) filename.utf16 (), FILE_ATTRIBUTE_NORMAL,
+ if (::SHGetFileInfoW (reinterpret_cast<const wchar_t*> (filename.utf16 ()), FILE_ATTRIBUTE_NORMAL,
&shellFileInfo, sizeof(shellFileInfo),
SHGFI_ICON | iconSize | SHGFI_USEFILEATTRIBUTES) != 0)
{
}
if (icon.isNull ())
- icon = QApplication::style ()->standardIcon (QStyle::SP_FileIcon);
+ icon = qApp->style ()->standardIcon (QStyle::SP_FileIcon);
return icon;
#else
if (fileIcons[0].isNull ())
{
- fallback = QApplication::style()->standardIcon (QStyle::SP_FileIcon);
+ fallback = qApp->style()->standardIcon (QStyle::SP_FileIcon);
suffixes[DISK] << QString::fromLatin1("iso");
fileIcons[DISK]= QIcon::fromTheme (QString::fromLatin1("media-optical"), fallback);