summaryrefslogtreecommitdiff
path: root/core
authorhakan <hakan>2002-03-09 11:39:21 (UTC)
committer hakan <hakan>2002-03-09 11:39:21 (UTC)
commit603e969bb8cef91534a1785e27106ba71eb03ba6 (patch) (side-by-side diff)
tree20642ed29acb08ab0cecc1dffd1d63baa8914ae2 /core
parent3d03d0e3f679578080bbbf7d8b7f9eba1b9560db (diff)
downloadopie-603e969bb8cef91534a1785e27106ba71eb03ba6.zip
opie-603e969bb8cef91534a1785e27106ba71eb03ba6.tar.gz
opie-603e969bb8cef91534a1785e27106ba71eb03ba6.tar.bz2
Added a WeekLst view showing an entire week and appointment descriptions and made default view configurable
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/clickablelabel.cpp31
-rw-r--r--core/pim/datebook/clickablelabel.h20
-rw-r--r--core/pim/datebook/datebook.cpp122
-rw-r--r--core/pim/datebook/datebook.h8
-rw-r--r--core/pim/datebook/datebook.pro38
-rw-r--r--core/pim/datebook/datebookweeklst.cpp314
-rw-r--r--core/pim/datebook/datebookweeklst.h131
-rw-r--r--core/pim/datebook/datebookweeklstdayhdr.ui149
-rw-r--r--core/pim/datebook/datebookweeklstheader.ui238
-rw-r--r--core/pim/datebook/dateentry.ui4
-rw-r--r--core/pim/datebook/dateentryimpl.cpp8
11 files changed, 1028 insertions, 35 deletions
diff --git a/core/pim/datebook/clickablelabel.cpp b/core/pim/datebook/clickablelabel.cpp
new file mode 100644
index 0000000..6912c34
--- a/dev/null
+++ b/core/pim/datebook/clickablelabel.cpp
@@ -0,0 +1,31 @@
+#include "clickablelabel.h"
+
+ClickableLabel::ClickableLabel(QWidget* parent = 0,
+ const char* name = 0,
+ WFlags fl = 0) :
+ QLabel(parent,name,fl)
+{
+ setFrameShape(NoFrame);
+ setFrameShadow(Sunken);
+}
+
+void ClickableLabel::mousePressEvent( QMouseEvent *e ) {
+ setFrameShape(Panel);
+ repaint();
+}
+
+void ClickableLabel::mouseReleaseEvent( QMouseEvent *e ) {
+ setFrameShape(NoFrame);
+ repaint();
+ if (rect().contains(e->pos())) {
+ emit clicked();
+ }
+}
+
+void ClickableLabel::mouseMoveEvent( QMouseEvent *e ) {
+ if (rect().contains(e->pos())) {
+ setFrameShape(Panel);
+ } else {
+ setFrameShape(NoFrame);
+ }
+}
diff --git a/core/pim/datebook/clickablelabel.h b/core/pim/datebook/clickablelabel.h
new file mode 100644
index 0000000..b6d33ad
--- a/dev/null
+++ b/core/pim/datebook/clickablelabel.h
@@ -0,0 +1,20 @@
+#ifndef CLICKABLELABEL
+#define CLICKABLELABEL
+
+#include <qlabel.h>
+
+class ClickableLabel: public QLabel
+{
+ Q_OBJECT
+public:
+ ClickableLabel(QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0);
+ protected:
+ void mousePressEvent( QMouseEvent *e );
+ void mouseReleaseEvent( QMouseEvent *e );
+ void mouseMoveEvent( QMouseEvent *e );
+ signals:
+ void clicked();
+};
+
+#endif
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index e8d808f..9880e2d 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -26,6 +26,7 @@
#include "datebookday.h"
#include "datebooksettings.h"
#include "datebookweek.h"
+#include "datebookweeklst.h"
#include "dateentryimpl.h"
#include <qpe/datebookmonth.h>
@@ -69,6 +70,7 @@
#define DAY 1
#define WEEK 2
+#define WEEKLST 4
#define MONTH 3
@@ -90,6 +92,14 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
setToolBarsMovable( FALSE );
+ views = new QWidgetStack( this );
+ setCentralWidget( views );
+
+ dayView = 0;
+ weekView = 0;
+ weekLstView = 0;
+ monthView = 0;
+
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
@@ -124,12 +134,21 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
a->setToggleAction( TRUE );
a->setOn( TRUE );
dayAction = a;
+
a = new QAction( tr( "Week" ), Resource::loadPixmap( "week" ), QString::null, 0, g, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( viewWeek() ) );
a->addTo( sub_bar );
a->addTo( view );
a->setToggleAction( TRUE );
weekAction = a;
+
+ a = new QAction( tr( "WeekLst" ), Resource::loadPixmap( "weeklst" ), QString::null, 0, g, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( viewWeekLst() ) );
+ a->addTo( sub_bar );
+ a->addTo( view );
+ a->setToggleAction( TRUE );
+ weekLstAction = a;
+
a = new QAction( tr( "Month" ), Resource::loadPixmap( "month" ), QString::null, 0, g, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( viewMonth() ) );
a->addTo( sub_bar );
@@ -145,33 +164,53 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
a->addTo( settings );
- views = new QWidgetStack( this );
- setCentralWidget( views );
-
- dayView = 0;
- weekView = 0;
- monthView = 0;
+ QPopupMenu *default_view = new QPopupMenu(this);
+ settings->insertItem( tr( "Default View" ),default_view );
+ default_view->setCheckable(TRUE);
- viewDay();
+
+ Config config("DateBook");
+ config.setGroup("Main");
+ int current=config.readNumEntry("defaultview", DAY);
+
+ QActionGroup *ag = new QActionGroup(this);
+ a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true );
+ if (current==DAY) a->setOn(true), viewDay();
+ ag->insert(a);
+ a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true );
+ if (current==WEEK) a->setOn(true), viewWeek();
+ ag->insert(a);
+ a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true );
+ if (current==WEEKLST) a->setOn(true), viewWeekLst();
+ ag->insert(a);
+ a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true );
+ if (current==MONTH) a->setOn(true), viewMonth();
+ ag->insert(a);
+
+ ag->addTo(default_view);
+ connect(ag, SIGNAL( selected ( QAction * ) ),
+ this, SLOT( newDefaultView(QAction *) )
+ );
+
connect( qApp, SIGNAL(clockChanged(bool)),
this, SLOT(changeClock(bool)) );
connect( qApp, SIGNAL(weekChanged(bool)),
this, SLOT(changeWeek(bool)) );
-
+
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
this, SLOT(appMessage(const QCString&, const QByteArray&)) );
#endif
-
+
// listen on QPE/System
#if defined(Q_WS_QWS)
#if !defined(QT_NO_COP)
QCopChannel *channel = new QCopChannel( "QPE/System", this );
connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(receive(const QCString&, const QByteArray&)) );
+ this, SLOT(receive(const QCString&, const QByteArray&)) );
#endif
#endif
-
+
qDebug("done t=%d", t.elapsed() );
}
@@ -264,6 +303,8 @@ QDate DateBook::currentDate()
d = dayView->date();
} else if ( weekView && views->visibleWidget() == weekView ) {
d = weekView->date();
+ } else if ( weekLstView && views->visibleWidget() == weekLstView ) {
+ d = weekLstView->date();
} else if ( monthView && views->visibleWidget() == monthView ) {
d = monthView->selectedDate();
}
@@ -291,6 +332,15 @@ void DateBook::viewWeek()
weekView->redraw();
}
+void DateBook::viewWeekLst() {
+ initWeekLst();
+ weekLstAction->setOn( TRUE );
+ QDate d=currentDate();
+ weekLstView->setDate(d);
+ views->raiseWidget( weekLstView );
+ weekLstView->redraw();
+}
+
void DateBook::viewMonth()
{
initMonth();
@@ -331,7 +381,8 @@ void DateBook::editEvent( const Event &e )
QString error = checkEvent(newEv);
if (!error.isNull()) {
if (QMessageBox::warning(this, "error box",
- error, "Fix it", "Continue", 0, 0, 1) == 0)
+ error, "Fix it", "Continue",
+ 0, 0, 1) == 0)
continue;
}
db->editEvent(e, newEv);
@@ -401,7 +452,7 @@ void DateBook::initWeek()
weekView->setStartViewTime( startTime );
views->addWidget( weekView, WEEK );
connect( weekView, SIGNAL( showDate( int, int, int ) ),
- this, SLOT( showDay( int, int, int ) ) );
+ this, SLOT( showDay( int, int, int ) ) );
connect( this, SIGNAL( newEvent() ),
weekView, SLOT( redraw() ) );
}
@@ -414,7 +465,7 @@ void DateBook::initWeek()
QDate d = QDate( yearNumber, 12, 31 );
calcWeek( d, totWeeks, yearNumber, onMonday );
-
+
while ( totWeeks == 1 ) {
d = d.addDays( -1 );
calcWeek( d, totWeeks, yearNumber, onMonday );
@@ -422,6 +473,28 @@ void DateBook::initWeek()
if ( totWeeks != weekView->totalWeeks() )
weekView->setTotalWeeks( totWeeks );
}
+void DateBook::initWeekLst() {
+ if ( !weekLstView ) {
+ weekLstView = new DateBookWeekLst( ampm, onMonday, db,
+ views, "weeklst view" );
+ views->addWidget( weekLstView, WEEKLST );
+
+ //weekLstView->setStartViewTime( startTime );
+ connect( weekLstView, SIGNAL( showDate( int, int, int ) ),
+ this, SLOT( showDay( int, int, int ) ) );
+ connect( weekLstView, SIGNAL( addEvent( const QDateTime &,
+ const QDateTime &,
+ const QString & ) ),
+ this, SLOT( slotNewEntry( const QDateTime &,
+ const QDateTime &,
+ const QString & ) ) );
+ connect( this, SIGNAL( newEvent() ),
+ weekLstView, SLOT( redraw() ) );
+ connect( weekLstView, SIGNAL( editEvent( const Event & ) ),
+ this, SLOT( editEvent( const Event & ) ) );
+ }
+}
+
void DateBook::initMonth()
{
@@ -444,7 +517,7 @@ void DateBook::loadSettings()
ampm = config.readBoolEntry( "AMPM", TRUE );
onMonday = config.readBoolEntry( "MONDAY" );
}
-
+
{
Config config("DateBook");
config.setGroup("Main");
@@ -464,6 +537,18 @@ void DateBook::saveSettings()
configDB.writeEntry("presettime",presetTime);
}
+void DateBook::newDefaultView(QAction *a) {
+ int val=DAY;
+ if (a->text() == "Day") val=DAY;
+ if (a->text() == "Week") val=WEEK;
+ if (a->text() == "WeekLst") val=WEEKLST;
+ if (a->text() == "Month") val=MONTH;
+
+ Config configDB( "DateBook" );
+ configDB.setGroup( "Main" );
+ configDB.writeEntry("defaultview",val);
+}
+
void DateBook::appMessage(const QCString& msg, const QByteArray& data)
{
bool needShow = FALSE;
@@ -536,6 +621,8 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data)
if ( cur == dayView )
viewWeek();
else if ( cur == weekView )
+ viewWeekLst();
+ else if ( cur == weekLstView )
viewMonth();
else if ( cur == monthView )
viewDay();
@@ -590,6 +677,7 @@ void DateBook::changeClock( bool newClock )
// repaint the affected objects...
if (dayView) dayView->redraw();
if (weekView) weekView->redraw();
+ if (weekLstView) weekLstView->redraw();
}
void DateBook::changeWeek( bool m )
@@ -660,7 +748,9 @@ void DateBook::slotNewEventFromKey( const QString &str )
start.setTime( QTime( 10, 0 ) );
end.setTime( QTime( 12, 0 ) );
}
-
+ slotNewEntry(start, end, str);
+}
+void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) {
// argh! This really needs to be encapsulated in a class
// or function.
QDialog newDlg( this, 0, TRUE );
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index 44627bb..fcdbfec 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -28,6 +28,7 @@ class QAction;
class QWidgetStack;
class DateBookDay;
class DateBookWeek;
+class DateBookWeekLst;
class DateBookMonth;
class Event;
class QDate;
@@ -57,7 +58,9 @@ public slots:
private slots:
void fileNew();
+ void slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str);
void slotSettings();
+ void newDefaultView(QAction *a);
void slotToday(); // view today
void changeClock( bool newClock );
void changeWeek( bool newDay );
@@ -69,6 +72,7 @@ private slots:
void viewDay();
void viewWeek();
+ void viewWeekLst();
void viewMonth();
void showDay( int y, int m, int d );
@@ -85,6 +89,7 @@ private:
void addEvent( const Event &e );
void initDay();
void initWeek();
+ void initWeekLst();
void initMonth();
void loadSettings();
void saveSettings();
@@ -95,7 +100,8 @@ private:
DateBookDay *dayView;
DateBookWeek *weekView;
DateBookMonth *monthView;
- QAction *dayAction, *weekAction, *monthAction;
+ DateBookWeekLst *weekLstView;
+ QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
bool aPreset; // have everything set to alarm?
int presetTime; // the standard time for the alarm
int startTime;
diff --git a/core/pim/datebook/datebook.pro b/core/pim/datebook/datebook.pro
index fae5d2b..bbe07af 100644
--- a/core/pim/datebook/datebook.pro
+++ b/core/pim/datebook/datebook.pro
@@ -3,29 +3,35 @@ CONFIG += qt warn_on release
DESTDIR = $(OPIEDIR)/bin
HEADERS = datebookday.h \
- datebook.h \
- dateentryimpl.h \
- datebookdayheaderimpl.h \
- datebooksettings.h \
- datebookweek.h \
- datebookweekheaderimpl.h \
- repeatentry.h
+ datebook.h \
+ dateentryimpl.h \
+ datebookdayheaderimpl.h \
+ datebooksettings.h \
+ datebookweek.h \
+ datebookweeklst.h \
+ datebookweekheaderimpl.h \
+ repeatentry.h \
+ clickablelabel.h
SOURCES = main.cpp \
- datebookday.cpp \
- datebook.cpp \
- dateentryimpl.cpp \
- datebookdayheaderimpl.cpp \
- datebooksettings.cpp \
- datebookweek.cpp \
- datebookweekheaderimpl.cpp \
- repeatentry.cpp
+ datebookday.cpp \
+ datebook.cpp \
+ dateentryimpl.cpp \
+ datebookdayheaderimpl.cpp \
+ datebooksettings.cpp \
+ datebookweek.cpp \
+ datebookweeklst.cpp \
+ datebookweekheaderimpl.cpp \
+ repeatentry.cpp \
+ clickablelabel.cpp
INTERFACES = dateentry.ui \
datebookdayheader.ui \
datebooksettingsbase.ui \
datebookweekheader.ui \
- repeatentrybase.ui
+ datebookweeklstheader.ui \
+ datebookweeklstdayhdr.ui \
+ repeatentrybase.ui
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp
new file mode 100644
index 0000000..05e36be
--- a/dev/null
+++ b/core/pim/datebook/datebookweeklst.cpp
@@ -0,0 +1,314 @@
+#include "datebookweeklst.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/datebookmonth.h>
+
+#include <qdatetime.h>
+#include <qheader.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qpopupmenu.h>
+#include <qtimer.h>
+#include <qstyle.h>
+#include <qtoolbutton.h>
+#include <qvbox.h>
+#include <qsizepolicy.h>
+#include <qabstractlayout.h>
+#include <qtl.h>
+
+bool calcWeek(const QDate &d, int &week, int &year,
+ bool startOnMonday = false);
+
+DateBookWeekLstHeader::DateBookWeekLstHeader(bool onM, QWidget* parent,
+ const char* name, WFlags fl)
+ : DateBookWeekLstHeaderBase(parent, name, fl)
+{
+ setBackgroundMode( PaletteButton );
+ labelDate->setBackgroundMode( PaletteButton );
+ labelWeek->setBackgroundMode( PaletteButton );
+ forward->setBackgroundMode( PaletteButton );
+ back->setBackgroundMode( PaletteButton );
+ DateBookWeekLstHeaderBaseLayout->setSpacing(0);
+ DateBookWeekLstHeaderBaseLayout->setMargin(0);
+ //setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
+ setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
+
+ connect(back, SIGNAL(clicked()), this, SLOT(prevWeek()));
+ connect(forward, SIGNAL(clicked()), this, SLOT(nextWeek()));
+ connect(labelWeek, SIGNAL(clicked()), this, SLOT(pickDate()));
+ onMonday=onM;
+}
+DateBookWeekLstHeader::~DateBookWeekLstHeader(){}
+void DateBookWeekLstHeader::setDate(QDate d) {
+ date=d;
+
+ int year,week;
+ calcWeek(d,week,year,onMonday);
+ labelWeek->setText("W: " + QString::number(week));
+
+ 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()) );
+ emit dateChanged(year,week);
+}
+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(labelWeek->pos()+QPoint(0,labelWeek->height())));
+ picker->setFocus();
+}
+void DateBookWeekLstHeader::setDate(int y, int m, int d) {
+ QDate new_date(y,m,d);
+ setDate(new_date);
+}
+
+void DateBookWeekLstHeader::nextWeek() {
+ setDate(date.addDays(7));
+}
+void DateBookWeekLstHeader::prevWeek() {
+ setDate(date.addDays(-7));
+}
+
+DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool onM,
+ QWidget* parent = 0,
+ const char* name = 0,
+ WFlags fl = 0 )
+ : DateBookWeekLstDayHdrBase(parent, name, fl) {
+
+ date=d;
+
+ static const char *wdays="MTWTFSS";
+ char day=wdays[d.dayOfWeek()-1];
+
+ label->setText( 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()));
+}
+
+void DateBookWeekLstDayHdr::showDay() {
+ 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,"");
+}
+DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev,
+ QWidget* parent = 0,
+ const char* name = 0,
+ WFlags fl = 0) :
+ ClickableLabel(parent,name,fl),
+ event(ev)
+{
+ char s[10];
+ if ( ev.startDate() != ev.date() ) { // multiday event (not first day)
+ if ( ev.endDate() == ev.date() ) { // last day
+ strcpy(s, "__|__");
+ } else {
+ strcpy(s, " |---");
+ }
+ } else {
+ sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute());
+ }
+ setText(QString(s) + " " + ev.description());
+ connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
+}
+void DateBookWeekLstEvent::editMe() {
+ emit editEvent(event.event());
+}
+
+
+DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
+ QDate &d, bool onM,
+ QWidget* parent,
+ const char* name, WFlags fl)
+ : QWidget( parent, name, fl )
+{
+ onMonday=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 (onMonday)
+ 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;
+ }
+
+ for (int i=0; i<7; i++) {
+ // Header
+ DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i),
+ onMonday,this);
+ connect(hdr, SIGNAL(showDate(int,int,int)),
+ this, SIGNAL(showDate(int,int,int)));
+ connect(hdr, SIGNAL(addEvent(const QDateTime &,
+ const QDateTime &,
+ const QString &)),
+ this, SIGNAL(addEvent(const QDateTime &,
+ const QDateTime &,
+ const QString &)));
+ layout->addWidget(hdr);
+
+ // Events
+ while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
+ DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,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();}
+
+DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB,
+ QWidget *parent,
+ const char *name )
+ : QWidget( parent, name ),
+ db( newDB ),
+ startTime( 0 ),
+ ampm( ap ),
+ onMonday(onM)
+{
+ setFocusPolicy(StrongFocus);
+ layout = new QVBoxLayout( this );
+ layout->setMargin(0);
+
+ header=new DateBookWeekLstHeader(onM, this);
+ layout->addWidget( header );
+ connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int)));
+
+ scroll=new QScrollView(this);
+ //scroll->setVScrollBarMode(QScrollView::AlwaysOn);
+ //scroll->setHScrollBarMode(QScrollView::AlwaysOff);
+ scroll->setResizePolicy(QScrollView::AutoOneFit);
+ layout->addWidget(scroll);
+
+ view=NULL;
+}
+
+
+void DateBookWeekLst::setDate( QDate &d ) {
+ int w,y;
+ calcWeek(d,w,y,onMonday);
+ year=y;
+ _week=w;
+ header->setDate(date());
+}
+void DateBookWeekLst::redraw() {getEvents();}
+
+QDate DateBookWeekLst::date() const {
+ QDate d;
+ d.setYMD(year,1,1);
+
+ int dow= d.dayOfWeek();
+ if (!onMonday)
+ if (dow==7) dow=1;
+ else dow++;
+
+ d=d.addDays( (_week-1)*7 - dow + 1 );
+ return d;
+}
+
+void DateBookWeekLst::getEvents() {
+ QDate start = date();
+ QDate stop = start.addDays(6);
+ QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
+
+ if (view) delete view;
+ view=new DateBookWeekLstView(el,start,onMonday,scroll);
+
+ connect (view, SIGNAL(editEvent(const Event &)),
+ this, SIGNAL(editEvent(const Event &)));
+ connect (view, SIGNAL(showDate(int,int,int)),
+ this, SIGNAL(showDate(int,int,int)));
+ connect (view, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
+ const QString &)),
+ this, SIGNAL(addEvent(const QDateTime &, const QDateTime &,
+ const QString &)));
+
+ scroll->addChild(view);
+ view->show();
+ scroll->updateScrollBars();
+}
+
+void DateBookWeekLst::dateChanged(int y, int w) {
+ year=y;
+ _week=w;
+ 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();
+ }
+}
+
diff --git a/core/pim/datebook/datebookweeklst.h b/core/pim/datebook/datebookweeklst.h
new file mode 100644
index 0000000..d2a07cc
--- a/dev/null
+++ b/core/pim/datebook/datebookweeklst.h
@@ -0,0 +1,131 @@
+#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 "clickablelabel.h"
+
+class QDateTime;
+class DateBookDB;
+
+class DateBookWeekLstHeader: public DateBookWeekLstHeaderBase
+{
+ Q_OBJECT
+public:
+ DateBookWeekLstHeader(bool onM, QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0 );
+ ~DateBookWeekLstHeader();
+ void setDate(QDate d);
+
+public slots:
+ void nextWeek();
+ void prevWeek();
+ void pickDate();
+ void setDate(int y, int m, int d);
+signals:
+ void dateChanged(int y, int w);
+private:
+ QDate date;
+ bool onMonday;
+};
+
+class DateBookWeekLstDayHdr: public DateBookWeekLstDayHdrBase
+{
+ Q_OBJECT
+public:
+ DateBookWeekLstDayHdr(const QDate &d, bool onM,
+ 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);
+private:
+ QDate date;
+};
+
+class DateBookWeekLstEvent: public ClickableLabel
+{
+ Q_OBJECT
+public:
+ DateBookWeekLstEvent(const EffectiveEvent &ev,
+ QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0);
+signals:
+ void editEvent(const Event &e);
+private slots:
+ void editMe();
+private:
+ const EffectiveEvent event;
+};
+
+class DateBookWeekLstView: public QWidget
+{
+ Q_OBJECT
+public:
+ DateBookWeekLstView(QValueList<EffectiveEvent> &ev, QDate &d, bool onM,
+ QWidget* parent = 0, const char* name = 0,
+ WFlags fl = 0 );
+ ~DateBookWeekLstView();
+signals:
+ void editEvent(const Event &e);
+ void showDate(int y, int m, int d);
+ void addEvent(const QDateTime &start, const QDateTime &stop,
+ const QString &str);
+private:
+ bool onMonday;
+protected slots:
+ void keyPressEvent(QKeyEvent *);
+};
+
+class DateBookWeekLst : public QWidget
+{
+ Q_OBJECT
+
+public:
+ DateBookWeekLst( bool ampm, bool onM, DateBookDB *newDB,
+ QWidget *parent = 0,
+ const char *name = 0 );
+ void setDate( int y, int w );
+ void setDate( QDate &d );
+ int week() const { return _week; };
+ QDate date() const;
+
+public slots:
+ void redraw();
+ void dateChanged(int y, int w);
+protected slots:
+ void keyPressEvent(QKeyEvent *);
+
+signals:
+ void showDate(int y, int m, int d);
+ void addEvent(const QDateTime &start, const QDateTime &stop,
+ const QString &str);
+ void editEvent(const Event &e);
+
+private:
+ DateBookDB *db;
+ int startTime;
+ bool ampm;
+ bool onMonday;
+ int year, _week;
+ DateBookWeekLstHeader *header;
+ DateBookWeekLstView *view;
+ QVBoxLayout *layout;
+ QScrollView *scroll;
+
+ void getEvents();
+};
+
+#endif
+
diff --git a/core/pim/datebook/datebookweeklstdayhdr.ui b/core/pim/datebook/datebookweeklstdayhdr.ui
new file mode 100644
index 0000000..3b88495
--- a/dev/null
+++ b/core/pim/datebook/datebookweeklstdayhdr.ui
@@ -0,0 +1,149 @@
+<!DOCTYPE UI><UI>
+<class>DateBookWeekLstDayHdrBase</class>
+<widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>DateBookWeekLstDayHdrBase</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>106</y>
+ <width>621</width>
+ <height>5</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Form1</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>Line</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Line1</cstring>
+ </property>
+ <property stdset="1">
+ <name>minimumSize</name>
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>32767</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget>
+ <class>ClickableLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>label</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ </widget>
+ <widget>
+ <class>Line</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Line1_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>minimumSize</name>
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>maximumSize</name>
+ <size>
+ <width>32767</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget>
+ <class>ClickableLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>add</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ </widget>
+ </hbox>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>ClickableLabel</class>
+ <header location="local">clickablelabel.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image>
+ <name>image0</name>
+ <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data>
+ </image>
+</images>
+</UI>
diff --git a/core/pim/datebook/datebookweeklstheader.ui b/core/pim/datebook/datebookweeklstheader.ui
new file mode 100644
index 0000000..666e896
--- a/dev/null
+++ b/core/pim/datebook/datebookweeklstheader.ui
@@ -0,0 +1,238 @@
+<!DOCTYPE UI><UI>
+<class>DateBookWeekLstHeaderBase</class>
+<widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>DateBookWeekLstHeaderBase</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>51</y>
+ <width>535</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Form2</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QToolButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>back</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string></string>
+ </property>
+ <property stdset="1">
+ <name>pixmap</name>
+ <pixmap>image0</pixmap>
+ </property>
+ <property stdset="1">
+ <name>autoRepeat</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>autoRaise</name>
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer1_3</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget>
+ <class>QToolButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>labelWeek</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>W: 00,00</string>
+ </property>
+ <property stdset="1">
+ <name>autoRaise</name>
+ <bool>false</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer1</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>labelDate</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>7</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>font</name>
+ <font>
+ <bold>1</bold>
+ </font>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>00 Jan-00 Jan</string>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>AlignCenter</set>
+ </property>
+ <property>
+ <name>hAlign</name>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer1_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget>
+ <class>QToolButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>forward</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string></string>
+ </property>
+ <property stdset="1">
+ <name>pixmap</name>
+ <pixmap>image1</pixmap>
+ </property>
+ <property stdset="1">
+ <name>autoRepeat</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>autoRaise</name>
+ <bool>true</bool>
+ </property>
+ </widget>
+ </hbox>
+</widget>
+<images>
+ <image>
+ <name>image0</name>
+ <data format="XPM.GZ" length="582">789c6dcfcd4e843010c0f13b4fd1d01b31bb6cb325211b1f41e3d1c4789876a60bcbd7aeae07637c773b6d5985d870e0f7ef50605b88e7a707516cb3f72b5c5b2b6c036fa2c08f61f87c79bdffcaf2dd5ef0558b5d7e97e51b61c5e33412df4b7f2fcbb09896a94ab557817063cd744cad74a915734aac35308740d018d9332d5ab0c8ec1229f2c2448d156a661b489ee1ab4e4cf2a08a790e24020abb0dd355442eec8e914e45526215790c749e8e89891069125de466b1fe14295705ccaa5863e2d05cc01894925b2a7e8217dd8a631eb169fd509af10fd1a9ebfbdf32008d9d0c07cd274f70ee162773ba2cdfee935c977ffe6b2edf87ec07796f81cd</data>
+ </image>
+ <image>
+ <name>image1</name>
+ <data format="XPM.GZ" length="627">789c7dcfc94ec3301006e07b9ec28a6f114a13cbb1a8108f00e28884387819676993340b07847877329ea8697a60ec83bfdf232f8784bdbfbdb0e4104db39e6bcb6ca54796b8afb6fdfef87cfe89e25cb2650ac1f2f8218a5366d96bdf01aef9b2e65928a4458a0c07b25c29890352e63293e19c53a0968f52230159e8c22981744495133552097554a1f982b4ce6aeb9013d215165c81ec894e109b4070ca85378f2b35f18c04050214b20d04d010762ba457003eecd6442f88f34a45f4817ea147762b35d1acf4c47457d784737d9f18ebee1363614bf852c6f812b6c460f90abb6e93ba694ed7c49fdbaeee2f76b83da71ba772e0db5d9ccf4b07dfdd5e858edd9b2948fff9d796fc3e457f660e8d47</data>
+ </image>
+</images>
+</UI>
diff --git a/core/pim/datebook/dateentry.ui b/core/pim/datebook/dateentry.ui
index 0c363a4..eac4e23 100644
--- a/core/pim/datebook/dateentry.ui
+++ b/core/pim/datebook/dateentry.ui
@@ -94,7 +94,7 @@
<item>
<property>
<name>text</name>
- <string>(None)</string>
+ <string></string>
</property>
</item>
<item>
@@ -161,7 +161,7 @@
<item>
<property>
<name>text</name>
- <string>(Unknown)</string>
+ <string></string>
</property>
</item>
<item>
diff --git a/core/pim/datebook/dateentryimpl.cpp b/core/pim/datebook/dateentryimpl.cpp
index 1122f79..b2e3e3a 100644
--- a/core/pim/datebook/dateentryimpl.cpp
+++ b/core/pim/datebook/dateentryimpl.cpp
@@ -41,6 +41,8 @@
#include <stdlib.h>
+#include <stdiostream.h>
+
/*
* Constructs a DateEntry which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
@@ -58,6 +60,7 @@ DateEntry::DateEntry( bool startOnMonday, const QDateTime &start,
{
init();
setDates(start,end);
+ setFocusProxy(comboDescription);
}
static void addOrPick( QComboBox* combo, const QString& t )
@@ -176,6 +179,7 @@ void DateEntry::init()
DateEntry::~DateEntry()
{
// no need to delete child widgets, Qt does it all for us
+ //cout << "Del: " << comboStart->currentText() << endl;
}
/*
@@ -270,6 +274,7 @@ void DateEntry::startTimeChanged( int index )
{
startTime = parseTime(comboStart->text(index),ampm);
changeEndCombo( index );
+ //cout << "Start: " << comboStart->currentText() << endl;
}
/*
* public slot
@@ -382,6 +387,9 @@ Event DateEntry::event()
if ( rp.type != Event::NoRepeat )
ev.setRepeat( TRUE, rp );
ev.setNotes( editNote->text() );
+
+ //cout << "Start: " << comboStart->currentText() << endl;
+
return ev;
}