- enhancement: resort files in the files view after rename
This commit is contained in:
parent
262b4916fd
commit
898d5f4e08
3
NEWS.md
3
NEWS.md
|
@ -12,7 +12,8 @@ Red Panda C++ Version 1.1.4
|
||||||
- enhancement: prevent group undo when caret position changed
|
- enhancement: prevent group undo when caret position changed
|
||||||
- fix: undo link break may lose leading spaces
|
- fix: undo link break may lose leading spaces
|
||||||
- fix: correctly restore editor's modified status when undo/redo
|
- fix: correctly restore editor's modified status when undo/redo
|
||||||
- enhancement: set current index to the folder after new folder created in the file view
|
- enhancement: set current index to the folder after new folder created in the files view
|
||||||
|
- enhancement: resort files in the files view after rename
|
||||||
|
|
||||||
Red Panda C++ Version 1.1.3
|
Red Panda C++ Version 1.1.3
|
||||||
|
|
||||||
|
|
|
@ -298,6 +298,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
|
|
||||||
//files view
|
//files view
|
||||||
ui->treeFiles->setModel(&mFileSystemModel);
|
ui->treeFiles->setModel(&mFileSystemModel);
|
||||||
|
connect(&mFileSystemModel, &QFileSystemModel::layoutChanged,
|
||||||
|
this, &MainWindow::onFileSystemModelLayoutChanged, Qt::QueuedConnection);
|
||||||
mFileSystemModel.setReadOnly(false);
|
mFileSystemModel.setReadOnly(false);
|
||||||
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
|
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
|
||||||
|
|
||||||
|
@ -4391,6 +4393,11 @@ void MainWindow::on_EditorTabsRight_tabCloseRequested(int index)
|
||||||
mEditorList->closeEditor(editor);
|
mEditorList->closeEditor(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::onFileSystemModelLayoutChanged()
|
||||||
|
{
|
||||||
|
ui->treeFiles->scrollTo(ui->treeFiles->currentIndex(),QTreeView::PositionAtCenter);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionOpen_triggered()
|
void MainWindow::on_actionOpen_triggered()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -351,6 +351,8 @@ private slots:
|
||||||
void on_EditorTabsLeft_tabCloseRequested(int index);
|
void on_EditorTabsLeft_tabCloseRequested(int index);
|
||||||
void on_EditorTabsRight_tabCloseRequested(int index);
|
void on_EditorTabsRight_tabCloseRequested(int index);
|
||||||
|
|
||||||
|
void onFileSystemModelLayoutChanged();
|
||||||
|
|
||||||
void on_actionOpen_triggered();
|
void on_actionOpen_triggered();
|
||||||
|
|
||||||
void on_actionSave_triggered();
|
void on_actionSave_triggered();
|
||||||
|
|
|
@ -20,6 +20,25 @@
|
||||||
|
|
||||||
CustomFileSystemModel::CustomFileSystemModel(QObject *parent) : QFileSystemModel(parent)
|
CustomFileSystemModel::CustomFileSystemModel(QObject *parent) : QFileSystemModel(parent)
|
||||||
{
|
{
|
||||||
|
connect(this, &QFileSystemModel::fileRenamed,
|
||||||
|
this, &CustomFileSystemModel::delaySort);
|
||||||
|
connect(this, &CustomFileSystemModel::rowsInserted,
|
||||||
|
this, &CustomFileSystemModel::delaySort);
|
||||||
|
connect(&mDelayedSortTimer, &QTimer::timeout,
|
||||||
|
this, &CustomFileSystemModel::performDelayedSort, Qt::QueuedConnection);
|
||||||
|
mDelayedSortTimer.setSingleShot(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomFileSystemModel::delaySort()
|
||||||
|
{
|
||||||
|
if (!mDelayedSortTimer.isActive())
|
||||||
|
mDelayedSortTimer.start(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CustomFileSystemModel::performDelayedSort()
|
||||||
|
{
|
||||||
|
sort(1);
|
||||||
|
sort(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#define CUSTOMFILESYSTEMMODEL_H
|
#define CUSTOMFILESYSTEMMODEL_H
|
||||||
|
|
||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
class GitRepository;
|
class GitRepository;
|
||||||
class GitManager;
|
class GitManager;
|
||||||
|
@ -27,6 +28,13 @@ class CustomFileSystemModel : public QFileSystemModel
|
||||||
public:
|
public:
|
||||||
explicit CustomFileSystemModel(QObject *parent = nullptr);
|
explicit CustomFileSystemModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void delaySort();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void performDelayedSort();
|
||||||
|
private:
|
||||||
|
QTimer mDelayedSortTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CUSTOMFILESYSTEMMODEL_H
|
#endif // CUSTOMFILESYSTEMMODEL_H
|
||||||
|
|
Loading…
Reference in New Issue