summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebook.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp78
1 files changed, 47 insertions, 31 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index cc7bf4b..68ab07a 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -1,188 +1,204 @@
1/********************************************************************** 1/*
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2                 This file is part of the Opie Project
3** 3
4** This file is part of Qtopia Environment. 4 Copyright (C) Opie Team <opie-devel@handhelds.org>
5** 5 =.
6** This file may be distributed and/or modified under the terms of the 6 .=l.
7** GNU General Public License version 2 as published by the Free Software 7           .>+-=
8** Foundation and appearing in the file LICENSE.GPL included in the 8 _;:,     .>    :=|. This program is free software; you can
9** packaging of this file. 9.> <`_,   >  .   <= redistribute it and/or modify it under
10** 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11.="- .-=="i,     .._ License as published by the Free Software
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13** 13     ._= =}       : or (at your option) any later version.
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14    .%`+i>       _;_.
15** 15    .i_,=:_.      -<s. This program is distributed in the hope that
16** Contact info@trolltech.com if any conditions of this licensing are 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17** not clear to you. 17 : ..    .:,     . . . without even the implied warranty of
18** 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19** $Id$ 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20** 20..}^=.=       =       ; Library General Public License for more
21**********************************************************************/ 21++=   -.     .`     .: details.
22:     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29*/
22 30
23#define QTOPIA_INTERNAL_FD 31#define QTOPIA_INTERNAL_FD
24 32
25#include "datebook.h" 33#include "datebook.h"
26#include "datebookday.h" 34#include "datebookday.h"
27#include "datebooksettings.h" 35#include "datebooksettings.h"
28#include "datebookweek.h" 36#include "datebookweek.h"
29#include "modules/weeklst/datebookweeklst.h" 37#include "modules/weeklst/datebookweeklst.h"
30#include "modules/monthview/odatebookmonth.h" 38#include "modules/monthview/odatebookmonth.h"
31#include "dateentryimpl.h" 39#include "dateentryimpl.h"
32 40
33#include <opie2/odebug.h> 41#include <opie2/odebug.h>
34#include <opie2/oholidaypluginif.h> 42#include <opie2/oholidaypluginif.h>
35#include <opie2/oholidayplugin.h> 43#include <opie2/oholidayplugin.h>
36#include <opie2/opluginloader.h> 44#include <opie2/opluginloader.h>
45#include <opie2/oresource.h>
37#include <opie2/todayplugininterface.h> 46#include <opie2/todayplugininterface.h>
38 47
39//#include <qpe/datebookmonth.h> 48//#include <qpe/datebookmonth.h>
40#include <qpe/qpeapplication.h> 49#include <qpe/qpeapplication.h>
41#include <qpe/config.h> 50#include <qpe/config.h>
42#include <qpe/finddialog.h> 51#include <qpe/finddialog.h>
43#include <qpe/ir.h> 52#include <qpe/ir.h>
44#include <qpe/qpemessagebox.h> 53#include <qpe/qpemessagebox.h>
45#include <qpe/resource.h>
46#include <qpe/sound.h> 54#include <qpe/sound.h>
47#include <qpe/tzselect.h> 55#include <qpe/tzselect.h>
48#include <qtopia/qlibrary.h> 56#include <qtopia/qlibrary.h>
49 57
50#include <qaction.h> 58#include <qaction.h>
51#include <qcopchannel_qws.h> 59#include <qcopchannel_qws.h>
52#include <qlayout.h> 60#include <qlayout.h>
53#include <qmessagebox.h> 61#include <qmessagebox.h>
54#include <qtimer.h> 62#include <qtimer.h>
55#include <qtl.h> 63#include <qtl.h>
56#include <qtoolbar.h> 64#include <qtoolbar.h>
57#include <qwidgetstack.h> 65#include <qwidgetstack.h>
58#include <qdir.h> 66#include <qdir.h>
59#include <qlabel.h> 67#include <qlabel.h>
60 68
61#include <sys/stat.h> 69#include <sys/stat.h>
62#include <sys/types.h> 70#include <sys/types.h>
63#include <fcntl.h> 71#include <fcntl.h>
64#include <unistd.h> 72#include <unistd.h>
65 73
66#include <stdlib.h> 74#include <stdlib.h>
67 75
68DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 76DateBook::DateBook( QWidget *parent, const char *, WFlags f )
69 : QMainWindow( parent, "datebook", f ), 77 : QMainWindow( parent, "datebook", f ),
70 aPreset( FALSE ), 78 aPreset( FALSE ),
71 presetTime( -1 ), 79 presetTime( -1 ),
72 startTime( 8 ), // an acceptable default 80 startTime( 8 ), // an acceptable default
73 rowStyle( 0 ), 81 rowStyle( 0 ),
74 bJumpToCurTime(FALSE), 82 bJumpToCurTime(FALSE),
75 syncing(FALSE), 83 syncing(FALSE),
76 inSearch(FALSE), 84 inSearch(FALSE),
77 alarmCounter(0) 85 alarmCounter(0)
78{ 86{
79 bool needEvilHack= false; // if we need an Evil Hack 87 bool needEvilHack= false; // if we need an Evil Hack
80 QTime t; 88 QTime t;
81 t.start(); 89 t.start();
82 db = new DateBookDBHoliday; 90 db = new DateBookDBHoliday;
83 odebug << "loading db t=" << t.elapsed() << oendl; 91 odebug << "loading db t=" << t.elapsed() << oendl;
84 db_holiday = new DateBookHoliday(); 92 db_holiday = new DateBookHoliday();
85 db->db_holiday=db_holiday; 93 db->db_holiday=db_holiday;
86 94
87 loadSettings(); 95 loadSettings();
88 setCaption( tr("Calendar") ); 96 setCaption( tr("Calendar") );
89 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 97 setIcon( Opie::Core::OResource::loadPixmap( "datebook_icon" ) );
90 98
91 setToolBarsMovable( FALSE ); 99 setToolBarsMovable( FALSE );
92 100
93 views = new QWidgetStack( this ); 101 views = new QWidgetStack( this );
94 setCentralWidget( views ); 102 setCentralWidget( views );
95 103
96 dayView = 0; 104 dayView = 0;
97 weekView = 0; 105 weekView = 0;
98 weekLstView = 0; 106 weekLstView = 0;
99 monthView = 0; 107 monthView = 0;
100 108
101// QToolBar *bar = new QToolBar( this ); 109// QToolBar *bar = new QToolBar( this );
102// bar->setHorizontalStretchable( TRUE ); 110// bar->setHorizontalStretchable( TRUE );
103 111
104// QMenuBar *mb = new QMenuBar( bar ); 112// QMenuBar *mb = new QMenuBar( bar );
105// mb->setMargin( 0 ); 113// mb->setMargin( 0 );
106 114
107// QPopupMenu *view = new QPopupMenu( this ); 115// QPopupMenu *view = new QPopupMenu( this );
108// mb->insertItem( tr( "View" ), view ); 116// mb->insertItem( tr( "View" ), view );
109 117
110 QToolBar *sub_bar = new QToolBar(this); 118 QToolBar *sub_bar = new QToolBar(this);
111 sub_bar->setHorizontalStretchable(TRUE); 119 sub_bar->setHorizontalStretchable(TRUE);
112 120
113 QActionGroup *g = new QActionGroup( this ); 121 QActionGroup *g = new QActionGroup( this );
114 g->setExclusive( TRUE ); 122 g->setExclusive( TRUE );
115 123
116 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 124 QAction *a = new QAction( tr( "New" ), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
125 QString::null, 0, this, 0 );
117 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 126 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
118 a->addTo( sub_bar ); 127 a->addTo( sub_bar );
119 128
120 sub_bar->addSeparator(); 129 sub_bar->addSeparator();
121 130
122 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); 131 a = new QAction( tr( "Today" ), Opie::Core::OResource::loadPixmap( "datebook/to_day", Opie::Core::OResource::SmallIcon ),
132 QString::null, 0, g, 0 );
123 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 133 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
124 a->addTo( sub_bar ); 134 a->addTo( sub_bar );
125// a->addTo( view ); 135// a->addTo( view );
126 136
127 sub_bar->addSeparator(); 137 sub_bar->addSeparator();
128 138
129 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 139 a = new QAction( tr( "Day" ), Opie::Core::OResource::loadPixmap( "day", Opie::Core::OResource::SmallIcon ),
140 QString::null, 0, g, 0 );
130 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 141 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
131 a->addTo( sub_bar ); 142 a->addTo( sub_bar );
132// a->addTo( view ); 143// a->addTo( view );
133 a->setToggleAction( TRUE ); 144 a->setToggleAction( TRUE );
134 a->setOn( TRUE ); 145 a->setOn( TRUE );
135 dayAction = a; 146 dayAction = a;
136 147
137 a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 ); 148 a = new QAction( tr( "Week" ), Opie::Core::OResource::loadPixmap( "week", Opie::Core::OResource::SmallIcon ),
149 QString::null, 0, g, 0 );
138 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) ); 150 connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
139 a->addTo( sub_bar ); 151 a->addTo( sub_bar );
140// a->addTo( view ); 152// a->addTo( view );
141 a->setToggleAction( TRUE ); 153 a->setToggleAction( TRUE );
142 weekAction = a; 154 weekAction = a;
143 155
144 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); 156 a = new QAction( tr( "WeekLst" ), Opie::Core::OResource::loadPixmap( "datebook/weeklst", Opie::Core::OResource::SmallIcon ),
157 QString::null, 0, g, 0 );
145 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 158 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
146 a->addTo( sub_bar ); 159 a->addTo( sub_bar );
147// a->addTo( view ); 160// a->addTo( view );
148 a->setToggleAction( TRUE ); 161 a->setToggleAction( TRUE );
149 weekLstAction = a; 162 weekLstAction = a;
150 163
151 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 164 a = new QAction( tr( "Month" ), Opie::Core::OResource::loadPixmap( "month", Opie::Core::OResource::SmallIcon ),
165 QString::null, 0, g, 0 );
152 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 166 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
153 a->addTo( sub_bar ); 167 a->addTo( sub_bar );
154// a->addTo( view ); 168// a->addTo( view );
155 a->setToggleAction( TRUE ); 169 a->setToggleAction( TRUE );
156 monthAction = a; 170 monthAction = a;
157 171
158 sub_bar->addSeparator(); 172 sub_bar->addSeparator();
159 173
160 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); 174 a = new QAction( tr( "Find" ), Opie::Core::OResource::loadPixmap( "mag", Opie::Core::OResource::SmallIcon ),
175 QString::null, 0, this, 0 );
161 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 176 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
162 a->addTo( sub_bar ); 177 a->addTo( sub_bar );
163 178
164 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); 179 a = new QAction( tr( "Edit..." ), Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ),
180 QString::null, 0, this, 0 );
165 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 181 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
166 a->addTo( sub_bar ); 182 a->addTo( sub_bar );
167 183
168 if(defaultView==DAY) viewDay(); 184 if(defaultView==DAY) viewDay();
169 if(defaultView==WEEK) needEvilHack=true; // viewWeek(); 185 if(defaultView==WEEK) needEvilHack=true; // viewWeek();
170 if(defaultView==WEEKLST) viewWeekLst(); 186 if(defaultView==WEEKLST) viewWeekLst();
171 if(defaultView==MONTH) viewMonth(); 187 if(defaultView==MONTH) viewMonth();
172 188
173 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 189 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
174 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 190 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
175 191
176#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 192#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
177 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); 193 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) );
178#endif 194#endif
179 195
180 // listen on QPE/System 196 // listen on QPE/System
181#if defined(Q_WS_QWS) 197#if defined(Q_WS_QWS)
182#if !defined(QT_NO_COP) 198#if !defined(QT_NO_COP)
183 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 199 QCopChannel *channel = new QCopChannel( "QPE/System", this );
184 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 200 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
185 channel = new QCopChannel( "QPE/Datebook", this ); 201 channel = new QCopChannel( "QPE/Datebook", this );
186 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 202 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
187#endif 203#endif
188#endif 204#endif