-rw-r--r-- | core/pim/today/today.cpp | 97 | ||||
-rw-r--r-- | core/pim/today/today.h | 5 | ||||
-rw-r--r-- | core/pim/today/todaybase.cpp | 17 | ||||
-rw-r--r-- | core/pim/today/todaybase.h | 2 |
4 files changed, 91 insertions, 30 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> @@ -69,3 +71,12 @@ Today::Today( QWidget* parent, const char* name, WFlags fl ) +#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); @@ -136,2 +191,3 @@ void Today::init() { + // -- 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); - } -void Today::startConfig() { - conf = new todayconfig ( this, "", true ); +/* + * The method for the configuration dialog. + */ +void Today::startConfig() { - //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" @@ -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() { diff --git a/core/pim/today/today.h b/core/pim/today/today.h index 0b4356c..6dec2c2 100644 --- a/core/pim/today/today.h +++ b/core/pim/today/today.h @@ -57,3 +57,8 @@ class Today : public TodayBase { bool checkIfModified(); + void setOwnerField(); + void setOwnerField(QString &string); QList<TodoItem> loadTodo(const char *filename); +private slots: + void channelReceived(const QCString &msg, const QByteArray & data); + private: diff --git a/core/pim/today/todaybase.cpp b/core/pim/today/todaybase.cpp index 552e2eb..c0b8d34 100644 --- a/core/pim/today/todaybase.cpp +++ b/core/pim/today/todaybase.cpp @@ -88,2 +88,6 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) + OwnerField = new QLabel(this , "Owner" ); + OwnerField->setGeometry(QRect(0,0, this->width(), 12 )); + OwnerField->setAlignment(int (QLabel::AlignTop | QLabel::AlignLeft ) ); + OwnerField->setMaximumHeight(12); @@ -96,5 +100,4 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) Frame4->setFrameStyle( QFrame::NoFrame ); - Frame4->setGeometry (QRect( 0, 0, this->width() , this->height()) ); + Frame4->setGeometry (QRect( 0, 8, this->width() , this->height()) ); - // QScrollView* sv1 = new QScrollView( Frame4 ); sv1 = new QScrollView( Frame4 ); @@ -113,10 +116,2 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) - //DatesField = new QLabel( sv1->viewport(), "DatesField" ); - //DatesField = new QVBox(sv1->viewport()); - //QWidget *dummy = new QWidget(sv1->viewport()); - //sv1->addChild(DatesField); - //DatesField->setText( tr( "No appointments today" ) ); - // DatesField->setAlignment( int( QLabel::AlignTop | QLabel::AlignLeft ) ); - - // --- mail section ---) @@ -144,3 +139,2 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) - // --- todo section -- @@ -181,2 +175,3 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl ) layout->addWidget(Frame); + layout->addWidget(OwnerField); layout->addWidget(Frame4); diff --git a/core/pim/today/todaybase.h b/core/pim/today/todaybase.h index 8840125..0118faa 100644 --- a/core/pim/today/todaybase.h +++ b/core/pim/today/todaybase.h @@ -34,3 +34,3 @@ public: QPushButton* DatesButton; - //QLabel* DatesField; + QLabel* OwnerField; QLabel* Frame; |