Commit 2f089c05 authored by Stéphane Albert's avatar Stéphane Albert

ENH: Replaced DatasetTreeWidgetItem::GetId() by ::GetHash().

parent 729974d4
...@@ -447,11 +447,11 @@ DatabaseBrowserController ...@@ -447,11 +447,11 @@ DatabaseBrowserController
if( currentDatasetItem!=NULL ) if( currentDatasetItem!=NULL )
{ {
QString datasetId = currentDatasetItem->GetId(); QString datasetHash( currentDatasetItem->GetHash() );
// qDebug() << "Checking dataset:" << currentDatasetItem->GetId(); // qDebug() << "Checking dataset:" << currentDatasetItem->GetId();
const DatasetModel* datasetModel = model->FindDatasetModel( datasetId ); const DatasetModel* datasetModel = model->FindDatasetModel( datasetHash );
assert( datasetModel!=NULL ); assert( datasetModel!=NULL );
// check consistency // check consistency
...@@ -591,7 +591,7 @@ DatabaseBrowserController ...@@ -591,7 +591,7 @@ DatabaseBrowserController
/*******************************************************************************/ /*******************************************************************************/
void void
DatabaseBrowserController DatabaseBrowserController
::OnDatasetToDeleteSelected( const QString& id ) ::OnDatasetToDeleteSelected( const QString& hash )
{ {
// Access database-model. // Access database-model.
assert( GetModel()==GetModel< DatabaseModel >() ); assert( GetModel()==GetModel< DatabaseModel >() );
...@@ -599,7 +599,7 @@ DatabaseBrowserController ...@@ -599,7 +599,7 @@ DatabaseBrowserController
assert( databaseModel!=NULL ); assert( databaseModel!=NULL );
// Access selected dataset-model (candidate to deletion). // Access selected dataset-model (candidate to deletion).
DatasetModel* datasetModel = databaseModel->FindDatasetModel( id ); DatasetModel* datasetModel = databaseModel->FindDatasetModel( hash );
assert( datasetModel!=NULL ); assert( datasetModel!=NULL );
// Pop confirm delete dialog. // Pop confirm delete dialog.
...@@ -614,7 +614,7 @@ DatabaseBrowserController ...@@ -614,7 +614,7 @@ DatabaseBrowserController
if( button==QMessageBox::No ) if( button==QMessageBox::No )
return; return;
databaseModel->RemoveDatasetModel( id ); databaseModel->RemoveDatasetModel( hash );
} }
} // end namespace 'mvd' } // end namespace 'mvd'
...@@ -146,7 +146,7 @@ private: ...@@ -146,7 +146,7 @@ private:
/** /**
*/ */
void Foo( QTreeWidgetItem* item, SqlId tagNodeId ); void Foo( QTreeWidgetItem* item, SqlId nodeId );
// //
// AbstractModelController overrides. // AbstractModelController overrides.
...@@ -173,10 +173,13 @@ private slots: ...@@ -173,10 +173,13 @@ private slots:
/** /**
* \brief Slot called when the currently selected dataset has changed. * \brief Slot called when the currently selected dataset has changed.
* *
* \param id The ID of the newly selected dataset. * \param hash The hash string (unique name) of the newly selected
* \param previousId The ID of the previously selected dataset. * dataset.
* \param previousHash The hash string (unique name) of the
* previously selected dataset.
*/ */
void OnCurrentDatasetChanged( const QString& id, const QString& previousId ); void OnCurrentDatasetChanged( const QString& hash,
const QString& previousHash );
/** /**
*/ */
...@@ -188,7 +191,7 @@ private slots: ...@@ -188,7 +191,7 @@ private slots:
/** /**
*/ */
void OnDatasetToDeleteSelected( const QString& id ); void OnDatasetToDeleteSelected( const QString& hash );
// //
// AbstractModelController overloads. // AbstractModelController overloads.
......
...@@ -211,7 +211,7 @@ DatabaseBrowserWidget ...@@ -211,7 +211,7 @@ DatabaseBrowserWidget
// get the currentItem Id if any selected. // get the currentItem Id if any selected.
// since all the TreeWidgetItem are deleted next, need to remember // since all the TreeWidgetItem are deleted next, need to remember
// it in order to set it back // it in order to set it back
QString currentItemId; QString currentItemHash;
DatasetTreeWidgetItem* selectedItem = DatasetTreeWidgetItem* selectedItem =
dynamic_cast< DatasetTreeWidgetItem* >( dynamic_cast< DatasetTreeWidgetItem* >(
...@@ -220,7 +220,7 @@ DatabaseBrowserWidget ...@@ -220,7 +220,7 @@ DatabaseBrowserWidget
if (selectedItem) if (selectedItem)
{ {
currentItemId = selectedItem->GetId(); currentItemHash = selectedItem->GetHash();
} }
// TODO: Get initial algorithm back (synchronizes two ordered // TODO: Get initial algorithm back (synchronizes two ordered
...@@ -253,10 +253,10 @@ DatabaseBrowserWidget ...@@ -253,10 +253,10 @@ DatabaseBrowserWidget
{ {
// current alias // current alias
const StringPairListType::value_type::first_type& alias = it->first; const StringPairListType::value_type::first_type& alias = it->first;
const StringPairListType::value_type::second_type& id = it->second; const StringPairListType::value_type::second_type& hash = it->second;
DatasetTreeWidgetItem* item = DatasetTreeWidgetItem* item =
new DatasetTreeWidgetItem( m_DatasetRootItem, id, alias ); new DatasetTreeWidgetItem( m_DatasetRootItem, hash, alias );
// Item is visible is search-text is empty or if alias contains // Item is visible is search-text is empty or if alias contains
// search-text. // search-text.
...@@ -266,7 +266,7 @@ DatabaseBrowserWidget ...@@ -266,7 +266,7 @@ DatabaseBrowserWidget
); );
// was it the selected item ? // was it the selected item ?
if( currentItemId == id ) if( currentItemHash == hash )
{ {
// ...add this child item as currentItem // ...add this child item as currentItem
GetDatabaseTreeWidget()->setCurrentItem( item ); GetDatabaseTreeWidget()->setCurrentItem( item );
...@@ -309,7 +309,7 @@ DatabaseBrowserWidget ...@@ -309,7 +309,7 @@ DatabaseBrowserWidget
/*****************************************************************************/ /*****************************************************************************/
void void
DatabaseBrowserWidget DatabaseBrowserWidget
::SetCurrentDataset( const QString& id ) ::SetCurrentDataset( const QString& hash )
{ {
// qDebug() << this << "::SetCurrentDataset(" << id << ")"; // qDebug() << this << "::SetCurrentDataset(" << id << ")";
...@@ -318,7 +318,7 @@ DatabaseBrowserWidget ...@@ -318,7 +318,7 @@ DatabaseBrowserWidget
QList< QTreeWidgetItem* > items( QList< QTreeWidgetItem* > items(
m_UI->databaseTreeWidget->findItems( m_UI->databaseTreeWidget->findItems(
id, hash,
Qt::MatchExactly | Qt::MatchRecursive, Qt::MatchExactly | Qt::MatchRecursive,
1 1
) )
...@@ -360,29 +360,29 @@ DatabaseBrowserWidget ...@@ -360,29 +360,29 @@ DatabaseBrowserWidget
// Current // Current
// TODO: Should be DatabaseModel::DatasetId but widgets should not depend on models!!! // TODO: Should be DatabaseModel::DatasetId but widgets should not depend on models!!!
QString currentId; QString currentHash;
DatasetTreeWidgetItem* currentItem = dynamic_cast< DatasetTreeWidgetItem* >( current ); DatasetTreeWidgetItem* currentItem = dynamic_cast< DatasetTreeWidgetItem* >( current );
if( currentItem!=NULL && currentItem->parent()!=NULL ) if( currentItem!=NULL && currentItem->parent()!=NULL )
// if current is root and not NULL get the Id of the corresponding // if current is root and not NULL get the Id of the corresponding
// Dataset. // Dataset.
currentId = currentItem->GetId(); currentHash = currentItem->GetHash();
// //
// Previous // Previous
// TODO: Should be DatabaseModel::DatasetId but widgets should not depend on models!!! // TODO: Should be DatabaseModel::DatasetId but widgets should not depend on models!!!
QString previousId; QString previousHash;
DatasetTreeWidgetItem* previousItem = dynamic_cast< DatasetTreeWidgetItem* >( previous ); DatasetTreeWidgetItem* previousItem = dynamic_cast< DatasetTreeWidgetItem* >( previous );
if( previousItem!=NULL ) if( previousItem!=NULL )
previousId = previousItem->GetId(); previousHash = previousItem->GetHash();
// //
// Emit event. // Emit event.
emit CurrentDatasetChanged( currentId, previousId ); emit CurrentDatasetChanged( currentHash, previousHash );
} }
/*******************************************************************************/ /*******************************************************************************/
......
...@@ -170,11 +170,13 @@ signals: ...@@ -170,11 +170,13 @@ signals:
/** /**
* \brief Slot emitted when the currently selected dataset has changed. * \brief Slot emitted when the currently selected dataset has changed.
* *
* \param id ID of newly selected dataset. * \param currentHash Hash string (unique name) of newly selected
* \param previousId ID of the previously selected dataset. * dataset.
* \param previousHash Hash string (unique name) of the previously
* selected dataset.
*/ */
void CurrentDatasetChanged( const QString& id, void CurrentDatasetChanged( const QString& currentHash,
const QString& previousId =QString() ); const QString& previousHash =QString() );
/*-[ PROTECTED SECTION ]---------------------------------------------------*/ /*-[ PROTECTED SECTION ]---------------------------------------------------*/
......
...@@ -284,7 +284,7 @@ DatabaseTreeWidget::OnItemChanged( QTreeWidgetItem* item , int column) ...@@ -284,7 +284,7 @@ DatabaseTreeWidget::OnItemChanged( QTreeWidgetItem* item , int column)
dynamic_cast<DatasetTreeWidgetItem *>( item ); dynamic_cast<DatasetTreeWidgetItem *>( item );
// send the new alias of the dataset / it identifier // send the new alias of the dataset / it identifier
emit DatasetRenamed(dsItem->text(column), dsItem->GetId() ); emit DatasetRenamed(dsItem->text(column), dsItem->GetHash() );
} }
else else
{ {
...@@ -333,7 +333,7 @@ DatabaseTreeWidget ...@@ -333,7 +333,7 @@ DatabaseTreeWidget
DatasetTreeWidgetItem* item DatasetTreeWidgetItem* item
= dynamic_cast<DatasetTreeWidgetItem *>( currentItem()); = dynamic_cast<DatasetTreeWidgetItem *>( currentItem());
emit DatasetToDeleteSelected( item->GetId() ); emit DatasetToDeleteSelected( item->GetHash() );
break; break;
} }
...@@ -365,7 +365,7 @@ DatabaseTreeWidget::OnCustomContextMenuRequested(const QPoint& pos) ...@@ -365,7 +365,7 @@ DatabaseTreeWidget::OnCustomContextMenuRequested(const QPoint& pos)
// use a QSignalMapper to bundle parameterless signals and re-emit // use a QSignalMapper to bundle parameterless signals and re-emit
// them with parameters (QString here) // them with parameters (QString here)
QSignalMapper *signalMapperDelete = new QSignalMapper( this ); QSignalMapper *signalMapperDelete = new QSignalMapper( this );
signalMapperDelete->setMapping( deleteNodeChild, item->GetId() ); signalMapperDelete->setMapping( deleteNodeChild, item->GetHash() );
QObject::connect( deleteNodeChild , QObject::connect( deleteNodeChild ,
SIGNAL(triggered()), SIGNAL(triggered()),
......
...@@ -60,7 +60,6 @@ namespace mvd ...@@ -60,7 +60,6 @@ namespace mvd
// //
// Internal classes pre-declaration. // Internal classes pre-declaration.
class BackgroundTask;
/*****************************************************************************/ /*****************************************************************************/
/* CLASS DEFINITION SECTION */ /* CLASS DEFINITION SECTION */
...@@ -85,7 +84,7 @@ public: ...@@ -85,7 +84,7 @@ public:
*/ */
DatasetTreeWidgetItem( QTreeWidgetItem* parent, DatasetTreeWidgetItem( QTreeWidgetItem* parent,
const QString& id, const QString& id,
const QString& alias, const QString& text,
const QStringList& columns = QStringList() ); const QStringList& columns = QStringList() );
/** /**
...@@ -96,7 +95,7 @@ public: ...@@ -96,7 +95,7 @@ public:
/** /**
* \brief Get the datasetID * \brief Get the datasetID
*/ */
inline QString GetId() const; inline QString GetHash() const;
/*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/ /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
...@@ -150,7 +149,7 @@ namespace mvd ...@@ -150,7 +149,7 @@ namespace mvd
inline inline
QString QString
DatasetTreeWidgetItem DatasetTreeWidgetItem
::GetId() const ::GetHash() const
{ {
return text( 1 ); return text( 1 );
} }
......
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