defuze.me  Client
listsitem.cpp
00001 /**************************************************************************
00002 ** defuze.me Epitech Innovative Project
00003 **
00004 ** Copyright 2010-2012
00005 **   Athena Calmettes - Jocelyn De La Rosa - Francois Gaillard
00006 **   Adrien Jarthon - Alexandre Moore - Luc Peres - Arnaud Sellier
00007 **
00008 ** All rights reserved.
00009 **************************************************************************/
00010 
00011 #include "listsitem.hpp"
00012 #include "listsmodel.hpp"
00013 #include <QDebug>
00014 
00015 using namespace Lists;
00016 
00017 ListsItem::ListsItem(const QString &title, QPixmap icon, ListsModel *model, EditableTreeItem *parent)
00018     : EditableTreeItem(title, parent), icon(icon), model(model)
00019 {
00020     id = 0;
00021 }
00022 
00023 bool ListsItem::insertChildren(int position, int count, int columns)
00024 {
00025     Q_UNUSED(columns)
00026 
00027     if (position < 0 || position > childItems.size())
00028         return false;
00029 
00030     for (int row = 0; row < count; ++row) {
00031         ListsItem *item = new ListsItem("", QPixmap(), model, this);
00032         childItems.insert(position, item);
00033     }
00034 
00035     return true;
00036 }
00037 
00038 ListsItem *ListsItem::child(int number)
00039 {
00040     return static_cast<ListsItem*>(childItems.value(number));
00041 }
00042 
00043 ListsItem::Kind ListsItem::getKind() const
00044 {
00045     return kind;
00046 }
00047 
00048 ListsItem::SubKind ListsItem::getSubKind() const
00049 {
00050     return subKind;
00051 }
00052 
00053 void ListsItem::setKind(ListsItem::Kind kind)
00054 {
00055     this->kind = kind;
00056 }
00057 
00058 void ListsItem::setSubKind(ListsItem::SubKind subKind)
00059 {
00060     this->subKind = subKind;
00061 }
00062 
00063 ListsModel *ListsItem::getModel() const
00064 {
00065     return model;
00066 }
00067 
00068 bool ListsItem::isOfKind(Kind _kind)
00069 {
00070     if (kind == _kind)
00071         return true;
00072     return false;
00073 }
00074 
00075 bool ListsItem::isOfKind(Kind _kind, SubKind _subKind)
00076 {
00077     if (kind == _kind && subKind == _subKind)
00078         return true;
00079     return false;
00080 }
00081 
00082 unsigned int ListsItem::getId() const
00083 {
00084     return id;
00085 }
00086 
00087 void ListsItem::setId(unsigned int id)
00088 {
00089     this->id = id;
00090 }