summaryrefslogtreecommitdiff
authorerik <erik>2007-04-23 20:46:34 (UTC)
committer erik <erik>2007-04-23 20:46:34 (UTC)
commit34975323367e4a903886cd317b34192f1271a1f2 (patch) (side-by-side diff)
tree8898d9010cdb89b371e0bccdbf717f87359d8513
parentd38e40fe9ee475230425fa83e924c49e5946b87c (diff)
downloadopie-34975323367e4a903886cd317b34192f1271a1f2.zip
opie-34975323367e4a903886cd317b34192f1271a1f2.tar.gz
opie-34975323367e4a903886cd317b34192f1271a1f2.tar.bz2
Fix for bug 1844. The display of 12hour (AM/PM) time was broken. It was
because the views never bother to check. This fix incorporates the patch submitted by harlekin. Thanks!
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklst.cpp15
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklst.h1
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp16
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstdblview.h5
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp183
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstevent.h3
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstview.cpp18
-rw-r--r--core/pim/datebook/modules/weeklst/datebookweeklstview.h7
8 files changed, 140 insertions, 108 deletions
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
index b36bf6d..59f937f 100644
--- a/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
+++ b/core/pim/datebook/modules/weeklst/datebookweeklst.cpp
@@ -1,158 +1,167 @@
#include "namespace_hack.h"
#include "datebookweeklst.h"
#include "datebookweeklstheader.h"
#include "datebookweeklstview.h"
#include "datebookweeklstdblview.h"
#include "datebook.h"
#include <opie2/odebug.h>
#include <qpe/datebookmonth.h>
#include <qpe/config.h>
+#include <qpe/qpeapplication.h>
#include <qlayout.h>
#include <qtoolbutton.h>
using namespace Opie::Ui;
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);
dateset = false;
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);
m_CurrentView=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);
}
void DateBookWeekLst::setDate(const QDate &d) {
bdate=d;
header->setDate(d);
}
void DateBookWeekLst::setDbl(bool on) {
dbl=on;
bool displayed = false;
if (m_CurrentView) {
displayed = m_CurrentView->toggleDoubleView(on);
}
if (!displayed||dbl) {
getEvents();
}
}
-void DateBookWeekLst::redraw() {getEvents();}
+void DateBookWeekLst::redraw() {
+ getEvents();
+}
QDate DateBookWeekLst::date() {
return bdate;
}
// return the date at the beginning of the week...
// copied from DateBookWeek
QDate DateBookWeekLst::weekDate() const
{
QDate d=bdate;
// Calculate offset to first day of week.
int dayoffset=d.dayOfWeek();
if(bStartOnMonday) dayoffset--;
else if( dayoffset == 7 )
dayoffset = 0;
return d.addDays(-dayoffset);
}
void DateBookWeekLst::getEvents() {
if (!dateset) return;
QDate start = weekDate(); //date();
QDate stop = start.addDays(6);
QDate start2;
QValueList<EffectiveEvent> el = db->getEffectiveEvents(start, stop);
QValueList<EffectiveEvent> el2;
if (dbl) {
start2 = start.addDays(7);
stop = start2.addDays(6);
el2 = db->getEffectiveEvents(start2, stop);
}
if (!m_CurrentView) {
if (dbl) {
- m_CurrentView=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,scroll);
+ m_CurrentView=new DateBookWeekLstDblView(el,el2,start,bStartOnMonday,ampm,scroll);
} else {
- m_CurrentView=new DateBookWeekLstDblView(el,start,bStartOnMonday,scroll);
+ m_CurrentView=new DateBookWeekLstDblView(el,start,bStartOnMonday,ampm,scroll);
}
m_CurrentView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
connect (m_CurrentView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
connect (m_CurrentView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
connect (m_CurrentView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
connect (m_CurrentView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
connect (m_CurrentView, SIGNAL(redraw()), this, SLOT(redraw()));
connect (m_CurrentView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
connect (m_CurrentView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
+ connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
scroll->addChild(m_CurrentView);
} else {
if (dbl) {
m_CurrentView->setEvents(el,el2,start,bStartOnMonday);
} else {
m_CurrentView->setEvents(el,start,bStartOnMonday);
}
}
scroll->updateScrollBars();
}
+void DateBookWeekLst::slotClockChanged( bool ap ) {
+ ampm = ap;
+ getEvents();
+}
+
void DateBookWeekLst::dateChanged(QDate &newdate) {
dateset = true;
bdate=newdate;
odebug << "Date changed " << oendl;
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/modules/weeklst/datebookweeklst.h b/core/pim/datebook/modules/weeklst/datebookweeklst.h
index 505810b..53bed05 100644
--- a/core/pim/datebook/modules/weeklst/datebookweeklst.h
+++ b/core/pim/datebook/modules/weeklst/datebookweeklst.h
@@ -1,66 +1,67 @@
#ifndef DATEBOOKWEEKLST
#define DATEBOOKWEEKLST
#include <qpe/event.h>
#include <qwidget.h>
#include <qdatetime.h>
class DateBookDB;
class DateBookDBHoliday;
class DateBookWeekLstHeader;
class DateBookWeekLstEvent;
class DateBookWeekLstDblView;
class QVBoxLayout;
class QScrollView;
class DateBookWeekLst : public QWidget
{
Q_OBJECT
public:
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 slotClockChanged(bool);
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);
private:
DateBookDBHoliday *db;
int startTime;
bool ampm;
bool bStartOnMonday;
bool dbl;
QDate bdate;
int year, _week,dow;
DateBookWeekLstHeader *header;
QVBoxLayout *layout;
QScrollView *scroll;
DateBookWeekLstDblView*m_CurrentView;
bool dateset:1;
void getEvents();
};
#endif
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp
index 6389822..5182df1 100644
--- a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.cpp
@@ -1,131 +1,131 @@
#include "datebookweeklstdblview.h"
#include "datebookweeklstview.h"
#include <qlayout.h>
DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
QValueList<EffectiveEvent> &ev2,
- QDate &d, bool onM,
+ QDate &d, bool onM, bool showAmPm,
QWidget* parent,
const char* name, WFlags fl)
- : QWidget( parent, name, fl )
+ : QWidget( parent, name, fl ), ampm( showAmPm )
{
m_MainLayout = new QHBoxLayout( this );
leftView = 0;
rightView = 0;
setEvents(ev1,ev2,d,onM);
}
DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
- QDate &d, bool onM,
+ QDate &d, bool onM, bool showAmPm,
QWidget* parent,
const char* name, WFlags fl)
- : QWidget( parent, name, fl )
+ : QWidget( parent, name, fl ), ampm( showAmPm )
{
m_MainLayout = new QHBoxLayout( this );
leftView = 0;
rightView = 0;
setEvents(ev1,d,onM);
}
/* setting the variant with both views */
void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QValueList<EffectiveEvent> &ev2,QDate &d, bool onM)
{
setUpdatesEnabled(false);
if (!leftView) {
- leftView=new DateBookWeekLstView(ev1,d,onM,this);
+ leftView=new DateBookWeekLstView(ev1, d, onM, ampm, this);
m_MainLayout->addWidget(leftView);
connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw()));
connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
} else {
leftView->hide();
leftView->setEvents(ev1,d,onM);
}
if (!rightView) {
- rightView=new DateBookWeekLstView(ev2,d.addDays(7),onM,this);
+ rightView=new DateBookWeekLstView(ev2, d.addDays(7), onM, ampm, this);
m_MainLayout->addWidget(rightView);
connect (rightView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
connect (rightView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
connect (rightView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
connect (rightView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
connect (rightView, SIGNAL(redraw()), this, SIGNAL(redraw()));
connect (rightView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
connect (rightView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
} else {
rightView->hide();
rightView->setEvents(ev2,d.addDays(7),onM);
}
leftView->show();
rightView->show();
setUpdatesEnabled(true);
}
void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM)
{
if (!leftView) {
- leftView=new DateBookWeekLstView(ev1,d,onM,this);
+ leftView=new DateBookWeekLstView(ev1, d, onM, ampm, this);
m_MainLayout->addWidget(leftView);
connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw()));
connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
} else {
leftView->hide();
leftView->setEvents(ev1,d,onM);
}
leftView->show();
if (rightView) {
rightView->hide();
}
}
void DateBookWeekLstDblView::setRightEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM)
{
if (!rightView) {
- rightView=new DateBookWeekLstView(ev1,d,onM,this);
+ rightView=new DateBookWeekLstView(ev1, d, onM, ampm, this);
m_MainLayout->addWidget(rightView);
connect (leftView, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
connect (leftView, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
connect (leftView, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
connect (leftView, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
connect (leftView, SIGNAL(redraw()), this, SIGNAL(redraw()));
connect (leftView, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
connect (leftView, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
} else {
rightView->hide();
rightView->setEvents(ev1,d,onM);
}
rightView->show();
}
bool DateBookWeekLstDblView::toggleDoubleView(bool how)
{
if (rightView) {
if (how) rightView->show();
else rightView->hide();
return true;
}
return false;
}
DateBookWeekLstDblView::~DateBookWeekLstDblView()
{
}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h
index 808556e..9eb17e0 100644
--- a/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstdblview.h
@@ -1,48 +1,49 @@
#ifndef _DATEBOOKWEEKLSTDBLVIEW_H
#define _DATEBOOKWEEKLSTDBLVIEW_H
#include <qpe/event.h>
#include <qwidget.h>
#include <qvaluelist.h>
#include <qdatetime.h>
#include <qstring.h>
class DateBookWeekLstView;
class QHBoxLayout;
class DateBookWeekLstDblView: public QWidget {
Q_OBJECT
public:
DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
QValueList<EffectiveEvent> &ev2,
- QDate &d, bool onM,
+ QDate &d, bool onM, bool showAmPm,
QWidget* parent = 0, const char* name = 0,
WFlags fl = 0 );
DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1,
- QDate &d, bool onM,
+ QDate &d, bool onM, bool showAmPm,
QWidget* parent = 0, const char* name = 0,
WFlags fl = 0 );
virtual ~DateBookWeekLstDblView();
void setEvents(QValueList<EffectiveEvent> &ev1,QValueList<EffectiveEvent> &ev2,QDate &d, bool onM);
void setEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM);
void setRightEvents(QValueList<EffectiveEvent> &ev1,QDate &d, bool onM);
bool toggleDoubleView(bool how);
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);
protected:
QHBoxLayout*m_MainLayout;
DateBookWeekLstView *leftView,*rightView;
+ bool ampm;
};
#endif
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp
index 797f766..881e8f1 100644
--- a/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstevent.cpp
@@ -1,85 +1,98 @@
-#include "datebookweeklstevent.h"
-#include "datebooktypes.h"
-
-#include <opie2/odebug.h>
-
-#include <qpe/ir.h>
-
-#include <qstring.h>
-#include <qpopupmenu.h>
-
-DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &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 ) );
-}
-void DateBookWeekLstEvent::editMe() {
- 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() );
-}
-void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e )
-{
- if (!event.event().isValidUid()) {
- // this is just such a holiday event.
- return;
- }
- 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() ));
-}
+#include "datebookweeklstevent.h"
+#include "datebooktypes.h"
+
+#include <opie2/odebug.h>
+
+#include <qpe/ir.h>
+
+#include <qstring.h>
+#include <qpopupmenu.h>
+
+DateBookWeekLstEvent::DateBookWeekLstEvent(bool ap, const EffectiveEvent &ev,
+ int weeklistviewconfig,
+ QWidget* parent,
+ const char* name,
+ WFlags fl ) : OClickableLabel(parent,name,fl), event(ev), ampm(ap)
+{
+ // old values... lastday = "__|__", middle=" |---", Firstday="00:00",
+ QString s,start,middle,end,day;
+
+ odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl;
+ if(weeklistviewconfig==NORMAL) { // "Normal", only display start time.
+ if ( ampm ) {
+ int shour = ev.start().hour();
+ int smin = ev.start().minute();
+ if ( shour >= 12 ) {
+ if ( shour > 12 ) {
+ shour -= 12;
+ }
+ start.sprintf( "%.2d:%.2d PM", shour, smin );
+ day.sprintf("%.2d:%.2d PM",shour,smin);
+ } else {
+ if ( shour == 0 ) {
+ shour = 12;
+ }
+ start.sprintf( "%.2d:%.2d AM", shour, smin );
+ day.sprintf("%.2d:%.2d AM",shour,smin);
+ }
+ } else {
+ start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
+ day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute());
+ }
+ middle.sprintf(" |---");
+ end.sprintf("__|__");
+ } 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());
+}
+void DateBookWeekLstEvent::duplicateMe()
+{
+ emit duplicateEvent(event.event());
+}
+void DateBookWeekLstEvent::deleteMe()
+{
+ emit removeEvent(event.event());
+ emit redraw();
+}
+void DateBookWeekLstEvent::beamMe()
+{
+ emit beamEvent( event.event() );
+}
+void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e )
+{
+ if (!event.event().isValidUid()) {
+ // this is just such a holiday event.
+ return;
+ }
+ 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() ));
+}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstevent.h b/core/pim/datebook/modules/weeklst/datebookweeklstevent.h
index 77f6283..1e3cd5d 100644
--- a/core/pim/datebook/modules/weeklst/datebookweeklstevent.h
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstevent.h
@@ -1,34 +1,35 @@
#ifndef _DATEBOOKWEEKLSTEVENT_H
#define _DATEBOOKWEEKLSTEVENT_H
#include <opie2/oclickablelabel.h>
#include <qpe/event.h>
class DateBookWeekLstEvent: public Opie::Ui::OClickableLabel
{
Q_OBJECT
public:
- DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig =1,
+ DateBookWeekLstEvent(bool ampm, const EffectiveEvent &ev, int weeklistviewconfig =1,
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 );
+ bool ampm;
};
#endif
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp
index 82b9c6d..469a60a 100644
--- a/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstview.cpp
@@ -1,104 +1,106 @@
#include "datebookweeklstview.h"
#include "datebooktypes.h"
#include "datebookweeklstdayhdr.h"
#include "datebookweeklstheader.h"
#include "datebookweeklstevent.h"
#include <opie2/odebug.h>
#include <qpe/config.h>
+#include <qpe/qpeapplication.h>
#include <qlayout.h>
#include <qtl.h>
DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
- const QDate &d, bool onM,
+ const QDate &d, bool onM, bool showAmPm,
QWidget* parent,
const char* name, WFlags fl)
- : QWidget( parent, name, fl )
+ : QWidget( parent, name, fl ), ampm(showAmPm)
{
childs.clear();
m_MainLayout = new QVBoxLayout( this );
setEvents(ev,d,onM);
}
void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM)
{
QValueList<QObject*>::Iterator wIter;
for (wIter=childs.begin();wIter!=childs.end();++wIter) {
QObject*w = (*wIter);
delete w;
}
childs.clear();
setUpdatesEnabled(false);
// m_MainLayout->deleteAllItems();
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));
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++) {
QWidget*w = new QWidget(this);
w->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
w->setPalette(white);
QVBoxLayout * tlayout = new QVBoxLayout(w);
childs.append(w);
- // Header
+ // Header
DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,w);
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&)));
tlayout->addWidget(hdr);
+ connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
// 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,w);
+ DateBookWeekLstEvent *l=new DateBookWeekLstEvent(ampm,*it,weeklistviewconfig,w);
tlayout->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++;
}
tlayout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
m_MainLayout->addWidget(w);
-/*
- QSpacerItem * tmp = new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding);
- m_MainLayout->addItem(tmp);
-*/
}
setUpdatesEnabled(true);
}
+void DateBookWeekLstView::slotClockChanged( bool ap ) {
+ ampm = ap;
+}
+
DateBookWeekLstView::~DateBookWeekLstView()
{}
void DateBookWeekLstView::keyPressEvent(QKeyEvent *e)
{
e->ignore();
}
diff --git a/core/pim/datebook/modules/weeklst/datebookweeklstview.h b/core/pim/datebook/modules/weeklst/datebookweeklstview.h
index 3d47842..900101d 100644
--- a/core/pim/datebook/modules/weeklst/datebookweeklstview.h
+++ b/core/pim/datebook/modules/weeklst/datebookweeklstview.h
@@ -1,43 +1,48 @@
#ifndef _DATEBOOKWEEKLISTVIEW_H
#define _DATEBOOKWEEKLISTVIEW_H
#include <qpe/event.h>
#include <qwidget.h>
#include <qvaluelist.h>
#include <qstring.h>
#include <qdatetime.h>
class QKeyEvent;
class QVBoxLayout;
class DateBookWeekLstView: public QWidget
{
Q_OBJECT
public:
- DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, QWidget* parent = 0, const char* name = 0,
+ DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d,
+ bool onM, bool showAmPm, QWidget* parent = 0,
+ const char* name = 0,
WFlags fl = 0 );
~DateBookWeekLstView();
void setEvents(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM);
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);
+
protected:
bool bStartOnMonday;
+ bool ampm;
QValueList<QObject*> childs;
QVBoxLayout*m_MainLayout;
protected slots:
void keyPressEvent(QKeyEvent *);
+ void slotClockChanged( bool ap );
};
#endif