From c07eff528deb31d8b430d82f28b19eb33dbcd4d9 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Mon, 25 Jan 2010 00:54:28 +0100 Subject: [PATCH] Qt: create new classes for IconView --- modules/gui/qt4/Modules.am | 3 ++ modules/gui/qt4/components/playlist/icon_view.cpp | 48 ++++++++++++++++++++ modules/gui/qt4/components/playlist/icon_view.hpp | 53 +++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 modules/gui/qt4/components/playlist/icon_view.cpp create mode 100644 modules/gui/qt4/components/playlist/icon_view.hpp diff --git a/modules/gui/qt4/Modules.am b/modules/gui/qt4/Modules.am index d86c20a386..5831febebe 100644 --- a/modules/gui/qt4/Modules.am +++ b/modules/gui/qt4/Modules.am @@ -52,6 +52,7 @@ nodist_SOURCES_qt4 = \ components/interface_widgets.moc.cpp \ components/controller.moc.cpp \ components/controller_widget.moc.cpp \ + components/playlist/icon_view.moc.cpp \ components/playlist/playlist_model.moc.cpp \ components/playlist/playlist.moc.cpp \ components/playlist/standardpanel.moc.cpp \ @@ -244,6 +245,7 @@ SOURCES_qt4 = qt4.cpp \ components/interface_widgets.cpp \ components/controller.cpp \ components/controller_widget.cpp \ + components/playlist/icon_view.cpp \ components/playlist/playlist_model.cpp \ components/playlist/playlist_item.cpp \ components/playlist/standardpanel.cpp \ @@ -294,6 +296,7 @@ noinst_HEADERS = \ components/interface_widgets.hpp \ components/controller.hpp \ components/controller_widget.hpp \ + components/playlist/icon_view.hpp \ components/playlist/playlist_model.hpp \ components/playlist/playlist_item.hpp \ components/playlist/standardpanel.hpp \ diff --git a/modules/gui/qt4/components/playlist/icon_view.cpp b/modules/gui/qt4/components/playlist/icon_view.cpp new file mode 100644 index 0000000000..48d6db7b79 --- /dev/null +++ b/modules/gui/qt4/components/playlist/icon_view.cpp @@ -0,0 +1,48 @@ +/***************************************************************************** + * icon_view.cpp : Icon view for the Playlist + **************************************************************************** + * Copyright © 2010 the VideoLAN team + * $Id$ + * + * Authors: Jean-Baptiste Kempf + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#include "components/playlist/icon_view.hpp" +#include "components/playlist/playlist_model.hpp" + +#include + +void PlListViewItemDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const +{ +} + +QSize PlListViewItemDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const +{ + return QSize(100, 100); +} + + +PlIconView::PlIconView( PLModel *model, QWidget *parent ) : QListView( parent ) +{ + setModel( model ); + setViewMode( QListView::IconMode ); + setMovement( QListView::Snap ); + + PlListViewItemDelegate *pl = new PlListViewItemDelegate(); + setItemDelegate( pl ); +} + diff --git a/modules/gui/qt4/components/playlist/icon_view.hpp b/modules/gui/qt4/components/playlist/icon_view.hpp new file mode 100644 index 0000000000..1d733848c1 --- /dev/null +++ b/modules/gui/qt4/components/playlist/icon_view.hpp @@ -0,0 +1,53 @@ +/***************************************************************************** + * icon_view.hpp : Icon view for the Playlist + **************************************************************************** + * Copyright © 2010 the VideoLAN team + * $Id$ + * + * Authors: Jean-Baptiste Kempf + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef _ICON_VIEW_H_ +#define _ICON_VIEW_H_ + +#include +#include + +class QPainter; +class PLModel; + +class PlListViewItemDelegate : public QStyledItemDelegate +{ + Q_OBJECT + +public: + PlListViewItemDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {} + + void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const; + QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const; +}; + +class PlIconView : public QListView +{ + Q_OBJECT + +public: + PlIconView( PLModel *model, QWidget *parent = 0 ); +}; + +#endif + -- 2.11.4.GIT