#include "hig.h"
#include "license.h"
-AboutDialog :: AboutDialog (QWidget * parent):
+AboutDialog::AboutDialog (QWidget * parent):
QDialog (parent, Qt::Dialog),
myLicenseDialog (new LicenseDialog (this))
{
}
void
-AboutDialog :: showCredits ()
+AboutDialog::showCredits ()
{
QMessageBox::about (
this,
#include "utils.h"
int
-AddData :: set (const QString& key)
+AddData::set (const QString& key)
{
if (Utils::isMagnetLink (key))
{
}
QByteArray
-AddData :: toBase64 () const
+AddData::toBase64 () const
{
QByteArray ret;
}
QString
-AddData :: readableName () const
+AddData::readableName () const
{
QString ret;
};
}
-MyApp :: MyApp (int& argc, char ** argv):
+MyApp::MyApp (int& argc, char ** argv):
QApplication (argc, argv),
myPrefs(nullptr),
mySession(nullptr),
/* these functions are for popping up desktop notifications */
void
-MyApp :: onTorrentsAdded (QSet<int> torrents)
+MyApp::onTorrentsAdded (QSet<int> torrents)
{
if (!myPrefs->getBool (Prefs::SHOW_NOTIFICATION_ON_ADD))
return;
}
void
-MyApp :: onTorrentCompleted (int id)
+MyApp::onTorrentCompleted (int id)
{
Torrent * tor = myModel->getTorrentFromId (id);
}
void
-MyApp :: onNewTorrentChanged (int id)
+MyApp::onNewTorrentChanged (int id)
{
Torrent * tor = myModel->getTorrentFromId (id);
***/
void
-MyApp :: consentGiven ()
+MyApp::consentGiven ()
{
myPrefs->set<bool> (Prefs::USER_HAS_GIVEN_INFORMED_CONSENT, true);
}
-MyApp :: ~MyApp ()
+MyApp::~MyApp ()
{
if (myPrefs != nullptr && myWindow != nullptr)
{
const QRect mainwinRect (myWindow->geometry ());
- myPrefs->set (Prefs :: MAIN_WINDOW_HEIGHT, std::max (100, mainwinRect.height ()));
- myPrefs->set (Prefs :: MAIN_WINDOW_WIDTH, std::max (100, mainwinRect.width ()));
- myPrefs->set (Prefs :: MAIN_WINDOW_X, mainwinRect.x ());
- myPrefs->set (Prefs :: MAIN_WINDOW_Y, mainwinRect.y ());
+ myPrefs->set (Prefs::MAIN_WINDOW_HEIGHT, std::max (100, mainwinRect.height ()));
+ myPrefs->set (Prefs::MAIN_WINDOW_WIDTH, std::max (100, mainwinRect.width ()));
+ myPrefs->set (Prefs::MAIN_WINDOW_X, mainwinRect.x ());
+ myPrefs->set (Prefs::MAIN_WINDOW_Y, mainwinRect.y ());
}
delete myWatchDir;
***/
void
-MyApp :: refreshPref (int key)
+MyApp::refreshPref (int key)
{
switch (key)
{
- case Prefs :: BLOCKLIST_UPDATES_ENABLED:
+ case Prefs::BLOCKLIST_UPDATES_ENABLED:
maybeUpdateBlocklist ();
break;
- case Prefs :: DIR_WATCH:
- case Prefs :: DIR_WATCH_ENABLED:
+ case Prefs::DIR_WATCH:
+ case Prefs::DIR_WATCH_ENABLED:
{
const QString path (myPrefs->getString (Prefs::DIR_WATCH));
const bool isEnabled (myPrefs->getBool (Prefs::DIR_WATCH_ENABLED));
}
void
-MyApp :: maybeUpdateBlocklist ()
+MyApp::maybeUpdateBlocklist ()
{
- if (!myPrefs->getBool (Prefs :: BLOCKLIST_UPDATES_ENABLED))
+ if (!myPrefs->getBool (Prefs::BLOCKLIST_UPDATES_ENABLED))
return;
- const QDateTime lastUpdatedAt = myPrefs->getDateTime (Prefs :: BLOCKLIST_DATE);
+ const QDateTime lastUpdatedAt = myPrefs->getDateTime (Prefs::BLOCKLIST_DATE);
const QDateTime nextUpdateAt = lastUpdatedAt.addDays (7);
const QDateTime now = QDateTime::currentDateTime ();
if (now < nextUpdateAt)
{
mySession->updateBlocklist ();
- myPrefs->set (Prefs :: BLOCKLIST_DATE, now);
+ myPrefs->set (Prefs::BLOCKLIST_DATE, now);
}
}
void
-MyApp :: onSessionSourceChanged ()
+MyApp::onSessionSourceChanged ()
{
mySession->initTorrents ();
mySession->refreshSessionStats ();
}
void
-MyApp :: refreshTorrents ()
+MyApp::refreshTorrents ()
{
// usually we just poll the torrents that have shown recent activity,
// but we also periodically ask for updates on the others to ensure
***/
void
-MyApp :: addTorrent (const QString& key)
+MyApp::addTorrent (const QString& key)
{
const AddData addme (key);
}
void
-MyApp :: addTorrent (const AddData& addme)
+MyApp::addTorrent (const AddData& addme)
{
- if (!myPrefs->getBool (Prefs :: OPTIONS_PROMPT))
+ if (!myPrefs->getBool (Prefs::OPTIONS_PROMPT))
{
mySession->addTorrent (addme);
}
***/
void
-MyApp :: raise ()
+MyApp::raise ()
{
- QApplication :: alert (myWindow);
+ QApplication::alert (myWindow);
}
bool
-MyApp :: notifyApp (const QString& title, const QString& body) const
+MyApp::notifyApp (const QString& title, const QString& body) const
{
const QString dbusServiceName = QString::fromUtf8 ("org.freedesktop.Notifications");
const QString dbusInterfaceName = QString::fromUtf8 ("org.freedesktop.Notifications");
#include "app.h"
#include "dbus-adaptor.h"
-TrDBusAdaptor :: TrDBusAdaptor (MyApp* app):
+TrDBusAdaptor::TrDBusAdaptor (MyApp* app):
QDBusAbstractAdaptor (app),
myApp (app)
{
}
bool
-TrDBusAdaptor :: PresentWindow ()
+TrDBusAdaptor::PresentWindow ()
{
myApp->raise ();
return true;
}
bool
-TrDBusAdaptor :: AddMetainfo (const QString& key)
+TrDBusAdaptor::AddMetainfo (const QString& key)
{
AddData addme (key);
***/
QIcon
-Details :: getStockIcon (const QString& freedesktop_name, int fallback)
+Details::getStockIcon (const QString& freedesktop_name, int fallback)
{
QIcon icon = QIcon::fromTheme (freedesktop_name);
return icon;
}
-Details :: Details (Session & session,
- Prefs & prefs,
- TorrentModel & model,
- QWidget * parent):
+Details::Details (Session & session,
+ Prefs & prefs,
+ TorrentModel & model,
+ QWidget * parent):
QDialog (parent, Qt::Dialog),
mySession (session),
myPrefs (prefs),
QWidget::setAttribute (Qt::WA_DeleteOnClose, true);
QList<int> initKeys;
- initKeys << Prefs :: SHOW_TRACKER_SCRAPES
- << Prefs :: SHOW_BACKUP_TRACKERS;
+ initKeys << Prefs::SHOW_TRACKER_SCRAPES
+ << Prefs::SHOW_BACKUP_TRACKERS;
foreach (int key, initKeys)
refreshPref (key);
myTimer.start (REFRESH_INTERVAL_MSEC);
}
-Details :: ~Details ()
+Details::~Details ()
{
myTrackerDelegate->deleteLater ();
myTrackerFilter->deleteLater ();
}
void
-Details :: setIds (const QSet<int>& ids)
+Details::setIds (const QSet<int>& ids)
{
if (ids == myIds)
return;
}
void
-Details :: refreshPref (int key)
+Details::refreshPref (int key)
{
QString str;
switch (key)
{
- case Prefs :: SHOW_TRACKER_SCRAPES:
+ case Prefs::SHOW_TRACKER_SCRAPES:
{
QItemSelectionModel * selectionModel (myTrackerView->selectionModel ());
const QItemSelection selection (selectionModel->selection ());
break;
}
- case Prefs :: SHOW_BACKUP_TRACKERS:
+ case Prefs::SHOW_BACKUP_TRACKERS:
myTrackerFilter->setShowBackupTrackers (myPrefs.getBool (key));
break;
***/
QString
-Details :: timeToStringRounded (int seconds)
+Details::timeToStringRounded (int seconds)
{
if (seconds > 60)
seconds -= (seconds % 60);
}
void
-Details :: onTimer ()
+Details::onTimer ()
{
getNewData ();
}
void
-Details :: getNewData ()
+Details::getNewData ()
{
if (!myIds.empty ())
{
}
void
-Details :: onTorrentChanged ()
+Details::onTorrentChanged ()
{
if (!myHavePendingRefresh)
{
}
void
-Details :: refresh ()
+Details::refresh ()
{
const int n = myIds.size ();
const bool single = n == 1;
}
void
-Details :: enableWhenChecked (QCheckBox * box, QWidget * w)
+Details::enableWhenChecked (QCheckBox * box, QWidget * w)
{
connect (box, SIGNAL (toggled (bool)), w, SLOT (setEnabled (bool)));
w->setEnabled (box->isChecked ());
***/
QWidget *
-Details :: createInfoTab ()
+Details::createInfoTab ()
{
HIG * hig = new HIG (this);
***/
void
-Details :: onShowTrackerScrapesToggled (bool val)
+Details::onShowTrackerScrapesToggled (bool val)
{
myPrefs.set (Prefs::SHOW_TRACKER_SCRAPES, val);
}
void
-Details :: onShowBackupTrackersToggled (bool val)
+Details::onShowBackupTrackersToggled (bool val)
{
myPrefs.set (Prefs::SHOW_BACKUP_TRACKERS, val);
}
void
-Details :: onHonorsSessionLimitsToggled (bool val)
+Details::onHonorsSessionLimitsToggled (bool val)
{
mySession.torrentSet (myIds, TR_KEY_honorsSessionLimits, val);
getNewData ();
}
void
-Details :: onDownloadLimitedToggled (bool val)
+Details::onDownloadLimitedToggled (bool val)
{
mySession.torrentSet (myIds, TR_KEY_downloadLimited, val);
getNewData ();
}
void
-Details :: onSpinBoxEditingFinished ()
+Details::onSpinBoxEditingFinished ()
{
const QObject * spin = sender ();
const tr_quark key = spin->property (PREF_KEY).toInt ();
}
void
-Details :: onUploadLimitedToggled (bool val)
+Details::onUploadLimitedToggled (bool val)
{
mySession.torrentSet (myIds, TR_KEY_uploadLimited, val);
getNewData ();
}
void
-Details :: onIdleModeChanged (int index)
+Details::onIdleModeChanged (int index)
{
const int val = myIdleCombo->itemData (index).toInt ();
mySession.torrentSet (myIds, TR_KEY_seedIdleMode, val);
}
void
-Details :: onRatioModeChanged (int index)
+Details::onRatioModeChanged (int index)
{
const int val = myRatioCombo->itemData (index).toInt ();
mySession.torrentSet (myIds, TR_KEY_seedRatioMode, val);
}
void
-Details :: onBandwidthPriorityChanged (int index)
+Details::onBandwidthPriorityChanged (int index)
{
if (index != -1)
{
}
void
-Details :: onTrackerSelectionChanged ()
+Details::onTrackerSelectionChanged ()
{
const int selectionCount = myTrackerView->selectionModel ()->selectedRows ().size ();
myEditTrackerButton->setEnabled (selectionCount == 1);
}
void
-Details :: onAddTrackerClicked ()
+Details::onAddTrackerClicked ()
{
bool ok = false;
const QString url = QInputDialog::getText (this,
}
void
-Details :: onEditTrackerClicked ()
+Details::onEditTrackerClicked ()
{
QItemSelectionModel * selectionModel = myTrackerView->selectionModel ();
QModelIndexList selectedRows = selectionModel->selectedRows ();
}
void
-Details :: onRemoveTrackerClicked ()
+Details::onRemoveTrackerClicked ()
{
// make a map of torrentIds to announce URLs to remove
QItemSelectionModel * selectionModel = myTrackerView->selectionModel ();
}
QWidget *
-Details :: createOptionsTab ()
+Details::createOptionsTab ()
{
QSpinBox * s;
QCheckBox * c;
hig->addSectionTitle (tr ("Seeding Limits"));
h = new QHBoxLayout ();
- h->setSpacing (HIG :: PAD);
+ h->setSpacing (HIG::PAD);
m = new QComboBox;
m->addItem (tr ("Use Global Settings"), TR_RATIOLIMIT_GLOBAL);
m->addItem (tr ("Seed regardless of ratio"), TR_RATIOLIMIT_UNLIMITED);
hig->addRow (tr ("&Ratio:"), h, m);
h = new QHBoxLayout ();
- h->setSpacing (HIG :: PAD);
+ h->setSpacing (HIG::PAD);
m = new QComboBox;
m->addItem (tr ("Use Global Settings"), TR_IDLELIMIT_GLOBAL);
m->addItem (tr ("Seed regardless of activity"), TR_IDLELIMIT_UNLIMITED);
***/
QWidget *
-Details :: createTrackerTab ()
+Details::createTrackerTab ()
{
QCheckBox * c;
QPushButton * p;
***/
QWidget *
-Details :: createPeersTab ()
+Details::createPeersTab ()
{
QWidget * top = new QWidget;
QVBoxLayout * v = new QVBoxLayout (top);
- v->setSpacing (HIG :: PAD_BIG);
+ v->setSpacing (HIG::PAD_BIG);
v->setContentsMargins (HIG::PAD_BIG, HIG::PAD_BIG, HIG::PAD_BIG, HIG::PAD_BIG);
QStringList headers;
***/
QWidget *
-Details :: createFilesTab ()
+Details::createFilesTab ()
{
myFileTreeView = new FileTreeView ();
}
void
-Details :: onFilePriorityChanged (const QSet<int>& indices, int priority)
+Details::onFilePriorityChanged (const QSet<int>& indices, int priority)
{
tr_quark key;
}
void
-Details :: onFileWantedChanged (const QSet<int>& indices, bool wanted)
+Details::onFileWantedChanged (const QSet<int>& indices, bool wanted)
{
const tr_quark key = wanted ? TR_KEY_files_wanted : TR_KEY_files_unwanted;
mySession.torrentSet (myIds, key, indices.toList ());
}
void
-Details :: onPathEdited (const QString& oldpath, const QString& newname)
+Details::onPathEdited (const QString& oldpath, const QString& newname)
{
mySession.torrentRenamePath (myIds, oldpath, newname);
}
void
-Details :: onOpenRequested (const QString& path)
+Details::onOpenRequested (const QString& path)
{
if (!mySession.isLocal ())
return;
****
***/
-Favicons :: Favicons ()
+Favicons::Favicons ()
{
myNAM = new QNetworkAccessManager ();
connect (myNAM, SIGNAL(finished(QNetworkReply*)), this, SLOT(onRequestFinished(QNetworkReply*)));
}
-Favicons :: ~Favicons ()
+Favicons::~Favicons ()
{
delete myNAM;
}
***/
QString
-Favicons :: getCacheDir ()
+Favicons::getCacheDir ()
{
const QString base =
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
}
void
-Favicons :: ensureCacheDirHasBeenScanned ()
+Favicons::ensureCacheDirHasBeenScanned ()
{
static bool hasBeenScanned = false;
}
QString
-Favicons :: getHost (const QUrl& url)
+Favicons::getHost (const QUrl& url)
{
QString host = url.host ();
const int first_dot = host.indexOf ('.');
}
QPixmap
-Favicons :: find (const QUrl& url)
+Favicons::find (const QUrl& url)
{
return findFromHost (getHost (url));
}
};
QPixmap
-Favicons :: findFromHost (const QString& host)
+Favicons::findFromHost (const QString& host)
{
ensureCacheDirHasBeenScanned ();
}
void
-Favicons :: add (const QUrl& url)
+Favicons::add (const QUrl& url)
{
ensureCacheDirHasBeenScanned ();
}
void
-Favicons :: onRequestFinished (QNetworkReply * reply)
+Favicons::onRequestFinished (QNetworkReply * reply)
{
const QString host = reply->url().host();
****/
const QHash<QString,int>&
-FileTreeItem :: getMyChildRows ()
+FileTreeItem::getMyChildRows ()
{
const size_t n = childCount();
}
-FileTreeItem :: ~FileTreeItem ()
+FileTreeItem::~FileTreeItem ()
{
assert(myChildren.isEmpty());
}
void
-FileTreeItem :: appendChild (FileTreeItem * child)
+FileTreeItem::appendChild (FileTreeItem * child)
{
const size_t n = childCount();
child->myParent = this;
}
FileTreeItem *
-FileTreeItem :: child (const QString& filename)
+FileTreeItem::child (const QString& filename)
{
FileTreeItem * item(0);
}
int
-FileTreeItem :: row () const
+FileTreeItem::row () const
{
int i(-1);
}
QVariant
-FileTreeItem :: data (int column, int role) const
+FileTreeItem::data (int column, int role) const
{
QVariant value;
}
void
-FileTreeItem :: getSubtreeWantedSize (uint64_t& have, uint64_t& total) const
+FileTreeItem::getSubtreeWantedSize (uint64_t& have, uint64_t& total) const
{
if (myIsWanted)
{
}
double
-FileTreeItem :: progress () const
+FileTreeItem::progress () const
{
double d(0);
uint64_t have(0), total(0);
}
QString
-FileTreeItem :: sizeString () const
+FileTreeItem::sizeString () const
{
QString str;
}
std::pair<int,int>
-FileTreeItem :: update (const QString& name,
- bool wanted,
- int priority,
- uint64_t haveSize,
- bool updateFields)
+FileTreeItem::update (const QString& name,
+ bool wanted,
+ int priority,
+ uint64_t haveSize,
+ bool updateFields)
{
int changed_count = 0;
int changed_columns[4];
}
QString
-FileTreeItem :: priorityString () const
+FileTreeItem::priorityString () const
{
const int i = priority();
}
int
-FileTreeItem :: priority () const
+FileTreeItem::priority () const
{
int i(0);
}
void
-FileTreeItem :: setSubtreePriority (int i, QSet<int>& ids)
+FileTreeItem::setSubtreePriority (int i, QSet<int>& ids)
{
if (myPriority != i)
{
}
void
-FileTreeItem :: twiddlePriority (QSet<int>& ids, int& p)
+FileTreeItem::twiddlePriority (QSet<int>& ids, int& p)
{
const int old(priority());
}
int
-FileTreeItem :: isSubtreeWanted () const
+FileTreeItem::isSubtreeWanted () const
{
if(myChildren.isEmpty())
return myIsWanted ? Qt::Checked : Qt::Unchecked;
}
void
-FileTreeItem :: setSubtreeWanted (bool b, QSet<int>& ids)
+FileTreeItem::setSubtreeWanted (bool b, QSet<int>& ids)
{
if (myIsWanted != b)
{
}
void
-FileTreeItem :: twiddleWanted (QSet<int>& ids, bool& wanted)
+FileTreeItem::twiddleWanted (QSet<int>& ids, bool& wanted)
{
wanted = isSubtreeWanted() != Qt::Checked;
setSubtreeWanted (wanted, ids);
}
QString
-FileTreeItem :: path () const
+FileTreeItem::path () const
{
QString itemPath;
const FileTreeItem * item = this;
}
bool
-FileTreeItem :: isComplete () const
+FileTreeItem::isComplete () const
{
return myHaveSize == totalSize ();
}
****
***/
-FileTreeModel :: FileTreeModel (QObject *parent, bool isEditable):
+FileTreeModel::FileTreeModel (QObject * parent, bool isEditable):
QAbstractItemModel(parent),
myRootItem (new FileTreeItem),
myIndexCache (),
{
}
-FileTreeModel :: ~FileTreeModel()
+FileTreeModel::~FileTreeModel()
{
clear();
}
FileTreeItem *
-FileTreeModel :: itemFromIndex (const QModelIndex& index) const
+FileTreeModel::itemFromIndex (const QModelIndex& index) const
{
return static_cast<FileTreeItem*>(index.internalPointer());
}
QVariant
-FileTreeModel :: data (const QModelIndex &index, int role) const
+FileTreeModel::data (const QModelIndex &index, int role) const
{
QVariant value;
}
Qt::ItemFlags
-FileTreeModel :: flags (const QModelIndex& index) const
+FileTreeModel::flags (const QModelIndex& index) const
{
int i(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
}
bool
-FileTreeModel :: setData (const QModelIndex& index, const QVariant& newname, int role)
+FileTreeModel::setData (const QModelIndex& index, const QVariant& newname, int role)
{
if (role == Qt::EditRole)
{
}
QVariant
-FileTreeModel :: headerData (int column, Qt::Orientation orientation, int role) const
+FileTreeModel::headerData (int column, Qt::Orientation orientation, int role) const
{
QVariant data;
}
QModelIndex
-FileTreeModel :: index (int row, int column, const QModelIndex& parent) const
+FileTreeModel::index (int row, int column, const QModelIndex& parent) const
{
QModelIndex i;
}
QModelIndex
-FileTreeModel :: parent (const QModelIndex& child) const
+FileTreeModel::parent (const QModelIndex& child) const
{
return parent (child, 0); // QAbstractItemModel::parent() wants col 0
}
QModelIndex
-FileTreeModel :: parent (const QModelIndex& child, int column) const
+FileTreeModel::parent (const QModelIndex& child, int column) const
{
QModelIndex parent;
}
int
-FileTreeModel :: rowCount (const QModelIndex& parent) const
+FileTreeModel::rowCount (const QModelIndex& parent) const
{
FileTreeItem * parentItem;
}
int
-FileTreeModel :: columnCount (const QModelIndex &parent) const
+FileTreeModel::columnCount (const QModelIndex& parent) const
{
Q_UNUSED(parent);
}
QModelIndex
-FileTreeModel :: indexOf (FileTreeItem * item, int column) const
+FileTreeModel::indexOf (FileTreeItem * item, int column) const
{
if (!item || item==myRootItem)
return QModelIndex();
}
void
-FileTreeModel :: clearSubtree (const QModelIndex& top)
+FileTreeModel::clearSubtree (const QModelIndex& top)
{
size_t i = rowCount (top);
}
void
-FileTreeModel :: clear ()
+FileTreeModel::clear ()
{
beginResetModel ();
clearSubtree (QModelIndex());
}
FileTreeItem *
-FileTreeModel :: findItemForFileIndex (int fileIndex) const
+FileTreeModel::findItemForFileIndex (int fileIndex) const
{
return myIndexCache.value (fileIndex, 0);
}
void
-FileTreeModel :: addFile (int fileIndex,
- const QString & filename,
- bool wanted,
- int priority,
- uint64_t totalSize,
- uint64_t have,
- QList<QModelIndex> & rowsAdded,
- bool updateFields)
+FileTreeModel::addFile (int fileIndex,
+ const QString & filename,
+ bool wanted,
+ int priority,
+ uint64_t totalSize,
+ uint64_t have,
+ QList<QModelIndex> & rowsAdded,
+ bool updateFields)
{
bool added = false;
FileTreeItem * item;
}
void
-FileTreeModel :: parentsChanged (const QModelIndex& index, int firstColumn, int lastColumn)
+FileTreeModel::parentsChanged (const QModelIndex& index, int firstColumn, int lastColumn)
{
assert (firstColumn <= lastColumn);
}
void
-FileTreeModel :: subtreeChanged (const QModelIndex& index, int firstColumn, int lastColumn)
+FileTreeModel::subtreeChanged (const QModelIndex& index, int firstColumn, int lastColumn)
{
assert (firstColumn <= lastColumn);
}
void
-FileTreeModel :: clicked (const QModelIndex& index)
+FileTreeModel::clicked (const QModelIndex& index)
{
const int column (index.column());
}
void
-FileTreeModel :: doubleClicked (const QModelIndex& index)
+FileTreeModel::doubleClicked (const QModelIndex& index)
{
if (!index.isValid())
return;
****/
QSize
-FileTreeDelegate :: sizeHint(const QStyleOptionViewItem& item, const QModelIndex& index) const
+FileTreeDelegate::sizeHint(const QStyleOptionViewItem& item, const QModelIndex& index) const
{
QSize size;
}
void
-FileTreeDelegate :: paint (QPainter * painter,
- const QStyleOptionViewItem & option,
- const QModelIndex & index) const
+FileTreeDelegate::paint (QPainter * painter,
+ const QStyleOptionViewItem & option,
+ const QModelIndex & index) const
{
const int column(index.column());
return;
}
- QStyle * style (QApplication :: style());
+ QStyle * style (QApplication::style ());
painter->save();
QItemDelegate::drawBackground (painter, option, index);
*****
****/
-FileTreeView :: FileTreeView (QWidget * parent, bool isEditable):
+FileTreeView::FileTreeView (QWidget * parent, bool isEditable):
QTreeView (parent),
myModel (this, isEditable),
myProxy (new QSortFilterProxyModel()),
Qt::QueuedConnection);
}
-FileTreeView :: ~FileTreeView ()
+FileTreeView::~FileTreeView ()
{
myProxy->deleteLater();
}
void
-FileTreeView :: onClicked (const QModelIndex& proxyIndex)
+FileTreeView::onClicked (const QModelIndex& proxyIndex)
{
const QModelIndex modelIndex = myProxy->mapToSource (proxyIndex);
myModel.clicked (modelIndex);
}
void
-FileTreeView :: onDoubleClicked (const QModelIndex& proxyIndex)
+FileTreeView::onDoubleClicked (const QModelIndex& proxyIndex)
{
const QModelIndex modelIndex = myProxy->mapToSource (proxyIndex);
myModel.doubleClicked (modelIndex);
}
void
-FileTreeView :: onOpenRequested (const QString& path)
+FileTreeView::onOpenRequested (const QString& path)
{
if (state () == EditingState)
return;
}
bool
-FileTreeView :: eventFilter (QObject * o, QEvent * event)
+FileTreeView::eventFilter (QObject * o, QEvent * event)
{
// this is kind of a hack to get the last three columns be the
// right size, and to have the filename column use whatever
}
void
-FileTreeView :: update (const FileList& files, bool updateFields)
+FileTreeView::update (const FileList& files, bool updateFields)
{
foreach (const TrFile file, files)
{
}
void
-FileTreeView :: clear ()
+FileTreeView::clear ()
{
myModel.clear();
}
}
}
-FilterBarComboBoxDelegate :: FilterBarComboBoxDelegate (QObject * parent, QComboBox * combo):
+FilterBarComboBoxDelegate::FilterBarComboBoxDelegate (QObject * parent, QComboBox * combo):
QItemDelegate (parent),
myCombo (combo)
{
}
bool
-FilterBarComboBoxDelegate :: isSeparator (const QModelIndex &index)
+FilterBarComboBoxDelegate::isSeparator (const QModelIndex& index)
{
return index.data (Qt::AccessibleDescriptionRole).toString () == QLatin1String ("separator");
}
void
-FilterBarComboBoxDelegate :: setSeparator (QAbstractItemModel * model, const QModelIndex& index)
+FilterBarComboBoxDelegate::setSeparator (QAbstractItemModel * model, const QModelIndex& index)
{
model->setData (index, QString::fromLatin1 ("separator"), Qt::AccessibleDescriptionRole);
}
void
-FilterBarComboBoxDelegate :: paint (QPainter * painter,
- const QStyleOptionViewItem & option,
- const QModelIndex & index) const
+FilterBarComboBoxDelegate::paint (QPainter * painter,
+ const QStyleOptionViewItem & option,
+ const QModelIndex & index) const
{
if (isSeparator (index))
{
}
QSize
-FilterBarComboBoxDelegate :: sizeHint (const QStyleOptionViewItem & option,
- const QModelIndex & index) const
+FilterBarComboBoxDelegate::sizeHint (const QStyleOptionViewItem & option,
+ const QModelIndex & index) const
{
if (isSeparator (index))
{
***
**/
-FilterBarComboBox :: FilterBarComboBox (QWidget * parent):
+FilterBarComboBox::FilterBarComboBox (QWidget * parent):
QComboBox (parent)
{
}
int
-FilterBarComboBox :: currentCount () const
+FilterBarComboBox::currentCount () const
{
int count = 0;
}
void
-FilterBarComboBox :: paintEvent (QPaintEvent * e)
+FilterBarComboBox::paintEvent (QPaintEvent * e)
{
Q_UNUSED (e);
****/
FilterBarComboBox *
-FilterBar :: createActivityCombo ()
+FilterBar::createActivityCombo ()
{
FilterBarComboBox * c = new FilterBarComboBox (this);
FilterBarComboBoxDelegate * delegate = new FilterBarComboBoxDelegate (this, c);
}
void
-FilterBar :: refreshTrackers ()
+FilterBar::refreshTrackers ()
{
Favicons& favicons = dynamic_cast<MyApp*> (QApplication::instance ())->favicons;
const int firstTrackerRow = 2; // skip over the "All" and separator...
FilterBarComboBox *
-FilterBar :: createTrackerCombo (QStandardItemModel * model)
+FilterBar::createTrackerCombo (QStandardItemModel * model)
{
FilterBarComboBox * c = new FilterBarComboBox (this);
FilterBarComboBoxDelegate * delegate = new FilterBarComboBoxDelegate (this, c);
*****
****/
-FilterBar :: FilterBar (Prefs& prefs, TorrentModel& torrents, TorrentFilter& filter, QWidget * parent):
+FilterBar::FilterBar (Prefs& prefs, TorrentModel& torrents, TorrentFilter& filter, QWidget * parent):
QWidget (parent),
myPrefs (prefs),
myTorrents (torrents),
// initialize our state
QList<int> initKeys;
- initKeys << Prefs :: FILTER_MODE
- << Prefs :: FILTER_TRACKERS;
+ initKeys << Prefs::FILTER_MODE
+ << Prefs::FILTER_TRACKERS;
foreach (int key, initKeys)
refreshPref (key);
}
-FilterBar :: ~FilterBar ()
+FilterBar::~FilterBar ()
{
delete myRecountTimer;
}
***/
void
-FilterBar :: refreshPref (int key)
+FilterBar::refreshPref (int key)
{
switch (key)
{
- case Prefs :: FILTER_MODE:
+ case Prefs::FILTER_MODE:
{
const FilterMode m = myPrefs.get<FilterMode> (key);
QAbstractItemModel * model = myActivityCombo->model ();
break;
}
- case Prefs :: FILTER_TRACKERS:
+ case Prefs::FILTER_TRACKERS:
{
const QString tracker = myPrefs.getString (key);
const QString name = readableHostName (tracker);
}
void
-FilterBar :: onTextChanged (const QString& str)
+FilterBar::onTextChanged (const QString& str)
{
if (!myIsBootstrapping)
myPrefs.set (Prefs::FILTER_TEXT, str.trimmed ());
}
void
-FilterBar :: onTrackerIndexChanged (int i)
+FilterBar::onTrackerIndexChanged (int i)
{
if (!myIsBootstrapping)
{
}
void
-FilterBar :: onActivityIndexChanged (int i)
+FilterBar::onActivityIndexChanged (int i)
{
if (!myIsBootstrapping)
{
****
***/
-void FilterBar :: onTorrentModelReset () { recountSoon (); }
-void FilterBar :: onTorrentModelRowsInserted (const QModelIndex&, int, int) { recountSoon (); }
-void FilterBar :: onTorrentModelRowsRemoved (const QModelIndex&, int, int) { recountSoon (); }
-void FilterBar :: onTorrentModelDataChanged (const QModelIndex&, const QModelIndex&) { recountSoon (); }
+void FilterBar::onTorrentModelReset () { recountSoon (); }
+void FilterBar::onTorrentModelRowsInserted (const QModelIndex&, int, int) { recountSoon (); }
+void FilterBar::onTorrentModelRowsRemoved (const QModelIndex&, int, int) { recountSoon (); }
+void FilterBar::onTorrentModelDataChanged (const QModelIndex&, const QModelIndex&) { recountSoon (); }
void
-FilterBar :: recountSoon ()
+FilterBar::recountSoon ()
{
if (!myRecountTimer->isActive ())
{
}
}
void
-FilterBar :: recount ()
+FilterBar::recount ()
{
QAbstractItemModel * model = myActivityCombo->model ();
}
QString
-FilterBar :: getCountString (int n) const
+FilterBar::getCountString (int n) const
{
return QString ("%L1").arg (n);
}
void
-FilterBar :: refreshCountLabel ()
+FilterBar::refreshCountLabel ()
{
const int visibleCount = myFilter.rowCount ();
const int trackerCount = myTrackerCombo->currentCount ();
};
int
-FilterMode :: modeFromName( const QString& name )
+FilterMode::modeFromName (const QString& name)
{
for (int i=0; i<NUM_MODES; ++i)
if( names[i] == name )
};
int
-SortMode :: modeFromName (const QString& name)
+SortMode::modeFromName (const QString& name)
{
for (int i=0; i<NUM_MODES; ++i)
if (names[i] == name)
QString Formatter::unitStrings[3][5];
void
-Formatter :: initUnits ()
+Formatter::initUnits ()
{
speed_K = 1000;
unitStrings[SPEED][B] = tr ( "B/s");
***/
double
-Speed :: KBps () const
+Speed::KBps () const
{
return _Bps / (double)speed_K;
}
Speed
-Speed :: fromKBps (double KBps)
+Speed::fromKBps (double KBps)
{
return int (KBps * speed_K);
}
***/
QString
-Formatter :: memToString (int64_t bytes)
+Formatter::memToString (int64_t bytes)
{
if (bytes < 0)
return tr ("Unknown");
}
QString
-Formatter :: sizeToString (int64_t bytes)
+Formatter::sizeToString (int64_t bytes)
{
if (bytes < 0)
return tr ("Unknown");
}
QString
-Formatter :: speedToString (const Speed& speed)
+Formatter::speedToString (const Speed& speed)
{
char buf[128];
tr_formatter_speed_KBps (buf, speed.KBps (), sizeof (buf));
}
QString
-Formatter :: uploadSpeedToString (const Speed& uploadSpeed)
+Formatter::uploadSpeedToString (const Speed& uploadSpeed)
{
static const QChar uploadSymbol (0x25B4);
}
QString
-Formatter :: downloadSpeedToString (const Speed& downloadSpeed)
+Formatter::downloadSpeedToString (const Speed& downloadSpeed)
{
static const QChar downloadSymbol (0x25BE);
}
QString
-Formatter :: percentToString (double x)
+Formatter::percentToString (double x)
{
char buf[128];
return QString (tr_strpercent (buf, x, sizeof (buf)));
}
QString
-Formatter :: ratioToString (double ratio)
+Formatter::ratioToString (double ratio)
{
char buf[128];
return QString::fromUtf8 (tr_strratio (buf, sizeof (buf), ratio, "\xE2\x88\x9E"));
}
QString
-Formatter :: timeToString (int seconds)
+Formatter::timeToString (int seconds)
{
int days, hours, minutes;
QString d, h, m, s;
static const int INTERVAL_MSEC = 15000;
}
-FreespaceLabel :: FreespaceLabel (Session & session,
- const QString & path,
- QWidget * parent):
+FreespaceLabel::FreespaceLabel (Session & session,
+ const QString & path,
+ QWidget * parent):
QLabel (parent),
mySession (session),
myTag (-1),
}
void
-FreespaceLabel :: setPath (const QString& path)
+FreespaceLabel::setPath (const QString& path)
{
if (myPath != path)
{
}
void
-FreespaceLabel :: onTimer ()
+FreespaceLabel::onTimer ()
{
const int64_t tag = mySession.getUniqueTag ();
const QByteArray myPathUtf8 = myPath.toUtf8 ();
}
void
-FreespaceLabel :: onSessionExecuted (int64_t tag, const QString& result, struct tr_variant * arguments)
+FreespaceLabel::onSessionExecuted (int64_t tag, const QString& result, struct tr_variant * arguments)
{
Q_UNUSED (result);
#include "hig.h"
-HIG :: HIG (QWidget * parent):
+HIG::HIG (QWidget * parent):
QWidget (parent),
myRow (0),
myHasTall (false),
myGrid->setColumnStretch (1, 1);
}
-HIG :: ~HIG ()
+HIG::~HIG ()
{
delete myGrid;
}
***/
void
-HIG :: addSectionDivider ()
+HIG::addSectionDivider ()
{
QWidget * w = new QWidget (this);
myGrid->addWidget (w, myRow, 0, 1, 2);
}
void
-HIG :: addSectionTitle (const QString& title)
+HIG::addSectionTitle (const QString& title)
{
QLabel * label = new QLabel (this);
label->setText (title);
}
void
-HIG :: addSectionTitle (QWidget * w)
+HIG::addSectionTitle (QWidget * w)
{
myGrid->addWidget (w, myRow, 0, 1, 2, Qt::AlignLeft|Qt::AlignVCenter);
++myRow;
}
void
-HIG :: addSectionTitle (QLayout * l)
+HIG::addSectionTitle (QLayout * l)
{
myGrid->addLayout (l, myRow, 0, 1, 2, Qt::AlignLeft|Qt::AlignVCenter);
++myRow;
QLayout *
-HIG :: addRow (QWidget * w)
+HIG::addRow (QWidget * w)
{
QHBoxLayout * h = new QHBoxLayout ();
h->addSpacing (18);
}
void
-HIG :: addWideControl (QLayout * l)
+HIG::addWideControl (QLayout * l)
{
QHBoxLayout * h = new QHBoxLayout ();
h->addSpacing (18);
}
void
-HIG :: addWideControl (QWidget * w)
+HIG::addWideControl (QWidget * w)
{
QHBoxLayout * h = new QHBoxLayout ();
h->addSpacing (18);
}
QCheckBox*
-HIG :: addWideCheckBox (const QString& text, bool isChecked)
+HIG::addWideCheckBox (const QString& text, bool isChecked)
{
QCheckBox * check = new QCheckBox (text, this);
check->setChecked (isChecked);
}
void
-HIG :: addLabel (QWidget * w)
+HIG::addLabel (QWidget * w)
{
QHBoxLayout * h = new QHBoxLayout ();
h->addSpacing (18);
}
QLabel*
-HIG :: addLabel (const QString& text)
+HIG::addLabel (const QString& text)
{
QLabel * label = new QLabel (text, this);
addLabel (label);
}
void
-HIG :: addTallLabel (QWidget * w)
+HIG::addTallLabel (QWidget * w)
{
QHBoxLayout * h = new QHBoxLayout ();
h->addSpacing (18);
}
QLabel*
-HIG :: addTallLabel (const QString& text)
+HIG::addTallLabel (const QString& text)
{
QLabel * label = new QLabel (text, this);
addTallLabel (label);
}
void
-HIG :: addControl (QWidget * w)
+HIG::addControl (QWidget * w)
{
myGrid->addWidget (w, myRow, 1, 1, 1);
}
void
-HIG :: addControl (QLayout * l)
+HIG::addControl (QLayout * l)
{
myGrid->addLayout (l, myRow, 1, 1, 1);
}
QLabel *
-HIG :: addRow (const QString& text, QWidget * control, QWidget * buddy)
+HIG::addRow (const QString& text, QWidget * control, QWidget * buddy)
{
QLabel * label = addLabel (text);
addControl (control);
}
QLabel *
-HIG :: addTallRow (const QString& text, QWidget * control, QWidget * buddy)
+HIG::addTallRow (const QString& text, QWidget * control, QWidget * buddy)
{
QLabel* label = addTallLabel (text);
label->setBuddy (buddy ? buddy : control);
}
QLabel *
-HIG :: addRow (const QString& text, QLayout * control, QWidget * buddy)
+HIG::addRow (const QString& text, QLayout * control, QWidget * buddy)
{
QLabel * label = addLabel (text);
addControl (control);
}
void
-HIG :: addRow (QWidget * label, QWidget * control, QWidget * buddy)
+HIG::addRow (QWidget * label, QWidget * control, QWidget * buddy)
{
addLabel (label);
}
void
-HIG :: addRow (QWidget * label, QLayout * control, QWidget * buddy)
+HIG::addRow (QWidget * label, QLayout * control, QWidget * buddy)
{
addLabel (label);
}
void
-HIG :: finish ()
+HIG::finish ()
{
if (!myHasTall)
{
#include "license.h"
-LicenseDialog :: LicenseDialog (QWidget * parent):
+LicenseDialog::LicenseDialog (QWidget * parent):
QDialog (parent, Qt::Dialog)
{
setWindowTitle (tr ("License"));
QIcon
-TrMainWindow :: getStockIcon (const QString& name, int fallback)
+TrMainWindow::getStockIcon (const QString& name, int fallback)
{
QIcon icon = QIcon::fromTheme (name);
return icon;
}
-TrMainWindow :: TrMainWindow (Session& session, Prefs& prefs, TorrentModel& model, bool minimized):
+TrMainWindow::TrMainWindow (Session& session, Prefs& prefs, TorrentModel& model, bool minimized):
myLastFullUpdateTime (0),
mySessionDialog (new SessionDialog (session, prefs, this)),
myPrefsDialog (0),
ui.verticalLayout->insertWidget (0, myFilterBar = new FilterBar (myPrefs, myModel, myFilterModel));
QList<int> initKeys;
- initKeys << Prefs :: MAIN_WINDOW_X
- << Prefs :: SHOW_TRAY_ICON
- << Prefs :: SORT_REVERSED
- << Prefs :: SORT_MODE
- << Prefs :: FILTERBAR
- << Prefs :: STATUSBAR
- << Prefs :: STATUSBAR_STATS
- << Prefs :: TOOLBAR
- << Prefs :: ALT_SPEED_LIMIT_ENABLED
- << Prefs :: COMPACT_VIEW
- << Prefs :: DSPEED
- << Prefs :: DSPEED_ENABLED
- << Prefs :: USPEED
- << Prefs :: USPEED_ENABLED
- << Prefs :: RATIO
- << Prefs :: RATIO_ENABLED;
+ initKeys << Prefs::MAIN_WINDOW_X
+ << Prefs::SHOW_TRAY_ICON
+ << Prefs::SORT_REVERSED
+ << Prefs::SORT_MODE
+ << Prefs::FILTERBAR
+ << Prefs::STATUSBAR
+ << Prefs::STATUSBAR_STATS
+ << Prefs::TOOLBAR
+ << Prefs::ALT_SPEED_LIMIT_ENABLED
+ << Prefs::COMPACT_VIEW
+ << Prefs::DSPEED
+ << Prefs::DSPEED_ENABLED
+ << Prefs::USPEED
+ << Prefs::USPEED_ENABLED
+ << Prefs::RATIO
+ << Prefs::RATIO_ENABLED;
foreach (int key, initKeys)
refreshPref (key);
refreshTitle ();
}
-TrMainWindow :: ~TrMainWindow ()
+TrMainWindow::~TrMainWindow ()
{
}
****/
void
-TrMainWindow :: onSessionSourceChanged ()
+TrMainWindow::onSessionSourceChanged ()
{
myModel.clear ();
}
void
-TrMainWindow :: onModelReset ()
+TrMainWindow::onModelReset ()
{
refreshTitle ();
refreshActionSensitivitySoon ();
#define PREF_VARIANTS_KEY "pref-variants-list"
void
-TrMainWindow :: onSetPrefs ()
+TrMainWindow::onSetPrefs ()
{
const QVariantList p = sender ()->property (PREF_VARIANTS_KEY).toList ();
assert ( (p.size () % 2) == 0);
}
void
-TrMainWindow :: onSetPrefs (bool isChecked)
+TrMainWindow::onSetPrefs (bool isChecked)
{
if (isChecked)
onSetPrefs ();
#define SHOW_KEY "show-mode"
QWidget *
-TrMainWindow :: createStatusBar ()
+TrMainWindow::createStatusBar ()
{
QMenu * m;
QLabel * l;
}
QMenu *
-TrMainWindow :: createOptionsMenu ()
+TrMainWindow::createOptionsMenu ()
{
QMenu * menu;
QMenu * sub;
****/
void
-TrMainWindow :: setSortPref (int i)
+TrMainWindow::setSortPref (int i)
{
myPrefs.set (Prefs::SORT_MODE, SortMode (i));
}
-void TrMainWindow :: onSortByActivityToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_ACTIVITY); }
-void TrMainWindow :: onSortByAgeToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_AGE); }
-void TrMainWindow :: onSortByETAToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_ETA); }
-void TrMainWindow :: onSortByNameToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_NAME); }
-void TrMainWindow :: onSortByProgressToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_PROGRESS); }
-void TrMainWindow :: onSortByQueueToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_QUEUE); }
-void TrMainWindow :: onSortByRatioToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_RATIO); }
-void TrMainWindow :: onSortBySizeToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_SIZE); }
-void TrMainWindow :: onSortByStateToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_STATE); }
+void TrMainWindow::onSortByActivityToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_ACTIVITY); }
+void TrMainWindow::onSortByAgeToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_AGE); }
+void TrMainWindow::onSortByETAToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_ETA); }
+void TrMainWindow::onSortByNameToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_NAME); }
+void TrMainWindow::onSortByProgressToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_PROGRESS); }
+void TrMainWindow::onSortByQueueToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_QUEUE); }
+void TrMainWindow::onSortByRatioToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_RATIO); }
+void TrMainWindow::onSortBySizeToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_SIZE); }
+void TrMainWindow::onSortByStateToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_STATE); }
void
-TrMainWindow :: setSortAscendingPref (bool b)
+TrMainWindow::setSortAscendingPref (bool b)
{
myPrefs.set (Prefs::SORT_REVERSED, b);
}
****/
void
-TrMainWindow :: showEvent (QShowEvent * event)
+TrMainWindow::showEvent (QShowEvent * event)
{
Q_UNUSED (event);
****/
void
-TrMainWindow :: hideEvent (QHideEvent * event)
+TrMainWindow::hideEvent (QHideEvent * event)
{
Q_UNUSED (event);
****/
void
-TrMainWindow :: onPrefsDestroyed ()
+TrMainWindow::onPrefsDestroyed ()
{
myPrefsDialog = 0;
}
void
-TrMainWindow :: openPreferences ()
+TrMainWindow::openPreferences ()
{
if (myPrefsDialog == 0)
{
}
void
-TrMainWindow :: onDetailsDestroyed ()
+TrMainWindow::onDetailsDestroyed ()
{
myDetailsDialog = 0;
}
void
-TrMainWindow :: openProperties ()
+TrMainWindow::openProperties ()
{
if (myDetailsDialog == 0)
{
}
void
-TrMainWindow :: setLocation ()
+TrMainWindow::setLocation ()
{
QDialog * d = new RelocateDialog (mySession, myModel, getSelectedTorrents (), this);
d->show ();
#endif
void
-TrMainWindow :: openFolder ()
+TrMainWindow::openFolder ()
{
const int torrentId (*getSelectedTorrents ().begin ());
const Torrent * tor (myModel.getTorrentFromId (torrentId));
return;
}
#endif
- QDesktopServices :: openUrl (QUrl::fromLocalFile (path));
+ QDesktopServices::openUrl (QUrl::fromLocalFile (path));
}
void
-TrMainWindow :: copyMagnetLinkToClipboard ()
+TrMainWindow::copyMagnetLinkToClipboard ()
{
const int id (*getSelectedTorrents ().begin ());
mySession.copyMagnetLinkToClipboard (id);
}
void
-TrMainWindow :: openDonate ()
+TrMainWindow::openDonate ()
{
- QDesktopServices :: openUrl (QUrl ("http://www.transmissionbt.com/donate.php"));
+ QDesktopServices::openUrl (QUrl ("http://www.transmissionbt.com/donate.php"));
}
void
-TrMainWindow :: openHelp ()
+TrMainWindow::openHelp ()
{
const char * fmt = "http://www.transmissionbt.com/help/gtk/%d.%dx";
int major, minor;
sscanf (SHORT_VERSION_STRING, "%d.%d", &major, &minor);
char url[128];
tr_snprintf (url, sizeof (url), fmt, major, minor/10);
- QDesktopServices :: openUrl (QUrl (url));
+ QDesktopServices::openUrl (QUrl (url));
}
void
-TrMainWindow :: refreshTitle ()
+TrMainWindow::refreshTitle ()
{
QString title ("Transmission");
const QUrl url (mySession.getRemoteUrl ());
}
void
-TrMainWindow :: refreshTrayIconSoon ()
+TrMainWindow::refreshTrayIconSoon ()
{
if (!myRefreshTrayIconTimer.isActive ())
{
}
}
void
-TrMainWindow :: refreshTrayIcon ()
+TrMainWindow::refreshTrayIcon ()
{
Speed upSpeed, downSpeed;
size_t upCount, downCount;
}
void
-TrMainWindow :: refreshStatusBar ()
+TrMainWindow::refreshStatusBar ()
{
Speed upSpeed, downSpeed;
size_t upCount, downCount;
void
-TrMainWindow :: refreshActionSensitivitySoon ()
+TrMainWindow::refreshActionSensitivitySoon ()
{
if (!myRefreshActionSensitivityTimer.isActive ())
{
}
}
void
-TrMainWindow :: refreshActionSensitivity ()
+TrMainWindow::refreshActionSensitivity ()
{
int selected (0);
int paused (0);
**/
void
-TrMainWindow :: clearSelection ()
+TrMainWindow::clearSelection ()
{
ui.action_DeselectAll->trigger ();
}
QSet<int>
-TrMainWindow :: getSelectedTorrents () const
+TrMainWindow::getSelectedTorrents () const
{
QSet<int> ids;
}
void
-TrMainWindow :: startSelected ()
+TrMainWindow::startSelected ()
{
mySession.startTorrents (getSelectedTorrents ());
}
void
-TrMainWindow :: startSelectedNow ()
+TrMainWindow::startSelectedNow ()
{
mySession.startTorrentsNow (getSelectedTorrents ());
}
void
-TrMainWindow :: pauseSelected ()
+TrMainWindow::pauseSelected ()
{
mySession.pauseTorrents (getSelectedTorrents ());
}
void
-TrMainWindow :: queueMoveTop ()
+TrMainWindow::queueMoveTop ()
{
mySession.queueMoveTop (getSelectedTorrents ());
}
void
-TrMainWindow :: queueMoveUp ()
+TrMainWindow::queueMoveUp ()
{
mySession.queueMoveUp (getSelectedTorrents ());
}
void
-TrMainWindow :: queueMoveDown ()
+TrMainWindow::queueMoveDown ()
{
mySession.queueMoveDown (getSelectedTorrents ());
}
void
-TrMainWindow :: queueMoveBottom ()
+TrMainWindow::queueMoveBottom ()
{
mySession.queueMoveBottom (getSelectedTorrents ());
}
void
-TrMainWindow :: startAll ()
+TrMainWindow::startAll ()
{
mySession.startTorrents ();
}
void
-TrMainWindow :: pauseAll ()
+TrMainWindow::pauseAll ()
{
mySession.pauseTorrents ();
}
void
-TrMainWindow :: removeSelected ()
+TrMainWindow::removeSelected ()
{
removeTorrents (false);
}
void
-TrMainWindow :: deleteSelected ()
+TrMainWindow::deleteSelected ()
{
removeTorrents (true);
}
void
-TrMainWindow :: verifySelected ()
+TrMainWindow::verifySelected ()
{
mySession.verifyTorrents (getSelectedTorrents ());
}
void
-TrMainWindow :: reannounceSelected ()
+TrMainWindow::reannounceSelected ()
{
mySession.reannounceTorrents (getSelectedTorrents ());
}
***
**/
-void TrMainWindow :: showTotalRatio () { myPrefs.set (Prefs::STATUSBAR_STATS, "total-ratio"); }
-void TrMainWindow :: showTotalTransfer () { myPrefs.set (Prefs::STATUSBAR_STATS, "total-transfer"); }
-void TrMainWindow :: showSessionRatio () { myPrefs.set (Prefs::STATUSBAR_STATS, "session-ratio"); }
-void TrMainWindow :: showSessionTransfer () { myPrefs.set (Prefs::STATUSBAR_STATS, "session-transfer"); }
+void TrMainWindow::showTotalRatio () { myPrefs.set (Prefs::STATUSBAR_STATS, "total-ratio"); }
+void TrMainWindow::showTotalTransfer () { myPrefs.set (Prefs::STATUSBAR_STATS, "total-transfer"); }
+void TrMainWindow::showSessionRatio () { myPrefs.set (Prefs::STATUSBAR_STATS, "session-ratio"); }
+void TrMainWindow::showSessionTransfer () { myPrefs.set (Prefs::STATUSBAR_STATS, "session-transfer"); }
/**
***
**/
void
-TrMainWindow :: setCompactView (bool visible)
+TrMainWindow::setCompactView (bool visible)
{
- myPrefs.set (Prefs :: COMPACT_VIEW, visible);
+ myPrefs.set (Prefs::COMPACT_VIEW, visible);
}
void
-TrMainWindow :: toggleSpeedMode ()
+TrMainWindow::toggleSpeedMode ()
{
- myPrefs.toggleBool (Prefs :: ALT_SPEED_LIMIT_ENABLED);
+ myPrefs.toggleBool (Prefs::ALT_SPEED_LIMIT_ENABLED);
const bool mode = myPrefs.get<bool> (Prefs::ALT_SPEED_LIMIT_ENABLED);
myAltSpeedAction->setIcon (mode ? mySpeedModeOnIcon : mySpeedModeOffIcon);
}
void
-TrMainWindow :: setToolbarVisible (bool visible)
+TrMainWindow::setToolbarVisible (bool visible)
{
myPrefs.set (Prefs::TOOLBAR, visible);
}
void
-TrMainWindow :: setFilterbarVisible (bool visible)
+TrMainWindow::setFilterbarVisible (bool visible)
{
myPrefs.set (Prefs::FILTERBAR, visible);
}
void
-TrMainWindow :: setStatusbarVisible (bool visible)
+TrMainWindow::setStatusbarVisible (bool visible)
{
myPrefs.set (Prefs::STATUSBAR, visible);
}
**/
void
-TrMainWindow :: toggleWindows (bool doShow)
+TrMainWindow::toggleWindows (bool doShow)
{
if (!doShow)
{
}
void
-TrMainWindow :: trayActivated (QSystemTrayIcon::ActivationReason reason)
+TrMainWindow::trayActivated (QSystemTrayIcon::ActivationReason reason)
{
if ((reason == QSystemTrayIcon::Trigger) ||
(reason == QSystemTrayIcon::DoubleClick))
void
-TrMainWindow :: refreshPref (int key)
+TrMainWindow::refreshPref (int key)
{
bool b;
int i;
myPrefs.getInt (Prefs::MAIN_WINDOW_HEIGHT));
break;
- case Prefs :: ALT_SPEED_LIMIT_ENABLED:
- case Prefs :: ALT_SPEED_LIMIT_UP:
- case Prefs :: ALT_SPEED_LIMIT_DOWN:
+ case Prefs::ALT_SPEED_LIMIT_ENABLED:
+ case Prefs::ALT_SPEED_LIMIT_UP:
+ case Prefs::ALT_SPEED_LIMIT_DOWN:
{
- b = myPrefs.getBool (Prefs :: ALT_SPEED_LIMIT_ENABLED);
+ b = myPrefs.getBool (Prefs::ALT_SPEED_LIMIT_ENABLED);
myAltSpeedButton->setChecked (b);
myAltSpeedButton->setIcon (b ? mySpeedModeOnIcon : mySpeedModeOffIcon);
const QString fmt = b ? tr ("Click to disable Temporary Speed Limits\n (%1 down, %2 up)")
#define SHOW_OPTIONS_CHECKBOX_NAME "show-options-checkbox"
void
-TrMainWindow :: newTorrent ()
+TrMainWindow::newTorrent ()
{
MakeDialog * dialog = new MakeDialog (mySession, this);
dialog->show ();
}
void
-TrMainWindow :: openTorrent ()
+TrMainWindow::openTorrent ()
{
QFileDialog * d;
d = new QFileDialog (this,
}
void
-TrMainWindow :: openURL ()
+TrMainWindow::openURL ()
{
QString str = QApplication::clipboard ()->text (QClipboard::Selection);
}
void
-TrMainWindow :: addTorrents (const QStringList& filenames)
+TrMainWindow::addTorrents (const QStringList& filenames)
{
bool showOptions = myPrefs.getBool (Prefs::OPTIONS_PROMPT);
}
void
-TrMainWindow :: addTorrent (const AddData& addMe, bool showOptions)
+TrMainWindow::addTorrent (const AddData& addMe, bool showOptions)
{
if (showOptions)
{
Options * o = new Options (mySession, myPrefs, addMe, this);
o->show ();
- QApplication :: alert (o);
+ QApplication::alert (o);
}
else
{
mySession.addTorrent (addMe);
- QApplication :: alert (this);
+ QApplication::alert (this);
}
}
void
-TrMainWindow :: removeTorrents (const bool deleteFiles)
+TrMainWindow::removeTorrents (const bool deleteFiles)
{
QSet<int> ids;
QMessageBox msgBox (this);
***/
void
-TrMainWindow :: updateNetworkIcon ()
+TrMainWindow::updateNetworkIcon ()
{
const time_t now = time (NULL);
const int period = 3;
}
void
-TrMainWindow :: onNetworkTimer ()
+TrMainWindow::onNetworkTimer ()
{
updateNetworkIcon ();
}
void
-TrMainWindow :: dataReadProgress ()
+TrMainWindow::dataReadProgress ()
{
if (!myNetworkError)
myLastReadTime = time (NULL);
}
void
-TrMainWindow :: dataSendProgress ()
+TrMainWindow::dataSendProgress ()
{
myLastSendTime = time (NULL);
}
void
-TrMainWindow :: onError (QNetworkReply::NetworkError code)
+TrMainWindow::onError (QNetworkReply::NetworkError code)
{
const bool hadError = myNetworkError;
const bool haveError = (code != QNetworkReply::NoError)
}
void
-TrMainWindow :: errorMessage (const QString msg)
+TrMainWindow::errorMessage (const QString msg)
{
myErrorMessage = msg;
}
void
-TrMainWindow :: wrongAuthentication ()
+TrMainWindow::wrongAuthentication ()
{
mySession.stop ();
mySessionDialog->show ();
***/
void
-TrMainWindow :: dragEnterEvent (QDragEnterEvent * event)
+TrMainWindow::dragEnterEvent (QDragEnterEvent * event)
{
const QMimeData * mime = event->mimeData ();
}
void
-TrMainWindow :: dropEvent (QDropEvent * event)
+TrMainWindow::dropEvent (QDropEvent * event)
{
QStringList list;
***/
void
-TrMainWindow :: contextMenuEvent (QContextMenuEvent * event)
+TrMainWindow::contextMenuEvent (QContextMenuEvent * event)
{
QMenu * menu = new QMenu (this);
***/
void
-MakeDialog :: onNewDialogDestroyed (QObject * o)
+MakeDialog::onNewDialogDestroyed (QObject * o)
{
Q_UNUSED (o);
}
void
-MakeDialog :: onNewButtonBoxClicked (QAbstractButton * button)
+MakeDialog::onNewButtonBoxClicked (QAbstractButton * button)
{
switch (myNewButtonBox->standardButton (button))
{
}
void
-MakeDialog :: onProgress ()
+MakeDialog::onProgress ()
{
// progress bar
const tr_metainfo_builder * b = myBuilder;
void
-MakeDialog :: makeTorrent ()
+MakeDialog::makeTorrent ()
{
if (!myBuilder)
return;
***/
void
-MakeDialog :: onFileClicked ()
+MakeDialog::onFileClicked ()
{
QFileDialog * d = new QFileDialog (this, tr ("Select File"));
d->setFileMode (QFileDialog::ExistingFile);
d->show ();
}
void
-MakeDialog :: onFileSelected (const QStringList& list)
+MakeDialog::onFileSelected (const QStringList& list)
{
if (!list.empty ())
onFileSelected (list.front ());
}
void
-MakeDialog :: onFileSelected (const QString& filename)
+MakeDialog::onFileSelected (const QString& filename)
{
myFile = Utils::removeTrailingDirSeparator (filename);
myFileButton->setText (QFileInfo(myFile).fileName());
}
void
-MakeDialog :: onFolderClicked ()
+MakeDialog::onFolderClicked ()
{
QFileDialog * d = new QFileDialog (this, tr ("Select Folder"));
d->setFileMode (QFileDialog::Directory);
}
void
-MakeDialog :: onFolderSelected (const QStringList& list)
+MakeDialog::onFolderSelected (const QStringList& list)
{
if (!list.empty ())
onFolderSelected (list.front ());
}
void
-MakeDialog :: onFolderSelected (const QString& filename)
+MakeDialog::onFolderSelected (const QString& filename)
{
myFolder = Utils::removeTrailingDirSeparator (filename);
myFolderButton->setText (QFileInfo(myFolder).fileName());
}
void
-MakeDialog :: onDestinationClicked ()
+MakeDialog::onDestinationClicked ()
{
QFileDialog * d = new QFileDialog (this, tr ("Select Folder"));
d->setFileMode (QFileDialog::Directory);
d->show ();
}
void
-MakeDialog :: onDestinationSelected (const QStringList& list)
+MakeDialog::onDestinationSelected (const QStringList& list)
{
if (!list.empty ())
onDestinationSelected (list.front());
}
void
-MakeDialog :: onDestinationSelected (const QString& filename)
+MakeDialog::onDestinationSelected (const QString& filename)
{
myDestination = Utils::removeTrailingDirSeparator (filename);
myDestinationButton->setText (QFileInfo(myDestination).fileName());
}
void
-MakeDialog :: enableBuddyWhenChecked (QRadioButton * box, QWidget * buddy)
+MakeDialog::enableBuddyWhenChecked (QRadioButton * box, QWidget * buddy)
{
connect (box, SIGNAL(toggled(bool)), buddy, SLOT(setEnabled(bool)));
buddy->setEnabled (box->isChecked ());
}
void
-MakeDialog :: enableBuddyWhenChecked (QCheckBox * box, QWidget * buddy)
+MakeDialog::enableBuddyWhenChecked (QCheckBox * box, QWidget * buddy)
{
connect (box, SIGNAL(toggled(bool)), buddy, SLOT(setEnabled(bool)));
buddy->setEnabled (box->isChecked ());
}
QString
-MakeDialog :: getSource () const
+MakeDialog::getSource () const
{
return myFileRadio->isChecked () ? myFile : myFolder;
}
void
-MakeDialog :: onButtonBoxClicked (QAbstractButton * button)
+MakeDialog::onButtonBoxClicked (QAbstractButton * button)
{
switch (myButtonBox->standardButton (button))
{
***/
void
-MakeDialog :: onSourceChanged ()
+MakeDialog::onSourceChanged ()
{
if (myBuilder)
{
virtual QSize sizeHint () const { return QSize (256, 50); }
};
-MakeDialog :: MakeDialog (Session & session, QWidget * parent):
+MakeDialog::MakeDialog (Session& session, QWidget * parent):
QDialog (parent, Qt::Dialog),
mySession (session),
myBuilder (0)
setWindowTitle (tr ("New Torrent"));
QVBoxLayout * top = new QVBoxLayout (this);
- top->setSpacing (HIG :: PAD);
+ top->setSpacing (HIG::PAD);
HIG * hig = new HIG;
hig->setContentsMargins (0, 0, 0, 0);
onSourceChanged ();
}
-MakeDialog :: ~MakeDialog ()
+MakeDialog::~MakeDialog ()
{
if (myBuilder)
tr_metaInfoBuilderFree (myBuilder);
***/
void
-MakeDialog :: dragEnterEvent (QDragEnterEvent * event)
+MakeDialog::dragEnterEvent (QDragEnterEvent * event)
{
const QMimeData * mime = event->mimeData ();
}
void
-MakeDialog :: dropEvent (QDropEvent * event)
+MakeDialog::dropEvent (QDropEvent * event)
{
const QString filename = event->mimeData()->urls().front().path();
const QFileInfo fileInfo (filename);
****
***/
-Options :: Options (Session& session, const Prefs& prefs, const AddData& addme, QWidget * parent):
+Options::Options (Session& session, const Prefs& prefs, const AddData& addme, QWidget * parent):
QDialog (parent, Qt::Dialog),
mySession (session),
myAdd (addme),
myEditTimer.setSingleShot (true);
connect (&myEditTimer, SIGNAL (timeout ()), this, SLOT (onDestinationEditedIdle ()));
- const int iconSize (style ()->pixelMetric (QStyle :: PM_SmallIconSize));
+ const int iconSize (style ()->pixelMetric (QStyle::PM_SmallIconSize));
QIcon fileIcon = style ()->standardIcon (QStyle::SP_FileIcon);
const QPixmap filePixmap = fileIcon.pixmap (iconSize);
QCheckBox * c;
c = myStartCheck = new QCheckBox (tr ("S&tart when added"));
- c->setChecked (prefs.getBool (Prefs :: START));
+ c->setChecked (prefs.getBool (Prefs::START));
layout->addWidget (c, ++row, 0, 1, 2, Qt::AlignLeft);
c = myTrashCheck = new QCheckBox (tr ("Mo&ve .torrent file to the trash"));
- c->setChecked (prefs.getBool (Prefs :: TRASH_ORIGINAL));
+ c->setChecked (prefs.getBool (Prefs::TRASH_ORIGINAL));
layout->addWidget (c, ++row, 0, 1, 2, Qt::AlignLeft);
QDialogButtonBox * b = new QDialogButtonBox (QDialogButtonBox::Open|QDialogButtonBox::Cancel, Qt::Horizontal, this);
layout->setRowStretch (3, 2);
layout->setColumnStretch (1, 2);
- layout->setSpacing (HIG :: PAD);
+ layout->setSpacing (HIG::PAD);
connect (myTree, SIGNAL (priorityChanged (const QSet<int>&,int)), this, SLOT (onPriorityChanged (const QSet<int>&,int)));
connect (myTree, SIGNAL (wantedChanged (const QSet<int>&,bool)), this, SLOT (onWantedChanged (const QSet<int>&,bool)));
reload ();
}
-Options :: ~Options ()
+Options::~Options ()
{
clearInfo ();
}
***/
void
-Options :: refreshButton (QPushButton * p, const QString& text, int width)
+Options::refreshButton (QPushButton * p, const QString& text, int width)
{
if (width <= 0)
width = p->width ();
}
void
-Options :: refreshSource (int width)
+Options::refreshSource (int width)
{
QString text = myAdd.readableName ();
}
void
-Options :: refreshDestinationButton (int width)
+Options::refreshDestinationButton (int width)
{
if (myDestinationButton != 0)
refreshButton (myDestinationButton, myLocalDestination.absolutePath (), width);
bool
-Options :: eventFilter (QObject * o, QEvent * event)
+Options::eventFilter (QObject * o, QEvent * event)
{
if (event->type() == QEvent::Resize)
{
***/
void
-Options :: clearInfo ()
+Options::clearInfo ()
{
if (myHaveInfo)
tr_metainfoFree (&myInfo);
}
void
-Options :: reload ()
+Options::reload ()
{
clearInfo ();
clearVerify ();
}
void
-Options :: onPriorityChanged (const QSet<int>& fileIndices, int priority)
+Options::onPriorityChanged (const QSet<int>& fileIndices, int priority)
{
foreach (int i, fileIndices)
myPriorities[i] = priority;
}
void
-Options :: onWantedChanged (const QSet<int>& fileIndices, bool isWanted)
+Options::onWantedChanged (const QSet<int>& fileIndices, bool isWanted)
{
foreach (int i, fileIndices)
myWanted[i] = isWanted;
}
void
-Options :: onAccepted ()
+Options::onAccepted ()
{
// rpc spec section 3.4 "adding a torrent"
}
void
-Options :: onFilenameClicked ()
+Options::onFilenameClicked ()
{
if (myAdd.type == AddData::FILENAME)
{
}
void
-Options :: onFilesSelected (const QStringList& files)
+Options::onFilesSelected (const QStringList& files)
{
if (files.size () == 1)
{
}
void
-Options :: onSourceEditingFinished ()
+Options::onSourceEditingFinished ()
{
myAdd.set (mySourceEdit->text());
}
void
-Options :: onDestinationClicked ()
+Options::onDestinationClicked ()
{
QFileDialog * d = new QFileDialog (this, tr ("Select Destination"), myLocalDestination.absolutePath ());
d->setFileMode (QFileDialog::Directory);
}
void
-Options :: onDestinationsSelected (const QStringList& destinations)
+Options::onDestinationsSelected (const QStringList& destinations)
{
if (destinations.size () == 1)
{
}
void
-Options :: onDestinationEdited (const QString& text)
+Options::onDestinationEdited (const QString& text)
{
Q_UNUSED (text);
}
void
-Options :: onDestinationEditedIdle ()
+Options::onDestinationEditedIdle ()
{
myFreespaceLabel->setPath (myDestinationEdit->text());
}
***/
void
-Options :: clearVerify ()
+Options::clearVerify ()
{
myVerifyHash.reset ();
myVerifyFile.close ();
}
void
-Options :: onVerify ()
+Options::onVerify ()
{
clearVerify ();
myVerifyFlags.insert (0, myInfo.pieceCount, false);
}
void
-Options :: onTimeout ()
+Options::onTimeout ()
{
if (myFiles.isEmpty())
{
};
void
-PrefsDialog :: checkBoxToggled (bool checked)
+PrefsDialog::checkBoxToggled (bool checked)
{
const int key (sender ()->property (PREF_KEY).toInt ());
setPref (key, checked);
}
QCheckBox *
-PrefsDialog :: checkBoxNew (const QString& text, int key)
+PrefsDialog::checkBoxNew (const QString& text, int key)
{
QCheckBox * box = new QCheckBox (text);
box->setChecked (myPrefs.getBool (key));
}
void
-PrefsDialog :: enableBuddyWhenChecked (QCheckBox * box, QWidget * buddy)
+PrefsDialog::enableBuddyWhenChecked (QCheckBox * box, QWidget * buddy)
{
connect (box, SIGNAL(toggled(bool)), buddy, SLOT(setEnabled(bool)));
buddy->setEnabled (box->isChecked ());
}
void
-PrefsDialog :: spinBoxEditingFinished()
+PrefsDialog::spinBoxEditingFinished ()
{
const QObject * spin = sender();
const int key = spin->property (PREF_KEY).toInt ();
}
QSpinBox *
-PrefsDialog :: spinBoxNew (int key, int low, int high, int step)
+PrefsDialog::spinBoxNew (int key, int low, int high, int step)
{
QSpinBox * spin = new QSpinBox ();
spin->setRange (low, high);
}
QDoubleSpinBox *
-PrefsDialog :: doubleSpinBoxNew (int key, double low, double high, double step, int decimals)
+PrefsDialog::doubleSpinBoxNew (int key, double low, double high, double step, int decimals)
{
QDoubleSpinBox * spin = new QDoubleSpinBox ();
spin->setRange (low, high);
}
void
-PrefsDialog :: lineEditingFinished ()
+PrefsDialog::lineEditingFinished ()
{
QLineEdit * e = qobject_cast<QLineEdit*>(sender());
if (e && e->isModified ())
}
QLineEdit*
-PrefsDialog :: lineEditNew (int key, int echoMode)
+PrefsDialog::lineEditNew (int key, int echoMode)
{
QLineEdit * e = new QLineEdit (myPrefs.getString (key));
e->setProperty (PREF_KEY, key);
***/
QWidget *
-PrefsDialog :: createRemoteTab (Session& session)
+PrefsDialog::createRemoteTab (Session& session)
{
HIG * hig = new HIG (this);
hig->addSectionTitle (tr ("Remote Control"));
***/
void
-PrefsDialog :: altSpeedDaysEdited (int i)
+PrefsDialog::altSpeedDaysEdited (int i)
{
const int value = qobject_cast<QComboBox*>(sender())->itemData(i).toInt();
setPref (Prefs::ALT_SPEED_LIMIT_TIME_DAY, value);
QWidget *
-PrefsDialog :: createSpeedTab ()
+PrefsDialog::createSpeedTab ()
{
QWidget *l, *r;
HIG * hig = new HIG (this);
hig->addSectionDivider ();
QHBoxLayout * h = new QHBoxLayout;
- h->setSpacing (HIG :: PAD);
+ h->setSpacing (HIG::PAD);
QLabel * label = new QLabel;
label->setPixmap (QPixmap (QString::fromUtf8 (":/icons/alt-limit-off.png")));
label->setAlignment (Qt::AlignLeft|Qt::AlignVCenter);
hig->addWideControl (new QLabel (s));
s = tr ("U&pload (%1):").arg (speed_K_str);
- r = spinBoxNew (Prefs :: ALT_SPEED_LIMIT_UP, 0, INT_MAX, 5);
+ r = spinBoxNew (Prefs::ALT_SPEED_LIMIT_UP, 0, INT_MAX, 5);
hig->addRow (s, r);
s = tr ("Do&wnload (%1):").arg (speed_K_str);
- r = spinBoxNew (Prefs :: ALT_SPEED_LIMIT_DOWN, 0, INT_MAX, 5);
+ r = spinBoxNew (Prefs::ALT_SPEED_LIMIT_DOWN, 0, INT_MAX, 5);
hig->addRow (s, r);
QCheckBox * c = checkBoxNew (tr ("&Scheduled times:"), Prefs::ALT_SPEED_LIMIT_TIME_ENABLED);
h = new QHBoxLayout ();
h->setSpacing (HIG::PAD);
- QWidget * w = timeEditNew (Prefs :: ALT_SPEED_LIMIT_TIME_BEGIN);
+ QWidget * w = timeEditNew (Prefs::ALT_SPEED_LIMIT_TIME_BEGIN);
h->addWidget (w, 1);
mySchedWidgets << w;
QLabel * nd = new QLabel (tr("&to"));
h->addWidget (nd);
mySchedWidgets << nd;
- w = timeEditNew (Prefs :: ALT_SPEED_LIMIT_TIME_END);
+ w = timeEditNew (Prefs::ALT_SPEED_LIMIT_TIME_END);
nd->setBuddy (w);
h->addWidget (w, 1);
mySchedWidgets << w;
box->addItem (noIcon, tr ("Thursday"), QVariant (TR_SCHED_THURS));
box->addItem (noIcon, tr ("Friday"), QVariant (TR_SCHED_FRI));
box->addItem (noIcon, tr ("Saturday"), QVariant (TR_SCHED_SAT));
- box->setCurrentIndex (box->findData (myPrefs.getInt (Prefs :: ALT_SPEED_LIMIT_TIME_DAY)));
+ box->setCurrentIndex (box->findData (myPrefs.getInt (Prefs::ALT_SPEED_LIMIT_TIME_DAY)));
connect (box, SIGNAL(activated(int)), this, SLOT(altSpeedDaysEdited(int)));
w = hig->addRow (s, box);
mySchedWidgets << w << box;
***/
QWidget *
-PrefsDialog :: createDesktopTab ()
+PrefsDialog::createDesktopTab ()
{
HIG * hig = new HIG (this);
hig->addSectionTitle (tr ("Desktop"));
***/
void
-PrefsDialog :: onPortTested (bool isOpen)
+PrefsDialog::onPortTested (bool isOpen)
{
myPortButton->setEnabled (true);
myWidgets[Prefs::PEER_PORT]->setEnabled (true);
}
void
-PrefsDialog :: onPortTest ()
+PrefsDialog::onPortTest ()
{
myPortLabel->setText (tr ("Testing TCP Port..."));
myPortButton->setEnabled (false);
}
QWidget *
-PrefsDialog :: createNetworkTab ()
+PrefsDialog::createNetworkTab ()
{
HIG * hig = new HIG (this);
hig->addSectionTitle (tr ("Incoming Peers"));
QPushButton * b = myPortButton = new QPushButton (tr ("Te&st Port"));
QLabel * l = myPortLabel = new QLabel (tr ("Status unknown"));
h->addWidget (l);
- h->addSpacing (HIG :: PAD_BIG);
+ h->addSpacing (HIG::PAD_BIG);
h->addWidget (b);
h->setStretchFactor (l, 1);
connect (b, SIGNAL(clicked(bool)), this, SLOT(onPortTest()));
hig->addRow (tr ("&Port for incoming connections:"), s);
hig->addRow (QString(), h, 0);
- hig->addWideControl (checkBoxNew (tr ("Pick a &random port every time Transmission is started"), Prefs :: PEER_PORT_RANDOM_ON_START));
+ hig->addWideControl (checkBoxNew (tr ("Pick a &random port every time Transmission is started"), Prefs::PEER_PORT_RANDOM_ON_START));
hig->addWideControl (checkBoxNew (tr ("Use UPnP or NAT-PMP port &forwarding from my router"), Prefs::PORT_FORWARDING));
hig->addSectionDivider ();
***/
void
-PrefsDialog :: onBlocklistDialogDestroyed (QObject * o)
+PrefsDialog::onBlocklistDialogDestroyed (QObject * o)
{
Q_UNUSED (o);
}
void
-PrefsDialog :: onUpdateBlocklistCancelled ()
+PrefsDialog::onUpdateBlocklistCancelled ()
{
disconnect (&mySession, SIGNAL(blocklistUpdated(int)), this, SLOT(onBlocklistUpdated(int)));
myBlocklistDialog->deleteLater ();
}
void
-PrefsDialog :: onBlocklistUpdated (int n)
+PrefsDialog::onBlocklistUpdated (int n)
{
myBlocklistDialog->setText (tr ("<b>Update succeeded!</b><p>Blocklist now has %Ln rules.", 0, n));
myBlocklistDialog->setTextFormat (Qt::RichText);
}
void
-PrefsDialog :: onUpdateBlocklistClicked ()
+PrefsDialog::onUpdateBlocklistClicked ()
{
myBlocklistDialog = new QMessageBox (QMessageBox::Information,
QString(),
}
void
-PrefsDialog :: encryptionEdited (int i)
+PrefsDialog::encryptionEdited (int i)
{
const int value (qobject_cast<QComboBox*>(sender())->itemData(i).toInt ());
setPref (Prefs::ENCRYPTION, value);
}
QWidget *
-PrefsDialog :: createPrivacyTab ()
+PrefsDialog::createPrivacyTab ()
{
QWidget * w;
HIG * hig = new HIG (this);
box->addItem (tr ("Allow encryption"), 0);
box->addItem (tr ("Prefer encryption"), 1);
box->addItem (tr ("Require encryption"), 2);
- myWidgets.insert (Prefs :: ENCRYPTION, box);
+ myWidgets.insert (Prefs::ENCRYPTION, box);
connect (box, SIGNAL(activated(int)), this, SLOT(encryptionEdited(int)));
hig->addRow (tr ("&Encryption mode:"), box);
***/
void
-PrefsDialog :: onScriptClicked (void)
+PrefsDialog::onScriptClicked (void)
{
const QString title = tr ("Select \"Torrent Done\" Script");
const QString myPath = myPrefs.getString (Prefs::SCRIPT_TORRENT_DONE_FILENAME);
}
void
-PrefsDialog :: onIncompleteClicked (void)
+PrefsDialog::onIncompleteClicked (void)
{
const QString title = tr ("Select Incomplete Directory");
const QString myPath = myPrefs.getString (Prefs::INCOMPLETE_DIR);
}
void
-PrefsDialog :: onWatchClicked (void)
+PrefsDialog::onWatchClicked (void)
{
const QString title = tr ("Select Watch Directory");
const QString myPath = myPrefs.getString (Prefs::DIR_WATCH);
}
void
-PrefsDialog :: onDestinationClicked (void)
+PrefsDialog::onDestinationClicked (void)
{
const QString title = tr ("Select Destination");
const QString myPath = myPrefs.getString (Prefs::DOWNLOAD_DIR);
}
void
-PrefsDialog :: onLocationSelected (const QString& path, int key)
+PrefsDialog::onLocationSelected (const QString& path, int key)
{
setPref (key, path);
}
QWidget *
-PrefsDialog :: createSeedingTab ()
+PrefsDialog::createSeedingTab ()
{
- const int iconSize (style ()->pixelMetric (QStyle :: PM_SmallIconSize));
+ const int iconSize (style ()->pixelMetric (QStyle::PM_SmallIconSize));
const QFileIconProvider iconProvider;
const QIcon folderIcon = iconProvider.icon (QFileIconProvider::Folder);
const QPixmap folderPixmap = folderIcon.pixmap (iconSize);
}
QWidget *
-PrefsDialog :: createDownloadingTab ()
+PrefsDialog::createDownloadingTab ()
{
- const int iconSize (style ()->pixelMetric (QStyle :: PM_SmallIconSize));
+ const int iconSize (style ()->pixelMetric (QStyle::PM_SmallIconSize));
const QFileIconProvider iconProvider;
const QIcon folderIcon = iconProvider.icon (QFileIconProvider::Folder);
const QPixmap folderPixmap = folderIcon.pixmap (iconSize);
****
***/
-PrefsDialog :: PrefsDialog (Session& session, Prefs& prefs, QWidget * parent):
+PrefsDialog::PrefsDialog (Session& session, Prefs& prefs, QWidget * parent):
QDialog (parent),
myIsServer (session.isServer ()),
mySession (session),
connect (&mySession, SIGNAL(sessionUpdated()), this, SLOT(sessionUpdated()));
QList<int> keys;
- keys << Prefs :: RPC_ENABLED
- << Prefs :: ALT_SPEED_LIMIT_ENABLED
- << Prefs :: ALT_SPEED_LIMIT_TIME_ENABLED
- << Prefs :: ENCRYPTION
- << Prefs :: BLOCKLIST_ENABLED
- << Prefs :: DIR_WATCH
- << Prefs :: DOWNLOAD_DIR
- << Prefs :: INCOMPLETE_DIR
- << Prefs :: INCOMPLETE_DIR_ENABLED
- << Prefs :: SCRIPT_TORRENT_DONE_FILENAME;
+ keys << Prefs::RPC_ENABLED
+ << Prefs::ALT_SPEED_LIMIT_ENABLED
+ << Prefs::ALT_SPEED_LIMIT_TIME_ENABLED
+ << Prefs::ENCRYPTION
+ << Prefs::BLOCKLIST_ENABLED
+ << Prefs::DIR_WATCH
+ << Prefs::DOWNLOAD_DIR
+ << Prefs::INCOMPLETE_DIR
+ << Prefs::INCOMPLETE_DIR_ENABLED
+ << Prefs::SCRIPT_TORRENT_DONE_FILENAME;
foreach (int key, keys)
refreshPref (key);
}
}
-PrefsDialog :: ~PrefsDialog ()
+PrefsDialog::~PrefsDialog ()
{
}
void
-PrefsDialog :: setPref (int key, const QVariant& v)
+PrefsDialog::setPref (int key, const QVariant& v)
{
myPrefs.set (key, v);
refreshPref (key);
***/
void
-PrefsDialog :: sessionUpdated ()
+PrefsDialog::sessionUpdated ()
{
updateBlocklistLabel ();
}
void
-PrefsDialog :: updateBlocklistLabel ()
+PrefsDialog::updateBlocklistLabel ()
{
const int n = mySession.blocklistSize ();
myBlocklistLabel->setText (tr ("<i>Blocklist contains %Ln rules</i>", 0, n));
}
void
-PrefsDialog :: refreshPref (int key)
+PrefsDialog::refreshPref (int key)
{
switch (key)
{
- case Prefs :: RPC_ENABLED:
- case Prefs :: RPC_WHITELIST_ENABLED:
- case Prefs :: RPC_AUTH_REQUIRED:
+ case Prefs::RPC_ENABLED:
+ case Prefs::RPC_WHITELIST_ENABLED:
+ case Prefs::RPC_AUTH_REQUIRED:
{
const bool enabled (myPrefs.getBool (Prefs::RPC_ENABLED));
const bool whitelist (myPrefs.getBool (Prefs::RPC_WHITELIST_ENABLED));
break;
}
- case Prefs :: ALT_SPEED_LIMIT_TIME_ENABLED:
+ case Prefs::ALT_SPEED_LIMIT_TIME_ENABLED:
{
const bool enabled = myPrefs.getBool (key);
foreach (QWidget * w, mySchedWidgets)w->setEnabled (enabled);
break;
}
- case Prefs :: BLOCKLIST_ENABLED:
+ case Prefs::BLOCKLIST_ENABLED:
{
const bool enabled = myPrefs.getBool (key);
foreach (QWidget * w, myBlockWidgets)w->setEnabled (enabled);
break;
}
- case Prefs :: DIR_WATCH:
+ case Prefs::DIR_WATCH:
myWatchButton->setText (QFileInfo(myPrefs.getString(Prefs::DIR_WATCH)).fileName());
break;
- case Prefs :: SCRIPT_TORRENT_DONE_FILENAME:
+ case Prefs::SCRIPT_TORRENT_DONE_FILENAME:
{
const QString path (myPrefs.getString (key));
myTorrentDoneScriptButton->setText (QFileInfo(path).fileName());
break;
}
- case Prefs :: PEER_PORT:
+ case Prefs::PEER_PORT:
myPortLabel->setText (tr ("Status unknown"));
myPortButton->setEnabled (true);
break;
- case Prefs :: DOWNLOAD_DIR:
+ case Prefs::DOWNLOAD_DIR:
{
const QString path (myPrefs.getString (key));
myDestinationButton->setText (QFileInfo(path).fileName());
break;
}
- case Prefs :: INCOMPLETE_DIR:
+ case Prefs::INCOMPLETE_DIR:
{
QString path (myPrefs.getString (key));
myIncompleteButton->setText (QFileInfo(path).fileName());
break;
}
- case Prefs :: INCOMPLETE_DIR_ENABLED:
+ case Prefs::INCOMPLETE_DIR_ENABLED:
{
const bool enabled = myPrefs.getBool (key);
myIncompleteButton->setEnabled (enabled);
}
bool
-PrefsDialog :: isAllowed (int key) const
+PrefsDialog::isAllowed (int key) const
{
Q_UNUSED (key);
****
***/
-Prefs :: Prefs (const char * configDir):
+Prefs::Prefs (const char * configDir):
myConfigDir (QString::fromUtf8 (configDir))
{
assert (sizeof(myItems) / sizeof(myItems[0]) == PREFS_COUNT);
case QVariant::DateTime:
if (tr_variantGetInt (b, &intVal))
- myValues[i].setValue (QDateTime :: fromTime_t (intVal));
+ myValues[i].setValue (QDateTime::fromTime_t (intVal));
break;
default:
tr_variantFree (&top);
}
-Prefs :: ~Prefs ()
+Prefs::~Prefs ()
{
// make a dict from settings.json
tr_variant current_settings;
* If you add a new preferences key, you /must/ add a default value here.
*/
void
-Prefs :: initDefaults (tr_variant * d)
+Prefs::initDefaults (tr_variant * d)
{
tr_variantDictReserve (d, 38);
tr_variantDictAddBool (d, TR_KEY_blocklist_updates_enabled, true);
***/
bool
-Prefs :: getBool (int key) const
+Prefs::getBool (int key) const
{
assert (myItems[key].type == QVariant::Bool);
return myValues[key].toBool();
}
QString
-Prefs :: getString (int key) const
+Prefs::getString (int key) const
{
assert (myItems[key].type == QVariant::String);
const QByteArray b = myValues[key].toByteArray();
}
int
-Prefs :: getInt (int key) const
+Prefs::getInt (int key) const
{
assert (myItems[key].type == QVariant::Int);
return myValues[key].toInt();
}
double
-Prefs :: getDouble (int key) const
+Prefs::getDouble (int key) const
{
assert (myItems[key].type == QVariant::Double);
return myValues[key].toDouble();
}
QDateTime
-Prefs :: getDateTime (int key) const
+Prefs::getDateTime (int key) const
{
assert (myItems[key].type == QVariant::DateTime);
return myValues[key].toDateTime();
***/
void
-Prefs :: toggleBool (int key)
+Prefs::toggleBool (int key)
{
set (key, !getBool(key));
}
#include "torrent-model.h"
#include "utils.h"
-bool RelocateDialog :: myMoveFlag = true;
+bool RelocateDialog::myMoveFlag = true;
void
-RelocateDialog :: onSetLocation ()
+RelocateDialog::onSetLocation ()
{
mySession.torrentSetLocation (myIds, myPath, myMoveFlag);
deleteLater ();
}
void
-RelocateDialog :: onFileSelected (const QString& path)
+RelocateDialog::onFileSelected (const QString& path)
{
myPath = path;
myDirButton->setText (myPath);
}
void
-RelocateDialog :: onDirButtonClicked ()
+RelocateDialog::onDirButtonClicked ()
{
const QString title = tr ("Select Location");
const QString path = Utils::remoteFileChooser (this, title, myPath, true, mySession.isServer ());
}
void
-RelocateDialog :: onMoveToggled (bool b)
+RelocateDialog::onMoveToggled (bool b)
{
myMoveFlag = b;
}
-RelocateDialog :: RelocateDialog (Session & session,
- TorrentModel & model,
- const QSet<int> & ids,
- QWidget * parent):
+RelocateDialog::RelocateDialog (Session & session,
+ TorrentModel & model,
+ const QSet<int> & ids,
+ QWidget * parent):
QDialog (parent),
mySession (session),
myModel (model),
myIds (ids)
{
- const int iconSize (style ()->pixelMetric (QStyle :: PM_SmallIconSize));
+ const int iconSize (style ()->pixelMetric (QStyle::PM_SmallIconSize));
const QFileIconProvider iconProvider;
const QIcon folderIcon = iconProvider.icon (QFileIconProvider::Folder);
const QPixmap folderPixmap = folderIcon.pixmap (iconSize);
***/
void
-SessionDialog :: onAccepted ()
+SessionDialog::onAccepted ()
{
myPrefs.set (Prefs::SESSION_IS_REMOTE, myRemoteRadioButton->isChecked ());
myPrefs.set (Prefs::SESSION_REMOTE_HOST, myHostLineEdit->text ());
}
void
-SessionDialog :: resensitize ()
+SessionDialog::resensitize ()
{
const bool isRemote = myRemoteRadioButton->isChecked();
const bool useAuth = myAuthCheckBox->isChecked();
****
***/
-SessionDialog :: SessionDialog (Session& session, Prefs& prefs, QWidget * parent):
+SessionDialog::SessionDialog (Session& session, Prefs& prefs, QWidget * parent):
QDialog (parent),
mySession (session),
myPrefs (prefs)
setWindowTitle (tr ("Change Session"));
QVBoxLayout * top = new QVBoxLayout (this);
- top->setSpacing (HIG :: PAD);
+ top->setSpacing (HIG::PAD);
HIG * hig = new HIG;
hig->setContentsMargins (0, 0, 0, 0);
***/
void
-FileAdded :: executed (int64_t tag, const QString& result, struct tr_variant * arguments)
+FileAdded::executed (int64_t tag, const QString& result, struct tr_variant * arguments)
{
Q_UNUSED (arguments);
***/
void
-Session :: sessionSet (const tr_quark key, const QVariant& value)
+Session::sessionSet (const tr_quark key, const QVariant& value)
{
tr_variant top;
tr_variantInitDict (&top, 2);
}
void
-Session :: portTest ()
+Session::portTest ()
{
tr_variant top;
tr_variantInitDict (&top, 2);
}
void
-Session :: copyMagnetLinkToClipboard (int torrentId)
+Session::copyMagnetLinkToClipboard (int torrentId)
{
tr_variant top;
tr_variantInitDict (&top, 3);
}
void
-Session :: updatePref (int key)
+Session::updatePref (int key)
{
if (myPrefs.isCore (key)) switch (key)
{
- case Prefs :: ALT_SPEED_LIMIT_DOWN:
- case Prefs :: ALT_SPEED_LIMIT_ENABLED:
- case Prefs :: ALT_SPEED_LIMIT_TIME_BEGIN:
- case Prefs :: ALT_SPEED_LIMIT_TIME_DAY:
- case Prefs :: ALT_SPEED_LIMIT_TIME_ENABLED:
- case Prefs :: ALT_SPEED_LIMIT_TIME_END:
- case Prefs :: ALT_SPEED_LIMIT_UP:
- case Prefs :: BLOCKLIST_DATE:
- case Prefs :: BLOCKLIST_ENABLED:
- case Prefs :: BLOCKLIST_URL:
- case Prefs :: DHT_ENABLED:
- case Prefs :: DOWNLOAD_QUEUE_ENABLED:
- case Prefs :: DOWNLOAD_QUEUE_SIZE:
- case Prefs :: DSPEED:
- case Prefs :: DSPEED_ENABLED:
- case Prefs :: IDLE_LIMIT:
- case Prefs :: IDLE_LIMIT_ENABLED:
- case Prefs :: INCOMPLETE_DIR:
- case Prefs :: INCOMPLETE_DIR_ENABLED:
- case Prefs :: LPD_ENABLED:
- case Prefs :: PEER_LIMIT_GLOBAL:
- case Prefs :: PEER_LIMIT_TORRENT:
- case Prefs :: PEER_PORT:
- case Prefs :: PEER_PORT_RANDOM_ON_START:
- case Prefs :: QUEUE_STALLED_MINUTES:
- case Prefs :: PEX_ENABLED:
- case Prefs :: PORT_FORWARDING:
- case Prefs :: RENAME_PARTIAL_FILES:
- case Prefs :: SCRIPT_TORRENT_DONE_ENABLED:
- case Prefs :: SCRIPT_TORRENT_DONE_FILENAME:
- case Prefs :: START:
- case Prefs :: TRASH_ORIGINAL:
- case Prefs :: USPEED:
- case Prefs :: USPEED_ENABLED:
- case Prefs :: UTP_ENABLED:
+ case Prefs::ALT_SPEED_LIMIT_DOWN:
+ case Prefs::ALT_SPEED_LIMIT_ENABLED:
+ case Prefs::ALT_SPEED_LIMIT_TIME_BEGIN:
+ case Prefs::ALT_SPEED_LIMIT_TIME_DAY:
+ case Prefs::ALT_SPEED_LIMIT_TIME_ENABLED:
+ case Prefs::ALT_SPEED_LIMIT_TIME_END:
+ case Prefs::ALT_SPEED_LIMIT_UP:
+ case Prefs::BLOCKLIST_DATE:
+ case Prefs::BLOCKLIST_ENABLED:
+ case Prefs::BLOCKLIST_URL:
+ case Prefs::DHT_ENABLED:
+ case Prefs::DOWNLOAD_QUEUE_ENABLED:
+ case Prefs::DOWNLOAD_QUEUE_SIZE:
+ case Prefs::DSPEED:
+ case Prefs::DSPEED_ENABLED:
+ case Prefs::IDLE_LIMIT:
+ case Prefs::IDLE_LIMIT_ENABLED:
+ case Prefs::INCOMPLETE_DIR:
+ case Prefs::INCOMPLETE_DIR_ENABLED:
+ case Prefs::LPD_ENABLED:
+ case Prefs::PEER_LIMIT_GLOBAL:
+ case Prefs::PEER_LIMIT_TORRENT:
+ case Prefs::PEER_PORT:
+ case Prefs::PEER_PORT_RANDOM_ON_START:
+ case Prefs::QUEUE_STALLED_MINUTES:
+ case Prefs::PEX_ENABLED:
+ case Prefs::PORT_FORWARDING:
+ case Prefs::RENAME_PARTIAL_FILES:
+ case Prefs::SCRIPT_TORRENT_DONE_ENABLED:
+ case Prefs::SCRIPT_TORRENT_DONE_FILENAME:
+ case Prefs::START:
+ case Prefs::TRASH_ORIGINAL:
+ case Prefs::USPEED:
+ case Prefs::USPEED_ENABLED:
+ case Prefs::UTP_ENABLED:
sessionSet (myPrefs.getKey (key), myPrefs.variant (key));
break;
- case Prefs :: DOWNLOAD_DIR:
+ case Prefs::DOWNLOAD_DIR:
sessionSet (myPrefs.getKey (key), myPrefs.variant (key));
/* this will change the 'freespace' argument, so refresh */
refreshSessionInfo ();
break;
- case Prefs :: RATIO:
+ case Prefs::RATIO:
sessionSet (TR_KEY_seedRatioLimit, myPrefs.variant (key));
break;
- case Prefs :: RATIO_ENABLED:
+ case Prefs::RATIO_ENABLED:
sessionSet (TR_KEY_seedRatioLimited, myPrefs.variant (key));
break;
- case Prefs :: ENCRYPTION:
+ case Prefs::ENCRYPTION:
{
const int i = myPrefs.variant (key).toInt ();
switch (i)
break;
}
- case Prefs :: RPC_AUTH_REQUIRED:
+ case Prefs::RPC_AUTH_REQUIRED:
if (mySession)
tr_sessionSetRPCPasswordEnabled (mySession, myPrefs.getBool (key));
break;
- case Prefs :: RPC_ENABLED:
+ case Prefs::RPC_ENABLED:
if (mySession)
tr_sessionSetRPCEnabled (mySession, myPrefs.getBool (key));
break;
- case Prefs :: RPC_PASSWORD:
+ case Prefs::RPC_PASSWORD:
if (mySession)
tr_sessionSetRPCPassword (mySession, myPrefs.getString (key).toUtf8 ().constData ());
break;
- case Prefs :: RPC_PORT:
+ case Prefs::RPC_PORT:
if (mySession)
tr_sessionSetRPCPort (mySession, myPrefs.getInt (key));
break;
- case Prefs :: RPC_USERNAME:
+ case Prefs::RPC_USERNAME:
if (mySession)
tr_sessionSetRPCUsername (mySession, myPrefs.getString (key).toUtf8 ().constData ());
break;
- case Prefs :: RPC_WHITELIST_ENABLED:
+ case Prefs::RPC_WHITELIST_ENABLED:
if (mySession)
tr_sessionSetRPCWhitelistEnabled (mySession, myPrefs.getBool (key));
break;
- case Prefs :: RPC_WHITELIST:
+ case Prefs::RPC_WHITELIST:
if (mySession)
tr_sessionSetRPCWhitelist (mySession, myPrefs.getString (key).toUtf8 ().constData ());
break;
****
***/
-Session :: Session (const char * configDir, Prefs& prefs):
+Session::Session (const char * configDir, Prefs& prefs):
nextUniqueTag (FIRST_UNIQUE_TAG),
myBlocklistSize (-1),
myPrefs (prefs),
this, SLOT (onResponseReceived (const QByteArray&)));
}
-Session :: ~Session ()
+Session::~Session ()
{
stop ();
}
QNetworkAccessManager *
-Session :: networkAccessManager ()
+Session::networkAccessManager ()
{
if (myNAM == 0)
{
***/
void
-Session :: stop ()
+Session::stop ()
{
if (myNAM != 0)
{
}
void
-Session :: restart ()
+Session::restart ()
{
stop ();
start ();
}
void
-Session :: start ()
+Session::start ()
{
if (myPrefs.get<bool> (Prefs::SESSION_IS_REMOTE))
{
}
bool
-Session :: isServer () const
+Session::isServer () const
{
return mySession != 0;
}
bool
-Session :: isLocal () const
+Session::isLocal () const
{
if (mySession != 0)
return true;
}
void
-Session :: torrentSet (const QSet<int>& ids, const tr_quark key, double value)
+Session::torrentSet (const QSet<int>& ids, const tr_quark key, double value)
{
tr_variant top;
tr_variantInitDict (&top, 2);
}
void
-Session :: torrentSet (const QSet<int>& ids, const tr_quark key, int value)
+Session::torrentSet (const QSet<int>& ids, const tr_quark key, int value)
{
tr_variant top;
tr_variantInitDict (&top, 2);
}
void
-Session :: torrentSet (const QSet<int>& ids, const tr_quark key, bool value)
+Session::torrentSet (const QSet<int>& ids, const tr_quark key, bool value)
{
tr_variant top;
tr_variantInitDict (&top, 2);
}
void
-Session :: torrentSet (const QSet<int>& ids, const tr_quark key, const QStringList& value)
+Session::torrentSet (const QSet<int>& ids, const tr_quark key, const QStringList& value)
{
tr_variant top;
tr_variantInitDict (&top, 2);
}
void
-Session :: torrentSet (const QSet<int>& ids, const tr_quark key, const QList<int>& value)
+Session::torrentSet (const QSet<int>& ids, const tr_quark key, const QList<int>& value)
{
tr_variant top;
tr_variantInitDict (&top, 2);
}
void
-Session :: torrentSet (const QSet<int>& ids, const tr_quark key, const QPair<int,QString>& value)
+Session::torrentSet (const QSet<int>& ids, const tr_quark key, const QPair<int,QString>& value)
{
tr_variant top;
tr_variantInitDict (&top, 2);
}
void
-Session :: torrentSetLocation (const QSet<int>& ids, const QString& location, bool doMove)
+Session::torrentSetLocation (const QSet<int>& ids, const QString& location, bool doMove)
{
tr_variant top;
tr_variantInitDict (&top, 2);
}
void
-Session :: torrentRenamePath (const QSet<int>& ids, const QString& oldpath, const QString& newname)
+Session::torrentRenamePath (const QSet<int>& ids, const QString& oldpath, const QString& newname)
{
tr_variant top;
tr_variantInitDict (&top, 2);
}
void
-Session :: refreshTorrents (const QSet<int>& ids)
+Session::refreshTorrents (const QSet<int>& ids)
{
if (ids.empty ())
{
}
void
-Session :: refreshExtraStats (const QSet<int>& ids)
+Session::refreshExtraStats (const QSet<int>& ids)
{
tr_variant top;
tr_variantInitDict (&top, 3);
}
void
-Session :: sendTorrentRequest (const char * request, const QSet<int>& ids)
+Session::sendTorrentRequest (const char * request, const QSet<int>& ids)
{
tr_variant top;
refreshTorrents (ids);
}
-void Session :: pauseTorrents (const QSet<int>& ids) { sendTorrentRequest ("torrent-stop", ids); }
-void Session :: startTorrents (const QSet<int>& ids) { sendTorrentRequest ("torrent-start", ids); }
-void Session :: startTorrentsNow (const QSet<int>& ids) { sendTorrentRequest ("torrent-start-now", ids); }
-void Session :: queueMoveTop (const QSet<int>& ids) { sendTorrentRequest ("queue-move-top", ids); }
-void Session :: queueMoveUp (const QSet<int>& ids) { sendTorrentRequest ("queue-move-up", ids); }
-void Session :: queueMoveDown (const QSet<int>& ids) { sendTorrentRequest ("queue-move-down", ids); }
-void Session :: queueMoveBottom (const QSet<int>& ids) { sendTorrentRequest ("queue-move-bottom", ids); }
+void Session::pauseTorrents (const QSet<int>& ids) { sendTorrentRequest ("torrent-stop", ids); }
+void Session::startTorrents (const QSet<int>& ids) { sendTorrentRequest ("torrent-start", ids); }
+void Session::startTorrentsNow (const QSet<int>& ids) { sendTorrentRequest ("torrent-start-now", ids); }
+void Session::queueMoveTop (const QSet<int>& ids) { sendTorrentRequest ("queue-move-top", ids); }
+void Session::queueMoveUp (const QSet<int>& ids) { sendTorrentRequest ("queue-move-up", ids); }
+void Session::queueMoveDown (const QSet<int>& ids) { sendTorrentRequest ("queue-move-down", ids); }
+void Session::queueMoveBottom (const QSet<int>& ids) { sendTorrentRequest ("queue-move-bottom", ids); }
void
-Session :: refreshActiveTorrents ()
+Session::refreshActiveTorrents ()
{
tr_variant top;
tr_variantInitDict (&top, 3);
}
void
-Session :: refreshAllTorrents ()
+Session::refreshAllTorrents ()
{
tr_variant top;
tr_variantInitDict (&top, 3);
}
void
-Session :: initTorrents (const QSet<int>& ids)
+Session::initTorrents (const QSet<int>& ids)
{
tr_variant top;
const int tag (ids.isEmpty () ? TAG_ALL_TORRENTS : TAG_SOME_TORRENTS);
}
void
-Session :: refreshSessionStats ()
+Session::refreshSessionStats ()
{
tr_variant top;
tr_variantInitDict (&top, 2);
}
void
-Session :: refreshSessionInfo ()
+Session::refreshSessionInfo ()
{
tr_variant top;
tr_variantInitDict (&top, 2);
}
void
-Session :: updateBlocklist ()
+Session::updateBlocklist ()
{
tr_variant top;
tr_variantInitDict (&top, 2);
***/
void
-Session :: exec (const tr_variant * request)
+Session::exec (const tr_variant * request)
{
char * str = tr_variantToStr (request, TR_VARIANT_FMT_JSON_LEAN, NULL);
exec (str);
}
void
-Session :: localSessionCallback (tr_session * s, struct evbuffer * json, void * vself)
+Session::localSessionCallback (tr_session * s, struct evbuffer * json, void * vself)
{
Q_UNUSED (s);
#define REQUEST_DATA_PROPERTY_KEY "requestData"
void
-Session :: exec (const char * json)
+Session::exec (const char * json)
{
if (mySession )
{
}
void
-Session :: onFinished (QNetworkReply * reply)
+Session::onFinished (QNetworkReply * reply)
{
#ifdef DEBUG_HTTP
std::cerr << "http response header: " << std::endl;
}
void
-Session :: onResponseReceived (const QByteArray& utf8)
+Session::onResponseReceived (const QByteArray& utf8)
{
parseResponse (utf8.constData (), utf8.length ());
}
void
-Session :: parseResponse (const char * json, size_t jsonLength)
+Session::parseResponse (const char * json, size_t jsonLength)
{
tr_variant top;
const int err (tr_variantFromJson (&top, json, jsonLength));
}
void
-Session :: updateStats (tr_variant * d, struct tr_session_stats * stats)
+Session::updateStats (tr_variant * d, struct tr_session_stats * stats)
{
int64_t i;
}
void
-Session :: updateStats (tr_variant * d)
+Session::updateStats (tr_variant * d)
{
tr_variant * c;
}
void
-Session :: updateInfo (tr_variant * d)
+Session::updateInfo (tr_variant * d)
{
int64_t i;
const char * str;
if (!b)
continue;
- if (i == Prefs :: ENCRYPTION)
+ if (i == Prefs::ENCRYPTION)
{
const char * val;
if (tr_variantGetStr (b, &val, NULL))
switch (myPrefs.type (i))
{
- case QVariant :: Int:
+ case QVariant::Int:
{
int64_t val;
if (tr_variantGetInt (b, &val))
myPrefs.set (i, (int)val);
break;
}
- case QVariant :: Double:
+ case QVariant::Double:
{
double val;
if (tr_variantGetReal (b, &val))
myPrefs.set (i, val);
break;
}
- case QVariant :: Bool:
+ case QVariant::Bool:
{
bool val;
if (tr_variantGetBool (b, &val))
myPrefs.set (i, (bool)val);
break;
}
- case TrTypes :: FilterModeType:
- case TrTypes :: SortModeType:
- case QVariant :: String:
+ case TrTypes::FilterModeType:
+ case TrTypes::SortModeType:
+ case QVariant::String:
{
const char * val;
if (tr_variantGetStr (b, &val, NULL))
if (tr_variantDictFindStr (d, TR_KEY_version, &str, NULL) && (mySessionVersion != str))
mySessionVersion = str;
- //std::cerr << "Session :: updateInfo end" << std::endl;
+ //std::cerr << "Session::updateInfo end" << std::endl;
connect (&myPrefs, SIGNAL (changed (int)), this, SLOT (updatePref (int)));
emit sessionUpdated ();
}
void
-Session :: setBlocklistSize (int64_t i)
+Session::setBlocklistSize (int64_t i)
{
myBlocklistSize = i;
}
void
-Session :: addTorrent (const AddData& addMe, tr_variant& top, bool trashOriginal)
+Session::addTorrent (const AddData& addMe, tr_variant& top, bool trashOriginal)
{
assert (tr_variantDictFind (&top, TR_KEY_method) == nullptr);
assert (tr_variantDictFind (&top, TR_KEY_tag) == nullptr);
}
void
-Session :: addTorrent (const AddData& addMe)
+Session::addTorrent (const AddData& addMe)
{
tr_variant top;
tr_variantInitDict (&top, 3);
}
void
-Session :: addNewlyCreatedTorrent (const QString& filename, const QString& localPath)
+Session::addNewlyCreatedTorrent (const QString& filename, const QString& localPath)
{
const QByteArray b64 = AddData (filename).toBase64 ();
const QByteArray localPathUtf8 = localPath.toUtf8 ();
}
void
-Session :: removeTorrents (const QSet<int>& ids, bool deleteFiles)
+Session::removeTorrents (const QSet<int>& ids, bool deleteFiles)
{
if (!ids.isEmpty ())
{
}
void
-Session :: verifyTorrents (const QSet<int>& ids)
+Session::verifyTorrents (const QSet<int>& ids)
{
if (!ids.isEmpty ())
{
}
void
-Session :: reannounceTorrents (const QSet<int>& ids)
+Session::reannounceTorrents (const QSet<int>& ids)
{
if (!ids.isEmpty ())
{
***/
void
-Session :: launchWebInterface ()
+Session::launchWebInterface ()
{
QUrl url;
url.setPort (myPrefs.getInt (Prefs::RPC_PORT));
}
- QDesktopServices :: openUrl (url);
+ QDesktopServices::openUrl (url);
}
#include "squeezelabel.h"
void
-SqueezeLabel :: init ()
+SqueezeLabel::init ()
{
setTextInteractionFlags(Qt::TextSelectableByMouse);
}
-SqueezeLabel :: SqueezeLabel (const QString& text, QWidget *parent):
+SqueezeLabel::SqueezeLabel (const QString& text, QWidget * parent):
QLabel (text, parent)
{
init();
}
-SqueezeLabel :: SqueezeLabel (QWidget * parent):
+SqueezeLabel::SqueezeLabel (QWidget * parent):
QLabel (parent)
{
init();
}
void
-SqueezeLabel :: paintEvent (QPaintEvent * paintEvent)
+SqueezeLabel::paintEvent (QPaintEvent * paintEvent)
{
Q_UNUSED (paintEvent);
REFRESH_INTERVAL_MSEC = (15*1000)
};
-StatsDialog :: StatsDialog (Session & session, QWidget * parent):
+StatsDialog::StatsDialog (Session& session, QWidget * parent):
QDialog (parent, Qt::Dialog),
mySession (session),
myTimer (new QTimer (this))
mySession.refreshSessionStats ();
}
-StatsDialog :: ~StatsDialog ()
+StatsDialog::~StatsDialog ()
{
}
void
-StatsDialog :: setVisible (bool visible)
+StatsDialog::setVisible (bool visible)
{
myTimer->stop ();
if (visible)
}
void
-StatsDialog :: onTimer ()
+StatsDialog::onTimer ()
{
mySession.refreshSessionStats ();
}
void
-StatsDialog :: updateStats ()
+StatsDialog::updateStats ()
{
const struct tr_session_stats& current (mySession.getStats ());
const struct tr_session_stats& total (mySession.getCumulativeStats ());
***/
QSize
-TorrentDelegateMin :: sizeHint (const QStyleOptionViewItem & option,
- const Torrent & tor) const
+TorrentDelegateMin::sizeHint (const QStyleOptionViewItem & option,
+ const Torrent & tor) const
{
const QStyle* style (QApplication::style());
- static const int iconSize (style->pixelMetric (QStyle :: PM_SmallIconSize));
+ static const int iconSize (style->pixelMetric (QStyle::PM_SmallIconSize));
QFont nameFont (option.font);
const QFontMetrics nameFM (nameFont);
}
void
-TorrentDelegateMin :: drawTorrent (QPainter * painter,
- const QStyleOptionViewItem & option,
- const Torrent & tor) const
+TorrentDelegateMin::drawTorrent (QPainter * painter,
+ const QStyleOptionViewItem & option,
+ const Torrent & tor) const
{
const bool isPaused (tor.isPaused());
const QStyle * style (QApplication::style());
- static const int iconSize (style->pixelMetric (QStyle :: PM_SmallIconSize));
+ static const int iconSize (style->pixelMetric (QStyle::PM_SmallIconSize));
QFont nameFont (option.font);
const QFontMetrics nameFM (nameFont);
BAR_HEIGHT = 12
};
-QColor TorrentDelegate :: greenBrush;
-QColor TorrentDelegate :: blueBrush;
-QColor TorrentDelegate :: silverBrush;
-QColor TorrentDelegate :: greenBack;
-QColor TorrentDelegate :: blueBack;
-QColor TorrentDelegate :: silverBack;
-
-TorrentDelegate :: TorrentDelegate (QObject * parent):
+QColor TorrentDelegate::greenBrush;
+QColor TorrentDelegate::blueBrush;
+QColor TorrentDelegate::silverBrush;
+QColor TorrentDelegate::greenBack;
+QColor TorrentDelegate::blueBack;
+QColor TorrentDelegate::silverBack;
+
+TorrentDelegate::TorrentDelegate (QObject * parent):
QStyledItemDelegate (parent),
myProgressBarStyle (new QStyleOptionProgressBar)
{
silverBack = QColor ("grey");
}
-TorrentDelegate :: ~TorrentDelegate ()
+TorrentDelegate::~TorrentDelegate ()
{
delete myProgressBarStyle;
}
***/
QSize
-TorrentDelegate :: margin (const QStyle& style) const
+TorrentDelegate::margin (const QStyle& style) const
{
Q_UNUSED (style);
}
QString
-TorrentDelegate :: progressString (const Torrent& tor) const
+TorrentDelegate::progressString (const Torrent& tor) const
{
const bool isMagnet (!tor.hasMetadata());
const bool isDone (tor.isDone ());
}
QString
-TorrentDelegate :: shortTransferString (const Torrent& tor) const
+TorrentDelegate::shortTransferString (const Torrent& tor) const
{
QString str;
const bool haveMeta (tor.hasMetadata());
}
QString
-TorrentDelegate :: shortStatusString (const Torrent& tor) const
+TorrentDelegate::shortStatusString (const Torrent& tor) const
{
QString str;
static const QChar ratioSymbol (0x262F);
}
QString
-TorrentDelegate :: statusString (const Torrent& tor) const
+TorrentDelegate::statusString (const Torrent& tor) const
{
QString str;
}
QSize
-TorrentDelegate :: sizeHint (const QStyleOptionViewItem& option, const Torrent& tor) const
+TorrentDelegate::sizeHint (const QStyleOptionViewItem& option, const Torrent& tor) const
{
const QStyle* style (QApplication::style ());
static const int iconSize (style->pixelMetric (QStyle::PM_MessageBoxIconSize));
}
QSize
-TorrentDelegate :: sizeHint (const QStyleOptionViewItem & option,
- const QModelIndex & index) const
+TorrentDelegate::sizeHint (const QStyleOptionViewItem & option,
+ const QModelIndex & index) const
{
const Torrent * tor (index.data (TorrentModel::TorrentRole).value<const Torrent*>());
return sizeHint (option, *tor);
}
void
-TorrentDelegate :: paint (QPainter * painter,
- const QStyleOptionViewItem & option,
- const QModelIndex & index) const
+TorrentDelegate::paint (QPainter * painter,
+ const QStyleOptionViewItem & option,
+ const QModelIndex & index) const
{
const Torrent * tor (index.data (TorrentModel::TorrentRole).value<const Torrent*>());
painter->save ();
}
void
-TorrentDelegate :: setProgressBarPercentDone (const QStyleOptionViewItem & option,
- const Torrent & tor) const
+TorrentDelegate::setProgressBarPercentDone (const QStyleOptionViewItem & option,
+ const Torrent & tor) const
{
double seedRatioLimit;
if (tor.isSeeding() && tor.getSeedRatio(seedRatioLimit))
}
void
-TorrentDelegate :: drawTorrent (QPainter * painter,
- const QStyleOptionViewItem & option,
- const Torrent & tor) const
+TorrentDelegate::drawTorrent (QPainter * painter,
+ const QStyleOptionViewItem & option,
+ const Torrent & tor) const
{
const QStyle * style (QApplication::style ());
static const int iconSize (style->pixelMetric (QStyle::PM_LargeIconSize));
#include "torrent-model.h"
#include "utils.h"
-TorrentFilter :: TorrentFilter (Prefs& prefs):
+TorrentFilter::TorrentFilter (Prefs& prefs):
myPrefs (prefs)
{
// listen for changes to the preferences to know when to refilter / resort
// initialize our state from the current prefs
QList<int> initKeys;
- initKeys << Prefs :: SORT_MODE
- << Prefs :: FILTER_MODE
- << Prefs :: FILTER_TRACKERS
- << Prefs :: FILTER_TEXT;
+ initKeys << Prefs::SORT_MODE
+ << Prefs::FILTER_MODE
+ << Prefs::FILTER_TRACKERS
+ << Prefs::FILTER_TEXT;
foreach (int key, initKeys)
refreshPref (key);
}
-TorrentFilter :: ~TorrentFilter ()
+TorrentFilter::~TorrentFilter ()
{
}
void
-TorrentFilter :: refreshPref (int key)
+TorrentFilter::refreshPref (int key)
{
switch (key)
{
- case Prefs :: FILTER_TEXT:
- case Prefs :: FILTER_MODE:
- case Prefs :: FILTER_TRACKERS:
+ case Prefs::FILTER_TEXT:
+ case Prefs::FILTER_MODE:
+ case Prefs::FILTER_TRACKERS:
invalidateFilter ();
/* force a re-sort */
sort (0, !myPrefs.getBool(Prefs::SORT_REVERSED) ? Qt::AscendingOrder : Qt::DescendingOrder);
- case Prefs :: SORT_MODE:
- case Prefs :: SORT_REVERSED:
+ case Prefs::SORT_MODE:
+ case Prefs::SORT_REVERSED:
sort (0, myPrefs.getBool(Prefs::SORT_REVERSED) ? Qt::AscendingOrder : Qt::DescendingOrder);
invalidate ();
break;
}
bool
-TorrentFilter :: lessThan (const QModelIndex& left, const QModelIndex& right) const
+TorrentFilter::lessThan (const QModelIndex& left, const QModelIndex& right) const
{
int val = 0;
const Torrent * a = sourceModel()->data (left, TorrentModel::TorrentRole).value<const Torrent*>();
switch (myPrefs.get<SortMode>(Prefs::SORT_MODE).mode())
{
- case SortMode :: SORT_BY_QUEUE:
+ case SortMode::SORT_BY_QUEUE:
if (!val)
val = -compare (a->queuePosition(), b->queuePosition());
break;
- case SortMode :: SORT_BY_SIZE:
+ case SortMode::SORT_BY_SIZE:
if (!val)
val = compare (a->sizeWhenDone(), b->sizeWhenDone());
break;
- case SortMode :: SORT_BY_AGE:
+ case SortMode::SORT_BY_AGE:
val = compare (a->dateAdded().toTime_t(), b->dateAdded().toTime_t());
break;
- case SortMode :: SORT_BY_ID:
+ case SortMode::SORT_BY_ID:
if (!val)
val = compare (a->id(), b->id());
break;
- case SortMode :: SORT_BY_ACTIVITY:
+ case SortMode::SORT_BY_ACTIVITY:
if (!val)
val = compare (a->downloadSpeed() + a->uploadSpeed(), b->downloadSpeed() + b->uploadSpeed());
if (!val)
b->peersWeAreUploadingTo() + b->webseedsWeAreDownloadingFrom());
// fall through
- case SortMode :: SORT_BY_STATE:
+ case SortMode::SORT_BY_STATE:
if (!val)
val = -compare (a->isPaused(), b->isPaused());
if (!val)
val = compare (a->hasError(), b->hasError());
// fall through
- case SortMode :: SORT_BY_PROGRESS:
+ case SortMode::SORT_BY_PROGRESS:
if (!val)
val = compare (a->percentComplete(), b->percentComplete());
if (!val)
if (!val)
val = -compare (a->queuePosition(), b->queuePosition());
- case SortMode :: SORT_BY_RATIO:
+ case SortMode::SORT_BY_RATIO:
if (!val)
val = a->compareRatio (*b);
break;
- case SortMode :: SORT_BY_ETA:
+ case SortMode::SORT_BY_ETA:
if (!val)
val = a->compareETA (*b);
break;
***/
bool
-TorrentFilter :: trackerFilterAcceptsTorrent (const Torrent * tor, const QString& tracker) const
+TorrentFilter::trackerFilterAcceptsTorrent (const Torrent * tor, const QString& tracker) const
{
return tracker.isEmpty() || tor->hasTrackerSubstring (tracker);
}
bool
-TorrentFilter :: activityFilterAcceptsTorrent (const Torrent * tor, const FilterMode& m) const
+TorrentFilter::activityFilterAcceptsTorrent (const Torrent * tor, const FilterMode& m) const
{
bool accepts;
}
bool
-TorrentFilter :: filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const
+TorrentFilter::filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const
{
QModelIndex childIndex = sourceModel()->index (sourceRow, 0, sourceParent);
const Torrent * tor = childIndex.model()->data (childIndex, TorrentModel::TorrentRole).value<const Torrent*>();
}
int
-TorrentFilter :: hiddenRowCount () const
+TorrentFilter::hiddenRowCount () const
{
return sourceModel()->rowCount () - rowCount ();
}
void
-TorrentFilter :: countTorrentsPerMode (int * setmeCounts) const
+TorrentFilter::countTorrentsPerMode (int * setmeCounts) const
{
std::fill_n (setmeCounts, static_cast<std::size_t>(FilterMode::NUM_MODES), 0);
#include "torrent-model.h"
void
-TorrentModel :: clear ()
+TorrentModel::clear ()
{
beginResetModel ();
}
int
-TorrentModel :: rowCount (const QModelIndex& parent) const
+TorrentModel::rowCount (const QModelIndex& parent) const
{
Q_UNUSED (parent);
}
QVariant
-TorrentModel :: data (const QModelIndex& index, int role) const
+TorrentModel::data (const QModelIndex& index, int role) const
{
QVariant var;
***/
void
-TorrentModel :: addTorrent (Torrent * t)
+TorrentModel::addTorrent (Torrent * t)
{
myIdToTorrent.insert (t->id (), t);
myIdToRow.insert (t->id (), myTorrents.size ());
myTorrents.append (t);
}
-TorrentModel :: TorrentModel (Prefs& prefs):
+TorrentModel::TorrentModel (Prefs& prefs):
myPrefs (prefs)
{
}
-TorrentModel :: ~TorrentModel ()
+TorrentModel::~TorrentModel ()
{
clear ();
}
***/
Torrent*
-TorrentModel :: getTorrentFromId (int id)
+TorrentModel::getTorrentFromId (int id)
{
id_to_torrent_t::iterator it (myIdToTorrent.find (id));
return it == myIdToTorrent.end() ? 0 : it.value ();
}
const Torrent*
-TorrentModel :: getTorrentFromId (int id) const
+TorrentModel::getTorrentFromId (int id) const
{
id_to_torrent_t::const_iterator it (myIdToTorrent.find (id));
return it == myIdToTorrent.end() ? 0 : it.value ();
***/
void
-TorrentModel :: onTorrentChanged (int torrentId)
+TorrentModel::onTorrentChanged (int torrentId)
{
const int row (myIdToRow.value (torrentId, -1));
if (row >= 0)
}
void
-TorrentModel :: removeTorrents (tr_variant * torrents)
+TorrentModel::removeTorrents (tr_variant * torrents)
{
int i = 0;
tr_variant * child;
}
void
-TorrentModel :: updateTorrents (tr_variant * torrents, bool isCompleteList)
+TorrentModel::updateTorrents (tr_variant * torrents, bool isCompleteList)
{
QList<Torrent*> newTorrents;
QSet<int> oldIds;
}
void
-TorrentModel :: removeTorrent (int id)
+TorrentModel::removeTorrent (int id)
{
const int row = myIdToRow.value (id, -1);
if (row >= 0)
}
void
-TorrentModel :: getTransferSpeed (Speed & uploadSpeed,
- size_t & uploadPeerCount,
- Speed & downloadSpeed,
- size_t & downloadPeerCount)
+TorrentModel::getTransferSpeed (Speed & uploadSpeed,
+ size_t & uploadPeerCount,
+ Speed & downloadSpeed,
+ size_t & downloadPeerCount)
{
Speed upSpeed, downSpeed;
size_t upCount=0, downCount=0;
}
QSet<int>
-TorrentModel :: getIds () const
+TorrentModel::getIds () const
{
QSet<int> ids;
}
bool
-TorrentModel :: hasTorrent (const QString& hashString) const
+TorrentModel::hasTorrent (const QString& hashString) const
{
foreach (const Torrent * tor, myTorrents)
if (tor->hashString () == hashString)
#include "utils.h"
-Torrent :: Torrent (Prefs& prefs, int id):
+Torrent::Torrent (Prefs& prefs, int id):
magnetTorrent (false),
myPrefs (prefs)
{
setIcon (MIME_ICON, QApplication::style()->standardIcon (QStyle::SP_FileIcon));
}
-Torrent :: ~Torrent ()
+Torrent::~Torrent ()
{
}
****
***/
-Torrent :: Property
-Torrent :: myProperties[] =
+Torrent::Property
+Torrent::myProperties[] =
{
{ ID, TR_KEY_id, QVariant::Int, INFO, },
{ UPLOAD_SPEED, TR_KEY_rateUpload, QVariant::ULongLong, STAT } /* Bps */,
{ QUEUE_POSITION, TR_KEY_queuePosition, QVariant::Int, STAT },
};
-Torrent :: KeyList
-Torrent :: buildKeyList (Group group)
+Torrent::KeyList
+Torrent::buildKeyList (Group group)
{
KeyList keys;
return keys;
}
-const Torrent :: KeyList&
-Torrent :: getInfoKeys ()
+const Torrent::KeyList&
+Torrent::getInfoKeys ()
{
static KeyList keys;
return keys;
}
-const Torrent :: KeyList&
-Torrent :: getStatKeys ()
+const Torrent::KeyList&
+Torrent::getStatKeys ()
{
static KeyList keys (buildKeyList(STAT));
return keys;
}
-const Torrent :: KeyList&
-Torrent :: getExtraStatKeys()
+const Torrent::KeyList&
+Torrent::getExtraStatKeys()
{
static KeyList keys;
}
bool
-Torrent :: setInt (int i, int value)
+Torrent::setInt (int i, int value)
{
bool changed = false;
}
bool
-Torrent :: setBool (int i, bool value)
+Torrent::setBool (int i, bool value)
{
bool changed = false;
}
bool
-Torrent :: setDouble (int i, double value)
+Torrent::setDouble (int i, double value)
{
bool changed = false;
}
bool
-Torrent :: setDateTime (int i, const QDateTime& value)
+Torrent::setDateTime (int i, const QDateTime& value)
{
bool changed = false;
}
bool
-Torrent :: setSize (int i, qulonglong value)
+Torrent::setSize (int i, qulonglong value)
{
bool changed = false;
}
bool
-Torrent :: setString (int i, const char * value)
+Torrent::setString (int i, const char * value)
{
bool changed = false;
}
bool
-Torrent :: setIcon (int i, const QIcon& value)
+Torrent::setIcon (int i, const QIcon& value)
{
assert (0<=i && i<PROPERTY_COUNT);
assert (myProperties[i].type == QVariant::Icon);
}
int
-Torrent :: getInt (int i) const
+Torrent::getInt (int i) const
{
assert (0<=i && i<PROPERTY_COUNT);
assert (myProperties[i].type == QVariant::Int);
}
QDateTime
-Torrent :: getDateTime (int i) const
+Torrent::getDateTime (int i) const
{
assert (0<=i && i<PROPERTY_COUNT);
assert (myProperties[i].type == QVariant::DateTime);
}
bool
-Torrent :: getBool (int i) const
+Torrent::getBool (int i) const
{
assert (0<=i && i<PROPERTY_COUNT);
assert (myProperties[i].type == QVariant::Bool);
}
qulonglong
-Torrent :: getSize (int i) const
+Torrent::getSize (int i) const
{
assert (0<=i && i<PROPERTY_COUNT);
assert (myProperties[i].type == QVariant::ULongLong);
return myValues[i].toULongLong ();
}
double
-Torrent :: getDouble (int i) const
+Torrent::getDouble (int i) const
{
assert (0<=i && i<PROPERTY_COUNT);
assert (myProperties[i].type == QVariant::Double);
return myValues[i].toDouble ();
}
QString
-Torrent :: getString (int i) const
+Torrent::getString (int i) const
{
assert (0<=i && i<PROPERTY_COUNT);
assert (myProperties[i].type == QVariant::String);
return myValues[i].toString ();
}
QIcon
-Torrent :: getIcon (int i) const
+Torrent::getIcon (int i) const
{
assert (0<=i && i<PROPERTY_COUNT);
assert (myProperties[i].type == QVariant::Icon);
***/
bool
-Torrent :: getSeedRatio (double& ratio) const
+Torrent::getSeedRatio (double& ratio) const
{
bool isLimited;
break;
case TR_RATIOLIMIT_GLOBAL:
- if ((isLimited = myPrefs.getBool (Prefs :: RATIO_ENABLED)))
- ratio = myPrefs.getDouble (Prefs :: RATIO);
+ if ((isLimited = myPrefs.getBool (Prefs::RATIO_ENABLED)))
+ ratio = myPrefs.getDouble (Prefs::RATIO);
break;
default: // TR_RATIOLIMIT_UNLIMITED:
}
bool
-Torrent :: hasFileSubstring (const QString& substr) const
+Torrent::hasFileSubstring (const QString& substr) const
{
foreach (const TrFile file, myFiles)
if (file.filename.contains (substr, Qt::CaseInsensitive))
}
bool
-Torrent :: hasTrackerSubstring (const QString& substr) const
+Torrent::hasTrackerSubstring (const QString& substr) const
{
foreach (QString s, myValues[TRACKERS].toStringList())
if (s.contains (substr, Qt::CaseInsensitive))
}
int
-Torrent :: compareSeedRatio (const Torrent& that) const
+Torrent::compareSeedRatio (const Torrent& that) const
{
double a;
double b;
}
int
-Torrent :: compareRatio (const Torrent& that) const
+Torrent::compareRatio (const Torrent& that) const
{
const double a = ratio ();
const double b = that.ratio ();
}
int
-Torrent :: compareETA (const Torrent& that) const
+Torrent::compareETA (const Torrent& that) const
{
const bool haveA (hasETA ());
const bool haveB (that.hasETA ());
}
int
-Torrent :: compareTracker (const Torrent& that) const
+Torrent::compareTracker (const Torrent& that) const
{
Q_UNUSED (that);
***/
void
-Torrent :: updateMimeIcon ()
+Torrent::updateMimeIcon ()
{
const FileList& files (myFiles);
if (files.size () > 1)
icon = QFileIconProvider().icon (QFileIconProvider::Folder);
else if (files.size () == 1)
- icon = Utils :: guessMimeIcon (files.at(0).filename);
+ icon = Utils::guessMimeIcon (files.at(0).filename);
else
icon = QIcon ();
***/
void
-Torrent :: notifyComplete () const
+Torrent::notifyComplete () const
{
// if someone wants to implement notification, here's the hook.
}
***/
void
-Torrent :: update (tr_variant * d)
+Torrent::update (tr_variant * d)
{
static bool lookup_initialized = false;
static int key_to_property_index[TR_N_KEYS];
switch (myProperties[property_index].type)
{
- case QVariant :: Int:
+ case QVariant::Int:
{
int64_t val;
if (tr_variantGetInt (child, &val))
changed |= setInt (property_index, val);
break;
}
- case QVariant :: Bool:
+ case QVariant::Bool:
{
bool val;
if (tr_variantGetBool (child, &val))
changed |= setBool (property_index, val);
break;
}
- case QVariant :: String:
+ case QVariant::String:
{
const char * val;
if (tr_variantGetStr(child, &val, NULL))
changed |= setString (property_index, val);
break;
}
- case QVariant :: ULongLong:
+ case QVariant::ULongLong:
{
int64_t val;
if (tr_variantGetInt (child, &val))
changed |= setSize (property_index, val);
break;
}
- case QVariant :: Double:
+ case QVariant::Double:
{
double val;
if (tr_variantGetReal (child, &val))
changed |= setDouble (property_index, val);
break;
}
- case QVariant :: DateTime:
+ case QVariant::DateTime:
{
int64_t val;
if (tr_variantGetInt (child, &val) && val)
- changed |= setDateTime (property_index, QDateTime :: fromTime_t(val));
+ changed |= setDateTime (property_index, QDateTime::fromTime_t(val));
break;
}
- case QVariant :: StringList:
- case TrTypes :: PeerList:
+ case QVariant::StringList:
+ case TrTypes::PeerList:
// handled below
break;
}
QString
-Torrent :: activityString () const
+Torrent::activityString () const
{
QString str;
}
QString
-Torrent :: getError () const
+Torrent::getError () const
{
QString s = getString (ERROR_STRING);
}
QPixmap
-TrackerStat :: getFavicon () const
+TrackerStat::getFavicon () const
{
MyApp * myApp = dynamic_cast<MyApp*>(QApplication::instance());
return myApp->favicons.find (QUrl (announce));
}
QSize
-TrackerDelegate :: margin (const QStyle& style) const
+TrackerDelegate::margin (const QStyle& style) const
{
Q_UNUSED (style);
***/
QSize
-TrackerDelegate :: sizeHint (const QStyleOptionViewItem & option,
- const TrackerInfo & info) const
+TrackerDelegate::sizeHint (const QStyleOptionViewItem & option,
+ const TrackerInfo & info) const
{
Q_UNUSED (option);
QPixmap favicon = info.st.getFavicon ();
- const QString text = TrackerDelegate :: getText(info);
+ const QString text = TrackerDelegate::getText(info);
QTextDocument textDoc;
textDoc.setHtml (text);
const QSize textSize = textDoc.size().toSize();
}
QSize
-TrackerDelegate :: sizeHint (const QStyleOptionViewItem & option,
- const QModelIndex & index) const
+TrackerDelegate::sizeHint (const QStyleOptionViewItem & option,
+ const QModelIndex & index) const
{
const TrackerInfo trackerInfo = index.data (TrackerModel::TrackerRole).value<TrackerInfo>();
return sizeHint (option, trackerInfo);
}
void
-TrackerDelegate :: paint (QPainter * painter,
- const QStyleOptionViewItem & option,
- const QModelIndex & index) const
+TrackerDelegate::paint (QPainter * painter,
+ const QStyleOptionViewItem & option,
+ const QModelIndex & index) const
{
const TrackerInfo trackerInfo = index.data (TrackerModel::TrackerRole).value<TrackerInfo>();
painter->save();
}
void
-TrackerDelegate :: drawTracker (QPainter * painter,
- const QStyleOptionViewItem & option,
- const TrackerInfo & inf) const
+TrackerDelegate::drawTracker (QPainter * painter,
+ const QStyleOptionViewItem & option,
+ const TrackerInfo & inf) const
{
painter->save();
}
void
-TrackerDelegate :: setShowMore (bool b)
+TrackerDelegate::setShowMore (bool b)
{
myShowMore = b;
}
}
QString
-TrackerDelegate :: getText (const TrackerInfo& inf) const
+TrackerDelegate::getText (const TrackerInfo& inf) const
{
QString key;
QString str;
#include "tracker-model.h"
#include "tracker-model-filter.h"
-TrackerModelFilter :: TrackerModelFilter (QObject * parent):
+TrackerModelFilter::TrackerModelFilter (QObject * parent):
QSortFilterProxyModel (parent),
myShowBackups (false)
{
}
void
-TrackerModelFilter :: setShowBackupTrackers (bool b)
+TrackerModelFilter::setShowBackupTrackers (bool b)
{
myShowBackups = b;
invalidateFilter ();
}
bool
-TrackerModelFilter :: filterAcceptsRow (int sourceRow,
- const QModelIndex & sourceParent) const
+TrackerModelFilter::filterAcceptsRow (int sourceRow,
+ const QModelIndex & sourceParent) const
{
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
const TrackerInfo trackerInfo = index.data(TrackerModel::TrackerRole).value<TrackerInfo>();
#include "tracker-model.h"
int
-TrackerModel :: rowCount (const QModelIndex& parent) const
+TrackerModel::rowCount (const QModelIndex& parent) const
{
Q_UNUSED (parent);
}
QVariant
-TrackerModel :: data (const QModelIndex& index, int role) const
+TrackerModel::data (const QModelIndex& index, int role) const
{
QVariant var;
};
void
-TrackerModel :: refresh (const TorrentModel& torrentModel, const QSet<int>& ids)
+TrackerModel::refresh (const TorrentModel& torrentModel, const QSet<int>& ids)
{
// build a list of the TrackerInfos
QVector<TrackerInfo> trackers;
}
int
-TrackerModel :: find (int torrentId, const QString& url) const
+TrackerModel::find (int torrentId, const QString& url) const
{
for (int i=0, n=myRows.size(); i<n; ++i)
{
#include "hig.h"
#include "triconpushbutton.h"
-TrIconPushButton :: TrIconPushButton (QWidget * parent):
+TrIconPushButton::TrIconPushButton (QWidget * parent):
QPushButton (parent)
{
}
-TrIconPushButton :: TrIconPushButton (const QIcon& icon, QWidget * parent):
+TrIconPushButton::TrIconPushButton (const QIcon& icon, QWidget * parent):
QPushButton (parent)
{
setIcon (icon);
}
QSize
-TrIconPushButton :: sizeHint () const
+TrIconPushButton::sizeHint () const
{
QSize s = iconSize ();
s.rwidth() += HIG::PAD_SMALL*2;
}
void
-TrIconPushButton :: paintEvent (QPaintEvent *)
+TrIconPushButton::paintEvent (QPaintEvent *)
{
QStylePainter p (this);
QStyleOptionButton opt;
#endif
QString
-Utils :: remoteFileChooser (QWidget * parent, const QString& title, const QString& myPath, bool dir, bool local)
+Utils::remoteFileChooser (QWidget * parent, const QString& title, const QString& myPath, bool dir, bool local)
{
QString path;
}
void
-Utils :: toStderr (const QString& str)
+Utils::toStderr (const QString& str)
{
std::cerr << qPrintable(str) << std::endl;
}
#endif
QIcon
-Utils :: guessMimeIcon (const QString& filename)
+Utils::guessMimeIcon (const QString& filename)
{
#ifdef _WIN32
QIcon icon;
if (fileIcons[0].isNull ())
{
- fallback = QApplication::style()->standardIcon (QStyle :: SP_FileIcon);
+ fallback = QApplication::style()->standardIcon (QStyle::SP_FileIcon);
suffixes[DISK] << QString::fromLatin1("iso");
fileIcons[DISK]= QIcon::fromTheme (QString::fromLatin1("media-optical"), fallback);
}
bool
-Utils :: isValidUtf8 (const char *s)
+Utils::isValidUtf8 (const char * s)
{
int n; // number of bytes in a UTF-8 sequence
}
QString
-Utils :: removeTrailingDirSeparator (const QString& path)
+Utils::removeTrailingDirSeparator (const QString& path)
{
return path.endsWith (QDir::separator ())
? path.left (path.length()-1)
****
***/
-WatchDir :: WatchDir (const TorrentModel& model):
+WatchDir::WatchDir (const TorrentModel& model):
myModel (model),
myWatcher (0)
{
}
-WatchDir :: ~WatchDir ()
+WatchDir::~WatchDir ()
{
}
***/
int
-WatchDir :: metainfoTest (const QString& filename) const
+WatchDir::metainfoTest (const QString& filename) const
{
int ret;
tr_info inf;
}
void
-WatchDir :: onTimeout ()
+WatchDir::onTimeout ()
{
QTimer * t = qobject_cast<QTimer*>(sender());
const QString filename = t->objectName ();
}
void
-WatchDir :: setPath (const QString& path, bool isEnabled)
+WatchDir::setPath (const QString& path, bool isEnabled)
{
// clear out any remnants of the previous watcher, if any
myWatchDirFiles.clear ();
}
void
-WatchDir :: watcherActivated (const QString& path)
+WatchDir::watcherActivated (const QString& path)
{
const QDir dir(path);
}
void
-WatchDir :: rescanAllWatchedDirectories ()
+WatchDir::rescanAllWatchedDirectories ()
{
if (myWatcher == nullptr)
return;