PageRenderTime 122ms CodeModel.GetById 81ms app.highlight 5ms RepoModel.GetById 34ms app.codeStats 0ms

/src/libtomahawk/playlist/dynamic/database/DatabaseControl.h

http://github.com/tomahawk-player/tomahawk
C Header | 81 lines | 43 code | 18 blank | 20 comment | 0 complexity | 0ecbd27f7ea3d80fdc0fd525c91565bf MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
 4 *
 5 *   Tomahawk 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 3 of the License, or
 8 *   (at your option) any later version.
 9 *
10 *   Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef DATABASE_CONTROL_H
20#define DATABASE_CONTROL_H
21
22#include "playlist/dynamic/DynamicControl.h"
23
24#include <QTimer>
25
26namespace Tomahawk
27{
28
29    class DatabaseControl : public DynamicControl
30    {
31        Q_OBJECT
32    public:
33        virtual QWidget* inputField();
34        virtual QWidget* matchSelector();
35
36        virtual QString input() const;
37        virtual QString match() const;
38        virtual QString matchString() const;
39        virtual QString summary() const;
40
41        virtual void setInput(const QString& input);
42        virtual void setMatch(const QString& match);
43
44        /// DO NOT USE IF YOU ARE NOT A DBCMD
45        DatabaseControl( const QString& type, const QStringList& typeSelectors, QObject* parent = 0 );
46        DatabaseControl( const QString& sql, const QString& summary, const QStringList& typeSelectors, QObject* parent = 0 );
47
48        QString sql() const;
49
50    public slots:
51        virtual void setSelectedType ( const QString& type );
52
53    private slots:
54        void updateData();
55        void editingFinished();
56        void editTimerFired();
57
58    private:
59        void updateWidgets();
60        void updateWidgetsFromData();
61
62        // utility
63        void calculateSummary();
64
65        QPointer< QWidget > m_input;
66        QPointer< QWidget > m_match;
67        QString m_matchData;
68        QString m_matchString;
69        QString m_summary;
70
71        QTimer m_editingTimer;
72        QTimer m_delayedEditTimer;
73
74        // SQL control
75        QString m_sql;
76        QString m_sqlSummary;
77    };
78
79};
80
81#endif