diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2009-03-29 13:11:51 -0400 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2009-03-29 13:11:51 -0400 |
| commit | 6781e2bcd051ace8da25dbd9e6950c87045753ef (patch) | |
| tree | 734cdbd2ddf05f0af9c5e3ada807d2780a5f3387 /sigmodr/widgets/MapItem.cpp | |
| parent | 7da85e52c1a0015213c0e905d7dbc5631a0b0904 (diff) | |
| download | sigen-6781e2bcd051ace8da25dbd9e6950c87045753ef.tar.gz sigen-6781e2bcd051ace8da25dbd9e6950c87045753ef.tar.xz sigen-6781e2bcd051ace8da25dbd9e6950c87045753ef.zip | |
Move the map editing classes to a subdirectory
Diffstat (limited to 'sigmodr/widgets/MapItem.cpp')
| -rw-r--r-- | sigmodr/widgets/MapItem.cpp | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/sigmodr/widgets/MapItem.cpp b/sigmodr/widgets/MapItem.cpp deleted file mode 100644 index 388cef05..00000000 --- a/sigmodr/widgets/MapItem.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -// Header include -#include "MapItem.h" - -// KDE includes -#include <KColorScheme> - -// Qt includes -#include <QtGui/QGraphicsScene> -#include <QtGui/QGraphicsSceneMouseEvent> -#include <QtGui/QGraphicsSimpleTextItem> -#include <QtGui/QPainter> -#include <QtGui/QStyleOptionGraphicsItem> - -using namespace Sigmodr::Widgets; - -MapItem::MapItem(QGraphicsScene* parent) : - QObject(parent), - m_tag(new QGraphicsSimpleTextItem(this)), - m_label(new QGraphicsSimpleTextItem(this)) -{ - setAcceptHoverEvents(true); - setFlags(ItemIsMovable | ItemIsSelectable | ItemDoesntPropagateOpacityToChildren); - m_tag->setPos(-5, -8); - m_label->hide(); -} - -void MapItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) -{ - Q_UNUSED(widget) - if (option->state & QStyle::State_MouseOver) - { - painter->setPen(QPen(KStatefulBrush(KColorScheme::View, KColorScheme::HoverColor).brush(QPalette::Active), 3)); - painter->drawRect(boundingRect()); - } - if (option->state & QStyle::State_Selected) - { - painter->setPen(QPen(KStatefulBrush(KColorScheme::Selection, KColorScheme::ActiveBackground).brush(QPalette::Active), 3)); - painter->drawRect(boundingRect()); - } -} - -void MapItem::hoverEnterEvent(QGraphicsSceneHoverEvent* event) -{ - m_label->show(); - QGraphicsItem::hoverEnterEvent(event); - update(); -} - -void MapItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) -{ - m_label->hide(); - QGraphicsItem::hoverLeaveEvent(event); - update(); -} - -void MapItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event) -{ - QGraphicsItem::mouseMoveEvent(event); - moveTo(scenePos().toPoint()); - update(); -} |
