mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Merge pull request #2504 from ngosang/remove_empty_labels
New feature: Remove empty labels
This commit is contained in:
commit
99cc29c18e
@ -295,10 +295,13 @@ void TransferListFiltersWidget::addLabel(QString& label) {
|
|||||||
|
|
||||||
void TransferListFiltersWidget::showLabelMenu(QPoint) {
|
void TransferListFiltersWidget::showLabelMenu(QPoint) {
|
||||||
QMenu labelMenu(labelFilters);
|
QMenu labelMenu(labelFilters);
|
||||||
|
QAction *addAct = labelMenu.addAction(IconProvider::instance()->getIcon("list-add"), tr("Add label..."));
|
||||||
QAction *removeAct = 0;
|
QAction *removeAct = 0;
|
||||||
|
QAction *removeEmptyAct = 0;
|
||||||
if (!labelFilters->selectedItems().empty() && labelFilters->row(labelFilters->selectedItems().first()) > 1)
|
if (!labelFilters->selectedItems().empty() && labelFilters->row(labelFilters->selectedItems().first()) > 1)
|
||||||
removeAct = labelMenu.addAction(IconProvider::instance()->getIcon("list-remove"), tr("Remove label"));
|
removeAct = labelMenu.addAction(IconProvider::instance()->getIcon("list-remove"), tr("Remove label"));
|
||||||
QAction *addAct = labelMenu.addAction(IconProvider::instance()->getIcon("list-add"), tr("Add label..."));
|
else
|
||||||
|
removeEmptyAct = labelMenu.addAction(IconProvider::instance()->getIcon("list-remove"), tr("Remove empty labels"));
|
||||||
labelMenu.addSeparator();
|
labelMenu.addSeparator();
|
||||||
QAction *startAct = labelMenu.addAction(IconProvider::instance()->getIcon("media-playback-start"), tr("Resume torrents"));
|
QAction *startAct = labelMenu.addAction(IconProvider::instance()->getIcon("media-playback-start"), tr("Resume torrents"));
|
||||||
QAction *pauseAct = labelMenu.addAction(IconProvider::instance()->getIcon("media-playback-pause"), tr("Pause torrents"));
|
QAction *pauseAct = labelMenu.addAction(IconProvider::instance()->getIcon("media-playback-pause"), tr("Pause torrents"));
|
||||||
@ -310,6 +313,10 @@ void TransferListFiltersWidget::showLabelMenu(QPoint) {
|
|||||||
removeSelectedLabel();
|
removeSelectedLabel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (act == removeEmptyAct) {
|
||||||
|
removeEmptyLabels();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (act == deleteTorrentsAct) {
|
if (act == deleteTorrentsAct) {
|
||||||
transferList->deleteVisibleTorrents();
|
transferList->deleteVisibleTorrents();
|
||||||
return;
|
return;
|
||||||
@ -360,6 +367,20 @@ void TransferListFiltersWidget::removeSelectedLabel() {
|
|||||||
Preferences::instance()->removeTorrentLabel(label);
|
Preferences::instance()->removeTorrentLabel(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransferListFiltersWidget::removeEmptyLabels() {
|
||||||
|
QStringList emptyLabels;
|
||||||
|
QHash<QString, int>::const_iterator i;
|
||||||
|
for (i = customLabels.begin(); i != customLabels.end(); ++i) {
|
||||||
|
if (i.value() == 0)
|
||||||
|
emptyLabels << i.key();
|
||||||
|
}
|
||||||
|
foreach (const QString &label, emptyLabels) {
|
||||||
|
customLabels.remove(label);
|
||||||
|
delete labelFilters->takeItem(labelFilters->rowFromLabel(label));
|
||||||
|
Preferences::instance()->removeTorrentLabel(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TransferListFiltersWidget::applyLabelFilter(int row) {
|
void TransferListFiltersWidget::applyLabelFilter(int row) {
|
||||||
switch(row) {
|
switch(row) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -108,6 +108,7 @@ protected slots:
|
|||||||
void addLabel(QString& label);
|
void addLabel(QString& label);
|
||||||
void showLabelMenu(QPoint);
|
void showLabelMenu(QPoint);
|
||||||
void removeSelectedLabel();
|
void removeSelectedLabel();
|
||||||
|
void removeEmptyLabels();
|
||||||
void applyLabelFilter(int row);
|
void applyLabelFilter(int row);
|
||||||
void torrentChangedLabel(TorrentModelItem *torrentItem, QString old_label, QString new_label);
|
void torrentChangedLabel(TorrentModelItem *torrentItem, QString old_label, QString new_label);
|
||||||
void handleNewTorrent(TorrentModelItem* torrentItem);
|
void handleNewTorrent(TorrentModelItem* torrentItem);
|
||||||
|
Loading…
Reference in New Issue
Block a user