Commit 0b2997ad authored by Markus Pister's avatar Markus Pister Committed by Christoph Cullmann
Browse files

CHANGELOG: Implemented Feature Request: Expand/Collapse all actions for items in the documents list

BUG: 360195

Patch by Markus Pister
parent 58d30687
......@@ -69,6 +69,14 @@ KateFileTree::KateFileTree(QWidget *parent): QTreeView(parent)
connect(m_filelistCloseDocument, SIGNAL(triggered()), this, SLOT(slotDocumentClose()));
m_filelistCloseDocument->setWhatsThis(i18n("Close the current document."));
m_filelistExpandRecursive = new QAction(QIcon::fromTheme(QLatin1String("view-list-tree")), i18nc("@action:inmenu", "Expand recursively"), this);
connect(m_filelistExpandRecursive, SIGNAL(triggered()), this, SLOT(slotExpandRecursive()));
m_filelistExpandRecursive->setWhatsThis(i18n("Expand the file list sub tree recursively."));
m_filelistCollapseRecursive = new QAction(QIcon::fromTheme(QLatin1String("view-list-tree")), i18nc("@action:inmenu", "Collapse recursively"), this);
connect(m_filelistCollapseRecursive, SIGNAL(triggered()), this, SLOT(slotCollapseRecursive()));
m_filelistCollapseRecursive->setWhatsThis(i18n("Collapse the file list sub tree recursively."));
m_filelistCloseOtherDocument = new QAction(QIcon::fromTheme(QLatin1String("document-close")), i18nc("@action:inmenu", "Close Other"), this);
connect(m_filelistCloseOtherDocument, SIGNAL(triggered()), this, SLOT(slotDocumentCloseOther()));
m_filelistCloseOtherDocument->setWhatsThis(i18n("Close other documents in this folder."));
......@@ -225,6 +233,8 @@ void KateFileTree::contextMenuEvent(QContextMenuEvent *event)
QMenu menu;
menu.addAction(m_filelistReloadDocument);
menu.addAction(m_filelistCloseDocument);
menu.addAction(m_filelistExpandRecursive);
menu.addAction(m_filelistCollapseRecursive);
if (isFile) {
menu.addAction(m_filelistCloseOtherDocument);
......@@ -337,6 +347,50 @@ void KateFileTree::slotDocumentClose()
KTextEditor::Editor::instance()->application()->closeDocuments(closingDocuments);
}
void KateFileTree::slotExpandRecursive()
{
if (! m_indexContextMenu.isValid()) {
return;
}
// Work list for DFS walk over sub tree
QList<QPersistentModelIndex> worklist = { m_indexContextMenu };
while (! worklist.isEmpty()) {
QPersistentModelIndex index = worklist.takeLast();
// Expand current item
expand(index);
// Append all children of current item
for (int i=0 ; i < model()->rowCount(index) ; ++i) {
worklist.append(index.child(i,0));
}
}
}
void KateFileTree::slotCollapseRecursive()
{
if (! m_indexContextMenu.isValid()) {
return;
}
// Work list for DFS walk over sub tree
QList<QPersistentModelIndex> worklist = { m_indexContextMenu };
while (! worklist.isEmpty()) {
QPersistentModelIndex index = worklist.takeLast();
// Expand current item
collapse(index);
// Prepend all children of current item
for (int i=0 ; i < model()->rowCount(index) ; ++i) {
worklist.append(index.child(i,0));
}
}
}
void KateFileTree::slotDocumentCloseOther()
{
QVariant v = model()->data(m_indexContextMenu.parent(), KateFileTreeModel::DocumentTreeRole);
......
......@@ -44,6 +44,8 @@ public:
public Q_SLOTS:
void slotDocumentClose();
void slotExpandRecursive();
void slotCollapseRecursive();
void slotDocumentCloseOther();
void slotDocumentReload();
void slotCopyFilename();
......@@ -88,6 +90,8 @@ private:
private:
QAction *m_filelistCloseDocument;
QAction *m_filelistExpandRecursive;
QAction *m_filelistCollapseRecursive;
QAction *m_filelistCloseOtherDocument;
QAction *m_filelistReloadDocument;
QAction *m_filelistCopyFilename;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment