/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. #include "DatabaseCommand_ImportPlaylist.h"
  19. #include <QSqlQuery>
  20. #include "tomahawk/Query.h"
  21. #include "tomahawk/Playlist.h"
  22. #include "DatabaseImpl.h"
  23. #include "utils/Logger.h"
  24. void
  25. DatabaseCommand_ImportPlaylist::exec( DatabaseImpl * dbi )
  26. {
  27. /*
  28. qDebug() << "Importing playlist of" << m_playlist->length() << "tracks";
  29. TomahawkSqlQuery query = dbi->newquery();
  30. query.prepare("INSERT INTO playlist(title, info, creator, lastmodified) "
  31. "VALUES(?,?,?,?)");
  32. query.addBindValue(m_playlist->title());
  33. query.addBindValue(m_playlist->info());
  34. query.addBindValue(m_playlist->creator());
  35. query.addBindValue(m_playlist->lastmodified());
  36. query.exec();
  37. int pid = query.lastInsertId().toInt();
  38. int pos = 0;
  39. query.prepare("INSERT INTO playlist_tracks( "
  40. "playlist, position, trackname, albumname, artistname) "
  41. "VALUES (?,?,?,?,?)");
  42. for(int k = 0; k < m_playlist->length(); k++)
  43. {
  44. pos++;
  45. query.addBindValue(pid);
  46. query.addBindValue(pos);
  47. query.addBindValue(m_playlist->at(k)->artist());
  48. query.addBindValue(m_playlist->at(k)->album());
  49. query.addBindValue(m_playlist->at(k)->track());
  50. query.exec();
  51. }
  52. emit done(pid);
  53. */
  54. }