Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/library/stardelegate.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                            stardelegate.h
00003                               -------------------
00004      copyright            : (C) 2010 Tobias Rafreider
00005          copyright            : (C) 2009 Nokia Corporation
00006 
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 
00019 #ifndef STARDELEGATE_H
00020 #define STARDELEGATE_H
00021 
00022 #include <QStyledItemDelegate>
00023 
00024 /*
00025  * When displaying data in a QListView, QTableView, or QTreeView,
00026  * the individual items are drawn by a delegate.
00027  * Also, when the user starts editing an item (e.g., by double-clicking the item),
00028  * the delegate provides an editor widget that is placed on top of the item while editing takes place.
00029  *
00030  * By default a QListView, QTableView, or QTreeView has a QItemDelegate attached,
00031  * which inherits QAbstractItemDelegate and handles the most common data types (notably int and QString).
00032  * If we need to support custom data types, or want to customize the rendering or the editing for
00033  * existing data types, we can subclass QAbstractItemDelegate or QItemDelegate or QStyledItemDelegate
00034  */
00035 class StarDelegate : public QStyledItemDelegate
00036 {
00037     Q_OBJECT
00038 
00039 public:
00040     StarDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {}
00042     void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
00044     QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
00046     QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,const QModelIndex &index) const;
00048     void setEditorData(QWidget *editor, const QModelIndex &index) const;
00050     void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
00051 
00052 private slots:
00053     void commitAndCloseEditor();
00054 };
00055 
00056 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines