summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Reher <tde@4reher.org>2022-08-13 09:46:14 -0700
committerVincent Reher <tde@4reher.org>2022-08-13 09:46:14 -0700
commita39f9134cdf34d937699bd99bbfd065af7ea82c8 (patch)
tree8b0ae067c91d7f771d241de50cf6fab3d3607770
parent21c8de4d483c0f33ada592195ad29e51a4a5aac7 (diff)
downloadtdelibs-issue/270/tdelibs.tar.gz
tdelibs-issue/270/tdelibs.zip
Implemented a single global "default" HiddenFileMatcher object thatissue/270/tdelibs
can be used instead of (or in conjunction with) application-specific HiddenFileMatchers. HiddenFileMatcher objects are now initialized from a criteria string stored as a setting in kdeglobals that defaults to wildcard matching of dotfiles. Removed KFileItem::setHidden(), merging its functionality into isHidden(HiddenFileMatcher*) Fixed some problems and made some improvements to Hidden_Files_Dialog. Other various fixes per discussions with MichelleC. Signed-off-by: Vincent Reher <tde@4reher.org>
-rw-r--r--tdeio/tdeio/global.cpp41
-rw-r--r--tdeio/tdeio/global.h73
-rw-r--r--tdeio/tdeio/hidden-file-dialog.cpp68
-rw-r--r--tdeio/tdeio/hidden-file-dialog.h9
-rw-r--r--tdeio/tdeio/kdirlister.cpp8
-rw-r--r--tdeio/tdeio/kdirlister.h10
-rw-r--r--tdeio/tdeio/tdefilefilter.h8
-rw-r--r--tdeio/tdeio/tdefileitem.cpp36
-rw-r--r--tdeio/tdeio/tdefileitem.h26
9 files changed, 187 insertions, 92 deletions
diff --git a/tdeio/tdeio/global.cpp b/tdeio/tdeio/global.cpp
index 54384c72..f4027791 100644
--- a/tdeio/tdeio/global.cpp
+++ b/tdeio/tdeio/global.cpp
@@ -2041,7 +2041,7 @@ TQString TDEIO::getCacheControlString(TDEIO::CacheControl cacheControl)
TDEIO::HiddenFileMatcher::HiddenFileMatcher()
{
- setCriteria( criteria_Default );
+ setCriteria( getGlobalCriteria() );
}
bool TDEIO::HiddenFileMatcher::match( const TQString& filename )
@@ -2063,7 +2063,7 @@ bool TDEIO::HiddenFileMatcher::match( const TQString& filename )
TQString TDEIO::HiddenFileMatcher::getCriteria()
{
- return criteria;
+ return Criteria;
}
void TDEIO::HiddenFileMatcher::generateCriteria()
@@ -2077,7 +2077,7 @@ void TDEIO::HiddenFileMatcher::generateCriteria()
if ( isCaseInsensitive )
leadingChar = leadingChar.upper();
newCriteria.prepend( leadingChar );
- criteria = newCriteria;
+ Criteria = newCriteria;
}
bool TDEIO::HiddenFileMatcher::setCriteria( TQString newCriteria )
@@ -2101,14 +2101,29 @@ bool TDEIO::HiddenFileMatcher::setCriteria( TQString newCriteria )
patternList.clear();
patternList = TQStringList::split( patternsDivider, newCriteria.mid(1), TRUE );
- criteria = newCriteria;
+ Criteria = newCriteria;
return TRUE;
}
-int TDEIO::HiddenFileMatcher::getMatchPropertiesFromUser()
+TQString TDEIO::HiddenFileMatcher::getGlobalCriteria()
+{
+ TDEConfig *config = TDEGlobal::config();
+ TDEConfigGroupSaver saver( config, globalSettingsGroup );
+ TQString defaultCriteria = config->readEntry( globalSettingsKey, criteriaLegacy );
+ return defaultCriteria;
+}
+
+void TDEIO::HiddenFileMatcher::setGlobalCriteria()
+{
+ TDEConfig *config = TDEGlobal::config();
+ TDEConfigGroupSaver saver( config, globalSettingsGroup );
+ config->writeEntry( globalSettingsKey, Criteria );
+}
+
+int TDEIO::HiddenFileMatcher::getMatchPropertiesFromUser( TQString forWhom )
{
TDEIO::Hidden_Files_Dialog defineHiddenUI =
- TDEIO::Hidden_Files_Dialog( patternList, isRegex, isCaseInsensitive );
+ TDEIO::Hidden_Files_Dialog( patternList, isRegex, isCaseInsensitive, forWhom );
defineHiddenUI.exec();
if ( defineHiddenUI.result() > TDEIO::HiddenFileMatcher::criteriaUnchanged ) {
@@ -2118,7 +2133,19 @@ int TDEIO::HiddenFileMatcher::getMatchPropertiesFromUser()
generateCriteria();
kdDebug(7000)
<< "TDEIO::HiddenFileMatcher::getMatchPropertiesFromUser: updated criteria string: '"
- << criteria << "'" << endl;
+ << Criteria << "'" << endl;
}
return defineHiddenUI.result();
}
+
+// Define a single application-independent instance of a TDEIO::HiddenFileMatcher
+
+TDEIO::HiddenFileMatcher* TDEIO::CommonHiddenFileMatcher::matcher = nullptr;
+
+TDEIO::HiddenFileMatcher* TDEIO::CommonHiddenFileMatcher::getMatcher()
+{
+ if (matcher == nullptr) {
+ matcher = new TDEIO::HiddenFileMatcher;
+ }
+ return(matcher);
+}
diff --git a/tdeio/tdeio/global.h b/tdeio/tdeio/global.h
index 374a90bd..bd6a3274 100644
--- a/tdeio/tdeio/global.h
+++ b/tdeio/tdeio/global.h
@@ -545,9 +545,8 @@ public:
/************
*
- * Hidden file matcher class. Defines properties and methods that are used
- * used to determine whether or not a file is "hidden". This is implemented
- * as a singleton class in that there will no more than one instance of it.
+ * Hidden file matcher class. Defines properties and methods that are
+ * used to determine whether or not a file is "hidden".
*/
class TDEIO_EXPORT HiddenFileMatcher
{
@@ -562,40 +561,45 @@ public:
bool match( const TQString& filename );
/**
- @return value of @property criteria described below.
+ @return value of @property Criteria described below.
*/
TQString getCriteria();
/**
- Derive value of @property criteria from the current values
+ Derive value of @property Criteria from the current values
of the match-controlling @properties described below
*/
void generateCriteria();
/**
- Process @param newcriteria to initialize / update the
+ Process @param newCriteria to initialize / update the
match-controlling @properties that are described below.
*/
- bool setCriteria(TQString newcriteria);
+ bool setCriteria(TQString newCriteria);
+
+ TQString getGlobalCriteria();
+ void setGlobalCriteria();
/**
Present dialog that allows user to view/update current
match-controlling @properties described below. @return
- true if match properties were successfully updated and
- user had pressed the Save button instead of Apply button.
+ one of the values of Result_getMatchPropertiesFromUser
+ listed below. @param forWhom can be used to designate
+ the software component that allocated the HiddenFileMatcher
+ (e.g. "Konqueror Listview", "Trinity Desktop Environment")
*/
- int getMatchPropertiesFromUser();
+ int getMatchPropertiesFromUser( TQString forWhom = TQString("Current Application") );
enum Result_getMatchPropertiesFromUser {
- reloadCriteria = -1,
- criteriaUnchanged,
- criteriaApplied,
- saveCriteria
+ reloadCriteria = -1, // Criteria was not changed, request reloading default
+ criteriaUnchanged = 0, // Criteria was not changed
+ criteriaApplied = 1, // New criteria applied, should not be saved
+ saveCriteria = 2 // New criteria applied, request saving as default
};
/**
@property patternsDivider is a character used to separate multiple
- match patterns in @property criteria described below. This should be
+ match patterns in @property Criteria described below. This should be
a character that would not be used in a match pattern or file name.
*/
const TQChar patternsDivider = '/';
@@ -621,21 +625,48 @@ protected:
/**
Strings that encode the match-controlling properties
- @property criteria is a string which encodes the match-controlling
+ @property Criteria is a string which encodes the match-controlling
@properties described above. It has the format ^([wWrR])(.+). The
leading character's case determines @property isCaseInsensitive and
its value determines @property isRegex (rR: TRUE, wW: FALSE).
Remainder of string is a @property patternsDivider separated list of
match patterns that determines the content of @property patternList.
- @property criteria_Default encodes the traditional unix-style
- hidden file matching of so-called dotfiles.
-
+ @property criteriaLegacy encodes the traditional unix-style
+ hidden file matching of so-called dotfiles. It is default value
+ of @property Criteria unless overridden.
*/
- TQString criteria;
- static constexpr const char * criteria_Default = "w.*";
+ TQString Criteria;
+ static constexpr const char * criteriaLegacy = "w.*";
+
+ // Default Criteria setting location in kdeglobals
+ static constexpr const char * globalSettingsGroup = "General";
+ static constexpr const char * globalSettingsKey = "globalHiddenFileSpec";
};
+/************
+ *
+ * Declare a common application-independent instance of the hidden file
+ * matcher class. This is implemented as a singleton class in that there
+ * will no more than ONE instance of it.
+ */
+
+class TDEIO_EXPORT CommonHiddenFileMatcher {
+public:
+ /**
+ @return @property matcher , a pointer to the common hidden file
+ matcher object. Object will be automatically created on first call.
+ */
+ static HiddenFileMatcher* getMatcher();
+
+private:
+ // Pointer to the single instance of the common hidden file matcher object
+ static HiddenFileMatcher* matcher;
+ // Private constructors
+ CommonHiddenFileMatcher() {}
+ CommonHiddenFileMatcher(const CommonHiddenFileMatcher&);
+ CommonHiddenFileMatcher& operator=(const CommonHiddenFileMatcher&);
+};
}
#endif
diff --git a/tdeio/tdeio/hidden-file-dialog.cpp b/tdeio/tdeio/hidden-file-dialog.cpp
index 9d0d0637..c20c9333 100644
--- a/tdeio/tdeio/hidden-file-dialog.cpp
+++ b/tdeio/tdeio/hidden-file-dialog.cpp
@@ -6,23 +6,39 @@
TDEIO::Hidden_Files_Dialog::Hidden_Files_Dialog(
TQStringList initPatternList,
bool initPatternIsRegex,
- bool initPatternIsCaseInsensitive
+ bool initPatternIsCaseInsensitive,
+ TQString forWhom
)
{
// Initialize our "output" variables
patternList.clear();
patternIsRegex = false;
patternIsCaseInsensitive = false;
+ dialogResult = TDEIO::HiddenFileMatcher::criteriaApplied;
setModal( TRUE );
setCaption( i18n( "Define Hidden File" ) );
// Create main layout and subordinate grid to position the widgets
+
TQHBoxLayout *topLayout = new TQHBoxLayout( this, 10 );
TQGridLayout *grid = new TQGridLayout( 0, 2 ); // 2 wide and autodetect number of rows
topLayout->addLayout( grid, 1 );
int gridrow = 1;
+ //=== Set up dialog title ===//
+
+ TQString titleGeneral = i18n( "Define 'Hidden' files for" ) ;
+ setCaption( titleGeneral + " " + forWhom );
+ TQLabel *dialogTitle = new TQLabel( this );
+ dialogTitle->setText( "<b>" + titleGeneral + "<br>" + forWhom );
+ dialogTitle->setFrameStyle( TQFrame::Box | TQFrame::Plain );
+ dialogTitle->setAlignment( TQt::AlignHCenter | TQt::AlignVCenter );
+ grid->addMultiCellWidget( dialogTitle, gridrow, gridrow, 0, 1 );
+ gridrow++;
+
+ //=== Set up match pattern edit boxes ===/
+
TQLabel *patterns_label = new TQLabel( this );
patterns_label->setText( i18n( "Hidden File Match Patterns" ) );
patterns_label->setAlignment( TQt::AlignHCenter );
@@ -52,6 +68,8 @@ TDEIO::Hidden_Files_Dialog::Hidden_Files_Dialog(
}
le_Patterns[first_empty_editbox]->setFocus();
+ //=== Set up match option check boxes ===//
+
// Create a group of check boxes
bg_Options = new TQButtonGroup( this, "checkGroup" );
bg_Options->setTitle( i18n( "Hidden File Match Options" ) );
@@ -76,6 +94,8 @@ TDEIO::Hidden_Files_Dialog::Hidden_Files_Dialog(
TQToolTip::add( cb_patternIsCaseInsensitive, i18n( "Case insensitive" ) );
vbox->addWidget( cb_patternIsCaseInsensitive );
+ //=== Set up final dispostion radio buttons ===//
+
// Create a group of radio buttons
bg_Disposition = new TQButtonGroup( this, "radioGroup" );
bg_Disposition->setTitle( i18n( "Disposition of Match Criteria:" ) );
@@ -87,20 +107,20 @@ TDEIO::Hidden_Files_Dialog::Hidden_Files_Dialog(
TQVBoxLayout *vbox2 = new TQVBoxLayout(bg_Disposition, 10);
vbox2->addSpacing( bg_Disposition->fontMetrics().height() );
- // Set up first radio button
+ // Set up radio button 0
rb_Disposition = new TQRadioButton( bg_Disposition );
+ rb_Disposition->setText( i18n( "&Apply but do not save" ) );
rb_Disposition->setChecked( TRUE );
- rb_Disposition->setText( i18n( "Apply and &save as default" ) );
- TQToolTip::add( rb_Disposition, i18n( "Changes will be applied and saved to disk" ) );
+ TQToolTip::add( rb_Disposition, i18n( "Changes will be applied temporarily" ) );
vbox2->addWidget( rb_Disposition );
- // Set up second radio button
+ // Set up radio button 1
rb_Disposition = new TQRadioButton( bg_Disposition );
- rb_Disposition->setText( i18n( "&Apply but do not save" ) );
- TQToolTip::add( rb_Disposition, i18n( "Changes will be applied temporarily" ) );
+ rb_Disposition->setText( i18n( "Apply and &save as default" ) );
+ TQToolTip::add( rb_Disposition, i18n( "Changes will be applied and saved to disk" ) );
vbox2->addWidget( rb_Disposition );
- // Set up third radio button
+ // Set up radio button 2
rb_Disposition = new TQRadioButton( bg_Disposition );
rb_Disposition->setText( i18n( "Ignore and restore &default" ) );
TQToolTip::add( rb_Disposition, i18n( "Changes will be ignored and saved default restored" ) );
@@ -108,7 +128,7 @@ TDEIO::Hidden_Files_Dialog::Hidden_Files_Dialog(
connect( bg_Disposition, SIGNAL(clicked(int)), SLOT(setExitDisposition(int)) );
- // Set up dialog exit buttons
+ //=== Set up dialog exit buttons ===/
pb_OK = new TQPushButton( this, "pb_OK" );
pb_OK->setDefault( FALSE );
@@ -125,18 +145,37 @@ TDEIO::Hidden_Files_Dialog::Hidden_Files_Dialog(
grid->addWidget( pb_Cancel, gridrow, 1 );
- connect( pb_OK, SIGNAL( clicked() ), this, SLOT( exitOK() ) );
+ connect( pb_OK, SIGNAL( clicked() ), this, SLOT( exitOK() ) );
connect( pb_Cancel, SIGNAL( clicked() ), this, SLOT( exitCancel() ) );
}
+//=== Dialog event handlers ===/
+
+bool TDEIO::Hidden_Files_Dialog::event( TQEvent * e ) {
+ if ( e->type() != TQEvent::KeyPress ) {
+ TQKeyEvent * ke = (TQKeyEvent*) e;
+ if ( ke->key() == Key_Escape ) {
+ ke->accept();
+ exitCancel();
+ return TRUE;
+ }
+ else if ( ke->key() == Key_Return ) {
+ ke->accept();
+ exitOK();
+ return TRUE;
+ }
+ }
+ return TQWidget::event( e );
+}
+
void TDEIO::Hidden_Files_Dialog::setExitDisposition(int buttonNum )
{
switch( buttonNum ) {
case 0:
- dialogResult = TDEIO::HiddenFileMatcher::saveCriteria;
+ dialogResult = TDEIO::HiddenFileMatcher::criteriaApplied;
break;
case 1:
- dialogResult = TDEIO::HiddenFileMatcher::criteriaApplied;
+ dialogResult = TDEIO::HiddenFileMatcher::saveCriteria;
break;
case 2:
dialogResult = TDEIO::HiddenFileMatcher::reloadCriteria;
@@ -144,6 +183,8 @@ void TDEIO::Hidden_Files_Dialog::setExitDisposition(int buttonNum )
}
}
+//=== Dialog exit functions ===//
+
void TDEIO::Hidden_Files_Dialog::exitOK()
{
if ( dialogResult > TDEIO::HiddenFileMatcher::criteriaUnchanged ) {
@@ -166,6 +207,8 @@ void TDEIO::Hidden_Files_Dialog::exitCancel()
close();
}
+//=== Object property accessors ===//
+
int TDEIO::Hidden_Files_Dialog::result()
{
return dialogResult;
@@ -186,5 +229,4 @@ TQStringList TDEIO::Hidden_Files_Dialog::getPatternList()
return patternList;
}
-
#include "hidden-file-dialog.moc"
diff --git a/tdeio/tdeio/hidden-file-dialog.h b/tdeio/tdeio/hidden-file-dialog.h
index 216b1e75..97ab1d76 100644
--- a/tdeio/tdeio/hidden-file-dialog.h
+++ b/tdeio/tdeio/hidden-file-dialog.h
@@ -25,7 +25,8 @@ public:
Hidden_Files_Dialog(
TQStringList initPatternList,
bool initPatternIsRegex,
- bool initPatternIsCaseInsensitive
+ bool initPatternIsCaseInsensitive,
+ TQString forWhom = TQString("Current Application")
);
int result();
@@ -33,6 +34,10 @@ public:
bool isPatternRegex();
bool isPatternCaseInsensitive();
+protected:
+
+ bool event( TQEvent * e );
+
private slots:
void setExitDisposition(int buttonNum );
@@ -62,7 +67,7 @@ private:
bool patternIsRegex;
bool patternIsCaseInsensitive;
- int dialogResult = TDEIO::HiddenFileMatcher::criteriaUnchanged;
+ int dialogResult = TDEIO::HiddenFileMatcher::saveCriteria;
};
diff --git a/tdeio/tdeio/kdirlister.cpp b/tdeio/tdeio/kdirlister.cpp
index 01af072d..d3722b12 100644
--- a/tdeio/tdeio/kdirlister.cpp
+++ b/tdeio/tdeio/kdirlister.cpp
@@ -1907,8 +1907,8 @@ void KDirListerCache::printDebug()
KDirLister::KDirLister( bool _delayedMimeTypes )
{
kdDebug(7003) << "+KDirLister" << endl;
-
d = new KDirListerPrivate;
+
matcher = new TDEIO::HiddenFileMatcher;
d->complete = true;
d->delayedMimeTypes = _delayedMimeTypes;
@@ -2123,8 +2123,7 @@ void KDirLister::emitChanges()
continue;
}
- (*kit)->setHidden( matcher );
- if ( (*kit)->isHidden() )
+ if ( (*kit)->isHidden( matcher ) )
{
if ( d->changes & HIDDEN_FILES )
{
@@ -2293,8 +2292,7 @@ bool KDirLister::matchesFilter( const KFileItem *item ) const
if ( item->text() == dotdot )
return false;
- const_cast<KFileItem*>(item)->setHidden( matcher );
- if ( !d->isShowingHiddenFiles && item->isHidden() )
+ if ( !d->isShowingHiddenFiles && const_cast<KFileItem*>(item)->isHidden( matcher ) )
return false;
if ( item->isDir() || d->lstFilters.isEmpty() )
diff --git a/tdeio/tdeio/kdirlister.h b/tdeio/tdeio/kdirlister.h
index cf0c4107..1d8abd96 100644
--- a/tdeio/tdeio/kdirlister.h
+++ b/tdeio/tdeio/kdirlister.h
@@ -174,7 +174,7 @@ public:
* @see showingHiddenFiles()
* @see also description of @property matcher
*/
- virtual void setShowingHiddenFiles( bool show );
+ virtual void setShowingHiddenFiles( bool _showHiddenFiles );
/**
* @deprecated use showingHiddenFiles()
@@ -648,10 +648,10 @@ public:
/**
* Pointer to object that encapsulates criteria for determining whether
- * or not a file is "hidden". There is one such object per KDirlister.
- * Object is passed to KFileItem::setHidden() so is can determine
- * whether or not an individual filesystem object is "hidden" by
- * current matcher criteria.
+ * or not a file is "hidden". There is one such object per KDirLister.
+ * Object may be passed to KFileItem::setHidden(...) so that function
+ * can determine whether or not an individual filesystem object is
+ * "hidden" by current matcher criteria.
*/
TDEIO::HiddenFileMatcher *matcher;
};
diff --git a/tdeio/tdeio/tdefilefilter.h b/tdeio/tdeio/tdefilefilter.h
index a91504cf..8750bc02 100644
--- a/tdeio/tdeio/tdefilefilter.h
+++ b/tdeio/tdeio/tdefilefilter.h
@@ -60,22 +60,22 @@ class TDEIO_EXPORT KSimpleFileFilter : public KFileFilter
{
public:
/**
- * Creates a new filter. By default, it filters only hidden dot files
+ * Creates a new filter. By default, it filters only hidden files
* and "." and "..".
*/
KSimpleFileFilter();
virtual ~KSimpleFileFilter();
/**
- * Enable or disable filtering hidden dot files.
+ * Enable or disable filtering hidden files.
* This option is enabled by default.
- * @param filter true to enable filtering dot files, false to
+ * @param filter true to enable filtering hidden files, false to
* disable
* @see filterHiddenFiles
*/
virtual void setFilterHiddenFiles( bool filter );
/**
- * Checks whether filtering dot files is enabled.
+ * Checks whether filtering hidden files is enabled.
* This option is enabled by default.
* @return true if filtering is enabled, false otherwise
* @see setFilterHiddenFiles
diff --git a/tdeio/tdeio/tdefileitem.cpp b/tdeio/tdeio/tdefileitem.cpp
index 32faa079..041b13c4 100644
--- a/tdeio/tdeio/tdefileitem.cpp
+++ b/tdeio/tdeio/tdefileitem.cpp
@@ -76,7 +76,6 @@ KFileItem::KFileItem( const TDEIO::UDSEntry& _entry, const KURL& _url,
m_bLink( false ),
m_bIsLocalURL( _url.isLocalFile() ),
m_bMimeTypeKnown( false ),
- m_bHiddenFile( false ),
m_hidden( Auto ),
d(0)
{
@@ -96,7 +95,6 @@ KFileItem::KFileItem( mode_t _mode, mode_t _permissions, const KURL& _url, bool
m_bLink( false ),
m_bIsLocalURL( _url.isLocalFile() ),
m_bMimeTypeKnown( false ),
- m_bHiddenFile( false ),
m_hidden( Auto ),
d(0)
{
@@ -114,7 +112,6 @@ KFileItem::KFileItem( const KURL &url, const TQString &mimeType, mode_t mode )
m_bLink( false ),
m_bIsLocalURL( url.isLocalFile() ),
m_bMimeTypeKnown( !mimeType.isEmpty() ),
- m_bHiddenFile( false ),
m_hidden( Auto ),
d(0)
{
@@ -207,6 +204,9 @@ void KFileItem::init( bool _determineMimeTypeOnDemand )
// otherwise, determineMimeType will be able to do better.
m_bMimeTypeKnown = (!_determineMimeTypeOnDemand) || accurate;
}
+
+ // Determine if file is hidden per global HiddenFileMatcher, may be overriden later
+ isHidden(nullptr); // sets m_bHiddenByMatcher
}
void KFileItem::readUDSEntry( bool _urlIsDirectory )
@@ -642,7 +642,6 @@ int KFileItem::overlays() const
&& !isReadable())
_state |= TDEIcon::LockOverlay;
- // kdWarning() << "KFileItem::overlays calling isHidden()" << endl;
if ( isHidden() )
_state |= TDEIcon::HiddenOverlay;
@@ -835,26 +834,27 @@ bool KFileItem::isWritable() const
}
-void KFileItem::setHidden( TDEIO::HiddenFileMatcher *matcher )
-{
- if ( !m_url.isEmpty() )
- m_bHiddenFile = matcher->match( m_url.fileName() );
- else // should never happen
- m_bHiddenFile = matcher->match( m_strName );
-}
-
-
bool KFileItem::isHidden() const
{
if ( m_hidden != Auto )
return m_hidden == Hidden;
- return m_bHiddenFile;
+ return m_bHiddenByMatcher;
+}
- /* FIXME: Who calls this function? We are aware of the following callers:
+bool KFileItem::isHidden(TDEIO::HiddenFileMatcher *matcher )
+{
+ if ( matcher == nullptr ) { // Caller wants us to use the global matcher
+ matcher = TDEIO::CommonHiddenFileMatcher::getMatcher();
+ }
- - tdeio/tdeio/kdirlister.cpp/KDirLister::emitChanges()
- - tdeio/tdeio/kdirlister.cpp/KDirLister::matchesFilter()
- */
+ // Re-evaluate file's "hideability" using the passed matcher and record
+ // that for future calls to this function where no matcher is passed
+ if ( !m_url.isEmpty() )
+ m_bHiddenByMatcher = matcher->match( m_url.fileName() );
+ else // should never happen
+ m_bHiddenByMatcher = matcher->match( m_strName );
+
+ return isHidden();
}
bool KFileItem::isDir() const
diff --git a/tdeio/tdeio/tdefileitem.h b/tdeio/tdeio/tdefileitem.h
index 24d6220f..e9c8daeb 100644
--- a/tdeio/tdeio/tdefileitem.h
+++ b/tdeio/tdeio/tdefileitem.h
@@ -229,22 +229,14 @@ public:
bool isWritable() const;
/**
- * Checks whether the file is hidden.
- * @return true if the file is hidden.
+ * Checks whether the file is hidden. If @param matcher is passed,
+ * the file's name is checked against it to determine if it meets
+ * the criteria to be considered "hidden" (i.e. hide-able) and
+ * and result is cached in @property m_bHiddenByMatcher.
*/
+ bool isHidden( TDEIO::HiddenFileMatcher *matcher );
bool isHidden() const;
- /**
- * Determines whether or not a file is hidden (i.e. hide-able)
- by the HiddenFileMatcher standards pointed to by @param matcher.
- Sets @property m_bHiddenFile accordingly.
- */
- void setHidden( TDEIO::HiddenFileMatcher *matcher );
-
- /**
- * Returns the link destination if isLink() == true.
- * @return the link destination. TQString::null if the item is not a link
- */
TQString linkDest() const;
/**
@@ -675,12 +667,12 @@ private:
bool m_bMimeTypeKnown:1;
/**
- * True if file is "hidden" (i.e. hide-able)
- by current HiddenFileMatcher standards
+ * Caches result of most recent call to HiddenFileMatcher.
+ True if file is "hidden" (i.e. hide-able), false otherwise.
*/
- bool m_bHiddenFile:1;
+ bool m_bHiddenByMatcher:1;
- // Auto: check leading dot.
+ // Auto: always check if hidden.
enum { Auto, Hidden, Shown } m_hidden:3;
// For special case like link to dirs over FTP