Browse Source

- Fix torrent deletion

- Fix extended selection in transfer list
- Disable and clear torrent properties when necessary
- Set correct visual attributes to transfer list
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
92a9d04568
  1. 30
      src/TransferListWidget.cpp
  2. 32
      src/propertieswidget.cpp
  3. 1
      src/propertieswidget.h

30
src/TransferListWidget.cpp

@ -79,6 +79,10 @@ TransferListWidget::TransferListWidget(QWidget *parent, bittorrent *_BTSession):
setRootIsDecorated(false); setRootIsDecorated(false);
setAllColumnsShowFocus(true); setAllColumnsShowFocus(true);
setSortingEnabled(true); setSortingEnabled(true);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setItemsExpandable(false);
setAutoScroll(true);
hideColumn(PRIORITY); hideColumn(PRIORITY);
hideColumn(HASH); hideColumn(HASH);
hideColumn(STATUS); hideColumn(STATUS);
@ -139,6 +143,9 @@ void TransferListWidget::addTorrent(QTorrentHandle& h) {
listModel->setData(listModel->index(row, STATUS), DOWNLOADING); listModel->setData(listModel->index(row, STATUS), DOWNLOADING);
//setRowColor(row, QString::fromUtf8("grey")); //setRowColor(row, QString::fromUtf8("grey"));
} }
// Select first torrent to be added
if(listModel->rowCount() == 1)
selectionModel()->setCurrentIndex(proxyModel->index(row, NAME), QItemSelectionModel::SelectCurrent|QItemSelectionModel::Rows);
} catch(invalid_handle e) { } catch(invalid_handle e) {
// Remove added torrent // Remove added torrent
listModel->removeRow(row); listModel->removeRow(row);
@ -403,11 +410,13 @@ void TransferListWidget::deleteSelectedTorrents() {
tr("&Yes"), tr("&No"), tr("&Yes"), tr("&No"),
QString(), 0, 1); QString(), 0, 1);
if(ret) return; if(ret) return;
QStringList hashes;
foreach(const QModelIndex &index, selectedIndexes) { foreach(const QModelIndex &index, selectedIndexes) {
// Get the file hash // Get the file hash
int row = proxyModel->mapToSource(index).row(); hashes << getHashFromRow(proxyModel->mapToSource(index).row());
QString hash = getHashFromRow(row); }
deleteTorrent(row); foreach(const QString &hash, hashes) {
deleteTorrent(getRowFromHash(hash));
BTSession->deleteTorrent(hash, false); BTSession->deleteTorrent(hash, false);
} }
} }
@ -423,11 +432,13 @@ void TransferListWidget::deletePermSelectedTorrents() {
tr("&Yes"), tr("&No"), tr("&Yes"), tr("&No"),
QString(), 0, 1); QString(), 0, 1);
if(ret) return; if(ret) return;
QStringList hashes;
foreach(const QModelIndex &index, selectedIndexes) { foreach(const QModelIndex &index, selectedIndexes) {
// Get the file hash // Get the file hash
int row = proxyModel->mapToSource(index).row(); hashes << getHashFromRow(proxyModel->mapToSource(index).row());
QString hash = getHashFromRow(row); }
deleteTorrent(row); foreach(const QString &hash, hashes) {
deleteTorrent(getRowFromHash(hash));
BTSession->deleteTorrent(hash, true); BTSession->deleteTorrent(hash, true);
} }
} }
@ -790,8 +801,11 @@ void TransferListWidget::loadLastSortedColumn() {
} }
void TransferListWidget::currentChanged(const QModelIndex& current, const QModelIndex&) { void TransferListWidget::currentChanged(const QModelIndex& current, const QModelIndex&) {
int row = proxyModel->mapToSource(current).row(); QTorrentHandle h;
QTorrentHandle h = BTSession->getTorrentHandle(getHashFromRow(row)); if(current.isValid()) {
int row = proxyModel->mapToSource(current).row();
h = BTSession->getTorrentHandle(getHashFromRow(row));
}
emit currentTorrentChanged(h); emit currentTorrentChanged(h);
} }

32
src/propertieswidget.cpp

@ -46,7 +46,13 @@
PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transferList, bittorrent* BTSession): QWidget(parent), transferList(transferList), BTSession(BTSession) { PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transferList, bittorrent* BTSession): QWidget(parent), transferList(transferList), BTSession(BTSession) {
setupUi(this); setupUi(this);
state = VISIBLE; state = VISIBLE;
reduce(); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
if(!settings.value("TorrentProperties/Visible", false).toBool()) {
reduce();
} else {
main_infos_button->setStyleSheet(SELECTED_BUTTON_CSS);
setEnabled(false);
}
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &))); connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &)));
connect(incrementalDownload, SIGNAL(stateChanged(int)), this, SLOT(setIncrementalDownload(int))); connect(incrementalDownload, SIGNAL(stateChanged(int)), this, SLOT(setIncrementalDownload(int)));
@ -64,6 +70,8 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transfer
} }
PropertiesWidget::~PropertiesWidget() { PropertiesWidget::~PropertiesWidget() {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
settings.setValue("TorrentProperties/Visible", state==VISIBLE);
delete refreshTimer; delete refreshTimer;
if(progressBarUpdater) if(progressBarUpdater)
delete progressBarUpdater; delete progressBarUpdater;
@ -85,9 +93,29 @@ void PropertiesWidget::slide() {
} }
} }
void PropertiesWidget::clear() {
save_path->clear();
creator->clear();
hash_lbl->clear();
comment_lbl->clear();
incrementalDownload->setChecked(false);
trackersURLS->clear();
trackerURL->clear();
progressBar->setProgress(QRealArray());
failed->clear();
upTotal->clear();
dlTotal->clear();
shareRatio->clear();
setEnabled(false);
}
void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) { void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
h = _h; h = _h;
if(!h.is_valid()) return; if(!h.is_valid()) {
clear();
return;
}
setEnabled(true);
if(progressBarUpdater) if(progressBarUpdater)
delete progressBarUpdater; delete progressBarUpdater;
progressBarUpdater = 0; progressBarUpdater = 0;

1
src/propertieswidget.h

@ -74,6 +74,7 @@ protected slots:
public slots: public slots:
void reduce(); void reduce();
void slide(); void slide();
void clear();
public: public:
PropertiesWidget(QWidget *parent, TransferListWidget *transferList, bittorrent* BTSession); PropertiesWidget(QWidget *parent, TransferListWidget *transferList, bittorrent* BTSession);

Loading…
Cancel
Save