From 9f07daefadf4c33471ac8681781f7df596adda69 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 16 Apr 2013 11:19:37 +0200 Subject: [PATCH] Moved MimeData into RimMimeData p4#: 21317 --- ApplicationCode/CMakeLists.txt | 1 + .../ProjectDataModel/CMakeLists_files.cmake | 2 + .../ProjectDataModel/RimMimeData.cpp | 81 +++++++++++++++++++ .../ProjectDataModel/RimMimeData.h | 46 +++++++++++ .../ProjectDataModel/RimUiTreeModelPdm.cpp | 1 + .../ProjectDataModel/RimUiTreeModelPdm.h | 51 ------------ .../ProjectDataModel/RimUiTreeView.cpp | 1 + 7 files changed, 132 insertions(+), 51 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimMimeData.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimMimeData.h diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 060a57de55..472c5c45e1 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -89,6 +89,7 @@ set ( QT_MOC_HEADERS ProjectDataModel/RimUiTreeModelPdm.h ProjectDataModel/RimUiTreeView.h + ProjectDataModel/RimMimeData.h UserInterface/RiuMainWindow.h UserInterface/RiuPreferencesDialog.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index c18ca33b7a..9f6d3a9ac2 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -38,6 +38,7 @@ ${CEE_CURRENT_LIST_DIR}RimUiTreeModelPdm.h ${CEE_CURRENT_LIST_DIR}RimUiTreeView.h ${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsCacher.h ${CEE_CURRENT_LIST_DIR}RimStatisticsCaseEvaluator.h +${CEE_CURRENT_LIST_DIR}RimMimeData.h ) list(APPEND CODE_SOURCE_FILES @@ -73,6 +74,7 @@ ${CEE_CURRENT_LIST_DIR}RimUiTreeModelPdm.cpp ${CEE_CURRENT_LIST_DIR}RimUiTreeView.cpp ${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsCacher.cpp ${CEE_CURRENT_LIST_DIR}RimStatisticsCaseEvaluator.cpp +${CEE_CURRENT_LIST_DIR}RimMimeData.cpp ) diff --git a/ApplicationCode/ProjectDataModel/RimMimeData.cpp b/ApplicationCode/ProjectDataModel/RimMimeData.cpp new file mode 100644 index 0000000000..e16db847d6 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimMimeData.cpp @@ -0,0 +1,81 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaStdInclude.h" + +#include "RimMimeData.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +MimeDataWithIndexes::MimeDataWithIndexes() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +MimeDataWithIndexes::MimeDataWithIndexes(const MimeDataWithIndexes & other) : QMimeData() +{ + setIndexes(other.indexes()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void MimeDataWithIndexes::setIndexes(const QModelIndexList & indexes) +{ + m_indexes = indexes; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QModelIndexList& MimeDataWithIndexes::indexes() const +{ + return m_indexes; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool MimeDataWithIndexes::hasFormat(const QString &mimetype) const +{ + return (mimetype == formatName()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList MimeDataWithIndexes::formats() const +{ + QStringList supportedFormats = QMimeData::formats(); + supportedFormats << formatName(); + + return supportedFormats; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString MimeDataWithIndexes::formatName() +{ + return "MimeDataWithIndexes"; +} + diff --git a/ApplicationCode/ProjectDataModel/RimMimeData.h b/ApplicationCode/ProjectDataModel/RimMimeData.h new file mode 100644 index 0000000000..0ff9fa9714 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimMimeData.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include + + +//-------------------------------------------------------------------------------------------------- +/// MimeData class used to carry a QModelIndexList +//-------------------------------------------------------------------------------------------------- +class MimeDataWithIndexes : public QMimeData +{ + Q_OBJECT + +public: + MimeDataWithIndexes(); + MimeDataWithIndexes(const MimeDataWithIndexes & other); + + void setIndexes(const QModelIndexList& indexes); + const QModelIndexList& indexes() const; + virtual bool hasFormat(const QString& mimetype) const; + virtual QStringList formats() const; + static QString formatName(); + +private: + QModelIndexList m_indexes; +}; + +Q_DECLARE_METATYPE(MimeDataWithIndexes) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 076ef7df8d..5357ee7e82 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -40,6 +40,7 @@ #include "RigGridManager.h" #include "RimCase.h" #include "RigCaseData.h" +#include "RimMimeData.h" //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index dc265b738f..81ba4f43c9 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -23,8 +23,6 @@ #include "cafPdmDocument.h" #include "cafUiTreeModelPdm.h" -#include - class QFileSystemWatcher; class RimCellPropertyFilter; @@ -35,55 +33,6 @@ class RimInputProperty; class RimStatisticsCase; class RimIdenticalGridCaseGroup; -//-------------------------------------------------------------------------------------------------- -/// MimeData class used to carry a QModelIndexList -//-------------------------------------------------------------------------------------------------- -class MimeDataWithIndexes : public QMimeData -{ - Q_OBJECT - -public: - MimeDataWithIndexes() - { - } - - - MimeDataWithIndexes(const MimeDataWithIndexes & other) : QMimeData() - { - setIndexes(other.indexes()); - } - - void setIndexes(const QModelIndexList & indexes) - { - m_indexes = indexes; - } - - const QModelIndexList& indexes() const { return m_indexes; } - - virtual bool hasFormat( const QString &mimetype ) const - { - return (mimetype == formatName()); - } - - virtual QStringList formats() const - { - QStringList supportedFormats = QMimeData::formats(); - supportedFormats << formatName(); - - return supportedFormats; - } - - static QString formatName() - { - return "MimeDataWithIndexes"; - } - -private: - QModelIndexList m_indexes; -}; - -Q_DECLARE_METATYPE(MimeDataWithIndexes) - //================================================================================================== /// diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 46a9430810..909250cb02 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -35,6 +35,7 @@ #include "RigCaseCellResultsData.h" #include "RimStatisticsCase.h" #include "RimResultCase.h" +#include "RimMimeData.h" //-------------------------------------------------------------------------------------------------- ///