mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3087 Show plot data. Add context menu: export to file
This commit is contained in:
@@ -20,8 +20,11 @@
|
||||
#include "RiuTextDialog.h"
|
||||
#include "RiuTools.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaQDateTimeTools.h"
|
||||
|
||||
#include "SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QBoxLayout>
|
||||
@@ -92,6 +95,30 @@ void RiuQPlainTextEdit::slotSelectAll()
|
||||
this->selectAll();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQPlainTextEdit::slotExportToFile()
|
||||
{
|
||||
// Get dialog
|
||||
RiuShowTabbedPlotDataDialog* dialog = nullptr;
|
||||
auto curr = parent();
|
||||
while (dialog == nullptr)
|
||||
{
|
||||
if (!curr) break;
|
||||
dialog = dynamic_cast<RiuShowTabbedPlotDataDialog*>(curr);
|
||||
if (dialog) break;
|
||||
curr = curr->parent();
|
||||
}
|
||||
|
||||
if(dialog)
|
||||
{
|
||||
QString defaultDir = RicAsciiExportSummaryPlotFeature::defaultExportDir();
|
||||
auto fileName = RicAsciiExportSummaryPlotFeature::getFileNameFromUserDialog(dialog->description(), defaultDir);
|
||||
RicAsciiExportSummaryPlotFeature::exportTextToFile(fileName, this->toPlainText());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
@@ -192,6 +219,23 @@ RiuShowTabbedPlotDataDialog::RiuShowTabbedPlotDataDialog(QWidget* parent /*= nul
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuShowTabbedPlotDataDialog::setDescription(const QString& description)
|
||||
{
|
||||
m_description = description;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuShowTabbedPlotDataDialog::description() const
|
||||
{
|
||||
if (m_description.isEmpty()) return "Plot Data";
|
||||
return m_description;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -279,5 +323,16 @@ void RiuShowTabbedPlotDataDialog::contextMenuEvent(QContextMenuEvent* event)
|
||||
menu.addAction(actionToSetup);
|
||||
}
|
||||
|
||||
{
|
||||
QAction* actionToSetup = new QAction(this);
|
||||
|
||||
actionToSetup->setText("Export to File...");
|
||||
//actionToSetup->setShortcuts(QKeySequence::);
|
||||
|
||||
connect(actionToSetup, SIGNAL(triggered()), textEdit, SLOT(slotExportToFile()));
|
||||
|
||||
menu.addAction(actionToSetup);
|
||||
}
|
||||
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user