File indexing completed on 2024-05-05 04:35:18
0001 /* This file is part of the TikZKit project. 0002 * 0003 * Copyright (C) 2013 Dominik Haumann <dhaumann@kde.org> 0004 * 0005 * This library is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU Library General Public License as published 0007 * by the Free Software Foundation, either version 2 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, see 0017 * <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #include "TikzItem.h" 0021 0022 #include <QGraphicsSceneHoverEvent> 0023 0024 #include <QDebug> 0025 0026 class TikzItemPrivate 0027 { 0028 public: 0029 bool hovered = false; 0030 }; 0031 0032 TikzItem::TikzItem(QGraphicsItem * parent) 0033 : QGraphicsObject(parent) 0034 , d(new TikzItemPrivate()) 0035 { 0036 setAcceptHoverEvents(true); 0037 } 0038 0039 TikzItem::~TikzItem() 0040 { 0041 delete d; 0042 } 0043 0044 int TikzItem::type() const 0045 { 0046 return UserType + 1; 0047 } 0048 0049 bool TikzItem::isHovered() const 0050 { 0051 return d->hovered && !isSelected(); 0052 } 0053 0054 void TikzItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event) 0055 { 0056 Q_UNUSED(event); 0057 d->hovered = true; 0058 update(); 0059 } 0060 0061 void TikzItem::hoverLeaveEvent(QGraphicsSceneHoverEvent * event) 0062 { 0063 Q_UNUSED(event); 0064 d->hovered = false; 0065 update(); 0066 } 0067 0068 // kate: indent-width 4; replace-tabs on;