mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 23:50:19 -05:00
#13901 ShowPlotData: Invert dependencies via capability mixins and text-dialog signal
This commit is contained in:
1 parent
99910c3d7d
commit
bd3836ba25
26 files changed
+612
-298
No files matched your search
@@ -20,9 +20,7 @@
|
||||
#include "RiuTextDialog.h"
|
||||
#include "RiuTools.h"
|
||||
|
||||
#include "RiaQDateTimeTools.h"
|
||||
|
||||
#include "SummaryPlotCommands/RicAsciiExportSummaryPlotFeature.h"
|
||||
#include "RimTabbedTextProvider.h"
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
@@ -33,7 +31,7 @@
|
||||
#include <QMenu>
|
||||
#include <QTabWidget>
|
||||
|
||||
#include <cvfAssert.h>
|
||||
#include <cafAssert.h>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -96,30 +94,6 @@ void RiuQPlainTextEdit::slotSelectAll()
|
||||
selectAll();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuQPlainTextEdit::slotExportToFile()
|
||||
{
|
||||
// Get dialog
|
||||
RiuTabbedTextDialog* dialog = nullptr;
|
||||
auto curr = parent();
|
||||
while ( dialog == nullptr )
|
||||
{
|
||||
if ( !curr ) break;
|
||||
dialog = dynamic_cast<RiuTabbedTextDialog*>( curr );
|
||||
if ( dialog ) break;
|
||||
curr = curr->parent();
|
||||
}
|
||||
|
||||
if ( dialog )
|
||||
{
|
||||
QString defaultDir = RicAsciiExportSummaryPlotFeature::defaultExportDir();
|
||||
auto fileName = RicAsciiExportSummaryPlotFeature::getFileNameFromUserDialog( dialog->description(), defaultDir );
|
||||
RicAsciiExportSummaryPlotFeature::exportTextToFile( fileName, toPlainText() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
@@ -188,15 +162,15 @@ void RiuTextDialog::contextMenuEvent( QContextMenuEvent* event )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuTabbedTextDialog::RiuTabbedTextDialog( RiuTabbedTextProvider* textProvider, QWidget* parent /*= nullptr*/ )
|
||||
: m_textProvider( textProvider )
|
||||
, QDialog( parent, RiuTools::defaultDialogFlags() )
|
||||
RiuTabbedTextDialog::RiuTabbedTextDialog( std::unique_ptr<RimTabbedTextProvider> textProvider, QWidget* parent /*= nullptr*/ )
|
||||
: QDialog( parent, RiuTools::defaultDialogFlags() )
|
||||
, m_textProvider( std::move( textProvider ) )
|
||||
{
|
||||
m_tabWidget = new QTabWidget( this );
|
||||
|
||||
connect( m_tabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( slotTabChanged( int ) ) );
|
||||
|
||||
CVF_ASSERT( m_textProvider->isValid() );
|
||||
CAF_ASSERT( m_textProvider && m_textProvider->isValid() );
|
||||
setWindowTitle( m_textProvider->description() );
|
||||
|
||||
for ( int tabIndex = 0; tabIndex < m_textProvider->tabCount(); ++tabIndex )
|
||||
@@ -224,6 +198,11 @@ RiuTabbedTextDialog::RiuTabbedTextDialog( RiuTabbedTextProvider* textProvider, Q
|
||||
updateTabText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuTabbedTextDialog::~RiuTabbedTextDialog() = default;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -293,6 +272,17 @@ void RiuTabbedTextDialog::slotTabChanged( int index )
|
||||
redrawText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuTabbedTextDialog::slotExportToFile()
|
||||
{
|
||||
auto textEdit = currentTextEdit();
|
||||
if ( !textEdit ) return;
|
||||
|
||||
emit exportToFileRequested( description(), textEdit->toPlainText() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -329,7 +319,7 @@ void RiuTabbedTextDialog::contextMenuEvent( QContextMenuEvent* event )
|
||||
|
||||
actionToSetup->setText( "Export to File..." );
|
||||
|
||||
connect( actionToSetup, SIGNAL( triggered() ), textEdit, SLOT( slotExportToFile() ) );
|
||||
connect( actionToSetup, SIGNAL( triggered() ), this, SLOT( slotExportToFile() ) );
|
||||
|
||||
menu.addAction( actionToSetup );
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QPointer>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class QTabWidget;
|
||||
class RimSummaryPlot;
|
||||
class RimTabbedTextProvider;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@@ -45,7 +45,6 @@ protected:
|
||||
private slots:
|
||||
void slotCopyContentToClipboard();
|
||||
void slotSelectAll();
|
||||
void slotExportToFile();
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -67,18 +66,6 @@ protected:
|
||||
void contextMenuEvent( QContextMenuEvent* ) override;
|
||||
};
|
||||
|
||||
class RiuTabbedTextProvider : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual bool isValid() const = 0;
|
||||
virtual QString description() const = 0;
|
||||
virtual QString tabTitle( int tabIndex ) const = 0;
|
||||
virtual QString tabText( int tabIndex ) const = 0;
|
||||
virtual int tabCount() const = 0;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -87,21 +74,26 @@ class RiuTabbedTextDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RiuTabbedTextDialog( RiuTabbedTextProvider* textProvider, QWidget* parent = nullptr );
|
||||
explicit RiuTabbedTextDialog( std::unique_ptr<RimTabbedTextProvider> textProvider, QWidget* parent = nullptr );
|
||||
~RiuTabbedTextDialog() override;
|
||||
|
||||
QString description() const;
|
||||
void redrawText();
|
||||
|
||||
signals:
|
||||
void exportToFileRequested( const QString& title, const QString& text );
|
||||
|
||||
private:
|
||||
RiuQPlainTextEdit* currentTextEdit() const;
|
||||
void updateTabText();
|
||||
|
||||
QTabWidget* m_tabWidget;
|
||||
QPointer<RiuTabbedTextProvider> m_textProvider;
|
||||
std::vector<QString> m_tabTexts;
|
||||
QTabWidget* m_tabWidget;
|
||||
std::unique_ptr<RimTabbedTextProvider> m_textProvider;
|
||||
std::vector<QString> m_tabTexts;
|
||||
|
||||
private slots:
|
||||
void slotTabChanged( int index );
|
||||
void slotExportToFile();
|
||||
|
||||
protected:
|
||||
void contextMenuEvent( QContextMenuEvent* ) override;
|
||||
|
||||
Reference in new issue
Block a user