Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve search behavior in the file browser #7679

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions include/FileBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@
#include <QDir>
#include <QMutex>
#include <QProgressBar>
#include <memory>
#include <future>

#include "FileSearch.h"
#include "embed.h"

#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
Expand Down Expand Up @@ -77,19 +76,6 @@ class FileBrowser : public SideBarWidget

~FileBrowser() override = default;

static QStringList excludedPaths()
{
static auto s_excludedPaths = QStringList{
#ifdef LMMS_BUILD_LINUX
"/bin", "/boot", "/dev", "/etc", "/proc", "/run", "/sbin",
"/sys"
#endif
#ifdef LMMS_BUILD_WIN32
"C:\\Windows"
#endif
};
return s_excludedPaths;
}
static QDir::Filters dirFilters() { return QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden; }
static QDir::SortFlags sortFlags() { return QDir::LocaleAware | QDir::DirsFirst | QDir::Name | QDir::IgnoreCase; }

Expand All @@ -99,17 +85,40 @@ private slots:
void giveFocusToFilter();

private:
class SearchManager
{
public:
~SearchManager() { cancel(); }

void cancel()
{
if (m_currentSearchTask.valid())
{
m_cancel = true;
m_currentSearchTask.get();
m_cancel = false;
}
}

bool cancelled() { return m_cancel; }

void setCurrentSearchTask(std::future<void> task) { m_currentSearchTask = std::move(task); }

std::future<void>& currentSearchTask() { return m_currentSearchTask; }

private:
std::future<void> m_currentSearchTask;
std::atomic<bool> m_cancel;
};

void keyPressEvent( QKeyEvent * ke ) override;

void addItems( const QString & path );

void saveDirectoriesStates();
void restoreDirectoriesStates();

void foundSearchMatch(FileSearch* search, const QString& match);
void searchCompleted(FileSearch* search);
void onSearch(const QString& filter);
void displaySearch(bool on);

void addContentCheckBox();

Expand All @@ -118,7 +127,7 @@ private slots:

QLineEdit * m_filterEdit;

std::shared_ptr<FileSearch> m_currentSearch;
SearchManager m_searchManager;
QProgressBar* m_searchIndicator = nullptr;

QString m_directories; //!< Directories to search, split with '*'
Expand All @@ -139,9 +148,6 @@ private slots:
QString m_previousFilterValue;
} ;




class FileBrowserTreeWidget : public QTreeWidget
{
Q_OBJECT
Expand Down Expand Up @@ -204,7 +210,7 @@ private slots:
class Directory : public QTreeWidgetItem
{
public:
Directory(const QString& filename, const QString& path, const QString& filter, bool disableEntryPopulation = false);
Directory(const QString& filename, const QString& path, const QString& filter);

void update();

Expand Down Expand Up @@ -247,7 +253,6 @@ class Directory : public QTreeWidgetItem
QString m_filter;

int m_dirCount;
bool m_disableEntryPopulation = false;
} ;


Expand Down
73 changes: 0 additions & 73 deletions include/FileSearch.h

This file was deleted.

1 change: 0 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ set(LMMS_SRCS
core/Engine.cpp
core/EnvelopeAndLfoParameters.cpp
core/fft_helpers.cpp
core/FileSearch.cpp
core/Mixer.cpp
core/ImportFilter.cpp
core/InlineAutomation.cpp
Expand Down
92 changes: 0 additions & 92 deletions src/core/FileSearch.cpp

This file was deleted.

Loading
Loading