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

0001 /* This file is part of the KDE project
0002    Copyright (C) 2007-2008 Carlos Licea <carlos.licea@kdemail.org>
0003    Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
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 #ifndef KPRCUSTOMSLIDESHOWS_H
0021 #define KPRCUSTOMSLIDESHOWS_H
0022 
0023 //Qt includes
0024 #include<QMap>
0025 #include<QList>
0026 #include<QString>
0027 #include<QObject>
0028 
0029 //Forward declarations
0030 class KoPAPageBase;
0031 #include "KoXmlReaderForward.h"
0032 class KoPASavingContext;
0033 class KoPALoadingContext;
0034 
0035 #include "stage_export.h"
0036 
0037 class STAGE_TEST_EXPORT KPrCustomSlideShows : public QObject
0038 {
0039     Q_OBJECT
0040 public:
0041     KPrCustomSlideShows();
0042     ~KPrCustomSlideShows() override;
0043 
0044     /**
0045      * @brief Insert a new Custom SlideShow
0046      *
0047      * @param name The name of the new SlideShow
0048      * @param slideShow a list of the pages in the desired order 
0049      */
0050     void insert( const QString &name, const QList<KoPAPageBase*> &slideShow );
0051 
0052     /**
0053      * @brief Delete a Custom SlideShow by its name
0054      *
0055      * @param name The name of the SlideShow to be removed
0056      */
0057     void remove( const QString &name );
0058 
0059     /**
0060      * @brief Replaces a custom SlideShow with the given SlideShow
0061      *
0062      * @param name The name of the SlideShow to be updated
0063      * @param slideShow slideShow to be inserted
0064      */
0065     void update( const QString &name, const QList<KoPAPageBase*> &slideShow );
0066 
0067     /**
0068      * @brief Replaces a custom SlideShow with the given SlideShow
0069      *
0070      * @param oldName The name of the SlideShow to be renamed
0071      * @param newName The new name of the SlideShow
0072      */
0073     void rename( const QString &oldName, const QString &newName );
0074 
0075     /**
0076      * @brief Returns a list of the names of the known SlideShows
0077      *
0078      */
0079     const QList<QString> names() const;
0080 
0081     /**
0082      * @brief Ask if a name is in use and return the object
0083      * 
0084      * @param name the name of the custom SlideShow to be retrived
0085      * @return a List of the Pages in the SlideShow if it was found
0086      *         a blank list if the SlideShow name was not found
0087      */
0088     QList<KoPAPageBase*> getByName( const QString &name ) const;
0089 
0090     /**
0091      * @brief Return the object that match the give index in the list with the given name
0092      *
0093      * @param name the name of the custom SlideShow
0094      / @param index the index of the slide to be retrived from the custom SlideShow
0095      * @return a Page in the SlideShow if it was found or a null pointer if not.
0096      */
0097     KoPAPageBase* pageByIndex(const QString &name, int index) const;
0098 
0099     /**
0100      * @brief return the index of a page within a custom show
0101      *
0102      * @param name the name of the custom SlideShow
0103      * @param page the KoPAPageBase within the custom SlideShow
0104      * @return a int index of the page within the SlideShow if it was found
0105      *         -1 if the page was not found
0106      */
0107     int indexByPage(const QString &name, KoPAPageBase *page) const;
0108 
0109     /**
0110      * @brief Insert a slide to the right of the given position of all the known custom SlideShows.
0111      * If the position is higher than the size of the list of the SlideShow, the slide is inserted at the end.
0112      * 
0113      * @param page slide page to be inserted
0114      * @param position the position at which the slide will be inserted.
0115      * If it's 0 it will be prepended to the list, if it's the size it will be appended to the list.
0116      * Negative numbers can be used to count backwards.
0117      */
0118     void addSlideToAll(KoPAPageBase *page, unsigned int position);
0119 
0120     /**
0121      * @brief Insert a  list of slides to the right of the given position of all the known custom SlideShows.
0122      * If the position is higher than the size of the list of the SlideShow, the list of slides are inserted at the end.
0123      *
0124      * @param slideShow list of slides to be inserted
0125      * @param position the position at which the slide will be inserted
0126      */
0127     void addSlidesToAll( const QList<KoPAPageBase*> &slideShow, unsigned int position );
0128 
0129     /**
0130      * @brief Deletes all the occurrences of a given slide from all the known custom SlideShows
0131      *
0132      * @param page slide page to be removed
0133      */
0134     void removeSlideFromAll(KoPAPageBase *page);
0135 
0136     /**
0137      * @brief Deletes all the occurrences of a given list of slides from all the known custom SlideShows
0138      *
0139      * @param slideShow list of slides to be removed
0140      */
0141     void removeSlidesFromAll( const QList<KoPAPageBase*> &slideShow );
0142 
0143     /**
0144      * @brief Save the slide shows
0145      *
0146      * @param context The saving context
0147      */
0148     void saveOdf( KoPASavingContext & context );
0149 
0150     /**
0151      * @brief Load the slide shows
0152      *
0153      * @param presentationSettings The element containing the presentation:settings
0154      * @param context The loading context
0155      */
0156     void loadOdf( const KoXmlElement & presentationSettings, KoPALoadingContext & context );
0157 
0158     /**
0159      * @brief Return the names of custom shows that contains the given page
0160      *
0161      * @param page the page to be searched in the custom shows
0162      * @return a List of the Slide Show names that contains the page
0163      *         a blank list if the page was not found
0164      */
0165     QStringList namesByPage(KoPAPageBase *page) const;
0166 
0167 Q_SIGNALS:
0168     void updated();
0169 
0170 private:
0171     QMap< QString, QList<KoPAPageBase*> > m_customSlideShows;
0172 
0173 };
0174 #endif /* KPRCUSTOMSLIDESHOWS_H */