diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 2bda8f7717adf28da4af0d34fb82f63d2868c31d (patch) | |
tree | 8d927b7b47a90c4adb646482a52613f58acd6f8c /superkaramba/src/clickmap.cpp | |
download | tdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.tar.gz tdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'superkaramba/src/clickmap.cpp')
-rw-r--r-- | superkaramba/src/clickmap.cpp | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/superkaramba/src/clickmap.cpp b/superkaramba/src/clickmap.cpp new file mode 100644 index 0000000..62b4376 --- /dev/null +++ b/superkaramba/src/clickmap.cpp @@ -0,0 +1,96 @@ +/*************************************************************************** + * Copyright (C) 2003 by Ralph M. Churchill * + * [email protected] * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#include "clickmap.h" +#include <qregexp.h> +#include <krun.h> + +ClickMap::ClickMap(karamba* k, int x, int y, int w, int h ) + :Meter(k, x, y, w, h ) +{ +/* + if( h != 0 || w != 0) + clip = 0; + else + clip = Qt::DontClip; +*/ + + if( h == 0 || w == 0) + { + setWidth(-1); + setHeight(-1); + } +} + +ClickMap::~ClickMap() +{ +} + +void ClickMap::setTextProps( TextField *t ) +{ + text = *t; +} + +bool ClickMap::click( QMouseEvent *e ) { + + //Don't load the web page if the click isn't for us + if (boundingBox.contains(e->x(), e->y())) { + + int index = ((e -> y() - getY()) / text.getLineHeight()) + 1; + if (index >= 1 && index <= (int)displays.count()) { + // qDebug( "You clicked item " + QString::number( index ) + ", " + + // displays[index - 1] + " " + links[index - 1] ); + KRun::runCommand("konqueror " + links[index - 1]); + } + } + return false; +} + +void ClickMap::mUpdate( QPainter *p ) +{ + int i = 0; //text.getLineHeight(); + int row = 1; + + p->setFont(text.getFont()); + QStringList::Iterator it = displays.begin(); + while( it != displays.end() && (row <= getHeight() || getHeight() == -1 ) ) + { + p->setPen( text.getColor() ); + // p->drawText(x,y+i,width,height, Qt::AlignCenter | Qt::ExpandTabs, *it); + p->drawText(getX(), getY() + i + text.getLineHeight(), *it); + i += text.getLineHeight(); + it++; + row++; + } +} + +void ClickMap::setValue( QString v ) +{ + QRegExp rx("^http://", false ); + if ( rx.search( v ) == -1 ) + { + displays.append( v ); + } + else + { + links.append( v ); + } +} + +void ClickMap::setValue( long v ) +{ + if ( v == 0 ) + { + links.clear(); + displays.clear(); + } +} + +#include "clickmap.moc" |