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

BUG: MANTIS-928 and MANTIS-822 (selected dataset after image has been imported).

parent 5f960144
......@@ -278,6 +278,9 @@ void
DatabaseBrowserController
::UpdateTree( QTreeWidgetItem* item, SqlId nodeId, int level )
{
// qDebug()
// << this << "::UpdateTree(" << item << "," << nodeId << "," << level << ")";
assert( GetModel()==GetModel< DatabaseModel >() );
DatabaseModel* model = GetModel< DatabaseModel >();
......@@ -317,9 +320,10 @@ DatabaseBrowserController
#if ENABLE_TREE_QDEBUG
qDebug()
<< "Node:"
<< child->text( 0 )
<< child->text( 1 )
<< child->data( 1, TreeWidgetItem::ITEM_ROLE_ID );
<< child->text( TreeWidgetItem::COLUMN_INDEX_TEXT )
<< child->text( TreeWidgetItem::COLUMN_INDEX_ID )
<< child->data( TreeWidgetItem::COLUMN_INDEX_ID,
TreeWidgetItem::ITEM_ROLE_ID );
#endif
container = &nodes;
break;
......@@ -330,10 +334,11 @@ DatabaseBrowserController
#if ENABLE_TREE_QDEBUG
qDebug()
<< "Leaf:"
<< child->text( 0 )
<< child->text( 1 )
<< child->data( 1, TreeWidgetItem::ITEM_ROLE_ID )
<< child->text( 2 );
<< child->text( TreeWidgetItem::COLUMN_INDEX_TEXT )
<< child->text( TreeWidgetItem::COLUMN_INDEX_ID )
<< child->data( TreeWidgetItem::COLUMN_INDEX_ID,
TreeWidgetItem::ITEM_ROLE_ID )
<< child->text( TreeWidgetItem::COLUMN_INDEX_HASH );
#endif
container = &leaves;
break;
......@@ -341,7 +346,10 @@ DatabaseBrowserController
// Others.
default:
others.push_back( child );
qDebug() << "Other:" << child->type() << child->text( 0 );
qDebug()
<< "Other:"
<< child->type()
<< child->text( TreeWidgetItem::COLUMN_INDEX_TEXT );
break;
}
......@@ -349,7 +357,10 @@ DatabaseBrowserController
{
TreeWidgetItemMap::iterator it(
container->insert(
child->data( 1, TreeWidgetItem::ITEM_ROLE_ID ).toString(),
child->data(
TreeWidgetItem::COLUMN_INDEX_ID,
TreeWidgetItem::ITEM_ROLE_ID
).toString(),
child
)
);
......@@ -361,9 +372,10 @@ DatabaseBrowserController
qDebug()
<< "Duplicate:"
<< child->type()
<< it.value()->text( 0 )
<< it.value()->text( 1 )
<< it.value()->data( 1, TreeWidgetItem::ITEM_ROLE_ID );
<< it.value()->text( TreeWidgetItem::COLUMN_INDEX_TEXT )
<< it.value()->text( TreeWidgetItem::COLUMN_INDEX_ID )
<< it.value()->data( TreeWidgetItem::COLUMN_INDEX_ID,
TreeWidgetItem::ITEM_ROLE_ID );
#endif
duplicates.push_back( it.value() );
......@@ -424,7 +436,10 @@ DatabaseBrowserController
TreeWidgetItemMap::iterator it( leaves.begin() );
#if ENABLE_TREE_QDEBUG
qDebug() << "-Leaf:" << it.key() << it.value()->text( 0 );
qDebug()
<< "-Leaf:"
<< it.key()
<< it.value()->text( TreeWidgetItem::COLUMN_INDEX_TEXT );
#endif
delete it.value();
......@@ -504,7 +519,10 @@ DatabaseBrowserController
TreeWidgetItemMap::iterator it( nodes.begin() );
#if ENABLE_TREE_QDEBUG
qDebug() << "-Node:" << it.key() << it.value()->text( 0 );
qDebug()
<< "-Node:"
<< it.key()
<< it.value()->text( TreeWidgetItem::COLUMN_INDEX_TEXT );
#endif
delete it.value();
......@@ -735,7 +753,13 @@ DatabaseBrowserController
if( id.isEmpty() )
return;
assert( GetModel()==GetModel< DatabaseModel >() );
DatabaseModel* model = GetModel< DatabaseModel >();
assert( model!=NULL );
assert( GetWidget()==GetWidget< DatabaseBrowserWidget >() );
DatabaseBrowserWidget* widget = GetWidget< DatabaseBrowserWidget >();
assert( widget!=NULL );
try
{
......@@ -758,7 +782,9 @@ DatabaseBrowserController
GetWidget< DatabaseBrowserWidget >()->SetCurrentDataset( previousId );
*/
emit SelectedDatasetFilenameChanged( QString() );
// emit SelectedDatasetFilenameChanged( QString() );
widget->SetCurrentDataset( QString() );
return;
}
......@@ -776,11 +802,14 @@ DatabaseBrowserController
GetWidget< DatabaseBrowserWidget >()->SetCurrentDataset( previousId );
*/
emit SelectedDatasetFilenameChanged( QString() );
// emit SelectedDatasetFilenameChanged( QString() );
widget->SetCurrentDataset( QString() );
return;
}
/*
// emit selected dataset image filename
VectorImageModel * imageModel
= qobject_cast< VectorImageModel *>(
......@@ -791,6 +820,9 @@ DatabaseBrowserController
// this signal is used to pass the current dataset input filename.
// it is connected to the DatabaseBrowserWidget custom QTreeWidget
emit SelectedDatasetFilenameChanged( imageModel->GetFilename() );
*/
widget->SetCurrentDataset( id );
}
/*******************************************************************************/
......
......@@ -109,7 +109,7 @@ signals:
/**
*/
void SelectedDatasetFilenameChanged( const QString& );
// void SelectedDatasetFilenameChanged( const QString& );
/*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
......
......@@ -253,7 +253,7 @@ void
DatabaseBrowserWidget
::SetCurrentDataset( const QString& hash )
{
// qDebug() << this << "::SetCurrentDataset(" << id << ")";
// qDebug() << this << "::SetCurrentDataset(" << hash << ")";
assert( m_UI!=NULL );
assert( m_UI->databaseTreeWidget!=NULL );
......@@ -262,31 +262,25 @@ DatabaseBrowserWidget
m_UI->databaseTreeWidget->findItems(
hash,
Qt::MatchExactly | Qt::MatchRecursive,
1
TreeWidgetItem::COLUMN_INDEX_HASH
)
);
assert( items.isEmpty() || items.size() == 1 );
/*
qDebug()
<< ( items.isEmpty() ? "NONE" : items.first()->text( 0 ) )
<< m_UI->databaseTreeWidget->selectionModel()->selectedIndexes().size();
*/
#if 0
m_UI->databaseTreeWidget->setCurrentItem(
items.isEmpty() ? NULL : items.first(),
0,
m_UI->databaseTreeWidget->setCurrentItem(
items.isEmpty()
? NULL
: items.first(),
TreeWidgetItem::COLUMN_INDEX_TEXT,
QItemSelectionModel::Clear |
QItemSelectionModel::Select |
QItemSelectionModel::Current
);
#else
if( items.isEmpty() )
return;
m_UI->databaseTreeWidget->setCurrentItem( items.first() );
#endif
}
/*****************************************************************************/
......
......@@ -222,6 +222,7 @@ TreeWidget
QTreeWidget( parent )
{
setDefaultDropAction( Qt::MoveAction );
// setDefaultDropAction( Qt::CopyAction );
setDragEnabled( true );
......
......@@ -81,6 +81,13 @@ class Monteverdi2_EXPORT TreeWidgetItem :
//
// Public types.
public:
enum ColumnIndex
{
COLUMN_INDEX_TEXT = 0,
COLUMN_INDEX_ID = 1,
COLUMN_INDEX_HASH = 2,
};
enum ItemType
{
ITEM_TYPE_NONE = QTreeWidgetItem::UserType,
......@@ -223,7 +230,7 @@ QVariant
TreeWidgetItem
::GetId() const
{
return data( 1, TreeWidgetItem::ITEM_ROLE_ID );
return data( COLUMN_INDEX_ID, TreeWidgetItem::ITEM_ROLE_ID );
}
/*****************************************************************************/
......@@ -232,8 +239,8 @@ void
TreeWidgetItem
::SetId( const QVariant& id )
{
setData( 1, TreeWidgetItem::ITEM_ROLE_ID, id );
setText( 1, id.toString() );
setData( COLUMN_INDEX_ID, TreeWidgetItem::ITEM_ROLE_ID, id );
setText( COLUMN_INDEX_ID, id.toString() );
}
/*****************************************************************************/
......@@ -242,7 +249,7 @@ QString
TreeWidgetItem
::GetText() const
{
return text( 0 );
return text( COLUMN_INDEX_TEXT );
}
/*****************************************************************************/
......@@ -251,7 +258,7 @@ QString
TreeWidgetItem
::GetHash() const
{
return text( 2 );
return text( COLUMN_INDEX_HASH );
}
} // end namespace 'mvd'
......
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