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.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 3d1bc0c..0a47bb8 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -27,97 +27,97 @@
27#include "datebooksettings.h" 27#include "datebooksettings.h"
28#include "datebookweek.h" 28#include "datebookweek.h"
29#include "datebookweeklst.h" 29#include "datebookweeklst.h"
30#include "dateentryimpl.h" 30#include "dateentryimpl.h"
31 31
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33 33
34#include <qpe/datebookmonth.h> 34#include <qpe/datebookmonth.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/finddialog.h> 37#include <qpe/finddialog.h>
38#include <qpe/ir.h> 38#include <qpe/ir.h>
39#include <qpe/qpemessagebox.h> 39#include <qpe/qpemessagebox.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/tzselect.h> 42#include <qpe/tzselect.h>
43 43
44#include <qaction.h> 44#include <qaction.h>
45#include <qcopchannel_qws.h> 45#include <qcopchannel_qws.h>
46#include <qlayout.h> 46#include <qlayout.h>
47#include <qmessagebox.h> 47#include <qmessagebox.h>
48#include <qtimer.h> 48#include <qtimer.h>
49#include <qtl.h> 49#include <qtl.h>
50#include <qtoolbar.h> 50#include <qtoolbar.h>
51#include <qwidgetstack.h> 51#include <qwidgetstack.h>
52 52
53#include <sys/stat.h> 53#include <sys/stat.h>
54#include <sys/types.h> 54#include <sys/types.h>
55#include <fcntl.h> 55#include <fcntl.h>
56#include <unistd.h> 56#include <unistd.h>
57 57
58#include <stdlib.h> 58#include <stdlib.h>
59 59
60DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 60DateBook::DateBook( QWidget *parent, const char *, WFlags f )
61 : QMainWindow( parent, "datebook", f ), 61 : QMainWindow( parent, "datebook", f ),
62 aPreset( FALSE ), 62 aPreset( FALSE ),
63 presetTime( -1 ), 63 presetTime( -1 ),
64 startTime( 8 ), // an acceptable default 64 startTime( 8 ), // an acceptable default
65 rowStyle( 0 ), 65 rowStyle( 0 ),
66 bJumpToCurTime(FALSE), 66 bJumpToCurTime(FALSE),
67 syncing(FALSE), 67 syncing(FALSE),
68 inSearch(FALSE), 68 inSearch(FALSE),
69 alarmCounter(0) 69 alarmCounter(0)
70{ 70{
71 bool needEvilHack= false; // if we need an Evil Hack 71 bool needEvilHack= false; // if we need an Evil Hack
72 QTime t; 72 QTime t;
73 t.start(); 73 t.start();
74 db = new DateBookDBHack; 74 db = new DateBookDBHack;
75 Opie::Core::odebug << "loading db t=" << t.elapsed() << oendl; 75 odebug << "loading db t=" << t.elapsed() << oendl;
76 loadSettings(); 76 loadSettings();
77 setCaption( tr("Calendar") ); 77 setCaption( tr("Calendar") );
78 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 78 setIcon( Resource::loadPixmap( "datebook_icon" ) );
79 79
80 setToolBarsMovable( FALSE ); 80 setToolBarsMovable( FALSE );
81 81
82 views = new QWidgetStack( this ); 82 views = new QWidgetStack( this );
83 setCentralWidget( views ); 83 setCentralWidget( views );
84 84
85 dayView = 0; 85 dayView = 0;
86 weekView = 0; 86 weekView = 0;
87 weekLstView = 0; 87 weekLstView = 0;
88 monthView = 0; 88 monthView = 0;
89 89
90// QToolBar *bar = new QToolBar( this ); 90// QToolBar *bar = new QToolBar( this );
91// bar->setHorizontalStretchable( TRUE ); 91// bar->setHorizontalStretchable( TRUE );
92 92
93// QMenuBar *mb = new QMenuBar( bar ); 93// QMenuBar *mb = new QMenuBar( bar );
94// mb->setMargin( 0 ); 94// mb->setMargin( 0 );
95 95
96// QPopupMenu *view = new QPopupMenu( this ); 96// QPopupMenu *view = new QPopupMenu( this );
97// mb->insertItem( tr( "View" ), view ); 97// mb->insertItem( tr( "View" ), view );
98 98
99 QToolBar *sub_bar = new QToolBar(this); 99 QToolBar *sub_bar = new QToolBar(this);
100 sub_bar->setHorizontalStretchable(TRUE); 100 sub_bar->setHorizontalStretchable(TRUE);
101 101
102 QActionGroup *g = new QActionGroup( this ); 102 QActionGroup *g = new QActionGroup( this );
103 g->setExclusive( TRUE ); 103 g->setExclusive( TRUE );
104 104
105 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 105 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
106 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 106 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
107 a->addTo( sub_bar ); 107 a->addTo( sub_bar );
108 108
109 sub_bar->addSeparator(); 109 sub_bar->addSeparator();
110 110
111 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 ); 111 a = new QAction( tr( "Today" ), Resource::loadPixmap( "datebook/to_day" ), QString::null, 0, g, 0 );
112 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); 112 connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) );
113 a->addTo( sub_bar ); 113 a->addTo( sub_bar );
114 //a->addTo( view ); 114 //a->addTo( view );
115 115
116 sub_bar->addSeparator(); 116 sub_bar->addSeparator();
117 117
118 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); 118 a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 );
119 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); 119 connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) );
120 a->addTo( sub_bar ); 120 a->addTo( sub_bar );
121// a->addTo( view ); 121// a->addTo( view );
122 a->setToggleAction( TRUE ); 122 a->setToggleAction( TRUE );
123 a->setOn( TRUE ); 123 a->setOn( TRUE );
@@ -131,97 +131,97 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
131 weekAction = a; 131 weekAction = a;
132 132
133 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 ); 133 a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "datebook/weeklst" ), QString::null, 0, g, 0 );
134 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) ); 134 connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
135 a->addTo( sub_bar ); 135 a->addTo( sub_bar );
136// a->addTo( view ); 136// a->addTo( view );
137 a->setToggleAction( TRUE ); 137 a->setToggleAction( TRUE );
138 weekLstAction = a; 138 weekLstAction = a;
139 139
140 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 ); 140 a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
141 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) ); 141 connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
142 a->addTo( sub_bar ); 142 a->addTo( sub_bar );
143// a->addTo( view ); 143// a->addTo( view );
144 a->setToggleAction( TRUE ); 144 a->setToggleAction( TRUE );
145 monthAction = a; 145 monthAction = a;
146 146
147 sub_bar->addSeparator(); 147 sub_bar->addSeparator();
148 148
149 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); 149 a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 );
150 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); 150 connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
151 a->addTo( sub_bar ); 151 a->addTo( sub_bar );
152 152
153 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); 153 a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 );
154 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 154 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
155 a->addTo( sub_bar ); 155 a->addTo( sub_bar );
156 156
157 if(defaultView==DAY) viewDay(); 157 if(defaultView==DAY) viewDay();
158 if(defaultView==WEEK) needEvilHack=true;// viewWeek(); 158 if(defaultView==WEEK) needEvilHack=true;// viewWeek();
159 if(defaultView==WEEKLST) viewWeekLst(); 159 if(defaultView==WEEKLST) viewWeekLst();
160 if(defaultView==MONTH) viewMonth(); 160 if(defaultView==MONTH) viewMonth();
161 161
162 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); 162 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
163 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); 163 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
164 164
165#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 165#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
166 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); 166 connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) );
167#endif 167#endif
168 168
169 // listen on QPE/System 169 // listen on QPE/System
170#if defined(Q_WS_QWS) 170#if defined(Q_WS_QWS)
171#if !defined(QT_NO_COP) 171#if !defined(QT_NO_COP)
172 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 172 QCopChannel *channel = new QCopChannel( "QPE/System", this );
173 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 173 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
174 channel = new QCopChannel( "QPE/Datebook", this ); 174 channel = new QCopChannel( "QPE/Datebook", this );
175 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); 175 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) );
176#endif 176#endif
177#endif 177#endif
178 178
179 Opie::Core::odebug << "done t=" << t.elapsed() << oendl; 179 odebug << "done t=" << t.elapsed() << oendl;
180 180
181 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); 181 connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) );
182 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); 182 connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) );
183 /* 183 /*
184 * Here is a problem description: 184 * Here is a problem description:
185 * When Weekview is the default view 185 * When Weekview is the default view
186 * a DateBookWeekView get's created 186 * a DateBookWeekView get's created
187 * redraw() get's called. So what? 187 * redraw() get's called. So what?
188 * Remember that we're still in the c'tor 188 * Remember that we're still in the c'tor
189 * and no final layout has happened? Ok 189 * and no final layout has happened? Ok
190 * now all Events get arranged. Their x 190 * now all Events get arranged. Their x
191 * position get's determined by a QHeader 191 * position get's determined by a QHeader
192 * position. But the QHeader isn't layouted or 192 * position. But the QHeader isn't layouted or
193 * at the right position. redraw() is a slot 193 * at the right position. redraw() is a slot
194 * so we'll call it then via a singleShot 194 * so we'll call it then via a singleShot
195 * from view() 195 * from view()
196 */ 196 */
197 if( needEvilHack ){ 197 if( needEvilHack ){
198 QTimer::singleShot( 500, this, SLOT(viewWeek()) ); 198 QTimer::singleShot( 500, this, SLOT(viewWeek()) );
199 } 199 }
200} 200}
201 201
202void DateBook::receive( const QCString &msg, const QByteArray &data ) 202void DateBook::receive( const QCString &msg, const QByteArray &data )
203{ 203{
204 QDataStream stream( data, IO_ReadOnly ); 204 QDataStream stream( data, IO_ReadOnly );
205 if ( msg == "timeChange(QString)" ) { 205 if ( msg == "timeChange(QString)" ) {
206 // update active view! 206 // update active view!
207 if ( dayAction->isOn() ) 207 if ( dayAction->isOn() )
208 viewDay(); 208 viewDay();
209 else if ( weekAction->isOn() ) 209 else if ( weekAction->isOn() )
210 viewWeek(); 210 viewWeek();
211 else if ( monthAction->isOn() ) 211 else if ( monthAction->isOn() )
212 viewMonth(); 212 viewMonth();
213 } 213 }
214 else if (msg == "editEvent(int)") { 214 else if (msg == "editEvent(int)") {
215 int uid; 215 int uid;
216 stream >> uid; 216 stream >> uid;
217 Event e=db->eventByUID(uid); 217 Event e=db->eventByUID(uid);
218 editEvent(e); 218 editEvent(e);
219 }else if (msg == "viewDefault(QDate)"){ 219 }else if (msg == "viewDefault(QDate)"){
220 QDate day; 220 QDate day;
221 stream >> day; 221 stream >> day;
222 viewDefault(day); 222 viewDefault(day);
223 } 223 }
224} 224}
225 225
226DateBook::~DateBook() 226DateBook::~DateBook()
227{ 227{
@@ -857,97 +857,97 @@ void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const
857 857
858 Event ev; 858 Event ev;
859 ev.setDescription( str ); 859 ev.setDescription( str );
860 // When the new gui comes in, change this... 860 // When the new gui comes in, change this...
861 if(location==0) { 861 if(location==0) {
862 if(defaultLocation.isEmpty()) { 862 if(defaultLocation.isEmpty()) {
863 ev.setLocation(tr("(Unknown)")); 863 ev.setLocation(tr("(Unknown)"));
864 } else { 864 } else {
865 ev.setLocation( defaultLocation ); 865 ev.setLocation( defaultLocation );
866 } 866 }
867 } else { 867 } else {
868 ev.setLocation(location); 868 ev.setLocation(location);
869 } 869 }
870 ev.setCategories(defaultCategories); 870 ev.setCategories(defaultCategories);
871 ev.setStart( start ); 871 ev.setStart( start );
872 ev.setEnd( end ); 872 ev.setEnd( end );
873 873
874 e = new DateEntry( onMonday, ev, ampm, &newDlg ); 874 e = new DateEntry( onMonday, ev, ampm, &newDlg );
875 e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); 875 e->setAlarmEnabled( aPreset, presetTime, Event::Loud );
876 sv->addChild( e ); 876 sv->addChild( e );
877 while ( QPEApplication::execDialog( &newDlg ) ) { 877 while ( QPEApplication::execDialog( &newDlg ) ) {
878 ev = e->event(); 878 ev = e->event();
879 ev.assignUid(); 879 ev.assignUid();
880 QString error = checkEvent( ev ); 880 QString error = checkEvent( ev );
881 if ( !error.isNull() ) { 881 if ( !error.isNull() ) {
882 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) 882 if ( QMessageBox::warning( this, tr("Error!"), error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 )
883 continue; 883 continue;
884 } 884 }
885 db->addEvent( ev ); 885 db->addEvent( ev );
886 emit newEvent(); 886 emit newEvent();
887 break; 887 break;
888 } 888 }
889} 889}
890 890
891void DateBook::setDocument( const QString &filename ) 891void DateBook::setDocument( const QString &filename )
892{ 892{
893 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; 893 if ( filename.find(".vcs") != int(filename.length()) - 4 ) return;
894 894
895 QValueList<Event> tl = Event::readVCalendar( filename ); 895 QValueList<Event> tl = Event::readVCalendar( filename );
896 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { 896 for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) {
897 db->addEvent( *it ); 897 db->addEvent( *it );
898 } 898 }
899} 899}
900 900
901static const char * beamfile = "/tmp/obex/event.vcs"; 901static const char * beamfile = "/tmp/obex/event.vcs";
902 902
903void DateBook::beamEvent( const Event &e ) 903void DateBook::beamEvent( const Event &e )
904{ 904{
905 Opie::Core::odebug << "trying to beam" << oendl; 905 odebug << "trying to beam" << oendl;
906 unlink( beamfile ); // delete if exists 906 unlink( beamfile ); // delete if exists
907 mkdir("/tmp/obex/", 0755); 907 mkdir("/tmp/obex/", 0755);
908 Event::writeVCalendar( beamfile, e ); 908 Event::writeVCalendar( beamfile, e );
909 Ir *ir = new Ir( this ); 909 Ir *ir = new Ir( this );
910 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 910 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
911 QString description = e.description(); 911 QString description = e.description();
912 ir->send( beamfile, description, "text/x-vCalendar" ); 912 ir->send( beamfile, description, "text/x-vCalendar" );
913} 913}
914 914
915void DateBook::beamDone( Ir *ir ) 915void DateBook::beamDone( Ir *ir )
916{ 916{
917 delete ir; 917 delete ir;
918 unlink( beamfile ); 918 unlink( beamfile );
919} 919}
920 920
921void DateBook::slotFind() 921void DateBook::slotFind()
922{ 922{
923 // move it to the day view... 923 // move it to the day view...
924 viewDay(); 924 viewDay();
925 FindDialog frmFind( "Calendar", this ); // no tr needed 925 FindDialog frmFind( "Calendar", this ); // no tr needed
926 frmFind.setUseDate( true ); 926 frmFind.setUseDate( true );
927 frmFind.setDate( currentDate() ); 927 frmFind.setDate( currentDate() );
928 QObject::connect( &frmFind, 928 QObject::connect( &frmFind,
929 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)), 929 SIGNAL(signalFindClicked(const QString&,const QDate&,bool,bool,int)),
930 this, 930 this,
931 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) ); 931 SLOT(slotDoFind(const QString&,const QDate&,bool,bool,int)) );
932 QObject::connect( this, 932 QObject::connect( this,
933 SIGNAL(signalNotFound()), 933 SIGNAL(signalNotFound()),
934 &frmFind, 934 &frmFind,
935 SLOT(slotNotFound()) ); 935 SLOT(slotNotFound()) );
936 QObject::connect( this, 936 QObject::connect( this,
937 SIGNAL(signalWrapAround()), 937 SIGNAL(signalWrapAround()),
938 &frmFind, 938 &frmFind,
939 SLOT(slotWrapAround()) ); 939 SLOT(slotWrapAround()) );
940 frmFind.move(0,0); 940 frmFind.move(0,0);
941 frmFind.exec(); 941 frmFind.exec();
942 inSearch = false; 942 inSearch = false;
943} 943}
944 944
945bool catComp( QArray<int> cats, int category ) 945bool catComp( QArray<int> cats, int category )
946{ 946{
947 bool returnMe; 947 bool returnMe;
948 int i, 948 int i,
949 count; 949 count;
950 950
951 count = int(cats.count()); 951 count = int(cats.count());
952 returnMe = false; 952 returnMe = false;
953 if ( (category == -1 && count == 0) || category == -2 ) 953 if ( (category == -1 && count == 0) || category == -2 )