~ubuntu-branches/ubuntu/trusty/tomahawk/trusty-proposed

« back to all changes in this revision

Viewing changes to src/libtomahawk/playlist/dynamic/database/DatabaseControl.cpp

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-03-07 21:50:13 UTC
  • Revision ID: package-import@ubuntu.com-20130307215013-6gdjkdds7i9uenvs
Tags: upstream-0.6.0+dfsg
ImportĀ upstreamĀ versionĀ 0.6.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 
2
 *
 
3
 *   Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
 
4
 *   Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
 
5
 *
 
6
 *   Tomahawk is free software: you can redistribute it and/or modify
 
7
 *   it under the terms of the GNU General Public License as published by
 
8
 *   the Free Software Foundation, either version 3 of the License, or
 
9
 *   (at your option) any later version.
 
10
 *
 
11
 *   Tomahawk is distributed in the hope that it will be useful,
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
14
 *   GNU General Public License for more details.
 
15
 *
 
16
 *   You should have received a copy of the GNU General Public License
 
17
 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include "DatabaseControl.h"
 
21
 
 
22
using namespace Tomahawk;
 
23
 
 
24
DatabaseControl::DatabaseControl( const QString& selectedType, const QStringList& typeSelectors, QObject* parent )
 
25
: DynamicControl ( selectedType.isEmpty() ? "Artist" : selectedType, typeSelectors, parent )
 
26
{
 
27
    setType( "database" );
 
28
 
 
29
    m_editingTimer.setInterval( 500 ); //timeout to edits
 
30
    m_editingTimer.setSingleShot( true );
 
31
    connect( &m_editingTimer, SIGNAL( timeout() ), this, SLOT( editTimerFired() ) );
 
32
 
 
33
    m_delayedEditTimer.setInterval( 250 ); // additional timer for "just typing" without enter or focus change
 
34
    m_delayedEditTimer.setSingleShot( true );
 
35
    connect( &m_delayedEditTimer, SIGNAL( timeout() ), &m_editingTimer, SLOT( start() ) );
 
36
 
 
37
}
 
38
 
 
39
DatabaseControl::DatabaseControl( const QString& sql, const QString& summary, const QStringList& typeSelectors, QObject* parent )
 
40
    : DynamicControl ( "SQL", typeSelectors )
 
41
    , m_sql( sql )
 
42
    , m_sqlSummary( summary )
 
43
{
 
44
    Q_UNUSED( parent );
 
45
    setType( "database" );
 
46
}
 
47
 
 
48
 
 
49
QString DatabaseControl::input() const
 
50
{
 
51
    // TODO
 
52
    return QString();
 
53
}
 
54
 
 
55
QWidget* DatabaseControl::inputField()
 
56
{
 
57
    return 0;
 
58
}
 
59
 
 
60
QString DatabaseControl::match() const
 
61
{
 
62
    return m_matchData;
 
63
}
 
64
 
 
65
QWidget* DatabaseControl::matchSelector()
 
66
{
 
67
    return 0;
 
68
}
 
69
 
 
70
QString DatabaseControl::matchString() const
 
71
{
 
72
    return m_matchString;
 
73
}
 
74
 
 
75
void DatabaseControl::setInput ( const QString& input )
 
76
{
 
77
    Q_UNUSED( input );
 
78
    // TODO
 
79
    updateWidgets();
 
80
}
 
81
 
 
82
void DatabaseControl::setMatch ( const QString& match )
 
83
{
 
84
    m_matchData = match;
 
85
 
 
86
    updateWidgets();
 
87
}
 
88
 
 
89
void DatabaseControl::setSelectedType ( const QString& type )
 
90
{
 
91
    if ( type != selectedType() ) {
 
92
        if ( !m_input.isNull() )
 
93
            delete m_input.data();
 
94
        if ( !m_match.isNull() )
 
95
            delete m_match.data();
 
96
 
 
97
        Tomahawk::DynamicControl::setSelectedType ( type );
 
98
        updateWidgets();
 
99
        updateData();
 
100
        //        qDebug() << "Setting new type, set data to:" << m_data.first << m_data.second;
 
101
    }
 
102
}
 
103
 
 
104
void DatabaseControl::editingFinished()
 
105
{
 
106
 
 
107
}
 
108
 
 
109
void DatabaseControl::editTimerFired()
 
110
{
 
111
 
 
112
}
 
113
 
 
114
void DatabaseControl::updateData()
 
115
{
 
116
 
 
117
}
 
118
 
 
119
void DatabaseControl::updateWidgets()
 
120
{
 
121
 
 
122
}
 
123
 
 
124
void DatabaseControl::updateWidgetsFromData()
 
125
{
 
126
 
 
127
}
 
128
 
 
129
void DatabaseControl::calculateSummary()
 
130
{
 
131
    if( !m_sqlSummary.isEmpty() )
 
132
        return;
 
133
 
 
134
}
 
135
 
 
136
QString
 
137
DatabaseControl::sql() const
 
138
{
 
139
    return m_sql;
 
140
}
 
141
 
 
142
 
 
143
QString
 
144
DatabaseControl::summary() const
 
145
{
 
146
    if( !m_sqlSummary.isEmpty() )
 
147
        return m_sqlSummary;
 
148
 
 
149
    return m_summary;
 
150
}