Namespace sh::search¶
-
namespace
sh
::
search
Infrastructure for searches in the filesystem.
See sh::search::SearchManager for more.
-
class
Search
: public QObject, public std::enable_shared_from_this<Search> - #include <search.h>
A search object represents one search request the user made.
Public Functions
-
~Search
()
-
std::shared_ptr<const sh::filesystem::Eurl>
eurl
() Returns the eurl containg the search configuration.
-
std::shared_ptr<sh::filesystem::FilesystemNode>
searchnode
() Returns the root node of the search (the one named like ‘Search …’).
-
void
search
() Start the searching.
-
bool
isSearching
() Returns if the search is currently in progress.
Signals
-
void
isSearchingChanged
() Triggers when Search::isSearching changes.
Private Functions
Private Members
-
std::shared_ptr<const sh::filesystem::Eurl>
_eurl
-
std::shared_ptr<sh::filesystem::FilesystemNode>
_searchnode
-
sh::search::SearchConfiguration *
_config
-
QHash<std::shared_ptr<const sh::filesystem::Eurl>, std::shared_ptr<sh::filesystem::FilesystemNode>>
_dirs
-
QMutex
_isSearchingMutex
-
bool
_isSearching
= false
-
bool
_isSearchAgain
= false
-
-
class
SearchConfiguration
- #include <searchconfiguration.h>
A search configuration.
Search configurations contain a list of search criteria and some auxiliary fields. Each search configuration describes what and how a user wants to search (just not where).
Public Functions
-
SearchConfiguration
()
-
QString
serialize
() Serialize this search configuration to a string. See also SearchConfiguration::deserialize.
Public Static Functions
-
SearchConfiguration *
deserialize
(QString s) Deserialize a search configuration from a string. See also SearchConfiguration::serialize.
-
-
class
SearchCriterion
- #include <searchcriterion.h>
Abstract base class for a search criterion.
Each search criterion implements how a user can filter his files in a search.
Register an implementation, e.g. with ‘REGISTER_CRITERION_FACTORY’ of “search/searchcriterionfactoryfromfunction.h”.
Subclassed by sh::search::criteria::AbstractActionDrivenSearchCriterion, sh::search::criteria::AbstractStringSearchCriterion, sh::search::criteria::ExtendedAttributeSearchCriterion, sh::search::criteria::MtimeSearchCriterion
Public Functions
-
~SearchCriterion
()
-
QString
serialize
() Serializes this criterion to a string. See also SearchCriterion::deserialize.
Checks if a given file (by eurl) matches this criterion. .
-
QString
valuedescription
() = 0 Returns a human readable text describing the current criterion shortly and precisely. .
-
std::shared_ptr<sh::search::SearchCriterionFactory>
factory
() Returns the factory this criterion has created (provides some more metadata).
Public Static Functions
-
std::shared_ptr<sh::search::SearchCriterion>
deserialize
(QString s) Deserializes this criterion from a string. See also SearchCriterion::serialize.
-
-
class
SearchCriterionFactory
: public std::enable_shared_from_this<SearchCriterionFactory> - #include <searchcriterionfactory.h>
Abstract base class for a search criterion factory, which constructs some sh::search::SearchCriterion instances.
It also provides some control methods and metadata (which is possible since there is a separate factory for each criterion class).
Note: Though possible in some exotic situations, one should not override this class. Override and register sh::search::SearchCriterion instead!
Subclassed by sh::scripting::api::ApiSearchCriterionFactory, sh::search::SearchCriterionFactoryFromFunction
Public Functions
-
SearchCriterionFactory
()
-
QString
key
() = 0 Returns the string key for the associated search criterion class. .
-
QString
description
() = 0 Returns the description string for the associated search criterion class. .
Builds the search config ui in a search panel.
Takes the data from
c
and populatespanelcfg
with it.
Updates own data with the content from the search config ui in a search panel.
Takes the data from
panelcfg
and updatesc
with it.
-
std::shared_ptr<sh::search::SearchCriterion>
construct
() = 0 Constructs an instance of the associated search criterion class. .
Checks if the associated search criterion class should be offered to the user for a given node. .
-
~SearchCriterionFactory
()
-
-
class
SearchCriterionFactoryFromFunction
: public sh::search::SearchCriterionFactory - #include <searchcriterionfactoryfromfunction.h>
A search criterion factory implementation which uses some additional static methods in the sh::search::SearchCriterion subclasses for control.
This is the default search criterion factory. It is typically used indirectly by the ‘REGISTER_CRITERION_FACTORY’ macro from here.
Public Functions
-
QString
key
() Returns the string key for the associated search criterion class. .
-
QString
description
() Returns the description string for the associated search criterion class. .
Builds the search config ui in a search panel.
Takes the data from
c
and populatespanelcfg
with it.
Updates own data with the content from the search config ui in a search panel.
Takes the data from
panelcfg
and updatesc
with it.
-
std::shared_ptr<SearchCriterion>
construct
() Constructs an instance of the associated search criterion class. .
Checks if the associated search criterion class should be offered to the user for a given node. .
Private Members
-
QString
_key
-
std::function<QString()>
_descriptionfct
-
std::function<void(std::shared_ptr<sh::search::SearchCriterion>, sh::ui::SearchPanelConfiguration*)>
_editorfct
-
std::function<void(sh::ui::SearchPanelConfiguration*, std::shared_ptr<sh::search::SearchCriterion>)>
_editorupdateconfigfct
-
std::function< std::shared_ptr< sh::search::SearchCriterion >std::shared_ptr< sh::search::SearchCriterionFactory >)> _constructfct
-
QString
-
class
SearchFilesystemHandler
: public sh::filesystem::FilesystemHandler, public sh::base::Singleton - #include <searchfilesystemhandler.h>
A filesystem handler for presenting filesystem search results.
Public Functions
Configure newly created nodes (e.g. setting another icon or changing the display name).
Determine a list of subelements in a certain directory.
Determine if a file is regular, or a dir, or a link, …
Determine the size of a file.
Determine the mtime of a file.
Set the mtime of a file.
Determine mime type of a file.
Resolve a link.
Fetches the list of available extended attributes for an entry.
Returns the site of value for one extended attribute for an entry.
Returns the value for one extended attribute for an entry.
Sets the value for one extended attribute for an entry.
Removes one extended attributes for an entry.
Returns the custom attributes for an entry.
In contrast to extended attributes, the custom attributes are not directly stored in the filesystem this way, but handle implementation specific aspects (like permissions).
Sets the value for one custom attribute for an entry.
See also getCustomAttributes.
Returns if it is allowed to get the content of a certain file.
Get the content of a file.
Returns if it is allowed to create subdirectories in a certain directory.
Create a directory.
Returns if it is allowed to create a link in a certain directory.
Create a link.
Returns if it is allowed to create files in a certain directory.
Creates a file with some content.
It may use
handlertransfer
for some better integration, like cancel support and progress monitoring.
Returns if it is allowed to delete a certain file/directory/link/….
Delete a file/directory/link/…
Deletes a directory only of it is empty.
Returns if it is allowed to rename a certain file, directory, link, … (see renameItem).
Renames an item to another path.
It can be a simple filename change or also changes in the deeper path segments.
Returns a list of actions (see former example) for showing for certain files.
-
bool
requiresResolvedLinks
() Returns if this handler requires to be used by the engine with resolved links.
Callback for preparing stuff when the view entered some directory (e.g. for enabling watchers). See also viewLeftDirectory.
Callback for preparing stuff when the view left some directory. See also viewEnteredDirectory.
-
bool
isWellKnownScheme
() Returns if the scheme for this handler is a well known one (which external programs typically would understand).
Helps searching for files.
Override this method with a behavior identical to the default, if a specialized implementation can be much faster than the default one.
Creates a custom gui, which becomes part of the fileview.
-
sh::filesystem::FilesystemModel *
model
() A convenience shortcut to the sh::filesystem::FilesystemModel (a singleton).
-
void
doShutdown
() Executes singleton shutdown.
-
void
shutdown
() Shutdown down this singleton.
-
bool
isAlive
() Returns if this singleton is alive (true until its shutdown begins).
Private Functions
-
SearchFilesystemHandler
()
-
class
SearchManager
: public QObject, public sh::base::Singleton - #include <searchmanager.h>
Manager for searches in the filesystem.
Public Functions
Requests a search.
Removes a search.
Returns the Search instance for an eurl for a search root node.
Adds a search criterion factory.
-
QList<std::shared_ptr<SearchCriterionFactory>>
factories
() Returns the sorted list of search criterion factories.
-
~SearchManager
()
-
void
doShutdown
() Executes singleton shutdown.
-
void
shutdown
() Shutdown down this singleton.
-
bool
isAlive
() Returns if this singleton is alive (true until its shutdown begins).
Public Static Attributes
-
const int
REGISTER_SEARCHCRITERION_INDEX_CORE
= 1000000 Base value for display indexes of core (i.e. very important) search criteria.
Used in SearchManager::addFactory.
-
const int
REGISTER_SEARCHCRITERION_INDEX_NORMAL
= 2000000 Base value for display indexes of search criteria with normal importance.
Used in SearchManager::addFactory.
-
const int
REGISTER_SEARCHCRITERION_INDEX_EXOTIC
= 3000000 Base value for display indexes of exotic search criteria.
Used in SearchManager::addFactory.
Private Functions
-
SearchManager
()
-
namespace
criteria
Implementations of search criteria.
Subclasses of sh::search::SearchCriterion.
-
class
AbstractActionDrivenSearchCriterion
: public sh::search::SearchCriterion - #include <abstractactiondrivensearchcriterion.h>
Abstract search criterion filtering by something which is configured in a wizard-like way by an action execution.
This provides an easy yet powerful programming interface, e.g. for usage in scripting.
Subclassed by sh::scripting::api::ApiSearchCriterion
Public Functions
Checks if a given file (by eurl) matches this criterion. .
-
QString
valuedescription
() Returns a human readable text describing the current criterion shortly and precisely. .
-
QString
serialize
() Serializes this criterion to a string. See also SearchCriterion::deserialize.
-
std::shared_ptr<sh::search::SearchCriterionFactory>
factory
() Returns the factory this criterion has created (provides some more metadata).
Public Members
-
QStringList
searchspec
Public Static Functions
-
std::shared_ptr<sh::search::SearchCriterion>
deserialize
(QString s) Deserializes this criterion from a string. See also SearchCriterion::serialize.
Friends
- friend class ActionAbstractActionDrivenSearchCriterionConfigure
-
class
AbstractStringSearchCriterion
: public sh::search::SearchCriterion - #include <abstractstringsearchcriterion.h>
Abstract search criterion filtering by some string value (providing different modes like exact, fuzzy, regexp, …).
Subclassed by sh::search::criteria::FileContentSearchCriterion, sh::search::criteria::FilenameSearchCriterion
Public Types
-
enum
Mode
Values:
-
enumerator
Simple
-
enumerator
Exact
-
enumerator
RegExp
-
enumerator
Fuzzy
-
enumerator
Public Functions
Checks if a given file (by eurl) matches this criterion. .
-
QString
valuedescription
() Returns a human readable text describing the current criterion shortly and precisely. .
-
QString
serialize
() Serializes this criterion to a string. See also SearchCriterion::deserialize.
-
std::shared_ptr<sh::search::SearchCriterionFactory>
factory
() Returns the factory this criterion has created (provides some more metadata).
Public Static Functions
-
int
levenshteinSubstringDistance
(QString needle, QString haystack)
-
double
relativeLevenshteinPartsSubstringDistance
(QString needle, QString haystack)
-
std::shared_ptr<sh::search::SearchCriterion>
deserialize
(QString s) Deserializes this criterion from a string. See also SearchCriterion::serialize.
Public Static Attributes
-
const QStringList
ModeCodes
-
enum
-
class
ActionAbstractActionDrivenSearchCriterionConfigure
: public sh::actions::ActionActionItem - #include <abstractactiondrivensearchcriterion.h>
Public Functions
-
void
action
(sh::actions::ActionExecutionInfo *info) The action implementation, i.e. what the actions should actually do.
-
void
execute
() Executes this action.
-
void
execute
(sh::actions::ActionExecutionInfo *info) Executes this action.
-
QKeySequence
shortcuthint
() Returns the keyboard shortcut for triggering this action.
-
bool
shortcuthintTriggersOnCurrentDirectory
() Checks if using the keyboard shortcut shall trigger the action on the current directory (or on the entry selection).
-
void
setShortcuthint
(QKeySequence shortcut, bool triggersOnCurrentDirectory = false) Sets the keyboard shortcut for triggering this action.
-
QString
text
() Returns the displayed text for this action.
-
QString
icon
() Returns the icon for this action.
-
bool
enabled
() Checks if this action is enabled.
-
bool
isChecked
() Checks if this action is checked (has a cross in the ui).
-
bool
isCheckable
() Checks if this action is checkable (can have a cross in the ui).
-
int
defaultActionPrecedence
() const Returns the precedence for becoming the default action of a parent submenu.
This e.g. leads to a bold label.
The action with the highest value becomes the default. Only values >0 will be considered. See ActionDefaultPrecedenceValues for reference values.
-
void
setText
(QString text) Sets the displayed text.
-
void
setIcon
(QString icon) Sets the icon.
-
void
setEnabled
(bool enabled) Sets if the item is enabled.
-
void
setChecked
(bool checked) Sets if the item is checked (has a cross in the ui).
-
void
setVisible
(bool visible) Sets the visibility of this item.
-
bool
visible
() Checks the visibility of this item (non-recursively).
-
std::weak_ptr<AbstractActionItem>
parentAction
() Returns the parent action, if it is added to a container.
Sets the parent action. .
-
void
initializeAsync
(std::function<void()> oninitialized = 0) Asynchonously initializes the action.
-
void
initializeSync
() Synchonously initializes the action.
-
bool
isInitialized
() Checks if this action is initialized.
-
bool
isInitializing
() Checks if this action is initializing.
Signals
-
void
changed
() Emits when some data changed.
-
void
-
class
ExtendedAttributeSearchCriterion
: public sh::search::SearchCriterion - #include <extendedattributesearchcriterion.h>
Search criterion filtering by extended attributes.
Public Types
-
enum
Mode
Values:
-
enumerator
None
-
enumerator
Simple
-
enumerator
RegExp
-
enumerator
Fuzzy
-
enumerator
Public Functions
Checks if a given file (by eurl) matches this criterion. .
-
QString
valuedescription
() Returns a human readable text describing the current criterion shortly and precisely. .
-
QString
serialize
() Serializes this criterion to a string. See also SearchCriterion::deserialize.
-
std::shared_ptr<sh::search::SearchCriterionFactory>
factory
() Returns the factory this criterion has created (provides some more metadata).
Public Static Functions
-
void
doInitialize
()
-
void
doShutdown
()
-
std::shared_ptr<sh::search::SearchCriterion>
deserialize
(QString s) Deserializes this criterion from a string. See also SearchCriterion::serialize.
Public Static Attributes
-
const QStringList
ModeCodes
-
enum
-
class
FileContentSearchCriterion
: public sh::search::criteria::AbstractStringSearchCriterion - #include <filecontentsearchcriterion.h>
Search criterion filtering by file contents.
Public Types
-
enum
Mode
Values:
-
enumerator
Simple
-
enumerator
Exact
-
enumerator
RegExp
-
enumerator
Fuzzy
-
enumerator
Public Functions
Checks if a given file (by eurl) matches this criterion. .
-
QString
valuedescription
() Returns a human readable text describing the current criterion shortly and precisely. .
-
QString
serialize
() Serializes this criterion to a string. See also SearchCriterion::deserialize.
-
std::shared_ptr<sh::search::SearchCriterionFactory>
factory
() Returns the factory this criterion has created (provides some more metadata).
Public Static Functions
-
void
doInitialize
()
-
void
doShutdown
()
-
int
levenshteinSubstringDistance
(QString needle, QString haystack)
-
double
relativeLevenshteinPartsSubstringDistance
(QString needle, QString haystack)
-
std::shared_ptr<sh::search::SearchCriterion>
deserialize
(QString s) Deserializes this criterion from a string. See also SearchCriterion::serialize.
Public Static Attributes
-
const QStringList
ModeCodes
-
enum
-
class
FilenameSearchCriterion
: public sh::search::criteria::AbstractStringSearchCriterion - #include <filenamesearchcriterion.h>
Search criterion filtering by file names.
Public Types
-
enum
Mode
Values:
-
enumerator
Simple
-
enumerator
Exact
-
enumerator
RegExp
-
enumerator
Fuzzy
-
enumerator
Public Functions
Checks if a given file (by eurl) matches this criterion. .
-
QString
valuedescription
() Returns a human readable text describing the current criterion shortly and precisely. .
-
QString
serialize
() Serializes this criterion to a string. See also SearchCriterion::deserialize.
-
std::shared_ptr<sh::search::SearchCriterionFactory>
factory
() Returns the factory this criterion has created (provides some more metadata).
Public Static Functions
-
void
doInitialize
()
-
void
doShutdown
()
-
int
levenshteinSubstringDistance
(QString needle, QString haystack)
-
double
relativeLevenshteinPartsSubstringDistance
(QString needle, QString haystack)
-
std::shared_ptr<sh::search::SearchCriterion>
deserialize
(QString s) Deserializes this criterion from a string. See also SearchCriterion::serialize.
Public Static Attributes
-
const QStringList
ModeCodes
-
enum
-
class
MtimeSearchCriterion
: public sh::search::SearchCriterion - #include <mtimesearchcriterion.h>
Search criterion filtering by file modification times.
Public Functions
Checks if a given file (by eurl) matches this criterion. .
-
QString
valuedescription
() Returns a human readable text describing the current criterion shortly and precisely. .
-
QString
serialize
() Serializes this criterion to a string. See also SearchCriterion::deserialize.
-
std::shared_ptr<sh::search::SearchCriterionFactory>
factory
() Returns the factory this criterion has created (provides some more metadata).
Public Members
-
QDateTime
from
-
QDateTime
to
Public Static Functions
-
void
doInitialize
()
-
void
doShutdown
()
-
std::shared_ptr<sh::search::SearchCriterion>
deserialize
(QString s) Deserializes this criterion from a string. See also SearchCriterion::serialize.
-
class
-
class