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 KwSongdbVersionNode.cpp
22 * @brief A node for a song version.
23 * @author James Hogan <james@albanarts.com>
26 #include "KwSongdbVersionNode.h"
28 #include "KwSongdbVersion.h"
29 #include "KwSongdbVersionNode.h"
35 * Constructors + destructor
38 /// Primary constructor.
39 KwSongdbVersionNode::KwSongdbVersionNode(KwSongdbNode
* parent
, QString label
, int id
)
40 : KwSongdbNode(parent
)
45 if (m_label
.isEmpty())
47 m_label
= i18n("Default version");
52 KwSongdbVersionNode::~KwSongdbVersionNode()
57 * Associated data access
60 KwSongdbSong
* KwSongdbVersionNode::associatedSong()
62 return KwSongdb::self()->songVersionById(m_id
)->song();
65 KwSongdbVersion
* KwSongdbVersionNode::associatedSongVersion()
67 return KwSongdb::self()->songVersionById(m_id
);
74 /// Get data associated with the node.
75 QVariant
KwSongdbVersionNode::getData(int role
, int column
)
77 if (role
== Qt::DisplayRole
)
84 else if (role
== Qt::DecorationRole
)
94 /// Get flags for this item.
95 Qt::ItemFlags
KwSongdbVersionNode::getFlags(Qt::ItemFlags defaultFlags
) const
97 return Qt::ItemIsDragEnabled
| defaultFlags
;
100 /// Get mime data string for this set of songs.
101 QString
KwSongdbVersionNode::mimeData()
103 return QString("songdb %1").arg(m_id
);
106 /// Override the icon to display.
107 void KwSongdbVersionNode::setIcon(const QIcon
& icon
)