Skip to content

Commit 113aa2d

Browse files
committed
Uses of std::set replaced with unordered_set
1 parent 2b2be63 commit 113aa2d

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

qt-app/qt-app.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TEMPLATE = app
22
TARGET = FileCommander
33

4-
QT = core gui widgets network
4+
QT = core gui widgets network testlib
55
lessThan(QT_MAJOR_VERSION, 6) {
66
win*:QT += winextras
77
}

qt-app/src/panel/cpanelwidget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ DISABLE_COMPILER_WARNINGS
3333
RESTORE_COMPILER_WARNINGS
3434

3535
#include <assert.h>
36-
#include <set>
36+
#include <unordered_set>
3737

3838
CPanelWidget::CPanelWidget(QWidget *parent) noexcept :
3939
QWidget(parent),
@@ -142,7 +142,7 @@ void CPanelWidget::setPanelPosition(Panel p)
142142

143143
_model = new(std::nothrow) CFileListModel(ui->_list, this);
144144
_model->setPanelPosition(p);
145-
assert_r(connect(_model, &CFileListModel::itemEdited, this, &CPanelWidget::itemNameEdited));
145+
assert_r(connect(_model, &CFileListModel::itemEdited, this, &CPanelWidget::renameItem));
146146

147147
_sortModel = new(std::nothrow) CFileListSortFilterProxyModel(this);
148148
_sortModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
@@ -282,7 +282,7 @@ void CPanelWidget::fillFromPanel(const CPanel &panel, FileListRefreshCause opera
282282
{
283283
const auto itemList = panel.list();
284284
const auto previousSelection = selectedItemsHashes(true);
285-
std::set<qulonglong> selectedItemsHashes; // For fast search
285+
std::unordered_set<qulonglong> selectedItemsHashes; // For fast search
286286
for (const auto slectedItemHash: previousSelection)
287287
selectedItemsHashes.insert(slectedItemHash);
288288

@@ -441,7 +441,7 @@ void CPanelWidget::setCursorToItem(const QString& folder, qulonglong currentItem
441441
_selectionModel->setCurrentIndex(newCurrentIndex, QItemSelectionModel::Current | QItemSelectionModel::Rows);
442442
}
443443

444-
void CPanelWidget::itemNameEdited(qulonglong hash, QString newName)
444+
void CPanelWidget::renameItem(qulonglong hash, QString newName)
445445
{
446446
CFileSystemObject item = _controller->itemByHash(_panelPosition, hash);
447447
if (item.isCdUp())

qt-app/src/panel/cpanelwidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private slots:
8585
void driveButtonClicked();
8686
void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
8787
void currentItemChanged(const QModelIndex& current, const QModelIndex& previous);
88-
void itemNameEdited(qulonglong hash, QString newName);
88+
void renameItem(qulonglong hash, QString newName);
8989
void toRoot();
9090
void showFavoriteLocationsMenu(QPoint pos);
9191
void showFavoriteLocationsEditor();

qt-app/src/panel/filelistwidget/model/cfilelistmodel.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@
66
#include "assert/advanced_assert.h"
77

88
DISABLE_COMPILER_WARNINGS
9+
#include <QAbstractItemModelTester>
910
#include <QMimeData>
1011
#include <QUrl>
1112
RESTORE_COMPILER_WARNINGS
1213

13-
#include <set>
14+
#include <unordered_set>
1415

1516
CFileListModel::CFileListModel(QTreeView * treeView, QObject *parent) :
1617
QStandardItemModel(0, NumberOfColumns, parent),
1718
_controller(CController::get()),
1819
_tree(treeView)
1920
{
21+
// new QAbstractItemModelTester(this, QAbstractItemModelTester::FailureReportingMode::Fatal, this);
2022
}
2123

2224
// Sets the position (left or right) of a panel that this model represents
@@ -125,7 +127,7 @@ QMimeData *CFileListModel::mimeData(const QModelIndexList & indexes) const
125127
{
126128
auto* mime = new QMimeData();
127129
QList<QUrl> urls;
128-
std::set<int> rows;
130+
std::unordered_set<int> rows;
129131
for(const auto& idx: indexes)
130132
{
131133
if (idx.isValid() && !rows.contains(idx.row()))

0 commit comments

Comments
 (0)