• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Plasma

itemspace.h

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 2008 Ambroz Bizjak <ambro@b4ever.net>
00003 
00004   This program is free software; you can redistribute it and/or modify
00005   it under the terms of the GNU General Public License as published by
00006   the Free Software Foundation; either version 2 of the License, or
00007   (at your option) any later version.
00008 */
00009 
00010 #ifndef _ITEMSPACE_H
00011 #define _ITEMSPACE_H
00012 
00013 #include <QRectF>
00014 #include <QList>
00015 #include <QVariant>
00016 
00038 class ItemSpace
00039 {
00040   public:
00041     ItemSpace();
00042 
00043     void setWorkingArea(QSizeF area);
00044 
00045     void activate();
00046 
00051     qreal positionVisibility(QRectF geom);
00052 
00053     class ItemSpaceItem
00054     {
00055       public:
00056         QRectF preferredGeometry;
00057         QRectF lastGeometry;
00058         bool pushBack : 1;
00059         bool animateMovement : 1;
00060         QVariant user;
00061     };
00062 
00063     enum DirectionFlag {
00064         DirLeft = 1,
00065         DirRight = 2,
00066         DirUp = 4,
00067         DirDown = 8
00068     };
00069     Q_DECLARE_FLAGS(Direction, DirectionFlag)
00070 
00071     enum PushPowerFlag {
00072         NoPower = 0,
00073         PushAwayFromPreferred = 1,
00074         PushOverBorder = 2
00075     };
00076     Q_DECLARE_FLAGS(PushPower, PushPowerFlag)
00077 
00078     
00081     void offsetPositions(const QPointF &offset);
00082 
00094     qreal performPush(int groupId, Direction direction, qreal amount, PushPower power);
00095 
00102     void addItem(ItemSpaceItem newItem);
00103 
00110     void removeItem(int groupIndex, int itemInGroup);
00111 
00118     void updateItem(int groupIndex, int itemInGroup);
00119 
00124     bool locateItemByPosition(int pos, int *groupIndex, int *itemInGroup) const;
00125 
00129     bool locateItemByUser(QVariant user, int *groupIndex, int *itemInGroup) const;
00130 
00141     void preparePush(Direction direction, PushPower power);
00142 
00164     QList<QPointF> positionVertically(
00165         const QSizeF &itemSize,
00166         Qt::Alignment align,
00167         bool limitedSpace,
00168         bool findAll
00169     ) const;
00170 
00171     bool positionedProperly(QRectF itemGeom);
00172 
00176     class ItemGroup
00177     {
00178       public:
00179 
00180         class Request
00181         {
00182           public:
00193             Request(
00194                 int sourceGroup,
00195                 qreal sourceGroupPushRequested,
00196                 qreal pushRequested
00197             );
00198 
00214             void activate(ItemSpace *itemSpace, ItemGroup *group);
00215 
00216             // saved from constructor
00217             int m_sourceGroup;
00218             qreal m_sourceGroupPushRequested;
00219             qreal m_pushRequested;
00220 
00221             // true if the request has already been reached by applyResults
00222             // and compensated for the reduction of the requester's move
00223             bool m_compensated;
00224         };
00225 
00226         void resetPush(int id);
00227 
00232         void addRequest(ItemSpace *itemSpace, const class Request &request);
00233 
00250         void applyResults(ItemSpace *itemSpace, int cameFrom);
00251 
00252         // items belonging to this group
00253         QList<ItemSpaceItem> m_groupItems;
00254 
00255         // the list index of this group in the calculation process
00256         int m_id;
00257         // the maximum of all push requests
00258         qreal m_largestPushRequested;
00259         // the available space calculated so-far
00260         qreal m_pushAvailable;
00261 
00262       private:
00263         // return true if the group is above this one (its requests lead here)
00264         bool groupIsAbove(ItemSpace *itemSpace, QList<int> &visited, int groupId);
00265 
00266         // move requests posted to this group
00267         QList<Request> m_requests;
00268         // groups we asked to move
00269         QList<int> m_obstacles;
00270     };
00271 
00275     QList<ItemGroup> m_groups;
00276 
00277     Qt::Alignment spaceAlignment;
00278     QSizeF workingGeom;
00279 
00280     qreal placementSpacing;
00281     qreal screenSpacing;
00282     qreal shiftingSpacing;
00283 
00284   private:
00285 
00286     QRectF itemInRegionStartingFirstVert(const QRectF &region) const;
00287     QRectF itemInRegionEndingLastVert(const QRectF &region) const;
00288     QRectF itemInRegionEndingFirstHoriz(const QRectF &region) const;
00289     QRectF itemInRegionStartingLastHoriz(const QRectF &region) const;
00290 
00291     Direction m_direction;
00292     PushPower m_power;
00293 };
00294 
00295 #endif

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal