inverse location<->direction enum mapping

svn path=/trunk/KDE/kdelibs/; revision=954611
This commit is contained in:
Aaron J. Seigo 2009-04-16 03:19:33 +00:00
parent 3919fe141a
commit b479428114
2 changed files with 31 additions and 1 deletions

View File

@ -67,6 +67,27 @@ Direction locationToDirection(Location location)
return Down; return Down;
} }
Direction locationToInverseDirection(Location location)
{
switch (location) {
case Floating:
case Desktop:
case TopEdge:
case FullScreen:
//TODO: should we be smarter for floating and planer?
// perhaps we should take a QRect and/or QPos as well?
return Up;
case BottomEdge:
return Down;
case LeftEdge:
return Left;
case RightEdge:
return Right;
}
return Up;
}
QGraphicsView *viewFor(const QGraphicsItem *item) QGraphicsView *viewFor(const QGraphicsItem *item)
{ {
if (!item || !item->scene()) { if (!item || !item->scene()) {

View File

@ -261,10 +261,19 @@ PLASMA_EXPORT qreal scalingFactor(ZoomLevel level);
* location or to point arrows and other directional items. * location or to point arrows and other directional items.
* *
* @param location the location of the container the element will appear in * @param location the location of the container the element will appear in
* @return the visual direction of the element should be oriented in * @return the visual direction the element should be oriented in
**/ **/
PLASMA_EXPORT Direction locationToDirection(Location location); PLASMA_EXPORT Direction locationToDirection(Location location);
/**
* Converts a location to the direction facing it. Handy for figuring out which way to collapse
* a popup or to point arrows at the item itself.
*
* @param location the location of the container the element will appear in
* @return the visual direction the element should be oriented in
**/
PLASMA_EXPORT Direction locationToInverseDirection(Location location);
/** /**
* Returns the most appropriate QGraphicsView for the item. * Returns the most appropriate QGraphicsView for the item.
* *