Commit 38c9cc53 authored by Stéphane Albert's avatar Stéphane Albert
parent 3d68e789
......@@ -823,7 +823,7 @@ MainWindow
/*****************************************************************************/
void
MainWindow
::ImportImage( const QString& filename )
::ImportImage( const QString& filename, bool forceCreate )
{
//
// Background task.
......@@ -833,6 +833,7 @@ MainWindow
ImageImporter* importer =
new ImageImporter(
filename,
forceCreate,
m_ImageView->width(), m_ImageView->height()
);
......@@ -921,7 +922,7 @@ MainWindow
//
// Import the image
ImportImage( filename );
ImportImage( filename, false );
}
/*****************************************************************************/
......@@ -1482,7 +1483,7 @@ MainWindow
// catalog database.
// import the result image into the database
ImportImage( outfname );
ImportImage( outfname, true );
}
/*****************************************************************************/
......@@ -1518,7 +1519,7 @@ void
MainWindow
::OnImageToImportDropped(const QString & fname)
{
ImportImage( fname );
ImportImage( fname, false );
}
} // end namespace 'mvd'
......@@ -129,7 +129,7 @@ signals:
// Protected methods.
protected:
void ImportImage( const QString & filename );
void ImportImage( const QString& filename, bool forceCreate );
//
// QMainWindow overrides.
......
......@@ -67,7 +67,8 @@ ImageLoader
try
{
DatasetModel* model = Application::LoadDatasetModel(
m_Filename, m_Width, m_Height );
m_Filename, m_Width, m_Height, false
);
// We can only push to another thread,
// so thread affinity must be set here,
......
......@@ -321,7 +321,7 @@ DatasetModel
m_Directory = workingDir;
// Initialize content.
if( isEmpty )
if( isEmpty || buildContext->m_IsForceCreateEnabled )
{
// Create in-memory descriptor.
assert( m_Descriptor==NULL );
......
......@@ -103,13 +103,15 @@ public:
const QString& name,
const QString& alias,
int width,
int height ) :
int height,
bool isForceCreateEnabled =false ) :
m_Path( path ),
m_Name( name ),
m_Alias( alias),
m_Width( width ),
m_Height( height ),
m_IsLoadSubModelsEnabled( true )
m_IsLoadSubModelsEnabled( true ),
m_IsForceCreateEnabled( isForceCreateEnabled )
{
}
......@@ -121,7 +123,8 @@ public:
m_Alias(),
m_Width( -1 ),
m_Height( -1 ),
m_IsLoadSubModelsEnabled( false )
m_IsLoadSubModelsEnabled( false ),
m_IsForceCreateEnabled( false )
{
}
......@@ -132,7 +135,8 @@ public:
m_Alias(),
m_Width( width ),
m_Height( height ),
m_IsLoadSubModelsEnabled( true )
m_IsLoadSubModelsEnabled( true ),
m_IsForceCreateEnabled( false )
{
}
......@@ -144,7 +148,19 @@ public:
QString m_Alias;
int m_Width;
int m_Height;
bool m_IsLoadSubModelsEnabled;
bool m_IsLoadSubModelsEnabled: 1;
bool m_IsForceCreateEnabled: 1;
/*
union
{
struct
{
bool m_IsLoadSubModelsEnabled: 1;
bool m_IsForceCreateEnabled: 1;
};
unsigned char m_Flags;
};
*/
};
//
......
......@@ -161,7 +161,8 @@ DatasetModel*
I18nCoreApplication
::LoadDatasetModel( const QString& imageFilename,
int width,
int height )
int height,
bool forceCreate )
{
// New model.
DatasetModel* model = new DatasetModel();
......@@ -187,7 +188,7 @@ I18nCoreApplication
// Build model (relink to cached data).
DatasetModel::BuildContext context(
path, name, finfo.baseName(), width, height
path, name, finfo.baseName(), width, height, forceCreate
);
model->BuildModel( &context );
......
......@@ -272,13 +272,16 @@ public:
* \param imageFilename The input image filename.
* \param with The width (in pixels) of the screen best fit.
* \param height The height (in pixels) of the screen best fit.
* \param forceCreate true to force dataset creation even if there
* is already an existing non-empty dataset directory.
*
* \return The loaded DatasetModel instance or NULL if the method has failed.
*/
static
DatasetModel* LoadDatasetModel( const QString& imageFilename,
int width,
int height );
int height,
bool forceCreate );
/**
* \brief Get the cache directory.
......
......@@ -69,13 +69,15 @@ namespace
/*******************************************************************************/
ImageImporter
::ImageImporter( const QString& filename,
bool isForceCreateEnabled,
int width,
int height,
QObject* parent ) :
AbstractWorker( parent ),
m_Filename( filename ),
m_Width( width ),
m_Height( height )
m_Height( height ),
m_IsForceCreateEnabled( isForceCreateEnabled )
{
}
......@@ -100,7 +102,10 @@ ImageImporter
emit ProgressRangeChanged( 0, 0 );
// Load dataset-model.
return I18nCoreApplication::LoadDatasetModel( m_Filename, m_Width, m_Height );
return
I18nCoreApplication::LoadDatasetModel(
m_Filename, m_Width, m_Height, m_IsForceCreateEnabled
);
}
/*******************************************************************************/
......
......@@ -89,8 +89,10 @@ public:
* \param filename Filename of image to import.
* \param width Width of the best-fit size or -1 if none.
* \param height Height of the best-fit size or -1 if none.
* \param isForceCreateEnabled true to force creation of dataset.
*/
ImageImporter( const QString& filename,
bool isForceCreateEnabled,
int width =-1,
int height =-1,
QObject* parent =NULL );
......@@ -160,6 +162,9 @@ private:
/**
*/
int m_Height;
/**
*/
bool m_IsForceCreateEnabled: 1;
/*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
......
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