summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-03-17 14:47:52 (UTC)
committer harlekin <harlekin>2002-03-17 14:47:52 (UTC)
commit31e0537b3406d3e89df6424cded2570d28d61df4 (patch) (side-by-side diff)
tree7bc5171eabbeb6f8469fdafb963a568e08b71aa1
parent2f18edca6cc3539298deccee89e6f4dd7a2570a2 (diff)
downloadopie-31e0537b3406d3e89df6424cded2570d28d61df4.zip
opie-31e0537b3406d3e89df6424cded2570d28d61df4.tar.gz
opie-31e0537b3406d3e89df6424cded2570d28d61df4.tar.bz2
new: Owner field with the ability to set any text with a qcop call
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/today/today.cpp109
-rw-r--r--core/pim/today/today.h5
-rw-r--r--core/pim/today/todaybase.cpp25
-rw-r--r--core/pim/today/todaybase.h2
4 files changed, 101 insertions, 40 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() {
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
@@ -87,4 +87,8 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
TextLabel1->setTextFormat( RichText );
-
-
+
+ OwnerField = new QLabel(this , "Owner" );
+ OwnerField->setGeometry(QRect(0,0, this->width(), 12 ));
+ OwnerField->setAlignment(int (QLabel::AlignTop | QLabel::AlignLeft ) );
+ OwnerField->setMaximumHeight(12);
+
// --- dates section ---
@@ -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 );
@@ -112,12 +115,4 @@ TodayBase::TodayBase( QWidget* parent, const char* name, WFlags fl )
DatesButton->setFlat( TRUE );
-
- //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 ---)
+
+ // --- mail section ---)
MailFrame = new QFrame( this ,"MailFrame" );
@@ -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;