Browse Source

- Fix crash when deleting a label

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
78ba99778a
  1. 2
      src/feeddownloader.h
  2. 14
      src/transferlistfilterswidget.h
  3. 3
      src/transferlistwidget.cpp

2
src/feeddownloader.h

@ -68,7 +68,7 @@ public: @@ -68,7 +68,7 @@ public:
foreach(const QString& token, match_tokens) {
if(token.isEmpty() || token == "")
continue;
qDebug("Token: %s", token.toLocal8Bit().data());
//qDebug("Token: %s", token.toLocal8Bit().data());
QRegExp reg(token, Qt::CaseInsensitive, QRegExp::Wildcard);
//reg.setMinimal(false);
if(reg.indexIn(s) < 0) return false;

14
src/transferlistfilterswidget.h

@ -278,11 +278,13 @@ protected slots: @@ -278,11 +278,13 @@ protected slots:
Q_ASSERT(row > 1);
QString label = customLabels.takeAt(row - 2);
labelCounters.removeAt(row-2);
labelFilters->removeItemWidget(labelFilters->selectedItems().first());
transferList->removeLabelFromRows(label);
// Select first label
labelFilters->setCurrentItem(labelFilters->item(0));
labelFilters->selectionModel()->select(labelFilters->model()->index(0,0), QItemSelectionModel::Select);
applyLabelFilter(0);
// Un display filter
delete labelFilters->takeItem(row);
}
void applyLabelFilter(int row) {
@ -302,10 +304,12 @@ protected slots: @@ -302,10 +304,12 @@ protected slots:
qDebug("Torrent label changed from %s to %s", old_label.toLocal8Bit().data(), new_label.toLocal8Bit().data());
if(!old_label.isEmpty()) {
int i = customLabels.indexOf(old_label);
int new_count = labelCounters[i]-1;
Q_ASSERT(new_count >= 0);
labelCounters.replace(i, new_count);
labelFilters->item(i+2)->setText(old_label + " ("+ QString::number(new_count) +")");
if(i >= 0) {
int new_count = labelCounters[i]-1;
Q_ASSERT(new_count >= 0);
labelCounters.replace(i, new_count);
labelFilters->item(i+2)->setText(old_label + " ("+ QString::number(new_count) +")");
}
--nb_labeled;
}
if(!new_label.isEmpty()) {

3
src/transferlistwidget.cpp

@ -899,9 +899,10 @@ void TransferListWidget::setSelectionLabel(QString label) { @@ -899,9 +899,10 @@ void TransferListWidget::setSelectionLabel(QString label) {
void TransferListWidget::removeLabelFromRows(QString label) {
for(int i=0; i<listModel->rowCount(); ++i) {
if(label == listModel->data(listModel->index(i, TR_LABEL), Qt::DisplayRole))
if(listModel->data(listModel->index(i, TR_LABEL)) == label) {
listModel->setData(listModel->index(i, TR_LABEL), "", Qt::DisplayRole);
emit torrentChangedLabel(label, "");
}
}
}

Loading…
Cancel
Save