Edit song books dialog does a bit more and some of backend implemented
[kworship.git] / kworship / songdb / KwSongdbFilterNode.h
blobe4196f1be50fc46eac8b797b3b7ea62f0fd79b85
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 #ifndef _KwSongdbFilterNode_h_
21 #define _KwSongdbFilterNode_h_
23 /**
24 * @file KwSongdbFilterNode.h
25 * @brief A node for filtering songs.
26 * @author James Hogan <james@albanarts.com>
29 #include "KwSongdbNode.h"
30 #include "KwSongdbFilter.h"
32 #include <QString>
34 class QSqlQuery;
36 /// A node for filtering songs.
37 class KwSongdbFilterNode : public KwSongdbNode
39 public:
42 * Constructors + destructor
45 /// Primary constructor.
46 KwSongdbFilterNode(const KwSongdbFilterLevelList* filters, QString label, KwSongdbNode* parent);
48 /// Destructor.
49 virtual ~KwSongdbFilterNode();
52 * Associated data access
55 virtual KwSongdbSong* associatedSong();
56 virtual KwSongdbVersion* associatedSongVersion();
59 * Main interface
62 /// Get data associated with the node.
63 virtual QVariant getData(int role, int column);
65 /// Get the number of children.
66 virtual int getChildCount() const;
68 /// Get flags for this item.
69 virtual Qt::ItemFlags getFlags(Qt::ItemFlags defaultFlags) const;
71 /// Get mime data string for this set of songs.
72 virtual QString mimeData();
74 protected:
76 /// Get a child node by index.
77 virtual KwSongdbNode* _getChild(int index);
79 /// Get a new node of this type.
80 KwSongdbFilterNode* _newNode(QString label, QString idExpression, int idValue);
82 /// Get a new final node.
83 KwSongdbNode* _newFinalNode(QString label, int id, const QIcon& icon);
85 private:
88 * Types
91 /// A known value from a previous filter.
92 struct KnownValue
94 QString idExpression;
95 int idValue;
96 KnownValue* next;
100 * Variables
103 /// Label.
104 QString m_label;
106 /// The shared list of filters.
107 const KwSongdbFilterLevelList* m_filterLevels;
109 /// The current filter level we're on.
110 int m_currentFilter;
112 /// The list of known values.
113 KnownValue m_knownValue;
115 /// Current SQL query.
116 QSqlQuery* m_query;
119 * Private constructors
122 /// Primary constructor.
123 KwSongdbFilterNode(KwSongdbFilterNode* parent, QString label, QString knownIdExpression, int knownId);
126 * Private functions
129 /// Setup the query.
130 void setupQuery();
133 #endif // _KwSongdbFilterNode_h_