Browse Source

Fix "Select All/None" buttons in torrent properties

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
dbfef8665b
  1. 27
      src/propertieswidget.cpp
  2. 2
      src/propertieswidget.h
  3. 4
      src/torrentfilesmodel.h

27
src/propertieswidget.cpp

@ -83,8 +83,8 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi @@ -83,8 +83,8 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi
// SIGNAL/SLOTS
connect(filesList, SIGNAL(clicked(const QModelIndex&)), filesList, SLOT(edit(const QModelIndex&)));
connect(selectAllButton, SIGNAL(clicked()), PropListModel, SLOT(selectAll()));
connect(selectNoneButton, SIGNAL(clicked()), PropListModel, SLOT(selectNone()));
connect(selectAllButton, SIGNAL(clicked()), this, SLOT(selectAllFiles()));
connect(selectNoneButton, SIGNAL(clicked()), this, SLOT(selectNoneFiles()));
connect(filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&)));
connect(filesList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openDoubleClickedFile(QModelIndex)));
connect(PropListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
@ -395,6 +395,7 @@ void PropertiesWidget::loadDynamicData() { @@ -395,6 +395,7 @@ void PropertiesWidget::loadDynamicData() {
// Expand first item if possible
filesList->expand(PropListModel->index(0, 0));
}
qDebug("Updating priorities in files tab");
std::vector<size_type> fp;
h.file_progress(fp);
PropListModel->updateFilesPriorities(h.file_priorities());
@ -404,6 +405,28 @@ void PropertiesWidget::loadDynamicData() { @@ -404,6 +405,28 @@ void PropertiesWidget::loadDynamicData() {
} catch(invalid_handle e) {}
}
void PropertiesWidget::selectAllFiles() {
// Update torrent properties
std::vector<int> prio = h.file_priorities();
for(std::vector<int>::iterator it = prio.begin(); it != prio.end(); it++) {
if(*it == IGNORED) {
*it = NORMAL;
}
}
h.prioritize_files(prio);
// Update model
PropListModel->selectAll();
}
void PropertiesWidget::selectNoneFiles() {
// Update torrent properties
std::vector<int> prio;
prio.assign(h.num_files(), IGNORED);
h.prioritize_files(prio);
// Update model
PropListModel->selectNone();
}
void PropertiesWidget::loadUrlSeeds(){
listWebSeeds->clear();
qDebug("Loading URL seeds");

2
src/propertieswidget.h

@ -101,6 +101,8 @@ protected slots: @@ -101,6 +101,8 @@ protected slots:
void showPiecesAvailability(bool show);
void updateSavePath(QTorrentHandle& h);
void renameSelectedFile();
void selectAllFiles();
void selectNoneFiles();
public slots:
void loadDynamicData();

4
src/torrentfilesmodel.h

@ -558,7 +558,9 @@ public: @@ -558,7 +558,9 @@ public:
public slots:
void selectAll() {
for(int i=0; i<rootItem->childCount(); ++i) {
rootItem->child(i)->setPriority(NORMAL);
TreeItem *child = rootItem->child(i);
if(child->getPriority() == IGNORED)
child->setPriority(NORMAL);
}
emit layoutChanged();
}

Loading…
Cancel
Save