mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 14:29:54 +08:00
restore last active item in directory tree after switching notebook
This commit is contained in:
parent
de4e5fef8e
commit
c2c70368da
@ -129,8 +129,27 @@ void VDirectoryTree::updateDirectoryTree()
|
|||||||
|
|
||||||
updateDirectoryTreeOne(item, 1);
|
updateDirectoryTreeOne(item, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!restoreCurrentItem()) {
|
||||||
setCurrentItem(topLevelItem(0));
|
setCurrentItem(topLevelItem(0));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VDirectoryTree::restoreCurrentItem()
|
||||||
|
{
|
||||||
|
qDebug() << m_notebook << m_notebookCurrentDirMap;
|
||||||
|
auto it = m_notebookCurrentDirMap.find(m_notebook);
|
||||||
|
if (it != m_notebookCurrentDirMap.end()) {
|
||||||
|
bool rootDirectory;
|
||||||
|
QTreeWidgetItem *item = findVDirectory(it.value(), rootDirectory);
|
||||||
|
if (item) {
|
||||||
|
setCurrentItem(item);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void VDirectoryTree::updateDirectoryTreeOne(QTreeWidgetItem *p_parent, int depth)
|
void VDirectoryTree::updateDirectoryTreeOne(QTreeWidgetItem *p_parent, int depth)
|
||||||
{
|
{
|
||||||
@ -401,7 +420,10 @@ void VDirectoryTree::currentDirectoryItemChanged(QTreeWidgetItem *currentItem)
|
|||||||
emit currentDirectoryChanged(NULL);
|
emit currentDirectoryChanged(NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emit currentDirectoryChanged(getVDirectory(currentItem));
|
|
||||||
|
QPointer<VDirectory> dir = getVDirectory(currentItem);
|
||||||
|
m_notebookCurrentDirMap[m_notebook] = dir;
|
||||||
|
emit currentDirectoryChanged(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VDirectoryTree::editDirectoryInfo()
|
void VDirectoryTree::editDirectoryInfo()
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <QHash>
|
||||||
#include "vdirectory.h"
|
#include "vdirectory.h"
|
||||||
#include "vnotebook.h"
|
#include "vnotebook.h"
|
||||||
#include "vnavigationmode.h"
|
#include "vnavigationmode.h"
|
||||||
@ -77,12 +78,15 @@ private:
|
|||||||
void expandItemTree(QTreeWidgetItem *p_item);
|
void expandItemTree(QTreeWidgetItem *p_item);
|
||||||
QList<QTreeWidgetItem *> getVisibleItems() const;
|
QList<QTreeWidgetItem *> getVisibleItems() const;
|
||||||
QList<QTreeWidgetItem *> getVisibleChildItems(const QTreeWidgetItem *p_item) const;
|
QList<QTreeWidgetItem *> getVisibleChildItems(const QTreeWidgetItem *p_item) const;
|
||||||
|
bool restoreCurrentItem();
|
||||||
|
|
||||||
VNote *vnote;
|
VNote *vnote;
|
||||||
QPointer<VNotebook> m_notebook;
|
QPointer<VNotebook> m_notebook;
|
||||||
QVector<QPointer<VDirectory> > m_copiedDirs;
|
QVector<QPointer<VDirectory> > m_copiedDirs;
|
||||||
VEditArea *m_editArea;
|
VEditArea *m_editArea;
|
||||||
|
|
||||||
|
QHash<VNotebook *, VDirectory *> m_notebookCurrentDirMap;
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
QAction *newRootDirAct;
|
QAction *newRootDirAct;
|
||||||
QAction *newSiblingDirAct;
|
QAction *newSiblingDirAct;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user