mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 08:27:24 -06:00
Add case-sensitive & case-insensitive natural sort helper function
Fix helper function not being thread-safe Use QBT_USES_QT5 define
This commit is contained in:
@@ -96,7 +96,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent)
|
||||
|
||||
// Load categories
|
||||
QStringList categories = session->categories();
|
||||
std::sort(categories.begin(), categories.end(), Utils::String::naturalCompare);
|
||||
std::sort(categories.begin(), categories.end(), Utils::String::naturalCompareCaseInsensitive);
|
||||
QString defaultCategory = settings()->loadValue(KEY_DEFAULTCATEGORY).toString();
|
||||
|
||||
if (!defaultCategory.isEmpty())
|
||||
|
||||
@@ -48,7 +48,7 @@ protected:
|
||||
case PeerListDelegate::CLIENT: {
|
||||
QString vL = left.data().toString();
|
||||
QString vR = right.data().toString();
|
||||
return Utils::String::naturalCompare(vL, vR);
|
||||
return Utils::String::naturalCompareCaseSensitive(vL, vR);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ void AutomatedRssDownloader::initCategoryCombobox()
|
||||
{
|
||||
// Load torrent categories
|
||||
QStringList categories = BitTorrent::Session::instance()->categories();
|
||||
std::sort(categories.begin(), categories.end(), Utils::String::naturalCompare);
|
||||
std::sort(categories.begin(), categories.end(), Utils::String::naturalCompareCaseInsensitive);
|
||||
ui->comboCategory->addItems(categories);
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ bool SearchSortModel::lessThan(const QModelIndex &left, const QModelIndex &right
|
||||
case ENGINE_URL: {
|
||||
QString vL = left.data().toString();
|
||||
QString vR = right.data().toString();
|
||||
return Utils::String::naturalCompare(vL, vR);
|
||||
return Utils::String::naturalCompareCaseSensitive(vL, vR);
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
@@ -90,7 +90,7 @@ bool TorrentContentFilterModel::lessThan(const QModelIndex &left, const QModelIn
|
||||
TorrentContentModelItem::ItemType rightType = m_model->itemType(m_model->index(right.row(), 0, right.parent()));
|
||||
|
||||
if (leftType == rightType)
|
||||
return Utils::String::naturalCompare(vL, vR);
|
||||
return Utils::String::naturalCompareCaseSensitive(vL, vR);
|
||||
else if (leftType == TorrentContentModelItem::FolderType && sortOrder() == Qt::AscendingOrder)
|
||||
return true;
|
||||
else
|
||||
|
||||
@@ -239,7 +239,7 @@ void CategoryFiltersList::addItem(const QString &category, bool hasTorrent)
|
||||
Q_ASSERT(count() >= 2);
|
||||
int insPos = count();
|
||||
for (int i = 2; i < count(); ++i) {
|
||||
if (Utils::String::naturalCompare(category, item(i)->text())) {
|
||||
if (Utils::String::naturalCompareCaseSensitive(category, item(i)->text())) {
|
||||
insPos = i;
|
||||
break;
|
||||
}
|
||||
@@ -511,7 +511,7 @@ void TrackerFiltersList::addItem(const QString &tracker, const QString &hash)
|
||||
Q_ASSERT(count() >= 4);
|
||||
int insPos = count();
|
||||
for (int i = 4; i < count(); ++i) {
|
||||
if (Utils::String::naturalCompare(host, item(i)->text())) {
|
||||
if (Utils::String::naturalCompareCaseSensitive(host, item(i)->text())) {
|
||||
insPos = i;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
|
||||
if (!vL.isValid() || !vR.isValid() || (vL == vR))
|
||||
return lowerPositionThan(left, right);
|
||||
|
||||
return Utils::String::naturalCompare(vL.toString(), vR.toString());
|
||||
return Utils::String::naturalCompareCaseSensitive(vL.toString(), vR.toString());
|
||||
}
|
||||
|
||||
case TorrentModel::TR_ADD_DATE:
|
||||
|
||||
@@ -769,7 +769,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
||||
listMenu.addAction(&actionRename);
|
||||
// Category Menu
|
||||
QStringList categories = BitTorrent::Session::instance()->categories();
|
||||
std::sort(categories.begin(), categories.end(), Utils::String::naturalCompare);
|
||||
std::sort(categories.begin(), categories.end(), Utils::String::naturalCompareCaseInsensitive);
|
||||
QList<QAction*> categoryActions;
|
||||
QMenu *categoryMenu = listMenu.addMenu(GuiIconProvider::instance()->getIcon("view-categories"), tr("Category"));
|
||||
categoryActions << categoryMenu->addAction(GuiIconProvider::instance()->getIcon("list-add"), tr("New...", "New category..."));
|
||||
|
||||
Reference in New Issue
Block a user