File indexing completed on 2024-05-12 16:36:51

0001 /* This file is part of the KDE project
0002 *
0003 * Copyright (C) 2010 Jean-Nicolas Artaud <jeannicolasartaud@gmail.com>
0004 *
0005 * This library is free software; you can redistribute it and/or
0006 * modify it under the terms of the GNU Library General Public
0007 * License as published by the Free Software Foundation; either
0008 * version 2 of the License, or (at your option) any later version.
0009 *
0010 * This library is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013 * Library General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU Library General Public License
0016 * along with this library; see the file COPYING.LIB.  If not, write to
0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018 * Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #ifndef KPRVIEWMODESLIDESSORTER_H
0022 #define KPRVIEWMODESLIDESSORTER_H
0023 
0024 #include <QListView>
0025 #include <KoPAViewMode.h>
0026 #include <KoZoomMode.h>
0027 
0028 class KoPAView;
0029 class KoPACanvas;
0030 class KoPAPageBase;
0031 class KoViewItemContextBar;
0032 class KPrSlidesSorterDocumentModel;
0033 class KPrSlidesManagerView;
0034 class KPrCustomSlideShowsModel;
0035 class KPrCustomSlideShows;
0036 class QToolButton;
0037 class QComboBox;
0038 
0039 /**
0040   * This view mode holds Slides Sorter view widget and
0041   * holds view and toolbar to manage custom slide shows
0042   * This class also manages all interaction between
0043   * the standard GUI and the slides sorter view and between
0044   * slides sorter view - custom slide shows view
0045   */
0046 class KPrViewModeSlidesSorter : public KoPAViewMode
0047 {
0048     Q_OBJECT
0049 public:
0050     KPrViewModeSlidesSorter(KoPAView *view, KoPACanvasBase *canvas);
0051     ~KPrViewModeSlidesSorter() override;
0052 
0053     void paint(KoPACanvasBase *canvas, QPainter &painter, const QRectF &paintRect) override;
0054     void paintEvent(KoPACanvas *canvas, QPaintEvent *event);
0055     void tabletEvent(QTabletEvent *event, const QPointF &point) override;
0056     void mousePressEvent(QMouseEvent *event, const QPointF &point) override;
0057     void mouseDoubleClickEvent(QMouseEvent *event, const QPointF &point) override;
0058     void mouseMoveEvent(QMouseEvent *event, const QPointF &point) override;
0059     void mouseReleaseEvent(QMouseEvent *event, const QPointF &point) override;
0060     void shortcutOverrideEvent(QKeyEvent *event) override;
0061     void keyPressEvent(QKeyEvent *event) override;
0062     void keyReleaseEvent(QKeyEvent *event) override;
0063     void wheelEvent(QWheelEvent *event, const QPointF &point) override;
0064 
0065     void activate(KoPAViewMode *previousViewMode) override;
0066     void deactivate() override;
0067 
0068     /**
0069      * Change the KPrView active page
0070      * @param page pointer to the new active page
0071      */
0072     void updateActivePage(KoPAPageBase *page) override;
0073 
0074     void addShape(KoShape *shape) override;
0075     void removeShape(KoShape *shape) override;
0076 
0077     /**
0078       * Return a list with the pointer to the selected slides
0079       *
0080       * @return a list of KoPAPageBase pointers to the slides sorter selected slides.
0081       */
0082     QList<KoPAPageBase*> extractSelectedSlides();
0083 
0084     /**
0085      * The icon size
0086      *
0087      * @return the icon size defined before
0088      */
0089     QSize iconSize() const;
0090 
0091     /**
0092      * Clear selection and select a list of slides on slides sorter view
0093      * @param slides list to be selected
0094      */
0095     void selectSlides(const QList<KoPAPageBase *> &slides);
0096 
0097     /** Set active custom slide show */
0098     void setActiveCustomSlideShow(int index);
0099 
0100 protected:
0101 
0102     /**
0103      * Setter of the icon size
0104      *
0105      * @param size which is a QSize
0106      */
0107     void setIconSize(const QSize &size);
0108 
0109     /**
0110      * load the last zoom value used
0111      */
0112     void loadZoomConfig();
0113 
0114     /**
0115      * Setter of the zoom value
0116      *
0117      * @param zoom percent
0118      */
0119     void setZoom(int zoom);
0120 
0121     /**
0122      * Return the last zoom stored
0123      *
0124      * @return the last zoom stored
0125      */
0126     int zoom();
0127 
0128     /**
0129       * save zoom value
0130       */
0131     void saveZoomConfig(int zoom);
0132 
0133 private:
0134     KPrSlidesManagerView *m_slidesSorterView;
0135     KPrSlidesManagerView *m_customSlideShowView;
0136     KPrSlidesSorterDocumentModel *m_slidesSorterModel;
0137     int m_zoom;
0138     QWidget *m_centralWidget;
0139     KPrCustomSlideShowsModel *m_customSlideShowModel;
0140     QSize m_iconSize;
0141     bool m_editCustomSlideShow;
0142     QToolButton *m_buttonAddCustomSlideShow;
0143     QToolButton *m_buttonDelCustomSlideShow;
0144     QToolButton *m_buttonAddSlideToCurrentShow;
0145     QToolButton *m_buttonDelSlideFromCurrentShow;
0146     QComboBox *m_customSlideShowsList;
0147     KoViewItemContextBar *m_slidesSorterItemContextBar;
0148 
0149 private Q_SLOTS:
0150     /** Changes the view active page to match the slides sorter current index*/
0151     void updateActivePageToCurrentIndex();
0152 
0153     /** Updates custom slide Shows list */
0154     void updateCustomSlideShowsList();
0155 
0156     /** Changes the view active page to match the slides sorter item selected*/
0157     void itemClicked(const QModelIndex);
0158 
0159     /** delete the current selected slides*/
0160     void deleteSlide();
0161 
0162     /** add a new slide after the current active page*/
0163     void addSlide();
0164 
0165     /** Item context bar actions */
0166     void contextBarDuplicateSlide();
0167     void contextBarDeleteSlide();
0168     void contextBarStartSlideshow();
0169 
0170     /** Rename current slide on Slides Sorter View */
0171     void renameCurrentSlide();
0172 
0173     /** cut the current selected slides*/
0174     void editCut();
0175 
0176     /** copy the current selected slides*/
0177     void editCopy();
0178 
0179     /** paste slides in slides sorter view*/
0180     void editPaste();
0181 
0182     /** update the zoom of the Slides Sorter view*/
0183     void updateZoom(KoZoomMode::Mode mode, qreal zoom);
0184 
0185     /** Changes the slides sorter current index to match view active page*/
0186     void updateToActivePageIndex();
0187 
0188     /** Hide KPrViewModeSlidesSorter and return to normal view*/
0189     void activateNormalViewMode();
0190 
0191     /** Provides a custom context menu for the slides sorter view*/
0192     void slidesSorterContextMenu(QContextMenuEvent *event);
0193 
0194     /** Provides a custom context menu for the slides sorter view*/
0195     void customSlideShowsContextMenu(QContextMenuEvent *event);
0196 
0197     /** Updates the UI according to the custom Show selected */
0198     void customShowChanged(int showNumber);
0199 
0200     /** Delete selected slides from the current custom slide show */
0201     void deleteSlidesFromCustomShow();
0202 
0203     /** Add slides selected on Slides Sorter view to the current custom slide show */
0204     void addSlideToCustomShow();
0205 
0206     /** Add a new slides custom Show */
0207     void addCustomSlideShow();
0208 
0209     /** Remove a new slides custom Show */
0210     void removeCustomSlideShow();
0211 
0212     /** Renames current custom slide show */
0213     void renameCustomSlideShow();
0214 
0215     /** Enable standard edit actions for Slides Sorter View */
0216     void enableEditActions();
0217 
0218     /** Disable standard edit actions for Slides Sorter View */
0219     void disableEditActions();
0220 
0221     /** Enable edit buttons for Custom Slide Shows List*/
0222     void enableEditCustomShowButtons();
0223 
0224     /** Disable edit buttons for Custom Slide Shows View and List*/
0225     void disableEditCustomShowButtons();
0226 
0227     /** Enable/Disable add and remove slides buttons for Custom Slide Show View */
0228     void manageAddRemoveSlidesButtons();
0229 
0230     /** Select pages on custom slide show view */
0231     void selectCustomShowPages(int start, int count);
0232 };
0233 
0234 #endif // KPRVIEWMODESLIDESSORTER_H