Changeset 14404


Ignore:
Timestamp:
Dec 27, 2014, 2:07:14 PM (7 years ago)
Author:
mikedld
Message:

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.

Location:
trunk/qt
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/about.cc

    r14399 r14404  
    2525  ui.setupUi (this);
    2626
    27   ui.iconLabel->setPixmap (QApplication::windowIcon ().pixmap (48));
     27  ui.iconLabel->setPixmap (qApp->windowIcon ().pixmap (48));
    2828  ui.titleLabel->setText (tr ("<big><b>Transmission %1</b></big>").arg (QString::fromUtf8 (LONG_VERSION_STRING)));
    2929
  • trunk/qt/add-data.cc

    r14394 r14404  
    103103          tr_info inf;
    104104          tr_ctor * ctor = tr_ctorNew (NULL);
    105           tr_ctorSetMetainfo (ctor, (const quint8*)metainfo.constData(), metainfo.size());
     105          tr_ctorSetMetainfo (ctor, reinterpret_cast<const quint8*> (metainfo.constData()), metainfo.size());
    106106          if (tr_torrentParse (ctor, &inf) == TR_PARSE_OK )
    107107            {
  • trunk/qt/app.cc

    r14396 r14404  
    154154  const char * configDir = 0;
    155155  QStringList filenames;
    156   while ((c = tr_getopt (getUsage(), argc, (const char**)argv, opts, &optarg)))
     156  while ((c = tr_getopt (getUsage(), argc, const_cast<const char**> (argv), opts, &optarg)))
    157157    {
    158158      switch (c)
     
    372372        {
    373373#if defined (Q_OS_WIN) || defined (Q_OS_MAC)
    374           QApplication::beep ();
     374          beep ();
    375375#else
    376376          QProcess::execute (myPrefs->getString (Prefs::COMPLETE_SOUND_COMMAND));
     
    534534MyApp::raise ()
    535535{
    536   QApplication::alert (myWindow);
     536  alert (myWindow);
    537537}
    538538
     
    553553  args.append (QStringList ());                       // actions - unused for plain passive popups
    554554  args.append (QVariantMap ());                       // hints - unused atm
    555   args.append (int32_t (-1));                          // use the default timeout period
     555  args.append (static_cast<int32_t> (-1));            // use the default timeout period
    556556  m.setArguments (args);
    557557  QDBusMessage replyMsg = QDBusConnection::sessionBus ().call (m);
  • trunk/qt/app.h

    r14379 r14404  
    7070};
    7171
     72#undef qApp
     73#define qApp static_cast<MyApp*> (MyApp::instance ())
     74
    7275#endif
  • trunk/qt/details.cc

    r14397 r14404  
    483483    string = none;
    484484  else
    485     string = QString ("%1%").arg (Formatter::percentToString ( (100.0 * available) / sizeWhenDone));
     485    string = QString::fromLatin1 ("%1%").arg (Formatter::percentToString ( (100.0 * available) / sizeWhenDone));
    486486  ui.availabilityValueLabel->setText (string);
    487487
     
    901901
    902902              if (!txt.isEmpty ())
    903                 codeTip += QString ("%1: %2\n").arg (ch).arg (txt);
     903                codeTip += QString::fromLatin1 ("%1: %2\n").arg (ch).arg (txt);
    904904            }
    905905
     
    909909          item->setText (COL_UP, peer.rateToPeer.isZero () ? "" : Formatter::speedToString (peer.rateToPeer));
    910910          item->setText (COL_DOWN, peer.rateToClient.isZero () ? "" : Formatter::speedToString (peer.rateToClient));
    911           item->setText (COL_PERCENT, peer.progress > 0 ? QString ("%1%").arg ( (int) (peer.progress * 100.0)) : "");
     911          item->setText (COL_PERCENT, peer.progress > 0 ? QString::fromLatin1 ("%1%").arg ( (int) (peer.progress * 100.0)) : "");
    912912          item->setText (COL_STATUS, code);
    913913          item->setToolTip (COL_STATUS, codeTip);
  • trunk/qt/file-tree.cc

    r14394 r14404  
    159159    {
    160160      if (childCount () > 0)
    161         value = QApplication::style ()->standardIcon (QStyle::SP_DirOpenIcon);
     161        value = qApp->style ()->standardIcon (QStyle::SP_DirOpenIcon);
    162162      else
    163163        value = Utils::guessMimeIcon (name ());
     
    816816    }
    817817
    818   QStyle * style (QApplication::style ());
     818  QStyle * style (qApp->style ());
    819819
    820820  painter->save();
     
    825825      QStyleOptionProgressBar p;
    826826      p.state = option.state | QStyle::State_Small;
    827       p.direction = QApplication::layoutDirection();
     827      p.direction = qApp->layoutDirection();
    828828      p.rect = option.rect;
    829829      p.rect.setSize (QSize(option.rect.width()-2, option.rect.height()-8));
    830830      p.rect.moveCenter (option.rect.center());
    831       p.fontMetrics = QApplication::fontMetrics();
     831      p.fontMetrics = qApp->fontMetrics();
    832832      p.minimum = 0;
    833833      p.maximum = 100;
     
    842842      QStyleOptionButton o;
    843843      o.state = option.state;
    844       o.direction = QApplication::layoutDirection();
     844      o.direction = qApp->layoutDirection();
    845845      o.rect.setSize (QSize(20, option.rect.height()));
    846846      o.rect.moveCenter (option.rect.center());
    847       o.fontMetrics = QApplication::fontMetrics();
     847      o.fontMetrics = qApp->fontMetrics();
    848848      switch (index.data().toInt())
    849849        {
     
    949949  if ((o == this) && (event->type() == QEvent::Resize))
    950950    {
    951       QResizeEvent * r = dynamic_cast<QResizeEvent*>(event);
     951      QResizeEvent * r = static_cast<QResizeEvent*> (event);
    952952      int left = r->size().width();
    953953      const QFontMetrics fontMetrics(font());
  • trunk/qt/filterbar.cc

    r14394 r14404  
    358358FilterBar::refreshTrackers ()
    359359{
    360   Favicons& favicons = dynamic_cast<MyApp*> (QApplication::instance ())->favicons;
     360  Favicons& favicons = qApp->favicons;
    361361  const int firstTrackerRow = 2; // skip over the "All" and separator...
    362362
     
    484484{
    485485  QHBoxLayout * h = new QHBoxLayout (this);
    486   const int hmargin = qMax (int (HIG::PAD), style ()->pixelMetric (QStyle::PM_LayoutHorizontalSpacing));
     486  const int hmargin = qMax (static_cast<int> (HIG::PAD), style ()->pixelMetric (QStyle::PM_LayoutHorizontalSpacing));
    487487
    488488  myCountLabel = new QLabel (this);
     
    654654FilterBar::getCountString (int n) const
    655655{
    656   return QString ("%L1").arg (n);
     656  return QString::fromLatin1 ("%L1").arg (n);
    657657}
    658658
  • trunk/qt/formatter.cc

    r14394 r14404  
    7676Speed::KBps () const
    7777{
    78   return _Bps / (double)speed_K;
     78  return _Bps / static_cast<double> (speed_K);
    7979}
    8080
     
    8282Speed::fromKBps (double KBps)
    8383{
    84   return int (KBps * speed_K);
     84  return static_cast<int> (KBps * speed_K);
    8585}
    8686
     
    145145{
    146146  char buf[128];
    147   return QString (tr_strpercent (buf, x, sizeof (buf)));
     147  return QString::fromUtf8 (tr_strpercent (buf, x, sizeof (buf)));
    148148}
    149149
  • trunk/qt/mainwin.cc

    r14402 r14404  
    189189  connect (&myFilterModel, SIGNAL (rowsRemoved (QModelIndex, int, int)), this, SLOT (refreshActionSensitivitySoon ()));
    190190
    191   connect (ui.action_Quit, SIGNAL (triggered ()), QCoreApplication::instance (), SLOT (quit ()));
     191  connect (ui.action_Quit, SIGNAL (triggered ()), qApp, SLOT (quit ()));
    192192
    193193  // torrent view
     
    231231  menu->addAction (ui.action_Quit);
    232232  myTrayIcon.setContextMenu (menu);
    233   myTrayIcon.setIcon (QIcon::fromTheme ("transmission-tray-icon", QApplication::windowIcon ()));
     233  myTrayIcon.setIcon (QIcon::fromTheme ("transmission-tray-icon", qApp->windowIcon ()));
    234234
    235235  connect (&myPrefs, SIGNAL (changed (int)), this, SLOT (refreshPref (int)));
     
    943943      //activateWindow ();
    944944      raise ();
    945       QApplication::setActiveWindow (this);
     945      qApp->setActiveWindow (this);
    946946    }
    947947}
     
    10421042        ui.action_TrayIcon->setChecked (b);
    10431043        myTrayIcon.setVisible (b);
    1044         dynamic_cast<MyApp*> (QCoreApplication::instance ())->setQuitOnLastWindowClosed (!b);
     1044        qApp->setQuitOnLastWindowClosed (!b);
    10451045        refreshTrayIconSoon ();
    10461046        break;
     
    11181118  b->setChecked (myPrefs.getBool (Prefs::OPTIONS_PROMPT));
    11191119  b->setObjectName (SHOW_OPTIONS_CHECKBOX_NAME);
    1120   auto l = dynamic_cast<QGridLayout*> (d->layout ());
     1120  auto l = qobject_cast<QGridLayout*> (d->layout ());
    11211121  if (l == nullptr)
    11221122    {
     
    11351135TrMainWindow::openURL ()
    11361136{
    1137   QString str = QApplication::clipboard ()->text (QClipboard::Selection);
     1137  QString str = qApp->clipboard ()->text (QClipboard::Selection);
    11381138
    11391139  if (!AddData::isSupported (str))
    1140     str = QApplication::clipboard ()->text (QClipboard::Clipboard);
     1140    str = qApp->clipboard ()->text (QClipboard::Clipboard);
    11411141
    11421142  if (!AddData::isSupported (str))
     
    11701170      Options * o = new Options (mySession, myPrefs, addMe, this);
    11711171      o->show ();
    1172       QApplication::alert (o);
     1172      qApp->alert (o);
    11731173    }
    11741174  else
    11751175    {
    11761176      mySession.addTorrent (addMe);
    1177       QApplication::alert (this);
     1177      qApp->alert (this);
    11781178    }
    11791179}
     
    12591259    }
    12601260
    1261   msgBox.setWindowTitle (QString (" "));
    1262   msgBox.setText (QString ("<big><b>%1</big></b>").arg (primary_text));
     1261  msgBox.setWindowTitle (QLatin1String (" "));
     1262  msgBox.setText (QString::fromLatin1 ("<big><b>%1</big></b>").arg (primary_text));
    12631263  msgBox.setInformativeText (secondary_text);
    12641264  msgBox.setStandardButtons (QMessageBox::Ok | QMessageBox::Cancel);
     
    12661266  msgBox.setIcon (QMessageBox::Question);
    12671267  // hack needed to keep the dialog from being too narrow
    1268   auto layout = dynamic_cast<QGridLayout*>(msgBox.layout());
     1268  auto layout = qobject_cast<QGridLayout*> (msgBox.layout ());
    12691269  if (layout == nullptr)
    12701270    {
     
    14181418            key = QUrl::fromPercentEncoding (url.path().toUtf8());
    14191419
    1420           dynamic_cast<MyApp*> (QApplication::instance ())->addTorrent (key);
     1420          qApp->addTorrent (key);
    14211421        }
    14221422    }
  • trunk/qt/make-dialog.cc

    r14394 r14404  
    7777  const tr_metainfo_builder * b = myBuilder;
    7878  const double denom = b->pieceCount ? b->pieceCount : 1;
    79   myNewProgress->setValue ((int) ((100.0 * b->pieceIndex) / denom));
     79  myNewProgress->setValue (static_cast<int> ((100.0 * b->pieceIndex) / denom));
    8080
    8181  // progress label
  • trunk/qt/options.cc

    r14403 r14404  
    238238    {
    239239      if (o == mySourceButton)
    240         refreshSource (dynamic_cast<QResizeEvent*> (event)->size ().width ());
     240        refreshSource (static_cast<QResizeEvent*> (event)->size ().width ());
    241241
    242242      else if (o == myDestinationButton)
    243         refreshDestinationButton (dynamic_cast<QResizeEvent*> (event)->size ().width ());
     243        refreshDestinationButton (static_cast<QResizeEvent*> (event)->size ().width ());
    244244    }
    245245
     
    530530  int64_t leftInFile = file->length - myVerifyFilePos;
    531531  int64_t bytesThisPass = std::min (leftInFile, leftInPiece);
    532   bytesThisPass = std::min (bytesThisPass, (int64_t)sizeof (myVerifyBuf));
     532  bytesThisPass = std::min (bytesThisPass, static_cast<int64_t> (sizeof (myVerifyBuf)));
    533533
    534534  if (myVerifyFile.isOpen () && myVerifyFile.seek (myVerifyFilePos))
     
    589589        {
    590590          // did the user accidentally specify the child directory instead of the parent?
    591           const QStringList tokens = QString (file->name).split ('/');
     591          const QStringList tokens = QString::fromUtf8 (file->name).split ('/');
    592592          if (!tokens.empty () && myLocalDestination.dirName ()==tokens.at (0))
    593593            {
  • trunk/qt/prefs.cc

    r14394 r14404  
    158158          case QVariant::Int:
    159159            if (tr_variantGetInt (b, &intVal))
    160               myValues[i].setValue (qlonglong(intVal));
     160              myValues[i].setValue (static_cast<qlonglong> (intVal));
    161161            break;
    162162
     
    178178          case QVariant::Bool:
    179179            if (tr_variantGetBool (b, &boolVal))
    180               myValues[i].setValue (bool(boolVal));
     180              myValues[i].setValue (static_cast<bool> (boolVal));
    181181            break;
    182182
  • trunk/qt/prefs.h

    r14378 r14404  
    168168    template<typename T> T get (int key) const { return myValues[key].value<T>(); }
    169169
    170     void set (int key, char * value) { set (key, QString::fromUtf8 (value)); }
    171170    void set (int key, const char * value) { set (key, QString::fromUtf8 (value)); }
    172171
  • trunk/qt/session.cc

    r14395 r14404  
    105105          const QString myFilename = QFileInfo (myName).fileName ();
    106106          const QString name = QString::fromUtf8 (str);
    107           QMessageBox::warning (QApplication::activeWindow (),
     107          QMessageBox::warning (qApp->activeWindow (),
    108108                                tr ("Add Torrent"),
    109109                                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));
     
    125125          text[i] = text[i].toUpper ();
    126126
    127       QMessageBox::warning (QApplication::activeWindow (),
     127      QMessageBox::warning (qApp->activeWindow (),
    128128                            tr ("Error Adding Torrent"),
    129                             QString ("<p><b>%1</b></p><p>%2</p>").arg (text).arg (myName));
     129                            QString::fromLatin1 ("<p><b>%1</b></p><p>%2</p>").arg (text).arg (myName));
    130130    }
    131131
     
    720720  /* this callback is invoked in the libtransmission thread, so we don't want
    721721     to process the response here... let's push it over to the Qt thread. */
    722   self->responseReceived (QByteArray ( (const char *)evbuffer_pullup (json, -1),
    723                                      (int)evbuffer_get_length (json)));
     722  self->responseReceived (QByteArray (reinterpret_cast<const char *> (evbuffer_pullup (json, -1)),
     723                                      static_cast<int> (evbuffer_get_length (json))));
    724724}
    725725
     
    737737      QNetworkRequest request;
    738738      request.setUrl (myUrl);
    739       request.setRawHeader ("User-Agent", QString (QCoreApplication::instance ()->applicationName () + "/" + LONG_VERSION_STRING).toUtf8 ());
     739      request.setRawHeader ("User-Agent", (qApp->applicationName () + "/" + LONG_VERSION_STRING).toUtf8 ());
    740740      request.setRawHeader ("Content-Type", "application/json; charset=UTF-8");
    741741
     
    780780        // we got a 409 telling us our session id has expired.
    781781        // update it and resubmit the request.
    782         mySessionId = QString (reply->rawHeader (TR_RPC_SESSION_ID_HEADER));
     782        mySessionId = QString::fromUtf8 (reply->rawHeader (TR_RPC_SESSION_ID_HEADER));
    783783        exec (reply->property (REQUEST_DATA_PROPERTY_KEY).toByteArray ().constData ());
    784784    }
     
    872872                        QMessageBox * d = new QMessageBox (QMessageBox::Information, title, text,
    873873                                                           QMessageBox::Close,
    874                                                            QApplication::activeWindow ());
     874                                                           qApp->activeWindow ());
    875875                        connect (d, SIGNAL (rejected ()), d, SLOT (deleteLater ()));
    876876                        d->show ();
     
    880880                        // let's get the updated file list
    881881                        char * req = tr_strdup_printf ("{ \"arguments\": { \"fields\": [ \"fileStats\", \"files\", \"id\", \"name\" ], \"ids\": %d }, \"method\": \"torrent-get\", \"tag\": %d }",
    882                                                        int (id),
    883                                                        int (TAG_SOME_TORRENTS));
     882                                                       static_cast<int> (id),
     883                                                       static_cast<int> (TAG_SOME_TORRENTS));
    884884                        exec (req);
    885885                        tr_free (req);
     
    890890
    891891                case TAG_PORT_TEST: {
    892                     bool isOpen = 0;
     892                    bool isOpen = false;
    893893                    if (tr_variantDictFindDict (&top, TR_KEY_arguments, &args))
    894894                        tr_variantDictFindBool (args, TR_KEY_port_is_open, &isOpen);
    895                     emit portTested ( (bool)isOpen);
     895                    emit portTested (isOpen);
    896896                    break;
    897897                }
     
    906906                        && ( (child = tr_variantListChild (torrents, 0)))
    907907                        && tr_variantDictFindStr (child, TR_KEY_magnetLink, &str, NULL))
    908                             QApplication::clipboard ()->setText (str);
     908                            qApp->clipboard ()->setText (str);
    909909                    break;
    910910                }
     
    917917                                                           QString::fromUtf8 (str),
    918918                                                           QMessageBox::Close,
    919                                                            QApplication::activeWindow ());
     919                                                           qApp->activeWindow ());
    920920                        connect (d, SIGNAL (rejected ()), d, SLOT (deleteLater ()));
    921921                        d->show ();
     
    10001000              int64_t val;
    10011001              if (tr_variantGetInt (b, &val))
    1002                 myPrefs.set (i, (int)val);
     1002                myPrefs.set (i, static_cast<int>(val));
    10031003              break;
    10041004            }
     
    10141014              bool val;
    10151015              if (tr_variantGetBool (b, &val))
    1016                 myPrefs.set (i, (bool)val);
     1016                myPrefs.set (i, val);
    10171017              break;
    10181018            }
     
    10231023              const char * val;
    10241024              if (tr_variantGetStr (b, &val, NULL))
    1025                 myPrefs.set (i, QString (val));
     1025                myPrefs.set (i, QString::fromUtf8 (val));
    10261026              break;
    10271027            }
     
    10341034  double x;
    10351035  if (tr_variantDictFindBool (d, TR_KEY_seedRatioLimited, &b))
    1036     myPrefs.set (Prefs::RATIO_ENABLED, b ? true : false);
     1036    myPrefs.set (Prefs::RATIO_ENABLED, b);
    10371037  if (tr_variantDictFindReal (d, TR_KEY_seedRatioLimit, &x))
    10381038    myPrefs.set (Prefs::RATIO, x);
  • trunk/qt/torrent-delegate-min.cc

    r14394 r14404  
    4848                              const Torrent              & tor) const
    4949{
    50   const QStyle* style (QApplication::style());
     50  const QStyle* style (qApp->style());
    5151  static const int iconSize (style->pixelMetric (QStyle::PM_SmallIconSize));
    5252
     
    5858
    5959  QFont statusFont (option.font);
    60   statusFont.setPointSize (int (option.font.pointSize() * 0.85));
     60  statusFont.setPointSize (static_cast<int> (option.font.pointSize() * 0.85));
    6161  const QFontMetrics statusFM (statusFont);
    6262  const QString statusStr (shortStatusString (tor));
     
    7777{
    7878  const bool isPaused (tor.isPaused());
    79   const QStyle * style (QApplication::style());
     79  const QStyle * style (qApp->style());
    8080  static const int iconSize (style->pixelMetric (QStyle::PM_SmallIconSize));
    8181
     
    8686
    8787  QFont statusFont (option.font);
    88   statusFont.setPointSize (int (option.font.pointSize() * 0.85));
     88  statusFont.setPointSize (static_cast<int> (option.font.pointSize() * 0.85));
    8989  const QFontMetrics statusFM (statusFont);
    9090  const QString statusStr (shortStatusString (tor));
  • trunk/qt/torrent-delegate.cc

    r14394 r14404  
    291291TorrentDelegate::sizeHint (const QStyleOptionViewItem& option, const Torrent& tor) const
    292292{
    293   const QStyle* style (QApplication::style ());
     293  const QStyle* style (qApp->style ());
    294294  static const int iconSize (style->pixelMetric (QStyle::PM_MessageBoxIconSize));
    295295
     
    300300  const int nameWidth = nameFM.width (nameStr);
    301301  QFont statusFont (option.font);
    302   statusFont.setPointSize (int (option.font.pointSize () * 0.9));
     302  statusFont.setPointSize (static_cast<int> (option.font.pointSize () * 0.9));
    303303  const QFontMetrics statusFM (statusFont);
    304304  const QString statusStr (statusString (tor));
     
    349349      const bool isMagnet (!tor.hasMetadata ());
    350350      myProgressBarStyle->direction = option.direction;
    351       myProgressBarStyle->progress = int(myProgressBarStyle->minimum + (((isMagnet ? tor.metadataPercentDone() : tor.percentDone()) * (myProgressBarStyle->maximum - myProgressBarStyle->minimum))));
     351      myProgressBarStyle->progress = static_cast<int> (myProgressBarStyle->minimum + (((isMagnet ? tor.metadataPercentDone() : tor.percentDone()) * (myProgressBarStyle->maximum - myProgressBarStyle->minimum))));
    352352    }
    353353}
     
    358358                              const Torrent              & tor) const
    359359{
    360   const QStyle * style (QApplication::style ());
     360  const QStyle * style (qApp->style ());
    361361  static const int iconSize (style->pixelMetric (QStyle::PM_LargeIconSize));
    362362  QFont nameFont (option.font);
     
    366366  const QSize nameSize (nameFM.size (0, nameStr));
    367367  QFont statusFont (option.font);
    368   statusFont.setPointSize (int (option.font.pointSize () * 0.9));
     368  statusFont.setPointSize (static_cast<int> (option.font.pointSize () * 0.9));
    369369  const QFontMetrics statusFM (statusFont);
    370370  const QString statusStr (progressString (tor));
  • trunk/qt/torrent.cc

    r14394 r14404  
    4040
    4141  setInt (ID, id);
    42   setIcon (MIME_ICON, QApplication::style()->standardIcon (QStyle::SP_FileIcon));
     42  setIcon (MIME_ICON, qApp->style()->standardIcon (QStyle::SP_FileIcon));
    4343}
    4444
     
    394394  const double a = ratio ();
    395395  const double b = that.ratio ();
    396   if ((int)a == TR_RATIO_INF && (int)b == TR_RATIO_INF) return 0;
    397   if ((int)a == TR_RATIO_INF) return 1;
    398   if ((int)b == TR_RATIO_INF) return -1;
     396  if (static_cast<int> (a) == TR_RATIO_INF && static_cast<int> (b) == TR_RATIO_INF) return 0;
     397  if (static_cast<int> (a) == TR_RATIO_INF) return 1;
     398  if (static_cast<int> (b) == TR_RATIO_INF) return -1;
    399399  if (a < b) return -1;
    400400  if (a > b) return 1;
     
    606606          if (tr_variantDictFindStr(child, TR_KEY_announce, &str, &len))
    607607            {
    608               dynamic_cast<MyApp*>(QApplication::instance())->favicons.add (QUrl(QString::fromUtf8(str)));
     608              qApp->favicons.add (QUrl(QString::fromUtf8(str)));
    609609              list.append (QString::fromUtf8 (str, len));
    610610            }
     
    646646            {
    647647              trackerStat.announce = QString::fromUtf8 (str, len);
    648               dynamic_cast<MyApp*>(QApplication::instance())->favicons.add (QUrl (trackerStat.announce));
     648              qApp->favicons.add (QUrl (trackerStat.announce));
    649649            }
    650650
     
    802802TrackerStat::getFavicon () const
    803803{
    804   MyApp * myApp = dynamic_cast<MyApp*>(QApplication::instance());
    805   return myApp->favicons.find (QUrl (announce));
    806 }
    807 
     804  return qApp->favicons.find (QUrl (announce));
     805}
     806
  • trunk/qt/torrent.h

    r14370 r14404  
    268268    int  pieceCount () const { return getInt (PIECE_COUNT); }
    269269    double ratio () const { return getDouble (RATIO); }
    270     double percentComplete () const { return haveTotal() / (double)totalSize(); }
     270    double percentComplete () const { return haveTotal() / static_cast<double> (totalSize()); }
    271271    double percentDone () const { return getDouble (PERCENT_DONE); }
    272272    double metadataPercentDone () const { return getDouble (METADATA_PERCENT_DONE); }
     
    304304    int peerLimit () const { return getInt (PEER_LIMIT); }
    305305    double seedRatioLimit () const { return getDouble (SEED_RATIO_LIMIT); }
    306     tr_ratiolimit seedRatioMode () const { return (tr_ratiolimit) getInt (SEED_RATIO_MODE); }
     306    tr_ratiolimit seedRatioMode () const { return static_cast<tr_ratiolimit> (getInt (SEED_RATIO_MODE)); }
    307307    int seedIdleLimit () const { return getInt (SEED_IDLE_LIMIT); }
    308     tr_idlelimit seedIdleMode () const { return (tr_idlelimit) getInt (SEED_IDLE_MODE); }
     308    tr_idlelimit seedIdleMode () const { return static_cast<tr_idlelimit> (getInt (SEED_IDLE_MODE)); }
    309309    TrackerStatsList trackerStats () const{ return myValues[TRACKERSTATS].value<TrackerStatsList>(); }
    310310    QStringList trackers() const { return myValues[TRACKERS].value<QStringList>(); }
     
    317317  public:
    318318    QString activityString () const;
    319     tr_torrent_activity getActivity () const { return (tr_torrent_activity) getInt (ACTIVITY); }
     319    tr_torrent_activity getActivity () const { return static_cast<tr_torrent_activity> (getInt (ACTIVITY)); }
    320320    bool isFinished () const { return getBool (IS_FINISHED); }
    321321    bool isPaused () const { return getActivity () == TR_STATUS_STOPPED; }
  • trunk/qt/tracker-delegate.cc

    r14394 r14404  
    145145  int port = 0;
    146146  tr_urlParse (inf.st.announce.toUtf8().constData(), -1, NULL, &host, &port, NULL);
    147   str += QString ("%1:%2").arg (host).arg (port);
     147  str += QString::fromLatin1 ("%1:%2").arg (host).arg (port);
    148148  tr_free (host);
    149149  if (!key.isEmpty()) str += " - " + key;
  • trunk/qt/tracker-model.cc

    r14394 r14404  
    3737        {
    3838          case Qt::DisplayRole:
    39             var = QString (trackerInfo.st.announce);
     39            var = trackerInfo.st.announce;
    4040            break;
    4141
  • trunk/qt/utils.cc

    r14394 r14404  
    8383
    8484        SHFILEINFO shellFileInfo;
    85         if (::SHGetFileInfoW ((const wchar_t*) filename.utf16 (), FILE_ATTRIBUTE_NORMAL,
     85        if (::SHGetFileInfoW (reinterpret_cast<const wchar_t*> (filename.utf16 ()), FILE_ATTRIBUTE_NORMAL,
    8686                              &shellFileInfo, sizeof(shellFileInfo),
    8787                              SHGFI_ICON | iconSize | SHGFI_USEFILEATTRIBUTES) != 0)
     
    123123
    124124  if (icon.isNull ())
    125     icon = QApplication::style ()->standardIcon (QStyle::SP_FileIcon);
     125    icon = qApp->style ()->standardIcon (QStyle::SP_FileIcon);
    126126
    127127  return icon;
     
    134134  if (fileIcons[0].isNull ())
    135135    {
    136       fallback = QApplication::style()->standardIcon (QStyle::SP_FileIcon);
     136      fallback = qApp->style()->standardIcon (QStyle::SP_FileIcon);
    137137
    138138      suffixes[DISK] << QString::fromLatin1("iso");
Note: See TracChangeset for help on using the changeset viewer.