1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-25 14:04:23 +00:00

- Fix crash on start introduced in last commit

This commit is contained in:
Christophe Dumez 2010-01-03 18:42:16 +00:00
parent 3008222b92
commit af5c1096b5

View File

@ -174,11 +174,6 @@ public:
QListWidgetItem *noLabel = new QListWidgetItem(labelFilters); QListWidgetItem *noLabel = new QListWidgetItem(labelFilters);
noLabel->setData(Qt::DisplayRole, tr("Unlabeled") + " (0)"); noLabel->setData(Qt::DisplayRole, tr("Unlabeled") + " (0)");
noLabel->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder.png")); noLabel->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder.png"));
foreach(const QString& label, customLabels) {
QListWidgetItem *newLabel = new QListWidgetItem(labelFilters);
newLabel->setText(label + " (0)");
newLabel->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder.png"));
}
// Load settings // Load settings
loadSettings(); loadSettings();
@ -217,6 +212,11 @@ public:
for(int i=0; i<customLabels.size(); ++i) { for(int i=0; i<customLabels.size(); ++i) {
labelCounters << 0; labelCounters << 0;
} }
foreach(const QString& label, customLabels) {
QListWidgetItem *newLabel = new QListWidgetItem(labelFilters);
newLabel->setText(label + " (0)");
newLabel->setData(Qt::DecorationRole, QIcon(":/Icons/oxygen/folder.png"));
}
labelFilters->setCurrentRow(settings.value("selectedLabelIndex", 0).toInt()); labelFilters->setCurrentRow(settings.value("selectedLabelIndex", 0).toInt());
//labelFilters->selectionModel()->select(labelFilters->model()->index(0,0), QItemSelectionModel::Select); //labelFilters->selectionModel()->select(labelFilters->model()->index(0,0), QItemSelectionModel::Select);
} }
@ -339,8 +339,10 @@ protected slots:
} }
// Update label counter // Update label counter
int i = customLabels.indexOf(label); int i = customLabels.indexOf(label);
Q_ASSERT(i >= 0);
int new_count = labelCounters[i]+1; int new_count = labelCounters[i]+1;
labelCounters.replace(i, new_count); labelCounters.replace(i, new_count);
Q_ASSERT(labelFilters->item(i+2));
labelFilters->item(i+2)->setText(label + " ("+ QString::number(new_count) +")"); labelFilters->item(i+2)->setText(label + " ("+ QString::number(new_count) +")");
++nb_labeled; ++nb_labeled;
} }