Changeset 14466


Ignore:
Timestamp:
Jan 29, 2015, 9:53:05 PM (6 years ago)
Author:
mikedld
Message:

Define QT_NO_CAST_FROM_ASCII (Qt client)

Use latin1 encoding most of the time where default encoding was used
before. Qt 4 assumes latin1 by default while Qt 5 uses utf-8 which is
not what we want.

Use utf-8 encoding in some places where default encoding was used before.
This includes strings coming from RPC.

Fix an issue with SortMode::names[] (filters.cc) where missing comma
between "sort-by-queue" and "sort-by-ratio" resulted in two array entries
being merged into solid "sort-by-queuesort-by-ratio" string and all the
following items being shifted compared to their enum counterparts.

Location:
trunk/qt
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/CMakeLists.txt

    r14460 r14466  
    165165add_definitions(
    166166    "-DTRANSLATIONS_DIR=\"${CMAKE_INSTALL_FULL_DATADIR}/${TR_NAME}/translations\""
     167    -DQT_NO_CAST_FROM_ASCII
    167168)
    168169
  • trunk/qt/app.cc

    r14464 r14466  
    107107        << QLibraryInfo::location (QLibraryInfo::TranslationsPath)
    108108#ifdef TRANSLATIONS_DIR
    109         << TRANSLATIONS_DIR
     109        << QString::fromUtf8 (TRANSLATIONS_DIR)
    110110#endif
    111         << (applicationDirPath () + "/translations")
     111        << (applicationDirPath () + QLatin1String ("/translations"))
    112112      ))
    113113    installTranslator (&qtTranslator);
     
    116116  if (loadTranslation (appTranslator, MY_CONFIG_NAME, localeName, QStringList ()
    117117#ifdef TRANSLATIONS_DIR
    118         << TRANSLATIONS_DIR
     118        << QString::fromUtf8 (TRANSLATIONS_DIR)
    119119#endif
    120         << (applicationDirPath () + "/translations")
     120        << (applicationDirPath () + QLatin1String ("/translations"))
    121121      ))
    122122    installTranslator (&appTranslator);
     
    126126#if defined (_WIN32) || defined (__APPLE__)
    127127  if (QIcon::themeName ().isEmpty ())
    128     QIcon::setThemeName ("Faenza");
     128    QIcon::setThemeName (QLatin1String ("Faenza"));
    129129#endif
    130130
    131131  // set the default icon
    132   QIcon icon = QIcon::fromTheme ("transmission");
     132  QIcon icon = QIcon::fromTheme (QLatin1String ("transmission"));
    133133  if (icon.isNull ())
    134134    {
     
    136136      sizes << 16 << 22 << 24 << 32 << 48 << 64 << 72 << 96 << 128 << 192 << 256;
    137137      foreach (int size, sizes)
    138         icon.addPixmap (QPixmap (QString::fromUtf8 (":/icons/transmission-%1.png").arg (size)));
     138        icon.addPixmap (QPixmap (QString::fromLatin1 (":/icons/transmission-%1.png").arg (size)));
    139139    }
    140140  setWindowIcon (icon);
     
    193193            case AddData::URL:      arguments.push_back (a.url.toString ()); break;
    194194            case AddData::MAGNET:   arguments.push_back (a.magnet); break;
    195             case AddData::FILENAME: arguments.push_back (a.toBase64 ().constData ()); break;
    196             case AddData::METAINFO: arguments.push_back (a.toBase64 ().constData ()); break;
     195            case AddData::FILENAME: arguments.push_back (QString::fromLatin1 (a.toBase64 ())); break;
     196            case AddData::METAINFO: arguments.push_back (QString::fromLatin1 (a.toBase64 ())); break;
    197197            default:                break;
    198198          }
     
    223223
    224224  // is this the first time we've run transmission?
    225   const bool firstTime = !dir.exists ("settings.json");
     225  const bool firstTime = !dir.exists (QLatin1String ("settings.json"));
    226226
    227227  // initialize the prefs
  • trunk/qt/details.cc

    r14458 r14466  
    870870      foreach (const Peer& peer, peers)
    871871        {
    872           const QString key = idStr + ":" + peer.address;
     872          const QString key = idStr + QLatin1Char (':') + peer.address;
    873873          PeerItem * item = static_cast<PeerItem*> (myPeers.value (key, 0));
    874874
    875875          if (item == 0) // new peer has connected
    876876            {
    877               static const QIcon myEncryptionIcon (":/icons/encrypted.png");
     877              static const QIcon myEncryptionIcon (QLatin1String (":/icons/encrypted.png"));
    878878              static const QIcon myEmptyIcon;
    879879              item = new PeerItem (peer);
     
    882882              item->setTextAlignment (COL_PERCENT, Qt::AlignRight|Qt::AlignVCenter);
    883883              item->setIcon (COL_LOCK, peer.isEncrypted ? myEncryptionIcon : myEmptyIcon);
    884               item->setToolTip (COL_LOCK, peer.isEncrypted ? tr ("Encrypted connection") : "");
     884              item->setToolTip (COL_LOCK, peer.isEncrypted ? tr ("Encrypted connection") : QString ());
    885885              item->setText (COL_ADDRESS, peer.address);
    886886              item->setText (COL_CLIENT, peer.clientName);
     
    919919            codeTip.resize (codeTip.size ()-1); // eat the trailing linefeed
    920920
    921           item->setText (COL_UP, peer.rateToPeer.isZero () ? "" : Formatter::speedToString (peer.rateToPeer));
    922           item->setText (COL_DOWN, peer.rateToClient.isZero () ? "" : Formatter::speedToString (peer.rateToClient));
    923           item->setText (COL_PERCENT, peer.progress > 0 ? QString::fromLatin1 ("%1%").arg ( (int) (peer.progress * 100.0)) : "");
     921          item->setText (COL_UP, peer.rateToPeer.isZero () ? QString () : Formatter::speedToString (peer.rateToPeer));
     922          item->setText (COL_DOWN, peer.rateToClient.isZero () ? QString () : Formatter::speedToString (peer.rateToClient));
     923          item->setText (COL_PERCENT, peer.progress > 0 ? QString::fromLatin1 ("%1%").arg ( (int) (peer.progress * 100.0)) : QString ());
    924924          item->setText (COL_STATUS, code);
    925925          item->setToolTip (COL_STATUS, codeTip);
     
    12201220  ui.trackersView->setItemDelegate (myTrackerDelegate);
    12211221
    1222   ui.addTrackerButton->setIcon (getStockIcon ("list-add", QStyle::SP_DialogOpenButton));
    1223   ui.editTrackerButton->setIcon (getStockIcon ("document-properties", QStyle::SP_DesktopIcon));
    1224   ui.removeTrackerButton->setIcon (getStockIcon ("list-remove", QStyle::SP_TrashIcon));
     1222  ui.addTrackerButton->setIcon (getStockIcon (QLatin1String ("list-add"), QStyle::SP_DialogOpenButton));
     1223  ui.editTrackerButton->setIcon (getStockIcon (QLatin1String ("document-properties"), QStyle::SP_DesktopIcon));
     1224  ui.removeTrackerButton->setIcon (getStockIcon (QLatin1String ("list-remove"), QStyle::SP_TrashIcon));
    12251225
    12261226  ui.showTrackerScrapesCheck->setChecked (myPrefs.getBool (Prefs::SHOW_TRACKER_SCRAPES));
     
    12521252
    12531253  ui.peersView->setColumnWidth (COL_LOCK, 20);
    1254   ui.peersView->setColumnWidth (COL_UP, measureViewItem (ui.peersView, "1024 MiB/s"));
    1255   ui.peersView->setColumnWidth (COL_DOWN, measureViewItem (ui.peersView, "1024 MiB/s"));
    1256   ui.peersView->setColumnWidth (COL_PERCENT, measureViewItem (ui.peersView, "100%"));
    1257   ui.peersView->setColumnWidth (COL_STATUS, measureViewItem (ui.peersView, "ODUK?EXI"));
    1258   ui.peersView->setColumnWidth (COL_ADDRESS, measureViewItem (ui.peersView, "888.888.888.888"));
     1254  ui.peersView->setColumnWidth (COL_UP, measureViewItem (ui.peersView, QLatin1String ("1024 MiB/s")));
     1255  ui.peersView->setColumnWidth (COL_DOWN, measureViewItem (ui.peersView, QLatin1String ("1024 MiB/s")));
     1256  ui.peersView->setColumnWidth (COL_PERCENT, measureViewItem (ui.peersView, QLatin1String ("100%")));
     1257  ui.peersView->setColumnWidth (COL_STATUS, measureViewItem (ui.peersView, QLatin1String ("ODUK?EXI")));
     1258  ui.peersView->setColumnWidth (COL_ADDRESS, measureViewItem (ui.peersView, QLatin1String ("888.888.888.888")));
    12591259}
    12601260
     
    13221322        continue;
    13231323
    1324       const QString localFilePath = tor->getPath () + "/" + path;
     1324      const QString localFilePath = tor->getPath () + QLatin1Char ('/') + path;
    13251325      if (!QFile::exists (localFilePath))
    13261326        continue;
  • trunk/qt/favicon.cc

    r14457 r14466  
    5050#endif
    5151
    52   return QDir(base).absoluteFilePath ("favicons");
     52  return QDir(base).absoluteFilePath (QLatin1String ("favicons"));
    5353}
    5454
     
    8080{
    8181  QString host = url.host ();
    82   const int first_dot = host.indexOf ('.');
    83   const int last_dot = host.lastIndexOf ('.');
     82  const int first_dot = host.indexOf (QLatin1Char ('.'));
     83  const int last_dot = host.lastIndexOf (QLatin1Char ('.'));
    8484
    8585  if ((first_dot != -1) && (last_dot != -1) &&  (first_dot != last_dot))
     
    124124
    125125      // try to download the favicon
    126       const QString path = "http://" + host + "/favicon.";
     126      const QString path = QLatin1String ("http://") + host + QLatin1String ("/favicon.");
    127127      QStringList suffixes;
    128       suffixes << "ico" << "png" << "gif" << "jpg";
     128      suffixes << QLatin1String ("ico") << QLatin1String ("png") << QLatin1String ("gif") << QLatin1String ("jpg");
    129129      foreach (QString suffix, suffixes)
    130130        myNAM->get (QNetworkRequest (path + suffix));
  • trunk/qt/file-tree.cc

    r14428 r14466  
    140140
    141141         case COL_SIZE:
    142            value.setValue (sizeString() + "  ");
     142           value.setValue (sizeString() + QLatin1String ("  "));
    143143           break;
    144144
     
    396396        itemPath = item->name();
    397397      else
    398         itemPath = item->name() + "/" + itemPath;
     398        itemPath = item->name() + QLatin1Char ('/') + itemPath;
    399399      item = item->parent ();
    400400    }
     
    967967          QString header;
    968968          if (column == COL_SIZE)
    969             header = "999.9 KiB";
     969            header = QLatin1String ("999.9 KiB");
    970970          else
    971971            header = myModel.headerData (column, Qt::Horizontal).toString();
    972           header += "    ";
     972          header += QLatin1String ("    ");
    973973          const int width = fontMetrics.size (0, header).width();
    974974          setColumnWidth (column, width);
  • trunk/qt/file-tree.h

    r14413 r14466  
    4242    virtual ~FileTreeItem();
    4343
    44     FileTreeItem (const QString& name="", int fileIndex=-1, uint64_t size=0):
     44    FileTreeItem (const QString& name=QString (), int fileIndex=-1, uint64_t size=0):
    4545      myFileIndex (fileIndex),
    4646      myParent (0),
  • trunk/qt/filterbar.cc

    r14464 r14466  
    287287{
    288288#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
    289   const QIcon icon = QIcon::fromTheme ("edit-clear", style ()->standardIcon (QStyle::SP_DialogCloseButton));
     289  const QIcon icon = QIcon::fromTheme (QLatin1String ("edit-clear"), style ()->standardIcon (QStyle::SP_DialogCloseButton));
    290290  const int iconSize = style ()->pixelMetric (QStyle::PM_SmallIconSize);
    291291
     
    364364  delegate->setSeparator (model, model->index (1, 0));
    365365
    366   row = new QStandardItem (QIcon::fromTheme ("system-run"), tr ("Active"));
     366  row = new QStandardItem (QIcon::fromTheme (QLatin1String ("system-run")), tr ("Active"));
    367367  row->setData (FilterMode::SHOW_ACTIVE, ActivityRole);
    368368  model->appendRow (row);
    369369
    370   row = new QStandardItem (QIcon::fromTheme ("go-down"), tr ("Downloading"));
     370  row = new QStandardItem (QIcon::fromTheme (QLatin1String ("go-down")), tr ("Downloading"));
    371371  row->setData (FilterMode::SHOW_DOWNLOADING, ActivityRole);
    372372  model->appendRow (row);
    373373
    374   row = new QStandardItem (QIcon::fromTheme ("go-up"), tr ("Seeding"));
     374  row = new QStandardItem (QIcon::fromTheme (QLatin1String ("go-up")), tr ("Seeding"));
    375375  row->setData (FilterMode::SHOW_SEEDING, ActivityRole);
    376376  model->appendRow (row);
    377377
    378   row = new QStandardItem (QIcon::fromTheme ("media-playback-pause"), tr ("Paused"));
     378  row = new QStandardItem (QIcon::fromTheme (QLatin1String ("media-playback-pause")), tr ("Paused"));
    379379  row->setData (FilterMode::SHOW_PAUSED, ActivityRole);
    380380  model->appendRow (row);
    381381
    382   row = new QStandardItem (QIcon::fromTheme ("dialog-ok"), tr ("Finished"));
     382  row = new QStandardItem (QIcon::fromTheme (QLatin1String ("dialog-ok")), tr ("Finished"));
    383383  row->setData (FilterMode::SHOW_FINISHED, ActivityRole);
    384384  model->appendRow (row);
    385385
    386   row = new QStandardItem (QIcon::fromTheme ("view-refresh"), tr ("Verifying"));
     386  row = new QStandardItem (QIcon::fromTheme (QLatin1String ("view-refresh")), tr ("Verifying"));
    387387  row->setData (FilterMode::SHOW_VERIFYING, ActivityRole);
    388388  model->appendRow (row);
    389389
    390   row = new QStandardItem (QIcon::fromTheme ("process-stop"), tr ("Error"));
     390  row = new QStandardItem (QIcon::fromTheme (QLatin1String ("process-stop")), tr ("Error"));
    391391  row->setData (FilterMode::SHOW_ERROR, ActivityRole);
    392392  model->appendRow (row);
     
    408408    // get the readable name...
    409409    QString name = host;
    410     const int pos = name.lastIndexOf ('.');
     410    const int pos = name.lastIndexOf (QLatin1Char ('.'));
    411411    if (pos >= 0)
    412412      name.truncate (pos);
     
    518518
    519519  QStandardItem * row = new QStandardItem (tr ("All"));
    520   row->setData ("", TrackerRole);
     520  row->setData (QString (), TrackerRole);
    521521  const int count = myTorrents.rowCount ();
    522522  row->setData (count, TorrentCountRole);
     
    645645      QString str;
    646646      const bool isTracker = !myTrackerCombo->itemData (i,TrackerRole).toString ().isEmpty ();
    647       if (!isTracker) // show all
    648         {
    649           str = "";
     647      if (!isTracker)
     648        {
     649          // show all
    650650        }
    651651      else
    652652        {
    653653          str = myTrackerCombo->itemData (i,TrackerRole).toString ();
    654           const int pos = str.lastIndexOf ('.');
     654          const int pos = str.lastIndexOf (QLatin1Char ('.'));
    655655          if (pos >= 0)
    656656            str.truncate (pos+1);
  • trunk/qt/filters.cc

    r14394 r14466  
    1212const QString FilterMode::names[NUM_MODES] =
    1313{
    14   "show-all",
    15   "show-active",
    16   "show-downloading",
    17   "show-seeding",
    18   "show-paused",
    19   "show-finished",
    20   "show-verifying",
    21   "show-error",
     14  QLatin1String ("show-all"),
     15  QLatin1String ("show-active"),
     16  QLatin1String ("show-downloading"),
     17  QLatin1String ("show-seeding"),
     18  QLatin1String ("show-paused"),
     19  QLatin1String ("show-finished"),
     20  QLatin1String ("show-verifying"),
     21  QLatin1String ("show-error")
    2222};
    2323
     
    3434const QString SortMode::names[NUM_MODES] =
    3535{
    36   "sort-by-activity",
    37   "sort-by-age",
    38   "sort-by-eta",
    39   "sort-by-name",
    40   "sort-by-progress",
    41   "sort-by-queue"
    42   "sort-by-ratio",
    43   "sort-by-size",
    44   "sort-by-state",
    45   "sort-by-id"
     36  QLatin1String ("sort-by-activity"),
     37  QLatin1String ("sort-by-age"),
     38  QLatin1String ("sort-by-eta"),
     39  QLatin1String ("sort-by-name"),
     40  QLatin1String ("sort-by-progress"),
     41  QLatin1String ("sort-by-queue"),
     42  QLatin1String ("sort-by-ratio"),
     43  QLatin1String ("sort-by-size"),
     44  QLatin1String ("sort-by-state"),
     45  QLatin1String ("sort-by-id")
    4646};
    4747
  • trunk/qt/freespace-label.cc

    r14405 r14466  
    9292    setText (tr("%1 free").arg(Formatter::sizeToString (bytes)));
    9393  else
    94     setText ("");
     94    setText (QString ());
    9595
    9696  // update the tooltip
  • trunk/qt/hig.cc

    r14394 r14466  
    5252  QLabel * label = new QLabel (this);
    5353  label->setText (title);
    54   label->setStyleSheet ("font: bold");
     54  label->setStyleSheet (QLatin1String ("font: bold"));
    5555  label->setAlignment (Qt::AlignLeft|Qt::AlignVCenter);
    5656  addSectionTitle (label);
  • trunk/qt/license.cc

    r14394 r14466  
    2323  QPlainTextEdit * t = new QPlainTextEdit (this);
    2424  t->setReadOnly (true);
    25   t->setPlainText (
     25  t->setPlainText (QLatin1String (
    2626    "Copyright 2005-2014. All code is copyrighted by the respective authors.\n"
    2727    "\n"
     
    3636    "\n"
    3737    "Some of Transmission's source files have more permissive licenses. "
    38     "Those files may, of course, be used on their own under their own terms.\n");
     38    "Those files may, of course, be used on their own under their own terms.\n"));
    3939  v->addWidget (t);
    4040
  • trunk/qt/mainwin.cc

    r14464 r14466  
    115115
    116116  // icons
    117   ui.action_OpenFile->setIcon (getStockIcon ("document-open", QStyle::SP_DialogOpenButton));
    118   ui.action_New->setIcon (getStockIcon ("document-new", QStyle::SP_DesktopIcon));
    119   ui.action_Properties->setIcon (getStockIcon ("document-properties", QStyle::SP_DesktopIcon));
    120   ui.action_OpenFolder->setIcon (getStockIcon ("folder-open", QStyle::SP_DirOpenIcon));
    121   ui.action_Start->setIcon (getStockIcon ("media-playback-start", QStyle::SP_MediaPlay));
    122   ui.action_StartNow->setIcon (getStockIcon ("media-playback-start", QStyle::SP_MediaPlay));
    123   ui.action_Announce->setIcon (getStockIcon ("network-transmit-receive"));
    124   ui.action_Pause->setIcon (getStockIcon ("media-playback-pause", QStyle::SP_MediaPause));
    125   ui.action_Remove->setIcon (getStockIcon ("list-remove", QStyle::SP_TrashIcon));
    126   ui.action_Delete->setIcon (getStockIcon ("edit-delete", QStyle::SP_TrashIcon));
    127   ui.action_StartAll->setIcon (getStockIcon ("media-playback-start", QStyle::SP_MediaPlay));
    128   ui.action_PauseAll->setIcon (getStockIcon ("media-playback-pause", QStyle::SP_MediaPause));
    129   ui.action_Quit->setIcon (getStockIcon ("application-exit"));
    130   ui.action_SelectAll->setIcon (getStockIcon ("edit-select-all"));
    131   ui.action_ReverseSortOrder->setIcon (getStockIcon ("view-sort-ascending", QStyle::SP_ArrowDown));
    132   ui.action_Preferences->setIcon (getStockIcon ("preferences-system"));
    133   ui.action_Contents->setIcon (getStockIcon ("help-contents", QStyle::SP_DialogHelpButton));
    134   ui.action_About->setIcon (getStockIcon ("help-about"));
    135   ui.action_QueueMoveTop->setIcon (getStockIcon ("go-top"));
    136   ui.action_QueueMoveUp->setIcon (getStockIcon ("go-up", QStyle::SP_ArrowUp));
    137   ui.action_QueueMoveDown->setIcon (getStockIcon ("go-down", QStyle::SP_ArrowDown));
    138   ui.action_QueueMoveBottom->setIcon (getStockIcon ("go-bottom"));
     117  ui.action_OpenFile->setIcon (getStockIcon (QLatin1String ("document-open"), QStyle::SP_DialogOpenButton));
     118  ui.action_New->setIcon (getStockIcon (QLatin1String ("document-new"), QStyle::SP_DesktopIcon));
     119  ui.action_Properties->setIcon (getStockIcon (QLatin1String ("document-properties"), QStyle::SP_DesktopIcon));
     120  ui.action_OpenFolder->setIcon (getStockIcon (QLatin1String ("folder-open"), QStyle::SP_DirOpenIcon));
     121  ui.action_Start->setIcon (getStockIcon (QLatin1String ("media-playback-start"), QStyle::SP_MediaPlay));
     122  ui.action_StartNow->setIcon (getStockIcon (QLatin1String ("media-playback-start"), QStyle::SP_MediaPlay));
     123  ui.action_Announce->setIcon (getStockIcon (QLatin1String ("network-transmit-receive")));
     124  ui.action_Pause->setIcon (getStockIcon (QLatin1String ("media-playback-pause"), QStyle::SP_MediaPause));
     125  ui.action_Remove->setIcon (getStockIcon (QLatin1String ("list-remove"), QStyle::SP_TrashIcon));
     126  ui.action_Delete->setIcon (getStockIcon (QLatin1String ("edit-delete"), QStyle::SP_TrashIcon));
     127  ui.action_StartAll->setIcon (getStockIcon (QLatin1String ("media-playback-start"), QStyle::SP_MediaPlay));
     128  ui.action_PauseAll->setIcon (getStockIcon (QLatin1String ("media-playback-pause"), QStyle::SP_MediaPause));
     129  ui.action_Quit->setIcon (getStockIcon (QLatin1String ("application-exit")));
     130  ui.action_SelectAll->setIcon (getStockIcon (QLatin1String ("edit-select-all")));
     131  ui.action_ReverseSortOrder->setIcon (getStockIcon (QLatin1String ("view-sort-ascending"), QStyle::SP_ArrowDown));
     132  ui.action_Preferences->setIcon (getStockIcon (QLatin1String ("preferences-system")));
     133  ui.action_Contents->setIcon (getStockIcon (QLatin1String ("help-contents"), QStyle::SP_DialogHelpButton));
     134  ui.action_About->setIcon (getStockIcon (QLatin1String ("help-about")));
     135  ui.action_QueueMoveTop->setIcon (getStockIcon (QLatin1String ("go-top")));
     136  ui.action_QueueMoveUp->setIcon (getStockIcon (QLatin1String ("go-up"), QStyle::SP_ArrowUp));
     137  ui.action_QueueMoveDown->setIcon (getStockIcon (QLatin1String ("go-down"), QStyle::SP_ArrowDown));
     138  ui.action_QueueMoveBottom->setIcon (getStockIcon (QLatin1String ("go-bottom")));
    139139
    140140  // ui signals
     
    231231  menu->addAction (ui.action_Quit);
    232232  myTrayIcon.setContextMenu (menu);
    233   myTrayIcon.setIcon (QIcon::fromTheme ("transmission-tray-icon", qApp->windowIcon ()));
     233  myTrayIcon.setIcon (QIcon::fromTheme (QLatin1String ("transmission-tray-icon"), qApp->windowIcon ()));
    234234
    235235  connect (&myPrefs, SIGNAL (changed (int)), this, SLOT (refreshPref (int)));
     
    584584  scriptArgs << QLatin1String ("-e")
    585585             << QLatin1String ("tell application \"Finder\" to activate");
    586   QProcess::execute ("/usr/bin/osascript", scriptArgs);
     586  QProcess::execute (QLatin1String ("/usr/bin/osascript"), scriptArgs);
    587587}
    588588#endif
     
    596596  const FileList files = tor->files ();
    597597  const QString firstfile = files.at (0).filename;
    598   int slashIndex = firstfile.indexOf ('/');
     598  int slashIndex = firstfile.indexOf (QLatin1Char ('/'));
    599599  if (slashIndex > -1)
    600600    {
    601       path = path + "/" + firstfile.left (slashIndex);
     601      path = path + QLatin1Char ('/') + firstfile.left (slashIndex);
    602602    }
    603603#ifdef HAVE_OPEN_SELECT
    604604  else
    605605    {
    606       openSelect (path + "/" + firstfile);
     606      openSelect (path + QLatin1Char ('/') + firstfile);
    607607      return;
    608608    }
     
    621621TrMainWindow::openDonate ()
    622622{
    623   QDesktopServices::openUrl (QUrl ("http://www.transmissionbt.com/donate.php"));
     623  QDesktopServices::openUrl (QUrl (QLatin1String ("http://www.transmissionbt.com/donate.php")));
    624624}
    625625
     
    634634TrMainWindow::refreshTitle ()
    635635{
    636   QString title ("Transmission");
     636  QString title (QLatin1String ("Transmission"));
    637637  const QUrl url (mySession.getRemoteUrl ());
    638638  if (!url.isEmpty ())
     
    700700  QString str;
    701701
    702   if (mode == "session-ratio")
     702  if (mode == QLatin1String ("session-ratio"))
    703703    {
    704704      str = tr ("Ratio: %1").arg (Formatter::ratioToString (mySession.getStats ().ratio));
    705705    }
    706   else if (mode == "session-transfer")
     706  else if (mode == QLatin1String ("session-transfer"))
    707707    {
    708708      const tr_session_stats& stats (mySession.getStats ());
     
    710710                                      .arg (Formatter::sizeToString (stats.uploadedBytes));
    711711    }
    712   else if (mode == "total-transfer")
     712  else if (mode == QLatin1String ("total-transfer"))
    713713    {
    714714      const tr_session_stats& stats (mySession.getCumulativeStats ());
     
    974974      case Prefs::STATUSBAR_STATS:
    975975        str = myPrefs.getString (key);
    976         ui.action_TotalRatio->setChecked (str == "total-ratio");
    977         ui.action_TotalTransfer->setChecked (str == "total-transfer");
    978         ui.action_SessionRatio->setChecked (str == "session-ratio");
    979         ui.action_SessionTransfer->setChecked (str == "session-transfer");
     976        ui.action_TotalRatio->setChecked (str == QLatin1String ("total-ratio"));
     977        ui.action_TotalTransfer->setChecked (str == QLatin1String ("total-transfer"));
     978        ui.action_SessionRatio->setChecked (str == QLatin1String ("session-ratio"));
     979        ui.action_SessionTransfer->setChecked (str == QLatin1String ("session-transfer"));
    980980        refreshStatusBar ();
    981981        break;
     
    10971097***/
    10981098
    1099 #define SHOW_OPTIONS_CHECKBOX_NAME "show-options-checkbox"
     1099namespace
     1100{
     1101  const QLatin1String SHOW_OPTIONS_CHECKBOX_NAME ("show-options-checkbox");
     1102}
    11001103
    11011104void
     
    12511254      if (connected && incomplete)
    12521255        {
    1253           secondary_text += "\n";
     1256          secondary_text += QLatin1Char ('\n');
    12541257        }
    12551258
     
    13101313  else
    13111314    key = "network-idle";
    1312   const QIcon icon = getStockIcon (key, QStyle::SP_DriveNetIcon);
     1315  const QIcon icon = getStockIcon (QLatin1String (key), QStyle::SP_DriveNetIcon);
    13131316  const QPixmap pixmap = icon.pixmap (16, 16);
    13141317
     
    13881391  const QMimeData * mime = event->mimeData ();
    13891392
    1390   if (mime->hasFormat ("application/x-bittorrent")
     1393  if (mime->hasFormat (QLatin1String ("application/x-bittorrent"))
    13911394        || mime->hasUrls()
    1392         || mime->text ().trimmed ().endsWith (".torrent", Qt::CaseInsensitive)
    1393         || mime->text ().startsWith ("magnet:", Qt::CaseInsensitive))
     1395        || mime->text ().trimmed ().endsWith (QLatin1String (".torrent"), Qt::CaseInsensitive)
     1396        || mime->text ().startsWith (QLatin1String ("magnet:"), Qt::CaseInsensitive))
    13941397    event->acceptProposedAction ();
    13951398}
     
    14021405  if (event->mimeData()->hasText())
    14031406    {
    1404       list = event->mimeData()->text().trimmed().split('\n');
     1407      list = event->mimeData()->text().trimmed().split(QLatin1Char ('\n'));
    14051408    }
    14061409  else if (event->mimeData()->hasUrls())
     
    14181421          const QUrl url (key);
    14191422
    1420           if (url.scheme () == "file")
     1423          if (url.scheme () == QLatin1String ("file"))
    14211424            key = QUrl::fromPercentEncoding (url.path().toUtf8());
    14221425
  • trunk/qt/make-dialog.cc

    r14458 r14466  
    133133  int tier = 0;
    134134  QVector<tr_tracker_info> trackers;
    135   foreach (QString line, ui.trackersEdit->toPlainText ().split ("\n"))
     135  foreach (QString line, ui.trackersEdit->toPlainText ().split (QLatin1Char ('\n')))
    136136    {
    137137      line = line.trimmed ();
     
    151151  // the file to create
    152152  const QString path = QString::fromUtf8 (myBuilder->top);
    153   const QString torrentName = QFileInfo (path).completeBaseName () + ".torrent";
     153  const QString torrentName = QFileInfo (path).completeBaseName () + QLatin1String (".torrent");
    154154  const QString target = QDir (ui.destinationButton->path ()).filePath (torrentName);
    155155
  • trunk/qt/options.cc

    r14415 r14466  
    439439        {
    440440          // did the user accidentally specify the child directory instead of the parent?
    441           const QStringList tokens = QString::fromUtf8 (file->name).split ('/');
     441          const QStringList tokens = QString::fromUtf8 (file->name).split (QLatin1Char ('/'));
    442442          if (!tokens.empty () && myLocalDestination.dirName () == tokens.at (0))
    443443            {
  • trunk/qt/prefs.cc

    r14464 r14466  
    163163          case TrTypes::SortModeType:
    164164            if (tr_variantGetStr (b, &str, NULL))
    165               myValues[i] = QVariant::fromValue (SortMode (str));
     165              myValues[i] = QVariant::fromValue (SortMode (QString::fromUtf8 (str)));
    166166            break;
    167167
    168168          case TrTypes::FilterModeType:
    169169            if (tr_variantGetStr (b, &str, NULL))
    170               myValues[i] = QVariant::fromValue (FilterMode (str));
     170              myValues[i] = QVariant::fromValue (FilterMode (QString::fromUtf8 (str)));
    171171            break;
    172172
     
    258258  // update settings.json with our settings
    259259  tr_variant file_settings;
    260   const QFile file (QDir(myConfigDir).absoluteFilePath("settings.json"));
     260  const QFile file (QDir(myConfigDir).absoluteFilePath(QLatin1String ("settings.json")));
    261261  if (tr_variantFromFile (&file_settings, TR_VARIANT_FMT_JSON, file.fileName().toUtf8().constData()))
    262262    tr_variantInitDict (&file_settings, PREFS_COUNT);
  • trunk/qt/qtr.pro

    r14460 r14466  
    2020}
    2121
     22DEFINES += QT_NO_CAST_FROM_ASCII
     23win32:DEFINES += QT_DBUS
     24
    2225TRANSMISSION_TOP = ..
    2326
     
    3336LIBS += $${LIBNATPMP_LIBS}
    3437unix: LIBS += -L$${EVENT_TOP}/lib -lz -lrt
    35 win32:DEFINES += QT_DBUS
    3638win32:LIBS += -levent-2.0 -lws2_32 -lintl
    3739win32:LIBS += -lidn -liconv -lwldap32 -liphlpapi
  • trunk/qt/rpc-client.cc

    r14405 r14466  
    7171
    7272#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
    73   if (myUrl.host () == "127.0.0.1" ||
    74       myUrl.host ().compare ("localhost", Qt::CaseInsensitive) == 0)
     73  if (myUrl.host () == QLatin1String ("127.0.0.1") ||
     74      myUrl.host ().compare (QLatin1String ("localhost"), Qt::CaseInsensitive) == 0)
    7575    return true;
    7676#else
     
    124124      QNetworkRequest request;
    125125      request.setUrl (myUrl);
    126       request.setRawHeader ("User-Agent", (qApp->applicationName () + "/" + LONG_VERSION_STRING).toUtf8 ());
     126      request.setRawHeader ("User-Agent", (qApp->applicationName () + QLatin1Char ('/') + QString::fromUtf8 (LONG_VERSION_STRING)).toUtf8 ());
    127127      request.setRawHeader ("Content-Type", "application/json; charset=UTF-8");
    128128
  • trunk/qt/session.cc

    r14464 r14466  
    8282    return;
    8383
    84   if (result == "success")
     84  if (result == QLatin1String ("success"))
    8585    {
    8686      tr_variant * dup;
     
    219219            {
    220220              case 0:
    221                 sessionSet (myPrefs.getKey (key), "tolerated");
     221                sessionSet (myPrefs.getKey (key), QLatin1String ("tolerated"));
    222222                break;
    223223              case 1:
    224                 sessionSet (myPrefs.getKey (key), "preferred");
     224                sessionSet (myPrefs.getKey (key), QLatin1String ("preferred"));
    225225                break;
    226226              case 2:
    227                 sessionSet (myPrefs.getKey (key), "required");
     227                sessionSet (myPrefs.getKey (key), QLatin1String ("required"));
    228228                break;
    229229            }
     
    335335    {
    336336      QUrl url;
    337       url.setScheme ("http");
     337      url.setScheme (QLatin1String ("http"));
    338338      url.setHost (myPrefs.get<QString> (Prefs::SESSION_REMOTE_HOST));
    339339      url.setPort (myPrefs.get<int> (Prefs::SESSION_REMOTE_PORT));
    340       url.setPath ("/transmission/rpc");
     340      url.setPath (QLatin1String ("/transmission/rpc"));
    341341      if (myPrefs.get<bool> (Prefs::SESSION_REMOTE_AUTH))
    342342        {
     
    661661              tr_variantDictFindStr (args, TR_KEY_name, &name, 0);
    662662              const QString title = tr ("Error Renaming Path");
    663               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);
     663              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 (QString::fromUtf8 (path)).arg (QString::fromUtf8 (name)).arg (result);
    664664              QMessageBox * d = new QMessageBox (QMessageBox::Information, title, text,
    665665                                                 QMessageBox::Close,
     
    699699              && ( (child = tr_variantListChild (torrents, 0)))
    700700              && tr_variantDictFindStr (child, TR_KEY_magnetLink, &str, NULL))
    701             qApp->clipboard ()->setText (str);
     701            qApp->clipboard ()->setText (QString::fromUtf8 (str));
    702702          break;
    703703        }
     
    843843    setBlocklistSize (i);
    844844
    845   if (tr_variantDictFindStr (d, TR_KEY_version, &str, NULL) && (mySessionVersion != str))
    846     mySessionVersion = str;
     845  if (tr_variantDictFindStr (d, TR_KEY_version, &str, NULL) && (mySessionVersion != QString::fromUtf8 (str)))
     846    mySessionVersion = QString::fromUtf8 (str);
    847847
    848848  //std::cerr << "Session::updateInfo end" << std::endl;
     
    979979    {
    980980      url = myRpc.url ();
    981       url.setPath ("/transmission/web/");
     981      url.setPath (QLatin1String ("/transmission/web/"));
    982982    }
    983983  else // local session
    984984    {
    985       url.setScheme ("http");
    986       url.setHost ("localhost");
     985      url.setScheme (QLatin1String ("http"));
     986      url.setHost (QLatin1String ("localhost"));
    987987      url.setPort (myPrefs.getInt (Prefs::RPC_PORT));
    988988    }
  • trunk/qt/torrent-delegate-min.cc

    r14454 r14466  
    181181
    182182  const QIcon::Mode emblemIm = isItemSelected ? QIcon::Selected : QIcon::Normal;
    183   const QIcon emblemIcon = tor.hasError () ? QIcon::fromTheme ("emblem-important", style->standardIcon (QStyle::SP_MessageBoxWarning)) : QIcon ();
     183  const QIcon emblemIcon = tor.hasError () ? QIcon::fromTheme (QLatin1String ("emblem-important"), style->standardIcon (QStyle::SP_MessageBoxWarning)) : QIcon ();
    184184
    185185  // layout
  • trunk/qt/torrent-delegate.cc

    r14455 r14466  
    486486
    487487  const QIcon::Mode emblemIm = isItemSelected ? QIcon::Selected : QIcon::Normal;
    488   const QIcon emblemIcon = tor.hasError () ? QIcon::fromTheme ("emblem-important", style->standardIcon (QStyle::SP_MessageBoxWarning)) : QIcon ();
     488  const QIcon emblemIcon = tor.hasError () ? QIcon::fromTheme (QLatin1String ("emblem-important"), style->standardIcon (QStyle::SP_MessageBoxWarning)) : QIcon ();
    489489
    490490  // layout
  • trunk/qt/torrent.cc

    r14404 r14466  
    247247  assert (myProperties[i].type == QVariant::String);
    248248
    249   if (myValues[i].isNull() || myValues[i].toString()!=value)
     249  if (myValues[i].isNull() || myValues[i].toString() != QString::fromUtf8 (value))
    250250    {
    251251      myValues[i].setValue (QString::fromUtf8 (value));
  • trunk/qt/tracker-delegate.cc

    r14457 r14466  
    174174  QString str;
    175175  const time_t now (time (0));
    176   const QString err_markup_begin = "<span style=\"color:red\">";
    177   const QString err_markup_end = "</span>";
    178   const QString timeout_markup_begin = "<span style=\"color:#224466\">";
    179   const QString timeout_markup_end = "</span>";
    180   const QString success_markup_begin = "<span style=\"color:#008B00\">";
    181   const QString success_markup_end = "</span>";
     176  const QString err_markup_begin = QLatin1String ("<span style=\"color:red\">");
     177  const QString err_markup_end = QLatin1String ("</span>");
     178  const QString timeout_markup_begin = QLatin1String ("<span style=\"color:#224466\">");
     179  const QString timeout_markup_end = QLatin1String ("</span>");
     180  const QString success_markup_begin = QLatin1String ("<span style=\"color:#008B00\">");
     181  const QString success_markup_end = QLatin1String ("</span>");
    182182
    183183  // hostname
    184   str += inf.st.isBackup ? "<i>" : "<b>";
     184  str += inf.st.isBackup ? QLatin1String ("<i>") : QLatin1String ("<b>");
    185185  char * host = NULL;
    186186  int port = 0;
    187187  tr_urlParse (inf.st.announce.toUtf8().constData(), -1, NULL, &host, &port, NULL);
    188   str += QString::fromLatin1 ("%1:%2").arg (host).arg (port);
     188  str += QString::fromLatin1 ("%1:%2").arg (QString::fromUtf8 (host)).arg (port);
    189189  tr_free (host);
    190   if (!key.isEmpty()) str += " - " + key;
    191   str += inf.st.isBackup ? "</i>" : "</b>";
     190  if (!key.isEmpty()) str += QLatin1String (" - ") + key;
     191  str += inf.st.isBackup ? QLatin1String ("</i>") : QLatin1String ("</b>");
    192192
    193193  // announce & scrape info
     
    197197        {
    198198          const QString tstr (timeToStringRounded (now - inf.st.lastAnnounceTime));
    199           str += "<br/>\n";
     199          str += QLatin1String ("<br/>\n");
    200200          if (inf.st.lastAnnounceSucceeded)
    201201            {
     
    228228          {
    229229            case TR_TRACKER_INACTIVE:
    230               str += "<br/>\n";
     230              str += QLatin1String ("<br/>\n");
    231231              str += tr ("No updates scheduled");
    232232              break;
     
    235235              {
    236236                const QString tstr (timeToStringRounded (inf.st.nextAnnounceTime - now));
    237                 str += "<br/>\n";
     237                str += QLatin1String ("<br/>\n");
    238238                //: %1 is duration
    239239                str += tr ("Asking for more peers in %1").arg (tstr);
     
    242242
    243243            case TR_TRACKER_QUEUED:
    244               str += "<br/>\n";
     244              str += QLatin1String ("<br/>\n");
    245245              str += tr ("Queued to ask for more peers");
    246246              break;
     
    248248            case TR_TRACKER_ACTIVE: {
    249249              const QString tstr (timeToStringRounded (now - inf.st.lastAnnounceStartTime));
    250               str += "<br/>\n";
     250              str += QLatin1String ("<br/>\n");
    251251              //: %1 is duration
    252252              str += tr ("Asking for more peers now... <small>%1</small>").arg (tstr);
     
    259259          if (inf.st.hasScraped)
    260260            {
    261               str += "<br/>\n";
     261              str += QLatin1String ("<br/>\n");
    262262              const QString tstr (timeToStringRounded (now - inf.st.lastScrapeTime));
    263263              if (inf.st.lastScrapeSucceeded)
     
    305305              case TR_TRACKER_WAITING:
    306306                {
    307                   str += "<br/>\n";
     307                  str += QLatin1String ("<br/>\n");
    308308                  const QString tstr (timeToStringRounded (inf.st.nextScrapeTime - now));
    309309                  //: %1 is duration
     
    314314              case TR_TRACKER_QUEUED:
    315315                {
    316                   str += "<br/>\n";
     316                  str += QLatin1String ("<br/>\n");
    317317                  str += tr ("Queued to ask for peer counts");
    318318                  break;
     
    321321              case TR_TRACKER_ACTIVE:
    322322                {
    323                   str += "<br/>\n";
     323                  str += QLatin1String ("<br/>\n");
    324324                  const QString tstr (timeToStringRounded (now - inf.st.lastScrapeStartTime));
    325325                  //: %1 is duration
Note: See TracChangeset for help on using the changeset viewer.