File indexing completed on 2024-05-05 17:09:08
0001 /* 0002 * This file is part of the KDE project 0003 * 0004 * Copyright (C) 2013 Dan Leinir Turthra Jensen <admin@leinir.dk> 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Library General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Library General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Library General Public License 0017 * along with this library; see the file COPYING.LIB. If not, write to 0018 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0019 * Boston, MA 02110-1301, USA. 0020 * 0021 */ 0022 0023 #ifndef CQLINKAREA_H 0024 #define CQLINKAREA_H 0025 0026 #include <QDeclarativeItem> 0027 0028 class CQLinkArea : public QDeclarativeItem 0029 { 0030 Q_OBJECT 0031 Q_PROPERTY(QVariantList links READ links WRITE setLinks NOTIFY linksChanged) 0032 Q_PROPERTY(QSizeF sourceSize READ sourceSize WRITE setSourceSize NOTIFY sourceSizeChanged) 0033 Q_PROPERTY(QColor linkColor READ linkColor WRITE setLinkColor NOTIFY linkColorChanged) 0034 0035 public: 0036 explicit CQLinkArea(QDeclarativeItem* parent = 0); 0037 virtual ~CQLinkArea(); 0038 virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget* ); 0039 0040 QVariantList links() const; 0041 void setLinks(const QVariantList& newLinks); 0042 0043 QSizeF sourceSize() const; 0044 void setSourceSize( const QSizeF& size ); 0045 0046 QColor linkColor() const; 0047 void setLinkColor( const QColor& color ); 0048 0049 Q_SIGNALS: 0050 void linksChanged(); 0051 void clicked(); 0052 void doubleClicked(); 0053 void linkClicked(QUrl linkTarget); 0054 void sourceSizeChanged(); 0055 void linkColorChanged(); 0056 0057 protected: 0058 virtual void mousePressEvent(QGraphicsSceneMouseEvent* event); 0059 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); 0060 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event); 0061 0062 private: 0063 class Private; 0064 Private* const d; 0065 }; 0066 0067 #endif // CQLINKAREA_H