New element panel can read the embedded collection of project (only at opening, other fonctionnality isn't created yet)

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4287 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2015-12-16 17:16:15 +00:00
parent 593f8eb4f1
commit 4f222d2843
14 changed files with 644 additions and 31 deletions

View File

@@ -19,6 +19,7 @@
#include "elementcollectionitem.h"
#include "qetapp.h"
#include "fileelementcollectionitem.h"
#include "xmlprojectelementcollectionitem.h"
/**
* @brief ElementsCollectionModel::ElementsCollectionModel
@@ -262,3 +263,46 @@ void ElementsCollectionModel::addCustomCollection()
else
delete feci;
}
/**
* @brief ElementsCollectionModel::addProject
* Add @project to the disalyed collection
* @param project
* @return true if project was successfully added. If project is already
* handled, return false.
*/
bool ElementsCollectionModel::addProject(QETProject *project)
{
if (m_project_list.contains(project)) return false;
m_project_list.append(project);
int row = m_project_list.indexOf(project);
beginInsertRows(QModelIndex(), row, row);
XmlProjectElementCollectionItem *xpeci = new XmlProjectElementCollectionItem(project, m_root_item);
bool r = m_root_item->insertChild(row, xpeci);
endInsertRows();
return r;
}
bool ElementsCollectionModel::removeProject(QETProject *project)
{
if (!m_project_list.contains(project)) return false;
int row = m_project_list.indexOf(project);
if (removeRows(row, 1, QModelIndex()))
{
m_project_list.removeOne(project);
return true;
}
else
return false;
}
/**
* @brief ElementsCollectionModel::project
* @return A list of project handled by this model
*/
QList<QETProject *> ElementsCollectionModel::project() const {
return m_project_list;
}