Add copy, move and index action to File tree
This commit is contained in:
@@ -66,12 +66,22 @@ void Filetree::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
QMenu menu;
|
QMenu menu;
|
||||||
QAction *open = nullptr;
|
QAction *open = nullptr;
|
||||||
QAction *setRoot = nullptr;
|
QAction *setRoot = nullptr;
|
||||||
|
QAction *copy = nullptr;
|
||||||
|
QAction *move = nullptr;
|
||||||
|
QAction *indexDir = nullptr;
|
||||||
|
|
||||||
if(info.isFile())
|
if(info.isFile())
|
||||||
open = menu.addAction(tr("Open"));
|
open = menu.addAction(tr("Open"));
|
||||||
|
|
||||||
if(info.isDir())
|
if(info.isDir())
|
||||||
|
{
|
||||||
|
open = menu.addAction(tr("Open"));
|
||||||
setRoot = menu.addAction("Set as root");
|
setRoot = menu.addAction("Set as root");
|
||||||
|
copy = menu.addAction(tr("Copy marked files"));
|
||||||
|
move = menu.addAction(tr("Move marked files"));
|
||||||
|
indexDir = menu.addAction(tr("Index directory"));
|
||||||
|
}
|
||||||
|
menu.addSeparator();
|
||||||
|
|
||||||
QAction *resetRoot = menu.addAction("Reset root");
|
QAction *resetRoot = menu.addAction("Reset root");
|
||||||
QAction *goUp = menu.addAction("Go up");
|
QAction *goUp = menu.addAction("Go up");
|
||||||
@@ -96,4 +106,16 @@ void Filetree::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
setRootIndex(rootIndex().parent());
|
setRootIndex(rootIndex().parent());
|
||||||
m_rootDir = m_fileSystemModel->filePath(rootIndex().parent());
|
m_rootDir = m_fileSystemModel->filePath(rootIndex().parent());
|
||||||
}
|
}
|
||||||
|
else if(a == copy)
|
||||||
|
{
|
||||||
|
emit copyFiles(m_fileSystemModel->filePath(index));
|
||||||
|
}
|
||||||
|
else if(a == move)
|
||||||
|
{
|
||||||
|
emit moveFiles(m_fileSystemModel->filePath(index));
|
||||||
|
}
|
||||||
|
else if(a == indexDir)
|
||||||
|
{
|
||||||
|
emit indexDirectory(m_fileSystemModel->filePath(index));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ public:
|
|||||||
void contextMenuEvent(QContextMenuEvent *event);
|
void contextMenuEvent(QContextMenuEvent *event);
|
||||||
signals:
|
signals:
|
||||||
void fileSelected(const QString &path);
|
void fileSelected(const QString &path);
|
||||||
|
void copyFiles(const QString &path);
|
||||||
|
void moveFiles(const QString &path);
|
||||||
|
void indexDirectory(const QString &path);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FILESYSTEMWIDGET_H
|
#endif // FILESYSTEMWIDGET_H
|
||||||
|
|||||||
+14
-1
@@ -57,6 +57,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|||||||
|
|
||||||
m_filetree = new Filetree(this);
|
m_filetree = new Filetree(this);
|
||||||
connect(m_filetree, &Filetree::fileSelected, this, static_cast<void (MainWindow::*)(const QString &)>(&MainWindow::loadFile));
|
connect(m_filetree, &Filetree::fileSelected, this, static_cast<void (MainWindow::*)(const QString &)>(&MainWindow::loadFile));
|
||||||
|
connect(m_filetree, &Filetree::copyFiles, [this](const QString &path){ copyOrMove(true, path); });
|
||||||
|
connect(m_filetree, &Filetree::moveFiles, [this](const QString &path){ copyOrMove(false, path); });
|
||||||
|
connect(m_filetree, &Filetree::indexDirectory, this, static_cast<void (MainWindow::*)(const QString &)>(&MainWindow::indexDir));
|
||||||
|
|
||||||
m_database = new Database(this);
|
m_database = new Database(this);
|
||||||
if(!m_database->init())
|
if(!m_database->init())
|
||||||
@@ -269,6 +272,11 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||||||
void MainWindow::copyOrMove(bool copy)
|
void MainWindow::copyOrMove(bool copy)
|
||||||
{
|
{
|
||||||
QString dest = QFileDialog::getExistingDirectory(this, tr("Select destination"), _lastDir);
|
QString dest = QFileDialog::getExistingDirectory(this, tr("Select destination"), _lastDir);
|
||||||
|
copyOrMove(copy, dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::copyOrMove(bool copy, const QString &dest)
|
||||||
|
{
|
||||||
QDir dir(dest);
|
QDir dir(dest);
|
||||||
if(!dest.isEmpty() && dir.exists())
|
if(!dest.isEmpty() && dir.exists())
|
||||||
{
|
{
|
||||||
@@ -313,8 +321,8 @@ void MainWindow::copyOrMove(bool copy)
|
|||||||
#endif
|
#endif
|
||||||
progress.setValue(i++);
|
progress.setValue(i++);
|
||||||
}
|
}
|
||||||
|
m_database->clearMarkedFiles();
|
||||||
}
|
}
|
||||||
m_database->clearMarkedFiles();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::socketNotify()
|
void MainWindow::socketNotify()
|
||||||
@@ -366,6 +374,11 @@ void MainWindow::loadFile(int row)
|
|||||||
void MainWindow::indexDir()
|
void MainWindow::indexDir()
|
||||||
{
|
{
|
||||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Index directory"), _lastDir);
|
QString dir = QFileDialog::getExistingDirectory(this, tr("Index directory"), _lastDir);
|
||||||
|
indexDir(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::indexDir(const QString &dir)
|
||||||
|
{
|
||||||
if(!dir.isEmpty())
|
if(!dir.isEmpty())
|
||||||
{
|
{
|
||||||
QProgressDialog progressDialog(tr("Indexing FITS files"), tr("Cancel"), 0, 1, this);
|
QProgressDialog progressDialog(tr("Indexing FITS files"), tr("Cancel"), 0, 1, this);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ protected:
|
|||||||
static void signalHandler(int);
|
static void signalHandler(int);
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
void copyOrMove(bool copy);
|
void copyOrMove(bool copy);
|
||||||
|
void copyOrMove(bool copy, const QString &dest);
|
||||||
protected slots:
|
protected slots:
|
||||||
void socketNotify();
|
void socketNotify();
|
||||||
void updateWindowTitle();
|
void updateWindowTitle();
|
||||||
@@ -46,6 +47,7 @@ protected slots:
|
|||||||
void loadFile(const QString &path);
|
void loadFile(const QString &path);
|
||||||
void loadFile(int row);
|
void loadFile(int row);
|
||||||
void indexDir();
|
void indexDir();
|
||||||
|
void indexDir(const QString &dir);
|
||||||
void reindex();
|
void reindex();
|
||||||
void saveAs();
|
void saveAs();
|
||||||
void convert(const QString &outfile);
|
void convert(const QString &outfile);
|
||||||
|
|||||||
Reference in New Issue
Block a user