summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-17 14:01:23 (UTC)
committer alwin <alwin>2005-03-17 14:01:23 (UTC)
commit8752141a5341877369f89a42fa1f0b5d08f56dbd (patch) (side-by-side diff)
tree63dc48ee207a4e9fbb6b9e8abddb239ec724c155
parentafee05f4b4c1e8dab8463e3423fcfc8f9d45aa8b (diff)
downloadopie-8752141a5341877369f89a42fa1f0b5d08f56dbd.zip
opie-8752141a5341877369f89a42fa1f0b5d08f56dbd.tar.gz
opie-8752141a5341877369f89a42fa1f0b5d08f56dbd.tar.bz2
1. datebookweeklist - a week has SEVEN days, not SIX. I'm wondering why
events on sunday never showed there ;) 2. extra file datebooktypes contains some special classes used by datebook so other classes must not include the big mainheader file. 3. added support for holiday-plugins to week-views. Month view is a little bit more tricky 'cause TT has never heard about virtual methods and so I have the choice between complete copy the monthview and make the modifications or changing the interface of datebookdb-class to virtual. both isn't nice.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp45
-rw-r--r--core/pim/datebook/datebook.h37
-rw-r--r--core/pim/datebook/datebookday.cpp5
-rw-r--r--core/pim/datebook/datebookday.h6
-rw-r--r--core/pim/datebook/datebookdayallday.cpp12
-rw-r--r--core/pim/datebook/datebooktypes.h59
-rw-r--r--core/pim/datebook/datebookweek.cpp489
-rw-r--r--core/pim/datebook/datebookweek.h9
-rw-r--r--core/pim/datebook/datebookweeklst.cpp597
-rw-r--r--core/pim/datebook/datebookweeklst.h93
10 files changed, 718 insertions, 634 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index f6aab0c..36c4bd7 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -54,51 +54,52 @@
#include <qdir.h>
#include <qtopia/qlibrary.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
DateBook::DateBook( QWidget *parent, const char *, WFlags f )
: QMainWindow( parent, "datebook", f ),
aPreset( FALSE ),
presetTime( -1 ),
startTime( 8 ), // an acceptable default
rowStyle( 0 ),
bJumpToCurTime(FALSE),
syncing(FALSE),
inSearch(FALSE),
alarmCounter(0)
{
bool needEvilHack= false; // if we need an Evil Hack
QTime t;
t.start();
- db = new DateBookDBHack;
+ db = new DateBookDBHoliday;
odebug << "loading db t=" << t.elapsed() << oendl;
db_holiday = new DateBookHoliday();
+ db->db_holiday=db_holiday;
loadSettings();
setCaption( tr("Calendar") );
setIcon( Resource::loadPixmap( "datebook_icon" ) );
setToolBarsMovable( FALSE );
views = new QWidgetStack( this );
setCentralWidget( views );
dayView = 0;
weekView = 0;
weekLstView = 0;
monthView = 0;
// QToolBar *bar = new QToolBar( this );
// bar->setHorizontalStretchable( TRUE );
// QMenuBar *mb = new QMenuBar( bar );
// mb->setMargin( 0 );
// QPopupMenu *view = new QPopupMenu( this );
// mb->insertItem( tr( "View" ), view );
@@ -1128,24 +1129,66 @@ void DateBookHoliday::init()
} else {
}
} else {
delete lib;
}
}
}
QStringList DateBookHoliday::holidaylist(const QDate&aDate)
{
QStringList ret;
QValueList<HPlugin*>::Iterator it;
for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
HPlugin*_pl = *it;
ret+=_pl->_plugin->entries(aDate);
}
return ret;
}
QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day)
{
return holidaylist(QDate(year,month,day));
}
+QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDate &from,const QDate &to )
+{
+ QValueList<EffectiveEvent> ret;
+ QValueList<HPlugin*>::Iterator it;
+ for (it=_pluginlist.begin();it!=_pluginlist.end();++it) {
+ HPlugin*_pl = *it;
+ ret+=_pl->_plugin->events(from,to);
+ }
+ return ret;
+}
+
+QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDate &from,const QDate &to )
+{
+ return DateBookDBHack::getEffectiveEvents(from,to);
+}
+
+QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDateTime &start)
+{
+ return DateBookDBHack::getEffectiveEvents(start);
+}
+
+QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDateTime &start)
+{
+ return getEffectiveEvents(start.date(),start.date());
+}
+
+QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents(const QDate &from,const QDate &to )
+{
+ QValueList<EffectiveEvent> ret;
+ odebug << "Ueberlagert 1" << oendl;
+ if (db_holiday) {
+ ret+=db_holiday->getEffectiveEvents(from,to);
+ }
+ ret+=getEffectiveEventsNoHoliday(from,to);
+ return ret;
+}
+
+QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents( const QDateTime &start)
+{
+ odebug << "Ueberlagert 2" << oendl;
+ return DateBookDBHack::getEffectiveEvents(start);
+}
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index 54ffcfb..3d7f5b5 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -1,95 +1,64 @@
/**********************************************************************
** 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.
**
**********************************************************************/
#ifndef DATEBOOK_H
#define DATEBOOK_H
+#include "datebooktypes.h"
+
#include <qpe/datebookdb.h>
#include <qmainwindow.h>
enum { DAY=1,WEEK,WEEKLST,MONTH }; // defaultView values
enum { NONE=0,NORMAL,EXTENDED }; // WeekLstView's modes.
class QAction;
class QWidgetStack;
class DateBookDay;
class DateBookWeek;
class DateBookWeekLst;
class DateBookMonth;
class Event;
class QDate;
class Ir;
-class QLibrary;
-
-namespace Opie {
-namespace Datebook {
- class HolidayPlugin;
- class HolidayPluginIf;
-}
-}
-
-class DateBookDBHack : public DateBookDB {
- public:
- Event eventByUID(int id);
-};
-
-class DateBookHoliday
-{
-public:
- DateBookHoliday();
- virtual ~DateBookHoliday();
-
- QStringList holidaylist(const QDate&);
- QStringList holidaylist(unsigned year, unsigned month, unsigned day);
-protected:
- void init();
- void deinit();
-
- struct HPlugin {
- Opie::Datebook::HolidayPlugin*_plugin;
- QLibrary*_lib;
- Opie::Datebook::HolidayPluginIf*_if;
- };
- QValueList<HPlugin*>_pluginlist;
-};
class DateBook : public QMainWindow
{
Q_OBJECT
public:
static QString appName() { return QString::fromLatin1("datebook"); }
DateBook( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~DateBook();
signals:
void newEvent();
void signalNotFound();
void signalWrapAround();
protected:
QDate currentDate();
void timerEvent( QTimerEvent *e );
void closeEvent( QCloseEvent *e );
void view(int v, const QDate &d);
public slots:
void flush();
@@ -116,49 +85,49 @@ private slots:
void viewMonth();
void showDay( int y, int m, int d );
void insertEvent( const Event &e );
void editEvent( const Event &e );
void duplicateEvent( const Event &e );
void removeEvent( const Event &e );
void receive( const QCString &msg, const QByteArray &data );
void setDocument( const QString & );
void beamEvent( const Event &e );
void beamDone( Ir *ir );
private:
void addEvent( const Event &e );
void initDay();
void initWeek();
void initWeekLst();
void initMonth();
void loadSettings();
void saveSettings();
private:
- DateBookDBHack *db;
+ DateBookDBHoliday *db;
DateBookHoliday*db_holiday;
QWidgetStack *views;
DateBookDay *dayView;
DateBookWeek *weekView;
DateBookMonth *monthView;
DateBookWeekLst *weekLstView;
QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
int weeklistviewconfig;
bool aPreset; // have everything set to alarm?
int presetTime; // the standard time for the alarm
int startTime;
int rowStyle;
int defaultView;
QArray<int> defaultCategories;
QString defaultLocation;
bool bJumpToCurTime; //should jump to current time in dayview?
bool ampm;
bool onMonday;
bool syncing;
bool inSearch;
int alarmCounter;
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index dfe39e5..00ddd05 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -1,45 +1,46 @@
/**********************************************************************
** 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 "datebookday.h"
+#include "datebooktypes.h"
#include "datebookdayheaderimpl.h"
#include "datebookdayallday.h"
#include <opie2/oholidayplugin.h>
#include <qpe/resource.h>
#include <qpe/qpeapplication.h>
#include <qpe/ir.h>
#include <qsimplerichtext.h>
#include <qpopupmenu.h>
#include <qtimer.h>
DateBookDayView::DateBookDayView( bool whichClock, QWidget *parent, const char *name )
: QTable( 24, 1, parent, name ), ampm( whichClock ), currDate( QDate::currentDate() )
{
enableClipper(TRUE);
setTopMargin( 0 );
horizontalHeader()->hide();
setLeftMargin(38);
setColumnStretchable( 0, TRUE );
setHScrollBarMode( QScrollView::AlwaysOff );
verticalHeader()->setPalette(white);
@@ -206,49 +207,49 @@ DateBookDayViewQuickLineEdit::DateBookDayViewQuickLineEdit(const QDateTime &star
}
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;
}
/* 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, DateBookHoliday*newHdb, QWidget *parent, const char *name )
+DateBookDay::DateBookDay( bool ampm, bool startOnMonday, DateBookDBHoliday *newDb, DateBookHoliday*newHdb, QWidget *parent, const char *name )
: QVBox( parent, name ), currDate( QDate::currentDate() ), db( newDb ), startTime( 0 )
{
widgetList.setAutoDelete( true );
_holiday_db = newHdb;
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;
@@ -346,49 +347,49 @@ void DateBookDay::dateChanged( int y, int m, int d )
}
void DateBookDay::redraw()
{
if ( isUpdatesEnabled() )
relayoutPage();
}
void DateBookDay::getEvents()
{
widgetList.clear();
/* clear the AllDay List */
m_allDays->hide(); // just in case
m_allDays->removeAllEvents();
QStringList hdays = _holiday_db->holidaylist(currDate);
QStringList::Iterator sit;
QObject* object = 0;
for (sit=hdays.begin();sit!=hdays.end();++sit) {
object = m_allDays->addHoliday(*sit);
if (!object) continue;
/* not to do something with it */
}
- QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate );
+ QValueList<EffectiveEvent> eventList = db->getEffectiveEventsNoHoliday( currDate, currDate );
QValueListIterator<EffectiveEvent> it;
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 );
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&) ) );
}
}
}
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h
index 3e44364..3b75eba 100644
--- a/core/pim/datebook/datebookday.h
+++ b/core/pim/datebook/datebookday.h
@@ -7,52 +7,54 @@
** 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 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 "datebooktypes.h"
#include <qlineedit.h>
class DateBookDayHeader;
class DateBookDB;
+class DateBookDBHoliday;
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
@@ -159,80 +161,80 @@ 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,DateBookHoliday*newHdb,
+ DateBookDay( bool ampm, bool startOnMonday, DateBookDBHoliday *newDb,DateBookHoliday*newHdb,
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;
+ DateBookDBHoliday *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
DateBookHoliday*_holiday_db;
};
#endif
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp
index 3c3f482..5b40246 100644
--- a/core/pim/datebook/datebookdayallday.cpp
+++ b/core/pim/datebook/datebookdayallday.cpp
@@ -9,49 +9,50 @@
#include "datebookdayallday.h"
#include <qlayout.h>
#include <qpe/ir.h>
#include <qpopupmenu.h>
#include <qtimer.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 )
: QScrollView( parent, name ),item_count(0),dateBook(db)
{
if ( !name )
setName( "DatebookdayAllday" );
setMinimumSize( QSize( 0, 0 ) );
setMaximumHeight(3* (QFontMetrics(font()).height()+4) );
m_MainFrame = new QFrame(viewport());
m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain);
setFrameStyle(QFrame::NoFrame|QFrame::Plain);
- setResizePolicy( QScrollView::Default );
+ //setResizePolicy( QScrollView::Default );
+ setResizePolicy(QScrollView::AutoOneFit);
setHScrollBarMode( AlwaysOff );
addChild(m_MainFrame);
datebookdayalldayLayout = new QVBoxLayout( m_MainFrame );
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;
@@ -90,55 +91,60 @@ 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);
int s = QFontMetrics(font()).height()+4;
setMaximumHeight( s );
setMinimumSize( QSize( 0, s ) );
m_holiday = false;
}
DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,const char* name, WFlags fl)
: QLabel(parent,name,fl),m_Ev(),dateBook(0)
{
QString strDesc = aholiday;
strDesc = strDesc.replace(QRegExp("<"),"&#60;");
Event ev;
ev.setDescription(strDesc);
ev.setAllDay(true);
m_Ev.setEvent(ev);
- setBackgroundColor(yellow);
setText(strDesc);
- setFrameStyle(QFrame::Raised|QFrame::Panel);
+
+ setAlignment(AlignHCenter);
+ setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum));
+
+ //setFrameStyle(QFrame::Raised|QFrame::Panel);
+ //setBackgroundColor(yellow);
int s = QFontMetrics(font()).height()+4;
setMaximumHeight( s );
setMinimumSize( QSize( 0, s ) );
+
m_holiday = true;
}
DatebookAlldayDisp::~DatebookAlldayDisp()
{
}
void DatebookAlldayDisp::beam_single_event()
{
if (m_holiday) return;
// 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 );
diff --git a/core/pim/datebook/datebooktypes.h b/core/pim/datebook/datebooktypes.h
new file mode 100644
index 0000000..9eb7e89
--- a/dev/null
+++ b/core/pim/datebook/datebooktypes.h
@@ -0,0 +1,59 @@
+#ifndef _DATEBOOK_TYPES_H
+#define _DATEBOOK_TYPES_H
+
+#include <qpe/datebookdb.h>
+
+#include <qvaluelist.h>
+#include <qstringlist.h>
+
+namespace Opie {
+namespace Datebook {
+ class HolidayPlugin;
+ class HolidayPluginIf;
+}
+}
+
+class QLibrary;
+
+class DateBookDBHack : virtual public DateBookDB {
+ public:
+ virtual ~DateBookDBHack(){}
+ Event eventByUID(int id);
+};
+
+class DateBookHoliday
+{
+public:
+ DateBookHoliday();
+ virtual ~DateBookHoliday();
+
+ QStringList holidaylist(const QDate&);
+ QStringList holidaylist(unsigned year, unsigned month, unsigned day);
+ virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
+ virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
+
+protected:
+ void init();
+ void deinit();
+
+ struct HPlugin {
+ Opie::Datebook::HolidayPlugin*_plugin;
+ QLibrary*_lib;
+ Opie::Datebook::HolidayPluginIf*_if;
+ };
+ QValueList<HPlugin*>_pluginlist;
+};
+
+class DateBookDBHoliday:virtual public DateBookDBHack {
+public:
+ DateBookDBHoliday():DateBookDBHack(){db_holiday=0;}
+ virtual ~DateBookDBHoliday(){}
+ virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
+ virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
+ virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDate &from,const QDate &to );
+ virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDateTime &start);
+
+ DateBookHoliday*db_holiday;
+};
+
+#endif
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index 7503751..a509d89 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -1,675 +1,676 @@
/**********************************************************************
** 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 "datebooktypes.h"
#include <qpe/datebookdb.h>
#include <qpe/qpeapplication.h>
#include <qpe/calendar.h>
#include <qheader.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qtimer.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,
- QWidget *parent, const char *name )
+ QWidget *parent, const char *name )
: QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ),
showingEvent( false )
{
items.setAutoDelete( true );
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)));
+ this, SLOT(slotChangeClock(bool)));
QFontMetrics fm( font() );
rowHeight = fm.height()+2;
resizeContents( width(), 24*rowHeight );
}
void DateBookWeekView::initNames()
{
static bool bFirst = true;
if ( bFirst ) {
- if ( bOnMonday ) {
+ if ( bOnMonday ) {
for ( int i = 1; i<=7; i++ ) {
header->addLabel( Calendar::nameOfDay( i ) );
}
- } else {
+ } else {
header->addLabel( Calendar::nameOfDay( 7 ) );
for ( int i = 1; i<7; i++ ) {
header->addLabel( Calendar::nameOfDay( i ) );
}
}
- bFirst = false;
+ bFirst = false;
} else {
- // we are change things...
- if ( bOnMonday ) {
+ // we are change things...
+ if ( bOnMonday ) {
for ( int i = 1; i<=7; i++ ) {
header->setLabel( i, Calendar::nameOfDay( i ) );
}
- } else {
+ } else {
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();
+ 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 );
}
void DateBookWeekView::keyPressEvent( QKeyEvent *e )
{
e->ignore();
}
void DateBookWeekView::slotChangeClock( bool c )
{
ampm = c;
viewport()->update();
}
static inline int db_round30min( int m )
{
if ( m < 15 )
- m = 0;
+ m = 0;
else if ( m < 45 )
- m = 1;
+ m = 1;
else
- m = 2;
+ m = 2;
return m;
}
void DateBookWeekView::alterDay( int day )
{
if ( !bOnMonday ) {
- day--;
+ day--;
}
emit showDay( day );
}
void DateBookWeekView::positionItem( DateBookWeekItem *i )
{
const int Width = 8;
const EffectiveEvent ev = i->event();
// 30 minute intervals
int y = ev.start().hour() * 2;
y += db_round30min( ev.start().minute() );
int y2 = ev.end().hour() * 2;
y2 += db_round30min( ev.end().minute() );
if ( y > 47 ) y = 47;
if ( y2 > 48 ) y2 = 48;
y = (y * rowHeight) / 2;
y2 = (y2 * rowHeight) / 2;
int h;
if ( ev.event().type() == Event::AllDay ) {
- h = (48 * rowHeight) / 2;
- y = 0;
- } else {
- h=y2-y;
- if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2;
+ h = (48 * rowHeight) / 2;
+ y = 0;
+ } else {
+ h=y2-y;
+ if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2;
}
int dow = ev.date().dayOfWeek();
if ( !bOnMonday ) {
- if ( dow == 7 )
- dow = 1;
- else
- dow++;
+ if ( dow == 7 )
+ dow = 1;
+ else
+ dow++;
}
int x = header->sectionPos( dow ) - 1;
int xlim = header->sectionPos( dow ) + header->sectionSize( dow );
DateBookWeekItem *isect = 0;
do {
- i->setGeometry( x, y, Width, h );
- isect = intersects( i );
- x += Width - 1;
+ i->setGeometry( x, y, Width, h );
+ isect = intersects( i );
+ x += Width - 1;
} while ( isect && x < xlim );
}
DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item )
{
QRect geom = item->geometry();
// We allow the edges to overlap
geom.moveBy( 1, 1 );
geom.setSize( geom.size()-QSize(2,2) );
QListIterator<DateBookWeekItem> it(items);
for ( ; it.current(); ++it ) {
- DateBookWeekItem *i = it.current();
- if ( i != item ) {
- if ( i->geometry().intersects( geom ) ) {
- return i;
- }
- }
+ DateBookWeekItem *i = it.current();
+ if ( i != item ) {
+ if ( i->geometry().intersects( geom ) ) {
+ return i;
+ }
+ }
}
return 0;
}
void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e )
{
QListIterator<DateBookWeekItem> it(items);
for ( ; it.current(); ++it ) {
- DateBookWeekItem *i = it.current();
- if ( i->geometry().contains( e->pos() ) ) {
- showingEvent = true;
- emit signalShowEvent( i->event() );
- break;
- }
+ DateBookWeekItem *i = it.current();
+ if ( i->geometry().contains( e->pos() ) ) {
+ showingEvent = true;
+ emit signalShowEvent( i->event() );
+ break;
+ }
}
}
void DateBookWeekView::contentsMouseReleaseEvent( QMouseEvent *e )
{
if ( showingEvent ) {
- showingEvent = false;
- emit signalHideEvent();
+ showingEvent = false;
+ emit signalHideEvent();
} else {
- int d = header->sectionAt( e->pos().x() );
- if ( d > 0 ) {
-// if ( !bOnMonday )
-// d--;
- emit showDay( d );
- }
+ int d = header->sectionAt( e->pos().x() );
+ if ( d > 0 ) {
+// if ( !bOnMonday )
+// d--;
+ emit showDay( d );
+ }
}
}
void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch )
{
QRect ur( cx, cy, cw, ch );
p->setPen( lightGray );
for ( int i = 1; i <= 7; i++ )
- p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch );
+ p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch );
p->setPen( black );
for ( int t = 0; t < 24; t++ ) {
- int y = t*rowHeight;
- if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) {
- QString s;
- if ( ampm ) {
- if ( t == 0 )
- s = QString::number( 12 );
- else if ( t == 12 )
- s = QString::number(12) + tr( "p" );
- else if ( t > 12 ) {
- if ( t - 12 < 10 )
- s = " ";
- else
- s = "";
- s += QString::number( t - 12 ) + tr("p");
- } else {
- if ( 12 - t < 3 )
- s = "";
- else
- s = " ";
- s += QString::number( t );
- }
- } else {
- s = QString::number( t );
- if ( s.length() == 1 )
- s.prepend( "0" );
- }
- p->drawText( 1, y+p->fontMetrics().ascent()+1, s );
- }
+ int y = t*rowHeight;
+ if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) {
+ QString s;
+ if ( ampm ) {
+ if ( t == 0 )
+ s = QString::number( 12 );
+ else if ( t == 12 )
+ s = QString::number(12) + tr( "p" );
+ else if ( t > 12 ) {
+ if ( t - 12 < 10 )
+ s = " ";
+ else
+ s = "";
+ s += QString::number( t - 12 ) + tr("p");
+ } else {
+ if ( 12 - t < 3 )
+ s = "";
+ else
+ s = " ";
+ s += QString::number( t );
+ }
+ } else {
+ s = QString::number( t );
+ if ( s.length() == 1 )
+ s.prepend( "0" );
+ }
+ p->drawText( 1, y+p->fontMetrics().ascent()+1, s );
+ }
}
QListIterator<DateBookWeekItem> it(items);
for ( ; it.current(); ++it ) {
- DateBookWeekItem *i = it.current();
- if ( i->geometry().intersects( ur ) ) {
- p->setBrush( i->color() );
- p->drawRect( i->geometry() );
- }
+ DateBookWeekItem *i = it.current();
+ if ( i->geometry().intersects( ur ) ) {
+ p->setBrush( i->color() );
+ p->drawRect( i->geometry() );
+ }
}
}
void DateBookWeekView::resizeEvent( QResizeEvent *e )
{
const int hourWidth = 20;
QScrollView::resizeEvent( e );
//HEAD
/*
int avail = visibleWidth();
header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(),
- visibleWidth(), header->sizeHint().height() );
+ visibleWidth(), header->sizeHint().height() );
setMargins( 0, header->sizeHint().height(), 0, 0 );
*/
//BRANCH_1_0
int avail = width()-qApp->style().scrollBarExtent().width()-1;
header->setGeometry( 0, 0, avail, header->sizeHint().height() );
setMargins( 0, header->height(), 0, 0 );
header->resizeSection( 0, hourWidth );
int sw = (avail - hourWidth) / 7;
for ( int i = 1; i < 7; i++ )
- header->resizeSection( i, sw );
+ header->resizeSection( i, sw );
header->resizeSection( 7, avail - hourWidth - sw*6 );
}
void DateBookWeekView::setStartOfWeek( bool bStartOnMonday )
{
bOnMonday = bStartOnMonday;
initNames();
}
//-------------------------------------------------------------------
-DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB,
- QWidget *parent, const char *name )
+DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDBHoliday *newDB,
+ QWidget *parent, const char *name )
: QWidget( parent, name ),
db( newDB ),
startTime( 0 ),
ampm( ap ),
bStartOnMonday( startOnMonday )
{
- setFocusPolicy(StrongFocus);
- QVBoxLayout *vb = new QVBoxLayout( this );
- header = new DateBookWeekHeader( bStartOnMonday, this );
- view = new DateBookWeekView( ampm, startOnMonday, this );
- vb->addWidget( header );
- vb->addWidget( view );
+ setFocusPolicy(StrongFocus);
+ QVBoxLayout *vb = new QVBoxLayout( this );
+ header = new DateBookWeekHeader( bStartOnMonday, this );
+ view = new DateBookWeekView( ampm, startOnMonday, this );
+ vb->addWidget( header );
+ vb->addWidget( view );
- lblDesc = new QLabel( this, "event label" );
- lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box );
- lblDesc->setBackgroundColor( yellow );
- lblDesc->hide();
+ lblDesc = new QLabel( this, "event label" );
+ lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box );
+ lblDesc->setBackgroundColor( yellow );
+ lblDesc->hide();
- tHide = new QTimer( this );
+ tHide = new QTimer( this );
- connect( view, SIGNAL( showDay(int) ), this, SLOT( showDay(int) ) );
- connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) );
- connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) );
- connect( header, SIGNAL( dateChanged(QDate&) ), this, SLOT( dateChanged(QDate&) ) );
- connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) );
- connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
- connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
- setDate(QDate::currentDate());
+ connect( view, SIGNAL( showDay(int) ), this, SLOT( showDay(int) ) );
+ connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) );
+ connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) );
+ connect( header, SIGNAL( dateChanged(QDate&) ), this, SLOT( dateChanged(QDate&) ) );
+ connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) );
+ connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
+ connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
+ setDate(QDate::currentDate());
}
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();
+ 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;
+ QDate d=bdate;
- // Calculate offset to first day of week.
- int dayoffset=d.dayOfWeek() % 7;
+ // Calculate offset to first day of week.
+ int dayoffset=d.dayOfWeek() % 7;
- if(bStartOnMonday) dayoffset--;
+ if(bStartOnMonday) dayoffset--;
- day--;
- d=d.addDays(day-dayoffset);
- emit showDate( d.year(), d.month(), d.day() );
+ 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));
+ setDate(QDate(y, m, d));
}
void DateBookWeek::setDate(QDate newdate)
{
- bdate=newdate;
- dow = newdate.dayOfWeek();
- header->setDate( newdate );
+ bdate=newdate;
+ dow = newdate.dayOfWeek();
+ header->setDate( newdate );
}
void DateBookWeek::dateChanged( QDate &newdate )
{
- bdate=newdate;
- getEvents();
+ bdate=newdate;
+ getEvents();
}
QDate DateBookWeek::date() const
{
- return bdate;
+ return bdate;
}
void DateBookWeek::getEvents()
{
- QDate startWeek = weekDate();
+ QDate startWeek = weekDate();
- QDate endWeek = startWeek.addDays( 6 );
- QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek);
- view->showEvents( eventList );
- view->moveToHour( startTime );
+ QDate endWeek = startWeek.addDays( 6 );
+ QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek);
+ view->showEvents( eventList );
+ view->moveToHour( startTime );
}
void DateBookWeek::generateAllDayTooltext( QString& text ) {
- text += "<b>" + tr("This is an all day event.") + "</b><br>";
+ text += "<b>" + tr("This is an all day event.") + "</b><br>";
}
void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) {
- str += "<b>" + QObject::tr("Start") + "</b>: ";
- str += TimeString::timeString( ev.event().start().time(), ampm, FALSE );
- if( ev.startDate()!=ev.endDate() ) {
- str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>";
- }
- str += "<br>";
- str += "<b>" + QObject::tr("End") + "</b>: ";
- str += TimeString::timeString( ev.event().end().time(), ampm, FALSE );
- if( ev.startDate()!=ev.endDate() ) {
- str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>";
- }
+ str += "<b>" + QObject::tr("Start") + "</b>: ";
+ str += TimeString::timeString( ev.event().start().time(), ampm, FALSE );
+ if( ev.startDate()!=ev.endDate() ) {
+ str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>";
+ }
+ str += "<br>";
+ str += "<b>" + QObject::tr("End") + "</b>: ";
+ str += TimeString::timeString( ev.event().end().time(), ampm, FALSE );
+ if( ev.startDate()!=ev.endDate() ) {
+ str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>";
+ }
}
void DateBookWeek::slotShowEvent( const EffectiveEvent &ev )
{
if ( tHide->isActive() )
tHide->stop();
// why would someone use "<"? Oh well, fix it up...
// I wonder what other things may be messed up...
QString strDesc = ev.description();
int where = strDesc.find( "<" );
while ( where != -1 ) {
- strDesc.remove( where, 1 );
- strDesc.insert( where, "&#60;" );
- where = strDesc.find( "<", where );
+ strDesc.remove( where, 1 );
+ strDesc.insert( where, "&#60;" );
+ where = strDesc.find( "<", where );
}
QString strCat;
// ### FIX later...
// QString strCat = ev.category();
// where = strCat.find( "<" );
// while ( where != -1 ) {
-// strCat.remove( where, 1 );
-// strCat.insert( where, "&#60;" );
-// where = strCat.find( "<", where );
+// strCat.remove( where, 1 );
+// strCat.insert( where, "&#60;" );
+// where = strCat.find( "<", where );
// }
QString strLocation = ev.location();
while ( where != -1 ) {
- strLocation.remove( where, 1 );
- strLocation.insert( where, "&#60;" );
- where = strLocation.find( "<", where );
+ strLocation.remove( where, 1 );
+ strLocation.insert( where, "&#60;" );
+ where = strLocation.find( "<", where );
}
QString strNote = ev.notes();
where = strNote.find( "<" );
while ( where != -1 ) {
- strNote.remove( where, 1 );
- strNote.insert( where, "&#60;" );
- where = strNote.find( "<", where );
+ strNote.remove( where, 1 );
+ strNote.insert( where, "&#60;" );
+ where = strNote.find( "<", where );
}
QString str = "<b>" + strDesc + "</b><br>"
+ strLocation + "<br>"
+ "<i>" + strCat + "</i>"
+ "<br>" + TimeString::longDateString( ev.date() )
- + "<br>";
+ + "<br>";
if (ev.event().type() == Event::Normal )
generateNormalTooltext( str, ev );
else
generateAllDayTooltext( str );
str += "<br><br>" + strNote;
lblDesc->setText( str );
lblDesc->resize( lblDesc->sizeHint() );
// move the label so it is "centerd" horizontally...
lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 );
lblDesc->show();
}
void DateBookWeek::slotHideEvent()
{
tHide->start( 2000, true );
}
void DateBookWeek::setStartViewTime( int startHere )
{
startTime = startHere;
view->moveToHour( startTime );
}
int DateBookWeek::startViewTime() const
{
return startTime;
}
void DateBookWeek::redraw()
{
getEvents();
}
void DateBookWeek::slotYearChanged( int y )
{
- int totWeek;
- QDate d( y, 12, 31 );
- int throwAway;
- calcWeek( d, totWeek, throwAway, bStartOnMonday );
- while ( totWeek == 1 ) {
- d = d.addDays( -1 );
- calcWeek( d, totWeek, throwAway, bStartOnMonday );
- }
+ int totWeek;
+ QDate d( y, 12, 31 );
+ int throwAway;
+ calcWeek( d, totWeek, throwAway, bStartOnMonday );
+ while ( totWeek == 1 ) {
+ d = d.addDays( -1 );
+ calcWeek( d, totWeek, throwAway, bStartOnMonday );
+ }
}
void DateBookWeek::slotWeekChanged( bool onMonday )
{
- bStartOnMonday = onMonday;
- view->setStartOfWeek( bStartOnMonday );
- header->setStartOfWeek( bStartOnMonday );
- redraw();
+ bStartOnMonday = onMonday;
+ view->setStartOfWeek( bStartOnMonday );
+ header->setStartOfWeek( bStartOnMonday );
+ redraw();
}
void DateBookWeek::slotClockChanged( bool ap )
{
- ampm = ap;
+ ampm = ap;
}
// return the date at the beginning of the week...
QDate DateBookWeek::weekDate() const
{
- QDate d=bdate;
+ QDate d=bdate;
- // Calculate offset to first day of week.
- int dayoffset=d.dayOfWeek();
- if(bStartOnMonday) dayoffset--;
- else if( dayoffset == 7 )
- dayoffset = 0;
+ // Calculate offset to first day of week.
+ int dayoffset=d.dayOfWeek();
+ if(bStartOnMonday) dayoffset--;
+ else if( dayoffset == 7 )
+ dayoffset = 0;
- return d.addDays(-dayoffset);
+ 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
// week...
bool calcWeek( const QDate &d, int &week, int &year,
- bool startOnMonday )
+ bool startOnMonday )
{
int weekNumber;
int yearNumber;
// remove a pesky warning, (Optimizations on g++)
weekNumber = -1;
int jan1WeekDay = QDate(d.year(), 1, 1).dayOfWeek();
int dayOfWeek = d.dayOfWeek();
if ( !d.isValid() )
- return false;
+ return false;
if ( startOnMonday ) {
- // find the Jan1Weekday;
- if ( d.dayOfYear() <= ( 8 - jan1WeekDay) && jan1WeekDay > 4 ) {
- yearNumber = d.year() - 1;
- if ( jan1WeekDay == 5 || ( jan1WeekDay == 6 && QDate::leapYear(yearNumber) ) )
- weekNumber = 53;
- else
- weekNumber = 52;
- } else
- yearNumber = d.year();
- if ( yearNumber == d.year() ) {
- int totalDays = 365;
- if ( QDate::leapYear(yearNumber) )
- totalDays++;
- if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek) )
- || (jan1WeekDay == 7) && (totalDays - d.dayOfYear()) < 3) {
- yearNumber++;
- weekNumber = 1;
- }
- }
- if ( yearNumber == d.year() ) {
- int j = d.dayOfYear() + (7 - dayOfWeek) + ( jan1WeekDay - 1 );
- weekNumber = j / 7;
- if ( jan1WeekDay > 4 )
- weekNumber--;
- }
+ // find the Jan1Weekday;
+ if ( d.dayOfYear() <= ( 8 - jan1WeekDay) && jan1WeekDay > 4 ) {
+ yearNumber = d.year() - 1;
+ if ( jan1WeekDay == 5 || ( jan1WeekDay == 6 && QDate::leapYear(yearNumber) ) )
+ weekNumber = 53;
+ else
+ weekNumber = 52;
+ } else
+ yearNumber = d.year();
+ if ( yearNumber == d.year() ) {
+ int totalDays = 365;
+ if ( QDate::leapYear(yearNumber) )
+ totalDays++;
+ if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek) )
+ || (jan1WeekDay == 7) && (totalDays - d.dayOfYear()) < 3) {
+ yearNumber++;
+ weekNumber = 1;
+ }
+ }
+ if ( yearNumber == d.year() ) {
+ int j = d.dayOfYear() + (7 - dayOfWeek) + ( jan1WeekDay - 1 );
+ weekNumber = j / 7;
+ if ( jan1WeekDay > 4 )
+ weekNumber--;
+ }
} else {
- // it's better to keep these cases separate...
- if ( d.dayOfYear() <= (7 - jan1WeekDay) && jan1WeekDay > 4
- && jan1WeekDay != 7 ) {
- yearNumber = d.year() - 1;
- if ( jan1WeekDay == 6
- || (jan1WeekDay == 7 && QDate::leapYear(yearNumber) ) ) {
- weekNumber = 53;
- }else
- weekNumber = 52;
- } else
- yearNumber = d.year();
- if ( yearNumber == d.year() ) {
- int totalDays = 365;
- if ( QDate::leapYear( yearNumber ) )
- totalDays++;
- if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek % 7)) ) {
- yearNumber++;
- weekNumber = 1;
- }
- }
- if ( yearNumber == d.year() ) {
- int j = d.dayOfYear() + (7 - dayOfWeek % 7) + ( jan1WeekDay - 1 );
- weekNumber = j / 7;
- if ( jan1WeekDay > 4 ) {
- weekNumber--;
- }
- }
+ // it's better to keep these cases separate...
+ if ( d.dayOfYear() <= (7 - jan1WeekDay) && jan1WeekDay > 4
+ && jan1WeekDay != 7 ) {
+ yearNumber = d.year() - 1;
+ if ( jan1WeekDay == 6
+ || (jan1WeekDay == 7 && QDate::leapYear(yearNumber) ) ) {
+ weekNumber = 53;
+ }else
+ weekNumber = 52;
+ } else
+ yearNumber = d.year();
+ if ( yearNumber == d.year() ) {
+ int totalDays = 365;
+ if ( QDate::leapYear( yearNumber ) )
+ totalDays++;
+ if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek % 7)) ) {
+ yearNumber++;
+ weekNumber = 1;
+ }
+ }
+ if ( yearNumber == d.year() ) {
+ int j = d.dayOfYear() + (7 - dayOfWeek % 7) + ( jan1WeekDay - 1 );
+ weekNumber = j / 7;
+ if ( jan1WeekDay > 4 ) {
+ weekNumber--;
+ }
+ }
}
year = yearNumber;
week = weekNumber;
return true;
}
diff --git a/core/pim/datebook/datebookweek.h b/core/pim/datebook/datebookweek.h
index c273e30..ddf54ed 100644
--- a/core/pim/datebook/datebookweek.h
+++ b/core/pim/datebook/datebookweek.h
@@ -7,122 +7,123 @@
** 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 DATEBOOKWEEK
#define DATEBOOKWEEK
#include <qpe/event.h>
#include <qlist.h>
#include <qscrollview.h>
#include <qstring.h>
#include <qvaluelist.h>
class DateBookDB;
+class DateBookDBHoliday;
class DateBookWeekHeader;
class QDate;
class QLabel;
class QResizeEvent;
class QSpinBox;
class QTimer;
class QHeader;
class DateBookWeekItem
{
public:
DateBookWeekItem( const EffectiveEvent e );
void setGeometry( int x, int y, int w, int h );
QRect geometry() const { return r; }
const QColor &color() const { return c; }
const EffectiveEvent event() const { return ev; }
private:
const EffectiveEvent ev;
QRect r;
QColor c;
};
class DateBookWeekView : public QScrollView
{
Q_OBJECT
public:
DateBookWeekView( bool ampm, bool weekOnMonday, QWidget *parent = 0,
- const char *name = 0 );
+ const char *name = 0 );
bool whichClock() const;
void showEvents( QValueList<EffectiveEvent> &ev );
void moveToHour( int h );
void setStartOfWeek( bool bOnMonday );
signals:
void showDay( int d );
void signalShowEvent( const EffectiveEvent & );
void signalHideEvent();
protected slots:
void keyPressEvent(QKeyEvent *);
private slots:
void slotChangeClock( bool );
void alterDay( int );
private:
void positionItem( DateBookWeekItem *i );
DateBookWeekItem *intersects( const DateBookWeekItem * );
void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
void contentsMousePressEvent( QMouseEvent * );
void contentsMouseReleaseEvent( QMouseEvent * );
void resizeEvent( QResizeEvent * );
void initNames();
private:
bool ampm;
bool bOnMonday;
QHeader *header;
QList<DateBookWeekItem> items;
int rowHeight;
bool showingEvent;
};
class DateBookWeek : public QWidget
{
Q_OBJECT
public:
- DateBookWeek( bool ampm, bool weekOnMonday, DateBookDB *newDB,
- QWidget *parent = 0, const char *name = 0 );
+ DateBookWeek( bool ampm, bool weekOnMonday, DateBookDBHoliday *newDB,
+ QWidget *parent = 0, const char *name = 0 );
void setDate( int y, int m, int d );
void setDate( QDate d );
QDate date() const;
DateBookWeekView *weekView() const { return view; }
void setStartViewTime( int startHere );
int startViewTime() const;
int week() const { return _week; };
QDate weekDate() const;
public slots:
void redraw();
void slotWeekChanged( bool bStartOnMonday );
void slotClockChanged( bool a );
signals:
void showDate( int y, int m, int d );
protected slots:
void keyPressEvent(QKeyEvent *);
private slots:
void showDay( int day );
void dateChanged( QDate &newdate );
void slotShowEvent( const EffectiveEvent & );
@@ -132,35 +133,35 @@ private slots:
private:
void getEvents();
/**
* Wow that's a hell lot of code duplication
* in datebook. I vote for a common base class
* but never the less. This add a note
* that the Event is an all day event
*
*/
void generateAllDayTooltext( QString& text );
/**
* This will add the times to the text
* It will be shown in the Tooltip bubble
*/
void generateNormalTooltext( QString& text,
const EffectiveEvent &ev);
int year;
int _week;
int dow;
QDate bdate;
DateBookWeekHeader *header;
DateBookWeekView *view;
- DateBookDB *db;
+ DateBookDBHoliday *db;
QLabel *lblDesc;
QTimer *tHide;
int startTime;
bool ampm;
bool bStartOnMonday;
};
bool calcWeek( const QDate &d, int &week, int &year, bool startOnMonday = false );
#endif
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
index 771aa00..0555bc7 100644
--- a/core/pim/datebook/datebookweeklst.cpp
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -1,436 +1,437 @@
#include "namespace_hack.h"
#include "datebookweeklst.h"
#include "datebook.h"
+#include "datebooktypes.h"
#include <opie2/odebug.h>
#include <qpe/datebookmonth.h>
#include <qpe/config.h>
#include <qpe/ir.h>
#include <qpe/resource.h>
#include <qlayout.h>
#include <qtoolbutton.h>
#include <qtl.h>
bool calcWeek(const QDate &d, int &week, int &year,bool startOnMonday = false);
using namespace Opie::Ui;
DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent, const char* name, WFlags fl)
: DateBookWeekLstHeaderBase(parent, name, fl)
{
- setBackgroundMode( PaletteButton );
- labelDate->setBackgroundMode( PaletteButton );
- forwardweek->setBackgroundMode( PaletteButton );
- forwardweek->setPixmap( Resource::loadPixmap("forward") );
- forwardmonth->setBackgroundMode( PaletteButton );
- 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;
+ setBackgroundMode( PaletteButton );
+ labelDate->setBackgroundMode( PaletteButton );
+ forwardweek->setBackgroundMode( PaletteButton );
+ forwardweek->setPixmap( Resource::loadPixmap("forward") );
+ forwardmonth->setBackgroundMode( PaletteButton );
+ 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--;
- 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()) + "." +
- Calendar::nameOfMonth( start.month() ) + "-" +
- QString::number(stop.day()) + "." +
+ int year,week,dayofweek;
+ date=d;
+ dayofweek=d.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()) + "." +
+ Calendar::nameOfMonth( start.month() ) + "-" +
+ QString::number(stop.day()) + "." +
Calendar::nameOfMonth( stop.month()) +" ("+
- tr("w")+":"+QString::number( week ) +")");
- date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
- emit dateChanged(date);
+ tr("w")+":"+QString::number( week ) +")");
+ date = d; // bugfix: 0001126 - date has to be the selected date, not monday!
+ 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() ) );
- }
- picker->setDate( date.year(), date.month(), date.day() );
- m1->popup(mapToGlobal(labelDate->pos()+QPoint(0,labelDate->height())));
- picker->setFocus();
+ 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 DateBookWeekLstHeader::setDate(int y, int m, int d) {
- setDate(QDate(y,m,d));
+ setDate(QDate(y,m,d));
}
void DateBookWeekLstHeader::nextWeek() {
- setDate(date.addDays(7));
+ setDate(date.addDays(7));
}
void DateBookWeekLstHeader::prevWeek() {
- setDate(date.addDays(-7));
+ setDate(date.addDays(-7));
}
void DateBookWeekLstHeader::nextMonth()
{
- setDate(date.addDays(28));
+ setDate(date.addDays(28));
}
void DateBookWeekLstHeader::prevMonth()
{
- setDate(date.addDays(-28));
+ setDate(date.addDays(-28));
}
DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */,
- QWidget* parent,
- const char* name,
- WFlags fl )
+ QWidget* parent,
+ const char* name,
+ WFlags fl )
: DateBookWeekLstDayHdrBase(parent, name, fl) {
- date=d;
+ date=d;
- static const QString wdays=tr("MTWTFSSM", "Week days");
- char day=wdays[d.dayOfWeek()-1];
+ static const QString wdays=tr("MTWTFSSM", "Week days");
+ char day=wdays[d.dayOfWeek()-1];
//dont use dayOfWeek() to save space !
- label->setText( QString(QObject::tr(QString(QChar(day)))) + " " +QString::number(d.day()) );
+ 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()));
+ 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()));
}
void DateBookWeekLstDayHdr::showDay() {
- emit showDate(date.year(), date.month(), date.day());
+ emit showDate(date.year(), date.month(), date.day());
}
void DateBookWeekLstDayHdr::newEvent() {
QDateTime start, stop;
start=stop=date;
start.setTime(QTime(10,0));
stop.setTime(QTime(12,0));
emit addEvent(start,stop,"",0);
}
DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
- int weeklistviewconfig,
- QWidget* parent,
- const char* name,
- WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
+ int weeklistviewconfig,
+ QWidget* parent,
+ const char* name,
+ WFlags fl ) : OClickableLabel(parent,name,fl), event(ev)
{
- // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
- QString s,start,middle,end,day;
-
- odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl;
- if(weeklistviewconfig==NONE) { // No times displayed.
-// start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
-// middle.sprintf("<--->");
-// end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
-// day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
- } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time.
- start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
- middle.sprintf(" |---");
- end.sprintf("__|__");
- day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
- } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
- start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
- middle.sprintf("<--->");
- end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
- day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
- }
-
- if(ev.event().type() == Event::Normal) {
- if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event.
- s=day;
- } else if(ev.startDate()==ev.date()) { // start event.
- s=start;
- } else if(ev.endDate()==ev.date()) { // end event.
- s=end;
- } else { // middle day.
- s=middle;
- }
- } else {
- s="";
- }
- setText(QString(s) + " " + ev.description());
-// connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
- setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
+ // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
+ QString s,start,middle,end,day;
+
+ odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl;
+ if(weeklistviewconfig==NONE) { // No times displayed.
+// start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
+// middle.sprintf("<--->");
+// end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
+// day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
+ } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time.
+ start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
+ middle.sprintf(" |---");
+ end.sprintf("__|__");
+ day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
+ } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times.
+ start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute());
+ middle.sprintf("<--->");
+ end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute());
+ day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute());
+ }
+
+ if(ev.event().type() == Event::Normal) {
+ if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event.
+ s=day;
+ } else if(ev.startDate()==ev.date()) { // start event.
+ s=start;
+ } else if(ev.endDate()==ev.date()) { // end event.
+ s=end;
+ } else { // middle day.
+ s=middle;
+ }
+ } else {
+ s="";
+ }
+ setText(QString(s) + " " + ev.description());
+// connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
+ setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) );
}
void DateBookWeekLstEvent::editMe() {
- emit editEvent(event.event());
+ emit editEvent(event.event());
}
void DateBookWeekLstEvent::duplicateMe()
{
emit duplicateEvent(event.event());
}
void DateBookWeekLstEvent::deleteMe()
{
emit removeEvent(event.event());
emit redraw();
}
void DateBookWeekLstEvent::beamMe()
{
- emit beamEvent( event.event() );
+ emit beamEvent( event.event() );
}
void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e )
{
- popmenue = new QPopupMenu;
- popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe()));
- popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe()));
- popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe()));
- if(Ir::supported())
- popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe()));
- popmenue->popup( mapToGlobal( e->pos() ));
+ popmenue = new QPopupMenu;
+ popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe()));
+ popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe()));
+ popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe()));
+ if(Ir::supported())
+ popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe()));
+ popmenue->popup( mapToGlobal( e->pos() ));
}
DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
- const QDate &d, bool onM,
- QWidget* parent,
- const char* name, WFlags fl)
+ const QDate &d, bool onM,
+ QWidget* parent,
+ const char* name, WFlags fl)
: QWidget( parent, name, fl )
{
- Config config("DateBook");
- config.setGroup("Main");
- int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
- odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl;
-
- 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&)));
- connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
- connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
- connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
- connect (l, SIGNAL(redraw()), this, SIGNAL(redraw()));
- }
- it++;
- }
- layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
+ Config config("DateBook");
+ config.setGroup("Main");
+ int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
+ odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl;
+
+ 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&)));
+ connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
+ connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
+ connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
+ connect (l, SIGNAL(redraw()), this, SIGNAL(redraw()));
+ }
+ it++;
+ }
+ layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
}
}
DateBookWeekLstView::~DateBookWeekLstView(){}
void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();}
DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
- QValueList<EffectiveEvent> &ev2,
- QDate &d, bool onM,
- QWidget* parent,
- const char* name, WFlags fl)
+ QValueList<EffectiveEvent> &ev2,
+ QDate &d, bool onM,
+ QWidget* parent,
+ const char* name, WFlags fl)
: QWidget( parent, name, fl )
{
- QHBoxLayout *layout = new QHBoxLayout( this );
-
- DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
- layout->addWidget(w);
- connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
- connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
- connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
- connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
- connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
- connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
- connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
- this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
-
-
- w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
- layout->addWidget(w);
- connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
- connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
- connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
- connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
- connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
- connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
- connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
- this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
+ QHBoxLayout *layout = new QHBoxLayout( this );
+
+ DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this);
+ layout->addWidget(w);
+ connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
+ connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
+ connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
+ connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
+ connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
+ connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
+ connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
+ this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
+
+
+ w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
+ layout->addWidget(w);
+ connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
+ connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
+ connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
+ connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
+ connect (w, SIGNAL(redraw()), this, SIGNAL(redraw()));
+ connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
+ connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
+ this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
}
-DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
- QWidget *parent,
- const char *name )
+DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDBHoliday *newDB,
+ QWidget *parent,
+ const char *name )
: QWidget( parent, name ),
db( newDB ),
startTime( 0 ),
ampm( ap ),
bStartOnMonday(onM)
{
- setFocusPolicy(StrongFocus);
- layout = new QVBoxLayout( this );
- layout->setMargin(0);
-
- header=new DateBookWeekLstHeader(onM, this);
- layout->addWidget( header );
- connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
- connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
-
- scroll=new QScrollView(this);
- scroll->setResizePolicy(QScrollView::AutoOneFit);
- layout->addWidget(scroll);
-
- view=NULL;
- Config config("DateBook");
- config.setGroup("Main");
- dbl=config.readBoolEntry("weeklst_dbl", false);
- header->dbl->setOn(dbl);
+ setFocusPolicy(StrongFocus);
+ layout = new QVBoxLayout( this );
+ layout->setMargin(0);
+
+ header=new DateBookWeekLstHeader(onM, this);
+ layout->addWidget( header );
+ connect(header, SIGNAL(dateChanged(QDate&)), this, SLOT(dateChanged(QDate&)));
+ connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool)));
+
+ scroll=new QScrollView(this);
+ scroll->setResizePolicy(QScrollView::AutoOneFit);
+ layout->addWidget(scroll);
+
+ view=NULL;
+ Config config("DateBook");
+ config.setGroup("Main");
+ dbl=config.readBoolEntry("weeklst_dbl", false);
+ header->dbl->setOn(dbl);
}
DateBookWeekLst::~DateBookWeekLst(){
- Config config("DateBook");
- config.setGroup("Main");
- config.writeEntry("weeklst_dbl", dbl);
+ Config config("DateBook");
+ config.setGroup("Main");
+ config.writeEntry("weeklst_dbl", dbl);
}
void DateBookWeekLst::setDate(const QDate &d) {
- bdate=d;
- header->setDate(d);
+ bdate=d;
+ header->setDate(d);
}
void DateBookWeekLst::setDbl(bool on) {
- dbl=on;
- redraw();
+ dbl=on;
+ redraw();
}
void DateBookWeekLst::redraw() {getEvents();}
QDate DateBookWeekLst::date() {
- return bdate;
+ return bdate;
}
// return the date at the beginning of the week...
// copied from DateBookWeek
QDate DateBookWeekLst::weekDate() const
{
- QDate d=bdate;
+ QDate d=bdate;
- // Calculate offset to first day of week.
- int dayoffset=d.dayOfWeek();
- if(bStartOnMonday) dayoffset--;
- else if( dayoffset == 7 )
- dayoffset = 0;
+ // Calculate offset to first day of week.
+ int dayoffset=d.dayOfWeek();
+ if(bStartOnMonday) dayoffset--;
+ else if( dayoffset == 7 )
+ dayoffset = 0;
- return d.addDays(-dayoffset);
+ return d.addDays(-dayoffset);
}
void DateBookWeekLst::getEvents() {
- QDate start = weekDate(); //date();
- QDate stop = start.addDays(6);
- QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
-
- if (view) delete view;
- if (dbl) {
- QDate start2=start.addDays(7);
- stop=start2.addDays(6);
- QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
- view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
- } else {
- view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
- }
-
- connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
- connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
- connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
- connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
- connect (view, SIGNAL(redraw()), this, SLOT(redraw()));
- connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
- connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
- this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
-
- scroll->addChild(view);
- view->show();
- scroll->updateScrollBars();
+ QDate start = weekDate(); //date();
+ QDate stop = start.addDays(7);
+ QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
+
+ if (view) delete view;
+ if (dbl) {
+ QDate start2=start.addDays(8);
+ stop=start2.addDays(7);
+ QValueList<EffectiveEvent> el2 = db->getEffectiveEvents(start2, stop);
+ view=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
+ } else {
+ view=new DateBookWeekLstView(el,start,bStartOnMonday,scroll);
+ }
+
+ connect (view, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
+ connect (view, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
+ connect (view, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
+ connect (view, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
+ connect (view, SIGNAL(redraw()), this, SLOT(redraw()));
+ connect (view, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
+ connect (view, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
+ this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
+
+ scroll->addChild(view);
+ view->show();
+ scroll->updateScrollBars();
}
void DateBookWeekLst::dateChanged(QDate &newdate) {
- bdate=newdate;
- getEvents();
+ bdate=newdate;
+ getEvents();
}
void DateBookWeekLst::keyPressEvent(QKeyEvent *e)
{
- switch(e->key()) {
- case Key_Up:
- scroll->scrollBy(0, -20);
- break;
- case Key_Down:
- scroll->scrollBy(0, 20);
- break;
- case Key_Left:
- header->prevWeek();
- break;
- case Key_Right:
- header->nextWeek();
- break;
- default:
- e->ignore();
- }
+ switch(e->key()) {
+ case Key_Up:
+ scroll->scrollBy(0, -20);
+ break;
+ case Key_Down:
+ scroll->scrollBy(0, 20);
+ break;
+ case Key_Left:
+ header->prevWeek();
+ break;
+ case Key_Right:
+ header->nextWeek();
+ break;
+ default:
+ e->ignore();
+ }
}
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
index 3bc7f2f..38d7777 100644
--- a/core/pim/datebook/datebookweeklst.h
+++ b/core/pim/datebook/datebookweeklst.h
@@ -1,177 +1,178 @@
#ifndef DATEBOOKWEEKLST
#define DATEBOOKWEEKLST
#include <qwidget.h>
#include <qdatetime.h>
#include <qpe/event.h>
#include <qlabel.h>
#include <qscrollview.h>
#include "datebookweeklstheader.h"
#include "datebookweeklstdayhdr.h"
#include <opie2/oclickablelabel.h>
class QDateTime;
class DateBookDB;
+class DateBookDBHoliday;
class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase
{
Q_OBJECT
public:
DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
- WFlags fl = 0 );
+ WFlags fl = 0 );
~DateBookWeekLstHeader();
void setDate(const QDate &d);
public slots:
- void nextWeek();
- void prevWeek();
- void nextMonth();
- void prevMonth();
- void pickDate();
- void setDate(int y, int m, int d);
+ void nextWeek();
+ void prevWeek();
+ void nextMonth();
+ void prevMonth();
+ void pickDate();
+ void setDate(int y, int m, int d);
signals:
- void dateChanged(QDate &newdate);
- void setDbl(bool on);
+ void dateChanged(QDate &newdate);
+ void setDbl(bool on);
private:
- QDate date;
-// bool onMonday;
- bool bStartOnMonday;
+ QDate date;
+// bool onMonday;
+ bool bStartOnMonday;
};
class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
{
Q_OBJECT
public:
DateBookWeekLstDayHdr(const QDate &d, bool onM,
- QWidget* parent = 0, const char* name = 0,
- WFlags fl = 0 );
+ QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0 );
public slots:
void showDay();
void newEvent();
signals:
void showDate(int y, int m, int d);
void addEvent(const QDateTime &start, const QDateTime &stop,
- const QString &str, const QString &location);
+ const QString &str, const QString &location);
private:
QDate date;
};
class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel
{
Q_OBJECT
public:
DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1,
- QWidget* parent = 0, const char* name = 0,
- WFlags fl = 0);
+ QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0);
signals:
void editEvent(const Event &e);
void duplicateEvent(const Event &e);
void removeEvent(const Event &e);
void beamEvent(const Event &e);
void redraw();
private slots:
void editMe();
void duplicateMe();
void deleteMe();
void beamMe();
private:
const EffectiveEvent event;
QPopupMenu* popmenue;
protected:
void mousePressEvent( QMouseEvent *e );
};
class DateBookWeekLstView: public QWidget
{
Q_OBJECT
public:
DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM,
- QWidget* parent = 0, const char* name = 0,
- WFlags fl = 0 );
+ QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0 );
~DateBookWeekLstView();
signals:
- void editEvent(const Event &e);
- void duplicateEvent(const Event &e);
- void removeEvent(const Event &e);
- void beamEvent(const Event &e);
- void redraw();
- void showDate(int y, int m, int d);
- void addEvent(const QDateTime &start, const QDateTime &stop,
- const QString &str, const QString &location);
+ void editEvent(const Event &e);
+ void duplicateEvent(const Event &e);
+ void removeEvent(const Event &e);
+ void beamEvent(const Event &e);
+ void redraw();
+ void showDate(int y, int m, int d);
+ void addEvent(const QDateTime &start, const QDateTime &stop,
+ const QString &str, const QString &location);
private:
- bool bStartOnMonday;
+ bool bStartOnMonday;
protected slots:
- void keyPressEvent(QKeyEvent *);
+ void keyPressEvent(QKeyEvent *);
};
class DateBookWeekLstDblView: public QWidget {
Q_OBJECT
public:
DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
- QValueList<EffectiveEvent> &ev2,
- QDate &d, bool onM,
- QWidget* parent = 0, const char* name = 0,
- WFlags fl = 0 );
+ QValueList<EffectiveEvent> &ev2,
+ QDate &d, bool onM,
+ QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0 );
signals:
void editEvent(const Event &e);
void duplicateEvent(const Event &e);
void removeEvent(const Event &e);
void beamEvent(const Event &e);
void redraw();
void showDate(int y, int m, int d);
void addEvent(const QDateTime &start, const QDateTime &stop,
- const QString &str, const QString &location);
+ const QString &str, const QString &location);
};
class DateBookWeekLst : public QWidget
{
Q_OBJECT
public:
- DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB,
- QWidget *parent = 0,
- const char *name = 0 );
+ DateBookWeekLst( bool ampm, bool onM, DateBookDBHoliday *newDB,
+ QWidget *parent = 0,
+ const char *name = 0 );
~DateBookWeekLst();
void setDate( int y, int w );
void setDate(const QDate &d );
int week() const { return _week; };
QDate date();
QDate weekDate() const;
public slots:
void redraw();
void dateChanged(QDate &date);
protected slots:
void keyPressEvent(QKeyEvent *);
void setDbl(bool on);
signals:
- void showDate(int y, int m, int d);
- void addEvent(const QDateTime &start, const QDateTime &stop,
- const QString &str, const QString &location);
- void editEvent(const Event &e);
- void duplicateEvent(const Event &e);
- void removeEvent(const Event &e);
- void beamEvent(const Event &e);
+ void showDate(int y, int m, int d);
+ void addEvent(const QDateTime &start, const QDateTime &stop,
+ const QString &str, const QString &location);
+ void editEvent(const Event &e);
+ void duplicateEvent(const Event &e);
+ void removeEvent(const Event &e);
+ void beamEvent(const Event &e);
private:
- DateBookDB *db;
+ DateBookDBHoliday *db;
int startTime;
bool ampm;
bool bStartOnMonday;
bool dbl;
- QDate bdate;
+ QDate bdate;
int year, _week,dow;
DateBookWeekLstHeader *header;
QWidget *view;
QVBoxLayout *layout;
QScrollView *scroll;
void getEvents();
};
#endif