Renaming related to tree item root

p4#: 21355
This commit is contained in:
Magne Sjaastad 2013-04-22 10:49:31 +02:00
parent d034717460
commit a326fac204
3 changed files with 28 additions and 18 deletions

View File

@ -919,7 +919,7 @@ void RiuMainWindow::setPdmRoot(caf::PdmObject* pdmRoot)
m_pdmRoot = pdmRoot; m_pdmRoot = pdmRoot;
caf::PdmUiTreeItem* treeItemRoot = caf::UiTreeItemBuilderPdm::buildViewItems(NULL, -1, m_pdmRoot); caf::PdmUiTreeItem* treeItemRoot = caf::UiTreeItemBuilderPdm::buildViewItems(NULL, -1, m_pdmRoot);
m_treeModelPdm->setRoot(treeItemRoot); m_treeModelPdm->setTreeItemRoot(treeItemRoot);
if (treeItemRoot && m_treeView->selectionModel()) if (treeItemRoot && m_treeView->selectionModel())
{ {

View File

@ -31,23 +31,23 @@ namespace caf
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
UiTreeModelPdm::UiTreeModelPdm(QObject* parent) UiTreeModelPdm::UiTreeModelPdm(QObject* parent)
{ {
m_root = NULL; m_treeItemRoot = NULL;
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void UiTreeModelPdm::setRoot(PdmUiTreeItem* root) void UiTreeModelPdm::setTreeItemRoot(PdmUiTreeItem* root)
{ {
beginResetModel(); beginResetModel();
if (m_root) if (m_treeItemRoot)
{ {
delete m_root; delete m_treeItemRoot;
} }
m_root = root; m_treeItemRoot = root;
endResetModel(); endResetModel();
} }
@ -56,7 +56,7 @@ void UiTreeModelPdm::setRoot(PdmUiTreeItem* root)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QModelIndex UiTreeModelPdm::index(int row, int column, const QModelIndex &parentIndex /*= QModelIndex( ) */) const QModelIndex UiTreeModelPdm::index(int row, int column, const QModelIndex &parentIndex /*= QModelIndex( ) */) const
{ {
if (!m_root) if (!m_treeItemRoot)
return QModelIndex(); return QModelIndex();
if (!hasIndex(row, column, parentIndex)) if (!hasIndex(row, column, parentIndex))
@ -65,7 +65,7 @@ QModelIndex UiTreeModelPdm::index(int row, int column, const QModelIndex &parent
PdmUiTreeItem* parentItem = NULL; PdmUiTreeItem* parentItem = NULL;
if (!parentIndex.isValid()) if (!parentIndex.isValid())
parentItem = m_root; parentItem = m_treeItemRoot;
else else
parentItem = UiTreeModelPdm::getTreeItemFromIndex(parentIndex); parentItem = UiTreeModelPdm::getTreeItemFromIndex(parentIndex);
@ -82,7 +82,7 @@ QModelIndex UiTreeModelPdm::index(int row, int column, const QModelIndex &parent
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QModelIndex UiTreeModelPdm::parent(const QModelIndex &childIndex) const QModelIndex UiTreeModelPdm::parent(const QModelIndex &childIndex) const
{ {
if (!m_root) return QModelIndex(); if (!m_treeItemRoot) return QModelIndex();
if (!childIndex.isValid()) return QModelIndex(); if (!childIndex.isValid()) return QModelIndex();
@ -92,7 +92,7 @@ QModelIndex UiTreeModelPdm::parent(const QModelIndex &childIndex) const
PdmUiTreeItem* parentItem = childItem->parent(); PdmUiTreeItem* parentItem = childItem->parent();
if (!parentItem) return QModelIndex(); if (!parentItem) return QModelIndex();
if (parentItem == m_root) return QModelIndex(); if (parentItem == m_treeItemRoot) return QModelIndex();
return createIndex(parentItem->row(), 0, parentItem); return createIndex(parentItem->row(), 0, parentItem);
} }
@ -102,7 +102,7 @@ QModelIndex UiTreeModelPdm::parent(const QModelIndex &childIndex) const
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
int UiTreeModelPdm::rowCount(const QModelIndex &parentIndex /*= QModelIndex( ) */) const int UiTreeModelPdm::rowCount(const QModelIndex &parentIndex /*= QModelIndex( ) */) const
{ {
if (!m_root) if (!m_treeItemRoot)
return 0; return 0;
if (parentIndex.column() > 0) if (parentIndex.column() > 0)
@ -110,7 +110,7 @@ int UiTreeModelPdm::rowCount(const QModelIndex &parentIndex /*= QModelIndex( ) *
PdmUiTreeItem* parentItem; PdmUiTreeItem* parentItem;
if (!parentIndex.isValid()) if (!parentIndex.isValid())
parentItem = m_root; parentItem = m_treeItemRoot;
else else
parentItem = UiTreeModelPdm::getTreeItemFromIndex(parentIndex); parentItem = UiTreeModelPdm::getTreeItemFromIndex(parentIndex);
@ -122,7 +122,7 @@ int UiTreeModelPdm::rowCount(const QModelIndex &parentIndex /*= QModelIndex( ) *
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
int UiTreeModelPdm::columnCount(const QModelIndex &parentIndex /*= QModelIndex( ) */) const int UiTreeModelPdm::columnCount(const QModelIndex &parentIndex /*= QModelIndex( ) */) const
{ {
if (!m_root) if (!m_treeItemRoot)
return 0; return 0;
if (parentIndex.isValid()) if (parentIndex.isValid())
@ -138,7 +138,7 @@ int UiTreeModelPdm::columnCount(const QModelIndex &parentIndex /*= QModelIndex(
} }
} }
else else
return m_root->columnCount(); return m_treeItemRoot->columnCount();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -146,7 +146,7 @@ int UiTreeModelPdm::columnCount(const QModelIndex &parentIndex /*= QModelIndex(
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
QVariant UiTreeModelPdm::data(const QModelIndex &index, int role /*= Qt::DisplayRole */) const QVariant UiTreeModelPdm::data(const QModelIndex &index, int role /*= Qt::DisplayRole */) const
{ {
if (!m_root) if (!m_treeItemRoot)
return QVariant(); return QVariant();
if (!index.isValid()) if (!index.isValid())
@ -362,7 +362,7 @@ bool UiTreeModelPdm::removeRows_special(int position, int rows, const QModelInde
} }
else else
{ {
parentItem = m_root; parentItem = m_treeItemRoot;
} }
if (!parentItem) return true; if (!parentItem) return true;
@ -401,6 +401,14 @@ void UiTreeModelPdm::rebuildUiSubTree(PdmObject* root)
} }
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PdmUiTreeItem* UiTreeModelPdm::treeItemRoot()
{
return m_treeItemRoot;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@ -43,7 +43,9 @@ class UiTreeModelPdm : public QAbstractItemModel
public: public:
UiTreeModelPdm(QObject* parent); UiTreeModelPdm(QObject* parent);
void setRoot(PdmUiTreeItem* root); void setTreeItemRoot(PdmUiTreeItem* root);
PdmUiTreeItem* treeItemRoot();
void emitDataChanged(const QModelIndex& index); void emitDataChanged(const QModelIndex& index);
static PdmUiTreeItem* getTreeItemFromIndex(const QModelIndex& index); static PdmUiTreeItem* getTreeItemFromIndex(const QModelIndex& index);
@ -70,7 +72,7 @@ protected:
QModelIndex getModelIndexFromPdmObjectRecursive(const QModelIndex& currentIndex, const PdmObject * object) const; QModelIndex getModelIndexFromPdmObjectRecursive(const QModelIndex& currentIndex, const PdmObject * object) const;
private: private:
PdmUiTreeItem* m_root; PdmUiTreeItem* m_treeItemRoot;
}; };