1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
4
* Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
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.
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.
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/>.
20
#include "DatabaseControl.h"
22
using namespace Tomahawk;
24
DatabaseControl::DatabaseControl( const QString& selectedType, const QStringList& typeSelectors, QObject* parent )
25
: DynamicControl ( selectedType.isEmpty() ? "Artist" : selectedType, typeSelectors, parent )
27
setType( "database" );
29
m_editingTimer.setInterval( 500 ); //timeout to edits
30
m_editingTimer.setSingleShot( true );
31
connect( &m_editingTimer, SIGNAL( timeout() ), this, SLOT( editTimerFired() ) );
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() ) );
39
DatabaseControl::DatabaseControl( const QString& sql, const QString& summary, const QStringList& typeSelectors, QObject* parent )
40
: DynamicControl ( "SQL", typeSelectors )
42
, m_sqlSummary( summary )
45
setType( "database" );
49
QString DatabaseControl::input() const
55
QWidget* DatabaseControl::inputField()
60
QString DatabaseControl::match() const
65
QWidget* DatabaseControl::matchSelector()
70
QString DatabaseControl::matchString() const
75
void DatabaseControl::setInput ( const QString& input )
82
void DatabaseControl::setMatch ( const QString& match )
89
void DatabaseControl::setSelectedType ( const QString& type )
91
if ( type != selectedType() ) {
92
if ( !m_input.isNull() )
93
delete m_input.data();
94
if ( !m_match.isNull() )
95
delete m_match.data();
97
Tomahawk::DynamicControl::setSelectedType ( type );
100
// qDebug() << "Setting new type, set data to:" << m_data.first << m_data.second;
104
void DatabaseControl::editingFinished()
109
void DatabaseControl::editTimerFired()
114
void DatabaseControl::updateData()
119
void DatabaseControl::updateWidgets()
124
void DatabaseControl::updateWidgetsFromData()
129
void DatabaseControl::calculateSummary()
131
if( !m_sqlSummary.isEmpty() )
137
DatabaseControl::sql() const
144
DatabaseControl::summary() const
146
if( !m_sqlSummary.isEmpty() )