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

superkaramba

  • superkaramba
  • src
datesensor.cpp
1 /***************************************************************************
2  * Copyright (C) 2003 by Hans Karlsson *
3  * karlsson.h@home.se *
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 #include "datesensor.h"
11 
12 #include <tqapplication.h>
13 DateSensor::DateSensor( int interval ) : Sensor( interval )
14 {
15  hidden = true;
16 }
17 DateSensor::~DateSensor()
18 {
19 }
20 
21 void DateSensor::update()
22 {
23  TQDateTime qdt = TQDateTime::currentDateTime();
24  TQString format;
25  SensorParams *sp;
26  Meter *meter;
27 
28  TQObjectListIt it( *objList );
29  while (it != 0)
30  {
31  sp = (SensorParams*)(*it);
32  meter = sp->getMeter();
33  format = sp->getParam("FORMAT");
34 
35  if (format.length() == 0 )
36  {
37  format = "hh:mm";
38  }
39  meter->setValue(qdt.toString(format));
40  ++it;
41  }
42 }
43 
44 void DateSensor::slotCalendarDeleted()
45 {
46  hidden = true;
47  cal = 0L;
48 }
49 
50 
51 DatePicker::DatePicker(TQWidget *parent)
52  : TQVBox( parent, 0, WType_TopLevel | WDestructiveClose |
53  WStyle_Customize | WStyle_StaysOnTop | WStyle_NoBorder )
54 {
55  setFrameStyle( TQFrame::PopupPanel | TQFrame::Raised );
56  //KWin::setOnAllDesktops( handle(), true );
57  picker = new KDatePicker(this);
58  picker->setCloseButton(true);
59 
60  /* name and icon for kicker's taskbar */
61  //setCaption(i18n("Calendar"));
62  //setIcon(SmallIcon("date"));
63 }
64 
65 void DatePicker::keyReleaseEvent(TQKeyEvent *e)
66 {
67  TQVBox::keyReleaseEvent(e);
68  if (e->key() == TQt::Key_Escape)
69  close();
70 }
71 
72 void DateSensor::toggleCalendar(TQMouseEvent *ev)
73 {
74  TQObjectListIt it(*objList);
75  while (it != 0)
76  {
77  SensorParams *sp = (SensorParams*)(*it);
78  Meter *meter = sp->getMeter();
79  TQString width = sp->getParam("CALWIDTH");
80  TQString height = sp->getParam("CALHEIGHT");
81 
82  TQRect rect(meter->getX(),meter->getY(),width.toInt(), height.toInt());
83  if (rect.contains( ev->x(), ev->y() ))
84  {
85  if (hidden)
86  {
87  hidden = false;
88  cal = new DatePicker(0);
89 
90  connect(cal, TQ_SIGNAL(destroyed()), TQ_SLOT(slotCalendarDeleted()));
91  TQPoint c = (TQPoint(ev->x(), ev->y()));
92 
93  int w = cal->sizeHint().width();
94  int h = cal->sizeHint().height();
95 
96  // make calendar fully visible
97  TQRect deskR = TQApplication::desktop()->screenGeometry(TQApplication::desktop()->screenNumber(c));
98 
99 
100  if (c.y()+h > deskR.bottom()) c.setY(deskR.bottom()-h-1);
101  if (c.x()+w > deskR.right()) c.setX(deskR.right()-w-1);
102  cal->move(c);
103  cal->show();
104 
105  }
106  else
107  {
108  cal->close();
109  }
110  }
111 
112  ++it;
113  }
114 }
115 
116 void DateSensor::mousePressEvent(TQMouseEvent *ev)
117 {
118  switch (ev->button())
119  {
120  case TQt::LeftButton:
121  toggleCalendar(ev);
122  break;
123  default:
124  break;
125  }
126 }
127 
128 
129 #include "datesensor.moc"
SensorParams
Hans Karlsson.
Definition: sensorparams.h:31

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.8.13
This website is maintained by Timothy Pearson.