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

superkaramba

clickmap.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Ralph M. Churchill <mrchucho@yahoo.com>         *
00003  *   Copyright (C) 2007 Matt Broadstone <mbroadst@gmail.com>               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 
00011 #include "clickmap.h"
00012 #include "clickmap.moc"
00013 
00014 #include "karamba.h"
00015 
00016 #include <QPainter>
00017 #include <QGraphicsSceneMouseEvent>
00018 
00019 #include <KRun>
00020 
00021 ClickMap::ClickMap(Karamba* k, int x, int y, int w, int h)
00022         :   Meter(k, x, y, w, h)
00023 {
00024     /*
00025         if( h != 0 || w != 0)
00026             clip = 0;
00027         else
00028             clip = Qt::TextDontClip;
00029     */
00030 
00031     if (h == 0 || w == 0) {
00032         setWidth(-1);
00033         setHeight(-1);
00034     }
00035 }
00036 
00037 ClickMap::~ClickMap()
00038 {}
00039 
00040 void ClickMap::setTextProps(TextField *t)
00041 {
00042     text = *t;
00043 }
00044 
00045 void ClickMap::mousePressEvent(QGraphicsSceneMouseEvent *e)
00046 {
00047     int index = (int)((e->pos().y() - getY()) / text.getLineHeight()) + 1;
00048     if (index >= 1 && index <= (int)displays.count()) {
00049         // qDebug( "You clicked item " + QString::number( index ) + ", " +
00050         //  displays[index - 1] + " " + links[index - 1] );
00051         KRun::runCommand("konqueror " + links[index - 1],0L);
00052     }
00053 
00054     return;
00055 }
00056 
00057 void ClickMap::paint(QPainter *p, const QStyleOptionGraphicsItem *option,
00058                      QWidget *widget)
00059 {
00060     Q_UNUSED(option);
00061     Q_UNUSED(widget);
00062 
00063     int i = 0; //text.getLineHeight();
00064     int row = 1;
00065 
00066     p->setFont(text.getFont());
00067 
00068     QStringList::Iterator it = displays.begin();
00069     while (it != displays.end() && (row <= getHeight() || getHeight() == -1)) {
00070         p->setPen(text.getColor());
00071         // p->drawText(x,y+i,width,height,  Qt::AlignCenter | Qt::TextExpandTabs, *it);
00072         p->drawText(getX(), getY() + i + text.getLineHeight(), *it);
00073         i += text.getLineHeight();
00074         it++;
00075         row++;
00076     }
00077 }
00078 
00079 void ClickMap::setValue(const QString &v)
00080 {
00081     QRegExp rx("^http://", Qt::CaseInsensitive);
00082     if (rx.indexIn(v) == -1)
00083         displays.append(v);
00084     else
00085         links.append(v);
00086 }
00087 
00088 void ClickMap::setValue(int v)
00089 {
00090     if (v == 0) {
00091         links.clear();
00092         displays.clear();
00093     }
00094 }
00095 

superkaramba

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

kdeutils

Skip menu "kdeutils"
  • ark
  • kcalc
  • kcharselect
  • kdelirc
  • kdessh
  • kdf
  • kfloppy
  • kgpg
  • kjots
  • klaptopdaemon
  • kmilo
  • ksim
  • ktimer
  • kwallet
  • superkaramba
Generated for kdeutils by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal