mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1401 Move serialization of tree view state to a single location
This commit is contained in:
parent
31852ba94f
commit
4ec6dc3796
@ -48,8 +48,9 @@
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEclipseWellCollection.h"
|
||||
#include "RimFaultCollection.h"
|
||||
#include "RimFormationNamesCollection.h"
|
||||
#include "RimFlowCharacteristicsPlot.h"
|
||||
#include "RimFlowPlotCollection.h"
|
||||
#include "RimFormationNamesCollection.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechCellColors.h"
|
||||
#include "RimGeoMechModels.h"
|
||||
@ -66,13 +67,13 @@
|
||||
#include "RimSummaryCurveFilter.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimTreeViewStateSerializer.h"
|
||||
#include "RimViewLinker.h"
|
||||
#include "RimViewLinkerCollection.h"
|
||||
#include "RimWellAllocationPlot.h"
|
||||
#include "RimWellLogPlot.h"
|
||||
#include "RimWellLogPlotCollection.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimFlowPlotCollection.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
|
||||
#include "RiuMainPlotWindow.h"
|
||||
@ -115,6 +116,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
#include <QTreeView>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@ -618,6 +620,47 @@ void RiaApplication::loadAndUpdatePlotData()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::storeTreeViewState()
|
||||
{
|
||||
{
|
||||
if (mainPlotWindow() && mainPlotWindow()->projectTreeView())
|
||||
{
|
||||
caf::PdmUiTreeView* projectTreeView = mainPlotWindow()->projectTreeView();
|
||||
|
||||
QString treeViewState;
|
||||
RimTreeViewStateSerializer::storeTreeViewStateToString(projectTreeView->treeView(), treeViewState);
|
||||
|
||||
QModelIndex mi = projectTreeView->treeView()->currentIndex();
|
||||
|
||||
QString encodedModelIndexString;
|
||||
RimTreeViewStateSerializer::encodeStringFromModelIndex(mi, encodedModelIndexString);
|
||||
|
||||
project()->plotWindowTreeViewState = treeViewState;
|
||||
project()->plotWindowCurrentModelIndexPath = encodedModelIndexString;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
caf::PdmUiTreeView* projectTreeView = RiuMainWindow::instance()->projectTreeView();
|
||||
if (projectTreeView)
|
||||
{
|
||||
QString treeViewState;
|
||||
RimTreeViewStateSerializer::storeTreeViewStateToString(projectTreeView->treeView(), treeViewState);
|
||||
|
||||
QModelIndex mi = projectTreeView->treeView()->currentIndex();
|
||||
|
||||
QString encodedModelIndexString;
|
||||
RimTreeViewStateSerializer::encodeStringFromModelIndex(mi, encodedModelIndexString);
|
||||
|
||||
project()->mainWindowTreeViewState = treeViewState;
|
||||
project()->mainWindowCurrentModelIndexPath = encodedModelIndexString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Add a list of well path file paths (JSON files) to the well path collection
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -775,6 +818,8 @@ bool RiaApplication::saveProjectAs(const QString& fileName)
|
||||
{
|
||||
m_project->fileName = fileName;
|
||||
|
||||
storeTreeViewState();
|
||||
|
||||
if (!m_project->writeFile())
|
||||
{
|
||||
QMessageBox::warning(NULL, "Error when saving project file", QString("Not possible to save project file. Make sure you have sufficient access rights.\n\nProject file location : %1").arg(fileName));
|
||||
|
@ -212,6 +212,8 @@ private:
|
||||
void deleteMainPlotWindow();
|
||||
|
||||
void loadAndUpdatePlotData();
|
||||
|
||||
void storeTreeViewState();
|
||||
|
||||
private slots:
|
||||
void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
|
@ -44,8 +44,6 @@ void RicSaveProjectAsFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
|
||||
RicSaveProjectFeature::storeTreeViewState();
|
||||
|
||||
app->saveProjectPromptForFileName();
|
||||
}
|
||||
|
||||
|
@ -20,16 +20,7 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimTreeViewStateSerializer.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuMainPlotWindow.h"
|
||||
|
||||
#include "cafPdmUiTreeView.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QTreeView>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicSaveProjectFeature, "RicSaveProjectFeature");
|
||||
|
||||
@ -50,8 +41,6 @@ void RicSaveProjectFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
|
||||
RicSaveProjectFeature::storeTreeViewState();
|
||||
|
||||
app->saveProject();
|
||||
}
|
||||
|
||||
@ -65,44 +54,3 @@ void RicSaveProjectFeature::setupActionLook(QAction* actionToSetup)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSaveProjectFeature::storeTreeViewState()
|
||||
{
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
if (app->mainPlotWindow() && app->mainPlotWindow()->projectTreeView())
|
||||
{
|
||||
caf::PdmUiTreeView* projectTreeView = app->mainPlotWindow()->projectTreeView();
|
||||
|
||||
QString treeViewState;
|
||||
RimTreeViewStateSerializer::storeTreeViewStateToString(projectTreeView->treeView(), treeViewState);
|
||||
|
||||
QModelIndex mi = projectTreeView->treeView()->currentIndex();
|
||||
|
||||
QString encodedModelIndexString;
|
||||
RimTreeViewStateSerializer::encodeStringFromModelIndex(mi, encodedModelIndexString);
|
||||
|
||||
RiaApplication::instance()->project()->plotWindowTreeViewState = treeViewState;
|
||||
RiaApplication::instance()->project()->plotWindowCurrentModelIndexPath = encodedModelIndexString;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
caf::PdmUiTreeView* projectTreeView = RiuMainWindow::instance()->projectTreeView();
|
||||
if (projectTreeView)
|
||||
{
|
||||
QString treeViewState;
|
||||
RimTreeViewStateSerializer::storeTreeViewStateToString(projectTreeView->treeView(), treeViewState);
|
||||
|
||||
QModelIndex mi = projectTreeView->treeView()->currentIndex();
|
||||
|
||||
QString encodedModelIndexString;
|
||||
RimTreeViewStateSerializer::encodeStringFromModelIndex(mi, encodedModelIndexString);
|
||||
|
||||
RiaApplication::instance()->project()->mainWindowTreeViewState = treeViewState;
|
||||
RiaApplication::instance()->project()->mainWindowCurrentModelIndexPath = encodedModelIndexString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,9 +28,6 @@ class RicSaveProjectFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void storeTreeViewState();
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled() override;
|
||||
|
Loading…
Reference in New Issue
Block a user