Skip to content

Commit

Permalink
https://github.com/StephaneCouturier/Katalog/issues/556
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneCouturier committed Sep 19, 2024
1 parent 7cdba23 commit a433cd9
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/filesview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ bool FilesView::lessThan(const QModelIndex &left, const QModelIndex &right) cons
QString leftString = leftData.toString();
QString rightString = rightData.toString();

return QString::compare(leftString, rightString, Qt::CaseInsensitive) < 0;
if (caseSensitive) {
return leftString < rightString;
} else {
return QString::compare(leftString, rightString, Qt::CaseInsensitive) < 0;
}
}

return QSortFilterProxyModel::lessThan(left, right);
Expand Down
1 change: 1 addition & 0 deletions src/filesview.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class FilesView : public QSortFilterProxyModel

public:
FilesView(QObject *parent = nullptr);
bool caseSensitive = false;

protected:
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
Expand Down
4 changes: 4 additions & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ class MainWindow : public QMainWindow
// void checkDatabaseContent(const QString &connectionName);
// void copyDataFromGlobalToSearchConnection(const QString &connectionName);

//Settings
bool fileSortCaseSensitive;

private:
//Global
//Application version
Expand Down Expand Up @@ -396,6 +399,7 @@ class MainWindow : public QMainWindow
void on_Settings_checkBox_BiggerIconSize_stateChanged(int arg1);
void on_Settings_checkBox_LoadLastCatalog_stateChanged(int arg1);
void on_Settings_pushButton_OpenSettingsFile_clicked();
void on_Settings_checkBox_SettingsFileCaseSensitiveSort_stateChanged();

void on_Settings_pushButton_Documentation_clicked();
void on_Settings_pushButton_ReleaseNotes_clicked();
Expand Down
3 changes: 3 additions & 0 deletions src/mainwindow_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@
optionDisplayFolders = settings.value("Explore/DisplayFolders").toBool();
optionDisplaySubFolders = settings.value("Explore/DisplaySubFolders").toBool();

//Restore other settings
fileSortCaseSensitive = settings.value("Settings/FileCaseSensitiveSort").toBool();
ui->Settings_checkBox_SettingsFileCaseSensitiveSort->setChecked(fileSortCaseSensitive);

//Restore DEV Settings
if(developmentMode==true){
Expand Down
1 change: 1 addition & 0 deletions src/mainwindow_tab_explore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@
loadCatalogQueryModel->setQuery(std::move(loadCatalogQuery));

FilesView *proxyModel2 = new FilesView(this);
proxyModel2->caseSensitive = fileSortCaseSensitive;
proxyModel2->setSourceModel(loadCatalogQueryModel);

proxyModel2->setHeaderData(0, Qt::Horizontal, tr("Name"));
Expand Down
1 change: 1 addition & 0 deletions src/mainwindow_tab_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@
QSqlQueryModel *loadCatalogQueryModel = new QSqlQueryModel;
// Prepare model to display
FilesView *fileViewModel = new FilesView(this);
fileViewModel->caseSensitive = fileSortCaseSensitive;

//Populate model with folders only if this option is selected
if ( newSearch->searchOnFolderCriteria==true and ui->Search_checkBox_ShowFolders->isChecked()==true )
Expand Down
7 changes: 7 additions & 0 deletions src/mainwindow_tab_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,13 @@
settings.setValue("Settings/CheckVersion", ui->Settings_checkBox_CheckVersion->isChecked());
}
//----------------------------------------------------------------------
void MainWindow::on_Settings_checkBox_SettingsFileCaseSensitiveSort_stateChanged()
{
QSettings settings(collection->settingsFilePath, QSettings:: IniFormat);
settings.setValue("Settings/FileCaseSensitiveSort", ui->Settings_checkBox_SettingsFileCaseSensitiveSort->isChecked());
fileSortCaseSensitive = ui->Settings_checkBox_SettingsFileCaseSensitiveSort->isChecked();
}
//----------------------------------------------------------------------

//SETTINGS / data methods --------------------------------------------------
void MainWindow::loadCollection()
Expand Down
1 change: 1 addition & 0 deletions src/searchprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ void SearchProcess::processSearchResults()
mainWindow->newSearch->fileCatalogs <<"";

// Populate model with data
fileViewModel->caseSensitive = mainWindow->fileSortCaseSensitive;
fileViewModel->setSourceModel(mainWindow->newSearch);
fileViewModel->setHeaderData(0, Qt::Horizontal, QCoreApplication::translate("MainWindow", "Name"));
fileViewModel->setHeaderData(1, Qt::Horizontal, QCoreApplication::translate("MainWindow", "Size"));
Expand Down

0 comments on commit a433cd9

Please sign in to comment.