mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-10 07:26:03 -06:00
(#641) Added support for copy / paste of points
This commit is contained in:
parent
19d156e8ff
commit
2f6bd07ff0
@ -82,7 +82,7 @@ RimCrossSection::RimCrossSection()
|
||||
CAF_PDM_InitFieldNoDefault(&direction, "Direction", "Direction", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&wellPath, "WellPath", "Well Path ", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&simulationWell, "SimulationWell", "Simulation Well", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_userPolyline, "Points", "Points", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_userPolyline, "Points", "Points", "", "Use Ctrl-C for copy and Ctrl-V for paste", "");
|
||||
CAF_PDM_InitField (&m_branchIndex, "Branch", -1, "Branch", "", "", "");
|
||||
CAF_PDM_InitField (&m_extentLength, "ExtentLength", 200.0, "Extent length", "", "", "");
|
||||
CAF_PDM_InitField (&showInactiveCells, "ShowInactiveCells", false, "Inactive Cells", "", "", "");
|
||||
|
@ -44,18 +44,21 @@
|
||||
|
||||
#include "cafFactory.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QApplication>
|
||||
#include <QBoxLayout>
|
||||
#include <QClipboard>
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QListView>
|
||||
#include <QListView>
|
||||
#include <QStringListModel>
|
||||
#include <QBoxLayout>
|
||||
#include <QListView>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
/// Helper class used to override flags to disable editable items
|
||||
@ -312,6 +315,33 @@ void PdmUiListEditor::slotListItemEdited(const QModelIndex&, const QModelIndex&)
|
||||
this->setValueToField(result);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString PdmUiListEditor::contentAsString() const
|
||||
{
|
||||
QString str;
|
||||
|
||||
if (m_model)
|
||||
{
|
||||
QStringList uiList = m_model->stringList();
|
||||
|
||||
str = uiList.join("\n");
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiListEditor::pasteFromString(const QString& content)
|
||||
{
|
||||
QStringList strList = content.split("\n");
|
||||
|
||||
this->setValueToField(strList);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -349,6 +379,31 @@ bool PdmUiListEditor::eventFilter(QObject * listView, QEvent * event)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (keyEv->modifiers() & Qt::ControlModifier)
|
||||
{
|
||||
if (keyEv->key() == Qt::Key_C)
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if (clipboard)
|
||||
{
|
||||
QString content = contentAsString();
|
||||
clipboard->setText(content);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (keyEv->key() == Qt::Key_V)
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if (clipboard)
|
||||
{
|
||||
QString content = clipboard->text();
|
||||
pasteFromString(content);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -90,6 +90,10 @@ protected slots:
|
||||
void slotSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
|
||||
void slotListItemEdited(const QModelIndex&, const QModelIndex&);
|
||||
|
||||
private:
|
||||
QString contentAsString() const;
|
||||
void pasteFromString(const QString& content);
|
||||
|
||||
private:
|
||||
QPointer<QListView> m_listView;
|
||||
QPointer<QLabel> m_label;
|
||||
|
Loading…
Reference in New Issue
Block a user