Update breadcrumbs when root directory changes.
This commit is contained in:
parent
a5bed9ed2c
commit
4cc43916cb
@ -68,7 +68,12 @@ SplitView {
|
|||||||
height: navigationView.height
|
height: navigationView.height
|
||||||
|
|
||||||
// Path to the directory opened in the file explorer.
|
// Path to the directory opened in the file explorer.
|
||||||
|
originalRootDirectory: root.projectDir
|
||||||
rootDirectory: root.projectDir
|
rootDirectory: root.projectDir
|
||||||
|
onRootDirectoryChanged: {
|
||||||
|
console.log(clideTreeView.rootDirectory)
|
||||||
|
breadCrumb.text = clideTreeView.rootDirectory
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,25 +14,21 @@ TreeView {
|
|||||||
|
|
||||||
property int lastIndex: -1
|
property int lastIndex: -1
|
||||||
|
|
||||||
required property string rootDirectory
|
required property string originalRootDirectory
|
||||||
|
property string rootDirectory
|
||||||
|
|
||||||
signal fileClicked(string filePath)
|
signal fileClicked(string filePath)
|
||||||
|
|
||||||
|
rootIndex: FileSystem.setDirectory(fileSystemTreeView.rootDirectory)
|
||||||
rootIndex: FileSystem.rootIndex
|
|
||||||
leftMargin: 5
|
leftMargin: 5
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
boundsMovement: Flickable.StopAtBounds
|
boundsMovement: Flickable.StopAtBounds
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
FileSystem.rootIndex = FileSystem.setDirectory(fileSystemTreeView.rootDirectory)
|
|
||||||
}
|
|
||||||
|
|
||||||
// The delegate represents a single entry in the filesystem.
|
// The delegate represents a single entry in the filesystem.
|
||||||
delegate: TreeViewDelegate {
|
delegate: TreeViewDelegate {
|
||||||
id: treeDelegate
|
id: treeDelegate
|
||||||
indentation: 6
|
indentation: 8
|
||||||
implicitWidth: fileSystemTreeView.width > 0 ? fileSystemTreeView.width : 250
|
implicitWidth: fileSystemTreeView.width > 0 ? fileSystemTreeView.width : 250
|
||||||
implicitHeight: 25
|
implicitHeight: 25
|
||||||
|
|
||||||
@ -125,7 +121,6 @@ TreeView {
|
|||||||
fileSystemTreeView.fileClicked(treeDelegate.filePath)
|
fileSystemTreeView.fileClicked(treeDelegate.filePath)
|
||||||
break;
|
break;
|
||||||
case Qt.RightButton:
|
case Qt.RightButton:
|
||||||
if (treeDelegate.hasChildren)
|
|
||||||
contextMenu.popup();
|
contextMenu.popup();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -136,16 +131,17 @@ TreeView {
|
|||||||
id: contextMenu
|
id: contextMenu
|
||||||
Action {
|
Action {
|
||||||
text: qsTr("Set as root index")
|
text: qsTr("Set as root index")
|
||||||
|
enabled: treeDelegate.hasChildren
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
console.log("Setting directory: " + treeDelegate.filePath)
|
console.log("Setting new root directory: " + treeDelegate.filePath)
|
||||||
FileSystem.rootIndex = FileSystem.setDirectory(treeDelegate.filePath)
|
fileSystemTreeView.rootDirectory = treeDelegate.filePath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action {
|
Action {
|
||||||
text: qsTr("Reset root index")
|
text: qsTr("Reset root index")
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
console.log("Reset root index")
|
console.log("Resetting root directory: " + fileSystemTreeView.originalRootDirectory)
|
||||||
FileSystem.rootIndex = FileSystem.setDirectory(fileSystemTreeView.rootDirectory)
|
fileSystemTreeView.rootDirectory = fileSystemTreeView.originalRootDirectory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,19 @@
|
|||||||
//
|
//
|
||||||
// SPDX-License-Identifier: GNU General Public License v3.0 or later
|
// SPDX-License-Identifier: GNU General Public License v3.0 or later
|
||||||
|
|
||||||
|
use cxx_qt_lib::{QModelIndex, QString};
|
||||||
|
use dirs;
|
||||||
|
use log::warn;
|
||||||
|
use std::fs;
|
||||||
|
use std::path::Path;
|
||||||
|
use syntect::easy::HighlightLines;
|
||||||
|
use syntect::highlighting::ThemeSet;
|
||||||
|
use syntect::html::{
|
||||||
|
IncludeBackground, append_highlighted_html_for_styled_line, start_highlighted_html_snippet,
|
||||||
|
};
|
||||||
|
use syntect::parsing::SyntaxSet;
|
||||||
|
use syntect::util::LinesWithEndings;
|
||||||
|
|
||||||
#[cxx_qt::bridge]
|
#[cxx_qt::bridge]
|
||||||
pub mod qobject {
|
pub mod qobject {
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
@ -21,7 +34,6 @@ pub mod qobject {
|
|||||||
#[qml_element]
|
#[qml_element]
|
||||||
#[qml_singleton]
|
#[qml_singleton]
|
||||||
#[qproperty(QString, file_path, cxx_name = "filePath")]
|
#[qproperty(QString, file_path, cxx_name = "filePath")]
|
||||||
#[qproperty(QModelIndex, root_index, cxx_name = "rootIndex")]
|
|
||||||
type FileSystem = super::FileSystemImpl;
|
type FileSystem = super::FileSystemImpl;
|
||||||
|
|
||||||
#[inherit]
|
#[inherit]
|
||||||
@ -43,24 +55,9 @@ pub mod qobject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use cxx_qt_lib::{QModelIndex, QString};
|
|
||||||
use dirs;
|
|
||||||
use log::warn;
|
|
||||||
use std::fs;
|
|
||||||
use std::io::BufRead;
|
|
||||||
use std::path::Path;
|
|
||||||
use syntect::easy::{HighlightFile, HighlightLines};
|
|
||||||
use syntect::highlighting::ThemeSet;
|
|
||||||
use syntect::html::{
|
|
||||||
IncludeBackground, append_highlighted_html_for_styled_line, start_highlighted_html_snippet,
|
|
||||||
};
|
|
||||||
use syntect::parsing::SyntaxSet;
|
|
||||||
use syntect::util::LinesWithEndings;
|
|
||||||
|
|
||||||
// TODO: Implement a provider for QFileSystemModel::setIconProvider for icons.
|
// TODO: Implement a provider for QFileSystemModel::setIconProvider for icons.
|
||||||
pub struct FileSystemImpl {
|
pub struct FileSystemImpl {
|
||||||
file_path: QString,
|
file_path: QString,
|
||||||
root_index: QModelIndex,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default is explicit to make the editor open this source file initially.
|
// Default is explicit to make the editor open this source file initially.
|
||||||
@ -68,7 +65,6 @@ impl Default for FileSystemImpl {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
file_path: QString::from(file!()),
|
file_path: QString::from(file!()),
|
||||||
root_index: Default::default(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,14 +130,13 @@ impl qobject::FileSystem {
|
|||||||
self.set_root_path(path)
|
self.set_root_path(path)
|
||||||
} else {
|
} else {
|
||||||
// If the initial directory can't be opened, attempt to find the home directory.
|
// If the initial directory can't be opened, attempt to find the home directory.
|
||||||
self.set_root_path(&QString::from(
|
let homedir = dirs::home_dir()
|
||||||
dirs::home_dir()
|
|
||||||
.expect("Failed to get home directory")
|
.expect("Failed to get home directory")
|
||||||
.as_path()
|
.as_path()
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string(),
|
.to_string();
|
||||||
))
|
self.set_root_path(&QString::from(homedir))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user