#1401 Add ModelChangeDetector

This commit is contained in:
Magne Sjaastad 2017-04-19 22:25:31 +02:00
parent 1e3af05879
commit 82b6e4b8f2
4 changed files with 147 additions and 1 deletions

View File

@ -28,6 +28,8 @@ set( PROJECT_FILES
cafPdmUiFieldSpecialization.h
cafPdmUiItem.cpp
cafPdmUiItem.h
cafPdmUiModelChangeDetector.cpp
cafPdmUiModelChangeDetector.h
cafPdmUiObjectEditorHandle.cpp
cafPdmUiObjectEditorHandle.h
cafPdmUiObjectHandle.cpp

View File

@ -2,7 +2,7 @@
#include "cafAssert.h"
#include "cafPdmFieldHandle.h"
#include "cafPdmUiModelChangeDetector.h"
#include "cafPdmUiObjectHandle.h"
namespace caf
@ -38,6 +38,8 @@ void PdmUiFieldHandle::notifyFieldChanged(const QVariant& oldFieldValue, const Q
// Update field editors
this->updateConnectedEditors();
PdmUiModelChangeDetector::instance()->setModelIsChanged();
}
}

View File

@ -0,0 +1,84 @@
//##################################################################################################
//
// Copyright (C) Ceetron Solutions 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 "cafPdmUiModelChangeDetector.h"
namespace caf {
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUiModelChangeDetector::PdmUiModelChangeDetector()
: m_modelIsChanged(false)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUiModelChangeDetector* PdmUiModelChangeDetector::instance()
{
static PdmUiModelChangeDetector staticInstance;
return &staticInstance;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiModelChangeDetector::setModelIsChanged()
{
m_modelIsChanged = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiModelChangeDetector::reset()
{
m_modelIsChanged = false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PdmUiModelChangeDetector::isModelChanged() const
{
return m_modelIsChanged;
}
} // end namespace caf

View File

@ -0,0 +1,58 @@
//##################################################################################################
//
// Copyright (C) Ceetron Solutions 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
namespace caf
{
class PdmUiModelChangeDetector
{
public:
static PdmUiModelChangeDetector* instance();
void setModelIsChanged();
void reset();
bool isModelChanged() const;
private:
PdmUiModelChangeDetector();
private:
bool m_modelIsChanged;
};
} // End of namespace caf