summaryrefslogtreecommitdiff
path: root/core/pim/today/today.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/today/today.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp109
1 files changed, 85 insertions, 24 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp
index 81d4d36..08efe2d 100644
--- a/core/pim/today/today.cpp
+++ b/core/pim/today/today.cpp
@@ -29,2 +29,4 @@
#include <qpe/resource.h>
+#include <qpe/contact.h>
+#include <qpe/global.h>
@@ -68,4 +70,13 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) );
-
+
+#if defined(Q_WS_QWS)
+#if !defined(QT_NO_COP)
+ QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this );
+ connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)),
+ this, SLOT ( channelReceived(const QCString &, const QByteArray &)) );
+#endif
+#endif
+
draw();
+ setOwnerField();
autoStart();
@@ -73,2 +84,42 @@ Today::Today( QWidget* parent, const char* name, WFlags fl )
+/*
+ * Qcop receive method.
+ */
+void Today::channelReceived(const QCString &msg, const QByteArray & data) {
+ QDataStream stream(data, IO_ReadOnly );
+ if ( msg == "message(QString)" ) {
+ QString message;
+ stream >> message;
+ setOwnerField(message);
+ }
+
+}
+
+/*
+ * Initialises the owner field with the default value, the username
+ */
+void Today::setOwnerField() {
+ QString file = Global::applicationFileName("addressbook", "businesscard.vcf");
+ if (QFile::exists(file)) {
+ Contact cont = Contact::readVCard(file)[0];
+ QString returnString = cont.fullName();
+ OwnerField->setText( tr ("<b>Owned by " + returnString + "</b>"));
+ } else {
+ OwnerField->setText( tr ("<b>to lame to fill out the business card </b>"));
+ }
+}
+
+/*
+ * Set the owner field with a given QString, for example per qcop.
+ */
+void Today::setOwnerField(QString &message) {
+ if (!message.isEmpty()) {
+ OwnerField->setText("<b>" + message + "</b>");
+ }
+}
+
+/*
+ * Autostart, uses the new (opie only) autostart method in the launcher code.
+ * If registered against that today ist started on each resume.
+ */
void Today::autoStart() {
@@ -88,2 +139,5 @@ void Today::autoStart() {
+/*
+ * Repaint method. Reread all fields.
+ */
void Today::draw() {
@@ -97,3 +151,2 @@ void Today::draw() {
-
/*
@@ -124,2 +177,5 @@ bool Today::checkIfModified() {
+/*
+ * Init stuff needed for today. Reads the config file.
+ */
void Today::init() {
@@ -127,3 +183,2 @@ void Today::init() {
QString time = (tr( date.toString()) );
-// QString time = (tr( date.toString()) , white);
@@ -135,3 +190,4 @@ void Today::init() {
cfg.setGroup("BaseConfig");
-
+
+ // -- config file section --
// how many lines should be showed in the task section
@@ -139,3 +195,3 @@ void Today::init() {
// after how many chars should the be cut off on tasks and notes
- MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",30);
+ MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",40);
// how many lines should be showed in the datebook section
@@ -146,12 +202,13 @@ void Today::init() {
SHOW_NOTES = cfg.readNumEntry("shownotes",0);
+ // should only later appointments be shown or all for the current day.
ONLY_LATER = cfg.readNumEntry("onlylater",1);
-
}
+
+/*
+ * The method for the configuration dialog.
+ */
void Today::startConfig() {
- conf = new todayconfig ( this, "", true );
-
-
- //Config cfg = new Config("today");
+ conf = new todayconfig ( this, "", true );
// read the config
@@ -173,3 +230,3 @@ void Today::startConfig() {
conf->CheckBox3->setChecked(ONLY_LATER);
-
+ // if today should be autostarted
conf->CheckBoxAuto->setChecked(AUTOSTART);
@@ -194,2 +251,3 @@ void Today::startConfig() {
cfg.writeEntry("autostart", autostart);
+
// sync it to "disk"
@@ -224,3 +282,3 @@ void Today::getDates() {
if ( list.count() > 0 ) {
-
+
for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin();
@@ -234,3 +292,3 @@ void Today::getDates() {
if (!ONLY_LATER) {
- count++;
+ count++;
DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents);
@@ -240,4 +298,4 @@ void Today::getDates() {
} else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) {
- count++;
-
+ count++;
+
// show only later appointments
@@ -264,4 +322,2 @@ void Today::getDates() {
AllDateBookEvents->show();
-
-
}
@@ -341,6 +397,4 @@ void Today::getMail() {
-
QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING);
-
MailField->setText(output);
@@ -351,3 +405,2 @@ void Today::getMail() {
* Get the todos
- *
*/
@@ -359,2 +412,3 @@ void Today::getTodo() {
}
+ // since it was the new start or the return from config dialog, set it to 0 again.
NEW_START=0;
@@ -404,2 +458,6 @@ void Today::startDatebook() {
}
+
+/*
+ * starts the edit dialog as known from datebook
+ */
void Today::editEvent(const Event &e) {
@@ -431,7 +489,4 @@ void Today::startMail() {
-/*
- * Destroys the object and frees any allocated resources
- */
+
Today::~Today() {
- // no need to delete child widgets, Qt does it all for us
}
@@ -439,2 +494,6 @@ Today::~Today() {
+
+/*
+ * Gets the events for the current day, if it should get all dates
+ */
DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
@@ -467,2 +526,3 @@ DateBookEvent::DateBookEvent(const EffectiveEvent &ev,
}
+
// include possible note or not
@@ -521,2 +581,3 @@ DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev,
+
void DateBookEvent::editMe() {