• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • superkaramba
 

superkaramba

datesensor.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Hans Karlsson                                   *
00003  *   karlsson.h@home.se                                                      *
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 #include "datesensor.h"
00011 
00012 #include <tqapplication.h>
00013 DateSensor::DateSensor( int interval ) : Sensor( interval )
00014 {
00015     hidden = true;
00016 }
00017 DateSensor::~DateSensor()
00018 {
00019 }
00020 
00021 void DateSensor::update()
00022 {
00023     TQDateTime qdt  =  TQDateTime::currentDateTime();
00024     TQString format;
00025     SensorParams *sp;
00026     Meter *meter;
00027 
00028     TQObjectListIt it( *objList );
00029     while (it != 0)
00030     {
00031         sp = (SensorParams*)(*it);
00032         meter = sp->getMeter();
00033         format = sp->getParam("FORMAT");
00034 
00035         if (format.length() == 0 )
00036         {
00037        format = "hh:mm";
00038         }
00039         meter->setValue(qdt.toString(format));
00040         ++it;
00041     }
00042 }
00043 
00044 void DateSensor::slotCalendarDeleted()
00045 {
00046     hidden = true;
00047     cal = 0L;
00048 }
00049 
00050 
00051 DatePicker::DatePicker(TQWidget *parent)
00052     : TQVBox( parent, 0, WType_TopLevel | WDestructiveClose |
00053              WStyle_Customize | WStyle_StaysOnTop | WStyle_NoBorder )
00054 {
00055     setFrameStyle( TQFrame::PopupPanel | TQFrame::Raised );
00056     //KWin::setOnAllDesktops( handle(), true );
00057     picker = new KDatePicker(this);
00058     picker->setCloseButton(true);
00059 
00060     /* name and icon for kicker's taskbar */
00061     //setCaption(i18n("Calendar"));
00062     //setIcon(SmallIcon("date"));
00063 }
00064 
00065 void DatePicker::keyReleaseEvent(TQKeyEvent *e)
00066 {
00067         TQVBox::keyReleaseEvent(e);
00068         if (e->key() == TQt::Key_Escape)
00069                 close();
00070 }
00071 
00072 void DateSensor::toggleCalendar(TQMouseEvent *ev)
00073 {
00074     TQObjectListIt it(*objList);
00075     while (it != 0)
00076     {
00077         SensorParams *sp = (SensorParams*)(*it);
00078         Meter *meter = sp->getMeter();
00079         TQString width = sp->getParam("CALWIDTH");
00080         TQString height = sp->getParam("CALHEIGHT");
00081 
00082         TQRect rect(meter->getX(),meter->getY(),width.toInt(), height.toInt());
00083         if (rect.contains( ev->x(), ev->y() ))
00084         {
00085             if (hidden)
00086             {
00087                 hidden = false;
00088                 cal = new DatePicker(0);
00089 
00090                 connect(cal, TQT_SIGNAL(destroyed()), TQT_SLOT(slotCalendarDeleted()));
00091                 TQPoint c = (TQPoint(ev->x(), ev->y()));
00092 
00093                 int w = cal->sizeHint().width();
00094                 int h = cal->sizeHint().height();
00095 
00096                 // make calendar fully visible
00097                  TQRect deskR = TQApplication::desktop()->screenGeometry(TQApplication::desktop()->screenNumber(c));
00098 
00099 
00100                 if (c.y()+h > deskR.bottom())   c.setY(deskR.bottom()-h-1);
00101                 if (c.x()+w > deskR.right())    c.setX(deskR.right()-w-1);
00102                 cal->move(c);
00103                 cal->show();
00104 
00105             }
00106             else
00107             {
00108                 cal->close();
00109             }
00110         }
00111 
00112         ++it;
00113     }
00114 }
00115 
00116 void DateSensor::mousePressEvent(TQMouseEvent *ev)
00117 {
00118     switch (ev->button()) 
00119     {
00120         case Qt::LeftButton:
00121             toggleCalendar(ev);
00122             break;
00123         default:
00124             break;
00125     }
00126 }
00127 
00128 
00129 #include "datesensor.moc"

superkaramba

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

superkaramba

Skip menu "superkaramba"
  • kcalc
  •   knumber
  • superkaramba
Generated for superkaramba by doxygen 1.6.3
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |