summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Reher <tde@4reher.org>2023-10-02 10:46:42 -0700
committerVincent Reher <tde@4reher.org>2023-10-02 11:22:04 -0700
commit2d9363f2bdf920666ddc7fab2bd76f27a137662b (patch)
tree8cdca533a4a93841bef2603de20155aa3f0dc13e
parent5fe559d3784117460761ad59981cab836ab79dda (diff)
downloadtdelibs-2d9363f2bdf920666ddc7fab2bd76f27a137662b.tar.gz
tdelibs-2d9363f2bdf920666ddc7fab2bd76f27a137662b.zip
Enable KDirLister to utilize its own custom TDEHiddenFileMatcher
object instead of the global instance. Signed-off-by: Vincent Reher <tde@4reher.org>
-rw-r--r--tdeio/tdeio/kdirlister.cpp48
-rw-r--r--tdeio/tdeio/kdirlister.h45
2 files changed, 70 insertions, 23 deletions
diff --git a/tdeio/tdeio/kdirlister.cpp b/tdeio/tdeio/kdirlister.cpp
index a0c31578f..83ff5c393 100644
--- a/tdeio/tdeio/kdirlister.cpp
+++ b/tdeio/tdeio/kdirlister.cpp
@@ -1907,15 +1907,19 @@ void KDirListerCache::printDebug()
KDirLister::KDirLister( bool _delayedMimeTypes )
{
kdDebug(7003) << "+KDirLister" << endl;
-
d = new KDirListerPrivate;
+ // Create a separate "copy" of the global hidden file matcher
+ TSMTRACE << "KDirLister::KDirLister: Allocating a hidden file matcher" << endl;
+ d->hiddenFileMatcher = new TDEStringMatcher;
+ d->hiddenFileMatcher->setMatchSpecs( TDEGlobal::hiddenFileMatcher()->getMatchSpecString() );
+
d->complete = true;
d->delayedMimeTypes = _delayedMimeTypes;
setAutoUpdate( true );
setDirOnlyMode( false );
- setShowingDotFiles( false );
+ setShowingHiddenFiles( false );
setAutoErrorHandlingEnabled( true, 0 );
}
@@ -1931,6 +1935,7 @@ KDirLister::~KDirLister()
s_pCache->forgetDirs( this );
}
+ delete d->hiddenFileMatcher;
delete d;
}
@@ -2015,18 +2020,28 @@ void KDirLister::setAutoUpdate( bool _enable )
s_pCache->setAutoUpdate( this, _enable );
}
-bool KDirLister::showingDotFiles() const
+bool KDirLister::isShowingHiddenFiles() const
{
- return d->isShowingDotFiles;
+ return d->isShowingHiddenFiles;
}
-void KDirLister::setShowingDotFiles( bool _showDotFiles )
+void KDirLister::setShowingHiddenFiles( bool _showHiddenFiles )
{
- if ( d->isShowingDotFiles == _showDotFiles )
+ if ( d->isShowingHiddenFiles == _showHiddenFiles )
return;
- d->isShowingDotFiles = _showDotFiles;
- d->changes ^= DOT_FILES;
+ d->isShowingHiddenFiles = _showHiddenFiles;
+ d->changes ^= HIDDEN_FILES;
+}
+
+bool KDirLister::showingDotFiles() const
+{
+ return isShowingHiddenFiles();
+}
+
+void KDirLister::setShowingDotFiles( bool _showDotFiles )
+{
+ setShowingHiddenFiles( _showDotFiles );
}
bool KDirLister::dirOnlyMode() const
@@ -2114,10 +2129,11 @@ void KDirLister::emitChanges()
if ( (*kit)->isHidden() )
{
- if ( d->changes & DOT_FILES )
+ if ( d->changes & HIDDEN_FILES )
{
- // the lister switched to dot files mode
- if ( d->isShowingDotFiles ) {
+ // the lister switched to hidden files mode
+ if ( d->isShowingHiddenFiles ) {
+
addNewItem( *kit );
}
else {
@@ -2190,6 +2206,10 @@ KFileItem *KDirLister::find( const KURL& _url ) const
}
#endif
+TDEStringMatcher *KDirLister::hiddenFileMatcher()
+{
+ return d->hiddenFileMatcher;
+}
// ================ public filter methods ================ //
@@ -2280,7 +2300,7 @@ bool KDirLister::matchesFilter( const KFileItem *item ) const
if ( item->text() == dotdot )
return false;
- if ( !d->isShowingDotFiles && item->isHidden() )
+ if ( !d->isShowingHiddenFiles && item->isHidden() )
return false;
if ( item->isDir() || d->lstFilters.isEmpty() )
@@ -2371,6 +2391,10 @@ void KDirLister::addNewItem( const KFileItem *item )
const_cast<KFileItem*>(item)->setURL(newItemURL);
}
+ // Replace KFileItem default hidden file matcher with our own.
+ //-Debug: TSMTRACE << "KDirLister::addNewItem() installing custom matcher for " << item->url().fileName() <<endl ;
+ const_cast<KFileItem*>(item)->setHiddenFileMatcher( d->hiddenFileMatcher );
+
if ( ( d->dirOnlyMode && !item->isDir() ) || !matchesFilter( item ) ) {
return; // No reason to continue... bailing out here prevents a mimetype scan.
}
diff --git a/tdeio/tdeio/kdirlister.h b/tdeio/tdeio/kdirlister.h
index b69a51841..f925de629 100644
--- a/tdeio/tdeio/kdirlister.h
+++ b/tdeio/tdeio/kdirlister.h
@@ -158,24 +158,36 @@ public:
*/
void setAutoErrorHandlingEnabled( bool enable, TQWidget *parent );
+ /**
+ * Checks whether hidden files will be shown. By default this
+ * option is disabled (hidden files will be not shown).
+ * @return true if hidden files are shown, false otherwise
+ * @see setShowingHiddenFiles()
+ */
+ bool isShowingHiddenFiles() const;
+
+ /**
+ * Changes the "is viewing hidden files" setting.
+ * Calls updateDirectory() if setting changed.
+ * @param show true to enable showing hidden files, false to
+ * disable
+ * @see isShowingHiddenFiles()
+ * @see also description of @property hiddenFileMatcher
+ */
+ virtual void setShowingHiddenFiles( bool _showHiddenFiles );
+
/**
- * Checks whether hidden files (files beginning with a dot) will be
- * shown.
- * By default this option is disabled (hidden files will be not shown).
+ * @deprecated use isShowingHiddenFiles()
* @return true if dot files are shown, false otherwise
* @see setShowingDotFiles()
*/
- bool showingDotFiles() const;
+ bool showingDotFiles() const KDE_DEPRECATED;
/**
- * Changes the "is viewing dot files" setting.
- * Calls updateDirectory() if setting changed.
- * By default this option is disabled (hidden files will not be shown).
- * @param _showDotFiles true to enable showing hidden files, false to
- * disable
+ * @deprecated use setShowingHiddenFiles()
* @see showingDotFiles()
*/
- virtual void setShowingDotFiles( bool _showDotFiles );
+ virtual void setShowingDotFiles( bool _showDotFiles ) KDE_DEPRECATED;
/**
* Checks whether the KDirLister only lists directories or all
@@ -255,6 +267,17 @@ public:
#endif
/**
+ * @return the pointer
+ * to the object that encapsulates criteria for determining whether
+ * or not the filesystem objects managed by this KDirLister should
+ * be hidden based on characteristics of their names. This object is
+ * passed to KFileItem::setHiddenFileMatcher() for each associated
+ * filesystem entity so the determination of "hidden" can be made using
+ * KDirLister's own hiddenFileMatcher instead of KFileItem's default.
+ */
+ TDEStringMatcher *hiddenFileMatcher();
+
+ /**
* Find an item by its name.
* @param name the item name
* @return the pointer to the KFileItem
@@ -536,7 +559,7 @@ signals:
protected:
enum Changes {
- NONE=0, NAME_FILTER=1, MIME_FILTER=2, DOT_FILES=4, DIR_ONLY_MODE=8
+ NONE=0, NAME_FILTER=1, MIME_FILTER=2, HIDDEN_FILES=4, DIR_ONLY_MODE=8
};
/**