author | alwin <alwin> | 2005-03-18 12:49:14 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-18 12:49:14 (UTC) |
commit | b7996a25adab32e6f2e4d278a9d9801ad66f90c7 (patch) (side-by-side diff) | |
tree | f90bf3aa5cd274c467a8ff3e84566fdfa6a1a6c5 | |
parent | d7fdcc3dac4a1d8cbd823d17ea52d17cb67b16f8 (diff) | |
download | opie-b7996a25adab32e6f2e4d278a9d9801ad66f90c7.zip opie-b7996a25adab32e6f2e4d278a9d9801ad66f90c7.tar.gz opie-b7996a25adab32e6f2e4d278a9d9801ad66f90c7.tar.bz2 |
made plugins configureable, eg, if them will load or not (or switch on/off
at runtime)
events generated from plugins will not editable and so on (check for a
wrong Uid) so them are just text inside datebook.
-rw-r--r-- | core/pim/datebook/datebook.cpp | 50 | ||||
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 7 | ||||
-rw-r--r-- | core/pim/datebook/datebookdayallday.cpp | 2 | ||||
-rw-r--r-- | core/pim/datebook/datebooksettings.cpp | 36 | ||||
-rw-r--r-- | core/pim/datebook/datebooksettings.h | 18 | ||||
-rw-r--r-- | core/pim/datebook/datebooksettingsbase.ui | 59 | ||||
-rw-r--r-- | core/pim/datebook/datebooktypes.h | 7 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 5 |
8 files changed, 144 insertions, 40 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index a7f6691..8ae4f84 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp @@ -153,208 +153,212 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) a->setToggleAction( TRUE ); monthAction = a; sub_bar->addSeparator(); a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); a->addTo( sub_bar ); a = new QAction( tr( "Edit..." ), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); a->addTo( sub_bar ); if(defaultView==DAY) viewDay(); if(defaultView==WEEK) needEvilHack=true; // viewWeek(); if(defaultView==WEEKLST) viewWeekLst(); if(defaultView==MONTH) viewMonth(); connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); #endif // listen on QPE/System #if defined(Q_WS_QWS) #if !defined(QT_NO_COP) QCopChannel *channel = new QCopChannel( "QPE/System", this ); connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); channel = new QCopChannel( "QPE/Datebook", this ); connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receive(const QCString&,const QByteArray&)) ); #endif #endif odebug << "done t=" << t.elapsed() << oendl; connect( qApp, SIGNAL( flush() ), this, SLOT( flush() ) ); connect( qApp, SIGNAL( reload()), this, SLOT( reload() ) ); /* * Here is a problem description: * When Weekview is the default view * a DateBookWeekView get's created * redraw() get's called. So what? * Remember that we're still in the c'tor * and no final layout has happened? Ok * now all Events get arranged. Their x * position get's determined by a QHeader * position. But the QHeader isn't layouted or * at the right position. redraw() is a slot * so we'll call it then via a singleShot * from view() */ if( needEvilHack ){ QTimer::singleShot( 500, this, SLOT(viewWeek()) ); } } void DateBook::receive( const QCString &msg, const QByteArray &data ) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "timeChange(QString)" ) { // update active view! if ( dayAction->isOn() ) viewDay(); else if ( weekAction->isOn() ) viewWeek(); else if ( monthAction->isOn() ) viewMonth(); } else if (msg == "editEvent(int)") { int uid; stream >> uid; Event e=db->eventByUID(uid); editEvent(e); }else if (msg == "viewDefault(QDate)"){ QDate day; stream >> day; viewDefault(day); } } DateBook::~DateBook() { delete db_holiday; } void DateBook::slotSettings() { DateBookSettings frmSettings( ampm, this ); frmSettings.setStartTime( startTime ); frmSettings.setAlarmPreset( aPreset, presetTime ); frmSettings.setJumpToCurTime( bJumpToCurTime ); frmSettings.setRowStyle( rowStyle ); frmSettings.comboDefaultView->setCurrentItem(defaultView-1); frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig); + frmSettings.setPluginList(db_holiday->pluginManager(),db_holiday->pluginLoader()); bool found=false; for (int i=0; i<(frmSettings.comboLocation->count()); i++) { if ( frmSettings.comboLocation->text(i) == defaultLocation ) { frmSettings.comboLocation->setCurrentItem(i); found=true; break; } } if(!found) { frmSettings.comboLocation->insertItem(defaultLocation); frmSettings.comboLocation->setCurrentItem(frmSettings.comboLocation->count()-1); } frmSettings.comboCategory->setCategories(defaultCategories,"Calendar", tr("Calendar")); if ( QPEApplication::execDialog( &frmSettings ) ) { + db_holiday->pluginManager()->save(); + db_holiday->reloadPlugins(); + aPreset = frmSettings.alarmPreset(); presetTime = frmSettings.presetTime(); startTime = frmSettings.startTime(); bJumpToCurTime = frmSettings.jumpToCurTime(); rowStyle = frmSettings.rowStyle(); defaultView=frmSettings.comboDefaultView->currentItem()+1; weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); defaultLocation=frmSettings.comboLocation->currentText(); defaultCategories=frmSettings.comboCategory->currentCategories(); if ( dayView ) { dayView->setStartViewTime( startTime ); dayView->setJumpToCurTime( bJumpToCurTime ); dayView->setRowStyle( rowStyle ); } if ( weekView ) { weekView->setStartViewTime( startTime ); } saveSettings(); // make the change obvious if ( views->visibleWidget() ) { if ( views->visibleWidget() == dayView ) dayView->redraw(); else if ( views->visibleWidget() == weekView ) weekView->redraw(); else if ( views->visibleWidget() == weekLstView ) weekLstView->redraw(); } } } void DateBook::fileNew() { slotNewEventFromKey(""); } QString DateBook::checkEvent(const Event &e) { /* check if overlaps with itself */ bool checkFailed = FALSE; /* check the next 12 repeats. should catch most problems */ QDate current_date = e.start().date(); Event previous = e; for(int i = 0; i < 12; i++) { QDateTime next; if (!nextOccurance(previous, current_date.addDays(1), next)) { break; // no more repeats } if(next < previous.end()) { checkFailed = TRUE; break; } current_date = next.date(); } if(checkFailed) return tr("Event duration is potentially longer\n" "than interval between repeats."); return QString::null; } QDate DateBook::currentDate() { QDate d = QDate::currentDate(); if ( dayView && views->visibleWidget() == dayView ) { d = dayView->date(); } else if ( weekView && views->visibleWidget() == weekView ) { d = weekView->date(); } else if ( weekLstView && views->visibleWidget() == weekLstView ) { d = weekLstView->date(); } else if ( monthView && views->visibleWidget() == monthView ) { d = monthView->selectedDate(); } return d; } void DateBook::view(int v, const QDate &d) { if (v==DAY) { initDay(); dayAction->setOn( TRUE ); dayView->setDate( d ); views->raiseWidget( dayView ); dayView->redraw(); } else if (v==WEEK) { initWeek(); weekAction->setOn( TRUE ); weekView->setDate( d ); views->raiseWidget( weekView ); weekView->redraw(); } else if (v==WEEKLST) { @@ -996,232 +1000,212 @@ void DateBook::slotDoFind( const QString& txt, const QDate &dt, } static QDate searchDate = dt; // if true at the end we will start at the begin again and afterwards // we will emit string not found static bool wrapAround = true; bool candidtate; candidtate = false; QValueList<Event> repeats = db->getRawRepeats(); // find the candidate for the first repeat that matches... // first check if there can ever be a match and then compute // the next occurence from start. See if this event is closer // to the beginning (start. next < dtEnd) and not smaller then the last // result. If we find a canditate we set the dtEnd to the time // of the ocurrence and rev to this occurence. // set wrap around to true because there might be more events coming // and we're not at the end. QValueListConstIterator<Event> it; QDate start = dt; for ( it = repeats.begin(); it != repeats.end(); ++it ) { if ( catComp( (*it).categories(), category ) ) { if ( (*it).match( r ) ) { if ( nextOccurance( *it, start, next ) ) { if ( next < dtEnd && !(next <= rev.start() ) ) { rev = *it; dtEnd = next; rev.setStart( next ); candidtate = true; wrapAround = true; } } } } } // now the for first non repeat... // dtEnd is set by the previous iteration of repeatingEvents // check if we find a closer item. Also set dtEnd to find even // more close occurrence QValueList<Event> nonRepeats = db->getNonRepeatingEvents( dt, dtEnd.date() ); qHeapSort( nonRepeats.begin(), nonRepeats.end() ); for ( it = nonRepeats.begin(); it != nonRepeats.end(); ++it ) { if ( catComp( (*it).categories(), category ) ) { if ( (*it).start() < dtEnd ) { if ( (*it).match( r ) && !(*it <= nonrev) ) { nonrev = *it; dtEnd = nonrev.start(); candidtate = true; wrapAround = true; break; } } } } if ( candidtate ) { dayView->setStartViewTime( dtEnd.time().hour() ); dayView->setDate( dtEnd.date().year(), dtEnd.date().month(), dtEnd.date().day() ); } else { if ( wrapAround ) { emit signalWrapAround(); rev.setStart( QDateTime(QDate(1960, 1, 1), QTime(0, 0, 0)) ); nonrev.setStart( rev.start() ); } else emit signalNotFound(); wrapAround = !wrapAround; } } Event DateBookDBHack::eventByUID(int uid) { // FIXME: Dirty Hacks to get hold of the private event lists QDate start; QDate end=start.addDays(-1); QValueList<Event> myEventList=getNonRepeatingEvents(start,end); QValueList<Event> myRepeatEvents=getRawRepeats(); QValueList<Event>::ConstIterator it; for (it = myEventList.begin(); it != myEventList.end(); it++) { if ((*it).uid() == uid) return *it; } for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { if ((*it).uid() == uid) return *it; } Event ev; return ev; // return at least } DateBookHoliday::DateBookHoliday() { _pluginlist.clear(); m_pluginLoader = new Opie::Core::OPluginLoader("holidays",false); m_pluginLoader->setAutoDelete(true); + m_pluginManager = new Opie::Core::OPluginManager(m_pluginLoader); + m_pluginManager->load(); + + init(); +} + +void DateBookHoliday::reloadPlugins() +{ + deinit(); init(); } DateBookHoliday::~DateBookHoliday() { deinit(); delete m_pluginLoader; + delete m_pluginManager; } void DateBookHoliday::deinit() { -/* QValueList<HPlugin*>::Iterator it; for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { HPlugin*_pl = *it; - // destructs itself? - _pl->_if->release(); - _pl->_lib->unload(); - delete _pl->_lib; + *it = 0; delete _pl; } _pluginlist.clear(); -*/ } #if 0 void debugLst( const Opie::Core::OPluginItem::List& lst ) { for ( Opie::Core::OPluginItem::List::ConstIterator it = lst.begin(); it != lst.end(); ++it ) odebug << "Name " << (*it).name() << " " << (*it).path() << " " << (*it).position() << oendl; } #endif void DateBookHoliday::init() { -#if 0 deinit(); -#endif - Opie::Core::OPluginItem::List lst = m_pluginLoader->allAvailable( false ); + + Opie::Core::OPluginItem::List lst = m_pluginLoader->filtered(true); // debugLst( lst ); for( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ){ Opie::Datebook::HolidayPluginIf*hif = m_pluginLoader->load<Opie::Datebook::HolidayPluginIf>(*it,IID_HOLIDAY_PLUGIN); if (hif) { Opie::Datebook::HolidayPlugin*pl = hif->plugin(); if (pl) { HPlugin*_pl=new HPlugin; _pl->_plugin = pl; odebug << "Found holiday " << pl->description()<<oendl; _pluginlist.append(_pl); //_pl->_if = hif; } } } -#if 0 - QString path = QPEApplication::qpeDir() + "plugins/datebook/holiday"; - QDir dir( path, "lib*.so" ); - QStringList list = dir.entryList(); - QStringList::Iterator it; - for (it=list.begin();it!=list.end();++it) { - Opie::Datebook::HolidayPluginIf*hif = 0; - QLibrary*lib=new QLibrary(path+"/"+*it); - if ((lib->queryInterface(IID_HOLIDAY_PLUGIN,(QUnknownInterface**)&hif) == QS_OK) && hif) { - Opie::Datebook::HolidayPlugin*pl = hif->plugin(); - if (pl) { - HPlugin*_pl=new HPlugin; - _pl->_plugin = pl; - odebug << "Found holiday " << pl->description()<<oendl; - _pl->_lib = lib; - _pl->_if = hif; - _pluginlist.append(_pl); - } else { - } - } else { - delete lib; - } - } -#endif } QStringList DateBookHoliday::holidaylist(const QDate&aDate) { QStringList ret; QValueList<HPlugin*>::Iterator it; for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { HPlugin*_pl = *it; ret+=_pl->_plugin->entries(aDate); } return ret; } QStringList DateBookHoliday::holidaylist(unsigned year, unsigned month, unsigned day) { return holidaylist(QDate(year,month,day)); } QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) { QValueList<EffectiveEvent> ret; QValueList<HPlugin*>::Iterator it; for (it=_pluginlist.begin();it!=_pluginlist.end();++it) { HPlugin*_pl = *it; ret+=_pl->_plugin->events(from,to); } return ret; } QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDate &from,const QDate &to ) { return DateBookDBHack::getEffectiveEvents(from,to); } QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEventsNoHoliday(const QDateTime &start) { return DateBookDBHack::getEffectiveEvents(start); } QValueList<EffectiveEvent> DateBookHoliday::getEffectiveEvents(const QDateTime &start) { return getEffectiveEvents(start.date(),start.date()); } QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents(const QDate &from,const QDate &to ) { QValueList<EffectiveEvent> ret; odebug << "Ueberlagert 1" << oendl; if (db_holiday) { ret+=db_holiday->getEffectiveEvents(from,to); } ret+=getEffectiveEventsNoHoliday(from,to); return ret; } QValueList<EffectiveEvent> DateBookDBHoliday::getEffectiveEvents( const QDateTime &start) { odebug << "Ueberlagert 2" << oendl; return DateBookDBHack::getEffectiveEvents(start); } diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index 00ddd05..26f0303 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp @@ -270,196 +270,197 @@ void DateBookDay::setRowStyle( int style ) if (rowStyle != style) view->setRowStyle( style ); rowStyle = style; } void DateBookDay::updateView( void ) { timeMarker->setTime( QTime::currentTime() ); //need to find a way to update all DateBookDayWidgets } void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) { selectedWidget = w; } DateBookDayWidget * DateBookDay::getSelectedWidget( void ) { return selectedWidget; } void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) { start.setDate( currDate ); end.setDate( currDate ); int sh=99,eh=-1; int n = dayView()->numSelections(); for (int i=0; i<n; i++) { QTableSelection sel = dayView()->selection( i ); sh = QMIN(sh,sel.topRow()); eh = QMAX(sh,sel.bottomRow()+1); } if (sh > 23 || eh < 1) { sh=8; eh=9; } start.setTime( QTime( sh, 0, 0 ) ); end.setTime( QTime( eh, 0, 0 ) ); } void DateBookDay::setDate( int y, int m, int d ) { header->setDate( y, m, d ); selectedWidget = 0; } void DateBookDay::setDate( QDate d) { header->setDate( d.year(), d.month(), d.day() ); selectedWidget = 0; } void DateBookDay::dateChanged( int y, int m, int d ) { QDate date( y, m, d ); if ( currDate == date ) return; currDate.setYMD( y, m, d ); relayoutPage(); dayView()->clearSelection(); QTableSelection ts; if (jumpToCurTime && this->date() == QDate::currentDate()) { ts.init( QTime::currentTime().hour(), 0); ts.expandTo( QTime::currentTime().hour(), 0); } else { ts.init( startTime, 0 ); ts.expandTo( startTime, 0 ); } dayView()->addSelection( ts ); selectedWidget = 0; } void DateBookDay::redraw() { if ( isUpdatesEnabled() ) relayoutPage(); } void DateBookDay::getEvents() { widgetList.clear(); /* clear the AllDay List */ m_allDays->hide(); // just in case m_allDays->removeAllEvents(); QStringList hdays = _holiday_db->holidaylist(currDate); QStringList::Iterator sit; QObject* object = 0; + + /* this way we make sure that holiday dummy events are always + on top of the widgetlist. */ for (sit=hdays.begin();sit!=hdays.end();++sit) { - object = m_allDays->addHoliday(*sit); - if (!object) continue; - /* not to do something with it */ + m_allDays->addHoliday(*sit); } QValueList<EffectiveEvent> eventList = db->getEffectiveEventsNoHoliday( currDate, currDate ); QValueListIterator<EffectiveEvent> it; for ( it = eventList.begin(); it != eventList.end(); ++it ) { EffectiveEvent ev=*it; if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) { // Skip events ending at 00:00 starting at another day. if (ev.event().type() == Event::AllDay ) { object = m_allDays->addEvent( ev ); if (!object) continue; }else { DateBookDayWidget* w = new DateBookDayWidget( *it, this ); widgetList.append( w ); object = w; } connect( object, SIGNAL( deleteMe(const Event&) ), this, SIGNAL( removeEvent(const Event&) ) ); connect( object, SIGNAL( duplicateMe(const Event&) ), this, SIGNAL( duplicateEvent(const Event&) ) ); connect( object, SIGNAL( editMe(const Event&) ), this, SIGNAL( editEvent(const Event&) ) ); connect( object, SIGNAL( beamMe(const Event&) ), this, SIGNAL( beamEvent(const Event&) ) ); } } } static int place( const DateBookDayWidget *item, bool *used, int maxn ) { int place = 0; int start = item->event().start().hour(); QTime e = item->event().end(); int end = e.hour(); if ( e.minute() < 5 ) end--; if ( end < start ) end = start; while ( place < maxn ) { bool free = TRUE; int s = start; while( s <= end ) { if ( used[10*s+place] ) { free = FALSE; break; } s++; } if ( free ) break; place++; } if ( place == maxn ) { return -1; } while( start <= end ) { used[10*start+place] = TRUE; start++; } return place; } void DateBookDay::relayoutPage( bool fromResize ) { setUpdatesEnabled( FALSE ); if ( !fromResize ) { getEvents(); // no need we already have them! if (m_allDays->items() > 0 ) m_allDays->show(); /* * else if ( m_allDays->items() == 0 ) already hide in getEvents */ } widgetList.sort(); //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view int wCount = widgetList.count(); int wid = view->columnWidth(0)-1; int wd; int n = 1; QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); if ( wCount < 20 ) { QArray<QRect> geometries(wCount); for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++); //stores geometry for each widget in vector for ( int i = 0; i < wCount; i++) { QValueList<int> intersectedWidgets; //find all widgets intersecting with widgetList.at(i) diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp index 5b40246..27fce44 100644 --- a/core/pim/datebook/datebookdayallday.cpp +++ b/core/pim/datebook/datebookdayallday.cpp @@ -99,171 +99,171 @@ DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, int s = QFontMetrics(font()).height()+4; setMaximumHeight( s ); setMinimumSize( QSize( 0, s ) ); m_holiday = false; } DatebookAlldayDisp::DatebookAlldayDisp(const QString&aholiday,QWidget* parent,const char* name, WFlags fl) : QLabel(parent,name,fl),m_Ev(),dateBook(0) { QString strDesc = aholiday; strDesc = strDesc.replace(QRegExp("<"),"<"); Event ev; ev.setDescription(strDesc); ev.setAllDay(true); m_Ev.setEvent(ev); setText(strDesc); setAlignment(AlignHCenter); setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum)); //setFrameStyle(QFrame::Raised|QFrame::Panel); //setBackgroundColor(yellow); int s = QFontMetrics(font()).height()+4; setMaximumHeight( s ); setMinimumSize( QSize( 0, s ) ); m_holiday = true; } DatebookAlldayDisp::~DatebookAlldayDisp() { } void DatebookAlldayDisp::beam_single_event() { if (m_holiday) return; // create an Event and beam it... /* * Start with the easy stuff. If start and end date is the same we can just use * the values of effective m_Events * If it is a multi day m_Event we need to find the real start and end date... */ if ( m_Ev.event().start().date() == m_Ev.event().end().date() ) { Event m_Event( m_Ev.event() ); QDateTime dt( m_Ev.date(), m_Ev.start() ); m_Event.setStart( dt ); dt.setTime( m_Ev.end() ); m_Event.setEnd( dt ); emit beamMe( m_Event ); }else { /* * at least the the Times are right now */ QDateTime start( m_Ev.event().start() ); QDateTime end ( m_Ev.event().end () ); /* * ok we know the start date or we need to find it */ if ( m_Ev.start() != QTime( 0, 0, 0 ) ) { start.setDate( m_Ev.date() ); }else { QDate dt = DateBookDay::findRealStart( m_Ev.event().uid(), m_Ev.date(), dateBook ); start.setDate( dt ); } /* * ok we know now the end date... * else * get to know the offset btw the real start and real end * and then add it to the new start date... */ if ( m_Ev.end() != QTime(23, 59, 59 ) ) { end.setDate( m_Ev.date() ); }else{ int days = m_Ev.event().start().date().daysTo( m_Ev.event().end().date() ); end.setDate( start.date().addDays( days ) ); } Event m_Event( m_Ev.event() ); m_Event.setStart( start ); m_Event.setEnd ( end ); emit beamMe( m_Event ); } } void DatebookAlldayDisp::mousePressEvent(QMouseEvent*e) { Event ev = m_Ev.event(); QColor b = backgroundColor(); setBackgroundColor(green); update(); QPopupMenu m; - if (!m_holiday) { + if (ev.isValidUid()) { m.insertItem( DateBookDayWidget::tr( "Edit" ), 1 ); m.insertItem( DateBookDayWidget::tr( "Duplicate" ), 4 ); m.insertItem( DateBookDayWidget::tr( "Delete" ), 2 ); if(Ir::supported()) m.insertItem( DateBookDayWidget::tr( "Beam" ), 3 ); if(Ir::supported() && m_Ev.event().doRepeat() ) m.insertItem( DateBookDayWidget::tr( "Beam this occurence"), 5 ); } m.insertItem( tr( "Info"),6); int r = m.exec( e->globalPos() ); setBackgroundColor(b); update(); switch (r) { case 1: emit editMe( ev ); break; case 2: emit deleteMe( ev ); break; case 3: emit beamMe( ev ); break; case 4: emit duplicateMe( ev ); break; case 5: beam_single_event(); break; case 6: emit displayMe( ev ); break; default: break; } } DatebookEventDesc::DatebookEventDesc(QWidget*parent,const char*name) :QLabel(parent,name) { m_Timer=new QTimer(this); connect(m_Timer,SIGNAL(timeout()),this,SLOT(hide())); setFrameStyle(QFrame::Sunken|QFrame::Panel); setTextFormat(RichText); } DatebookEventDesc::~DatebookEventDesc() { } void DatebookEventDesc::mousePressEvent(QMouseEvent*) { hide(); if (m_Timer->isActive()) m_Timer->stop(); } void DatebookEventDesc::disp_event(const Event&e) { if (m_Timer->isActive()) m_Timer->stop(); QString text; text = "<b><i>"+e.description()+"</i></b><br>"; if (e.notes().length()>0) { text+="<b>"+e.notes()+"</b><br>"; } if (e.location().length()>0) { text+="<i>"+e.location()+"</i><br>"; } text = text.replace(QRegExp("\n"),"<br>"); setText(text); QSize s = sizeHint(); s+=QSize(10,10); resize(s); move( QMAX(0,(parentWidget()->width()-width()) / 2), (parentWidget()->height()-height())/2 ); show(); m_Timer->start(2000,true); } diff --git a/core/pim/datebook/datebooksettings.cpp b/core/pim/datebook/datebooksettings.cpp index cb4b73b..861e266 100644 --- a/core/pim/datebook/datebooksettings.cpp +++ b/core/pim/datebook/datebooksettings.cpp @@ -1,155 +1,191 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "datebooksettings.h" +#include <opie2/opluginloader.h> +#include <opie2/odebug.h> + #include <qpe/qpeapplication.h> #include <qspinbox.h> #include <qcheckbox.h> +#include <qlistview.h> +#include <qheader.h> DateBookSettings::DateBookSettings( bool whichClock, QWidget *parent, const char *name, bool modal, WFlags fl ) : DateBookSettingsBase( parent, name, modal, fl ), ampm( whichClock ) { init(); QObject::connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( slotChangeClock(bool) ) ); QArray<int> categories; comboCategory->setCategories( categories, "Calendar", tr("Calendar") ); + m_loader = 0; + m_manager = 0; + m_PluginListView->header()->hide(); + m_PluginListView->setSorting(-1); } DateBookSettings::~DateBookSettings() { } void DateBookSettings::setStartTime( int newStartViewTime ) { if ( ampm ) { if ( newStartViewTime >= 12 ) { newStartViewTime %= 12; if ( newStartViewTime == 0 ) newStartViewTime = 12; spinStart->setSuffix( tr(":00 PM") ); } else if ( newStartViewTime == 0 ) { newStartViewTime = 12; spinStart->setSuffix( tr(":00 AM") ); } oldtime = newStartViewTime; } spinStart->setValue( newStartViewTime ); } int DateBookSettings::startTime() const { int returnMe = spinStart->value(); if ( ampm ) { if ( returnMe != 12 && spinStart->suffix().contains(tr("PM"), FALSE) ) returnMe += 12; else if (returnMe == 12 && spinStart->suffix().contains(tr("AM"), TRUE)) returnMe = 0; } return returnMe; } +void DateBookSettings::setPluginList(Opie::Core::OPluginManager*aManager,Opie::Core::OPluginLoader*aLoader) +{ + m_manager = aManager; + m_loader = aLoader; + if (!aManager||!aLoader) return; + Opie::Core::OPluginItem::List inLst = m_loader->allAvailable(true); + QCheckListItem *pitem = 0; + + for ( Opie::Core::OPluginItem::List::Iterator it = inLst.begin(); it != inLst.end(); ++it ) { + pitem = new QCheckListItem(m_PluginListView,(*it).name(),QCheckListItem::CheckBox); + pitem->setOn( (*it).isEnabled() ); + } +} + +void DateBookSettings::pluginItemClicked(QListViewItem *aItem) +{ + if (!aItem||!m_manager||!m_loader) return; + QCheckListItem*pitem = ((QCheckListItem*)aItem); + + Opie::Core::OPluginItem::List lst = m_loader->allAvailable( true ); + for ( Opie::Core::OPluginItem::List::Iterator it = lst.begin(); it != lst.end(); ++it ) { + if ( QString::compare( (*it).name() , pitem->text(0) ) == 0 ) { + m_manager->setEnabled((*it),pitem->isOn()); + break; + } + } +} void DateBookSettings::setAlarmPreset( bool bAlarm, int presetTime ) { chkAlarmPreset->setChecked( bAlarm ); if ( presetTime >=5 ) spinPreset->setValue( presetTime ); } bool DateBookSettings::alarmPreset() const { return chkAlarmPreset->isChecked(); } int DateBookSettings::presetTime() const { return spinPreset->value(); } void DateBookSettings::slot12Hour( int i ) { if ( ampm ) { if ( spinStart->suffix().contains( tr("AM"), FALSE ) ) { if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) spinStart->setSuffix( tr(":00 PM") ); } else { if ( oldtime == 12 && i == 11 || oldtime == 11 && i == 12 ) spinStart->setSuffix( tr(":00 AM") ); } oldtime = i; } } void DateBookSettings::init() { if ( ampm ) { spinStart->setMinValue( 1 ); spinStart->setMaxValue( 12 ); spinStart->setValue( 12 ); spinStart->setSuffix( tr(":00 AM") ); oldtime = 12; } else { spinStart->setMinValue( 0 ); spinStart->setMaxValue( 23 ); spinStart->setSuffix( tr(":00") ); } } void DateBookSettings::slotChangeClock( bool whichClock ) { int saveMe; saveMe = spinStart->value(); if ( ampm && spinStart->suffix().contains( tr("AM"), FALSE ) ) { if ( saveMe == 12 ) saveMe = 0; } else if ( ampm && spinStart->suffix().contains( tr("PM"), FALSE ) ) { if ( saveMe != 12 ) saveMe += 12; } ampm = whichClock; init(); setStartTime( saveMe ); } void DateBookSettings::setJumpToCurTime( bool bJump ) { chkJumpToCurTime->setChecked( bJump ); } bool DateBookSettings::jumpToCurTime() const { return chkJumpToCurTime->isChecked(); } void DateBookSettings::setRowStyle( int style ) { comboRowStyle->setCurrentItem( style ); } int DateBookSettings::rowStyle() const { return comboRowStyle->currentItem(); } diff --git a/core/pim/datebook/datebooksettings.h b/core/pim/datebook/datebooksettings.h index cf8a0ff..df7d32c 100644 --- a/core/pim/datebook/datebooksettings.h +++ b/core/pim/datebook/datebooksettings.h @@ -1,55 +1,71 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef DATEBOOKSETTINGS_H #define DATEBOOKSETTINGS_H #include "datebooksettingsbase.h" #include <qpe/categoryselect.h> +namespace Opie { +namespace Core { + class OPluginManager; + class OGenericPluginLoader; + class OPluginLoader; +} +namespace Ui { + class OPluginConfigWidget; +} +} + class DateBookSettings : public DateBookSettingsBase { Q_OBJECT public: DateBookSettings( bool whichClock, QWidget *parent = 0, const char *name = 0, bool modal = TRUE, WFlags = 0 ); ~DateBookSettings(); void setStartTime( int newStartViewTime ); int startTime() const; void setAlarmPreset( bool bAlarm, int presetTime ); bool alarmPreset() const; int presetTime() const; void setAlarmType( int alarmType ); int alarmType() const; void setJumpToCurTime( bool bJump ); bool jumpToCurTime() const; void setRowStyle( int style ); int rowStyle() const; + void setPluginList(Opie::Core::OPluginManager*,Opie::Core::OPluginLoader*); private slots: void slot12Hour( int ); void slotChangeClock( bool ); +protected slots: + virtual void pluginItemClicked(QListViewItem *); -private: +protected: void init(); bool ampm; int oldtime; + Opie::Core::OPluginManager*m_manager; + Opie::Core::OPluginLoader*m_loader; }; #endif diff --git a/core/pim/datebook/datebooksettingsbase.ui b/core/pim/datebook/datebooksettingsbase.ui index e613db1..7b3e591 100644 --- a/core/pim/datebook/datebooksettingsbase.ui +++ b/core/pim/datebook/datebooksettingsbase.ui @@ -1,158 +1,164 @@ <!DOCTYPE UI><UI> <class>DateBookSettingsBase</class> <comment>********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** ** $Id$ ** **********************************************************************</comment> <widget> <class>QDialog</class> <property stdset="1"> <name>name</name> <cstring>DateBookSettingsBase</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> <width>273</width> <height>340</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Preferences</string> </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <vbox> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> - <cstring>TabWidget2</cstring> + <cstring>TabWidget</cstring> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Views</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> <number>11</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout5</cstring> </property> <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <spacer> <property> <name>name</name> <cstring>Spacer1</cstring> </property> <property stdset="1"> <name>orientation</name> <enum>Horizontal</enum> </property> <property stdset="1"> <name>sizeType</name> <enum>Expanding</enum> </property> <property> <name>sizeHint</name> <size> <width>20</width> <height>20</height> </size> </property> </spacer> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel1_2</cstring> </property> <property stdset="1"> <name>text</name> <string>Default view:</string> </property> </widget> <widget> <class>QComboBox</class> <item> <property> <name>text</name> <string>Day</string> </property> </item> <item> <property> <name>text</name> <string>Week</string> </property> </item> <item> <property> <name>text</name> <string>Week List</string> </property> </item> <item> <property> <name>text</name> <string>Month</string> </property> </item> <property stdset="1"> <name>name</name> <cstring>comboDefaultView</cstring> @@ -575,138 +581,187 @@ <enum>MShape</enum> </property> <property stdset="1"> <name>frameShadow</name> <enum>MShadow</enum> </property> <property stdset="1"> <name>text</name> <string>Location:</string> </property> </widget> <widget> <class>QComboBox</class> <item> <property> <name>text</name> <string></string> </property> </item> <item> <property> <name>text</name> <string>Office</string> </property> </item> <item> <property> <name>text</name> <string>Home</string> </property> </item> <property stdset="1"> <name>name</name> <cstring>comboLocation</cstring> </property> <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>7</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>editable</name> <bool>true</bool> </property> <property stdset="1"> <name>currentItem</name> <number>0</number> </property> <property stdset="1"> <name>duplicatesEnabled</name> <bool>false</bool> </property> </widget> </hbox> </widget> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout7_2</cstring> </property> <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>TextLabel2_2_2_2</cstring> </property> <property stdset="1"> <name>text</name> <string>Category:</string> </property> </widget> <widget> <class>CategorySelect</class> <property stdset="1"> <name>name</name> <cstring>comboCategory</cstring> </property> </widget> </hbox> </widget> </vbox> </widget> </vbox> </widget> + <widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>plugintab</cstring> + </property> + <attribute> + <name>title</name> + <string>Plugins</string> + </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> + <widget> + <class>QListView</class> + <column> + <property> + <name>text</name> + <string>Pluginlist</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <property stdset="1"> + <name>name</name> + <cstring>m_PluginListView</cstring> + </property> + </widget> + </vbox> + </widget> </widget> </vbox> </widget> <customwidgets> <customwidget> <class>CategorySelect</class> <header location="global">qpe/categoryselect.h</header> <sizehint> <width>-1</width> <height>-1</height> </sizehint> <container>0</container> <sizepolicy> <hordata>7</hordata> <verdata>1</verdata> </sizepolicy> <pixmap>image0</pixmap> </customwidget> </customwidgets> <images> <image> <name>image0</name> <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> </image> </images> <connections> <connection> <sender>chkAlarmPreset</sender> <signal>toggled(bool)</signal> <receiver>spinPreset</receiver> <slot>setEnabled(bool)</slot> </connection> <connection> <sender>spinStart</sender> <signal>valueChanged(int)</signal> <receiver>DateBookSettingsBase</receiver> <slot>slot12Hour( int )</slot> </connection> - <slot access="public">slotChangeClock( bool )</slot> + <connection> + <sender>m_PluginListView</sender> + <signal>clicked(QListViewItem*)</signal> + <receiver>DateBookSettingsBase</receiver> + <slot>pluginItemClicked(QListViewItem *)</slot> + </connection> + <slot access="protected">pluginItemClicked(QListViewItem *)</slot> <slot access="public">slot12Hour( int )</slot> + <slot access="public">slotChangeClock( bool )</slot> </connections> </UI> diff --git a/core/pim/datebook/datebooktypes.h b/core/pim/datebook/datebooktypes.h index f944e84..2966814 100644 --- a/core/pim/datebook/datebooktypes.h +++ b/core/pim/datebook/datebooktypes.h @@ -1,63 +1,70 @@ #ifndef _DATEBOOK_TYPES_H
#define _DATEBOOK_TYPES_H
#include <qpe/datebookdb.h>
#include <qvaluelist.h>
#include <qstringlist.h>
namespace Opie {
namespace Datebook {
class HolidayPlugin;
class HolidayPluginIf;
}
namespace Core {
class OPluginLoader;
+ class OPluginManager;
}
}
class QLibrary;
class DateBookDBHack : virtual public DateBookDB {
public:
virtual ~DateBookDBHack(){}
Event eventByUID(int id);
};
class DateBookHoliday
{
public:
DateBookHoliday();
virtual ~DateBookHoliday();
QStringList holidaylist(const QDate&);
QStringList holidaylist(unsigned year, unsigned month, unsigned day);
virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
+ void reloadPlugins();
+
+ Opie::Core::OPluginLoader*pluginLoader(){return m_pluginLoader;}
+ Opie::Core::OPluginManager*pluginManager(){return m_pluginManager;}
+
protected:
void init();
void deinit();
struct HPlugin {
Opie::Datebook::HolidayPlugin*_plugin;
//QLibrary*_lib;
//Opie::Datebook::HolidayPluginIf*_if;
};
QValueList<HPlugin*>_pluginlist;
Opie::Core::OPluginLoader*m_pluginLoader;
+ Opie::Core::OPluginManager*m_pluginManager;
};
class DateBookDBHoliday:virtual public DateBookDBHack {
public:
DateBookDBHoliday():DateBookDBHack(){db_holiday=0;}
virtual ~DateBookDBHoliday(){}
virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDate &from,const QDate &to );
virtual QValueList<EffectiveEvent> getEffectiveEvents(const QDateTime &start);
virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDate &from,const QDate &to );
virtual QValueList<EffectiveEvent> getEffectiveEventsNoHoliday(const QDateTime &start);
DateBookHoliday*db_holiday;
};
#endif
diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index b0e78f1..3c871ea 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp @@ -122,193 +122,198 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /* onM */, if (d == QDate::currentDate()) { QPalette pal=label->palette(); pal.setColor(QColorGroup::Foreground, QColor(0,0,255)); label->setPalette(pal); /* QFont f=label->font(); f.setItalic(true); label->setFont(f); label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); */ } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday QPalette pal=label->palette(); pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); label->setPalette(pal); } connect (label, SIGNAL(clicked()), this, SLOT(showDay())); connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); } void DateBookWeekLstDayHdr::showDay() { emit showDate(date.year(), date.month(), date.day()); } void DateBookWeekLstDayHdr::newEvent() { QDateTime start, stop; start=stop=date; start.setTime(QTime(10,0)); stop.setTime(QTime(12,0)); emit addEvent(start,stop,"",0); } DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, int weeklistviewconfig, QWidget* parent, const char* name, WFlags fl ) : OClickableLabel(parent,name,fl), event(ev) { // old values... lastday = "__|__", middle=" |---", Firstday="00:00", QString s,start,middle,end,day; odebug << "weeklistviewconfig=" << weeklistviewconfig << oendl; if(weeklistviewconfig==NONE) { // No times displayed. // start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); // middle.sprintf("<--->"); // end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); // day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); } else if(weeklistviewconfig==NORMAL) { // "Normal", only display start time. start.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); middle.sprintf(" |---"); end.sprintf("__|__"); day.sprintf("%.2d:%.2d",ev.start().hour(),ev.start().minute()); } else if(weeklistviewconfig==EXTENDED) { // Extended mode, display start and end times. start.sprintf("%.2d:%.2d-",ev.start().hour(),ev.start().minute()); middle.sprintf("<--->"); end.sprintf("-%.2d:%.2d",ev.end().hour(),ev.end().minute()); day.sprintf("%.2d:%.2d-%.2d:%.2d",ev.start().hour(),ev.start().minute(),ev.end().hour(),ev.end().minute()); } if(ev.event().type() == Event::Normal) { if(ev.startDate()==ev.date() && ev.endDate()==ev.date()) { // day event. s=day; } else if(ev.startDate()==ev.date()) { // start event. s=start; } else if(ev.endDate()==ev.date()) { // end event. s=end; } else { // middle day. s=middle; } } else { s=""; } setText(QString(s) + " " + ev.description()); // connect(this, SIGNAL(clicked()), this, SLOT(editMe())); setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); } void DateBookWeekLstEvent::editMe() { emit editEvent(event.event()); } void DateBookWeekLstEvent::duplicateMe() { emit duplicateEvent(event.event()); } void DateBookWeekLstEvent::deleteMe() { emit removeEvent(event.event()); emit redraw(); } void DateBookWeekLstEvent::beamMe() { emit beamEvent( event.event() ); } void DateBookWeekLstEvent::mousePressEvent( QMouseEvent *e ) { + if (!event.event().isValidUid()) { + // this is just such a holiday event. + return; + } popmenue = new QPopupMenu; + popmenue->insertItem( tr( "Edit" ), this, SLOT(editMe())); popmenue->insertItem( tr( "Duplicate" ), this, SLOT(duplicateMe())); popmenue->insertItem( tr( "Delete" ), this, SLOT(deleteMe())); if(Ir::supported()) popmenue->insertItem( tr( "Beam" ), this, SLOT(beamMe())); popmenue->popup( mapToGlobal( e->pos() )); } DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, QWidget* parent, const char* name, WFlags fl) : QWidget( parent, name, fl ) { Config config("DateBook"); config.setGroup("Main"); int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL); odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl; bStartOnMonday=onM; setPalette(white); setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); QVBoxLayout *layout = new QVBoxLayout( this ); qBubbleSort(ev); QValueListIterator<EffectiveEvent> it; it=ev.begin(); int dayOrder[7]; if (bStartOnMonday) { for (int d=0; d<7; d++) dayOrder[d]=d+1; } else { for (int d=0; d<7; d++) dayOrder[d]=d; dayOrder[0]=7; } // Calculate offset to first day of week. int dayoffset=d.dayOfWeek(); if(bStartOnMonday) dayoffset--; else if( dayoffset == 7 ) dayoffset = 0; for (int i=0; i<7; i++) { // Header DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,this); connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); layout->addWidget(hdr); // Events while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,this); layout->addWidget(l); connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); connect (l, SIGNAL(redraw()), this, SIGNAL(redraw())); } it++; } layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); } } DateBookWeekLstView::~DateBookWeekLstView(){} void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, QValueList<EffectiveEvent> &ev2, QDate &d, bool onM, QWidget* parent, const char* name, WFlags fl) : QWidget( parent, name, fl ) { QHBoxLayout *layout = new QHBoxLayout( this ); DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); layout->addWidget(w); connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); connect (w, SIGNAL(redraw()), this, SIGNAL(redraw())); connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); connect (w, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)), this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&))); w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); layout->addWidget(w); connect (w, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&))); connect (w, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &))); connect (w, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &))); connect (w, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &))); |