Index: kevents.h =================================================================== --- kevents.h (revision 657614) +++ kevents.h (working copy) @@ -33,6 +33,7 @@ class DvbStream; class DVBevents; class ChannelDesc; +class QCheckBox; @@ -61,24 +62,31 @@ private slots: void checkNewEvent(); + void checkEpgSearch(QString searchword); void mouseClickedSlot( int btn, QListViewItem *it, const QPoint &p, int c ); void reset(); void setMode( int m, QString name="" ); void setScheduled(); void setCurrentNext(); void setCurrentChannelEpg(); + void epgSearch(); void zap( QListViewItem* it, const QPoint &p, int col ); private: QPtrList *dvb; KListView *listView; - KPushButton *resetBtn, *currentNextBtn, *allBtn, *currentChannelEpg; + KPushButton *resetBtn, *currentNextBtn, *allBtn, *currentChannelEpgBtn, *searchBtn; + QCheckBox *titleCb; QPtrList *channels; QTextBrowser *textBrow; int mode; ChannelDesc *chan; +protected: + + QLineEdit *searchLineEdit; + signals: void addTimer( QString channel, QString name, QDateTime begin, QTime duration ); Index: kevents.cpp =================================================================== --- kevents.cpp (revision 657614) +++ kevents.cpp (working copy) @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -74,8 +75,16 @@ hbox->addWidget( allBtn ); currentNextBtn = new KPushButton( i18n("Current/Next"), this ); hbox->addWidget( currentNextBtn ); - currentChannelEpg = new KPushButton( i18n("Current Channel"), this ); - hbox->addWidget( currentChannelEpg ); + currentChannelEpgBtn = new KPushButton( i18n("Current Channel"), this ); + hbox->addWidget( currentChannelEpgBtn ); + searchLineEdit = new QLineEdit(this); + hbox->addWidget( searchLineEdit ); + titleCb = new QCheckBox(i18n("only Title"), this ); + titleCb->setChecked(true); + hbox->addWidget( titleCb); + searchBtn = new KPushButton( i18n("Search"), this ); + searchBtn->setFocus(); + hbox->addWidget( searchBtn ); QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); hbox->addItem( spacer ); @@ -100,14 +109,17 @@ resetBtn->setGuiItem( KGuiItem(i18n("Refresh"), icon->loadIconSet("reload", KIcon::Small) ) ); allBtn->setGuiItem( KGuiItem(i18n("Scheduled"), icon->loadIconSet("date", KIcon::Small) ) ); currentNextBtn->setGuiItem( KGuiItem(i18n("Current/Next"), icon->loadIconSet("toggle_log", KIcon::Small) ) ); - currentChannelEpg->setGuiItem( KGuiItem(i18n("Current Channel"), icon->loadIconSet("date", KIcon::Small) ) ); + currentChannelEpgBtn->setGuiItem( KGuiItem(i18n("Current Channel"), icon->loadIconSet("date", KIcon::Small) ) ); + searchBtn->setGuiItem( KGuiItem(i18n("EPG-Search"), icon->loadIconSet("find", KIcon::Small) ) ); new EListViewItem( (QListView*)listView, "Une chaine", "99/99/99 99:99 9999", "99:99 99", "un titre de programme", 0 ); resize( size ); connect( resetBtn , SIGNAL( clicked() ), this, SLOT( reset() ) ); connect( allBtn , SIGNAL( clicked() ), this, SLOT( setScheduled() ) ); connect( currentNextBtn , SIGNAL( clicked() ), this, SLOT( setCurrentNext() ) ); - connect( currentChannelEpg , SIGNAL( clicked() ), this, SLOT( setCurrentChannelEpg() ) ); + connect( currentChannelEpgBtn, SIGNAL( clicked() ), this, SLOT( setCurrentChannelEpg() ) ); + connect( searchBtn , SIGNAL( clicked() ), this, SLOT( epgSearch() ) ); + connect( listView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), this, SLOT(mouseClickedSlot(int,QListViewItem*,const QPoint&,int)) ); connect( listView, SIGNAL(doubleClicked(QListViewItem*,const QPoint &,int)), @@ -117,6 +129,94 @@ delete icon; } +void KEvents::checkEpgSearch(QString searchword) +{ + int i, j, k, m, n,l; + DVBevents *events=0; + EventSourceList *slist; + EventTsidList *tlist; + EListViewItem *itt=0; + + QString s, channel, begin, duration, title; + bool found; + EventDesc *desc; + QPixmap pix; + for( k=0; k<(int)dvb->count(); k++ ) { + events = dvb->at(k)->dvbEvents; + events->mutex.lock(); + for ( m=0; m<(int)events->srcList.count(); m++ ) { + slist = events->srcList.at(m); + for ( n=0; n<(int)slist->tsidList.count(); n++ ) { + tlist = slist->tsidList.at(n); + for ( j=0; j<(int)tlist->events.count(); j++ ) { + desc = tlist->events.at(j); + + if ( desc->title.isEmpty() ) + continue; + + for ( i=0; i<(int)channels->count(); i++ ) { + if ( desc->source==channels->at(i)->tp.source && desc->sid==channels->at(i)->sid && desc->tsid==channels->at(i)->tp.tsid ) { + channel = channels->at(i)->name; + + found=false; + if(desc->title.upper().find(searchword.upper())!=-1) + found=true; + if(!titleCb->isChecked()) { + if(!found) { + for ( l=0; l<(int)desc->extEvents.count(); l++ ) { + s = *desc->extEvents.at(l); + if(!s.isEmpty()) { + if(s.upper().find(searchword.upper())!=-1) { + found=true; + s=""; + break; + } + } + } + } + if(!found) { + for ( l=0; l<(int)desc->shortEvents.count(); l++ ) { + s = s + desc->shortEvents.at(l)->name; + s += s + desc->shortEvents.at(l)->text; + if(!s.isEmpty()) { + if(s.upper().find(searchword.upper())!=-1) { + found=true; + s=""; + break; + } + } + } + } + } + if(!found) + continue; + + pix = channels->at(i)->pix; + begin = KGlobal::locale()->formatDateTime( desc->startDateTime ); + duration = desc->duration.toString("hh:mm"); + title = desc->title; + + itt = new EListViewItem( (QListView*)listView, channel, begin, duration, title, desc ); + + if ( !pix.isNull() ) + itt->setPixmap( 0, pix ); + } + } + } + } + } + events->mutex.unlock(); + } +} + +void KEvents::epgSearch() +{ + QString text = searchLineEdit->text(); + if (text.stripWhiteSpace().isEmpty()) return; + listView->clear(); + checkEpgSearch(text); +} + void KEvents::setCurrentChannelEpg() { ChannelDesc curchan; @@ -288,6 +388,8 @@ sids.clear(); for ( j=0; j<(int)tlist->events.count(); j++ ) { desc = tlist->events.at(j); + if ( desc->title.isEmpty() ) + continue; //if ( mode==1 && desc->tid>0x4f ) if ( sids.contains( desc->sid ) ) continue;