Browse Source

Coding style of whole trackerlist.h and a little in trackerlist.cpp

adaptive-webui-19844
thalieht 8 years ago
parent
commit
ce77ebdfe1
  1. 52
      src/gui/properties/trackerlist.cpp
  2. 79
      src/gui/properties/trackerlist.h

52
src/gui/properties/trackerlist.cpp

@ -30,31 +30,34 @@
#include "trackerlist.h" #include "trackerlist.h"
#include <QApplication>
#include <QTreeWidgetItem>
#include <QStringList>
#include <QMenu>
#include <QHash>
#include <QAction> #include <QAction>
#include <QApplication>
#include <QColor> #include <QColor>
#include <QDebug> #include <QDebug>
#include <QUrl> #include <QHash>
#include <QHeaderView>
#include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QStringList>
#include <QTableView> #include <QTableView>
#include <QHeaderView> #include <QTreeWidgetItem>
#include <QUrl>
#include "base/bittorrent/peerinfo.h"
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
#include "base/bittorrent/torrenthandle.h" #include "base/bittorrent/torrenthandle.h"
#include "base/bittorrent/peerinfo.h"
#include "base/bittorrent/trackerentry.h" #include "base/bittorrent/trackerentry.h"
#include "base/preferences.h" #include "base/preferences.h"
#include "base/utils/misc.h" #include "base/utils/misc.h"
#include "autoexpandabledialog.h"
#include "guiiconprovider.h"
#include "propertieswidget.h" #include "propertieswidget.h"
#include "trackersadditiondlg.h" #include "trackersadditiondlg.h"
#include "guiiconprovider.h"
#include "autoexpandabledialog.h"
TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), properties(properties) { TrackerList::TrackerList(PropertiesWidget *properties)
: QTreeWidget()
, properties(properties)
{
// Graphical settings // Graphical settings
setRootIsDecorated(false); setRootIsDecorated(false);
setAllColumnsShowFocus(true); setAllColumnsShowFocus(true);
@ -98,11 +101,12 @@ TrackerList::TrackerList(PropertiesWidget *properties): QTreeWidget(), propertie
loadSettings(); loadSettings();
} }
TrackerList::~TrackerList() { TrackerList::~TrackerList()
delete editHotkey; {
delete deleteHotkey; delete editHotkey;
delete copyHotkey; delete deleteHotkey;
saveSettings(); delete copyHotkey;
saveSettings();
} }
QList<QTreeWidgetItem*> TrackerList::getSelectedTrackerItems() const { QList<QTreeWidgetItem*> TrackerList::getSelectedTrackerItems() const {
@ -524,13 +528,15 @@ void TrackerList::showTrackerListMenu(QPoint) {
} }
} }
void TrackerList::loadSettings() { void TrackerList::loadSettings()
if (!header()->restoreState(Preferences::instance()->getPropTrackerListState())) { {
setColumnWidth(0, 30); if (!header()->restoreState(Preferences::instance()->getPropTrackerListState())) {
setColumnWidth(1, 300); setColumnWidth(0, 30);
} setColumnWidth(1, 300);
}
} }
void TrackerList::saveSettings() const { void TrackerList::saveSettings() const
Preferences::instance()->setPropTrackerListState(header()->saveState()); {
Preferences::instance()->setPropTrackerListState(header()->saveState());
} }

79
src/gui/properties/trackerlist.h

@ -31,14 +31,13 @@
#ifndef TRACKERLIST_H #ifndef TRACKERLIST_H
#define TRACKERLIST_H #define TRACKERLIST_H
#include <QClipboard>
#include <QList>
#include <QShortcut> #include <QShortcut>
#include <QTreeWidget> #include <QTreeWidget>
#include <QList>
#include <QClipboard>
#include "propertieswidget.h" #include "propertieswidget.h"
enum TrackerListColumn {COL_TIER, COL_URL, COL_STATUS, COL_RECEIVED, COL_SEEDS, COL_PEERS, COL_DOWNLOADED, COL_MSG};
#define NB_STICKY_ITEM 3 #define NB_STICKY_ITEM 3
namespace BitTorrent namespace BitTorrent
@ -46,45 +45,57 @@ namespace BitTorrent
class TorrentHandle; class TorrentHandle;
} }
class TrackerList: public QTreeWidget { class TrackerList: public QTreeWidget
Q_OBJECT {
Q_DISABLE_COPY(TrackerList) Q_OBJECT
Q_DISABLE_COPY(TrackerList)
private:
PropertiesWidget *properties;
QHash<QString, QTreeWidgetItem*> tracker_items;
QTreeWidgetItem* dht_item;
QTreeWidgetItem* pex_item;
QTreeWidgetItem* lsd_item;
QShortcut *editHotkey;
QShortcut *deleteHotkey;
QShortcut *copyHotkey;
public: public:
TrackerList(PropertiesWidget *properties); enum TrackerListColumn
~TrackerList(); {
COL_TIER,
COL_URL,
COL_STATUS,
COL_RECEIVED,
COL_SEEDS,
COL_PEERS,
COL_DOWNLOADED,
COL_MSG
};
protected: TrackerList(PropertiesWidget *properties);
QList<QTreeWidgetItem*> getSelectedTrackerItems() const; ~TrackerList();
public slots: public slots:
void setRowColor(int row, QColor color); void setRowColor(int row, QColor color);
void moveSelectionUp(); void moveSelectionUp();
void moveSelectionDown(); void moveSelectionDown();
void clear(); void clear();
void loadStickyItems(BitTorrent::TorrentHandle *const torrent); void loadStickyItems(BitTorrent::TorrentHandle *const torrent);
void loadTrackers(); void loadTrackers();
void askForTrackers(); void askForTrackers();
void copyTrackerUrl(); void copyTrackerUrl();
void reannounceSelected(); void reannounceSelected();
void deleteSelectedTrackers(); void deleteSelectedTrackers();
void editSelectedTracker(); void editSelectedTracker();
void showTrackerListMenu(QPoint); void showTrackerListMenu(QPoint);
void loadSettings(); void loadSettings();
void saveSettings() const; void saveSettings() const;
protected:
QList<QTreeWidgetItem *> getSelectedTrackerItems() const;
private:
PropertiesWidget *properties;
QHash<QString, QTreeWidgetItem *> tracker_items;
QTreeWidgetItem *dht_item;
QTreeWidgetItem *pex_item;
QTreeWidgetItem *lsd_item;
QShortcut *editHotkey;
QShortcut *deleteHotkey;
QShortcut *copyHotkey;
}; };
#endif // TRACKERLIST_H #endif // TRACKERLIST_H

Loading…
Cancel
Save