TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

80 lines
2.9 KiB

  1. /*******************************************************************
  2. KNotes -- Notes for the KDE project
  3. Copyright (c) 2005, Michael Brade <brade@kde.org>
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. In addition, as a special exception, the copyright holders give
  16. permission to link the code of this program with any edition of
  17. the TQt library by Trolltech AS, Norway (or with modified versions
  18. of TQt that use the same license as TQt), and distribute linked
  19. combinations including the two. You must obey the GNU General
  20. Public License in all respects for all of the code used other than
  21. TQt. If you modify this file, you may extend this exception to
  22. your version of the file, but you are not obligated to do so. If
  23. you do not wish to do so, delete this exception statement from
  24. your version.
  25. *******************************************************************/
  26. #include <tqstringlist.h>
  27. #include <tdemessagebox.h>
  28. #include <tdelocale.h>
  29. #include <libkcal/calendarresources.h>
  30. #include "knotes/resourcemanager.h"
  31. #include "knotesalarm.h"
  32. #include "knotesglobalconfig.h"
  33. KNotesAlarm::KNotesAlarm( KNotesResourceManager *manager, TQObject *parent, const char *name )
  34. : TQObject( parent, name ),
  35. m_manager( manager ),
  36. m_checkTimer( 0, "m_checkTimer" )
  37. {
  38. // TODO: fix timezone stuff?
  39. connect( &m_checkTimer, TQT_SIGNAL(timeout()), TQT_SLOT(checkAlarms()) );
  40. m_checkTimer.start( 1000 * KNotesGlobalConfig::self()->checkInterval() ); // interval in seconds
  41. }
  42. void KNotesAlarm::checkAlarms()
  43. {
  44. TQDateTime from = KNotesGlobalConfig::self()->alarmsLastChecked().addSecs( 1 );
  45. if ( !from.isValid() )
  46. from.setTime_t( 0 );
  47. KNotesGlobalConfig::self()->setAlarmsLastChecked( TQDateTime::currentDateTime() );
  48. TQValueList<KCal::Alarm *> alarms = m_manager->alarms( from, KNotesGlobalConfig::self()->alarmsLastChecked() );
  49. if( alarms.isEmpty())
  50. return;
  51. TQStringList notes;
  52. TQValueList<KCal::Alarm *>::ConstIterator it;
  53. for ( it = alarms.constBegin(); it != alarms.constEnd(); ++it )
  54. {
  55. KCal::Incidence *incidence = (*it)->parent();
  56. notes += incidence->summary();
  57. }
  58. if ( !notes.isEmpty() )
  59. KMessageBox::informationList( 0, i18n("The following notes triggered alarms:"), notes, i18n("Alarm") );
  60. }
  61. #include "knotesalarm.moc"