Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/render/notes/NotesItem.cpp
- This file was added.
1 | // This program is free software licensed under the GNU LGPL. You can | ||||
---|---|---|---|---|---|
2 | // find a copy of this license in LICENSE.txt in the top directory of | ||||
3 | // the source code. | ||||
4 | // | ||||
5 | // Copyright 2016 Spencer Brown <spencerbrown991@gmail.com> | ||||
6 | // | ||||
7 | | ||||
8 | #include "NotesItem.h" | ||||
9 | | ||||
10 | #include <QPainter> | ||||
11 | #include <QRect> | ||||
12 | | ||||
13 | using namespace Marble; | ||||
14 | | ||||
15 | const QFont NotesItem::s_font = QFont( QStringLiteral( "Sans Serif" ), 10, QFont::Bold ); | ||||
16 | const int NotesItem::s_labelOutlineWidth = 5; | ||||
17 | | ||||
18 | NotesItem::NotesItem( QObject *parent ) | ||||
19 | : AbstractDataPluginItem( parent ) | ||||
20 | { | ||||
21 | setSize( QSize( 0, 0 ) ); | ||||
22 | setCacheMode( ItemCoordinateCache ); | ||||
23 | } | ||||
24 | | ||||
25 | NotesItem::~NotesItem() | ||||
26 | { | ||||
27 | } | ||||
28 | | ||||
29 | bool NotesItem::initialized() const | ||||
30 | { | ||||
31 | return !id().isEmpty(); | ||||
32 | } | ||||
33 | | ||||
34 | bool NotesItem::operator<( const AbstractDataPluginItem *other ) const | ||||
35 | { | ||||
36 | return this->id() < other->id(); | ||||
37 | } | ||||
38 | | ||||
39 | void NotesItem::paint( QPainter *painter ) | ||||
40 | { | ||||
41 | painter->save(); | ||||
42 | | ||||
43 | /*QPen outlinepen( Qt::white ); | ||||
44 | outlinepen.setWidthF( s_labelOutlineWidth ); | ||||
45 | QBrush outlinebrush( Qt::black ); | ||||
46 | const int fontAscent = QFontMetrics( s_font ).ascent(); | ||||
47 | | ||||
48 | const QPointF baseline( s_labelOutlineWidth / 2.0, fontAscent ); | ||||
49 | | ||||
50 | QPainterPath outlinepath; | ||||
51 | outlinepath.addText( baseline, s_font, "Note" ); | ||||
52 | | ||||
53 | painter->setRenderHint( QPainter::Antialiasing, true ); | ||||
54 | painter->setPen( outlinepen ); | ||||
55 | painter->setBrush( outlinebrush ); | ||||
56 | painter->drawPath( outlinepath ); | ||||
57 | painter->setPen( Qt::NoPen ); | ||||
58 | painter->drawPath( outlinepath ); | ||||
59 | painter->setRenderHint( QPainter::Antialiasing, false );*/ | ||||
60 | painter->drawImage(QRect(), QImage("waypoint.png"), QRect()); //copyed image from data/bitmaps for testing purposes. | ||||
61 | | ||||
62 | painter->restore(); | ||||
63 | } |