summaryrefslogtreecommitdiff
path: root/core/pim
Side-by-side diff
Diffstat (limited to 'core/pim') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp46
-rw-r--r--core/pim/datebook/datebook.pro6
-rw-r--r--core/pim/datebook/datebookday.cpp123
-rw-r--r--core/pim/datebook/datebookday.h6
-rw-r--r--core/pim/datebook/datebookdayallday.cpp226
-rw-r--r--core/pim/datebook/datebookdayallday.h80
-rw-r--r--core/pim/datebook/datebooksettings.h1
-rw-r--r--core/pim/datebook/datebookweek.cpp63
-rw-r--r--core/pim/datebook/datebookweekheaderimpl.cpp12
-rw-r--r--core/pim/datebook/datebookweeklst.cpp10
-rw-r--r--core/pim/datebook/dateentryimpl.cpp2
-rw-r--r--core/pim/datebook/opie-datebook.control6
-rw-r--r--core/pim/datebook/repeatentry.cpp50
13 files changed, 557 insertions, 74 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index b7e89b0..10a9b59 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -207,48 +207,52 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
* from view()
*/
if( needEvilHack ){
QTimer::singleShot( 500, this, SLOT(viewWeek()) );
}
}
void DateBook::receive( const QCString &msg, const QByteArray &data )
{
QDataStream stream( data, IO_ReadOnly );
if ( msg == "timeChange(QString)" ) {
// update active view!
if ( dayAction->isOn() )
viewDay();
else if ( weekAction->isOn() )
viewWeek();
else if ( monthAction->isOn() )
viewMonth();
}
else if (msg == "editEvent(int)") {
int uid;
stream >> uid;
Event e=db->eventByUID(uid);
editEvent(e);
+ }else if (msg == "viewDefault(QDate)"){
+ QDate day;
+ stream >> day;
+ viewDefault(day);
}
}
DateBook::~DateBook()
{
}
void DateBook::slotSettings()
{
DateBookSettings frmSettings( ampm, this );
frmSettings.setStartTime( startTime );
frmSettings.setAlarmPreset( aPreset, presetTime );
frmSettings.setJumpToCurTime( bJumpToCurTime );
frmSettings.setRowStyle( rowStyle );
frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
bool found=false;
for (int i=0; i<(frmSettings.comboLocation->count()); i++) {
if ( frmSettings.comboLocation->text(i) == defaultLocation ) {
frmSettings.comboLocation->setCurrentItem(i);
found=true;
break;
}
@@ -415,133 +419,143 @@ void DateBook::duplicateEvent( const Event &e )
Event dupevent(e); // Make a duplicate.
// workaround added for text input.
QDialog editDlg( this, 0, TRUE );
DateEntry *entry;
editDlg.setCaption( tr("Duplicate Event") );
QVBoxLayout *vb = new QVBoxLayout( &editDlg );
QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
sv->setResizePolicy( QScrollView::AutoOneFit );
// KLUDGE!!!
sv->setHScrollBarMode( QScrollView::AlwaysOff );
vb->addWidget( sv );
entry = new DateEntry( onMonday, dupevent, ampm, &editDlg, "editor" );
entry->timezone->setEnabled( FALSE );
sv->addChild( entry );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
editDlg.showMaximized();
#endif
while (editDlg.exec() ) {
Event newEv = entry->event();
QString error = checkEvent(newEv);
if (!error.isNull()) {
- if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0)
+ if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0)
continue;
}
+ /*
+ * The problem:
+ * DateBookDB does remove repeating events not by uid but by the time
+ * the recurrence was created
+ * so we need to update that time as well
+ */
+ Event::RepeatPattern rp = newEv.repeatPattern();
+ rp.createTime = ::time( NULL );
+ newEv.setRepeat( TRUE, rp ); // has repeat and repeatPattern...
+
db->addEvent(newEv);
emit newEvent();
break;
}
}
void DateBook::editEvent( const Event &e )
{
if (syncing) {
QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
return;
}
// workaround added for text input.
QDialog editDlg( this, 0, TRUE );
DateEntry *entry;
editDlg.setCaption( tr("Edit Event") );
QVBoxLayout *vb = new QVBoxLayout( &editDlg );
QScrollView *sv = new QScrollView( &editDlg, "scrollview" );
sv->setResizePolicy( QScrollView::AutoOneFit );
// KLUDGE!!!
sv->setHScrollBarMode( QScrollView::AlwaysOff );
vb->addWidget( sv );
entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" );
entry->timezone->setEnabled( FALSE );
sv->addChild( entry );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
editDlg.showMaximized();
#endif
while (editDlg.exec() ) {
Event newEv = entry->event();
if(newEv.description().isEmpty() && newEv.notes().isEmpty() )
break;
newEv.setUid(e.uid()); // FIXME: Hack not to clear uid
QString error = checkEvent(newEv);
if (!error.isNull()) {
- if (QMessageBox::warning(this, "error box", error, "Fix it", "Continue", 0, 0, 1) == 0) continue;
+ if (QMessageBox::warning(this, tr("error box"), error, tr("Fix it"), tr("Continue"), 0, 0, 1) == 0) continue;
}
db->editEvent(e, newEv);
emit newEvent();
break;
}
}
void DateBook::removeEvent( const Event &e )
{
if (syncing) {
QMessageBox::warning( this, tr("Calendar"), tr( "Can not edit data, currently syncing") );
return;
}
QString strName = e.description();
if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) )
return;
db->removeEvent( e );
if ( views->visibleWidget() == dayView && dayView )
dayView->redraw();
}
void DateBook::addEvent( const Event &e )
{
QDate d = e.start().date();
initDay();
dayView->setDate( d );
}
void DateBook::showDay( int year, int month, int day )
{
QDate d(year, month, day);
view(DAY,d);
}
void DateBook::initDay()
{
if ( !dayView ) {
dayView = new DateBookDay( ampm, onMonday, db, views, "day view" );
views->addWidget( dayView, DAY );
- dayView->setStartViewTime( startTime );
dayView->setJumpToCurTime( bJumpToCurTime );
+ dayView->setStartViewTime( startTime );
dayView->setRowStyle( rowStyle );
connect( this, SIGNAL( newEvent() ), dayView, SLOT( redraw() ) );
connect( dayView, SIGNAL( newEvent() ), this, SLOT( fileNew() ) );
connect( dayView, SIGNAL( removeEvent( const Event & ) ), this, SLOT( removeEvent( const Event & ) ) );
connect( dayView, SIGNAL( editEvent( const Event & ) ), this, SLOT( editEvent( const Event & ) ) );
connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), this, SLOT( duplicateEvent( const Event & ) ) );
connect( dayView, SIGNAL( beamEvent( const Event & ) ), this, SLOT( beamEvent( const Event & ) ) );
connect( dayView, SIGNAL(sigNewEvent(const QString &)), this, SLOT(slotNewEventFromKey(const QString &)) );
}
}
void DateBook::initWeek()
{
if ( !weekView ) {
weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" );
weekView->setStartViewTime( startTime );
views->addWidget( weekView, WEEK );
connect( weekView, SIGNAL( showDate( int, int, int ) ), this, SLOT( showDay( int, int, int ) ) );
connect( this, SIGNAL( newEvent() ), weekView, SLOT( redraw() ) );
}
//But also get it right: the year that we display can be different
//from the year of the current date. So, first find the year
//number of the current week.
@@ -676,74 +690,90 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data)
alarmCounter = 0;
stopTimer = startTimer( 5000 );
}
QDialog dlg( this, 0, TRUE );
QVBoxLayout *vb = new QVBoxLayout( &dlg );
QScrollView *view = new QScrollView( &dlg, "scrollView");
view->setResizePolicy( QScrollView::AutoOneFit );
vb->addWidget( view );
QLabel *lblMsg = new QLabel( msg, &dlg );
view->addChild( lblMsg );
QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
vb->addWidget( cmdOk );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
dlg.showMaximized();
#endif
needShow = dlg.exec();
if ( bSound )
killTimer( stopTimer );
}
}
} else if ( msg == "nextView()" ) {
+ needShow = true;
if ( !qApp-> activeWindow ( )) {
needShow = TRUE;
} else {
QWidget* cur = views->visibleWidget();
if ( cur ) {
if ( cur == dayView )
viewWeek();
else if ( cur == weekView )
viewWeekLst();
else if ( cur == weekLstView )
viewMonth();
else if ( cur == monthView )
viewDay();
needShow = TRUE;
}
}
+ } else if (msg == "editEvent(int)") {
+ /* simple copy from receive */
+ QDataStream stream(data,IO_ReadOnly);
+ int uid;
+ stream >> uid;
+ Event e=db->eventByUID(uid);
+ editEvent(e);
+ } else if (msg == "viewDefault(QDate)"){
+ /* simple copy from receive */
+ QDataStream stream(data,IO_ReadOnly);
+ QDate day;
+ stream >> day;
+ viewDefault(day);
+ needShow = true;
}
+
if ( needShow ) {
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
- showMaximized();
+// showMaximized();
#else
- show();
+// show();
#endif
- raise();
+// raise();
QPEApplication::setKeepRunning();
- setActiveWindow();
+// setActiveWindow();
}
}
void DateBook::reload()
{
db->reload();
if ( dayAction->isOn() ) viewDay();
else if ( weekAction->isOn() ) viewWeek();
else if ( monthAction->isOn() ) viewMonth();
syncing = FALSE;
}
void DateBook::flush()
{
syncing = TRUE;
db->save();
}
void DateBook::timerEvent( QTimerEvent *e )
{
if ( alarmCounter < 10 ) {
alarmCounter++;
Sound::soundAlarm();
} else {
@@ -896,49 +926,49 @@ void DateBook::setDocument( const QString &filename )
static const char * beamfile = "/tmp/obex/event.vcs";
void DateBook::beamEvent( const Event &e )
{
qDebug("trying to beamn");
unlink( beamfile ); // delete if exists
mkdir("/tmp/obex/", 0755);
Event::writeVCalendar( beamfile, e );
Ir *ir = new Ir( this );
connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
QString description = e.description();
ir->send( beamfile, description, "text/x-vCalendar" );
}
void DateBook::beamDone( Ir *ir )
{
delete ir;
unlink( beamfile );
}
void DateBook::slotFind()
{
// move it to the day view...
viewDay();
- FindDialog frmFind( "Calendar", this );
+ FindDialog frmFind( "Calendar", this ); // no tr needed
frmFind.setUseDate( true );
frmFind.setDate( currentDate() );
QObject::connect( &frmFind,
SIGNAL(signalFindClicked(const QString&, const QDate&,
bool, bool, int)),
this,
SLOT(slotDoFind(const QString&, const QDate&,
bool, bool, int)) );
QObject::connect( this,
SIGNAL(signalNotFound()),
&frmFind,
SLOT(slotNotFound()) );
QObject::connect( this,
SIGNAL(signalWrapAround()),
&frmFind,
SLOT(slotWrapAround()) );
frmFind.move(0,0);
frmFind.exec();
inSearch = false;
}
bool catComp( QArray<int> cats, int category )
{
bool returnMe;
diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro
index e8e0a98..ae30c8d 100644
--- a/core/pim/datebook/datebook.pro
+++ b/core/pim/datebook/datebook.pro
@@ -1,50 +1,52 @@
TEMPLATE = app
CONFIG += qt warn_on release
DESTDIR = $(OPIEDIR)/bin
HEADERS = datebookday.h \
datebook.h \
dateentryimpl.h \
datebookdayheaderimpl.h \
datebooksettings.h \
datebookweek.h \
datebookweeklst.h \
datebookweekheaderimpl.h \
repeatentry.h \
noteentryimpl.h \
- onoteedit.h
+ onoteedit.h \
+ datebookdayallday.h
SOURCES = main.cpp \
datebookday.cpp \
datebook.cpp \
dateentryimpl.cpp \
datebookdayheaderimpl.cpp \
datebooksettings.cpp \
datebookweek.cpp \
datebookweeklst.cpp \
datebookweekheaderimpl.cpp \
repeatentry.cpp \
noteentryimpl.cpp \
- onoteedit.cpp
+ onoteedit.cpp \
+ datebookdayallday.cpp
INTERFACES = dateentry.ui \
datebookdayheader.ui \
datebookweekheader.ui \
datebookweeklstheader.ui \
datebookweeklstdayhdr.ui \
repeatentrybase.ui \
datebooksettingsbase.ui \
noteentry.ui
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie
TARGET = datebook
TRANSLATIONS = ../../../i18n/de/datebook.ts \
../../../i18n/nl/datebook.ts \
../../../i18n/xx/datebook.ts \
../../../i18n/en/datebook.ts \
../../../i18n/es/datebook.ts \
../../../i18n/fr/datebook.ts \
../../../i18n/hu/datebook.ts \
../../../i18n/ja/datebook.ts \
../../../i18n/ko/datebook.ts \
../../../i18n/no/datebook.ts \
../../../i18n/pl/datebook.ts \
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index 0b213e9..f4008e9 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -1,47 +1,48 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <qmessagebox.h>
#include "datebookday.h"
#include "datebookdayheaderimpl.h"
+#include "datebookdayallday.h"
#include <qpe/datebookdb.h>
#include <qpe/resource.h>
#include <qpe/event.h>
#include <qpe/qpeapplication.h>
#include <qpe/timestring.h>
#include <qpe/qpedebug.h>
#include <qpe/ir.h>
#include <qheader.h>
#include <qdatetime.h>
#include <qpainter.h>
#include <qsimplerichtext.h>
#include <qpopupmenu.h>
#include <qtextcodec.h>
#include <qpalette.h>
#include <qlineedit.h>
#include <qtimer.h>
DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name )
: QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() )
{
@@ -190,82 +191,91 @@ void DateBookDayView::contentsMouseReleaseEvent( QMouseEvent *e )
quickLineEdit->setGeometry(0,0,this->columnWidth(0)-1,this->rowHeight(0));
this->moveChild(quickLineEdit,0,sh*this->rowHeight(0));
quickLineEdit->setFocus();
quickLineEdit->show();
}
//===========================================================================
DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name) : QLineEdit(parent,name)
{
active=1;
quickEvent.setStart(start);
quickEvent.setEnd(end);
connect(this,SIGNAL(returnPressed()),this,SLOT(slotReturnPressed()));
}
void DateBookDayViewQuickLineEdit::slotReturnPressed()
{
if(active && (!this->text().isEmpty())) { // Fix to avoid having this event beeing added multiple times.
quickEvent.setDescription(this->text());
connect(this,SIGNAL(insertEvent(const Event &)),this->topLevelWidget(),SLOT(insertEvent(const Event &)));
emit(insertEvent(quickEvent));
active=0;
}
- this->close(true); // Close and also delete this widget
+ /* we need to return to this object.. */
+ QTimer::singleShot(500, this, SLOT(finallyCallClose()) ); // Close and also delete this widget
+}
+void DateBookDayViewQuickLineEdit::finallyCallClose() {
+ close(true); // also deletes this widget...
}
void DateBookDayViewQuickLineEdit::focusOutEvent ( QFocusEvent * e )
{
slotReturnPressed(); // Reuse code to add event and close this widget.
}
//===========================================================================
DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb, QWidget *parent, const char *name )
: QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 )
{
widgetList.setAutoDelete( true );
header = new DateBookDayHeader( startOnMonday, this, "day header" );
header->setDate( currDate.year(), currDate.month(), currDate.day() );
+
+ m_allDays = new DatebookdayAllday(newDb, this, "all day event list" );
+ m_allDays->hide();
+
view = new DateBookDayView( ampm, this, "day view" );
connect( header, SIGNAL( dateChanged( int, int, int ) ), this, SLOT( dateChanged( int, int, int ) ) );
connect( header, SIGNAL( dateChanged( int, int, int ) ), view, SLOT( slotDateChanged( int, int, int ) ) );
connect( view, SIGNAL( sigColWidthChanged() ), this, SLOT( slotColWidthChanged() ) );
connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
connect( view, SIGNAL(sigCapturedKey(const QString &)), this, SIGNAL(sigNewEvent(const QString&)) );
QTimer *timer = new QTimer( this );
connect( timer, SIGNAL(timeout()), this, SLOT(updateView()) ); //connect timer for updating timeMarker & daywidgetcolors
timer->start( 1000*60*5, FALSE ); //update every 5min
selectedWidget = 0;
timeMarker = new DateBookDayTimeMarker( this );
timeMarker->setTime( QTime::currentTime() );
rowStyle = -1; // initialize with bogus values
+ jumpToCurTime = false;
}
void DateBookDay::setJumpToCurTime( bool bJump )
{
jumpToCurTime = bJump;
}
void DateBookDay::setRowStyle( int style )
{
if (rowStyle != style) view->setRowStyle( style );
rowStyle = style;
}
void DateBookDay::updateView( void )
{
timeMarker->setTime( QTime::currentTime() );
//need to find a way to update all DateBookDayWidgets
}
void DateBookDay::setSelectedWidget( DateBookDayWidget *w )
{
selectedWidget = w;
}
@@ -322,104 +332,125 @@ void DateBookDay::dateChanged( int y, int m, int d )
if (jumpToCurTime && this->date() == QDate::currentDate())
{
ts.init( QTime::currentTime().hour(), 0);
ts.expandTo( QTime::currentTime().hour(), 0);
} else {
ts.init( startTime, 0 );
ts.expandTo( startTime, 0 );
}
dayView()->addSelection( ts );
selectedWidget = 0;
}
void DateBookDay::redraw()
{
if ( isUpdatesEnabled() )
relayoutPage();
}
void DateBookDay::getEvents()
{
widgetList.clear();
+ /* clear the AllDay List */
+ m_allDays->hide(); // just in case
+ m_allDays->removeAllEvents();
+
QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate );
QValueListIterator<EffectiveEvent> it;
+ QObject* object = 0;
for ( it = eventList.begin(); it != eventList.end(); ++it ) {
EffectiveEvent ev=*it;
if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) { // Skip events ending at 00:00 starting at another day.
+ if (ev.event().type() == Event::AllDay ) {
+ object = m_allDays->addEvent( ev );
+ if (!object)
+ continue;
+ }else {
DateBookDayWidget* w = new DateBookDayWidget( *it, this );
- connect( w, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) );
- connect( w, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) );
- connect( w, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) );
- connect( w, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) );
widgetList.append( w );
+ object = w;
+ }
+
+ connect( object, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) );
+ connect( object, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) );
+ connect( object, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) );
+ connect( object, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) );
+
}
}
}
static int place( const DateBookDayWidget *item, bool *used, int maxn )
{
int place = 0;
int start = item->event().start().hour();
QTime e = item->event().end();
int end = e.hour();
if ( e.minute() < 5 )
end--;
if ( end < start )
end = start;
while ( place < maxn ) {
bool free = TRUE;
int s = start;
while( s <= end ) {
if ( used[10*s+place] ) {
free = FALSE;
break;
}
s++;
}
if ( free )
break;
place++;
}
if ( place == maxn ) {
return -1;
}
while( start <= end ) {
used[10*start+place] = TRUE;
start++;
}
return place;
}
void DateBookDay::relayoutPage( bool fromResize )
{
setUpdatesEnabled( FALSE );
- if ( !fromResize )
+ if ( !fromResize ) {
getEvents(); // no need we already have them!
+ if (m_allDays->items() > 0 )
+ m_allDays->show();
+ /*
+ * else if ( m_allDays->items() == 0 ) already hide in getEvents
+ */
+ }
+
widgetList.sort();
//sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning
//this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view
int wCount = widgetList.count();
int wid = view->columnWidth(0)-1;
int wd;
int n = 1;
QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget
for (int i = 0; i<wCount; anzIntersect[i] = 1, i++);
if ( wCount < 20 ) {
QArray<QRect> geometries(wCount);
for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++); //stores geometry for each widget in vector
for ( int i = 0; i < wCount; i++) {
QValueList<int> intersectedWidgets;
//find all widgets intersecting with widgetList.at(i)
for ( int j = 0; j < wCount; j++) {
if (i != j)
@@ -709,74 +740,154 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e )
p.drawRect(rect());
// p.drawRect(0,0, 5, height());
int y = 0;
int d = 0;
if ( ev.event().hasAlarm() ) {
p.drawPixmap( width() - 16, 0, Resource::loadPixmap( "bell" ) );
y = 20;
d = 20;
}
if ( ev.event().hasRepeat() ) {
p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) );
d = 20;
y += 20;
}
QSimpleRichText rt( text, font() );
rt.setWidth( geom.width() - d - 6 );
rt.draw( &p, 7, 0, e->region(), colorGroup() );
}
+/*
+ * we need to find the real start date for a uid
+ * we need to check from one day to another...
+ */
+QDate DateBookDay::findRealStart( int uid, const QDate& isIncluded , DateBookDB* db) {
+ QDate dt( isIncluded );
+ QDate fnd = dt;
+
+ bool doAgain = true;
+ do{
+ dt = dt.addDays( -1 );
+ QValueList<EffectiveEvent> events = db->getEffectiveEvents( dt, dt );
+ for (QValueList<EffectiveEvent>::Iterator it = events.begin(); it != events.end(); ++it ) {
+ EffectiveEvent ev = (*it);
+ if ( uid == ev.event().uid() && ev.start() != QTime(0, 0, 0 ) )
+ return ev.date();
+ }
+ }while (doAgain );
+
+ return fnd;
+}
+
void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
{
DateBookDayWidget *item;
item = dateBook->getSelectedWidget();
if (item)
item->update();
dateBook->setSelectedWidget(this);
update();
dateBook->repaint();
QPopupMenu m;
m.insertItem( tr( "Edit" ), 1 );
m.insertItem( tr( "Duplicate" ), 4 );
m.insertItem( tr( "Delete" ), 2 );
if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 );
+ if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 );
int r = m.exec( e->globalPos() );
if ( r == 1 ) {
emit editMe( ev.event() );
} else if ( r == 2 ) {
emit deleteMe( ev.event() );
} else if ( r == 3 ) {
emit beamMe( ev.event() );
} else if ( r == 4 ) {
emit duplicateMe( ev.event() );
+ } else if ( r == 5 ) {
+ // create an Event and beam it...
+ /*
+ * Start with the easy stuff. If start and end date is the same we can just use
+ * the values of effective events
+ * If it is a multi day event we need to find the real start and end date...
+ */
+ if ( ev.event().start().date() == ev.event().end().date() ) {
+ Event event( ev.event() );
+
+ QDateTime dt( ev.date(), ev.start() );
+ event.setStart( dt );
+
+ dt.setTime( ev.end() );
+ event.setEnd( dt );
+ emit beamMe( event );
+ }else {
+ /*
+ * at least the the Times are right now
+ */
+ QDateTime start( ev.event().start() );
+ QDateTime end ( ev.event().end () );
+
+
+ /*
+ * ok we know the start date or we need to find it
+ */
+ if ( ev.start() != QTime( 0, 0, 0 ) ) {
+ start.setDate( ev.date() );
+ }else {
+ QDate dt = DateBookDay::findRealStart( ev.event().uid(), ev.date(), dateBook->db );
+ start.setDate( dt );
+ }
+
+
+ /*
+ * ok we know now the end date...
+ * else
+ * get to know the offset btw the real start and real end
+ * and then add it to the new start date...
+ */
+ if ( ev.end() != QTime(23, 59, 59 ) ) {
+ end.setDate( ev.date() );
+ }else{
+ int days = ev.event().start().date().daysTo( ev.event().end().date() );
+ end.setDate( start.date().addDays( days ) );
+ }
+
+
+
+ Event event( ev.event() );
+ event.setStart( start );
+ event.setEnd ( end );
+
+
+ emit beamMe( event );
+ }
}
}
void DateBookDayWidget::setGeometry( const QRect &r )
{
geom = r;
setFixedSize( r.width()+1, r.height()+1 );
dateBook->dayView()->moveChild( this, r.x(), r.y()-1 );
show();
}
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
DateBookDayTimeMarker::DateBookDayTimeMarker( DateBookDay *db )
: QWidget( db->dayView()->viewport() ), dateBook( db )
{
setBackgroundMode( PaletteBase );
}
DateBookDayTimeMarker::~DateBookDayTimeMarker()
{
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h
index 961f60f..3898cbc 100644
--- a/core/pim/datebook/datebookday.h
+++ b/core/pim/datebook/datebookday.h
@@ -11,64 +11,66 @@
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DATEBOOKDAY_H
#define DATEBOOKDAY_H
#include <qpe/event.h>
#include <qdatetime.h>
#include <qtable.h>
#include <qvbox.h>
#include <qlist.h>
#include "datebook.h"
#include <qlineedit.h>
class DateBookDayHeader;
class DateBookDB;
+class DatebookdayAllday;
class QDateTime;
class QMouseEvent;
class QPaintEvent;
class QResizeEvent;
class DateBookDayViewQuickLineEdit : public QLineEdit
{
Q_OBJECT
public:
DateBookDayViewQuickLineEdit(const QDateTime &start, const QDateTime &end,QWidget * parent, const char *name=0);
protected:
Event quickEvent;
int active;
void focusOutEvent( QFocusEvent *e );
protected slots:
void slotReturnPressed(void);
+ void finallyCallClose();
signals:
void insertEvent(const Event &e);
};
class DateBookDayView : public QTable
{
Q_OBJECT
public:
DateBookDayView( bool hourClock, QWidget *parent, const char *name );
bool whichClock() const;
void setRowStyle( int style );
public slots:
void moveUp();
void moveDown();
void slotDateChanged( int year, int month, int day );
signals:
void sigColWidthChanged();
void sigCapturedKey( const QString &txt );
protected slots:
void slotChangeClock( bool );
@@ -155,76 +157,80 @@ private:
//reimplemented the compareItems function so that it sorts DayWidgets by geometry heights
class WidgetListClass : public QList<DateBookDayWidget>
{
private:
int compareItems( QCollection::Item s1, QCollection::Item s2 )
{
//hmm, don't punish me for that ;)
if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height())
{
return -1;
} else
{
return 1;
}
}
};
class DateBookDay : public QVBox
{
Q_OBJECT
+ friend class DateBookDayWidget; // for beam this occurence and access to DateBookDB
public:
DateBookDay( bool ampm, bool startOnMonday, DateBookDB *newDb,
QWidget *parent, const char *name );
void selectedDates( QDateTime &start, QDateTime &end );
QDate date() const;
DateBookDayView *dayView() const { return view; }
void setStartViewTime( int startHere );
int startViewTime() const;
void setSelectedWidget( DateBookDayWidget * );
DateBookDayWidget * getSelectedWidget( void );
void setJumpToCurTime( bool bJump );
void setRowStyle( int style );
+ static QDate findRealStart( int uid, const QDate& isIncluded,
+ DateBookDB* );
public slots:
void setDate( int y, int m, int d );
void setDate( QDate );
void redraw();
void slotWeekChanged( bool bStartOnMonday );
void updateView(); //updates TimeMarker and DayWidget-colors
signals:
void removeEvent( const Event& );
void editEvent( const Event& );
void duplicateEvent( const Event& );
void beamEvent( const Event& );
void newEvent();
void sigNewEvent( const QString & );
protected slots:
void keyPressEvent(QKeyEvent *);
private slots:
void dateChanged( int y, int m, int d );
void slotColWidthChanged() { relayoutPage(); };
private:
void getEvents();
void relayoutPage( bool fromResize = false );
DateBookDayWidget *intersects( const DateBookDayWidget *item, const QRect &geom );
QDate currDate;
DateBookDayView *view;
DateBookDayHeader *header;
+ DatebookdayAllday *m_allDays;
DateBookDB *db;
WidgetListClass widgetList; //reimplemented QList for sorting widgets by height
int startTime;
bool jumpToCurTime; //should we jump to current time in dayview?
int rowStyle;
DateBookDayWidget *selectedWidget; //actual selected widget (obviously)
DateBookDayTimeMarker *timeMarker; //marker for current time
};
#endif
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp
new file mode 100644
index 0000000..985f31a
--- a/dev/null
+++ b/core/pim/datebook/datebookdayallday.cpp
@@ -0,0 +1,226 @@
+/****************************************************************************
+** GPL by Rajko Albrecht
+**
+**
+**
+**
+**
+****************************************************************************/
+#include "datebookdayallday.h"
+
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qvariant.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qobjectlist.h>
+#include <qpe/event.h>
+#include <qpe/ir.h>
+#include <qpe/datebookdb.h>
+#include <qpe/resource.h>
+#include <qpopupmenu.h>
+#include <qtimer.h>
+#include <qregexp.h>
+#include <qdatetime.h>
+
+#include "datebookday.h"
+
+/*
+ * Constructs a DatebookdayAllday which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
+ */
+DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name,fl ),item_count(0),dateBook(db)
+{
+ if ( !name )
+ setName( "DatebookdayAllday" );
+ setMinimumSize( QSize( 0, 0 ) );
+
+ datebookdayalldayLayout = new QVBoxLayout( this );
+ datebookdayalldayLayout->setSpacing( 0 );
+ datebookdayalldayLayout->setMargin( 0 );
+
+ lblDesc = new DatebookEventDesc(parent->parentWidget(),"");
+ lblDesc->setBackgroundColor(Qt::yellow);
+ lblDesc->hide();
+ subWidgets.setAutoDelete(true);
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+DatebookdayAllday::~DatebookdayAllday()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev)
+{
+ DatebookAlldayDisp * lb;
+ lb = new DatebookAlldayDisp(dateBook,ev,this,NULL);
+ datebookdayalldayLayout->addWidget(lb);
+ subWidgets.append(lb);
+
+ connect(lb,SIGNAL(displayMe(const Event &)),lblDesc,SLOT(disp_event(const Event&)));
+ ++item_count;
+
+ return lb;
+}
+
+void DatebookdayAllday::removeAllEvents()
+{
+ subWidgets.clear();
+ item_count = 0;
+}
+
+DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev,
+ QWidget* parent,const char* name,WFlags f)
+ : QLabel(parent,name,f),m_Ev(ev),dateBook(db)
+{
+ QString strDesc = m_Ev.description();
+ strDesc = strDesc.replace(QRegExp("<"),"&#60;");
+ setBackgroundColor(yellow);
+ setText(strDesc);
+ setFrameStyle(QFrame::Raised|QFrame::Panel);
+ QSize s = sizeHint();
+ setMaximumSize( QSize( 32767, s.height()-4 ) );
+ setMinimumSize( QSize( 0, s.height()-4 ) );
+}
+
+DatebookAlldayDisp::~DatebookAlldayDisp()
+{
+}
+
+void DatebookAlldayDisp::beam_single_event()
+{
+ // create an Event and beam it...
+ /*
+ * Start with the easy stuff. If start and end date is the same we can just use
+ * the values of effective m_Events
+ * If it is a multi day m_Event we need to find the real start and end date...
+ */
+ if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) {
+ Event m_Event( m_Ev.event() );
+
+ QDateTime dt( m_Ev.date(), m_Ev.start() );
+ m_Event.setStart( dt );
+
+ dt.setTime( m_Ev.end() );
+ m_Event.setEnd( dt );
+ emit beamMe( m_Event );
+ }else {
+ /*
+ * at least the the Times are right now
+ */
+ QDateTime start( m_Ev.event().start() );
+ QDateTime end ( m_Ev.event().end () );
+
+ /*
+ * ok we know the start date or we need to find it
+ */
+ if ( m_Ev.start() != QTime( 0, 0, 0 ) ) {
+ start.setDate( m_Ev.date() );
+ }else {
+ QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook );
+ start.setDate( dt );
+ }
+
+ /*
+ * ok we know now the end date...
+ * else
+ * get to know the offset btw the real start and real end
+ * and then add it to the new start date...
+ */
+ if ( m_Ev.end() != QTime(23, 59, 59 ) ) {
+ end.setDate( m_Ev.date() );
+ }else{
+ int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() );
+ end.setDate( start.date().addDays( days ) );
+ }
+ Event m_Event( m_Ev.event() );
+ m_Event.setStart( start );
+ m_Event.setEnd ( end );
+ emit beamMe( m_Event );
+ }
+}
+
+void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e)
+{
+ QColor b = backgroundColor();
+ setBackgroundColor(green);
+ update();
+ QPopupMenu m;
+ m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 );
+ m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 );
+ m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 );
+ if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 );
+ if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 );
+ m.insertItem( tr( "Info"),6);
+ int r = m.exec( e->globalPos() );
+ setBackgroundColor(b);
+ update();
+ switch (r) {
+ case 1:
+ emit editMe( m_Ev.event() );
+ break;
+ case 2:
+ emit deleteMe( m_Ev.event() );
+ break;
+ case 3:
+ emit beamMe( m_Ev.event() );
+ break;
+ case 4:
+ emit duplicateMe( m_Ev.event() );
+ break;
+ case 5:
+ beam_single_event();
+ break;
+ case 6:
+ emit displayMe( m_Ev.event() );
+ break;
+ default:
+ break;
+ }
+}
+
+DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name)
+ :QLabel(parent,name)
+{
+ m_Timer=new QTimer(this);
+ connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide()));
+ setFrameStyle(QFrame::Sunken|QFrame::Panel);
+ setTextFormat(RichText);
+}
+
+DatebookEventDesc::~DatebookEventDesc()
+{
+}
+
+void DatebookEventDesc::mousePressEvent(QMouseEvent*)
+{
+ hide();
+ if (m_Timer->isActive()) m_Timer->stop();
+}
+
+void DatebookEventDesc::disp_event(const Event&e)
+{
+ if (m_Timer->isActive()) m_Timer->stop();
+ QString text;
+ text = "<b><i>"+e.description()+"</i></b><br>";
+ if (e.notes().length()>0) {
+ text+="<b>"+e.notes()+"</b><br>";
+ }
+ if (e.location().length()>0) {
+ text+="<i>"+e.location()+"</i><br>";
+ }
+ text = text.replace(QRegExp("\n"),"<br>");
+ setText(text);
+ QSize s = sizeHint();
+ s+=QSize(10,10);
+ resize(s);
+ move( QMAX(0,(parentWidget()->width()-width()) / 2),
+ (parentWidget()->height()-height())/2 );
+ show();
+ m_Timer->start(2000,true);
+}
+
diff --git a/core/pim/datebook/datebookdayallday.h b/core/pim/datebook/datebookdayallday.h
new file mode 100644
index 0000000..c781785
--- a/dev/null
+++ b/core/pim/datebook/datebookdayallday.h
@@ -0,0 +1,80 @@
+#ifndef DATEBOOKDAYALLDAYBASE_H
+#define DATEBOOKDAYALLDAYBASE_H
+
+#include <qvariant.h>
+#include <qframe.h>
+#include <qlabel.h>
+#include <qlist.h>
+#include <qpe/event.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class DatebookAlldayDisp;
+class DatebookEventDesc;
+class DateBookDB;
+
+class DatebookdayAllday : public QWidget
+{
+ Q_OBJECT
+
+public:
+ DatebookdayAllday(DateBookDB* db,
+ QWidget* parent = 0, const char* name = 0, WFlags fl = 0);
+ ~DatebookdayAllday();
+ DatebookAlldayDisp* addEvent(const EffectiveEvent&e);
+ const unsigned int items()const{return item_count;}
+
+public slots:
+ void removeAllEvents();
+
+protected:
+ QVBoxLayout* datebookdayalldayLayout;
+ DatebookEventDesc * lblDesc;
+ unsigned int item_count;
+ QList<DatebookAlldayDisp> subWidgets;
+ DateBookDB *dateBook;
+};
+
+class DatebookAlldayDisp : public QLabel
+{
+ Q_OBJECT
+
+public:
+ DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e,
+ QWidget* parent=0,const char* name = 0, WFlags fl=0);
+ virtual ~DatebookAlldayDisp();
+
+signals:
+ void deleteMe( const Event &e );
+ void duplicateMe( const Event &e );
+ void editMe( const Event &e );
+ void beamMe( const Event &e );
+ void displayMe(const Event &e);
+
+public slots:
+
+protected:
+ EffectiveEvent m_Ev;
+ DateBookDB* dateBook;
+ void mousePressEvent( QMouseEvent *e );
+ void beam_single_event();
+};
+
+class DatebookEventDesc: public QLabel
+{
+ Q_OBJECT
+
+public:
+ DatebookEventDesc(QWidget* Parent=0,const char* name = 0);
+ virtual ~DatebookEventDesc();
+
+public slots:
+ void disp_event(const Event&e);
+
+protected:
+ void mousePressEvent(QMouseEvent*e);
+ QTimer* m_Timer;
+};
+
+#endif // DATEBOOKDAYALLDAYBASE_H
diff --git a/core/pim/datebook/datebooksettings.h b/core/pim/datebook/datebooksettings.h
index c3036e1..cf8a0ff 100644
--- a/core/pim/datebook/datebooksettings.h
+++ b/core/pim/datebook/datebooksettings.h
@@ -4,48 +4,49 @@
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef DATEBOOKSETTINGS_H
#define DATEBOOKSETTINGS_H
#include "datebooksettingsbase.h"
#include <qpe/categoryselect.h>
class DateBookSettings : public DateBookSettingsBase
{
+ Q_OBJECT
public:
DateBookSettings( bool whichClock, QWidget *parent = 0,
const char *name = 0, bool modal = TRUE, WFlags = 0 );
~DateBookSettings();
void setStartTime( int newStartViewTime );
int startTime() const;
void setAlarmPreset( bool bAlarm, int presetTime );
bool alarmPreset() const;
int presetTime() const;
void setAlarmType( int alarmType );
int alarmType() const;
void setJumpToCurTime( bool bJump );
bool jumpToCurTime() const;
void setRowStyle( int style );
int rowStyle() const;
private slots:
void slot12Hour( int );
void slotChangeClock( bool );
private:
void init();
bool ampm;
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index 2ad7aa9..ab7e963 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -1,61 +1,54 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "datebookweek.h"
#include "datebookweekheaderimpl.h"
-#include <qpe/calendar.h>
#include <qpe/datebookdb.h>
-#include <qpe/event.h>
#include <qpe/qpeapplication.h>
-#include <qpe/timestring.h>
+#include <qpe/calendar.h>
-#include <qdatetime.h>
#include <qheader.h>
#include <qlabel.h>
#include <qlayout.h>
-#include <qpainter.h>
-#include <qpopupmenu.h>
#include <qtimer.h>
-#include <qspinbox.h>
-#include <qstyle.h>
//-----------------------------------------------------------------
DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e )
: ev( e )
{
// with the current implementation change the color for all day events
if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) {
c = Qt::green;
} else {
c = ev.event().hasAlarm() ? Qt::red : Qt::blue;
}
}
void DateBookWeekItem::setGeometry( int x, int y, int w, int h )
{
r.setRect( x, y, w, h );
}
//------------------=---------------------------------------------
DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday,
@@ -68,86 +61,79 @@ DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday,
viewport()->setBackgroundMode( PaletteBase );
header = new QHeader( this );
header->addLabel( "" );
header->setMovingEnabled( false );
header->setResizeEnabled( false );
header->setClickEnabled( false, 0 );
initNames();
connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) );
QObject::connect(qApp, SIGNAL(clockChanged(bool)),
this, SLOT(slotChangeClock(bool)));
QFontMetrics fm( font() );
rowHeight = fm.height()+2;
resizeContents( width(), 24*rowHeight );
}
void DateBookWeekView::initNames()
{
+#warning Please review this ! (eilers)
+
+ // Ok, I am Mr. Pedantic, but shouldn't we count until 6 instead of 7, if bOnMonday is false ? (eilers)
+
static bool bFirst = true;
if ( bFirst ) {
if ( bOnMonday ) {
- header->addLabel( tr("Mo", "Monday" ) );
- header->addLabel( tr("Tu", "Tuesday") );
- header->addLabel( tr("We", "Wednesday" ) );
- header->addLabel( tr("Th", "Thursday" ) );
- header->addLabel( tr("Fr", "Friday" ) );
- header->addLabel( tr("Sa", "Saturday" ) );
- header->addLabel( tr("Su", "Sunday" ) );
+ for ( int i = 1; i<=7; i++ ) {
+ header->addLabel( Calendar::nameOfDay( i ) );
+ }
+
} else {
- header->addLabel( tr("Su", "Sunday" ) );
- header->addLabel( tr("Mo", "Monday") );
- header->addLabel( tr("Tu", "Tuesday") );
- header->addLabel( tr("We", "Wednesday" ) );
- header->addLabel( tr("Th", "Thursday" ) );
- header->addLabel( tr("Fr", "Friday" ) );
- header->addLabel( tr("Sa", "Saturday" ) );
+ header->addLabel( Calendar::nameOfDay( 7 ) );
+ for ( int i = 1; i<7; i++ ) {
+ header->addLabel( Calendar::nameOfDay( i ) );
+ }
}
bFirst = false;
} else {
// we are change things...
if ( bOnMonday ) {
- header->setLabel( 1, tr("Mo", "Monday") );
- header->setLabel( 2, tr("Tu", "Tuesday") );
- header->setLabel( 3, tr("We", "Wednesday" ) );
- header->setLabel( 4, tr("Th", "Thursday" ) );
- header->setLabel( 5, tr("Fr", "Friday" ) );
- header->setLabel( 6, tr("Sa", "Saturday" ) );
- header->setLabel( 7, tr("Su", "Sunday" ) );
+ for ( int i = 1; i<=7; i++ ) {
+ header->setLabel( i, Calendar::nameOfDay( i ) );
+ }
+
} else {
- header->setLabel( 1, tr("Su", "Sunday" ) );
- header->setLabel( 2, tr("Mo", "Monday") );
- header->setLabel( 3, tr("Tu", "Tuesday") );
- header->setLabel( 4, tr("We", "Wednesday" ) );
- header->setLabel( 5, tr("Th", "Thursday" ) );
- header->setLabel( 6, tr("Fr", "Friday" ) );
- header->setLabel( 7, tr("Sa", "Saturday" ) );
+ header->setLabel( 1, Calendar::nameOfDay( 7 ) );
+ for ( int i = 1; i<7; i++ ) {
+ header->setLabel( i+1, Calendar::nameOfDay( i ) );
+ }
+
}
}
}
void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev )
{
items.clear();
QValueListIterator<EffectiveEvent> it;
for ( it = ev.begin(); it != ev.end(); ++it ) {
DateBookWeekItem *i = new DateBookWeekItem( *it );
if(!((i->event().end().hour()==0) && (i->event().end().minute()==0) && (i->event().startDate()!=i->event().date()))) { // Skip events ending at 00:00 starting at another day.
positionItem( i );
items.append( i );
}
}
viewport()->update();
}
void DateBookWeekView::moveToHour( int h )
{
int offset = h*rowHeight;
setContentsPos( 0, offset );
@@ -381,49 +367,50 @@ void DateBookWeek::keyPressEvent(QKeyEvent *e)
{
switch(e->key()) {
case Key_Up:
view->scrollBy(0, -20);
break;
case Key_Down:
view->scrollBy(0, 20);
break;
case Key_Left:
setDate(date().addDays(-7));
break;
case Key_Right:
setDate(date().addDays(7));
break;
default:
e->ignore();
}
}
void DateBookWeek::showDay( int day )
{
QDate d=bdate;
// Calculate offset to first day of week.
- int dayoffset=d.dayOfWeek();
+ int dayoffset=d.dayOfWeek() % 7;
+
if(bStartOnMonday) dayoffset--;
day--;
d=d.addDays(day-dayoffset);
emit showDate( d.year(), d.month(), d.day() );
}
void DateBookWeek::setDate( int y, int m, int d )
{
setDate(QDate(y, m, d));
}
void DateBookWeek::setDate(QDate newdate)
{
bdate=newdate;
dow = newdate.dayOfWeek();
header->setDate( newdate );
}
void DateBookWeek::dateChanged( QDate &newdate )
{
bdate=newdate;
getEvents();
}
@@ -554,48 +541,50 @@ void DateBookWeek::slotYearChanged( int y )
}
}
void DateBookWeek::slotWeekChanged( bool onMonday )
{
bStartOnMonday = onMonday;
view->setStartOfWeek( bStartOnMonday );
header->setStartOfWeek( bStartOnMonday );
redraw();
}
void DateBookWeek::slotClockChanged( bool ap )
{
ampm = ap;
}
// return the date at the beginning of the week...
QDate DateBookWeek::weekDate() const
{
QDate d=bdate;
// Calculate offset to first day of week.
int dayoffset=d.dayOfWeek();
if(bStartOnMonday) dayoffset--;
+ else if( dayoffset == 7 )
+ dayoffset = 0;
return d.addDays(-dayoffset);
}
// this used to only be needed by datebook.cpp, but now we need it inside
// week view since
// we need to be able to figure out our total number of weeks on the fly...
// this is probably the best place to put it..
// For Weeks that start on Monday... (EASY!)
// At the moment we will use ISO 8601 method for computing
// the week. Granted, other countries use other methods,
// bet we aren't doing any Locale stuff at the moment. So,
// this should pass. This Algorithim is public domain and
// available at:
// http://personal.ecu.edu/mccartyr/ISOwdALG.txt
// the week number is return, and the year number is returned in year
// for Instance 2001/12/31 is actually the first week in 2002.
// There is a more mathematical definition, but I will implement it when
// we are pass our deadline.
// For Weeks that start on Sunday... (ahh... home rolled)
// okay, if Jan 1 is on Friday or Saturday,
// it will go to the pervious
diff --git a/core/pim/datebook/datebookweekheaderimpl.cpp b/core/pim/datebook/datebookweekheaderimpl.cpp
index ff7626f..770410e 100644
--- a/core/pim/datebook/datebookweekheaderimpl.cpp
+++ b/core/pim/datebook/datebookweekheaderimpl.cpp
@@ -49,67 +49,75 @@ DateBookWeekHeader::DateBookWeekHeader( bool startOnMonday, QWidget* parent, con
*/
DateBookWeekHeader::~DateBookWeekHeader()
{
// no need to delete child widgets, Qt does it all for us
}
void DateBookWeekHeader::pickDate()
{
static QPopupMenu *m1 = 0;
static DateBookMonth *picker = 0;
if ( !m1 ) {
m1 = new QPopupMenu( this );
picker = new DateBookMonth( m1, 0, TRUE );
m1->insertItem( picker );
connect( picker, SIGNAL( dateClicked( int, int, int ) ), this, SLOT( setDate( int, int, int ) ) );
// connect( m1, SIGNAL( aboutToHide() ), this, SLOT( gotHide() ) );
}
picker->setDate( date.year(), date.month(), date.day() );
m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
picker->setFocus();
}
void DateBookWeekHeader::nextMonth()
{
+ qWarning("nextMonth() " );
setDate(date.addDays(28));
}
void DateBookWeekHeader::prevMonth()
{
+ qWarning("prevMonth() " );
setDate(date.addDays(-28));
}
void DateBookWeekHeader::nextWeek()
{
+ qWarning("nextWeek() " );
setDate(date.addDays(7));
}
void DateBookWeekHeader::prevWeek()
{
+ qWarning("prevWeek() ");
setDate(date.addDays(-7));
}
void DateBookWeekHeader::setDate( int y, int m, int d )
{
setDate(QDate(y,m,d));
}
void DateBookWeekHeader::setDate(const QDate &d) {
int year,week,dayofweek;
date=d;
dayofweek=d.dayOfWeek();
- if(bStartOnMonday) dayofweek--;
- date=date.addDays(-dayofweek);
+ if(bStartOnMonday)
+ dayofweek--;
+ else if( dayofweek == 7 )
+ /* we already have the right day -7 would lead to the current week..*/
+ dayofweek = 0;
+ date=date.addDays(-dayofweek);
calcWeek(date,week,year,bStartOnMonday);
QDate start=date;
QDate stop=start.addDays(6);
labelDate->setText( QString::number(start.day()) + "." +
start.monthName(start.month()) + "-" +
QString::number(stop.day()) + "." +
start.monthName(stop.month()) +" ("+
tr("w")+":"+QString::number( week ) +")");
emit dateChanged(date);
}
void DateBookWeekHeader::setStartOfWeek( bool onMonday )
{
bStartOnMonday = onMonday;
setDate( date );
}
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 7817042..aad1f3a 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -40,49 +40,54 @@ DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const ch
forwardmonth->setPixmap( Resource::loadPixmap("fastforward") );
backweek->setBackgroundMode( PaletteButton );
backweek->setPixmap( Resource::loadPixmap("back") );
backmonth->setBackgroundMode( PaletteButton );
backmonth->setPixmap( Resource::loadPixmap("fastback") );
DateBookWeekLstHeaderBaseLayout->setSpacing(0);
DateBookWeekLstHeaderBaseLayout->setMargin(0);
//setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
connect(backmonth, SIGNAL(clicked()), this, SLOT(prevMonth()));
connect(backweek, SIGNAL(clicked()), this, SLOT(prevWeek()));
connect(forwardweek, SIGNAL(clicked()), this, SLOT(nextWeek()));
connect(forwardmonth, SIGNAL(clicked()), this, SLOT(nextMonth()));
connect(labelDate, SIGNAL(clicked()), this, SLOT(pickDate()));
connect(dbl, SIGNAL(toggled(bool)), this, SIGNAL(setDbl(bool)));
bStartOnMonday=onM;
}
DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
void DateBookWeekLstHeader::setDate(const QDate &d) {
int year,week,dayofweek;
date=d;
dayofweek=d.dayOfWeek();
- if(bStartOnMonday) dayofweek--;
+ if(bStartOnMonday)
+ dayofweek--;
+ else if( dayofweek == 7 )
+ /* we already have the right day -7 would lead to the same week */
+ dayofweek = 0;
+
date=date.addDays(-dayofweek);
calcWeek(date,week,year,bStartOnMonday);
QDate start=date;
QDate stop=start.addDays(6);
labelDate->setText( QString::number(start.day()) + "." +
start.monthName(start.month()) + "-" +
QString::number(stop.day()) + "." +
start.monthName(stop.month()) +" ("+
tr("w")+":"+QString::number( week ) +")");
emit dateChanged(date);
}
void DateBookWeekLstHeader::pickDate() {
static QPopupMenu *m1 = 0;
static DateBookMonth *picker = 0;
if ( !m1 ) {
m1 = new QPopupMenu( this );
picker = new DateBookMonth( m1, 0, TRUE );
m1->insertItem( picker );
connect( picker, SIGNAL( dateClicked( int, int, int ) ),this, SLOT( setDate( int, int, int ) ) );
//connect( m1, SIGNAL( aboutToHide() ),
//this, SLOT( gotHide() ) );
}
@@ -96,49 +101,49 @@ void DateBookWeekLstHeader::setDate(int y, int m, int d) {
void DateBookWeekLstHeader::nextWeek() {
setDate(date.addDays(7));
}
void DateBookWeekLstHeader::prevWeek() {
setDate(date.addDays(-7));
}
void DateBookWeekLstHeader::nextMonth()
{
setDate(date.addDays(28));
}
void DateBookWeekLstHeader::prevMonth()
{
setDate(date.addDays(-28));
}
DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
QWidget* parent,
const char* name,
WFlags fl )
: DateBookWeekLstDayHdrBase(parent, name, fl) {
date=d;
- static const char *wdays={"MTWTFSSM"};
+ static const QString wdays=tr("MTWTFSSM", "Week days");
char day=wdays[d.dayOfWeek()-1];
label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
add->setText("+");
if (d == QDate::currentDate()) {
QPalette pal=label->palette();
pal.setColor(QColorGroup::Foreground, QColor(0,0,255));
label->setPalette(pal);
/*
QFont f=label->font();
f.setItalic(true);
label->setFont(f);
label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor()));
*/
} else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday
QPalette pal=label->palette();
pal.setColor(QColorGroup::Foreground, QColor(255,0,0));
label->setPalette(pal);
}
connect (label, SIGNAL(clicked()), this, SLOT(showDay()));
connect (add, SIGNAL(clicked()), this, SLOT(newEvent()));
@@ -216,48 +221,49 @@ DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
qDebug("Read weeklistviewconfig: %d",weeklistviewconfig);
bStartOnMonday=onM;
setPalette(white);
setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
QVBoxLayout *layout = new QVBoxLayout( this );
qBubbleSort(ev);
QValueListIterator<EffectiveEvent> it;
it=ev.begin();
int dayOrder[7];
if (bStartOnMonday) {
for (int d=0; d<7; d++) dayOrder[d]=d+1;
} else {
for (int d=0; d<7; d++) dayOrder[d]=d;
dayOrder[0]=7;
}
// Calculate offset to first day of week.
int dayoffset=d.dayOfWeek();
if(bStartOnMonday) dayoffset--;
+ else if( dayoffset == 7 ) dayoffset = 0;
for (int i=0; i<7; i++) {
// Header
DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this);
connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)),
this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)));
layout->addWidget(hdr);
// Events
while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day.
DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this);
layout->addWidget(l);
connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &)));
}
it++;
}
layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
}
}
DateBookWeekLstView::~DateBookWeekLstView(){}
void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index 13d2ce2..d9e5225 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -381,48 +381,50 @@ void DateEntry::typeChanged( const QString &s )
buttonStart->setEnabled( b );
comboStart->setEnabled( b );
comboEnd->setEnabled( b );
}
void DateEntry::slotRepeat()
{
// Work around for compiler Bug..
RepeatEntry *e;
// it is better in my opinion to just grab this from the mother,
// since, this dialog doesn't need to keep track of it...
if ( rp.type != Event::NoRepeat )
e = new RepeatEntry( startWeekOnMonday, rp, startDate, this);
else
e = new RepeatEntry( startWeekOnMonday, startDate, this );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
e->showMaximized();
#endif
if ( e->exec() ) {
rp = e->repeatPattern();
setRepeatLabel();
}
+ // deleting sounds like a nice idea...
+ delete e;
}
void DateEntry::slotChangeStartOfWeek( bool onMonday )
{
startWeekOnMonday = onMonday;
}
Event DateEntry::event()
{
Event ev;
Event::SoundTypeChoice st;
ev.setDescription( comboDescription->currentText() );
ev.setLocation( comboLocation->currentText() );
ev.setCategories( comboCategory->currentCategories() );
ev.setType( checkAllDay->isChecked() ? Event::AllDay : Event::Normal );
if ( startDate > endDate ) {
QDate tmp = endDate;
endDate = startDate;
startDate = tmp;
}
// This is now done in the changed slots
// startTime = parseTime( comboStart->text(), ampm );
//endTime = parseTime( comboEnd->text(), ampm );
diff --git a/core/pim/datebook/opie-datebook.control b/core/pim/datebook/opie-datebook.control
index 1a28448..fe5a086 100644
--- a/core/pim/datebook/opie-datebook.control
+++ b/core/pim/datebook/opie-datebook.control
@@ -1,11 +1,11 @@
Package: opie-datebook
-Files: bin/datebook apps/1Pim/datebook.desktop pics/datebook
+Files: bin/datebook apps/1Pim/datebook.desktop
Priority: optional
Section: opie/applications
Conflicts: qpe-tkccalendar
Maintainer: Warwick Allison <warwick@trolltech.com>
Architecture: arm
-Version: $QPE_VERSION-$SUB_VERSION
-Depends: task-opie-minimal, libopie1
+Depends: task-opie-minimal, libopie1, opie-pics
Description: A datebook/appointment manager
A datebook/appointment manager for the Opie environment.
+Version: $QPE_VERSION$EXTRAVERSION
diff --git a/core/pim/datebook/repeatentry.cpp b/core/pim/datebook/repeatentry.cpp
index 5637c4d..b1a162d 100644
--- a/core/pim/datebook/repeatentry.cpp
+++ b/core/pim/datebook/repeatentry.cpp
@@ -12,89 +12,111 @@
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "repeatentry.h"
#include <qpe/datebookmonth.h>
#include <qpe/qpeapplication.h>
#include <qpe/timestring.h>
#include <qbuttongroup.h>
#include <qlabel.h>
#include <qpopupmenu.h>
#include <qspinbox.h>
#include <qtoolbutton.h>
#include <time.h>
// Global Templates for use in setting up the repeat label...
-const QString strDayTemplate = QObject::tr("Every");
-const QString strYearTemplate = QObject::tr("%1 %2 every ");
-const QString strMonthDateTemplate = QObject::tr("The %1 every ");
-const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every");
-const QString strWeekTemplate = QObject::tr("Every ");
-const QString dayLabel[] = { QObject::tr("Monday"),
- QObject::tr("Tuesday"),
- QObject::tr("Wednesday"),
- QObject::tr("Thursday"),
- QObject::tr("Friday"),
- QObject::tr("Saturday"),
- QObject::tr("Sunday") };
-
+// the problem is these strings get initialized before QPEApplication can install the translator -zecke
+namespace {
+QString strDayTemplate;
+QString strYearTemplate;
+QString strMonthDateTemplate;
+QString strMonthDayTemplate;
+QString strWeekTemplate;
+QString dayLabel[7];
+}
+
+/*
+ * static linkage to not polute the symbol table...
+ * The problem is that const and static linkage are resolved prior to installing a translator
+ * leading to that the above strings are translted but to the original we delay the init of these strings...
+ * -zecke
+ */
+static void fillStrings() {
+ strDayTemplate = QObject::tr("Every");
+ strYearTemplate = QObject::tr("%1 %2 every ");
+ strMonthDateTemplate = QObject::tr("The %1 every ");
+ strMonthDayTemplate = QObject::tr("The %1 %1 of every");
+ strWeekTemplate = QObject::tr("Every ");
+ dayLabel[0] = QObject::tr("Monday");
+ dayLabel[1] = QObject::tr("Tuesday");
+ dayLabel[2] = QObject::tr("Wednesday");
+ dayLabel[3] = QObject::tr("Thursday");
+ dayLabel[4] = QObject::tr("Friday");
+ dayLabel[5] = QObject::tr("Saturday");
+ dayLabel[6] = QObject::tr("Sunday");
+}
static QString numberPlacing( int x ); // return the proper word format for
// x (1st, 2nd, etc)
static int week( const QDate &dt ); // what week in the month is dt?
RepeatEntry::RepeatEntry( bool startOnMonday,
const QDate &newStart, QWidget *parent,
const char *name, bool modal, WFlags fl )
: RepeatEntryBase( parent, name, modal, fl ),
start( newStart ),
currInterval( NONE ),
startWeekOnMonday( startOnMonday )
{
+ if (strDayTemplate.isEmpty() )
+ fillStrings();
+
init();
fraType->setButton( currInterval );
chkNoEnd->setChecked( TRUE );
setupNone();
}
RepeatEntry::RepeatEntry( bool startOnMonday, const Event::RepeatPattern &rp,
const QDate &startDate,
QWidget *parent, const char *name, bool modal,
WFlags fl )
: RepeatEntryBase( parent, name, modal, fl ),
start( startDate ),
end( rp.endDate() ),
startWeekOnMonday( startOnMonday )
{
+ if (strDayTemplate.isEmpty() )
+ fillStrings();
// do some stuff with the repeat pattern
init();
switch ( rp.type ) {
default:
case Event::NoRepeat:
currInterval = NONE;
setupNone();
break;
case Event::Daily:
currInterval = DAY;
setupDaily();
break;
case Event::Weekly:
currInterval = WEEK;
setupWeekly();
int day, buttons;
for ( day = 0x01, buttons = 0; buttons < 7;
day = day << 1, buttons++ ) {
if ( rp.days & day ) {
if ( startWeekOnMonday )
fraExtra->setButton( buttons );
else {
if ( buttons == 7 )
fraExtra->setButton( 0 );
@@ -479,49 +501,49 @@ void RepeatEntry::slotWeekLabel()
QStringList::Iterator itStr;
for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) {
if ( i == 3 )
bNeedCarriage = TRUE;
else
bNeedCarriage = FALSE;
if ( str.isNull() )
str = *itStr;
else if ( i == list.count() - 1 ) {
if ( i < 2 )
str += tr(" and ") + *itStr;
else {
if ( bNeedCarriage )
str += tr( ",\nand " ) + *itStr;
else
str += tr( ", and " ) + *itStr;
}
} else {
if ( bNeedCarriage )
str += ",\n" + *itStr;
else
str += ", " + *itStr;
}
}
- str = str.prepend( "on " );
+ str = str.prepend( tr("on ") );
lblWeekVar->setText( str );
}
void RepeatEntry::slotMonthLabel( int type )
{
QString str;
if ( currInterval != MONTH || type > 1 )
return;
if ( type == 1 )
str = strMonthDateTemplate.arg( numberPlacing(start.day()) );
else
str = strMonthDayTemplate.arg( numberPlacing(week(start)))
.arg( dayLabel[start.dayOfWeek() - 1] );
lblRepeat->setText( str );
}
void RepeatEntry::slotChangeStartOfWeek( bool onMonday )
{
startWeekOnMonday = onMonday;
// we need to make this unintrusive as possible...
int saveSpin = spinFreq->value();
char days = 0;
int day;
QListIterator<QToolButton> itExtra( listExtra );