Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

selection.h

Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008     copyright            : (C) 2005 by Craig Bradney
00009     email                : cbradney@zip.com.au
00010 ***************************************************************************/
00011 
00012 /***************************************************************************
00013 *                                                                         *
00014 *   This program is free software; you can redistribute it and/or modify  *
00015 *   it under the terms of the GNU General Public License as published by  *
00016 *   the Free Software Foundation; either version 2 of the License, or     *
00017 *   (at your option) any later version.                                   *
00018 *                                                                         *
00019 ***************************************************************************/
00020 #ifndef SELECTION_H
00021 #define SELECTION_H
00022 
00023 #include <QList>
00024 #include <QMap>
00025 #include <QObject>
00026 #include <QPointer>
00027 
00028 #include "pageitem.h"
00029 #include "scribusapi.h"
00030 
00031 typedef QList< QPointer<PageItem> > SelectionList;
00032 
00033 class SCRIBUS_API Selection : public QObject
00034 {
00035     Q_OBJECT
00036     public:
00041         explicit Selection(QObject* parent);   // otherwise implicit conversion Selection* -> Selection& is possible
00047         Selection(QObject* parent, bool guiSelection);
00055         Selection(const Selection& other);
00056         Selection& operator=( const Selection & );
00057         ~Selection();
00058 
00062         void copy(Selection& other, bool copyGUISelectionn, bool emptyOther);
00063         
00064         bool connectItemToGUI();
00071         bool disconnectAllItemsFromGUI();
00079         bool addItem(PageItem *item, bool ignoreGUI=false);
00087         bool prependItem(PageItem *item, bool doEmit=true);
00088 
00089         bool containsItem(PageItem *item) const { return m_SelList.contains(item); }
00093         bool addGroup();
00098         bool removeItem(PageItem *item);
00103         bool removeFirst();
00107         bool removeGroup();
00113         PageItem* takeItem(int itemIndex);
00119         int findItem(PageItem *item) const { return m_SelList.indexOf(item); }
00123         int count() const { return m_SelList.count(); }
00127         bool isEmpty() const { return m_SelList.count()==0; }
00131         bool clear();
00136         bool primarySelectionIs(const PageItem* item) const { return (!m_SelList.isEmpty() && (item==m_SelList.first())); }
00137         PageItem *itemAt(int index=0) { return itemAt_(index); }
00138         const PageItem *itemAt(int index=0) const { return const_cast<Selection*>(this)->itemAt_(index); }
00139         QStringList getSelectedItemsByName() const;
00140         bool isMultipleSelection() const { return m_hasGroupSelection; }
00141         bool isGUISelection() const { return m_isGUISelection; }
00142         void setIsGUISelection(bool guiSelection) { m_isGUISelection=guiSelection; }
00143         double width() const;
00144         double height() const;
00145         //set the group rectangle properties
00146         void setGroupRect();
00147         void getGroupRect(double *x, double *y, double *w, double *h);
00149         bool itemsAreSameType() const;
00150         
00151     protected:
00152         PageItem *itemAt_(int index=0);
00153         SelectionList m_SelList;
00154         bool m_hasGroupSelection;
00155         bool m_isGUISelection;
00156         double groupX;
00157         double groupY;
00158         double groupW;
00159         double groupH;
00160 
00161         
00162     signals:
00163         void selectionIsMultiple(bool);
00164         void empty();
00165         void selectionChanged();
00166 };
00167 
00168 #endif
Created with personalized Doxygen. This is documentation for GPL software Scribus - Open Source Desktop Publishing.