summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Reher <tde@4reher.org>2022-05-12 10:37:55 -0700
committerVincent Reher <tde@4reher.org>2022-05-12 10:39:56 -0700
commita42ea7e71115b256db2f1b160eefe91e9a0fd4de (patch)
tree6d7e979a988ca440d6bf03c3db442c10157b0b04
parentbba87770062ed2d32d60042b7a596077238b0691 (diff)
downloadtdebase-issue/270/tdebase.tar.gz
tdebase-issue/270/tdebase.zip
Set up konqueror interface to TDEIO:HiddenFileMatcher object:issue/270/tdebase
(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>
-rw-r--r--konqueror/listview/konq_detailedlistview.rc1
-rw-r--r--konqueror/listview/konq_infolistview.rc1
-rw-r--r--konqueror/listview/konq_listview.cpp122
-rw-r--r--konqueror/listview/konq_listview.h2
-rw-r--r--konqueror/listview/konq_listviewitems.cpp8
-rw-r--r--konqueror/listview/konq_textview.rc1
-rw-r--r--konqueror/listview/konq_treeview.rc1
-rw-r--r--libkonq/konq_propsview.cpp24
-rw-r--r--libkonq/konq_propsview.h10
9 files changed, 167 insertions, 3 deletions
diff --git a/konqueror/listview/konq_detailedlistview.rc b/konqueror/listview/konq_detailedlistview.rc
index 79059c6d4..591ffefa2 100644
--- a/konqueror/listview/konq_detailedlistview.rc
+++ b/konqueror/listview/konq_detailedlistview.rc
@@ -23,6 +23,7 @@
<Action name="modesmall"/>
</Menu>
<Separator/>
+ <Action name="change_hidden_file_matcher"/>
<Action name="show_dot"/>
<Menu name="sort"><text>Sort</text>
<Action name="group_directories_first"/>
diff --git a/konqueror/listview/konq_infolistview.rc b/konqueror/listview/konq_infolistview.rc
index 451eb5785..59dca8421 100644
--- a/konqueror/listview/konq_infolistview.rc
+++ b/konqueror/listview/konq_infolistview.rc
@@ -23,6 +23,7 @@
<Action name="modesmall"/>
</Menu>
<Separator/>
+ <Action name="change_hidden_file_matcher"/>
<Action name="show_dot"/>
<Menu name="sort"><text>Sort</text>
<Action name="group_directories_first"/>
diff --git a/konqueror/listview/konq_listview.cpp b/konqueror/listview/konq_listview.cpp
index f8307e84c..741617ffb 100644
--- a/konqueror/listview/konq_listview.cpp
+++ b/konqueror/listview/konq_listview.cpp
@@ -475,6 +475,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() );
@@ -927,7 +1031,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" );
diff --git a/konqueror/listview/konq_listview.h b/konqueror/listview/konq_listview.h
index 666ae7743..85f1be909 100644
--- a/konqueror/listview/konq_listview.h
+++ b/konqueror/listview/konq_listview.h
@@ -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
@@ -184,6 +185,7 @@ private:
TDEToggleAction *m_paCaseInsensitive;
+ TDEAction *m_paChangeHiddenFileMatcher;
TDEToggleAction *m_paShowDot;
TDEToggleAction *m_paShowTime;
TDEToggleAction *m_paShowType;
diff --git a/konqueror/listview/konq_listviewitems.cpp b/konqueror/listview/konq_listviewitems.cpp
index 31aefe6f7..0ec6fb259 100644
--- a/konqueror/listview/konq_listviewitems.cpp
+++ b/konqueror/listview/konq_listviewitems.cpp
@@ -87,14 +87,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
diff --git a/konqueror/listview/konq_textview.rc b/konqueror/listview/konq_textview.rc
index 20b20f451..ccc9a6f80 100644
--- a/konqueror/listview/konq_textview.rc
+++ b/konqueror/listview/konq_textview.rc
@@ -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>Sort</text>
<Action name="group_directories_first"/>
diff --git a/konqueror/listview/konq_treeview.rc b/konqueror/listview/konq_treeview.rc
index 711f267be..93e60f194 100644
--- a/konqueror/listview/konq_treeview.rc
+++ b/konqueror/listview/konq_treeview.rc
@@ -23,6 +23,7 @@
<Action name="modesmall"/>
</Menu>
<Separator/>
+ <Action name="change_hidden_file_matcher"/>
<Action name="show_dot"/>
<Menu name="sort"><text>Sort</text>
<Action name="group_directories_first"/>
diff --git a/libkonq/konq_propsview.cpp b/libkonq/konq_propsview.cpp
index af7a65eae..4a9a439a6 100644
--- a/libkonq/konq_propsview.cpp
+++ b/libkonq/konq_propsview.cpp
@@ -71,6 +71,7 @@ struct KonqPropsView::Private
bool dirsfirst:1;
bool descending:1;
TQString sortcriterion;
+ TQString hiddenfilecriteria;
};
KonqPropsView::KonqPropsView( TDEInstance * instance, KonqPropsView * defaultProps )
@@ -94,6 +95,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 );
@@ -155,6 +157,11 @@ bool KonqPropsView::isDescending() const
return d->descending;
}
+const TQString& KonqPropsView::hiddenFileSpec() const
+{
+ return d->hiddenfilecriteria;
+}
+
TDEConfigBase * KonqPropsView::currentConfig()
{
if ( !m_currentConfig )
@@ -363,6 +370,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;
diff --git a/libkonq/konq_propsview.h b/libkonq/konq_propsview.h
index 84ffcf029..51e0e64ac 100644
--- a/libkonq/konq_propsview.h
+++ b/libkonq/konq_propsview.h
@@ -99,6 +99,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; }
@@ -183,6 +186,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();