Basic openoffice.org control, and listening for new presentation documents, still...
[kworship.git] / unipresent / common / UpBackendNode.cpp
blob80d55c8f6bf88bb0e8bcedca31ff3dea6b4ce6ff
1 /***************************************************************************
2 * This file is part of KWorship. *
3 * Copyright 2008 James Hogan <james@albanarts.com> *
4 * *
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. *
9 * *
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. *
14 * *
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 ***************************************************************************/
20 /**
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"
30 #include <KIcon>
32 #include <cassert>
35 * Constructors + destructor.
38 /// Primary constructor.
39 UpBackendNode::UpBackendNode(DefaultModelNode* parent, UpBackend* item)
40 : DefaultModelNode(parent)
41 , m_item(item)
45 /// Destructor.
46 UpBackendNode::~UpBackendNode()
51 * Accessors
54 UpBackend* UpBackendNode::getItem()
56 return m_item;
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)
67 return node;
70 return 0;
74 * Main interface
77 QVariant UpBackendNode::getData(int role, int column)
79 if (role == Qt::DisplayRole)
81 if (column == 0)
83 return m_item->name();
86 else if (role == Qt::DecorationRole)
88 if (column == 0)
90 return m_item->icon();
93 return QVariant();
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);