/src/configdelegatebase.h

http://github.com/tomahawk-player/tomahawk · C Header · 53 lines · 23 code · 12 blank · 18 comment · 0 complexity · 9c4d429a5aee2b5dcd7566ea849572be MD5 · raw file

  1. /*
  2. Copyright (C) 2011 Leo Franchi <leo.franchi@kdab.com>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef CONFIGDELEGATEBASE_H
  15. #define CONFIGDELEGATEBASE_H
  16. #include "DllMacro.h"
  17. #include <QStyledItemDelegate>
  18. #define PADDING 4
  19. class QPainter;
  20. class Q_DECL_EXPORT ConfigDelegateBase : public QStyledItemDelegate
  21. {
  22. Q_OBJECT
  23. public:
  24. ConfigDelegateBase( QObject* parent = 0 );
  25. virtual QSize sizeHint ( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
  26. virtual bool editorEvent ( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index );
  27. // if you want to use a checkbox, you need to have this say where to paint it
  28. virtual QRect checkRectForIndex( const QStyleOptionViewItem& option, const QModelIndex& idx, int role ) const = 0;
  29. // if you want to use a config wrench, you need to have this say where to paint it
  30. virtual QRect configRectForIndex( const QStyleOptionViewItem& option, const QModelIndex& idx ) const = 0;
  31. virtual QList<int> extraCheckRoles() const;
  32. signals:
  33. void configPressed( const QModelIndex& idx );
  34. protected:
  35. private:
  36. QModelIndex m_configPressed;
  37. };
  38. #endif // CONFIGDELEGATEBASE_H