• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

superkaramba

  • sources
  • kde-4.12
  • kdeutils
  • superkaramba
  • src
  • meters
clickmap.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2003 by Ralph M. Churchill <mrchucho@yahoo.com> *
3  * Copyright (C) 2007 Matt Broadstone <mbroadst@gmail.com> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  ***************************************************************************/
10 
11 #include "clickmap.h"
12 #include "clickmap.moc"
13 
14 #include "karamba.h"
15 
16 #include <QPainter>
17 #include <QGraphicsSceneMouseEvent>
18 
19 #include <KRun>
20 
21 ClickMap::ClickMap(Karamba* k, int x, int y, int w, int h)
22  : Meter(k, x, y, w, h)
23 {
24  /*
25  if( h != 0 || w != 0)
26  clip = 0;
27  else
28  clip = Qt::TextDontClip;
29  */
30 
31  if (h == 0 || w == 0) {
32  setWidth(-1);
33  setHeight(-1);
34  }
35 }
36 
37 ClickMap::~ClickMap()
38 {}
39 
40 void ClickMap::setTextProps(TextField *t)
41 {
42  text = *t;
43 }
44 
45 void ClickMap::mousePressEvent(QGraphicsSceneMouseEvent *e)
46 {
47  int index = (int)((e->pos().y() - getY()) / text.getLineHeight()) + 1;
48  if (index >= 1 && index <= (int)displays.count()) {
49  // qDebug( "You clicked item " + QString::number( index ) + ", " +
50  // displays[index - 1] + " " + links[index - 1] );
51  KRun::runCommand("konqueror " + links[index - 1],0L);
52  }
53 
54  return;
55 }
56 
57 void ClickMap::paint(QPainter *p, const QStyleOptionGraphicsItem *option,
58  QWidget *widget)
59 {
60  Q_UNUSED(option);
61  Q_UNUSED(widget);
62 
63  int i = 0; //text.getLineHeight();
64  int row = 1;
65 
66  p->setFont(text.getFont());
67 
68  QStringList::Iterator it = displays.begin();
69  while (it != displays.end() && (row <= getHeight() || getHeight() == -1)) {
70  p->setPen(text.getColor());
71  // p->drawText(x,y+i,width,height, Qt::AlignCenter | Qt::TextExpandTabs, *it);
72  p->drawText(getX(), getY() + i + text.getLineHeight(), *it);
73  i += text.getLineHeight();
74  it++;
75  row++;
76  }
77 }
78 
79 void ClickMap::setValue(const QString &v)
80 {
81  QRegExp rx("^http://", Qt::CaseInsensitive);
82  if (rx.indexIn(v) == -1)
83  displays.append(v);
84  else
85  links.append(v);
86 }
87 
88 void ClickMap::setValue(int v)
89 {
90  if (v == 0) {
91  links.clear();
92  displays.clear();
93  }
94 }
95 
Meter::getHeight
virtual int getHeight() const
Definition: meters/meter.cpp:97
Meter::getY
virtual int getY() const
Definition: meters/meter.cpp:69
TextField::getFont
QString getFont() const
Definition: textfield.cpp:88
clickmap.h
QWidget
Meter::setHeight
virtual void setHeight(int)
Definition: meters/meter.cpp:102
TextField::getColor
QColor getColor() const
Definition: textfield.cpp:65
ClickMap::setTextProps
void setTextProps(TextField *)
Definition: clickmap.cpp:40
Karamba
Definition: karamba.h:52
Meter::setWidth
virtual void setWidth(int)
Definition: meters/meter.cpp:88
ClickMap::setValue
void setValue(const QString &)
Definition: clickmap.cpp:79
ClickMap::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
Definition: clickmap.cpp:57
TextField::getLineHeight
int getLineHeight() const
Definition: textfield.cpp:155
ClickMap::~ClickMap
~ClickMap()
Definition: clickmap.cpp:37
ClickMap::mousePressEvent
void mousePressEvent(QGraphicsSceneMouseEvent *event)
Definition: clickmap.cpp:45
Meter
Definition: meters/meter.h:23
Meter::getX
virtual int getX() const
Definition: meters/meter.cpp:55
ClickMap::ClickMap
ClickMap(Karamba *k, int x, int y, int w, int h)
Definition: clickmap.cpp:21
TextField
Ralph M.
Definition: textfield.h:22
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

superkaramba

Skip menu "superkaramba"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal