Set up konqueror interface to TDEIO:HiddenFileMatcher object:

(1) Establish "HiddenFileSpec" key to be stored in a konq*viewrc config file.
  (2) Establish menu access for modifying key in listview (iconview TBD).

The "HiddenFileSpec" key (under [Settings] in config/konqlistviewrc) should contain
a string specifying what constitutes a hidden file. The string should conform to
the syntax described in latest commit message for corresponding tdelibs PR # 163.

Testing at this point will require manually editing the configuration file.

KonqListView::slotChangeHiddenFileMatcher will eventually call a dialog through
which a user can query and modify the specification for how "hidden" files are to
be identified. Currently it only demonstrates access to HiddenFileMatcher methods.

Signed-off-by: Vincent Reher <tde@4reher.org>
Vincent Reher 2 years ago
parent 11c4316fbd
commit 2dd3bfd009

@ -23,6 +23,7 @@
<Action name="modesmall"/>
</Menu>
<Separator/>
<Action name="change_hidden_file_matcher"/>
<Action name="show_dot"/>
<Menu name="sort"><text>&amp;Sort</text>
<Action name="order_unicode_based"/>

@ -23,6 +23,7 @@
<Action name="modesmall"/>
</Menu>
<Separator/>
<Action name="change_hidden_file_matcher"/>
<Action name="show_dot"/>
<Menu name="sort"><text>&amp;Sort</text>
<Action name="order_unicode_based"/>

@ -477,6 +477,110 @@ void KonqListView::newIconSize( int size )
m_pListView->updateListContents();
}
void KonqListView::slotChangeHiddenFileMatcher()
{
/* Temporarily
*/
TDEIO::HiddenFileMatcher* matcher = TDEIO::HiddenFileMatcher::getInstance();
// Someday we will do this and it will actually accomplish what we want:
TQString updated_criteria = matcher->updateCriteria( "Define hidden for listview" );
if ( matcher->setCriteria( updated_criteria ) ) {
m_pProps->setHiddenFileSpec ( updated_criteria );
}
else {
kdWarning()
<< "Failed to update critera - bad input? <"
<< updated_criteria << ">"
<< endl;
}
// Until the UI dialog is ready, we'll just do a demonstration
TQString stored_criteria = m_pProps->hiddenFileSpec();
TQString stored_criteria_saved = stored_criteria;
TQString active_criteria = matcher->getCriteria();
kdWarning()
<< "Hidden file match criteria before test updates:" << endl
<< " Config: <" << stored_criteria << "> (assuming that this is a good match criteria)" << endl
<< " Active: <" << active_criteria << "> (should be same because of KonqListview initialization)" << endl
;
// What happens with good update?
updated_criteria = "R^good/criteria$"; // simulation of output of TBD UI dialog:
// TQString updated_criteria = Get_HiddenFileCriteri_Dialog(stored_criteria);
if ( matcher->setCriteria( updated_criteria ) ) {
m_pProps->setHiddenFileSpec ( updated_criteria );
}
else {
kdWarning()
<< "Failed to update critera - bad input? <"
<< updated_criteria << ">"
<< endl;
}
active_criteria = matcher->getCriteria();
stored_criteria = m_pProps->hiddenFileSpec();
kdWarning()
<< "Hidden file match criteria after test update 1:" << endl
<< " Update: <" << updated_criteria << ">" << endl
<< " Active: <" << active_criteria << ">" << endl
<< " Config: <" << stored_criteria << ">" << endl
;
// What happens with bad update?
updated_criteria = "^bad/need/leading/W_w_R_r";
if ( matcher->setCriteria( updated_criteria ) ) {
m_pProps->setHiddenFileSpec ( updated_criteria );
}
else {
kdWarning()
<< "Failed to update critera - bad input? <"
<< updated_criteria << ">"
<< endl;
}
active_criteria = matcher->getCriteria();
stored_criteria = m_pProps->hiddenFileSpec();
kdWarning()
<< "Hidden file match criteria after test update 2:" << endl
<< " Update: <" << updated_criteria << ">" << endl
<< " Active: <" << active_criteria << ">" << endl
<< " Config: <" << stored_criteria << ">" << endl
;
// Restore the original (and hopefully valid) match criteria
updated_criteria = stored_criteria_saved;
if ( matcher->setCriteria( updated_criteria ) ) {
m_pProps->setHiddenFileSpec ( updated_criteria );
}
else {
kdWarning()
<< "Failed to update critera - bad input? <"
<< updated_criteria << ">"
<< endl;
}
active_criteria = matcher->getCriteria();
stored_criteria = m_pProps->hiddenFileSpec();
kdWarning()
<< "Hidden file match criteria after restoring original criteria:" << endl
<< " Update: <" << updated_criteria << ">" << endl
<< " Active: <" << active_criteria << ">" << endl
<< " Config: <" << stored_criteria << ">" << endl
;
return;
}
void KonqListView::slotShowDot()
{
m_pProps->setShowingDotFiles( m_paShowDot->isChecked() );
@ -929,7 +1033,23 @@ void KonqListView::setupActions()
m_paRenameMovePrev->setToolTip( i18n("Complete rename operation and move the previous item"));
m_paRenameMovePrev->setEnabled(false);
m_paShowDot = new TDEToggleAction( i18n( "Show &Hidden Files" ), 0, this, TQT_SLOT( slotShowDot() ), actionCollection(), "show_dot" );
m_paChangeHiddenFileMatcher = new TDEAction( i18n( "Change &Hidden File Matcher" ), CTRL+SHIFT+Key_H, this,
TQT_SLOT( slotChangeHiddenFileMatcher() ), actionCollection(), "change_hidden_file_matcher" );
/* Temporarily
*/
// Initialize hidden file matcher criteria
TDEIO::HiddenFileMatcher* matcher = TDEIO::HiddenFileMatcher::getInstance();
// This is probably the 1st call that creates the central instance
matcher->setCriteria( m_pProps->hiddenFileSpec() );
/* Do we want or need to display current match criteria in menu???
Sample from konq_iconview.cpp::KonqKfmIconView::KonqKfmIconView
//enable menu item representing the saved sorting criterion
TQString sortcrit = KonqIconViewFactory::defaultViewProps()->sortCriterion();
TDERadioAction *sort_action = tqt_dynamic_cast<TDERadioAction *>(actionCollection()->action(sortcrit.latin1()));
if(sort_action!=NULL) sort_action->activate();
*/
m_paShowDot = new TDEToggleAction( i18n( "Show &Hidden Files" ), CTRL+Key_H, this, TQT_SLOT( slotShowDot() ), actionCollection(), "show_dot" );
// m_paShowDot->setCheckedState(i18n("Hide &Hidden Files"));
m_paCaseInsensitive = new TDEToggleAction(i18n("Case Insensitive Sort"), 0, this, TQT_SLOT(slotCaseInsensitive()),actionCollection(), "sort_caseinsensitive" );

@ -111,6 +111,7 @@ protected slots:
void slotCaseInsensitive();
void slotSelectionChanged();
void slotChangeHiddenFileMatcher();
void slotShowDot();
//this is called if a item in the submenu is toggled
//it saves the new configuration according to the menu items
@ -188,6 +189,7 @@ private:
TDEToggleAction *m_paCaseInsensitive;
TDEAction *m_paChangeHiddenFileMatcher;
TDEToggleAction *m_paShowDot;
TDEToggleAction *m_paShowTime;
TDEToggleAction *m_paShowType;

@ -88,14 +88,18 @@ void KonqListViewItem::updateContents()
bool m_groupDirectoriesFirst = m_pListViewWidget->props()->isDirsFirst();
bool m_groupHiddenFirst = m_pListViewWidget->props()->isHiddenFirst();
// The default TDE order is: .dir (0), dir (1), .file (2), file (3)
// The default TDE display order is:
// hidden-dir (0), non-hidden-dir (1), hidden-file (2), non-hidden-file (3)
if ( m_groupDirectoriesFirst )
sortChar = S_ISDIR( m_fileitem->mode() ) ? 1 : 3;
else
sortChar = 3;
if ( m_groupHiddenFirst && TDEIO::fileIsHidden(m_fileitem->text()) )
/* Temporarily
*/
TDEIO::HiddenFileMatcher* matcher = TDEIO::HiddenFileMatcher::getInstance();
if ( m_groupHiddenFirst && matcher->match(m_fileitem->text()) )
--sortChar;
//now we have the first column, so let's do the rest

@ -12,6 +12,7 @@
</Menu>
</Menu>
<Menu name="view"><text>&amp;View</text>
<Action name="change_hidden_file_matcher"/>
<Action name="show_dot" />
<Menu name="sort"><text>&amp;Sort</text>
<Action name="order_unicode_based"/>

@ -23,6 +23,7 @@
<Action name="modesmall"/>
</Menu>
<Separator/>
<Action name="change_hidden_file_matcher"/>
<Action name="show_dot"/>
<Menu name="sort"><text>&amp;Sort</text>
<Action name="order_unicode_based"/>

@ -74,6 +74,7 @@ struct KonqPropsView::Private
bool hiddenfirst:1;
bool descending:1;
TQString sortcriterion;
TQString hiddenfilecriteria;
};
KonqPropsView::KonqPropsView( TDEInstance * instance, KonqPropsView * defaultProps )
@ -98,6 +99,7 @@ KonqPropsView::KonqPropsView( TDEInstance * instance, KonqPropsView * defaultPro
d->dirsfirst = config->readBoolEntry( "SortDirsFirst", true );
d->hiddenfirst = config->readBoolEntry( "SortHiddenFirst", true );
d->descending = config->readBoolEntry( "SortDescending", false );
d->hiddenfilecriteria = config->readEntry( "HiddenFileSpec", "w.*" ); // default is wildcard for dotfiles
m_bShowDot = config->readBoolEntry( "ShowDotFiles", false );
m_bShowDirectoryOverlays = config->readBoolEntry( "ShowDirectoryOverlays", false );
m_bShowFreeSpaceOverlays = config->readBoolEntry( "ShowFreeSpaceOverlays", true );
@ -164,6 +166,11 @@ bool KonqPropsView::isDescending() const
return d->descending;
}
const TQString& KonqPropsView::hiddenFileSpec() const
{
return d->hiddenfilecriteria;
}
TDEConfigBase * KonqPropsView::currentConfig()
{
if ( !m_currentConfig )
@ -388,6 +395,23 @@ void KonqPropsView::setDescending( bool descend)
}
}
void KonqPropsView::setHiddenFileSpec( const TQString &criteria )
{
kdDebug(1203) << "KonqPropsView::setHiddenFileSpec " << criteria << endl;
d->hiddenfilecriteria = criteria;
if ( m_defaultProps && !m_bSaveViewPropertiesLocally ) {
kdDebug(1203) << "Saving in default properties" << endl;
m_defaultProps->setHiddenFileSpec( criteria );
}
else if (currentConfig())
{
kdDebug(1203) << "Saving in current config" << endl;
TDEConfigGroupSaver cgs(currentConfig(), currentGroup());
currentConfig()->writeEntry( "HiddenFileSpec", d->hiddenfilecriteria );
currentConfig()->sync();
}
}
void KonqPropsView::setShowingDotFiles( bool show )
{
kdDebug(1203) << "KonqPropsView::setShowingDotFiles " << show << endl;

@ -104,6 +104,9 @@ public:
void setDescending (bool descending);
bool isDescending() const;
void setHiddenFileSpec( const TQString &criteria );
const TQString& hiddenFileSpec() const;
void setShowingDotFiles( bool show );
bool isShowingDotFiles() const { return m_bShowDot; }
@ -188,6 +191,13 @@ private:
Private *d;
/**
* FIXME
*
* Why are some private class properties declared in the
* "Private" structure d in konq_propsview.cpp and not above?
*/
private:
KonqPropsView( const KonqPropsView & );
KonqPropsView();

Loading…
Cancel
Save