Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b8a56b8

Browse files
authoredMar 16, 2025
Merge pull request #16 from sandbox-science/fileTree
File Tree Navigation
2 parents da95e0f + aa3008c commit b8a56b8

File tree

5 files changed

+343
-195
lines changed

5 files changed

+343
-195
lines changed
 

‎CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ add_executable(${TARGET_NAME}
5555
src/MainWindow.cpp
5656
src/CodeEditor.cpp
5757
src/Syntax.cpp
58+
src/Tree.cpp
5859
include/MainWindow.h
5960
include/CodeEditor.h
6061
include/Syntax.h
62+
include/Tree.h
6163
)
6264

6365
qt_add_resources(APP_RESOURCES resources.qrc)

‎include/MainWindow.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "CodeEditor.h"
55
#include "Syntax.h"
6+
#include "Tree.h"
7+
68
#include <QMainWindow>
79
#include <QMenu>
810
#include <QAction>
@@ -17,6 +19,7 @@ class MainWindow : public QMainWindow
1719
public:
1820
explicit MainWindow(QWidget *parent = nullptr);
1921
virtual ~MainWindow();
22+
void loadFileInEditor(const QString &filePath);
2023

2124
private slots:
2225
void newFile();
@@ -36,6 +39,7 @@ private slots:
3639
CodeEditor *editor;
3740
QString currentFileName;
3841
Syntax *syntax;
42+
Tree *tree;
3943
};
4044

4145
#endif // MAINWINDOW_H

‎include/Tree.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#ifndef TREE_H
2+
#define TREE_H
3+
4+
#include <QSplitter>
5+
#include <QTreeView>
6+
#include <QFileSystemModel>
7+
#include <QObject>
8+
9+
class MainWindow; // Forward declaration
10+
11+
class Tree : public QObject
12+
{
13+
Q_OBJECT
14+
15+
public:
16+
Tree(QSplitter *splitter, MainWindow *mainWindow);
17+
~Tree();
18+
19+
private:
20+
void showContextMenu(const QPoint &pos);
21+
void setupModel();
22+
void setupTree();
23+
void openFile(const QModelIndex &index);
24+
QString getDirectoryPath();
25+
26+
QFileSystemModel *model;
27+
QTreeView *tree;
28+
MainWindow *mainWindow;
29+
};
30+
31+
#endif // TREE_H

0 commit comments

Comments
 (0)
Please sign in to comment.