Source Code (Use browser search to find items of interest.)
Class Index
knotes'MyTimer (./kdeutils/knotes/timer.h:32)
class MyTimer : public QObject{
public:
MyTimer(){
startTimer( 1000 );
}
protected:
virtual void timerEvent( QTimerEvent * );
void playSound( QString );
public:
void start();
void stop();
};
knotes'MyTimer::start() (./kdeutils/knotes/timer.cpp:41)
void MyTimer::start(){
startTimer(1000);
}
knotes'MyTimer::stop() (./kdeutils/knotes/timer.cpp:47)
void MyTimer::stop(){
killTimers();
}
knotes'MyTimer::timerEvent() (./kdeutils/knotes/timer.cpp:52)
void MyTimer::timerEvent( QTimerEvent * ){
this->stop();
QDateTime qdt = QDateTime::currentDateTime();
// printf("In Timer counter:%d\n",KPostit::AlarmList.count());
QListIterator<AlarmEntry> it(KPostit::AlarmList);
AlarmEntry* entry;
while ( (entry=it.current()) ) {
if(entry->dt < qdt){
if (postitdefaults.playSound && !postitdefaults.soundcommand.isEmpty()) {
playSound(postitdefaults.soundcommand);
}
else {
QApplication::beep();
kapp->processEvents();
sleep(1);
QApplication::beep();
kapp->processEvents();
sleep(1);
QApplication::beep();
}
// now we need to reset the Caption of the PostitWindow whose
// alarm expired
bool exists = FALSE;
KPostit *t = 0;
for(KPostit::PostitList.first();KPostit::PostitList.current();
KPostit::PostitList.next()){
if(
KPostit::PostitList.current()->name == entry->name
){
exists = TRUE;
t = KPostit::PostitList.current();
t->setCaption(i18n("Note: ") +
KPostit::PostitList.current()->name);
t->label->setText(KPostit::PostitList.current()->name);
if( KPostit::PostitList.current()->hidden == true){
KPostit::PostitList.current()->hidden = false;
if(KPostit::PostitList.current()->propertystring != (QString) "")
KPostit::PostitList.current()->setGeometry(KWM::setProperties(KPostit::PostitList.current()->winId(),
KPostit::PostitList.current()->propertystring));
}
KPostit::PostitList.current()->show();
KWM::activate(KPostit::PostitList.current()->winId());
}
}
if(!exists){
// if this particular kpostit note widget is not alive yet, create it.
t = new KPostit (NULL,NULL,0,
entry->name.copy());
t->setCaption(i18n("Note: ") + entry->name);
t->label->setText(entry->name);
t->show ();
KPostit::PostitList.append( t );
}
QString str;
str = i18n("Alarm for KNote:\n\n%1")
.arg(entry->name);
KMessageBox::information(t, str, i18n("Alarm"));
delete entry;
KPostit::AlarmList.remove(entry);
}
++it;
}
this->start();
}
// this belongs somewhere in KApplication if you ask me
knotes'MyTimer::playSound() (./kdeutils/knotes/timer.cpp:147)
void MyTimer::playSound( QString cmd )
{
QString param;
KProcess p;
int argIdx;
cmd.simplifyWhiteSpace();
while( !cmd.isEmpty() )
{
argIdx = cmd.find(" ");
param = cmd.left( argIdx );
p << param;
if (argIdx == -1)
argIdx = cmd.length();
cmd = cmd.remove( 0, argIdx + 1 );
}
if (!p.start(KProcess::DontCare, KProcess::NoCommunication))
QApplication::beep();
}