author | erik <erik> | 2007-04-23 20:46:34 (UTC) |
---|---|---|
committer | erik <erik> | 2007-04-23 20:46:34 (UTC) |
commit | 34975323367e4a903886cd317b34192f1271a1f2 (patch) (side-by-side diff) | |
tree | 8898d9010cdb89b371e0bccdbf717f87359d8513 | |
parent | d38e40fe9ee475230425fa83e924c49e5946b87c (diff) | |
download | opie-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!
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 @@ -11,4 +11,5 @@ #include <qpe/datebookmonth.h> #include <qpe/config.h> +#include <qpe/qpeapplication.h> #include <qlayout.h> @@ -69,5 +70,7 @@ void DateBookWeekLst::setDbl(bool on) { } -void DateBookWeekLst::redraw() {getEvents();} +void DateBookWeekLst::redraw() { + getEvents(); +} QDate DateBookWeekLst::date() { @@ -107,7 +110,7 @@ void DateBookWeekLst::getEvents() { 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)); @@ -120,4 +123,5 @@ void DateBookWeekLst::getEvents() { 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 { @@ -131,4 +135,9 @@ void DateBookWeekLst::getEvents() { } +void DateBookWeekLst::slotClockChanged( bool ap ) { + ampm = ap; + getEvents(); +} + void DateBookWeekLst::dateChanged(QDate &newdate) { dateset = true; 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 @@ -36,4 +36,5 @@ public slots: protected slots: void keyPressEvent(QKeyEvent *); + void slotClockChanged(bool); void setDbl(bool on); 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 @@ -6,8 +6,8 @@ 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 );
@@ -19,8 +19,8 @@ DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, 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 );
@@ -36,5 +36,5 @@ void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QValueLis 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&)));
@@ -53,5 +53,5 @@ void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QValueLis 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&)));
@@ -76,5 +76,5 @@ void DateBookWeekLstDblView::setEvents(QValueList<EffectiveEvent> &ev1,QDate &d, {
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&)));
@@ -100,5 +100,5 @@ void DateBookWeekLstDblView::setRightEvents(QValueList<EffectiveEvent> &ev1,QDat {
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&)));
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 @@ -17,9 +17,9 @@ 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 );
@@ -44,4 +44,5 @@ protected: QHBoxLayout*m_MainLayout;
DateBookWeekLstView *leftView,*rightView;
+ bool ampm;
};
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 @@ -10,5 +10,5 @@ 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);
@@ -29,4 +29,5 @@ private: protected:
void mousePressEvent( QMouseEvent *e );
+ bool ampm;
};
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 @@ -8,4 +8,5 @@ #include <qpe/config.h>
+#include <qpe/qpeapplication.h>
#include <qlayout.h>
@@ -13,8 +14,8 @@ 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();
@@ -66,5 +67,5 @@ void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate 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)));
@@ -72,9 +73,10 @@ void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate 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&)));
@@ -88,12 +90,12 @@ void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate 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()
{}
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 @@ -16,5 +16,7 @@ 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();
@@ -31,6 +33,8 @@ signals: void addEvent(const QDateTime &start, const QDateTime &stop,
const QString &str, const QString &location);
+
protected:
bool bStartOnMonday;
+ bool ampm;
QValueList<QObject*> childs;
@@ -39,4 +43,5 @@ protected: protected slots:
void keyPressEvent(QKeyEvent *);
+ void slotClockChanged( bool ap );
};
|