mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1840 Summary case: Cut paste of summary cases
This commit is contained in:
@@ -6,6 +6,7 @@ endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicCopyReferencesToClipboardFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicCutReferencesToClipboardFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteFeatureImpl.h
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.h
|
||||
@@ -15,6 +16,7 @@ ${CEE_CURRENT_LIST_DIR}RicPasteGeoMechViewsFeature.h
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicCopyReferencesToClipboardFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicCutReferencesToClipboardFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteFeatureImpl.cpp
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.cpp
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicCutReferencesToClipboardFeature.h"
|
||||
|
||||
#include "RimMimeData.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
#include "RimSummaryCurveFilter.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmUiItem.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicCutReferencesToClipboardFeature, "RicCutReferencesToClipboardFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCutReferencesToClipboardFeature::isCommandEnabled()
|
||||
{
|
||||
return isAnyCuttableObjectSelected();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCutReferencesToClipboardFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
this->disableModelChangeContribution();
|
||||
|
||||
if (!isAnyCuttableObjectSelected()) return;
|
||||
|
||||
std::vector<QString> referenceList;
|
||||
|
||||
std::vector<caf::PdmObject*> selectedFormationNamesCollObjs;
|
||||
caf::SelectionManager::instance()->objectsByType(&selectedFormationNamesCollObjs);
|
||||
|
||||
for (caf::PdmObject* pdmObject : selectedFormationNamesCollObjs)
|
||||
{
|
||||
if (RicCutReferencesToClipboardFeature::isCuttingOfObjectSupported(pdmObject))
|
||||
{
|
||||
QString itemRef = caf::PdmReferenceHelper::referenceFromRootToObject(caf::SelectionManager::instance()->pdmRootObject(), pdmObject);
|
||||
|
||||
referenceList.push_back(itemRef);
|
||||
}
|
||||
}
|
||||
|
||||
MimeDataWithReferences* myObject = new MimeDataWithReferences;
|
||||
myObject->setReferences(referenceList);
|
||||
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if (clipboard)
|
||||
{
|
||||
clipboard->setMimeData(myObject);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCutReferencesToClipboardFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Cut");
|
||||
actionToSetup->setIcon(QIcon(":/Clipboard.png"));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCutReferencesToClipboardFeature::isAnyCuttableObjectSelected()
|
||||
{
|
||||
std::vector<caf::PdmObject*> selectedFormationNamesCollObjs;
|
||||
caf::SelectionManager::instance()->objectsByType(&selectedFormationNamesCollObjs);
|
||||
|
||||
for (caf::PdmObject* pdmObject : selectedFormationNamesCollObjs)
|
||||
{
|
||||
if (RicCutReferencesToClipboardFeature::isCuttingOfObjectSupported(pdmObject))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCutReferencesToClipboardFeature::isCuttingOfObjectSupported(caf::PdmObject* pdmObject)
|
||||
{
|
||||
if (dynamic_cast<RimSummaryCase*>(pdmObject))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017- Statoil ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmObject;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicCutReferencesToClipboardFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
private:
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered( bool isChecked ) override;
|
||||
virtual void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
static bool isAnyCuttableObjectSelected();
|
||||
static bool isCuttingOfObjectSupported(caf::PdmObject* pdmObject);
|
||||
};
|
||||
@@ -149,3 +149,14 @@ void RicPasteFeatureImpl::setIconAndShortcuts(QAction* action)
|
||||
action->setShortcuts(QKeySequence::Paste);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteFeatureImpl::clearClipboard()
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if (!clipboard) return;
|
||||
|
||||
clipboard->setMimeData(nullptr);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ public:
|
||||
|
||||
static void setIconAndShortcuts(QAction* action);
|
||||
|
||||
static void clearClipboard();
|
||||
|
||||
private:
|
||||
static void populateObjectGroupFromReferences(const std::vector<QString>& referenceList, caf::PdmObjectGroup* objectGroup);
|
||||
static void referencesFromClipboard(std::vector<QString>& referenceList);
|
||||
|
||||
Reference in New Issue
Block a user