PageRenderTime 41ms CodeModel.GetById 20ms app.highlight 2ms RepoModel.GetById 18ms app.codeStats 0ms

/src/libtomahawk/database/DatabaseCommand_ImportPlaylist.cpp

http://github.com/tomahawk-player/tomahawk
C++ | 61 lines | 10 code | 6 blank | 45 comment | 0 complexity | 92b970c9f766ff19245c204982de08f4 MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.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#include "DatabaseCommand_ImportPlaylist.h"
20
21#include <QSqlQuery>
22
23#include "tomahawk/Query.h"
24#include "tomahawk/Playlist.h"
25#include "DatabaseImpl.h"
26#include "utils/Logger.h"
27
28
29void
30DatabaseCommand_ImportPlaylist::exec( DatabaseImpl * dbi )
31{
32    /*
33    qDebug() << "Importing playlist of" << m_playlist->length() << "tracks";
34    TomahawkSqlQuery query = dbi->newquery();
35    query.prepare("INSERT INTO playlist(title, info, creator, lastmodified) "
36                  "VALUES(?,?,?,?)");
37    query.addBindValue(m_playlist->title());
38    query.addBindValue(m_playlist->info());
39    query.addBindValue(m_playlist->creator());
40    query.addBindValue(m_playlist->lastmodified());
41    query.exec();
42    int pid = query.lastInsertId().toInt();
43    int pos = 0;
44    query.prepare("INSERT INTO playlist_tracks( "
45                  "playlist, position, trackname, albumname, artistname) "
46                  "VALUES (?,?,?,?,?)");
47
48    for(int k = 0; k < m_playlist->length(); k++)
49    {
50        pos++;
51        query.addBindValue(pid);
52        query.addBindValue(pos);
53        query.addBindValue(m_playlist->at(k)->artist());
54        query.addBindValue(m_playlist->at(k)->album());
55        query.addBindValue(m_playlist->at(k)->track());
56        query.exec();
57    }
58    emit done(pid);
59    */
60}
61