-rw-r--r-- | core/pim/today/today.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 69bcb68..d10082f 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -182,297 +182,296 @@ void Today::startConfig() { int maxmeet = conf->SpinBox1->value(); int location = conf->CheckBox1->isChecked(); int notes = conf->CheckBox2->isChecked(); int maxcharclip = conf->SpinBox7->value(); int onlylater = conf->CheckBox3->isChecked(); int autostart =conf->CheckBoxAuto->isChecked(); cfg.writeEntry("maxlinestask",maxlinestask); cfg.writeEntry("maxcharclip", maxcharclip); cfg.writeEntry("maxlinesmeet",maxmeet); cfg.writeEntry("showlocation",location); cfg.writeEntry("shownotes", notes); cfg.writeEntry("onlylater", onlylater); cfg.setGroup("Autostart"); cfg.writeEntry("autostart", autostart); // sync it to "disk" cfg.write(); autoStart(); draw(); } /* * Get all events that are in the datebook xml file for today */ void Today::getDates() { QDate date = QDate::currentDate(); QWidget* AllDateBookEvents = new QWidget( ); QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); //QTime time = QTime::currentTime(); QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); Config config( "qpe" ); // if 24 h format //bool ampm = config.readBoolEntry( "AMPM", TRUE ); int count=0; if ( list.count() > 0 ) { QString msg; for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { count++; if ( count <= MAX_LINES_MEET ) { DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents); layoutDates->addWidget(l); connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); } } layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); sv1->addChild(AllDateBookEvents); //if (msg.isEmpty()) { // msg = tr("No more appointments today"); //} //DatesField->setText(msg); } } /* * Parse in the todolist.xml */ QList<TodoItem> Today::loadTodo(const char *filename) { DOM *todo; ELE *tasks; ELE **tasklist; ATT **attlist; int i, j; char *description; int completed; int priority; TodoItem *tmp; QList<TodoItem> loadtodolist; todo = minidom_load(filename); tasks = todo->el; tasks = tasks->el[0]; /*!DOCTYPE-quickhack*/ if(tasks) { tasklist = tasks->el; i = 0; while((tasklist) && (tasklist[i])) { attlist = tasklist[i]->at; j = 0; description = NULL; priority = -1; completed = -1; while((attlist) && (attlist[j])) { if(!attlist[j]->name) { continue; } if(!strcmp(attlist[j]->name, "Description")) { description = attlist[j]->value; } // get Completed tag (0 or 1) if(!strcmp(attlist[j]->name, "Completed")) { QString s = attlist[j]->name; if(s == "Completed") { completed = QString(attlist[j]->value).toInt(); } } // get Priority (1 to 5) if(!strcmp(attlist[j]->name, "Priority")) { QString s = attlist[j]->name; if(s == "Priority") { priority = QString(attlist[j]->value).toInt(); } } j++; } if(description) { tmp = new TodoItem(description, completed, priority); loadtodolist.append(tmp); } i++; } } minidom_free(todo); return loadtodolist; } void Today::getMail() { Config cfg("opiemail"); 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); } /* * Get the todos * */ void Today::getTodo() { // if the todolist.xml file was not modified in between, do not parse it. if (!checkIfModified() && !NEW_START) { return; } NEW_START=0; QString output; QString tmpout; int count = 0; QDir dir; QString homedir = dir.homeDirPath (); // see if todolist.xml does exist. QFile f(homedir +"/Applications/todolist/todolist.xml"); if ( f.exists() ) { QList<TodoItem> todolist = loadTodo(homedir +"/Applications/todolist/todolist.xml"); TodoItem *item; for( item = todolist.first(); item; item = todolist.next()) { if (!(item->getCompleted() == 1) ) { count++; if (count <= MAX_LINES_TASK) { tmpout += "<b>- </b>" + QString(((item)->getDescription().mid(0, MAX_CHAR_CLIP) + ("<br>"))); } } } } if (count > 0) { if( count == 1 ) { output = tr("There is <b> 1</b> active task: <br>" ); } else { output = tr("There are <b> %1</b> active tasks: <br>").arg(count); } output += tmpout; } else { output = tr("No active tasks"); } TodoField->setText(tr(output)); } /* * launches datebook */ void Today::startDatebook() { QCopEnvelope e("QPE/System", "execute(QString)"); e << QString("datebook"); } /* * launches todolist */ void Today::startTodo() { QCopEnvelope e("QPE/System", "execute(QString)"); e << QString("todolist"); } /* * launch opiemail */ void Today::startMail() { QCopEnvelope e("QPE/System", "execute(QString)"); e << QString("opiemail"); } /* * Destroys the object and frees any allocated resources */ Today::~Today() { // no need to delete child widgets, Qt does it all for us } DateBookEvent::DateBookEvent(const EffectiveEvent &ev, QWidget* parent = 0, const char* name = 0, WFlags fl = 0) : ClickableLabel(parent,name,fl), event(ev) { QString msg; QTime time = QTime::currentTime(); if (!ONLY_LATER) { msg += "<B>" + (ev).description() + "</B>"; if ( (ev).event().hasAlarm() ) { msg += " <b>[with alarm]</b>"; } // include location or not if (SHOW_LOCATION == 1) { msg += "<BR><i>" + (ev).location(); msg += "</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()) ) // end time of event + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); } - msg += "<BR>"; // include possible note or not if (SHOW_NOTES == 1) { - msg += " <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; + msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; } } else if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { msg += "<B>" + (ev).description() + "</B>"; if ( (ev).event().hasAlarm() ) { msg += " <b>[with alarm]</b>"; } // include location or not if (SHOW_LOCATION == 1) { msg+= "<BR><i>" + (ev).location(); msg += "</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()) ) // end time of event + "<b> - </b>" + TimeString::timeString(QTime((ev).event().end().time()) ); } // include possible note or not if (SHOW_NOTES == 1) { msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP) + "<br>"; } } setText(msg); connect(this, SIGNAL(clicked()), this, SLOT(editMe())); setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); } void DateBookEvent::editMe() { emit editEvent(event.event()); } |