File indexing completed on 2024-05-19 16:09:35

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2008 Fredy Yanardi <fyanardi@gmail.com>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #include "KPrPresenterViewSlidesInterface.h"
0021 
0022 #include <KoPAPageBase.h>
0023 #include <KoPAPageThumbnailModel.h>
0024 
0025 #include <QVBoxLayout>
0026 #include <QListView>
0027 
0028 KPrPresenterViewSlidesInterface::KPrPresenterViewSlidesInterface( const QList<KoPAPageBase *> &pages, QWidget *parent )
0029     : KPrPresenterViewBaseInterface( pages, parent )
0030 {
0031     QVBoxLayout *vLayout = new QVBoxLayout;
0032 
0033     m_listView = new QListView;
0034     m_thumbnailModel = new KoPAPageThumbnailModel( m_pages, this );
0035     m_listView->setModel( m_thumbnailModel );
0036     m_listView->setDragDropMode( QListView::NoDragDrop );
0037     m_listView->setIconSize( QSize( 128, 128 ) );
0038     m_listView->setViewMode( QListView::IconMode );
0039     m_listView->setFlow( QListView::LeftToRight );
0040     m_listView->setWrapping( true );
0041     m_listView->setResizeMode( QListView::Adjust );
0042     m_listView->setSelectionMode( QAbstractItemView::SingleSelection );
0043     m_listView->setMovement( QListView::Static );
0044 
0045     connect( m_listView, SIGNAL(clicked(QModelIndex)), this,
0046             SLOT(itemClicked(QModelIndex)) );
0047     connect( m_listView, SIGNAL(doubleClicked(QModelIndex)), this,
0048             SLOT(itemDoubleClicked(QModelIndex)) );
0049 
0050     vLayout->addWidget( m_listView );
0051 
0052     setLayout( vLayout );
0053 }
0054 
0055 void KPrPresenterViewSlidesInterface::itemClicked( const QModelIndex &index )
0056 {
0057     emit selectedPageChanged( index.row(), false );
0058 }
0059 
0060 void KPrPresenterViewSlidesInterface::itemDoubleClicked( const QModelIndex &index )
0061 {
0062     emit selectedPageChanged( index.row(), true );
0063 }