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

superkaramba

clickarea.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Hans Karlsson                                   *
00003  *   karlsson.h@home.se                                                    *
00004  *                                                                         *
00005  *   Copyright (C) 2004,2005 Luke Kenneth Casson Leighton <lkcl@lkcl.net>  *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  ***************************************************************************/
00012 
00013 #include "clickarea.h"
00014 
00015 #include <QMouseEvent>
00016 #include <QCursor>
00017 
00018 #include <KService>
00019 
00020 
00021 ClickArea::ClickArea(Karamba* k, bool preview, int x, int y, int w, int h)
00022         : Meter(k, x, y, w, h), m_preview(preview)
00023 {
00024     value = "";
00025     setAcceptedMouseButtons(Qt::LeftButton);
00026     setCursor(QCursor(Qt::PointingHandCursor));
00027 }
00028 
00029 ClickArea::~ClickArea()
00030 {}
00031 
00032 bool ClickArea::mouseEvent(QEvent *e)
00033 {
00034     //K3ShellProcess ksp;
00035     Q_UNUSED(e);
00036 
00037     if (!svc_name.isEmpty()) {
00038         KService sv(svc_name, svc_onClick, svc_icon);
00039         KUrl::List l;
00040         KRun::run(sv, l, 0);
00041         return false;
00042     } else {
00043         QString program;
00044         program = onClick;
00045         program.replace(QRegExp("%v", Qt::CaseInsensitive), value);
00046 
00047         if (!program.isEmpty()) {
00048             //qDebug(program);
00049             KRun::runCommand(program,0L);
00050         }
00051     }
00052 
00053     return false;
00054 }
00055 
00056 void ClickArea::setOnClick(const QString &oc)
00057 {
00058     onClick = oc;
00059 }
00060 
00061 void ClickArea::setServiceOnClick(const QString &name, const QString &exec, const QString &icon)
00062 {
00063     svc_name = name;
00064     svc_onClick = exec;
00065     svc_icon = icon;
00066 }
00067 
00068 void ClickArea::setOnMiddleClick(const QString &oc)
00069 {
00070     onMiddleClick = oc;
00071 }
00072 
00073 
00074 QRect ClickArea::getRectangle()
00075 {
00076     return boundingRect().toRect();
00077 }
00078 
00079 void ClickArea::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
00080                       QWidget *widget)
00081 {
00082     Q_UNUSED(option);
00083     Q_UNUSED(widget);
00084 
00085     if (m_preview)
00086         painter->drawRect(boundingRect());
00087 }
00088 
00089 
00090 void ClickArea::setValue(int v)
00091 {
00092     setValue(QString::number(v));
00093 }
00094 
00095 
00096 void ClickArea::setValue(const QString &v)
00097 {
00098     value = v;
00099 }
00100 
00101 #include "clickarea.moc"

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