Commit ae58b1d8 authored by Stéphane Albert's avatar Stéphane Albert

ENH: Generalized Common/Core/I18nApplication::closeEvent() (confirm...

ENH: Generalized Common/Core/I18nApplication::closeEvent() (confirm save/quit); Instanciated DatabaseModel and linked ::OpenDatabase() to main; Added exerimental) Common/Core/SerializableInterface and Common/Core/ModifiableInterface.
parent d46ad690
......@@ -54,15 +54,16 @@
int
main( int argc, char* argv[] )
{
// Initialize application and sync settings.
// 1. Initialize application and sync settings.
mvd::CatalogueApplication application( argc, argv );
application.Initialize();
// Initialize main-window (UI).
// 2. Initialize main-window (UI).
mvd::MainWindow mainWindow;
mainWindow.Initialize();
// 3. Initialize cache directory.
#if 0
// TODO: 1) MVD2-viewer: Factorize cache-dir search between Viewer & Catalogue.
if (!appHasSettingsFile || appHasIncorrectCacheDir)
......@@ -87,10 +88,13 @@ main( int argc, char* argv[] )
}
#endif
// Show window.
// 4. Initialize database.
application.OpenDatabase();
// 5. Show window.
mainWindow.show();
// Run application and return exit code.
// 6. Let's go: run the application and return exit code.
return application.exec();
}
......
......@@ -34,6 +34,7 @@
//
// Monteverdi includes (sorted by alphabetic order)
#include "Core/mvdDatabaseModel.h"
//
// Class implementation.
......@@ -72,6 +73,16 @@ CatalogueApplication
{
}
/*******************************************************************************/
void
CatalogueApplication
::OpenDatabase()
{
DatabaseModel* databaseModel = new DatabaseModel( this );
SetModel( databaseModel );
}
/*******************************************************************************/
void
CatalogueApplication
......
......@@ -96,6 +96,10 @@ public:
/** \brief Destructor. */
virtual ~CatalogueApplication();
/**
*/
void OpenDatabase();
/*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
public slots:
......@@ -116,7 +120,7 @@ protected:
// Protected attributes.
protected:
virtual void virtual_InitializeCore();
void virtual_InitializeCore();
/*-[ PRIVATE SECTION ]-----------------------------------------------------*/
......
......@@ -135,11 +135,11 @@ protected slots:
/**
*/
virtual void OnAboutToChangeModel( const AbstractModel* );
void OnAboutToChangeModel( const AbstractModel* );
/**
*/
virtual void OnModelChanged( AbstractModel* );
void OnModelChanged( AbstractModel* );
/*-[ PRIVATE SECTION ]-----------------------------------------------------*/
......
......@@ -12,8 +12,10 @@ set( Common_Core_SOURCES
mvdHistogramModel.cxx
mvdI18nApplication.cxx
mvdMath.cxx
mvdModifiableInterface.cxx
mvdMyClass.cxx
mvdQuicklookModel.cxx
mvdSerializableInterface.cxx
mvdSystemError.cxx
mvdTypes.cxx
mvdVectorImageModel.cxx
......
......@@ -81,6 +81,14 @@ AbstractModel
{
}
/*******************************************************************************/
void
AbstractModel
::virtual_Save()
{
qDebug() << this << "::Save()";
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
......
......@@ -112,6 +112,10 @@ public:
*/
virtual void ClearModified();
/**
*/
inline void Save();
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
//
......@@ -131,6 +135,10 @@ protected:
// derived-classes.
virtual void virtual_BuildModel( void* context =NULL ) =0;
/**
*/
virtual void virtual_Save();
//
// Protected attributes.
protected:
......@@ -222,6 +230,17 @@ AbstractModel
virtual_BuildModel( context );
}
/*****************************************************************************/
inline
void
AbstractModel
::Save()
{
virtual_Save();
ClearModified();
}
} // end namespace 'mvd'
#endif // __mvdAbstractModel_h
......@@ -58,7 +58,6 @@ namespace mvd
/*****************************************************************************/
/* STATIC IMPLEMENTATION SECTION */
/*****************************************************************************/
/* CLASS IMPLEMENTATION SECTION */
......@@ -87,23 +86,31 @@ bool
DatabaseModel
::IsModified() const
{
return false;
return true;
}
/*******************************************************************************/
#if 0
void
DatabaseModel
::ClearModified()
{
}
#endif
/*******************************************************************************/
#if 0
void
DatabaseModel
::Save()
::virtual_Save()
{
}
#endif
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
......
......@@ -109,16 +109,14 @@ public:
/** \brief Destructor. */
virtual ~DatabaseModel();
/**
*/
void Save();
//
// AbstractModel overrides.
virtual bool IsModified() const;
bool IsModified() const;
virtual void ClearModified();
#if 0
void ClearModified();
#endif
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
......@@ -135,9 +133,11 @@ protected:
//
// AbstractModel overrides.
/**
*/
virtual void virtual_BuildModel( void* context =NULL );
void virtual_BuildModel( void* context =NULL );
#if 0
void virtual_Save();
#endif
//
// Protected attributes.
......
......@@ -339,11 +339,9 @@ DatasetModel
/*******************************************************************************/
void
DatasetModel
::Save()
::virtual_Save()
{
WriteDescriptor();
ClearModified();
}
/*******************************************************************************/
......
......@@ -154,10 +154,6 @@ public:
*/
inline ConstAbstractImageModelList GetImageModels() const;
/**
*/
void Save();
//
// AbstractModel overrides.
......@@ -180,8 +176,9 @@ protected:
//
// AbstractModel overrides.
/** */
virtual void virtual_BuildModel( void* context =NULL );
void virtual_BuildModel( void* context =NULL );
void virtual_Save();
//
// Protected attributes.
......
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "mvdModifiableInterface.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
namespace mvd
{
/*
TRANSLATOR mvd::ModifiableInterface
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*****************************************************************************/
/* CLASS IMPLEMENTATION SECTION */
/*******************************************************************************/
ModifiableInterface
::ModifiableInterface()
{
}
/*******************************************************************************/
ModifiableInterface
::~ModifiableInterface()
{
}
/*******************************************************************************/
} // end namespace 'mvd'
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __mvdModifiableInterface_h
#define __mvdModifiableInterface_h
//
// Configuration include.
//// Included at first position before any other ones.
#include "ConfigureMonteverdi2.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
/*****************************************************************************/
/* PRE-DECLARATION SECTION */
//
// External classes pre-declaration.
namespace
{
}
namespace mvd
{
//
// Internal classes pre-declaration.
/*****************************************************************************/
/* CLASS DEFINITION SECTION */
/** \class ModifiableInterface
*
*/
class Monteverdi2_EXPORT ModifiableInterface
{
/*-[ PUBLIC SECTION ]------------------------------------------------------*/
//
// Public methods.
public:
/** Destructor */
virtual ~ModifiableInterface();
/**
*/
virtual bool IsModified() const =0;
/**
*/
virtual void ClearModified() =0;
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
//
// Protected methods.
protected:
/** Constructor */
ModifiableInterface();
//
// Protected attributes.
protected:
/*-[ PRIVATE SECTION ]-----------------------------------------------------*/
//
// Private methods.
private:
//
// Private attributes.
private:
};
} // end namespace 'mvd'.
/*****************************************************************************/
/* INLINE SECTION */
namespace mvd
{
} // end namespace 'mvd'
#endif // __mvdModifiableInterface_h
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "mvdSerializableInterface.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
namespace mvd
{
/*
TRANSLATOR mvd::SerializableInterface
Necessary for lupdate to be aware of C++ namespaces.
Context comment for translator.
*/
/*****************************************************************************/
/* CLASS IMPLEMENTATION SECTION */
/*******************************************************************************/
SerializableInterface
::SerializableInterface()
{
}
/*******************************************************************************/
SerializableInterface
::~SerializableInterface()
{
}
/*******************************************************************************/
} // end namespace 'mvd'
/*=========================================================================
Program: Monteverdi2
Language: C++
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See Copyright.txt for details.
Monteverdi2 is distributed under the CeCILL licence version 2. See
Licence_CeCILL_V2-en.txt or
http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __mvdSerializableInterface_h
#define __mvdSerializableInterface_h
//
// Configuration include.
//// Included at first position before any other ones.
#include "ConfigureMonteverdi2.h"
/*****************************************************************************/
/* INCLUDE SECTION */
//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
//
// System includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
#include "mvdModifiableInterface.h"
/*****************************************************************************/
/* PRE-DECLARATION SECTION */
//
// External classes pre-declaration.
namespace
{
}
namespace mvd
{
//
// Internal classes pre-declaration.
/*****************************************************************************/
/* CLASS DEFINITION SECTION */
/** \class SerializableInterface
*
*/
class Monteverdi2_EXPORT SerializableInterface :
public ModifiableInterface
{
/*-[ PUBLIC SECTION ]------------------------------------------------------*/
//
// Public methods.
public:
/** Destructor */
virtual ~SerializableInterface();
/**
*/
inline void Save();
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
//
// Protected methods.
protected:
/** Constructor */
SerializableInterface();
/**
*/
virtual void virtual_Save() =0;
//
// Protected attributes.
protected:
/*-[ PRIVATE SECTION ]-----------------------------------------------------*/
//
// Private methods.
private:
//
// Private attributes.
private:
};
} // end namespace 'mvd'.