mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 00:54:20 +02:00
fix more sql stuff
This commit is contained in:
@@ -34,13 +34,14 @@ DatabaseCommand_CreateDynamicPlaylist::exec( DatabaseImpl* lib )
|
||||
Q_ASSERT( !source().isNull() );
|
||||
|
||||
DatabaseCommand_CreatePlaylist::exec( lib );
|
||||
qDebug() << "Created normal playlist, now creating additional dynamic info!" << m_playlist.isNull();
|
||||
|
||||
TomahawkSqlQuery cre = lib->newquery();
|
||||
cre.prepare( "INSERT INTO dynamic_playlist( guid, pltype, plmode ) "
|
||||
"VALUES( :guid, :pltype, :plmode )" );
|
||||
cre.bindValue( ":guid", m_playlist->guid() );
|
||||
cre.bindValue( ":pltype", m_playlist->type() );
|
||||
cre.bindValue( ":plmode", m_playlist->mode() );
|
||||
"VALUES( ?, ?, ? )" );
|
||||
cre.bindValue( 0, m_playlist->guid() );
|
||||
cre.bindValue( 1, m_playlist->type() );
|
||||
cre.bindValue( 2, m_playlist->mode() );
|
||||
|
||||
qDebug() << "CREATE DYNPLAYLIST:" << cre.boundValues();
|
||||
|
||||
|
@@ -13,7 +13,7 @@ void DatabaseCommand_LoadAllPlaylists::exec( DatabaseImpl* dbi )
|
||||
TomahawkSqlQuery query = dbi->newquery();
|
||||
|
||||
query.exec( QString( "SELECT guid, title, info, creator, lastmodified, shared, currentrevision "
|
||||
"FROM playlist WHERE source %1" )
|
||||
"FROM playlist WHERE source %1 AND NOT dynplaylist" )
|
||||
.arg( source()->isLocal() ? "IS NULL" :
|
||||
QString( "=%1" ).arg( source()->id() )
|
||||
) );
|
||||
|
@@ -60,7 +60,8 @@ CREATE TABLE IF NOT EXISTS playlist (
|
||||
info TEXT,
|
||||
creator TEXT,
|
||||
lastmodified INTEGER NOT NULL DEFAULT 0,
|
||||
currentrevision TEXT REFERENCES playlist_revision(guid) DEFERRABLE INITIALLY DEFERRED
|
||||
currentrevision TEXT REFERENCES playlist_revision(guid) DEFERRABLE INITIALLY DEFERRED,
|
||||
dynplaylist BOOLEAN DEFAULT false
|
||||
);
|
||||
|
||||
--INSERT INTO playlist(guid, title, info, currentrevision)
|
||||
@@ -97,27 +98,27 @@ CREATE TABLE IF NOT EXISTS playlist_revision (
|
||||
previous_revision TEXT REFERENCES playlist_revision(guid) DEFERRABLE INITIALLY DEFERRED
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS dynamic_playlist {
|
||||
CREATE TABLE IF NOT EXISTS dynamic_playlist (
|
||||
guid TEXT PRIMARY KEY,
|
||||
pltype TEXT, -- the generator type
|
||||
plmode INTEGER -- the mode of this playlist
|
||||
};
|
||||
);
|
||||
|
||||
-- list of controls in each playlist. each control saves a selectedType, a match, and an input
|
||||
CREATE TABLE IF NOT EXISTS dynamic_playlist_controls {
|
||||
CREATE TABLE IF NOT EXISTS dynamic_playlist_controls (
|
||||
id TEXT PRIMARY KEY,
|
||||
playlist TEXT NOT NULL REFERENCES playlist(guid) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
selectedType TEXT,
|
||||
match TEXT,
|
||||
input TEXT
|
||||
};
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS dynamic_playlist_revision {
|
||||
CREATE TABLE IF NOT EXISTS dynamic_playlist_revision (
|
||||
guid TEXT PRIMARY KEY,
|
||||
controls TEXT, -- qlist( id, id, id )
|
||||
plmode INTEGER REFERENCES dynamic_playlist( plmode ) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,
|
||||
pltype TEXT REFERENCES dynamic_playlist( pltype ) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED
|
||||
};
|
||||
);
|
||||
|
||||
--INSERT INTO playlist_revision(guid, playlist, entries)
|
||||
-- VALUES('revisionguid-1', 'playlistguid-1', '["itemguid-2","itemguid-1","itemguid-3"]');
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
This file was automatically generated from schema.sql on Tue Jul 13 12:23:44 CEST 2010.
|
||||
This file was automatically generated from schema.sql on Mon Dec 6 22:41:52 EST 2010.
|
||||
*/
|
||||
|
||||
static const char * tomahawk_schema_sql =
|
||||
@@ -49,7 +49,8 @@ static const char * tomahawk_schema_sql =
|
||||
" info TEXT,"
|
||||
" creator TEXT,"
|
||||
" lastmodified INTEGER NOT NULL DEFAULT 0,"
|
||||
" currentrevision TEXT REFERENCES playlist_revision(guid) DEFERRABLE INITIALLY DEFERRED"
|
||||
" currentrevision TEXT REFERENCES playlist_revision(guid) DEFERRABLE INITIALLY DEFERRED,"
|
||||
" dynplaylist BOOLEAN DEFAULT false"
|
||||
");"
|
||||
"CREATE TABLE IF NOT EXISTS playlist_item ("
|
||||
" guid TEXT PRIMARY KEY,"
|
||||
@@ -72,6 +73,25 @@ static const char * tomahawk_schema_sql =
|
||||
" timestamp INTEGER NOT NULL DEFAULT 0,"
|
||||
" previous_revision TEXT REFERENCES playlist_revision(guid) DEFERRABLE INITIALLY DEFERRED"
|
||||
");"
|
||||
"CREATE TABLE IF NOT EXISTS dynamic_playlist ("
|
||||
" guid TEXT PRIMARY KEY,"
|
||||
" pltype TEXT, "
|
||||
" plmode INTEGER "
|
||||
");"
|
||||
"CREATE TABLE IF NOT EXISTS dynamic_playlist_controls ("
|
||||
" id TEXT PRIMARY KEY,"
|
||||
" playlist TEXT NOT NULL REFERENCES playlist(guid) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,"
|
||||
" selectedType TEXT,"
|
||||
" match TEXT,"
|
||||
" input TEXT"
|
||||
");"
|
||||
""
|
||||
"CREATE TABLE IF NOT EXISTS dynamic_playlist_revision ("
|
||||
" guid TEXT PRIMARY KEY,"
|
||||
" controls TEXT, "
|
||||
" plmode INTEGER REFERENCES dynamic_playlist( plmode ) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,"
|
||||
" pltype TEXT REFERENCES dynamic_playlist( pltype ) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED"
|
||||
");"
|
||||
"CREATE TABLE IF NOT EXISTS artist_search_index ("
|
||||
" ngram TEXT NOT NULL,"
|
||||
" id INTEGER NOT NULL REFERENCES artist(id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED,"
|
||||
|
@@ -15,6 +15,9 @@
|
||||
#include "database/databasecommand_collectionstats.h"
|
||||
#include "database/databaseresolver.h"
|
||||
#include "sip/SipHandler.h"
|
||||
#include "dynamic/generatorfactory.h"
|
||||
#include "dynamic/echonest/echonestgenerator.h"
|
||||
#include "jabber/jabber.h"
|
||||
#include "utils/tomahawkutils.h"
|
||||
#include "xmppbot/xmppbot.h"
|
||||
#include "web/api_v1.h"
|
||||
@@ -215,6 +218,8 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
|
||||
m_mainwindow->showSettingsDialog();
|
||||
}
|
||||
#endif
|
||||
|
||||
GeneratorFactory::registerFactory( "echonest", new EchonestFactory );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -169,6 +169,7 @@ TomahawkWindow::setupSignals()
|
||||
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( rescanCollectionManually() ) );
|
||||
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
|
||||
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
|
||||
connect( ui->actionCreateDynamicPlaylist, SIGNAL( triggered() ), SLOT( createDynamicPlaylist() ));
|
||||
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
|
||||
connect( ui->actionExit, SIGNAL( triggered() ), APP, SLOT( quit() ) );
|
||||
|
||||
@@ -319,9 +320,15 @@ TomahawkWindow::loadSpiff()
|
||||
loader->load( url );
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkWindow::createDynamicPlaylist()
|
||||
{
|
||||
createPlaylist( true );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::createPlaylist()
|
||||
TomahawkWindow::createPlaylist( bool dynamic )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
@@ -334,6 +341,9 @@ TomahawkWindow::createPlaylist()
|
||||
QString id = uuid();
|
||||
QString info = ""; // FIXME
|
||||
QString creator = "someone"; // FIXME
|
||||
if( dynamic )
|
||||
DynamicPlaylist::create( author, id, name, info, creator, false );
|
||||
else
|
||||
Playlist::create( author, id, name, info, creator, false /* shared */ );
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,8 @@ protected:
|
||||
void closeEvent( QCloseEvent* e );
|
||||
|
||||
public slots:
|
||||
void createPlaylist();
|
||||
void createDynamicPlaylist();
|
||||
void createPlaylist( bool dynamic = false );
|
||||
void loadSpiff();
|
||||
void showSettingsDialog();
|
||||
|
||||
|
@@ -81,6 +81,7 @@
|
||||
<string>&Playlist</string>
|
||||
</property>
|
||||
<addaction name="actionCreatePlaylist"/>
|
||||
<addaction name="actionCreateDynamicPlaylist"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionLoadXSPF"/>
|
||||
</widget>
|
||||
@@ -156,6 +157,11 @@
|
||||
<enum>QAction::AboutRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreateDynamicPlaylist">
|
||||
<property name="text">
|
||||
<string>Create New &Dynamic Playlist</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
Reference in New Issue
Block a user