Skip to content

Commit

Permalink
Refresh selection now support multi-selection
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromerobert committed Nov 17, 2019
1 parent d590a14 commit e4d350d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
21 changes: 14 additions & 7 deletions src/k4dirstat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/

#include "k4dirstat.h"
//#include "k4dirstatview.h"
#include "settings.h"

#include <QtGui/QDropEvent>
Expand Down Expand Up @@ -458,11 +457,11 @@ void k4dirstat::refreshAll() {
}

void k4dirstat::refreshSelected() {
if (!_treeView->selection())
return;

statusMsg(i18n("Refreshing selected subtree..."));
_treeView->refreshSelected();
auto sel = _treeView->tree()->selection();
for(auto it = sel.begin(); it != sel.end(); ++it)
if(!(*it)->isDotEntry())
_treeView->tree()->refresh(*it);
statusMsg(i18n("Ready."));
}

Expand Down Expand Up @@ -544,14 +543,23 @@ void k4dirstat::cleanupOpenWith() {
KRun::displayOpenWithDialog(urlList, this, false);
}

bool atLeastOneNotDotEntry(KDirTree * tree) {
auto sel = tree->selection();
for(auto it = sel.begin(); it != sel.end(); ++it) {
if((*it)->isDotEntry())
return false;
}
return true;
}

void k4dirstat::selectionChanged(KDirTree* tree) {
_fileRefreshSelected->setEnabled(atLeastOneNotDotEntry(tree));
if (tree->selection().size() == 1) {
// TODO: Most action have been written for single selection. We keep
// that logic until all actions have been ported to multi-selection.
KFileInfo * selection = tree->selection()[0];
_editCopy->setEnabled(true);
_reportMailToOwner->setEnabled(true);
_fileRefreshSelected->setEnabled(!selection->isDotEntry());
_cleanupOpenWith->setEnabled(!selection->isDotEntry());
_fileReadExcludedDir->setEnabled(selection->isExcluded());

Expand All @@ -565,7 +573,6 @@ void k4dirstat::selectionChanged(KDirTree* tree) {
} else {
_editCopy->setEnabled(false);
_reportMailToOwner->setEnabled(false);
_fileRefreshSelected->setEnabled(false);
_fileContinueReadingAtMountPoint->setEnabled(false);
_cleanupOpenWith->setEnabled(false);
statusMsg("");
Expand Down
10 changes: 0 additions & 10 deletions src/kdirtreeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,16 +594,6 @@ void KDirTreeView::refreshAll() {
}
}

void KDirTreeView::refreshSelected() {
if (_tree->root() && selection()) {
// Implicitly calling prepareReading() via the tree's startingReading()
// signal
_tree->refresh(selection());
}

logActivity(10);
}

void KDirTreeView::abortReading() {
_tree->abortReading();
}
Expand Down
5 changes: 0 additions & 5 deletions src/kdirtreeview.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,6 @@ public slots:
**/
void refreshAll();

/**
* Refresh (i.e. re-read from disk) the selected subtree.
**/
void refreshSelected();

/**
* Forcefully stop a running read process.
**/
Expand Down

0 comments on commit e4d350d

Please sign in to comment.