Skip to content

Commit

Permalink
Github Issue #204: Improved the logic for setting the vault root path…
Browse files Browse the repository at this point in the history
… for the navigation QTreeView. Only if the path is changed then the list of files are cleared from the recently opened list of files
  • Loading branch information
AngryFender committed Aug 20, 2024
1 parent ea6e2fd commit df1ebe2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
27 changes: 15 additions & 12 deletions views_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@ void ViewsHandler::initViews(Ui::MainWindow &ui)
initFontDefault();
}

void ViewsHandler::initTreeView(QString path)
bool ViewsHandler::initTreeView(QString path)
{
//ignore if the path is already set
if(modelTree.rootPath()==path){
return false;
}

modelTree.setReadOnly(false);
modelTree.setFilter(QDir::NoDotAndDotDot|QDir::AllEntries);
if(path.isEmpty()){
Expand All @@ -97,6 +102,7 @@ void ViewsHandler::initTreeView(QString path)
{
viewTree->setColumnHidden(column,true);
}
return true;
}

void ViewsHandler::initFontDefault()
Expand Down Expand Up @@ -504,11 +510,10 @@ void ViewsHandler::updateUiSettingsHandler(const QFont &font)
viewTextSearchTree->setFont(fontView);
settingsDialog->setFont(fontView);

initTreeView(vaultPath);
setVaultPath(vaultPath);

recentFilesList->clear();
recentFileCursorMap.clear();
if(initTreeView(vaultPath)){
recentFilesList->clear();
recentFileCursorMap.clear();
}
}

void ViewsHandler::fileSaveRawHandle()
Expand Down Expand Up @@ -686,12 +691,10 @@ QString ViewsHandler::setVaultPathHandler()
QStringList list = dialog.selectedFiles();
newPath = list.first();
}
initTreeView(newPath);
setVaultPath(newPath);

recentFilesList->clear();
recentFileCursorMap.clear();

if(initTreeView(newPath)){
recentFilesList->clear();
recentFileCursorMap.clear();
}
QSettings settings("Remini","Remini");
settings.setValue("VaultPath", newPath);

Expand Down
2 changes: 1 addition & 1 deletion views_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public slots:
void setVaultPath(QString& path);

void initViews(Ui::MainWindow &ui);
void initTreeView(QString path = NULL);
bool initTreeView(QString path = NULL);
void initFontDefault();
void initConnection();
void connectDocument();
Expand Down

0 comments on commit df1ebe2

Please sign in to comment.