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

Plasma

plasma.cpp

Go to the documentation of this file.
00001 /*
00002  *   Copyright 2005 by Aaron Seigo <aseigo@kde.org>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU Library General Public License as
00006  *   published by the Free Software Foundation; either version 2, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details
00013  *
00014  *   You should have received a copy of the GNU Library General Public
00015  *   License along with this program; if not, write to the
00016  *   Free Software Foundation, Inc.,
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 
00020 #include <plasma/plasma.h>
00021 
00022 #include <QGraphicsScene>
00023 #include <QGraphicsView>
00024 
00025 #include <plasma/containment.h>
00026 #include <plasma/view.h>
00027 
00028 namespace Plasma
00029 {
00030 
00031 qreal scalingFactor(ZoomLevel level)
00032 {
00033     switch (level) {
00034     case DesktopZoom:
00035         return 1;
00036         break;
00037     case GroupZoom:
00038         return 0.5;
00039         break;
00040     case OverviewZoom:
00041         return 0.2;
00042         break;
00043     }
00044 
00045     // to make odd compilers not warn like silly beasts
00046     return 1;
00047 }
00048 
00049 Direction locationToDirection(Location location)
00050 {
00051     switch (location) {
00052     case Floating:
00053     case Desktop:
00054     case TopEdge:
00055     case FullScreen:
00056         //TODO: should we be smarter for floating and planer?
00057         //      perhaps we should take a QRect and/or QPos as well?
00058         return Down;
00059     case BottomEdge:
00060         return Up;
00061     case LeftEdge:
00062         return Right;
00063     case RightEdge:
00064         return Left;
00065     }
00066 
00067     return Down;
00068 }
00069 
00070 QGraphicsView *viewFor(const QGraphicsItem *item)
00071 {
00072     if (!item || !item->scene()) {
00073         return 0;
00074     }
00075 
00076     QGraphicsView *found = 0;
00077     foreach (QGraphicsView *view, item->scene()->views()) {
00078         if (view->sceneRect().intersects(item->sceneBoundingRect()) ||
00079             view->sceneRect().contains(item->scenePos())) {
00080             if (!found || view->isActiveWindow()) {
00081                 found = view;
00082             }
00083         }
00084     }
00085 
00086     return found;
00087 }
00088 
00089 } // Plasma namespace

Plasma

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs 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