/src/libtomahawk/playlist/dynamic/database/DatabaseControl.h

http://github.com/tomahawk-player/tomahawk · C Header · 81 lines · 43 code · 18 blank · 20 comment · 0 complexity · 0ecbd27f7ea3d80fdc0fd525c91565bf MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, Leo Franchi <lfranchi@kde.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. #ifndef DATABASE_CONTROL_H
  19. #define DATABASE_CONTROL_H
  20. #include "playlist/dynamic/DynamicControl.h"
  21. #include <QTimer>
  22. namespace Tomahawk
  23. {
  24. class DatabaseControl : public DynamicControl
  25. {
  26. Q_OBJECT
  27. public:
  28. virtual QWidget* inputField();
  29. virtual QWidget* matchSelector();
  30. virtual QString input() const;
  31. virtual QString match() const;
  32. virtual QString matchString() const;
  33. virtual QString summary() const;
  34. virtual void setInput(const QString& input);
  35. virtual void setMatch(const QString& match);
  36. /// DO NOT USE IF YOU ARE NOT A DBCMD
  37. DatabaseControl( const QString& type, const QStringList& typeSelectors, QObject* parent = 0 );
  38. DatabaseControl( const QString& sql, const QString& summary, const QStringList& typeSelectors, QObject* parent = 0 );
  39. QString sql() const;
  40. public slots:
  41. virtual void setSelectedType ( const QString& type );
  42. private slots:
  43. void updateData();
  44. void editingFinished();
  45. void editTimerFired();
  46. private:
  47. void updateWidgets();
  48. void updateWidgetsFromData();
  49. // utility
  50. void calculateSummary();
  51. QPointer< QWidget > m_input;
  52. QPointer< QWidget > m_match;
  53. QString m_matchData;
  54. QString m_matchString;
  55. QString m_summary;
  56. QTimer m_editingTimer;
  57. QTimer m_delayedEditTimer;
  58. // SQL control
  59. QString m_sql;
  60. QString m_sqlSummary;
  61. };
  62. };
  63. #endif