Add open file and open file location to DB view
This commit is contained in:
+18
-13
@@ -183,19 +183,7 @@ void BatchProcessing::browse()
|
|||||||
|
|
||||||
void BatchProcessing::openScriptDir()
|
void BatchProcessing::openScriptDir()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_LINUX
|
openDir(_scriptBasePath);
|
||||||
QDBusConnection con = QDBusConnection::sessionBus();
|
|
||||||
QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.FileManager1", "/org/freedesktop/FileManager1", "org.freedesktop.FileManager1", "ShowFolders");
|
|
||||||
QList<QVariant> args = {QStringList(QUrl::fromLocalFile(_scriptBasePath).toString()), QString()};
|
|
||||||
message.setArguments(args);
|
|
||||||
con.call(message);
|
|
||||||
#endif
|
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
QProcess::startDetached("explorer.exe", {QDir::toNativeSeparators(_scriptBasePath)});
|
|
||||||
#endif
|
|
||||||
#ifdef Q_OS_MACOS
|
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(_scriptBasePath));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchProcessing::runScript()
|
void BatchProcessing::runScript()
|
||||||
@@ -309,3 +297,20 @@ void BatchProcessing::plot(const QVector<QPointF> &points)
|
|||||||
diag->resize(640, 480);
|
diag->resize(640, 480);
|
||||||
diag->show();
|
diag->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void openDir(const QString &path)
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
QDBusConnection con = QDBusConnection::sessionBus();
|
||||||
|
QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.FileManager1", "/org/freedesktop/FileManager1", "org.freedesktop.FileManager1", "ShowFolders");
|
||||||
|
QList<QVariant> args = {QStringList(QUrl::fromLocalFile(path).toString()), QString()};
|
||||||
|
message.setArguments(args);
|
||||||
|
con.call(message);
|
||||||
|
#endif
|
||||||
|
#ifdef Q_OS_WINDOWS
|
||||||
|
QProcess::startDetached("explorer.exe", {QDir::toNativeSeparators(path)});
|
||||||
|
#endif
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
@@ -45,4 +45,6 @@ public slots:
|
|||||||
void plot(const QVector<QPointF> &points);
|
void plot(const QVector<QPointF> &points);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void openDir(const QString &path);
|
||||||
|
|
||||||
#endif // BATCHPROCESSING_H
|
#endif // BATCHPROCESSING_H
|
||||||
|
|||||||
+18
-1
@@ -10,6 +10,7 @@
|
|||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "batchprocessing.h"
|
||||||
|
|
||||||
const QStringList DEFAULT_COLUMNS = {"EXPTIME", "OBJECT", "RA", "DEC"};
|
const QStringList DEFAULT_COLUMNS = {"EXPTIME", "OBJECT", "RA", "DEC"};
|
||||||
|
|
||||||
@@ -214,6 +215,8 @@ void DatabaseTableView::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
QMenu menu;
|
QMenu menu;
|
||||||
QAction *mark = menu.addAction(tr("Mark"));
|
QAction *mark = menu.addAction(tr("Mark"));
|
||||||
QAction *unmark = menu.addAction(tr("Unmark"));
|
QAction *unmark = menu.addAction(tr("Unmark"));
|
||||||
|
QAction *open = menu.addAction(tr("Open"));
|
||||||
|
QAction *openDirAction = menu.addAction(tr("Open file location"));
|
||||||
|
|
||||||
QAction *a = menu.exec(event->globalPos());
|
QAction *a = menu.exec(event->globalPos());
|
||||||
if(a == nullptr)
|
if(a == nullptr)
|
||||||
@@ -225,7 +228,10 @@ void DatabaseTableView::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
emit filesMarked(indexes);
|
emit filesMarked(indexes);
|
||||||
else if(a == unmark)
|
else if(a == unmark)
|
||||||
emit filesUnmarked(indexes);
|
emit filesUnmarked(indexes);
|
||||||
|
else if(a == open)
|
||||||
|
emit openFile(indexes);
|
||||||
|
else if(a == openDirAction)
|
||||||
|
emit openDir(indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataBaseView::DataBaseView(Database *database, QWidget *parent) : QWidget(parent)
|
DataBaseView::DataBaseView(Database *database, QWidget *parent) : QWidget(parent)
|
||||||
@@ -270,6 +276,17 @@ DataBaseView::DataBaseView(Database *database, QWidget *parent) : QWidget(parent
|
|||||||
m_database->unmark(files);
|
m_database->unmark(files);
|
||||||
m_model->filesUnmarked(indexes);
|
m_model->filesUnmarked(indexes);
|
||||||
});
|
});
|
||||||
|
connect(m_tableView, &DatabaseTableView::openFile, [this](QModelIndexList indexes){
|
||||||
|
if(indexes.size())
|
||||||
|
emit loadFile(m_model->data(indexes.front().siblingAtColumn(0)).toString());
|
||||||
|
});
|
||||||
|
connect(m_tableView, &DatabaseTableView::openDir, [this](QModelIndexList indexes){
|
||||||
|
if(indexes.size())
|
||||||
|
{
|
||||||
|
QFileInfo info(m_model->data(indexes.front().siblingAtColumn(0)).toString());
|
||||||
|
openDir(info.absolutePath());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
auto addFilterItems = [](QComboBox *combobox, const QStringList &fitsKeywords)
|
auto addFilterItems = [](QComboBox *combobox, const QStringList &fitsKeywords)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ protected:
|
|||||||
signals:
|
signals:
|
||||||
void filesMarked(QModelIndexList indexes);
|
void filesMarked(QModelIndexList indexes);
|
||||||
void filesUnmarked(QModelIndexList indexes);
|
void filesUnmarked(QModelIndexList indexes);
|
||||||
|
void openFile(QModelIndexList indexes);
|
||||||
|
void openDir(QModelIndexList indexes);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DataBaseView : public QWidget
|
class DataBaseView : public QWidget
|
||||||
|
|||||||
Reference in New Issue
Block a user