mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added CopyReferencesToClipboardFeature
This commit is contained in:
parent
69243076b2
commit
a1ecc50605
@ -103,6 +103,7 @@ list( APPEND REFERENCED_CMAKE_FILES
|
||||
ModelVisualization/CMakeLists_files.cmake
|
||||
GeoMech/GeoMechVisualization/CMakeLists_files.cmake
|
||||
Commands/CMakeLists_files.cmake
|
||||
Commands/OperationsUsingObjReferences/CMakeLists_files.cmake
|
||||
)
|
||||
|
||||
# Include source file lists from *.cmake files
|
||||
|
@ -0,0 +1,23 @@
|
||||
|
||||
# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly
|
||||
if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
|
||||
set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/)
|
||||
endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicCopyReferencesToClipboardFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicCopyReferencesToClipboardFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
${SOURCE_GROUP_HEADER_FILES}
|
||||
)
|
||||
|
||||
list(APPEND CODE_SOURCE_FILES
|
||||
${SOURCE_GROUP_SOURCE_FILES}
|
||||
)
|
||||
|
||||
source_group( "CommandFeature_ObjReferences" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake )
|
@ -0,0 +1,88 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) 2011-2013 Ceetron AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library 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.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
#include "RicCopyReferencesToClipboardFeature.h"
|
||||
|
||||
#include "RimMimeData.h"
|
||||
#include "cafPdmUiItem.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicCopyReferencesToClipboardFeature, "RicCopyReferencesToClipboardFeature");
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCopyReferencesToClipboardFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCopyReferencesToClipboardFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
std::vector<QString> referenceList;
|
||||
SelectionManager::instance()->selectionAsReferences(referenceList);
|
||||
|
||||
MimeDataWithReferences* myObject = new MimeDataWithReferences;
|
||||
myObject->setReferences(referenceList);
|
||||
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if (clipboard)
|
||||
{
|
||||
clipboard->setMimeData(myObject);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCopyReferencesToClipboardFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("RicCopyReferencesToClipboardFeature");
|
||||
}
|
||||
|
||||
} // end namespace caf
|
@ -0,0 +1,61 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) 2011-2013 Ceetron AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library 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.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicCopyReferencesToClipboardFeature : public CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
protected:
|
||||
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // end namespace caf
|
@ -79,3 +79,67 @@ QString MimeDataWithIndexes::formatName()
|
||||
return "MimeDataWithIndexes";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
MimeDataWithReferences::MimeDataWithReferences()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
MimeDataWithReferences::MimeDataWithReferences(const MimeDataWithReferences& other)
|
||||
{
|
||||
setReferences(other.references());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void MimeDataWithReferences::setReferences(const std::vector<QString>& references)
|
||||
{
|
||||
m_references = references;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<QString>& MimeDataWithReferences::references() const
|
||||
{
|
||||
return m_references;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool MimeDataWithReferences::hasFormat(const QString& mimetype) const
|
||||
{
|
||||
return (mimetype == formatName());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList MimeDataWithReferences::formats() const
|
||||
{
|
||||
QStringList supportedFormats = QMimeData::formats();
|
||||
supportedFormats << formatName();
|
||||
|
||||
return supportedFormats;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString MimeDataWithReferences::formatName()
|
||||
{
|
||||
return "MimeDataWithReferences";
|
||||
}
|
||||
|
@ -20,6 +20,9 @@
|
||||
|
||||
#include <QMimeData>
|
||||
#include <QModelIndex>
|
||||
#include <QStringList>
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -44,3 +47,27 @@ private:
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(MimeDataWithIndexes)
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// MimeData class used to carry string references to pdm objects
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class MimeDataWithReferences : public QMimeData
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MimeDataWithReferences();
|
||||
MimeDataWithReferences(const MimeDataWithReferences& other);
|
||||
|
||||
void setReferences(const std::vector<QString>& references);
|
||||
const std::vector<QString>& references() const;
|
||||
virtual bool hasFormat(const QString& mimetype) const;
|
||||
virtual QStringList formats() const;
|
||||
static QString formatName();
|
||||
|
||||
private:
|
||||
std::vector<QString> m_references;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(MimeDataWithReferences)
|
||||
|
@ -525,10 +525,12 @@ void RimProject::computeUtmAreaOfInterest()
|
||||
#include "RimEclipsePropertyFilter.h"
|
||||
#include "RimGeoMechPropertyFilterCollection.h"
|
||||
#include "RimGeoMechPropertyFilter.h"
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseFaultColors.h"
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -544,9 +546,14 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
||||
caf::PdmUiItem* uiItem = uiItems[0];
|
||||
CVF_ASSERT(uiItem);
|
||||
|
||||
if (dynamic_cast<RimEclipseCase*>(uiItem))
|
||||
if (dynamic_cast<RimGeoMechView*>(uiItem))
|
||||
{
|
||||
commandIds << "RicEclipseCaseCopy";
|
||||
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimEclipseCase*>(uiItem))
|
||||
{
|
||||
commandIds << "RicCopyReferencesToClipboardFeature";
|
||||
|
||||
commandIds << "RicEclipseCasePaste";
|
||||
commandIds << "RicEclipseCaseClose";
|
||||
commandIds << "RicEclipseCaseNewView";
|
||||
|
@ -1287,6 +1287,8 @@ void RiuMainWindow::setPdmRoot(caf::PdmObject* pdmRoot)
|
||||
m_projectTreeView->setPdmItem(pdmRoot);
|
||||
|
||||
m_projectTreeView->treeView()->expandAll();
|
||||
|
||||
caf::SelectionManager::instance()->setPdmRootObject(pdmRoot);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -84,8 +84,8 @@ public:
|
||||
void selectedItems(std::vector<PdmUiItem*>& items, int role = SelectionManager::APPLICATION_GLOBAL);
|
||||
void setSelectedItems(const std::vector<PdmUiItem*>& items, int role = SelectionManager::APPLICATION_GLOBAL);
|
||||
|
||||
void selectionAsReferences(std::vector<QString>& referenceList, int role) const;
|
||||
void setSelectionFromReferences(const std::vector<QString>& referenceList, int role);
|
||||
void selectionAsReferences(std::vector<QString>& referenceList, int role = SelectionManager::APPLICATION_GLOBAL) const;
|
||||
void setSelectionFromReferences(const std::vector<QString>& referenceList, int role = SelectionManager::APPLICATION_GLOBAL);
|
||||
|
||||
void clearAll();
|
||||
void clear(int role);
|
||||
|
Loading…
Reference in New Issue
Block a user