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