Skip to content

Commit

Permalink
Uses of std::set replaced with unordered_set
Browse files Browse the repository at this point in the history
  • Loading branch information
VioletGiraffe committed Sep 13, 2024
1 parent 2b2be63 commit 113aa2d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion qt-app/qt-app.pro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TEMPLATE = app
TARGET = FileCommander

QT = core gui widgets network
QT = core gui widgets network testlib
lessThan(QT_MAJOR_VERSION, 6) {
win*:QT += winextras
}
Expand Down
8 changes: 4 additions & 4 deletions qt-app/src/panel/cpanelwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ DISABLE_COMPILER_WARNINGS
RESTORE_COMPILER_WARNINGS

#include <assert.h>
#include <set>
#include <unordered_set>

CPanelWidget::CPanelWidget(QWidget *parent) noexcept :
QWidget(parent),
Expand Down Expand Up @@ -142,7 +142,7 @@ void CPanelWidget::setPanelPosition(Panel p)

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

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

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

void CPanelWidget::itemNameEdited(qulonglong hash, QString newName)
void CPanelWidget::renameItem(qulonglong hash, QString newName)
{
CFileSystemObject item = _controller->itemByHash(_panelPosition, hash);
if (item.isCdUp())
Expand Down
2 changes: 1 addition & 1 deletion qt-app/src/panel/cpanelwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private slots:
void driveButtonClicked();
void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
void currentItemChanged(const QModelIndex& current, const QModelIndex& previous);
void itemNameEdited(qulonglong hash, QString newName);
void renameItem(qulonglong hash, QString newName);
void toRoot();
void showFavoriteLocationsMenu(QPoint pos);
void showFavoriteLocationsEditor();
Expand Down
6 changes: 4 additions & 2 deletions qt-app/src/panel/filelistwidget/model/cfilelistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
#include "assert/advanced_assert.h"

DISABLE_COMPILER_WARNINGS
#include <QAbstractItemModelTester>
#include <QMimeData>
#include <QUrl>
RESTORE_COMPILER_WARNINGS

#include <set>
#include <unordered_set>

CFileListModel::CFileListModel(QTreeView * treeView, QObject *parent) :
QStandardItemModel(0, NumberOfColumns, parent),
_controller(CController::get()),
_tree(treeView)
{
// new QAbstractItemModelTester(this, QAbstractItemModelTester::FailureReportingMode::Fatal, this);
}

// Sets the position (left or right) of a panel that this model represents
Expand Down Expand Up @@ -125,7 +127,7 @@ QMimeData *CFileListModel::mimeData(const QModelIndexList & indexes) const
{
auto* mime = new QMimeData();
QList<QUrl> urls;
std::set<int> rows;
std::unordered_set<int> rows;
for(const auto& idx: indexes)
{
if (idx.isValid() && !rows.contains(idx.row()))
Expand Down
2 changes: 1 addition & 1 deletion text-encoding-detector

0 comments on commit 113aa2d

Please sign in to comment.