Commit 89d410a5 authored by Stéphane Albert's avatar Stéphane Albert

REFAC: Code cleanup (removed disabled code).

parent c85eb301
......@@ -58,87 +58,6 @@ const char* Application::DATASET_EXT = ".ds";
/*****************************************************************************/
/* STATIC IMPLEMENTATION SECTION */
#if 0
/*****************************************************************************/
void
Application
::DatasetPathName( QString& path,
QString& name,
const QString& imageFilename )
{
// '/tmp/archive.tar.gz'
QFileInfo fileInfo( imageFilename );
#if 0
// Dataset is stored into image-file path.
// E.g. '/tmp'
path = fileInfo.path();
#else
// Dataset is stored into application cache-directory.
// E.g. '$HOME/<CACHE_DIR>'
path = Application::Instance()->GetCacheDir().path();
#endif
// '[_tmp_]archive.tar.gz.<SUFFIX>'
name =
#if 1
fileInfo.canonicalPath().replace( QRegExp( "[/\\\\:]+" ), "_") +
"_" +
#endif
fileInfo.fileName() +
Application::DATASET_EXT;
}
/*****************************************************************************/
DatasetModel*
Application::LoadDatasetModel( const QString& imageFilename,
int width,
int height )
{
// New model.
DatasetModel* model = new DatasetModel();
// Retrive path and name.
QString path;
QString name;
Application::DatasetPathName( path, name, imageFilename );
qDebug() << "Dataset path: " << path;
qDebug() << "Dataset name: " << name;
// Setup QObject
model->setObjectName( QDir( path ).filePath( name ) );
try
{
// try if the filename is valid
VectorImageModel::EnsureValidImage(imageFilename);
// Build model (relink to cached data).
DatasetModel::BuildContext context( path, name, width, height );
model->BuildModel( &context );
// Load image if DatasetModel is empty.
if( !model->HasSelectedImageModel() )
{
// Import image from filename given (w; h) size to choose
// best-fit resolution.
model->ImportImage( imageFilename, width, height );
}
}
catch( std::exception& exc )
{
delete model;
model = NULL;
throw;
}
return model;
}
#endif
/*****************************************************************************/
/* CLASS IMPLEMENTATION SECTION */
......@@ -146,15 +65,8 @@ Application::LoadDatasetModel( const QString& imageFilename,
/*******************************************************************************/
Application
::Application( int& argc, char** argv ) :
I18nApplication( argc, argv )//,
#if 0
m_Model( NULL )
#endif
I18nApplication( argc, argv )
{
#if 0
InitializeCore();
#endif
QObject::connect(
this, SIGNAL( aboutToQuit() ),
this, SLOT( OnAboutToQuit() )
......@@ -167,25 +79,6 @@ Application
{
}
/*******************************************************************************/
#if 0
void
Application
::SetModel( AbstractModel* model )
{
emit AboutToChangeSelectedModel( model );
delete m_Model;
m_Model = model;
if( model!=NULL )
m_Model->setParent( this );
emit SelectedModelChanged( m_Model );
}
#endif
/*******************************************************************************/
void
Application
......@@ -199,38 +92,6 @@ Application
);
}
/*******************************************************************************/
#if 0
void
Application
::InitializeCore()
{
//
// Setup application tags.
//
QCoreApplication::setApplicationName(
PROJECT_NAME
);
QCoreApplication::setApplicationVersion(
Monteverdi2_VERSION_STRING
);
//
// Setup organization tags.
//
QCoreApplication::setOrganizationName(
"OrfeoToolBox");
QCoreApplication::setOrganizationDomain(
"orfeo-toolbox.org"
);
#ifndef Q_WS_MAC
setWindowIcon(QIcon(QLatin1String(":/images/application_icon")));
#endif
}
#endif
/*******************************************************************************/
bool
Application
......
......@@ -99,26 +99,6 @@ public:
/** \brief Destructor. */
virtual ~Application();
#if 0
/**
*/
inline const AbstractModel* GetModel() const;
/**
*/
inline AbstractModel* GetModel();
/**
*/
template< typename TModel >
inline const TModel* GetModel() const;
/**
*/
template< typename TModel >
inline TModel* GetModel();
#endif
/**
*
*/
......@@ -170,47 +150,15 @@ public:
*/
inline static const Application* ConstInstance();
#if 0
/**
*/
static
void DatasetPathName( QString& path,
QString& name,
const QString& imageFilename );
/**
*/
static
DatasetModel* LoadDatasetModel( const QString& imageFilename,
int width,
int height );
#endif
//
// PUBLIC SLOTS.
public slots:
#if 0
/**
*/
// Method could be inline but it's better not new/delete in inline
// methods (heap and memory-alignment contexts).
void SetModel( AbstractModel* model );
#endif
/*-[ SIGNALS SECTION ]-----------------------------------------------------*/
//
// Signals.
signals:
#if 0
/**
*/
void AboutToChangeSelectedModel( const AbstractModel* );
/**
*/
void SelectedModelChanged( AbstractModel* );
#endif
/*-[ PROTECTED SECTION ]---------------------------------------------------*/
......@@ -229,20 +177,10 @@ protected:
//
// Private methods.
private:
#if 0
/**
*/
void InitializeCore();
#endif
//
// Private attributes.
private:
#if 0
/**
*/
AbstractModel* m_Model;
#endif
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
......@@ -275,46 +213,6 @@ Application
return I18nApplication::ConstInstance< Application >();
}
#if 0
/*****************************************************************************/
inline
const AbstractModel*
Application
::GetModel() const
{
return m_Model;
}
/*****************************************************************************/
inline
AbstractModel*
Application
::GetModel()
{
return m_Model;
}
/*****************************************************************************/
template< typename TModel >
inline
const TModel*
Application
::GetModel() const
{
return qobject_cast< const TModel* >( m_Model );
}
/*****************************************************************************/
template< typename TModel >
inline
TModel*
Application
::GetModel()
{
return qobject_cast< TModel* >( m_Model );
}
#endif
/*****************************************************************************/
} // end namespace 'mvd'
......
......@@ -196,17 +196,6 @@ I18nApplication
m_Model( NULL ),
m_IsRunningFromBuildDir( false )
{
#if 0
// Initialize internationlization.
InitializeLocale();
//
// Force numeric options of locale to "C"
// See issue #635
//
// TODO: Move into I18nApplication.
setlocale( LC_NUMERIC, "C" );
#endif
}
/*******************************************************************************/
......@@ -284,88 +273,6 @@ I18nApplication
return isNew;
}
#if 0
/*******************************************************************************/
bool
I18nApplication
::CheckCacheDirIsCorrect()
{
QDir dir = m_CacheDir;
if (!TestDirExistenceAndWriteAcess(dir))
{
return false;
}
else
{
// Check if this directory has the good name
if (m_CacheDir.dirName().compare(QString(I18nApplication::DEFAULT_CACHE_DIR_NAME)))
{
return false;
}
}
return true;
}
/*******************************************************************************/
bool
I18nApplication
::TestDirExistenceAndWriteAcess( QDir dir)
{
// Check if this directory exists
if (!dir.exists())
{
return false;
}
// Check if we can write in this directory
if (dir.mkdir("testWriteAccess"))
{ // ok this repository is correct
dir.rmdir("testWriteAccess");
}
else
{ // ko this repository is not correct
return false;
}
return true;
}
#endif
#if 0
/*******************************************************************************/
bool
I18nApplication
::HasSettingsFile()
{
// The settings file should contain the cacheDir key to be valid
QSettings settings;
settings.sync();
return ( (settings.status()==QSettings::NoError) && settings.contains("cacheDir"));
}
/*******************************************************************************/
void
I18nApplication
::ReadCacheDirFromSettings()
{
QSettings settings;
QString cacheDirSetting = settings.value("cacheDir").toString();
m_CacheDir.setPath(cacheDirSetting);
}
/*******************************************************************************/
void
I18nApplication
::WriteCacheDirIntoSettings()
{
QSettings settings;
settings.setValue("cacheDir", m_CacheDir.path());
}
#endif
/*******************************************************************************/
void
I18nApplication
......
......@@ -196,23 +196,6 @@ public:
*/
bool MakeCacheDir( const QString& cacheDirStr );
#if 0
/**
* \brief Check if the cache directory is valid.
*
* \return true if the cache directory is correct
*/
bool CheckCacheDirIsCorrect();
/**
* \brief Test if the application can write in the directory provided.
*
* \param dir input directory
* \return true if the directory can be used
*/
bool TestDirExistenceAndWriteAcess( QDir dir);
#endif
/**
* \brief Get the cache directory.
*
......@@ -224,20 +207,6 @@ public:
// APPLICATION SETTINGS.
//
#if 0
/**
*/
bool HasSettingsFile();
/**
*/
void ReadCacheDirFromSettings();
/**
*/
void WriteCacheDirIntoSettings();
#endif
/**
*/
// TODO: Move method into ApplicationSettings class.
......@@ -539,16 +508,6 @@ I18nApplication
return m_CacheDir;
}
/*****************************************************************************/
#if 0
const char*
I18nApplication
::GetCacheDirName() const
{
return I18nApplication::CACHE_DIR_NAME;
}
#endif
/*****************************************************************************/
inline
bool
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment