Changeset 14539


Ignore:
Timestamp:
Jun 12, 2015, 10:12:12 PM (6 years ago)
Author:
mikedld
Message:

Unify/prettify Qt client headers style

Location:
trunk/qt
Files:
56 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/AboutDialog.h

    r14537 r14539  
    2020
    2121  public:
    22     AboutDialog (QWidget * parent = 0);
    23     ~AboutDialog () {}
     22    AboutDialog (QWidget * parent = nullptr);
     23    virtual ~AboutDialog () {}
    2424
    2525  public slots:
     
    2727
    2828  private:
     29    Ui::AboutDialog ui;
     30
    2931    QDialog * myLicenseDialog;
    30     Ui::AboutDialog ui;
    3132};
    3233
  • trunk/qt/AddData.h

    r14537 r14539  
    1818{
    1919  public:
     20    enum
     21    {
     22      NONE,
     23      MAGNET,
     24      URL,
     25      FILENAME,
     26      METAINFO
     27    };
    2028
    21     enum { NONE, MAGNET, URL, FILENAME, METAINFO };
     29  public:
     30    AddData (): type (NONE) {}
     31    AddData (const QString& str) { set (str); }
     32
     33    int set (const QString&);
     34
     35    QByteArray toBase64 () const;
     36    QString readableName () const;
     37
     38    static bool isSupported (const QString& str) { return AddData (str).type != NONE; }
     39
     40  public:
    2241    int type;
    23 
    2442    QByteArray metainfo;
    2543    QString filename;
    2644    QString magnet;
    2745    QUrl url;
    28 
    29   public:
    30 
    31     int set (const QString&);
    32     AddData (const QString& str) { set(str); }
    33     AddData (): type(NONE) {}
    34 
    35     QByteArray toBase64 () const;
    36     QString readableName () const;
    37 
    38   public:
    39 
    40     static bool isSupported (const QString& str) { return AddData(str).type != NONE; }
    4146};
    4247
  • trunk/qt/Application.cc

    r14537 r14539  
    570570}
    571571
     572FaviconCache& Application::faviconCache ()
     573{
     574  return myFavicons;
     575}
     576
    572577/***
    573578****
  • trunk/qt/Application.h

    r14537 r14539  
    3333    virtual ~Application ();
    3434
    35   public:
    3635    void raise ();
    3736    bool notifyApp (const QString& title, const QString& body) const;
    3837
    39   public:
    40     FaviconCache favicons;
     38    FaviconCache& faviconCache ();
     39
     40  public slots:
     41    void addTorrent (const QString&);
     42    void addTorrent (const AddData&);
     43
     44  private:
     45    void maybeUpdateBlocklist ();
     46    void quitLater ();
     47
     48  private slots:
     49    void consentGiven (int result);
     50    void onSessionSourceChanged ();
     51    void refreshPref (int key);
     52    void refreshTorrents ();
     53    void onTorrentsAdded (const QSet<int>& torrents);
     54    void onTorrentCompleted (int);
     55    void onNewTorrentChanged (int);
    4156
    4257  private:
     
    5267    QTranslator qtTranslator;
    5368    QTranslator appTranslator;
    54 
    55   private slots:
    56     void consentGiven (int result);
    57     void onSessionSourceChanged ();
    58     void refreshPref (int key);
    59     void refreshTorrents ();
    60     void onTorrentsAdded (const QSet<int>& torrents);
    61     void onTorrentCompleted (int);
    62     void onNewTorrentChanged (int);
    63 
    64   public slots:
    65     void addTorrent (const QString&);
    66     void addTorrent (const AddData&);
    67 
    68   private:
    69     void maybeUpdateBlocklist ();
    70 
    71     void quitLater ();
     69    FaviconCache myFavicons;
    7270};
    7371
  • trunk/qt/ColumnResizer.h

    r14537 r14539  
    2626    void addLayout (QGridLayout * layout);
    2727
     28    // QObject
    2829    virtual bool eventFilter (QObject * object, QEvent * event);
    2930
  • trunk/qt/CustomVariantType.h

    r14537 r14539  
    1616{
    1717  public:
    18 
    1918    enum
    2019    {
  • trunk/qt/DBusAdaptor.h

    r14537 r14539  
    1818{
    1919    Q_OBJECT
    20     Q_CLASSINFO( "D-Bus Interface", "com.transmissionbt.Transmission" )
     20    Q_CLASSINFO ("D-Bus Interface", "com.transmissionbt.Transmission")
     21
     22  public:
     23    DBusAdaptor (Application *);
     24    virtual ~DBusAdaptor () {}
     25
     26  public slots:
     27    bool PresentWindow ();
     28    bool AddMetainfo (const QString&);
    2129
    2230  private:
    2331    Application * myApp;
    24 
    25   public:
    26     DBusAdaptor( Application* );
    27     virtual ~DBusAdaptor() {}
    28 
    29   public slots:
    30     bool PresentWindow();
    31     bool AddMetainfo( const QString& );
    3232};
    3333
  • trunk/qt/DetailsDialog.cc

    r14537 r14539  
    285285****
    286286***/
    287 
    288 QString
    289 DetailsDialog::timeToStringRounded (int seconds)
    290 {
    291   if (seconds > 60)
    292     seconds -= (seconds % 60);
    293 
    294   return Formatter::timeToString (seconds);
    295 }
    296287
    297288void
  • trunk/qt/DetailsDialog.h

    r14537 r14539  
    1717#include <QTimer>
    1818
    19 #include "Prefs.h"
    20 
    2119#include "ui_DetailsDialog.h"
    2220
    2321class QTreeWidgetItem;
     22
     23class Prefs;
    2424class Session;
    2525class Torrent;
     
    3333    Q_OBJECT
    3434
    35   private:
    36     void getNewData ();
     35  public:
     36    DetailsDialog (Session&, Prefs&, const TorrentModel&, QWidget * parent = nullptr);
     37    virtual ~DetailsDialog ();
    3738
    38   private slots:
    39     void onTorrentChanged ();
    40     void onTimer ();
     39    void setIds (const QSet<int>& ids);
    4140
    42   public:
    43     DetailsDialog (Session&, Prefs&, const TorrentModel&, QWidget * parent = 0);
    44     ~DetailsDialog ();
    45     void setIds (const QSet<int>& ids);
     41    // QWidget
    4642    virtual QSize sizeHint () const { return QSize (440, 460); }
    4743
     
    5349    void initOptionsTab ();
    5450
    55   private:
     51    void getNewData ();
     52
    5653    QIcon getStockIcon (const QString& freedesktop_name, int fallback);
    57     QString timeToStringRounded (int seconds);
    58     QString trimToDesiredWidth (const QString& str);
    59 
    60   private:
    61     Session& mySession;
    62     Prefs& myPrefs;
    63     const TorrentModel& myModel;
    64     QSet<int> myIds;
    65     QTimer myTimer;
    66     bool myChangedTorrents;
    67     bool myHavePendingRefresh;
    68 
    69     Ui::DetailsDialog ui;
    70 
    71     TrackerModel * myTrackerModel;
    72     TrackerModelFilter * myTrackerFilter;
    73     TrackerDelegate * myTrackerDelegate;
    74 
    75     QMap<QString,QTreeWidgetItem*> myPeers;
    7654
    7755  private slots:
     56    void refresh ();
    7857    void refreshPref (int key);
    79     void onBandwidthPriorityChanged (int);
     58
     59    void onTorrentChanged ();
     60    void onTimer ();
     61
     62    // Tracker tab
     63    void onTrackerSelectionChanged ();
     64    void onAddTrackerClicked ();
     65    void onEditTrackerClicked ();
     66    void onRemoveTrackerClicked ();
     67    void onShowTrackerScrapesToggled (bool);
     68    void onShowBackupTrackersToggled (bool);
     69
     70    // Files tab
    8071    void onFilePriorityChanged (const QSet<int>& fileIndices, int);
    8172    void onFileWantedChanged (const QSet<int>& fileIndices, bool);
    8273    void onPathEdited (const QString& oldpath, const QString& newname);
    8374    void onOpenRequested (const QString& path);
     75
     76    // Options tab
     77    void onBandwidthPriorityChanged (int);
    8478    void onHonorsSessionLimitsToggled (bool);
    8579    void onDownloadLimitedToggled (bool);
     
    8983    void onIdleModeChanged (int);
    9084    void onIdleLimitChanged ();
    91     void onShowTrackerScrapesToggled (bool);
    92     void onShowBackupTrackersToggled (bool);
    93     void onTrackerSelectionChanged ();
    94     void onAddTrackerClicked ();
    95     void onEditTrackerClicked ();
    96     void onRemoveTrackerClicked ();
    97     void refresh ();
     85
     86  private:
     87    Session& mySession;
     88    Prefs& myPrefs;
     89    const TorrentModel& myModel;
     90
     91    Ui::DetailsDialog ui;
     92
     93    QSet<int> myIds;
     94    QTimer myTimer;
     95    bool myChangedTorrents;
     96    bool myHavePendingRefresh;
     97
     98    TrackerModel * myTrackerModel;
     99    TrackerModelFilter * myTrackerFilter;
     100    TrackerDelegate * myTrackerDelegate;
     101
     102    QMap<QString, QTreeWidgetItem*> myPeers;
    98103};
    99104
  • trunk/qt/FaviconCache.h

    r14537 r14539  
    2525
    2626  public:
    27 
    28     static QString getHost( const QUrl& url );
    29     static QSize getIconSize ();
    30 
    31   public:
    32 
    33     FaviconCache();
    34     virtual ~FaviconCache();
     27    FaviconCache ();
     28    virtual ~FaviconCache ();
    3529
    3630    // returns a cached pixmap, or a NULL pixmap if there's no match in the cache
     
    4337    void add (const QUrl& url);
    4438
     39    static QString getHost (const QUrl& url);
     40    static QSize getIconSize ();
     41
    4542  signals:
    46 
    4743    void pixmapReady (const QString& host);
    4844
    4945  private:
    50 
    51     QNetworkAccessManager * myNAM;
    52     QMap<QString,QPixmap> myPixmaps;
    53 
    5446    QString getCacheDir ();
    5547    void ensureCacheDirHasBeenScanned ();
    5648
    5749  private slots:
     50    void onRequestFinished (QNetworkReply * reply);
    5851
    59     void onRequestFinished (QNetworkReply * reply);
     52  private:
     53    QNetworkAccessManager * myNAM;
     54    QMap<QString, QPixmap> myPixmaps;
    6055};
    6156
  • trunk/qt/FileTreeDelegate.h

    r14537 r14539  
    1818
    1919  public:
    20     FileTreeDelegate (QObject * parent=0): QItemDelegate(parent) {}
    21     virtual ~FileTreeDelegate() {}
     20    FileTreeDelegate (QObject * parent = nullptr): QItemDelegate (parent) {}
     21    virtual ~FileTreeDelegate () {}
    2222
    2323  public:
     24    // QAbstractItemDelegate
    2425    virtual QSize sizeHint (const QStyleOptionViewItem&, const QModelIndex&) const;
    25     virtual void paint (QPainter*, const QStyleOptionViewItem&, const QModelIndex&) const;
     26    virtual void paint (QPainter *, const QStyleOptionViewItem&, const QModelIndex&) const;
    2627};
    2728
  • trunk/qt/FileTreeItem.h

    r14537 r14539  
    1313#include <stdint.h>
    1414
    15 #include <QObject>
     15#include <QCoreApplication>
     16#include <QHash>
    1617#include <QList>
    17 #include <QHash>
    1818#include <QSet>
    1919#include <QString>
    2020#include <QVariant>
    2121
    22 class FileTreeItem: public QObject
     22class FileTreeItem
    2323{
    24     Q_OBJECT
    25 
    26     enum { LOW=(1<<0), NORMAL=(1<<1), HIGH=(1<<2) };
     24    Q_DECLARE_TR_FUNCTIONS (FileTreeItem)
    2725
    2826  public:
    29 
    30     virtual ~FileTreeItem();
    31 
    32     FileTreeItem (const QString& name=QString (), int fileIndex=-1, uint64_t size=0):
     27    FileTreeItem (const QString& name = QString (), int fileIndex = -1, uint64_t size = 0):
     28      myName (name),
    3329      myFileIndex (fileIndex),
    34       myParent (0),
    35       myName (name),
     30      myTotalSize (size),
     31      myParent (nullptr),
    3632      myPriority (0),
    37       myIsWanted (0),
     33      myIsWanted (false),
    3834      myHaveSize (0),
    39       myTotalSize (size),
    4035      myFirstUnhashedRow (0) {}
     36    ~FileTreeItem();
    4137
    4238  public:
    43     void appendChild (FileTreeItem *child);
     39    void appendChild (FileTreeItem * child);
    4440    FileTreeItem * child (const QString& filename);
    45     FileTreeItem * child (int row) { return myChildren.at(row); }
    46     int childCount () const { return myChildren.size(); }
     41    FileTreeItem * child (int row) { return myChildren.at (row); }
     42    int childCount () const { return myChildren.size (); }
    4743    FileTreeItem * parent () { return myParent; }
    4844    const FileTreeItem * parent () const { return myParent; }
     
    5046    const QString& name () const { return myName; }
    5147    QVariant data (int column, int role) const;
    52     std::pair<int,int> update (const QString& name, bool want, int priority, uint64_t have, bool updateFields);
     48    std::pair<int, int> update (const QString& name, bool want, int priority, uint64_t have, bool updateFields);
    5349    void twiddleWanted (QSet<int>& fileIds, bool&);
    5450    void twiddlePriority (QSet<int>& fileIds, int&);
     
    5753    QString path () const;
    5854    bool isComplete () const;
     55
     56  private:
     57    enum
     58    {
     59      LOW    = (1 << 0),
     60      NORMAL = (1 << 1),
     61      HIGH   = (1 << 2)
     62    };
    5963
    6064  private:
     
    6771    int priority () const;
    6872    int isSubtreeWanted () const;
     73    const QHash<QString,int>& getMyChildRows();
    6974
     75  private:
     76    QString myName;
    7077    const int myFileIndex;
     78    const uint64_t myTotalSize;
     79
    7180    FileTreeItem * myParent;
    7281    QList<FileTreeItem*> myChildren;
    7382    QHash<QString,int> myChildRows;
    74     const QHash<QString,int>& getMyChildRows();
    75     QString myName;
    7683    int myPriority;
    7784    bool myIsWanted;
    7885    uint64_t myHaveSize;
    79     const uint64_t myTotalSize;
    8086    size_t myFirstUnhashedRow;
    8187};
  • trunk/qt/FileTreeModel.cc

    r14537 r14539  
    1717FileTreeModel::FileTreeModel (QObject * parent, bool isEditable):
    1818  QAbstractItemModel(parent),
     19  myIsEditable (isEditable),
    1920  myRootItem (new FileTreeItem),
    20   myIndexCache (),
    21   myIsEditable (isEditable)
     21  myIndexCache ()
    2222{
    2323}
  • trunk/qt/FileTreeModel.h

    r14537 r14539  
    4040
    4141  public:
    42     FileTreeModel (QObject *parent = 0, bool isEditable = true);
    43     ~FileTreeModel ();
     42    FileTreeModel (QObject * parent = nullptr, bool isEditable = true);
     43    virtual ~FileTreeModel ();
    4444
    4545    void setEditable (bool editable);
    4646
    47   public:
    48     QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const;
    49     Qt::ItemFlags flags (const QModelIndex& index) const;
    50     QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
    51     QModelIndex index (int row, int column, const QModelIndex& parent = QModelIndex()) const;
    52     QModelIndex parent (const QModelIndex& child) const;
     47    void clear ();
     48    void addFile (int index, const QString& filename,
     49                  bool wanted, int priority,
     50                  uint64_t size, uint64_t have,
     51                  QList<QModelIndex>& rowsAdded,
     52                  bool torrentChanged);
     53
    5354    QModelIndex parent (const QModelIndex& child, int column) const;
    54     int rowCount (const QModelIndex& parent = QModelIndex()) const;
    55     int columnCount (const QModelIndex &parent = QModelIndex()) const;
    56     virtual bool setData (const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
     55
     56    // QAbstractItemModel
     57    virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
     58    virtual Qt::ItemFlags flags (const QModelIndex& index) const;
     59    virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
     60    virtual QModelIndex index (int row, int column, const QModelIndex& parent = QModelIndex ()) const;
     61    virtual QModelIndex parent (const QModelIndex& child) const;
     62    virtual int rowCount (const QModelIndex& parent = QModelIndex ()) const;
     63    virtual int columnCount (const QModelIndex& parent = QModelIndex ()) const;
     64    virtual bool setData (const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
     65
     66  public slots:
     67    void clicked (const QModelIndex& index);
     68    void doubleClicked (const QModelIndex& index);
    5769
    5870  signals:
     
    6274    void openRequested (const QString& path);
    6375
    64   public:
    65     void clear ();
    66     void addFile (int index, const QString& filename,
    67                   bool wanted, int priority,
    68                   uint64_t size, uint64_t have,
    69                   QList<QModelIndex>& rowsAdded,
    70                   bool torrentChanged);
    71 
    7276  private:
    73     void clearSubtree (const QModelIndex &);
     77    void clearSubtree (const QModelIndex&);
    7478    QModelIndex indexOf (FileTreeItem *, int column) const;
    75     void parentsChanged (const QModelIndex &, int firstColumn, int lastColumn);
    76     void subtreeChanged (const QModelIndex &, int firstColumn, int lastColumn);
     79    void parentsChanged (const QModelIndex&, int firstColumn, int lastColumn);
     80    void subtreeChanged (const QModelIndex&, int firstColumn, int lastColumn);
    7781    FileTreeItem * findItemForFileIndex (int fileIndex) const;
    7882    FileTreeItem * itemFromIndex (const QModelIndex&) const;
    7983
    8084  private:
     85    bool myIsEditable;
     86
    8187    FileTreeItem * myRootItem;
    8288    QMap<int, FileTreeItem *> myIndexCache;
    83     bool myIsEditable;
    84 
    85   public slots:
    86     void clicked (const QModelIndex & index);
    87     void doubleClicked (const QModelIndex & index);
    8889};
    8990
  • trunk/qt/FileTreeView.h

    r14537 r14539  
    2626
    2727  public:
    28     FileTreeView (QWidget * parent=0, bool editable=true);
     28    FileTreeView (QWidget * parent = nullptr, bool editable = true);
     29
    2930    void clear ();
    30     void update (const FileList& files, bool updateProperties=true);
     31    void update (const FileList& files, bool updateProperties = true);
    3132
    3233    void setEditable (bool editable);
     34
     35  public slots:
     36    void onClicked (const QModelIndex& index);
     37    void onDoubleClicked (const QModelIndex& index);
     38    void onOpenRequested (const QString& path);
    3339
    3440  signals:
     
    3945
    4046  protected:
     47    // QObject
    4148    bool eventFilter (QObject *, QEvent *);
    4249
     
    4552    QSortFilterProxyModel * myProxy;
    4653    FileTreeDelegate * myDelegate;
    47 
    48   public slots:
    49     void onClicked (const QModelIndex& index);
    50     void onDoubleClicked (const QModelIndex& index);
    51     void onOpenRequested (const QString& path);
    5254};
    5355
  • trunk/qt/FilterBar.cc

    r14537 r14539  
    2020#include "FilterBarLineEdit.h"
    2121#include "Prefs.h"
     22#include "Torrent.h"
    2223#include "TorrentFilter.h"
    2324#include "TorrentModel.h"
     
    104105FilterBar::refreshTrackers ()
    105106{
    106   FaviconCache& favicons = qApp->favicons;
     107  FaviconCache& favicons = qApp->faviconCache ();
    107108  const int firstTrackerRow = 2; // skip over the "All" and separator...
    108109
  • trunk/qt/FilterBar.h

    r14537 r14539  
    2828
    2929  public:
    30     FilterBar (Prefs& prefs, const TorrentModel& torrents, const TorrentFilter& filter, QWidget * parent = 0);
    31     ~FilterBar ();
     30    FilterBar (Prefs& prefs, const TorrentModel& torrents, const TorrentFilter& filter, QWidget * parent = nullptr);
     31    virtual ~FilterBar ();
    3232
    3333  private:
    34     FilterBarComboBox * createTrackerCombo (QStandardItemModel * );
     34    FilterBarComboBox * createTrackerCombo (QStandardItemModel *);
    3535    FilterBarComboBox * createActivityCombo ();
    3636    void recountSoon ();
    3737    void refreshTrackers ();
    3838    QString getCountString (int n) const;
    39 
    40   private:
    41     Prefs& myPrefs;
    42     const TorrentModel& myTorrents;
    43     const TorrentFilter& myFilter;
    44     FilterBarComboBox * myActivityCombo;
    45     FilterBarComboBox * myTrackerCombo;
    46     QLabel * myCountLabel;
    47     QStandardItemModel * myTrackerModel;
    48     QTimer * myRecountTimer;
    49     bool myIsBootstrapping;
    50     FilterBarLineEdit * myLineEdit;
    5139
    5240  private slots:
     
    6149    void onTorrentModelDataChanged (const QModelIndex&, const QModelIndex&);
    6250    void onTextChanged (const QString&);
     51
     52  private:
     53    Prefs& myPrefs;
     54    const TorrentModel& myTorrents;
     55    const TorrentFilter& myFilter;
     56
     57    FilterBarComboBox * myActivityCombo;
     58    FilterBarComboBox * myTrackerCombo;
     59    QLabel * myCountLabel;
     60    QStandardItemModel * myTrackerModel;
     61    QTimer * myRecountTimer;
     62    bool myIsBootstrapping;
     63    FilterBarLineEdit * myLineEdit;
    6364};
    6465
  • trunk/qt/FilterBarComboBox.h

    r14537 r14539  
    2626
    2727  public:
    28     FilterBarComboBox (QWidget * parent = 0);
     28    FilterBarComboBox (QWidget * parent = nullptr);
     29
    2930    int currentCount () const;
    3031
     32    // QWidget
    3133    virtual QSize minimumSizeHint () const;
    3234    virtual QSize sizeHint () const;
    3335
    3436  protected:
     37    // QWidget
    3538    virtual void paintEvent (QPaintEvent * e);
    3639
  • trunk/qt/FilterBarComboBoxDelegate.h

    r14537 r14539  
    2323    FilterBarComboBoxDelegate (QObject * parent, QComboBox * combo);
    2424
    25   public:
    2625    static bool isSeparator (const QModelIndex &index);
    2726    static void setSeparator (QAbstractItemModel * model, const QModelIndex& index);
    2827
    2928  protected:
    30     virtual void paint (QPainter*, const QStyleOptionViewItem&, const QModelIndex&) const;
     29    // QAbstractItemDelegate
     30    virtual void paint (QPainter *, const QStyleOptionViewItem&, const QModelIndex&) const;
    3131    virtual QSize sizeHint (const QStyleOptionViewItem&, const QModelIndex&) const;
    3232
    3333  private:
    34     QComboBox * myCombo;
     34    QComboBox * const myCombo;
    3535};
    3636
  • trunk/qt/FilterBarLineEdit.h

    r14537 r14539  
    2020
    2121  public:
    22     FilterBarLineEdit (QWidget * parent = 0);
     22    FilterBarLineEdit (QWidget * parent = nullptr);
    2323
    2424  protected:
     25    // QWidget
    2526    virtual void resizeEvent (QResizeEvent * event);
    2627
  • trunk/qt/Filters.h

    r14537 r14539  
    1717class FilterMode
    1818{
     19  public:
     20    enum
     21    {
     22      SHOW_ALL,
     23      SHOW_ACTIVE,
     24      SHOW_DOWNLOADING,
     25      SHOW_SEEDING,
     26      SHOW_PAUSED,
     27      SHOW_FINISHED,
     28      SHOW_VERIFYING,
     29      SHOW_ERROR,
     30      NUM_MODES
     31    };
     32
     33  public:
     34    FilterMode (int mode = SHOW_ALL): myMode (mode) {}
     35    FilterMode (const QString& name): myMode (modeFromName (name)) {}
     36
     37    int mode () const { return myMode; }
     38    const QString& name () const { return names[myMode]; }
     39
     40    static int modeFromName (const QString& name);
     41    static const QString& nameFromMode(int mode) { return names[mode]; }
     42
    1943  private:
    2044    int myMode;
    2145
    22   public:
    23     FilterMode( int mode=SHOW_ALL ): myMode(mode) {}
    24     FilterMode( const QString& name ): myMode(modeFromName(name)) {}
    2546    static const QString names[];
    26     enum { SHOW_ALL, SHOW_ACTIVE, SHOW_DOWNLOADING, SHOW_SEEDING, SHOW_PAUSED,
    27            SHOW_FINISHED, SHOW_VERIFYING, SHOW_ERROR, NUM_MODES };
    28     static int modeFromName( const QString& name );
    29     static const QString& nameFromMode( int mode ) { return names[mode]; }
    30     int mode() const { return myMode; }
    31     const QString& name() const { return names[myMode]; }
    3247};
     48
     49Q_DECLARE_METATYPE(FilterMode)
    3350
    3451class SortMode
    3552{
     53  public:
     54    enum
     55    {
     56      SORT_BY_ACTIVITY,
     57      SORT_BY_AGE,
     58      SORT_BY_ETA,
     59      SORT_BY_NAME,
     60      SORT_BY_PROGRESS,
     61      SORT_BY_QUEUE,
     62      SORT_BY_RATIO,
     63      SORT_BY_SIZE,
     64      SORT_BY_STATE,
     65      SORT_BY_ID,
     66      NUM_MODES
     67    };
     68
     69  public:
     70    SortMode (int mode = SORT_BY_ID): myMode (mode) {}
     71    SortMode (const QString& name): myMode (modeFromName (name)) {}
     72
     73    int mode () const { return myMode; }
     74    const QString& name () const { return names[myMode]; }
     75
     76    static int modeFromName (const QString& name);
     77    static const QString& nameFromMode (int mode);
     78
    3679  private:
    3780    int myMode;
    3881
    39   public:
    40     SortMode( int mode=SORT_BY_ID ): myMode(mode) {}
    41     SortMode( const QString& name ): myMode(modeFromName(name)) {}
    4282    static const QString names[];
    43     enum { SORT_BY_ACTIVITY, SORT_BY_AGE, SORT_BY_ETA, SORT_BY_NAME,
    44            SORT_BY_PROGRESS, SORT_BY_QUEUE, SORT_BY_RATIO, SORT_BY_SIZE,
    45            SORT_BY_STATE, SORT_BY_ID, NUM_MODES };
    46     static int modeFromName( const QString& name );
    47     static const QString& nameFromMode( int mode );
    48     int mode() const { return myMode; }
    49     const QString& name() const { return names[myMode]; }
    5083};
    5184
    52 Q_DECLARE_METATYPE(FilterMode)
    5385Q_DECLARE_METATYPE(SortMode)
    5486
  • trunk/qt/Formatter.h

    r14537 r14539  
    1313#include <stdint.h> // int64_t
    1414
     15#include <QCoreApplication>
    1516#include <QString>
    16 #include <QObject>
    17 #include <QIcon>
    1817
    1918class Speed;
    2019
    21 class Formatter: public QObject
     20class Formatter
    2221{
    23     Q_OBJECT
     22    Q_DECLARE_TR_FUNCTIONS (Formatter)
    2423
    2524  public:
     25    enum Size
     26    {
     27      B,
     28      KB,
     29      MB,
     30      GB,
     31      TB
     32    };
    2633
    27     Formatter() {}
    28     virtual ~Formatter() {}
     34    enum Type
     35    {
     36      SPEED,
     37      SIZE,
     38      MEM
     39    };
    2940
    3041  public:
    31 
    3242    static QString memToString (int64_t bytes);
    3343    static QString sizeToString (int64_t bytes);
     
    3646    static QString ratioToString (double ratio);
    3747    static QString timeToString (int seconds);
    38     static QString uploadSpeedToString(const Speed& up);
    39     static QString downloadSpeedToString(const Speed& down);
     48    static QString uploadSpeedToString (const Speed& up);
     49    static QString downloadSpeedToString (const Speed& down);
    4050
    41   public:
    42 
    43     typedef enum { B, KB, MB, GB, TB } Size;
    44     typedef enum { SPEED, SIZE, MEM } Type;
    4551    static QString unitStr (Type t, Size s) { return unitStrings[t][s]; }
    4652    static void initUnits ();
    4753
    4854  private:
    49 
    5055    static QString unitStrings[3][5];
    5156};
  • trunk/qt/FreeSpaceLabel.h

    r14537 r14539  
    1313#include <stdint.h>
    1414
     15#include <QLabel>
    1516#include <QString>
    1617#include <QTimer>
    17 #include <QLabel>
    1818
    1919class Session;
     
    2929
    3030  public:
    31     FreeSpaceLabel (QWidget * parent = 0);
     31    FreeSpaceLabel (QWidget * parent = nullptr);
    3232    virtual ~FreeSpaceLabel () {}
    3333
    3434    void setSession (Session& session);
    3535    void setPath (const QString& folder);
     36
     37  private slots:
     38    void onSessionExecuted (int64_t tag, const QString& result, tr_variant * arguments);
     39    void onTimer ();
    3640
    3741  private:
     
    4044    QString myPath;
    4145    QTimer myTimer;
    42 
    43   private slots:
    44     void onSessionExecuted (int64_t tag, const QString& result, tr_variant * arguments);
    45     void onTimer ();
    4646};
    4747
  • trunk/qt/IconToolButton.h

    r14537 r14539  
    2121
    2222  protected:
     23    // QWidget
    2324    virtual void paintEvent (QPaintEvent * event);
    2425};
  • trunk/qt/LicenseDialog.h

    r14537 r14539  
    1818
    1919  public:
    20     LicenseDialog (QWidget * parent = 0);
    21     ~LicenseDialog () {}
     20    LicenseDialog (QWidget * parent = nullptr);
     21    virtual ~LicenseDialog () {}
    2222};
    2323
  • trunk/qt/MainWindow.cc

    r14537 r14539  
    8080
    8181MainWindow::MainWindow (Session& session, Prefs& prefs, TorrentModel& model, bool minimized):
     82  mySession (session),
     83  myPrefs (prefs),
     84  myModel (model),
    8285  myLastFullUpdateTime (0),
    8386  mySessionDialog (new SessionDialog (session, prefs, this)),
     
    8992  myTorrentDelegate (new TorrentDelegate (this)),
    9093  myTorrentDelegateMin (new TorrentDelegateMin (this)),
    91   mySession (session),
    92   myPrefs (prefs),
    93   myModel (model),
    9494  myLastSendTime (0),
    9595  myLastReadTime (0),
  • trunk/qt/MainWindow.h

    r14537 r14539  
    1212
    1313#include <ctime>
    14 #include <QLineEdit>
    15 #include <QIcon>
     14
    1615#include <QMainWindow>
    17 #include <QMap>
     16#include <QNetworkReply>
    1817#include <QPointer>
    19 #include <QPushButton>
    2018#include <QSet>
    2119#include <QSystemTrayIcon>
    2220#include <QTimer>
    2321#include <QWidgetList>
    24 #include <QNetworkReply>
    2522
    2623#include "Filters.h"
     
    2825#include "ui_MainWindow.h"
    2926
     27class QAction;
     28class QIcon;
     29class QMenu;
     30
    3031class AddData;
    31 class ActionDelegator;
    3232class Prefs;
    3333class DetailsDialog;
     
    3636class TorrentDelegateMin;
    3737class TorrentModel;
    38 class QAction;
    39 class QLabel;
    40 class QMenu;
    41 class QModelIndex;
    42 class QSortFilterProxyModel;
    43 class Filterbar;
    4438
    4539extern "C"
     
    5246    Q_OBJECT
    5347
     48  public:
     49    MainWindow (Session&, Prefs&, TorrentModel&, bool minized);
     50    virtual ~MainWindow ();
     51
     52  public slots:
     53    void startAll ();
     54    void startSelected ();
     55    void startSelectedNow ();
     56    void pauseAll ();
     57    void pauseSelected ();
     58    void removeSelected ();
     59    void deleteSelected ();
     60    void verifySelected ();
     61    void queueMoveTop ();
     62    void queueMoveUp ();
     63    void queueMoveDown ();
     64    void queueMoveBottom ();
     65    void reannounceSelected ();
     66    void onNetworkTimer ();
     67
     68    void setToolbarVisible (bool);
     69    void setFilterbarVisible (bool);
     70    void setStatusbarVisible (bool);
     71    void setCompactView (bool);
     72    void refreshActionSensitivity ();
     73    void refreshActionSensitivitySoon ();
     74    void wrongAuthentication ();
     75
     76  protected:
     77    // QWidget
     78    virtual void contextMenuEvent (QContextMenuEvent *);
     79    virtual void dragEnterEvent (QDragEnterEvent *);
     80    virtual void dropEvent (QDropEvent *);
     81
    5482  private:
     83    QIcon getStockIcon (const QString&, int fallback = -1);
     84
     85    QSet<int> getSelectedTorrents () const;
     86    void updateNetworkIcon ();
     87
     88    QMenu * createOptionsMenu ();
     89    QMenu * createStatsModeMenu ();
     90    void initStatusBar ();
     91
     92    void clearSelection ();
     93    void addTorrent (const AddData& addMe, bool showOptions);
     94
     95    // QWidget
    5596    virtual void hideEvent (QHideEvent * event);
    5697    virtual void showEvent (QShowEvent * event);
    57 
    58   private:
    59     time_t myLastFullUpdateTime;
    60     QDialog * mySessionDialog;
    61     QPointer<QDialog> myPrefsDialog;
    62     QDialog * myAboutDialog;
    63     QDialog * myStatsDialog;
    64     DetailsDialog * myDetailsDialog;
    65     QSystemTrayIcon myTrayIcon;
    66     TorrentFilter myFilterModel;
    67     TorrentDelegate * myTorrentDelegate;
    68     TorrentDelegateMin * myTorrentDelegateMin;
    69     Session& mySession;
    70     Prefs& myPrefs;
    71     TorrentModel& myModel;
    72     Ui_MainWindow ui;
    73     time_t myLastSendTime;
    74     time_t myLastReadTime;
    75     QTimer myNetworkTimer;
    76     bool myNetworkError;
    77     QTimer myRefreshTrayIconTimer;
    78     QTimer myRefreshActionSensitivityTimer;
    79     QAction * myDlimitOffAction;
    80     QAction * myDlimitOnAction;
    81     QAction * myUlimitOffAction;
    82     QAction * myUlimitOnAction;
    83     QAction * myRatioOffAction;
    84     QAction * myRatioOnAction;
    85 
    86   private:
    87     QIcon getStockIcon (const QString&, int fallback=-1);
    88 
    89   private:
    90     QSet<int> getSelectedTorrents () const;
    91     void updateNetworkIcon ();
    92     QWidgetList myHidden;
    9398
    9499  private slots:
     
    127132    void onModelReset ();
    128133
    129   private slots:
    130134    void setSortPref (int);
    131135    void setSortAscendingPref (bool);
     
    141145
    142146  private:
     147    Session& mySession;
     148    Prefs& myPrefs;
     149    TorrentModel& myModel;
     150
     151    Ui_MainWindow ui;
     152
     153    time_t myLastFullUpdateTime;
     154    QDialog * mySessionDialog;
     155    QPointer<QDialog> myPrefsDialog;
     156    QDialog * myAboutDialog;
     157    QDialog * myStatsDialog;
     158    DetailsDialog * myDetailsDialog;
     159    QSystemTrayIcon myTrayIcon;
     160    TorrentFilter myFilterModel;
     161    TorrentDelegate * myTorrentDelegate;
     162    TorrentDelegateMin * myTorrentDelegateMin;
     163    time_t myLastSendTime;
     164    time_t myLastReadTime;
     165    QTimer myNetworkTimer;
     166    bool myNetworkError;
     167    QTimer myRefreshTrayIconTimer;
     168    QTimer myRefreshActionSensitivityTimer;
     169    QAction * myDlimitOffAction;
     170    QAction * myDlimitOnAction;
     171    QAction * myUlimitOffAction;
     172    QAction * myUlimitOnAction;
     173    QAction * myRatioOffAction;
     174    QAction * myRatioOnAction;
     175    QWidgetList myHidden;
    143176    QWidget * myFilterBar;
    144 
    145   private:
    146     QMenu * createOptionsMenu ();
    147     QMenu * createStatsModeMenu ();
    148     void initStatusBar ();
    149 
    150177    QAction * myAltSpeedAction;
    151178    QString myErrorMessage;
    152 
    153   public slots:
    154     void startAll ();
    155     void startSelected ();
    156     void startSelectedNow ();
    157     void pauseAll ();
    158     void pauseSelected ();
    159     void removeSelected ();
    160     void deleteSelected ();
    161     void verifySelected ();
    162     void queueMoveTop ();
    163     void queueMoveUp ();
    164     void queueMoveDown ();
    165     void queueMoveBottom ();
    166     void reannounceSelected ();
    167     void onNetworkTimer ();
    168 
    169   private:
    170     void clearSelection ();
    171     void addTorrent (const AddData& addMe, bool showOptions);
    172 
    173   public slots:
    174     void setToolbarVisible (bool);
    175     void setFilterbarVisible (bool);
    176     void setStatusbarVisible (bool);
    177     void setCompactView (bool);
    178     void refreshActionSensitivity ();
    179     void refreshActionSensitivitySoon ();
    180     void wrongAuthentication ();
    181 
    182   public:
    183     MainWindow (Session&, Prefs&, TorrentModel&, bool minized);
    184     virtual ~MainWindow ();
    185 
    186   protected:
    187     virtual void contextMenuEvent (QContextMenuEvent *);
    188     virtual void dragEnterEvent (QDragEnterEvent *);
    189     virtual void dropEvent (QDropEvent *);
    190179};
    191180
  • trunk/qt/MakeDialog.h

    r14537 r14539  
    3030    Q_OBJECT
    3131
     32  public:
     33    MakeDialog (Session&, QWidget * parent = nullptr);
     34    virtual ~MakeDialog ();
     35
     36  protected:
     37    // QWidget
     38    virtual void dragEnterEvent (QDragEnterEvent *);
     39    virtual void dropEvent (QDropEvent *);
     40
     41  private:
     42    QString getSource () const;
     43
    3244  private slots:
    3345    void onSourceChanged ();
     
    3547
    3648  private:
    37     QString getSource () const;
     49    Session& mySession;
    3850
    39   private:
    40     Session& mySession;
    4151    Ui::MakeDialog ui;
     52
    4253    std::unique_ptr<tr_metainfo_builder, void(*)(tr_metainfo_builder*)> myBuilder;
    43 
    44   protected:
    45     virtual void dragEnterEvent (QDragEnterEvent *);
    46     virtual void dropEvent (QDropEvent *);
    47 
    48   public:
    49     MakeDialog (Session&, QWidget * parent = 0);
    50     virtual ~MakeDialog ();
    5154};
    5255
  • trunk/qt/OptionsDialog.h

    r14537 r14539  
    1616#include <QFile>
    1717#include <QMap>
    18 #include <QString>
    1918#include <QString>
    2019#include <QTimer>
     
    3938
    4039  public:
    41     OptionsDialog (Session& session, const Prefs& prefs, const AddData& addme, QWidget * parent = 0);
    42     ~OptionsDialog ();
     40    OptionsDialog (Session& session, const Prefs& prefs, const AddData& addme, QWidget * parent = nullptr);
     41    virtual ~OptionsDialog ();
     42
     43  private:
     44    typedef QMap<uint32_t, int32_t> mybins_t;
    4345
    4446  private:
     
    6062    Session& mySession;
    6163    AddData myAdd;
     64
     65    Ui::OptionsDialog ui;
     66
    6267    QDir myLocalDestination;
    6368    bool myHaveInfo;
    6469    tr_info myInfo;
    65     Ui::OptionsDialog ui;
    6670    QPushButton * myVerifyButton;
    6771    QVector<int> myPriorities;
     
    6973    FileList myFiles;
    7074
    71   private:
    7275    QTimer myVerifyTimer;
    7376    char myVerifyBuf[2048 * 4];
     
    7982    QVector<bool> myVerifyFlags;
    8083    QCryptographicHash myVerifyHash;
    81     typedef QMap<uint32_t, int32_t> mybins_t;
    8284    mybins_t myVerifyBins;
    8385    QTimer myEditTimer;
  • trunk/qt/PathButton.h

    r14537 r14539  
    3434    const QString& path () const;
    3535
     36    // QWidget
    3637    virtual QSize sizeHint () const;
    3738
     
    4041
    4142  protected:
     43    // QWidget
    4244    virtual void paintEvent (QPaintEvent * event);
    43 
    44   private slots:
    45     void onClicked ();
    46     void onFileSelected (const QString& path);
    4745
    4846  private:
     
    5149    bool isDirMode () const;
    5250    QString effectiveTitle () const;
     51
     52  private slots:
     53    void onClicked ();
     54    void onFileSelected (const QString& path);
    5355
    5456  private:
  • trunk/qt/Prefs.cc

    r14537 r14539  
    1313#include <iostream>
    1414
     15#include <QDateTime>
    1516#include <QDir>
    1617#include <QFile>
  • trunk/qt/Prefs.h

    r14537 r14539  
    1111#define QTR_PREFS_H
    1212
    13 #include <QDateTime>
    1413#include <QObject>
    1514#include <QSet>
     
    2019
    2120#include "Filters.h"
     21
     22class QDateTime;
    2223
    2324extern "C"
     
    3132
    3233  public:
    33 
    3434    enum
    3535    {
     
    132132    };
    133133
    134   private:
     134  public:
     135    Prefs (const QString& configDir);
     136    virtual ~Prefs ();
    135137
    136     struct PrefItem
    137     {
    138       int id;
    139       tr_quark key;
    140       int type;
    141     };
    142 
    143     static PrefItem myItems[];
    144 
    145   private:
    146     QSet<int> myTemporaryPrefs;
    147     QString const myConfigDir;
    148     mutable QVariant myValues[PREFS_COUNT];
    149     void initDefaults (tr_variant *);
    150 
    151     void set (int key, const char * value);
    152 
    153   public:
    154     bool isCore (int key) const { return FIRST_CORE_PREF<=key && key<=LAST_CORE_PREF; }
     138    bool isCore (int key) const { return FIRST_CORE_PREF <= key && key <= LAST_CORE_PREF; }
    155139    bool isClient (int key) const { return !isCore (key); }
    156140    const char * keyStr (int i) const { return tr_quark_get_string (myItems[i].key,NULL); }
    157     tr_quark getKey  (int i) const { return myItems[i].key; }
     141    tr_quark getKey (int i) const { return myItems[i].key; }
    158142    int type (int i) const { return myItems[i].type; }
    159143    const QVariant& variant (int i) const { return myValues[i]; }
    160 
    161     Prefs (const QString& configDir);
    162     ~Prefs ();
    163144
    164145    int getInt (int key) const;
     
    174155      QVariant& v (myValues[key]);
    175156      const QVariant tmp = QVariant::fromValue (value);
    176       if (v.isNull() || (v!=tmp))
     157      if (v.isNull() || v != tmp)
    177158        {
    178159          v = tmp;
     
    185166  signals:
    186167    void changed (int key);
     168
     169  private:
     170    struct PrefItem
     171    {
     172      int id;
     173      tr_quark key;
     174      int type;
     175    };
     176
     177  private:
     178    void initDefaults (tr_variant *);
     179
     180    // Intentionally not implemented
     181    void set (int key, const char * value);
     182
     183  private:
     184    const QString myConfigDir;
     185
     186    QSet<int> myTemporaryPrefs;
     187    mutable QVariant myValues[PREFS_COUNT];
     188
     189    static PrefItem myItems[];
    187190};
    188191
  • trunk/qt/PrefsDialog.cc

    r14537 r14539  
    533533PrefsDialog::PrefsDialog (Session& session, Prefs& prefs, QWidget * parent):
    534534  QDialog (parent),
    535   myIsServer (session.isServer ()),
    536535  mySession (session),
    537   myPrefs (prefs)
     536  myPrefs (prefs),
     537  myIsServer (session.isServer ())
    538538{
    539539  ui.setupUi (this);
  • trunk/qt/PrefsDialog.h

    r14537 r14539  
    1818#include "ui_PrefsDialog.h"
    1919
    20 class QAbstractButton;
    21 class QCheckBox;
    22 class QDoubleSpinBox;
    2320class QHttp;
    24 class QLabel;
    25 class QLineEdit;
    2621class QMessageBox;
    27 class QPushButton;
    28 class QSpinBox;
    2922class QString;
    30 class QTime;
    31 class QTimeEdit;
    32 class QVBoxLayout;
    33 class QWidget;
    3423
    35 class FreeSpaceLabel;
    3624class Prefs;
    3725class Session;
     
    4028{
    4129    Q_OBJECT
     30
     31  public:
     32    PrefsDialog (Session&, Prefs&, QWidget * parent = nullptr);
     33    virtual ~PrefsDialog ();
     34
     35  private:
     36    typedef QMap<int, QWidget*> key2widget_t;
     37
     38  private:
     39    bool updateWidgetValue (QWidget * widget, int prefKey);
     40    void linkWidgetToPref (QWidget * widget, int prefKey);
     41    void updateBlocklistLabel ();
     42
     43    void setPref (int key, const QVariant& v);
     44
     45    void initDownloadingTab ();
     46    void initSeedingTab ();
     47    void initSpeedTab ();
     48    void initPrivacyTab ();
     49    void initNetworkTab ();
     50    void initDesktopTab ();
     51    void initRemoteTab ();
    4252
    4353  private slots:
     
    6272
    6373  private:
    64     bool updateWidgetValue (QWidget * widget, int prefKey);
    65     void linkWidgetToPref (QWidget * widget, int prefKey);
    66     void updateBlocklistLabel ();
     74    Session& mySession;
     75    Prefs& myPrefs;
    6776
    68   public:
    69     PrefsDialog (Session&, Prefs&, QWidget * parent = 0);
    70     ~PrefsDialog ();
     77    Ui::PrefsDialog ui;
    7178
    72   private:
    73     void setPref (int key, const QVariant& v);
    74 
    75     void initDownloadingTab ();
    76     void initSeedingTab ();
    77     void initSpeedTab ();
    78     void initPrivacyTab ();
    79     void initNetworkTab ();
    80     void initDesktopTab ();
    81     void initRemoteTab ();
    82 
    83   private:
    84     typedef QMap<int,QWidget*> key2widget_t;
    8579    key2widget_t myWidgets;
    8680    const bool myIsServer;
    87     Session& mySession;
    88     Prefs& myPrefs;
    8981    QWidgetList myWebWidgets;
    9082    QWidgetList myWebAuthWidgets;
     
    9587    QWidgetList myBlockWidgets;
    9688    QWidgetList myUnsupportedWhenRemote;
    97     Ui::PrefsDialog ui;
    9889
    9990    int myBlocklistHttpTag;
  • trunk/qt/RelocateDialog.h

    r14537 r14539  
    2424
    2525  public:
    26     RelocateDialog (Session&, const TorrentModel&, const QSet<int>& ids, QWidget * parent = 0);
    27     ~RelocateDialog () {}
     26    RelocateDialog (Session&, const TorrentModel&, const QSet<int>& ids, QWidget * parent = nullptr);
     27    virtual ~RelocateDialog () {}
     28
     29  private:
     30    QString newLocation () const;
    2831
    2932  private slots:
     
    3235
    3336  private:
    34     QString newLocation () const;
    35 
    36   private:
    3737    Session& mySession;
    3838    const QSet<int> myIds;
     39
    3940    Ui::RelocateDialog ui;
    4041
  • trunk/qt/Session.cc

    r14537 r14539  
    276276
    277277Session::Session (const QString& configDir, Prefs& prefs):
     278  myConfigDir (configDir),
     279  myPrefs (prefs),
    278280  nextUniqueTag (FIRST_UNIQUE_TAG),
    279281  myBlocklistSize (-1),
    280   myPrefs (prefs),
    281   mySession (0),
    282   myConfigDir (configDir)
     282  mySession (0)
    283283{
    284284  myStats.ratio = TR_RATIO_NA;
  • trunk/qt/Session.h

    r14537 r14539  
    3535  public:
    3636    FileAdded (int64_t tag, const QString& name): myTag (tag), myName (name) {}
    37     ~FileAdded () {}
     37    virtual ~FileAdded () {}
     38
    3839    void setFileToDelete (const QString& file) { myDelFile = file; }
    3940
     
    4445    const int64_t myTag;
    4546    const QString myName;
     47
    4648    QString myDelFile;
    4749};
     
    5355  public:
    5456    Session (const QString& configDir, Prefs& prefs);
    55     ~Session ();
     57    virtual ~Session ();
    5658
    57   public:
    5859    void stop ();
    5960    void restart ();
    6061
    61   private:
    62     void start ();
    63 
    64   public:
    6562    const QUrl& getRemoteUrl () const { return myRpc.url (); }
    6663    const tr_session_stats& getStats () const { return myStats; }
     
    6865    const QString& sessionVersion () const { return mySessionVersion; }
    6966
    70   public:
    7167    int64_t blocklistSize () const { return myBlocklistSize; }
    7268    void setBlocklistSize (int64_t i);
     
    7470    void portTest ();
    7571    void copyMagnetLinkToClipboard (int torrentId);
    76 
    77   public:
    7872
    7973    /** returns true if the transmission session is being run inside this client */
     
    8377    bool isLocal () const;
    8478
    85   private:
    86     void updateStats (tr_variant * args);
    87     void updateInfo (tr_variant * args);
     79    void exec (tr_quark method, tr_variant * args, int64_t tag = -1);
     80    void exec (const char * method, tr_variant * args, int64_t tag = -1);
    8881
    89   public:
    90     void exec (tr_quark method, tr_variant * args, int64_t tag = -1);
    91     void exec (const char* method, tr_variant * args, int64_t tag = -1);
    92 
    93   public:
    9482    int64_t getUniqueTag () { return nextUniqueTag++; }
    9583
    96   private:
    97     void sessionSet (const tr_quark key, const QVariant& variant);
    98     void pumpRequests ();
    99     void sendTorrentRequest (const char * request, const QSet<int>& torrentIds);
    100     static void updateStats (tr_variant * d, tr_session_stats * stats);
    101     void refreshTorrents (const QSet<int>& torrentIds);
    102 
    103   public:
    10484    void torrentSet (const QSet<int>& ids, const tr_quark key, bool val);
    10585    void torrentSet (const QSet<int>& ids, const tr_quark key, int val);
     
    127107    void addNewlyCreatedTorrent (const QString& filename, const QString& localPath);
    128108    void addTorrent (const AddData& addme);
    129     void removeTorrents (const QSet<int>& torrentIds, bool deleteFiles=false);
     109    void removeTorrents (const QSet<int>& torrentIds, bool deleteFiles = false);
    130110    void verifyTorrents (const QSet<int>& torrentIds);
    131111    void reannounceTorrents (const QSet<int>& torrentIds);
    132112    void launchWebInterface ();
    133113    void updatePref (int key);
    134 
     114 
    135115    /** request a refresh for statistics, including the ones only used by the properties dialog, for a specific torrent */
    136116    void refreshExtraStats (const QSet<int>& ids);
    137 
    138   private slots:
    139     void responseReceived (int64_t tag, const QString& result, tr_variant * args);
    140117
    141118  signals:
     
    155132
    156133  private:
     134    void start ();
     135
     136    void updateStats (tr_variant * args);
     137    void updateInfo (tr_variant * args);
     138
     139    void sessionSet (const tr_quark key, const QVariant& variant);
     140    void pumpRequests ();
     141    void sendTorrentRequest (const char * request, const QSet<int>& torrentIds);
     142    void refreshTorrents (const QSet<int>& torrentIds);
     143
     144    static void updateStats (tr_variant * d, tr_session_stats * stats);
     145
     146  private slots:
     147    void responseReceived (int64_t tag, const QString& result, tr_variant * args);
     148
     149  private:
     150    QString const myConfigDir;
     151    Prefs& myPrefs;
     152
    157153    int64_t nextUniqueTag;
    158154    int64_t myBlocklistSize;
    159     Prefs& myPrefs;
    160155    tr_session * mySession;
    161     QString const myConfigDir;
    162156    QStringList myIdleJSON;
    163157    tr_session_stats myStats;
  • trunk/qt/SessionDialog.h

    r14537 r14539  
    2424
    2525  public:
    26     SessionDialog (Session& session, Prefs& prefs, QWidget * parent = 0);
    27     ~SessionDialog () {}
     26    SessionDialog (Session& session, Prefs& prefs, QWidget * parent = nullptr);
     27    virtual ~SessionDialog () {}
    2828
    2929  private slots:
     
    3434    Session& mySession;
    3535    Prefs& myPrefs;
     36
    3637    Ui::SessionDialog ui;
     38
    3739    QWidgetList myRemoteWidgets;
    3840    QWidgetList myAuthWidgets;
  • trunk/qt/Speed.h

    r14537 r14539  
    1111#define QTR_SPEED_H
    1212
    13 #include "Formatter.h"
    14 
    1513class Speed
    1614{
    17   private:
    18     int _Bps;
    19     Speed (int Bps): _Bps (Bps) {}
    20 
    2115  public:
    2216    Speed (): _Bps (0) {}
     17
    2318    double KBps () const;
    2419    int Bps () const { return _Bps; }
     
    3025    Speed operator+ (const Speed& that) const { return Speed (_Bps + that._Bps); }
    3126    bool operator< (const Speed& that) const { return _Bps < that._Bps; }
     27
     28  private:
     29    Speed (int Bps): _Bps (Bps) {}
     30
     31  private:
     32    int _Bps;
    3233};
    3334
  • trunk/qt/SqueezeLabel.h

    r14537 r14539  
    5050
    5151  public:
    52     SqueezeLabel (QWidget *parent=0);
    53     SqueezeLabel (const QString& text, QWidget *parent=0);
     52    SqueezeLabel (QWidget * parent = nullptr);
     53    SqueezeLabel (const QString& text, QWidget * parent = nullptr);
    5454
    5555  protected:
    56     void paintEvent (QPaintEvent* paintEvent);
     56    // QWidget
     57    virtual void paintEvent (QPaintEvent * paintEvent);
    5758};
    5859
  • trunk/qt/StatsDialog.h

    r14537 r14539  
    1515#include "ui_StatsDialog.h"
    1616
     17class QTimer;
     18
    1719class Session;
    18 class QTimer;
    1920
    2021class StatsDialog: public QDialog
     
    2223    Q_OBJECT
    2324
     25  public:
     26    StatsDialog (Session&, QWidget * parent = nullptr);
     27    ~StatsDialog ();
     28
     29    // QWidget
     30    virtual void setVisible (bool visible);
     31
    2432  private slots:
    2533    void updateStats ();
    2634
    27   public:
    28     StatsDialog (Session&, QWidget * parent = 0);
    29     ~StatsDialog ();
    30     virtual void setVisible (bool visible);
     35  private:
     36    Session& mySession;
    3137
    32   private:
    33     Session & mySession;
     38    Ui::StatsDialog ui;
     39
    3440    QTimer * myTimer;
    35     Ui::StatsDialog ui;
    3641};
    3742
  • trunk/qt/Torrent.cc

    r14537 r14539  
    3030
    3131Torrent::Torrent (const Prefs& prefs, int id):
    32   magnetTorrent (false),
    33   myPrefs (prefs)
     32  myPrefs (prefs),
     33  magnetTorrent (false)
    3434{
    3535#ifndef NDEBUG
     
    605605          if (tr_variantDictFindStr(child, TR_KEY_announce, &str, &len))
    606606            {
    607               qApp->favicons.add (QUrl(QString::fromUtf8(str)));
     607              qApp->faviconCache ().add (QUrl(QString::fromUtf8(str)));
    608608              list.append (QString::fromUtf8 (str, len));
    609609            }
     
    645645            {
    646646              trackerStat.announce = QString::fromUtf8 (str, len);
    647               qApp->favicons.add (QUrl (trackerStat.announce));
     647              qApp->faviconCache ().add (QUrl (trackerStat.announce));
    648648            }
    649649
     
    801801TrackerStat::getFavicon () const
    802802{
    803   return qApp->favicons.find (QUrl (announce));
    804 }
    805 
     803  return qApp->faviconCache ().find (QUrl (announce));
     804}
     805
  • trunk/qt/Torrent.h

    r14537 r14539  
    1818#include <QStringList>
    1919#include <QList>
    20 #include <QTemporaryFile>
    2120#include <QVariant>
    2221
     
    3130#endif
    3231
     32class QPixmap;
     33
    3334class Prefs;
    34 class QPixmap;
    35 class QStyle;
    3635
    3736extern "C"
     
    5958};
    6059
     60Q_DECLARE_METATYPE(Peer)
     61
    6162typedef QList<Peer> PeerList;
    62 Q_DECLARE_METATYPE(Peer)
    6363Q_DECLARE_METATYPE(PeerList)
    6464
    6565struct TrackerStat
    6666{
     67  QPixmap getFavicon () const;
     68
    6769  bool hasAnnounced;
    6870  bool hasScraped;
     
    9092  QString lastAnnounceResult;
    9193  QString lastScrapeResult;
    92   QPixmap getFavicon () const;
    9394};
    9495
     96Q_DECLARE_METATYPE(TrackerStat)
     97
    9598typedef QList<TrackerStat> TrackerStatsList;
    96 Q_DECLARE_METATYPE(TrackerStat)
    9799Q_DECLARE_METATYPE(TrackerStatsList)
    98100
    99101struct TorrentFile
    100102{
    101   TorrentFile(): wanted(true), index(-1), priority(0), size(0), have(0) {}
     103  TorrentFile(): wanted (true), index (-1), priority (0), size (0), have (0) {}
    102104
    103105  bool wanted;
     
    109111};
    110112
     113Q_DECLARE_METATYPE(TorrentFile)
     114
    111115typedef QList<TorrentFile> FileList;
    112 Q_DECLARE_METATYPE(TorrentFile)
    113116Q_DECLARE_METATYPE(FileList)
    114117
    115 
    116118class Torrent: public QObject
    117119{
     
    119121
    120122  public:
    121 
    122123    enum
    123124    {
     
    182183    };
    183184
     185    typedef QList<tr_quark> KeyList;
     186
    184187  public:
    185188    Torrent (const Prefs&, int id);
    186189    virtual ~Torrent ();
    187 
    188   signals:
    189     void torrentChanged (int id);
    190     void torrentCompleted (int id);
    191 
    192   private:
    193 
    194     enum Group
    195     {
    196       INFO, // info fields that only need to be loaded once
    197       STAT, // commonly-used stats that should be refreshed often
    198       STAT_EXTRA,  // rarely used; only refresh if details dialog is open
    199       DERIVED // doesn't come from RPC
    200     };
    201 
    202     struct Property
    203     {
    204       int id;
    205       tr_quark key;
    206       int type;
    207       int group;
    208     };
    209 
    210     static Property myProperties[];
    211 
    212     bool magnetTorrent;
    213 
    214   public:
    215     typedef QList<tr_quark> KeyList;
    216     static const KeyList& getInfoKeys ();
    217     static const KeyList& getStatKeys ();
    218     static const KeyList& getExtraStatKeys ();
    219 
    220   private:
    221     static KeyList buildKeyList (Group group);
    222 
    223   private:
    224     QVariant myValues[PROPERTY_COUNT];
    225 
    226     int getInt            (int key) const;
    227     bool getBool          (int key) const;
    228     QTime getTime         (int key) const;
    229     QIcon getIcon         (int key) const;
    230     double getDouble      (int key) const;
    231     qulonglong getSize    (int key) const;
    232     QString getString     (int key) const;
    233     QDateTime getDateTime (int key) const;
    234 
    235     bool setInt        (int key, int value);
    236     bool setBool       (int key, bool value);
    237     bool setIcon       (int key, const QIcon&);
    238     bool setDouble     (int key, double);
    239     bool setString     (int key, const char *);
    240     bool setSize       (int key, qulonglong);
    241     bool setDateTime   (int key, const QDateTime&);
    242 
    243   public:
    244190
    245191    int getBandwidthPriority () const { return getInt (BANDWIDTH_PRIORITY); }
     
    315261    bool isStalled () const { return getBool (IS_STALLED); }
    316262
    317   public:
    318263    QString activityString () const;
    319264    tr_torrent_activity getActivity () const { return static_cast<tr_torrent_activity> (getInt (ACTIVITY)); }
     
    330275    void notifyComplete () const;
    331276
    332   public:
    333277    void update (tr_variant * dict);
    334278    void setMagnet (bool magnet) { magnetTorrent = magnet; }
    335279
     280    QIcon getMimeTypeIcon () const { return getIcon (MIME_ICON); }
     281
     282    static const KeyList& getInfoKeys ();
     283    static const KeyList& getStatKeys ();
     284    static const KeyList& getExtraStatKeys ();
     285
     286  signals:
     287    void torrentChanged (int id);
     288    void torrentCompleted (int id);
     289
    336290  private:
     291    enum Group
     292    {
     293      INFO, // info fields that only need to be loaded once
     294      STAT, // commonly-used stats that should be refreshed often
     295      STAT_EXTRA,  // rarely used; only refresh if details dialog is open
     296      DERIVED // doesn't come from RPC
     297    };
     298
     299    struct Property
     300    {
     301      int id;
     302      tr_quark key;
     303      int type;
     304      int group;
     305    };
     306
     307  private:
     308    int getInt            (int key) const;
     309    bool getBool          (int key) const;
     310    QTime getTime         (int key) const;
     311    QIcon getIcon         (int key) const;
     312    double getDouble      (int key) const;
     313    qulonglong getSize    (int key) const;
     314    QString getString     (int key) const;
     315    QDateTime getDateTime (int key) const;
     316
     317    bool setInt        (int key, int value);
     318    bool setBool       (int key, bool value);
     319    bool setIcon       (int key, const QIcon&);
     320    bool setDouble     (int key, double);
     321    bool setString     (int key, const char *);
     322    bool setSize       (int key, qulonglong);
     323    bool setDateTime   (int key, const QDateTime&);
     324
    337325    const char * getMimeTypeString () const;
    338326    void updateMimeIcon ();
    339327
    340   public:
    341     QIcon getMimeTypeIcon () const { return getIcon (MIME_ICON); }
     328    static KeyList buildKeyList (Group group);
    342329
    343330  private:
    344331    const Prefs& myPrefs;
     332
     333    QVariant myValues[PROPERTY_COUNT];
     334    bool magnetTorrent;
    345335    FileList myFiles;
     336
     337    static Property myProperties[];
    346338};
    347339
  • trunk/qt/TorrentDelegate.cc

    r14537 r14539  
    158158
    159159QString
    160 TorrentDelegate::progressString (const Torrent& tor) const
     160TorrentDelegate::progressString (const Torrent& tor)
    161161{
    162162  const bool isMagnet (!tor.hasMetadata());
     
    267267
    268268QString
    269 TorrentDelegate::shortTransferString (const Torrent& tor) const
     269TorrentDelegate::shortTransferString (const Torrent& tor)
    270270{
    271271  QString str;
     
    286286
    287287QString
    288 TorrentDelegate::shortStatusString (const Torrent& tor) const
     288TorrentDelegate::shortStatusString (const Torrent& tor)
    289289{
    290290  QString str;
     
    313313
    314314QString
    315 TorrentDelegate::statusString (const Torrent& tor) const
     315TorrentDelegate::statusString (const Torrent& tor)
    316316{
    317317  QString str;
  • trunk/qt/TorrentDelegate.h

    r14537 r14539  
    1212
    1313#include <QStyledItemDelegate>
    14 #include <QSize>
    1514
     15class QStyle;
    1616class QStyleOptionProgressBar;
    17 class QStyleOptionViewItem;
    18 class QStyle;
    19 class Session;
     17
    2018class Torrent;
    2119
     
    2523
    2624  public:
    27     static QColor blueBrush, greenBrush, silverBrush;
    28     static QColor blueBack,  greenBack, silverBack;
     25    explicit TorrentDelegate (QObject * parent = nullptr);
     26    virtual ~TorrentDelegate ();
     27
     28    // QAbstractItemDelegate
     29    virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
     30    virtual void paint(QPainter * painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
     31
     32  protected:
     33    QSize margin (const QStyle& style) const;
     34    void setProgressBarPercentDone (const QStyleOptionViewItem& option, const Torrent&) const;
     35
     36    // Our own overridables
     37    virtual QSize sizeHint (const QStyleOptionViewItem&, const Torrent&) const;
     38    virtual void drawTorrent (QPainter * painter, const QStyleOptionViewItem& option, const Torrent&) const;
     39
     40    static QString statusString (const Torrent& tor);
     41    static QString progressString (const Torrent& tor);
     42    static QString shortStatusString (const Torrent& tor);
     43    static QString shortTransferString (const Torrent& tor);
    2944
    3045  protected:
    3146    QStyleOptionProgressBar * myProgressBarStyle;
    3247
    33   protected:
    34     QString statusString (const Torrent& tor) const;
    35     QString progressString (const Torrent& tor) const;
    36     QString shortStatusString (const Torrent& tor) const;
    37     QString shortTransferString (const Torrent& tor) const;
    38 
    39   protected:
    40     QSize margin (const QStyle& style) const;
    41     virtual QSize sizeHint (const QStyleOptionViewItem&, const Torrent&) const;
    42     virtual void setProgressBarPercentDone (const QStyleOptionViewItem& option, const Torrent&) const;
    43     virtual void drawTorrent (QPainter* painter, const QStyleOptionViewItem& option, const Torrent&) const;
    44 
    45   public:
    46     explicit TorrentDelegate (QObject * parent=0);
    47     virtual ~TorrentDelegate ();
    48 
    49     QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
    50     void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
     48    static QColor blueBrush;
     49    static QColor greenBrush;
     50    static QColor silverBrush;
     51    static QColor blueBack;
     52    static QColor greenBack;
     53    static QColor silverBack;
    5154};
    5255
  • trunk/qt/TorrentDelegateMin.h

    r14537 r14539  
    1111#define QTR_TORRENT_DELEGATE_MIN_H
    1212
    13 #include <QSize>
    14 
    1513#include "TorrentDelegate.h"
    16 
    17 class QStyleOptionViewItem;
    18 class QStyle;
    19 class Session;
    20 class Torrent;
    2114
    2215class TorrentDelegateMin: public TorrentDelegate
     
    2417    Q_OBJECT
    2518
     19  public:
     20    explicit TorrentDelegateMin (QObject * parent = nullptr): TorrentDelegate (parent) {}
     21    virtual ~TorrentDelegateMin () {}
     22
    2623  protected:
     24    // TorrentDelegate
    2725    virtual QSize sizeHint (const QStyleOptionViewItem&, const Torrent&) const;
    28     void drawTorrent (QPainter* painter, const QStyleOptionViewItem& option, const Torrent&) const;
    29 
    30   public:
    31     explicit TorrentDelegateMin (QObject * parent=0): TorrentDelegate(parent) {}
    32     virtual ~TorrentDelegateMin () {}
     26    virtual void drawTorrent (QPainter * painter, const QStyleOptionViewItem& option, const Torrent&) const;
    3327};
    3428
  • trunk/qt/TorrentFilter.h

    r14537 r14539  
    1212
    1313#include <QSortFilterProxyModel>
    14 #include <QMetaType>
    15 #include <QVariant>
    1614
    1715class QString;
    18 class QWidget;
    1916
    2017class FilterMode;
     
    2724
    2825  public:
     26    enum TextMode
     27    {
     28      FILTER_BY_NAME,
     29      FILTER_BY_FILES,
     30      FILTER_BY_TRACKER
     31    };
     32
     33  public:
    2934    TorrentFilter (const Prefs& prefs);
    3035    virtual ~TorrentFilter ();
    3136
    32   public:
    33     enum TextMode { FILTER_BY_NAME, FILTER_BY_FILES, FILTER_BY_TRACKER };
    3437    int hiddenRowCount () const;
    3538
    36   private slots:
    37     void refreshPref (int key);
     39    void countTorrentsPerMode (int * setmeCounts) const;
    3840
    3941  protected:
     42    // QSortFilterProxyModel
    4043    virtual bool filterAcceptsRow (int, const QModelIndex&) const;
    4144    virtual bool lessThan (const QModelIndex&, const QModelIndex&) const;
     
    4548    bool trackerFilterAcceptsTorrent (const Torrent * tor, const QString& tracker) const;
    4649
    47   public:
    48     void countTorrentsPerMode (int * setmeCounts) const;
     50  private slots:
     51    void refreshPref (int key);
    4952
    5053  private:
  • trunk/qt/TorrentModel.cc

    r14537 r14539  
    1414#include <libtransmission/variant.h>
    1515
     16#include "Speed.h"
     17#include "Torrent.h"
    1618#include "TorrentDelegate.h"
    1719#include "TorrentModel.h"
  • trunk/qt/TorrentModel.h

    r14537 r14539  
    1616#include <QVector>
    1717
    18 #include "Speed.h"
    19 #include "Torrent.h"
    20 
    2118class Prefs;
     19class Speed;
     20class Torrent;
    2221
    2322extern "C"
     
    3029    Q_OBJECT
    3130
    32   private:
    33     typedef QMap<int,int> id_to_row_t;
    34     typedef QMap<int,Torrent*> id_to_torrent_t;
    35     typedef QVector<Torrent*> torrents_t;
    36     id_to_row_t myIdToRow;
    37     id_to_torrent_t myIdToTorrent;
    38     torrents_t myTorrents;
    39     const Prefs& myPrefs;
     31  public:
     32    enum Role
     33    {
     34      TorrentRole = Qt::UserRole
     35    };
    4036
    4137  public:
     38    TorrentModel (const Prefs& prefs);
     39    virtual ~TorrentModel ();
     40
    4241    void clear ();
    4342    bool hasTorrent (const QString& hashString) const;
    44     virtual int rowCount (const QModelIndex& parent = QModelIndex()) const;
     43
     44    Torrent * getTorrentFromId (int id);
     45    const Torrent * getTorrentFromId (int id) const;
     46
     47    void getTransferSpeed (Speed& uploadSpeed, size_t& uploadPeerCount,
     48                           Speed& downloadSpeed, size_t& downloadPeerCount);
     49
     50    // QAbstractItemModel
     51    virtual int rowCount (const QModelIndex& parent = QModelIndex ()) const;
    4552    virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
    46     enum Role { TorrentRole = Qt::UserRole };
    47 
    48   public:
    49     Torrent* getTorrentFromId (int id);
    50     const Torrent* getTorrentFromId (int id) const;
    51 
    52   private:
    53     void addTorrent (Torrent *);
    54     QSet<int> getIds () const;
    55 
    56   public:
    57     void getTransferSpeed (Speed  & uploadSpeed,
    58                            size_t & uploadPeerCount,
    59                            Speed  & downloadSpeed,
    60                            size_t & downloadPeerCount);
    6153
    6254  signals:
     
    6860    void removeTorrent (int id);
    6961
     62  private:
     63    typedef QMap<int, int> id_to_row_t;
     64    typedef QMap<int, Torrent*> id_to_torrent_t;
     65    typedef QVector<Torrent*> torrents_t;
     66
     67  private:
     68    void addTorrent (Torrent *);
     69    QSet<int> getIds () const;
     70
    7071  private slots:
    7172    void onTorrentChanged (int propertyId);
    7273
    73   public:
    74     TorrentModel (const Prefs& prefs);
    75     virtual ~TorrentModel ();
     74  private:
     75    const Prefs& myPrefs;
     76
     77    id_to_row_t myIdToRow;
     78    id_to_torrent_t myIdToTorrent;
     79    torrents_t myTorrents;
    7680};
    7781
  • trunk/qt/TrackerDelegate.h

    r14537 r14539  
    1212
    1313#include <QItemDelegate>
    14 #include <QSize>
    1514
    16 class QPainter;
    17 class QStyleOptionViewItem;
    1815class QStyle;
    1916
     
    2623
    2724  public:
    28     TrackerDelegate (QObject * parent=0): QItemDelegate(parent), myShowMore(false) {}
     25    TrackerDelegate (QObject * parent = nullptr): QItemDelegate (parent), myShowMore (false) {}
    2926    virtual ~TrackerDelegate () {}
    3027
    31   public:
    32     QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
    33     void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
     28    void setShowMore (bool b);
    3429
    35   public:
    36     void setShowMore (bool b);
     30    // QAbstractItemDelegate
     31    virtual QSize sizeHint (const QStyleOptionViewItem& option, const QModelIndex& index) const;
     32    virtual void paint (QPainter * painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
    3733
    3834  protected:
    3935    QString getText (const TrackerInfo&) const;
    4036    QSize margin (const QStyle& style) const;
    41     virtual QSize sizeHint (const QStyleOptionViewItem&, const TrackerInfo&) const;
    42     void drawTracker (QPainter*, const QStyleOptionViewItem&, const TrackerInfo&) const;
     37
     38    QSize sizeHint (const QStyleOptionViewItem&, const TrackerInfo&) const;
     39    void drawTracker (QPainter *, const QStyleOptionViewItem&, const TrackerInfo&) const;
    4340
    4441  private:
  • trunk/qt/TrackerModel.cc

    r14537 r14539  
    1313
    1414#include "Application.h" // Application
     15#include "TorrentModel.h"
    1516#include "TrackerModel.h"
    1617
  • trunk/qt/TrackerModel.h

    r14537 r14539  
    1616
    1717#include "Torrent.h"
    18 #include "TorrentModel.h"
     18
     19class TorrentModel;
    1920
    2021struct TrackerInfo
    2122{
    22     TrackerStat st;
    23     int torrentId;
     23  TrackerStat st;
     24  int torrentId;
    2425};
     26
    2527Q_DECLARE_METATYPE(TrackerInfo)
    2628
     
    2931    Q_OBJECT
    3032
    31     typedef QVector<TrackerInfo> rows_t;
    32     rows_t myRows;
    33 
    3433  public:
    35     void refresh (const TorrentModel&, const QSet<int>& ids);
    36     int find (int torrentId, const QString& url) const;
    37 
    38   public:
    39     virtual int rowCount (const QModelIndex& parent = QModelIndex()) const;
    40     virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
    41     enum Role { TrackerRole = Qt::UserRole };
     34    enum Role
     35    {
     36      TrackerRole = Qt::UserRole
     37    };
    4238
    4339  public:
    4440    TrackerModel () {}
    4541    virtual ~TrackerModel () {}
     42
     43    void refresh (const TorrentModel&, const QSet<int>& ids);
     44    int find (int torrentId, const QString& url) const;
     45
     46    // QAbstractItemModel
     47    virtual int rowCount (const QModelIndex& parent = QModelIndex ()) const;
     48    virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
     49
     50  private:
     51    typedef QVector<TrackerInfo> rows_t;
     52
     53  private:
     54    rows_t myRows;
    4655};
    4756
  • trunk/qt/TrackerModelFilter.h

    r14537 r14539  
    1313#include <QSortFilterProxyModel>
    1414
    15 class TrackerModelFilter : public QSortFilterProxyModel
     15class TrackerModelFilter: public QSortFilterProxyModel
    1616{
    1717    Q_OBJECT
    1818
    1919  public:
    20     TrackerModelFilter (QObject *parent = 0);
     20    TrackerModelFilter (QObject * parent = nullptr);
    2121
    22   public:
    2322    void setShowBackupTrackers (bool);
    2423    bool showBackupTrackers () const { return myShowBackups; }
    2524
    2625  protected:
    27     bool filterAcceptsRow (int sourceRow, const QModelIndex&sourceParent) const;
     26    // QSortFilterProxyModel
     27    virtual bool filterAcceptsRow (int sourceRow, const QModelIndex& sourceParent) const;
    2828
    2929  private:
  • trunk/qt/Utils.cc

    r14537 r14539  
    1919#include <QFileDialog>
    2020#include <QFileInfo>
     21#include <QIcon>
    2122#include <QInputDialog>
    2223#include <QObject>
  • trunk/qt/Utils.h

    r14537 r14539  
    1313#include <cctype> // isxdigit()
    1414
    15 #include <QIcon>
    16 #include <QObject>
    1715#include <QRect>
    1816#include <QString>
    1917
    20 #include "Speed.h"
     18class QColor;
     19class QIcon;
    2120
    22 class QColor;
    23 
    24 class Utils: public QObject
     21class Utils
    2522{
    26     Q_OBJECT
    27 
    28   public:
    29     Utils () {}
    30     virtual ~Utils () {}
    31 
    3223  public:
    3324    static QIcon guessMimeIcon (const QString& filename);
    3425    // Test if string is UTF-8 or not
    35     static bool isValidUtf8  (const char *s);
     26    static bool isValidUtf8 (const char * s);
    3627
    3728    static QString removeTrailingDirSeparator (const QString& path);
  • trunk/qt/WatchDir.h

    r14537 r14539  
    2525  public:
    2626    WatchDir (const TorrentModel&);
    27     ~WatchDir ();
     27    virtual ~WatchDir ();
    2828
    29   public:
    3029    void setPath (const QString& path, bool isEnabled);
    3130
     31  signals:
     32    void torrentFileAdded (const QString& filename);
     33
    3234  private:
    33     enum { OK, DUPLICATE, ERROR };
     35    enum
     36    {
     37      OK,
     38      DUPLICATE,
     39      ERROR
     40    };
     41
     42  private:
    3443    int metainfoTest (const QString& filename) const;
    35 
    36   signals:
    37     void torrentFileAdded (QString filename);
    3844
    3945  private slots:
     
    4147    void onTimeout ();
    4248
    43   private slots:
    4449    void rescanAllWatchedDirectories ();
    4550
    4651  private:
    4752    const TorrentModel& myModel;
     53
    4854    QSet<QString> myWatchDirFiles;
    4955    QFileSystemWatcher * myWatcher;
Note: See TracChangeset for help on using the changeset viewer.