Database: sqlite default to appdata kworship.db
[kworship.git] / kworship / songdb / KwSongdbVersionNode.cpp
blob5dac1f318522d02bea6ac0c4af65c234376d76b8
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 KwSongdbVersionNode.cpp
22 * @brief A node for a song version.
23 * @author James Hogan <james@albanarts.com>
26 #include "KwSongdbVersionNode.h"
27 #include "KwSongdb.h"
28 #include "KwSongdbVersion.h"
29 #include "KwSongdbVersionNode.h"
31 #include <KIcon>
32 #include <KLocale>
35 * Constructors + destructor
38 /// Primary constructor.
39 KwSongdbVersionNode::KwSongdbVersionNode(KwSongdbNode* parent, QString label, int id)
40 : KwSongdbNode(parent)
41 , m_label(label)
42 , m_id(id)
43 , m_icon()
45 if (m_label.isEmpty())
47 m_label = i18n("Default version");
51 /// Destructor.
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);
71 * Main interface
74 /// Get data associated with the node.
75 QVariant KwSongdbVersionNode::getData(int role, int column)
77 if (role == Qt::DisplayRole)
79 if (column == 0)
81 return m_label;
84 else if (role == Qt::DecorationRole)
86 if (column == 0)
88 return m_icon;
91 return QVariant();
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)
109 m_icon = icon;