summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/TODO2
-rw-r--r--core/pim/today/changelog2
-rw-r--r--core/pim/today/today.cpp186
-rw-r--r--core/pim/today/today.h42
-rw-r--r--core/pim/today/todaybase.cpp24
5 files changed, 155 insertions, 101 deletions
diff --git a/core/pim/today/TODO b/core/pim/today/TODO
index 48e8d20..6acbf5a 100644
--- a/core/pim/today/TODO
+++ b/core/pim/today/TODO
@@ -3,6 +3,4 @@ TODO for today:
* show alarm icons on alarm events (partly done)
-* add am/pm mode instead of 24 h, take system default
-
* qcop integration for updating events?
diff --git a/core/pim/today/changelog b/core/pim/today/changelog
index b3da1fb..f04ff78 100644
--- a/core/pim/today/changelog
+++ b/core/pim/today/changelog
@@ -1,2 +1,4 @@
+* am/pm time optinal (autodetect)
+
0.3.1
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 7cef035..028947d 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -22,5 +22,5 @@
#include <qpe/timestring.h>
#include <qpe/config.h>
-#include <qpe/qcopenvelope_qws.h>
+#include <qpe/qcopenvelope_qws.h>
#include <qpe/qprocess.h>
#include <qpe/resource.h>
@@ -31,5 +31,5 @@
#include <qdir.h>
#include <qfile.h>
-#include <qdatetime.h>
+#include <qdatetime.h>
#include <qtextstream.h>
#include <qcheckbox.h>
@@ -57,7 +57,7 @@ int AUTOSTART;
int NEW_START=1;
-/*
- * Constructs a Example which is a child of 'parent', with the
- * name 'name' and widget flags set to 'f'
+/*
+ * Constructs a Example which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
*/
Today::Today( QWidget* parent, const char* name, WFlags fl )
@@ -67,6 +67,6 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) );
QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) );
-
-#if defined(Q_WS_QWS)
+
+#if defined(Q_WS_QWS)
#if !defined(QT_NO_COP)
QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this );
@@ -75,5 +75,7 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
#endif
#endif
-
+
+
+
db = NULL;
setOwnerField();
@@ -99,5 +101,5 @@ void Today::channelReceived(const QCString &msg, const QByteArray & data) {
/*
* Initialises the owner field with the default value, the username
- */
+ */
void Today::setOwnerField() {
QString file = Global::applicationFileName("addressbook", "businesscard.vcf");
@@ -118,5 +120,5 @@ void Today::setOwnerField(QString &message) {
OwnerField->setText("<b>" + message + "</b>");
}
-}
+}
/*
@@ -126,5 +128,5 @@ void Today::setOwnerField(QString &message) {
void Today::autoStart() {
Config cfg("today");
- cfg.setGroup("Autostart");
+ cfg.setGroup("Autostart");
AUTOSTART = cfg.readNumEntry("autostart",1);
if (AUTOSTART) {
@@ -146,5 +148,5 @@ void Today::draw() {
getDates();
getMail();
-
+
// if the todolist.xml file was not modified in between, do not parse it.
if (checkIfModified()) {
@@ -222,8 +224,8 @@ void Today::startConfig() {
// read the config
Config cfg("today");
- cfg.setGroup("BaseConfig");
-
+ cfg.setGroup("BaseConfig");
+
//init();
-
+
conf->SpinBox1->setValue(MAX_LINES_MEET);
// location show box
@@ -241,5 +243,5 @@ void Today::startConfig() {
conf->exec();
-
+
int maxlinestask = conf->SpinBox2->value();
int maxmeet = conf->SpinBox1->value();
@@ -249,7 +251,7 @@ void Today::startConfig() {
int onlylater = conf->CheckBox3->isChecked();
int autostart =conf->CheckBoxAuto->isChecked();
-
+
cfg.writeEntry("maxlinestask",maxlinestask);
- cfg.writeEntry("maxcharclip", maxcharclip);
+ cfg.writeEntry("maxcharclip", maxcharclip);
cfg.writeEntry("maxlinesmeet",maxmeet);
cfg.writeEntry("showlocation",location);
@@ -258,7 +260,7 @@ void Today::startConfig() {
cfg.setGroup("Autostart");
cfg.writeEntry("autostart", autostart);
-
+
// sync it to "disk"
- cfg.write();
+ cfg.write();
NEW_START=1;
draw();
@@ -280,5 +282,5 @@ void Today::getDates() {
delete db;
}
- db = new DateBookDB;
+ db = new DateBookDB;
QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date);
@@ -290,17 +292,17 @@ void Today::getDates() {
// if 24 h format
//bool ampm = config.readBoolEntry( "AMPM", TRUE );
-
+
int count=0;
-
+
if ( list.count() > 0 ) {
-
+
for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin();
it!=list.end(); ++it ) {
-
-
+
+
if ( count <= MAX_LINES_MEET ) {
QTime time = QTime::currentTime();
-
+
if (!ONLY_LATER) {
count++;
@@ -311,5 +313,5 @@ void Today::getDates() {
} else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) {
count++;
-
+
// show only later appointments
DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES);
@@ -317,5 +319,5 @@ void Today::getDates() {
connect (l, SIGNAL(editEvent(const Event &)),
this, SLOT(editEvent(const Event &)));
- }
+ }
}
}
@@ -324,5 +326,5 @@ void Today::getDates() {
noMoreEvents->setText(tr("No more appointments today"));
layoutDates->addWidget(noMoreEvents);
- }
+ }
} else {
QLabel* noEvents = new QLabel(AllDateBookEvents);
@@ -330,21 +332,21 @@ void Today::getDates() {
layoutDates->addWidget(noEvents);
}
-
+
layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
sv1->addChild(AllDateBookEvents);
AllDateBookEvents->show();
}
-
+
void Today::getMail() {
Config cfg("opiemail");
- cfg.setGroup("today");
-
+ cfg.setGroup("today");
+
// how many lines should be showed in the task section
int NEW_MAILS = cfg.readNumEntry("newmails",0);
int OUTGOING = cfg.readNumEntry("outgoing",0);
-
+
QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING);
-
+
MailField->setText(output);
}
@@ -355,5 +357,5 @@ void Today::getMail() {
*/
void Today::getTodo() {
-
+
QString output;
QString tmpout;
@@ -371,5 +373,5 @@ void Today::getTodo() {
}
}
-
+
// get total number of still open todos
QValueList<ToDoEvent> open = todo->rawToDos();
@@ -379,5 +381,5 @@ void Today::getTodo() {
if (!(*it).isCompleted()){
count +=1;
- // not the overdues, we allready got them, and not if we are
+ // not the overdues, we allready got them, and not if we are
// over the maxlines
if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) {
@@ -387,6 +389,6 @@ void Today::getTodo() {
}
}
-
-
+
+
if (count > 0) {
if( count == 1 ) {
@@ -399,5 +401,5 @@ void Today::getTodo() {
output = tr("No active tasks");
}
-
+
TodoField->setText(tr(output));
}
@@ -406,5 +408,5 @@ void Today::getTodo() {
* launches datebook
*/
-void Today::startDatebook() {
+void Today::startDatebook() {
QCopEnvelope e("QPE/System", "execute(QString)");
e << QString("datebook");
@@ -413,5 +415,5 @@ void Today::startDatebook() {
/*
* starts the edit dialog as known from datebook
- */
+ */
extern QPEApplication *todayApp;
@@ -419,5 +421,5 @@ extern QPEApplication *todayApp;
void Today::editEvent(const Event &e) {
startDatebook();
-
+
while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents();
QCopEnvelope env("QPE/Datebook", "editEvent(int)");
@@ -427,5 +429,5 @@ void Today::editEvent(const Event &e) {
/*
* launches todolist
- */
+ */
void Today::startTodo() {
QCopEnvelope e("QPE/System", "execute(QString)");
@@ -445,20 +447,23 @@ Today::~Today() {
}
-
-
/*
- * Gets the events for the current day, if it should get all dates
+ * Gets the events for the current day, if it should get all dates
*/
-DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
- QWidget* parent = 0,
+DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
+ QWidget* parent = 0,
int SHOW_LOCATION = 0,
int SHOW_NOTES = 0,
- const char* name = 0,
+ const char* name = 0,
WFlags fl = 0) :
ClickableLabel(parent,name,fl), event(ev) {
-
+
QString msg;
//QTime time = QTime::currentTime();
-
+
+ Config config( "qpe" );
+ // if 24 h format
+ ampm = config.readBoolEntry( "AMPM", TRUE );
+
+
if (!ONLY_LATER) {
msg += "<B>" + (ev).description() + "</B>";
@@ -470,14 +475,14 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
msg += "<BR><i>" + (ev).location() + "</i>";
}
-
+
if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) {
msg += "<br>All day";
} else {
// start time of event
- msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) )
+ msg += "<br>" + ampmTime(QTime((ev).event().start().time()) );
// end time of event
- + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) );
+ + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) );
}
-
+
// include possible note or not
if (SHOW_NOTES == 1) {
@@ -491,15 +496,40 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
-DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
- QWidget* parent = 0,
+QString DateBookEvent::ampmTime(QTime tm) {
+
+ QString s;
+ if( ampm ) {
+ int hour = tm.hour();
+ if (hour == 0)
+ hour = 12;
+ if (hour > 12)
+ hour -= 12;
+ s.sprintf( "%2d:%02d %s", hour, tm.minute(),
+ (tm.hour() >= 12) ? "PM" : "AM" );
+ return s;
+ } else {
+ s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
+ return s;
+ }
+
+}
+
+
+DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
+ QWidget* parent = 0,
int SHOW_LOCATION = 0,
int SHOW_NOTES = 0,
- const char* name = 0,
+ const char* name = 0,
WFlags fl = 0) :
ClickableLabel(parent,name,fl), event(ev) {
-
+
QString msg;
QTime time = QTime::currentTime();
-
+
+ Config config( "qpe" );
+ // if 24 h format
+ ampm = config.readBoolEntry( "AMPM", TRUE );
+
+
if ((time.toString() <= TimeString::dateString((ev).event().end())) ) {
// show only later appointments
@@ -512,12 +542,12 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
msg += "<BR><i>" + (ev).location() + "</i>";
}
-
+
if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) {
msg += "<br>All day";
} else {
// start time of event
- msg += "<br>" + TimeString::timeString(QTime((ev).event().start().time()) )
+ msg += "<br>" + ampmTime(QTime((ev).event().start().time()) )
// end time of event
- + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) );
+ + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) );
}
// include possible note or not
@@ -525,6 +555,6 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP);
}
- }
-
+ }
+
setText(msg);
connect(this, SIGNAL(clicked()), this, SLOT(editMe()));
@@ -533,4 +563,24 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
+QString DateBookEventLater::ampmTime(QTime tm) {
+
+ QString s;
+ if( ampm ) {
+ int hour = tm.hour();
+ if (hour == 0)
+ hour = 12;
+ if (hour > 12)
+ hour -= 12;
+ s.sprintf( "%2d:%02d %s", hour, tm.minute(),
+ (tm.hour() >= 12) ? "PM" : "AM" );
+ return s;
+ } else {
+ s.sprintf( "%2d:%02d", tm.hour(), tm.minute() );
+ return s;
+ }
+
+}
+
+
void DateBookEvent::editMe() {
emit editEvent(event.event());
diff --git a/core/pim/today/today.h b/core/pim/today/today.h
index 090e8f9..d265d67 100644
--- a/core/pim/today/today.h
+++ b/core/pim/today/today.h
@@ -28,5 +28,5 @@
#include <qdatetime.h>
-#include <qlist.h>
+#include <qlist.h>
#include "todayconfig.h"
@@ -37,10 +37,10 @@ class QVBoxLayout;
class Today : public TodayBase {
- Q_OBJECT
-
- public:
- Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
- ~Today();
-
+ Q_OBJECT
+
+ public:
+ Today( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ ~Today();
+
private slots:
void startConfig();
@@ -59,7 +59,7 @@ class Today : public TodayBase {
void setOwnerField();
void setOwnerField(QString &string);
- private slots:
- void channelReceived(const QCString &msg, const QByteArray & data);
-
+ private slots:
+ void channelReceived(const QCString &msg, const QByteArray & data);
+
private:
DateBookDB *db;
@@ -71,5 +71,5 @@ class Today : public TodayBase {
int MAX_CHAR_CLIP;
int MAX_LINES_MEET;
- int SHOW_LOCATION;
+ int SHOW_LOCATION;
int SHOW_NOTES;
};
@@ -78,10 +78,10 @@ class DateBookEvent: public ClickableLabel {
Q_OBJECT
public:
- DateBookEvent(const EffectiveEvent &ev,
- QWidget* parent = 0,
- int SHOW_LOCATION = 0,
- int SHOW_NOTES = 0,
- const char* name = 0,
- WFlags fl = 0);
+ DateBookEvent(const EffectiveEvent &ev,
+ QWidget* parent = 0,
+ int SHOW_LOCATION = 0,
+ int SHOW_NOTES = 0,
+ const char* name = 0,
+ WFlags fl = 0);
signals:
void editEvent(const Event &e);
@@ -89,5 +89,7 @@ private slots:
void editMe();
private:
+ QString ampmTime(QTime);
const EffectiveEvent event;
+ bool ampm;
};
@@ -95,9 +97,9 @@ class DateBookEventLater: public ClickableLabel {
Q_OBJECT
public:
- DateBookEventLater(const EffectiveEvent &ev,
+ DateBookEventLater(const EffectiveEvent &ev,
QWidget* parent = 0,
int SHOW_LOCATION = 0,
int SHOW_NOTES = 0,
- const char* name = 0,
+ const char* name = 0,
WFlags fl = 0);
signals:
@@ -106,5 +108,7 @@ private slots:
void editMe();
private:
+ QString ampmTime(QTime);
const EffectiveEvent event;
+ bool ampm;
};
diff --git a/core/pim/today/todaybase.cpp b/core/pim/today/todaybase.cpp
index 755c860..ae8763b 100644
--- a/core/pim/today/todaybase.cpp
+++ b/core/pim/today/todaybase.cpp
@@ -46,11 +46,11 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
QPixmap mail = Resource::loadPixmap( "today/mail" ); // mail icon
- QPalette pal = this->palette();
- QColor col = pal.color(QPalette::Active, QColorGroup::Background);
- pal.setColor(QPalette::Active, QColorGroup::Button, col);
- pal.setColor(QPalette::Inactive, QColorGroup::Button, col);
- pal.setColor(QPalette::Normal, QColorGroup::Button, col);
- pal.setColor(QPalette::Disabled, QColorGroup::Button, col);
- this->setPalette(pal);
+ //QPalette pal = this->palette();
+ // QColor col = pal.color(QPalette::Active, QColorGroup::Background);
+ //pal.setColor(QPalette::Active, QColorGroup::Button, col);
+ //pal.setColor(QPalette::Inactive, QColorGroup::Button, col);
+ //pal.setColor(QPalette::Normal, QColorGroup::Button, col);
+ //pal.setColor(QPalette::Disabled, QColorGroup::Button, col);
+ //this->setPalette(pal);
@@ -96,5 +96,5 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
// --- dates section ---
Frame4 = new QFrame( this, "Frame4" );
- Frame4->setPalette( pal );
+// Frame4->setPalette( pal );
Frame4->setFrameShape( QScrollView::StyledPanel );
Frame4->setFrameShadow( QScrollView::Sunken );
@@ -113,5 +113,5 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
DatesButton->setGeometry( QRect( 2, 4, 36, 32 ) );
DatesButton->setBackgroundOrigin( QPushButton::WidgetOrigin );
- DatesButton->setPalette( pal );
+// DatesButton->setPalette( pal );
DatesButton->setPixmap( datebook );
DatesButton->setFlat( TRUE );
@@ -129,5 +129,5 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
MailButton = new QPushButton (MailFrame, "MailButton" );
MailButton->setGeometry( QRect( 2, 3, 36, 19 ) );
- MailButton->setPalette( pal );
+// MailButton->setPalette( pal );
MailButton->setPixmap( mail );
MailButton->setFlat( TRUE );
@@ -151,5 +151,5 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
TodoButton = new QPushButton (Frame15, "TodoButton" );
TodoButton->setGeometry( QRect( 2, 4, 36, 32 ) );
- TodoButton->setPalette( pal );
+// TodoButton->setPalette( pal );
TodoButton->setPixmap( todo );
TodoButton->setFlat( TRUE );
@@ -170,5 +170,5 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
PushButton1->setGeometry( QRect( 2, 68, 25, 21 ) );
PushButton1->setPixmap( config );
- PushButton1->setPalette( pal );
+// PushButton1->setPalette( pal );
PushButton1->setAutoDefault( TRUE );
PushButton1->setFlat( TRUE );