A bit of harmless refactoring
Prefer C++-style over C-style type casting. Use qApp instead of QApplication/QCoreApplication::instance(). Use explicit QString::fromLatin1()/fromUtf8() where applicable.
This commit is contained in:
parent
2ca4596fac
commit
17d6666b4c
|
@ -24,7 +24,7 @@ AboutDialog::AboutDialog (QWidget * parent):
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -102,7 +102,7 @@ AddData::readableName () const
|
|||
{
|
||||
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
|
||||
|
|
|
@ -153,7 +153,7 @@ MyApp::MyApp (int& argc, char ** argv):
|
|||
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)
|
||||
{
|
||||
|
@ -371,7 +371,7 @@ MyApp::onTorrentCompleted (int id)
|
|||
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
|
||||
|
@ -533,7 +533,7 @@ MyApp::addTorrent (const AddData& addme)
|
|||
void
|
||||
MyApp::raise ()
|
||||
{
|
||||
QApplication::alert (myWindow);
|
||||
alert (myWindow);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -552,7 +552,7 @@ MyApp::notifyApp (const QString& title, const QString& body) const
|
|||
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;
|
||||
|
|
3
qt/app.h
3
qt/app.h
|
@ -69,4 +69,7 @@ class MyApp: public QApplication
|
|||
void maybeUpdateBlocklist ();
|
||||
};
|
||||
|
||||
#undef qApp
|
||||
#define qApp static_cast<MyApp*> (MyApp::instance ())
|
||||
|
||||
#endif
|
||||
|
|
|
@ -482,7 +482,7 @@ Details::refresh ()
|
|||
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
|
||||
|
@ -900,7 +900,7 @@ Details::refresh ()
|
|||
}
|
||||
|
||||
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 ())
|
||||
|
@ -908,7 +908,7 @@ Details::refresh ()
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ FileTreeItem::data (int column, int role) const
|
|||
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 ());
|
||||
}
|
||||
|
@ -815,7 +815,7 @@ FileTreeDelegate::paint (QPainter * painter,
|
|||
return;
|
||||
}
|
||||
|
||||
QStyle * style (QApplication::style ());
|
||||
QStyle * style (qApp->style ());
|
||||
|
||||
painter->save();
|
||||
QItemDelegate::drawBackground (painter, option, index);
|
||||
|
@ -824,11 +824,11 @@ FileTreeDelegate::paint (QPainter * painter,
|
|||
{
|
||||
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;
|
||||
|
@ -841,10 +841,10 @@ FileTreeDelegate::paint (QPainter * painter,
|
|||
{
|
||||
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;
|
||||
|
@ -948,7 +948,7 @@ FileTreeView::eventFilter (QObject * o, QEvent * event)
|
|||
// 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)
|
||||
|
|
|
@ -357,7 +357,7 @@ namespace
|
|||
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...
|
||||
|
@ -483,7 +483,7 @@ FilterBar::FilterBar (Prefs& prefs, TorrentModel& torrents, TorrentFilter& filte
|
|||
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);
|
||||
|
@ -653,7 +653,7 @@ FilterBar::recount ()
|
|||
QString
|
||||
FilterBar::getCountString (int n) const
|
||||
{
|
||||
return QString ("%L1").arg (n);
|
||||
return QString::fromLatin1 ("%L1").arg (n);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -75,13 +75,13 @@ Formatter::initUnits ()
|
|||
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);
|
||||
}
|
||||
|
||||
/***
|
||||
|
@ -144,7 +144,7 @@ QString
|
|||
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
|
||||
|
|
|
@ -188,7 +188,7 @@ TrMainWindow::TrMainWindow (Session& session, Prefs& prefs, TorrentModel& model,
|
|||
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);
|
||||
|
@ -230,7 +230,7 @@ TrMainWindow::TrMainWindow (Session& session, Prefs& prefs, TorrentModel& model,
|
|||
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)));
|
||||
|
@ -942,7 +942,7 @@ TrMainWindow::toggleWindows (bool doShow)
|
|||
if (isMinimized ()) showNormal ();
|
||||
//activateWindow ();
|
||||
raise ();
|
||||
QApplication::setActiveWindow (this);
|
||||
qApp->setActiveWindow (this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1041,7 +1041,7 @@ TrMainWindow::refreshPref (int key)
|
|||
b = myPrefs.getBool (key);
|
||||
ui.action_TrayIcon->setChecked (b);
|
||||
myTrayIcon.setVisible (b);
|
||||
dynamic_cast<MyApp*> (QCoreApplication::instance ())->setQuitOnLastWindowClosed (!b);
|
||||
qApp->setQuitOnLastWindowClosed (!b);
|
||||
refreshTrayIconSoon ();
|
||||
break;
|
||||
|
||||
|
@ -1117,7 +1117,7 @@ TrMainWindow::openTorrent ()
|
|||
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;
|
||||
|
@ -1134,10 +1134,10 @@ TrMainWindow::openTorrent ()
|
|||
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 ();
|
||||
|
@ -1169,12 +1169,12 @@ TrMainWindow::addTorrent (const AddData& addMe, bool showOptions)
|
|||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1258,14 +1258,14 @@ TrMainWindow::removeTorrents (const bool deleteFiles)
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -1417,7 +1417,7 @@ TrMainWindow::dropEvent (QDropEvent * event)
|
|||
if (url.scheme () == "file")
|
||||
key = QUrl::fromPercentEncoding (url.path().toUtf8());
|
||||
|
||||
dynamic_cast<MyApp*> (QApplication::instance ())->addTorrent (key);
|
||||
qApp->addTorrent (key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ MakeDialog::onProgress ()
|
|||
// 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);
|
||||
|
|
|
@ -237,10 +237,10 @@ Options::eventFilter (QObject * o, QEvent * event)
|
|||
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;
|
||||
|
@ -529,7 +529,7 @@ Options::onTimeout ()
|
|||
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))
|
||||
{
|
||||
|
@ -588,7 +588,7 @@ Options::onTimeout ()
|
|||
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
|
||||
|
|
|
@ -157,7 +157,7 @@ Prefs::Prefs (const char * configDir):
|
|||
{
|
||||
case QVariant::Int:
|
||||
if (tr_variantGetInt (b, &intVal))
|
||||
myValues[i].setValue (qlonglong(intVal));
|
||||
myValues[i].setValue (static_cast<qlonglong> (intVal));
|
||||
break;
|
||||
|
||||
case TrTypes::SortModeType:
|
||||
|
@ -177,7 +177,7 @@ Prefs::Prefs (const char * configDir):
|
|||
|
||||
case QVariant::Bool:
|
||||
if (tr_variantGetBool (b, &boolVal))
|
||||
myValues[i].setValue (bool(boolVal));
|
||||
myValues[i].setValue (static_cast<bool> (boolVal));
|
||||
break;
|
||||
|
||||
case QVariant::Double:
|
||||
|
|
|
@ -167,7 +167,6 @@ class Prefs: public QObject
|
|||
|
||||
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)
|
||||
|
|
|
@ -104,7 +104,7 @@ FileAdded::executed (int64_t tag, const QString& result, tr_variant * arguments)
|
|||
{
|
||||
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));
|
||||
}
|
||||
|
@ -124,9 +124,9 @@ FileAdded::executed (int64_t tag, const QString& result, tr_variant * arguments)
|
|||
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 ();
|
||||
|
@ -719,8 +719,8 @@ Session::localSessionCallback (tr_session * s, evbuffer * json, void * vself)
|
|||
|
||||
/* 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"
|
||||
|
@ -736,7 +736,7 @@ Session::exec (const char * json)
|
|||
{
|
||||
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 ())
|
||||
|
@ -779,7 +779,7 @@ Session::onFinished (QNetworkReply * reply)
|
|||
{
|
||||
// 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)
|
||||
|
@ -871,7 +871,7 @@ Session::parseResponse (const char * json, size_t jsonLength)
|
|||
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 ();
|
||||
}
|
||||
|
@ -879,8 +879,8 @@ Session::parseResponse (const char * json, size_t jsonLength)
|
|||
{
|
||||
// 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);
|
||||
}
|
||||
|
@ -889,10 +889,10 @@ Session::parseResponse (const char * json, size_t jsonLength)
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -905,7 +905,7 @@ Session::parseResponse (const char * json, size_t jsonLength)
|
|||
&& 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;
|
||||
}
|
||||
|
||||
|
@ -916,7 +916,7 @@ Session::parseResponse (const char * json, size_t jsonLength)
|
|||
tr ("Add Torrent"),
|
||||
QString::fromUtf8 (str),
|
||||
QMessageBox::Close,
|
||||
QApplication::activeWindow ());
|
||||
qApp->activeWindow ());
|
||||
connect (d, SIGNAL (rejected ()), d, SLOT (deleteLater ()));
|
||||
d->show ();
|
||||
}
|
||||
|
@ -999,7 +999,7 @@ Session::updateInfo (tr_variant * d)
|
|||
{
|
||||
int64_t val;
|
||||
if (tr_variantGetInt (b, &val))
|
||||
myPrefs.set (i, (int)val);
|
||||
myPrefs.set (i, static_cast<int>(val));
|
||||
break;
|
||||
}
|
||||
case QVariant::Double:
|
||||
|
@ -1013,7 +1013,7 @@ Session::updateInfo (tr_variant * d)
|
|||
{
|
||||
bool val;
|
||||
if (tr_variantGetBool (b, &val))
|
||||
myPrefs.set (i, (bool)val);
|
||||
myPrefs.set (i, val);
|
||||
break;
|
||||
}
|
||||
case TrTypes::FilterModeType:
|
||||
|
@ -1022,7 +1022,7 @@ Session::updateInfo (tr_variant * d)
|
|||
{
|
||||
const char * val;
|
||||
if (tr_variantGetStr (b, &val, NULL))
|
||||
myPrefs.set (i, QString (val));
|
||||
myPrefs.set (i, QString::fromUtf8 (val));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1033,7 +1033,7 @@ Session::updateInfo (tr_variant * d)
|
|||
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);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ QSize
|
|||
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);
|
||||
|
@ -57,7 +57,7 @@ TorrentDelegateMin::sizeHint (const QStyleOptionViewItem & option,
|
|||
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);
|
||||
|
@ -76,7 +76,7 @@ TorrentDelegateMin::drawTorrent (QPainter * painter,
|
|||
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);
|
||||
|
@ -85,7 +85,7 @@ TorrentDelegateMin::drawTorrent (QPainter * painter,
|
|||
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));
|
||||
|
|
|
@ -290,7 +290,7 @@ namespace
|
|||
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);
|
||||
|
@ -299,7 +299,7 @@ TorrentDelegate::sizeHint (const QStyleOptionViewItem& option, const Torrent& to
|
|||
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);
|
||||
|
@ -348,7 +348,7 @@ TorrentDelegate::setProgressBarPercentDone (const QStyleOptionViewItem & option,
|
|||
{
|
||||
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))));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ TorrentDelegate::drawTorrent (QPainter * painter,
|
|||
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);
|
||||
|
@ -365,7 +365,7 @@ TorrentDelegate::drawTorrent (QPainter * painter,
|
|||
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);
|
||||
|
|
|
@ -39,7 +39,7 @@ Torrent::Torrent (Prefs& prefs, int id):
|
|||
#endif
|
||||
|
||||
setInt (ID, id);
|
||||
setIcon (MIME_ICON, QApplication::style()->standardIcon (QStyle::SP_FileIcon));
|
||||
setIcon (MIME_ICON, qApp->style()->standardIcon (QStyle::SP_FileIcon));
|
||||
}
|
||||
|
||||
Torrent::~Torrent ()
|
||||
|
@ -393,9 +393,9 @@ Torrent::compareRatio (const Torrent& that) const
|
|||
{
|
||||
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;
|
||||
|
@ -605,7 +605,7 @@ Torrent::update (tr_variant * d)
|
|||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -645,7 +645,7 @@ Torrent::update (tr_variant * d)
|
|||
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))
|
||||
|
@ -801,7 +801,6 @@ Torrent::getError () const
|
|||
QPixmap
|
||||
TrackerStat::getFavicon () const
|
||||
{
|
||||
MyApp * myApp = dynamic_cast<MyApp*>(QApplication::instance());
|
||||
return myApp->favicons.find (QUrl (announce));
|
||||
return qApp->favicons.find (QUrl (announce));
|
||||
}
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ class Torrent: public QObject
|
|||
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); }
|
||||
|
@ -303,9 +303,9 @@ class Torrent: public QObject
|
|||
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>(); }
|
||||
|
@ -316,7 +316,7 @@ class Torrent: public QObject
|
|||
|
||||
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; }
|
||||
|
|
|
@ -144,7 +144,7 @@ TrackerDelegate::getText (const TrackerInfo& inf) const
|
|||
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>";
|
||||
|
|
|
@ -36,7 +36,7 @@ TrackerModel::data (const QModelIndex& index, int role) const
|
|||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
var = QString (trackerInfo.st.announce);
|
||||
var = trackerInfo.st.announce;
|
||||
break;
|
||||
|
||||
case Qt::DecorationRole:
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace
|
|||
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)
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ Utils::guessMimeIcon (const QString& filename)
|
|||
}
|
||||
|
||||
if (icon.isNull ())
|
||||
icon = QApplication::style ()->standardIcon (QStyle::SP_FileIcon);
|
||||
icon = qApp->style ()->standardIcon (QStyle::SP_FileIcon);
|
||||
|
||||
return icon;
|
||||
#else
|
||||
|
@ -133,7 +133,7 @@ Utils::guessMimeIcon (const QString& filename)
|
|||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue