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. 6
      src/transferlistfilterswidget.h
  3. 3
      src/transferlistwidget.cpp

2
src/feeddownloader.h

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

6
src/transferlistfilterswidget.h

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

3
src/transferlistwidget.cpp

@ -899,10 +899,11 @@ void TransferListWidget::setSelectionLabel(QString label) {
void TransferListWidget::removeLabelFromRows(QString label) { void TransferListWidget::removeLabelFromRows(QString label) {
for(int i=0; i<listModel->rowCount(); ++i) { 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); listModel->setData(listModel->index(i, TR_LABEL), "", Qt::DisplayRole);
emit torrentChangedLabel(label, ""); emit torrentChangedLabel(label, "");
} }
}
} }
void TransferListWidget::displayListMenu(const QPoint&) { void TransferListWidget::displayListMenu(const QPoint&) {

Loading…
Cancel
Save