Browse Source

- Added buttons to change trackers priority (libtorrent v0.14 only)

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
27e980de28
  1. 10
      src/propertieswidget.cpp
  2. 74
      src/trackerlist.h
  3. 129
      src/ui/propertieswidget.ui

10
src/propertieswidget.cpp

@ -99,7 +99,14 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi @@ -99,7 +99,14 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi
ProgressHLayout_2->insertWidget(1, pieces_availability);
// Tracker list
trackerList = new TrackerList(this);
verticalLayout_trackers->addWidget(trackerList);
#ifdef LIBTORRENT_0_15
trackerUpButton->setVisible(false);
trackerDownButton->setVisible(false);
#else
connect(trackerUpButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionUp()));
connect(trackerDownButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionDown()));
#endif
horizontalLayout_trackers->insertWidget(0, trackerList);
// Peers list
peersList = new PeerListWidget(this);
peerpage_layout->addWidget(peersList);
@ -119,7 +126,6 @@ PropertiesWidget::~PropertiesWidget() { @@ -119,7 +126,6 @@ PropertiesWidget::~PropertiesWidget() {
delete PropDelegate;
}
void PropertiesWidget::showPiecesAvailability(bool show) {
avail_pieces_lbl->setVisible(show);
pieces_availability->setVisible(show);

74
src/trackerlist.h

@ -112,6 +112,80 @@ public slots: @@ -112,6 +112,80 @@ public slots:
}
}
#ifndef LIBTORRENT_0_15
void moveSelectionUp() {
QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid()) {
clear();
return;
}
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
if(selected_items.isEmpty()) return;
bool change = false;
foreach(QTreeWidgetItem *item, selected_items){
int index = indexOfTopLevelItem(item);
if(index > NB_STICKY_ITEM) {
insertTopLevelItem(index-1, takeTopLevelItem(index));
change = true;
}
}
if(!change) return;
// Restore selection
QItemSelectionModel *selection = selectionModel();
foreach(QTreeWidgetItem *item, selected_items) {
selection->select(indexFromItem(item), QItemSelectionModel::Rows|QItemSelectionModel::Select);
}
setSelectionModel(selection);
// Update torrent trackers
std::vector<announce_entry> trackers;
for(int i=NB_STICKY_ITEM; i<topLevelItemCount(); ++i) {
QString tracker_url = topLevelItem(i)->data(COL_URL, Qt::DisplayRole).toString();
announce_entry e(tracker_url.toStdString());
e.tier = i-NB_STICKY_ITEM;
trackers.push_back(e);
}
h.replace_trackers(trackers);
// Reannounce
h.force_reannounce();
}
void moveSelectionDown() {
QTorrentHandle h = properties->getCurrentTorrent();
if(!h.is_valid()) {
clear();
return;
}
QList<QTreeWidgetItem *> selected_items = getSelectedTrackerItems();
if(selected_items.isEmpty()) return;
bool change = false;
for(int i=selectedItems().length()-1; i>= 0; --i) {
int index = indexOfTopLevelItem(selected_items.at(i));
if(index < topLevelItemCount()-1) {
insertTopLevelItem(index+1, takeTopLevelItem(index));
change = true;
}
}
if(!change) return;
// Restore selection
QItemSelectionModel *selection = selectionModel();
foreach(QTreeWidgetItem *item, selected_items) {
selection->select(indexFromItem(item), QItemSelectionModel::Rows|QItemSelectionModel::Select);
}
setSelectionModel(selection);
// Update torrent trackers
std::vector<announce_entry> trackers;
for(int i=NB_STICKY_ITEM; i<topLevelItemCount(); ++i) {
QString tracker_url = topLevelItem(i)->data(COL_URL, Qt::DisplayRole).toString();
announce_entry e(tracker_url.toStdString());
e.tier = i-NB_STICKY_ITEM;
trackers.push_back(e);
}
h.replace_trackers(trackers);
// Reannounce
h.force_reannounce();
}
#endif
void clear() {
qDeleteAll(tracker_items.values());
tracker_items.clear();

129
src/ui/propertieswidget.ui

@ -53,9 +53,9 @@ @@ -53,9 +53,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-81</y>
<y>0</y>
<width>518</width>
<height>371</height>
<height>359</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
@ -621,7 +621,112 @@ p, li { white-space: pre-wrap; } @@ -621,7 +621,112 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
<widget class="QWidget" name="page_trackers">
<layout class="QVBoxLayout" name="verticalLayout_trackers"/>
<layout class="QHBoxLayout" name="horizontalLayout_trackers">
<item>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="trackerUpButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>31</horstretch>
<verstretch>27</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>31</width>
<height>27</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>31</width>
<height>27</height>
</size>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/Icons/uparrow.png</normaloff>:/Icons/uparrow.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>28</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="trackerDownButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>31</horstretch>
<verstretch>27</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>31</width>
<height>27</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>31</width>
<height>27</height>
</size>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/Icons/downarrow.png</normaloff>:/Icons/downarrow.png</iconset>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_5">
<layout class="QVBoxLayout" name="peerpage_layout"/>
@ -664,7 +769,7 @@ p, li { white-space: pre-wrap; } @@ -664,7 +769,7 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset>
<iconset resource="../icons.qrc">
<normaloff>:/Icons/oxygen/list-remove.png</normaloff>:/Icons/oxygen/list-remove.png</iconset>
</property>
</widget>
@ -681,7 +786,7 @@ p, li { white-space: pre-wrap; } @@ -681,7 +786,7 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset>
<iconset resource="../icons.qrc">
<normaloff>:/Icons/oxygen/list-add.png</normaloff>:/Icons/oxygen/list-add.png</iconset>
</property>
</widget>
@ -796,7 +901,7 @@ p, li { white-space: pre-wrap; } @@ -796,7 +901,7 @@ p, li { white-space: pre-wrap; }
<string>General</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../icons.qrc">
<normaloff>:/Icons/oxygen/help-about.png</normaloff>:/Icons/oxygen/help-about.png</iconset>
</property>
<property name="iconSize">
@ -813,7 +918,7 @@ p, li { white-space: pre-wrap; } @@ -813,7 +918,7 @@ p, li { white-space: pre-wrap; }
<string>Trackers</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../icons.qrc">
<normaloff>:/Icons/oxygen/network-server.png</normaloff>:/Icons/oxygen/network-server.png</iconset>
</property>
<property name="iconSize">
@ -836,7 +941,7 @@ p, li { white-space: pre-wrap; } @@ -836,7 +941,7 @@ p, li { white-space: pre-wrap; }
<string>Peers</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../icons.qrc">
<normaloff>:/Icons/oxygen/peer.png</normaloff>:/Icons/oxygen/peer.png</iconset>
</property>
<property name="iconSize">
@ -853,7 +958,7 @@ p, li { white-space: pre-wrap; } @@ -853,7 +958,7 @@ p, li { white-space: pre-wrap; }
<string>URL seeds</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../icons.qrc">
<normaloff>:/Icons/oxygen/urlseed.png</normaloff>:/Icons/oxygen/urlseed.png</iconset>
</property>
<property name="iconSize">
@ -870,7 +975,7 @@ p, li { white-space: pre-wrap; } @@ -870,7 +975,7 @@ p, li { white-space: pre-wrap; }
<string>Files</string>
</property>
<property name="icon">
<iconset>
<iconset resource="../icons.qrc">
<normaloff>:/Icons/oxygen/folder.png</normaloff>:/Icons/oxygen/folder.png</iconset>
</property>
<property name="iconSize">
@ -898,6 +1003,8 @@ p, li { white-space: pre-wrap; } @@ -898,6 +1003,8 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../icons.qrc"/>
</resources>
<connections/>
</ui>

Loading…
Cancel
Save