1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
5 * KWorship is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 2 of the License, or *
8 * (at your option) any later version. *
10 * KWorship is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with KWorship. If not, write to the Free Software Foundation, *
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
21 * @file UpBackendNode.cpp
22 * @brief A presentations node for a backend.
23 * @author James Hogan <james@albanarts.com>
26 #include "UpBackendNode.h"
27 #include "UpBackend.h"
28 #include "UpPresentationNode.h"
35 * Constructors + destructor.
38 /// Primary constructor.
39 UpBackendNode::UpBackendNode(DefaultModelNode
* parent
, UpBackend
* item
)
40 : DefaultModelNode(parent
)
46 UpBackendNode::~UpBackendNode()
54 UpBackend
* UpBackendNode::getItem()
59 UpPresentationNode
* UpBackendNode::getPresentationNode(UpPresentation
* presentation
)
61 int numPresentations
= getNumCachedChildren();
62 for (int i
= 0; i
< numPresentations
; ++i
)
64 UpPresentationNode
* node
= dynamic_cast<UpPresentationNode
*>(getCachedChild(i
));
65 if (0 != node
&& node
->getItem() == presentation
)
77 QVariant
UpBackendNode::getData(int role
, int column
)
79 if (role
== Qt::DisplayRole
)
83 return m_item
->name();
86 else if (role
== Qt::DecorationRole
)
90 return m_item
->icon();
96 int UpBackendNode::getChildCount() const
98 return m_item
->presentations().size();
101 DefaultModelNode
* UpBackendNode::_getChild(int index
)
103 QList
<UpPresentation
*> presentations
= m_item
->presentations();
104 UpPresentation
* presentation
= presentations
.at(index
);
105 return new UpPresentationNode(this, presentation
);