Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

datebookweeklstview.cpp

Go to the documentation of this file.
00001 #include "datebookweeklstview.h"
00002 #include "datebooktypes.h"
00003 #include "datebookweeklstdayhdr.h"
00004 #include "datebookweeklstheader.h"
00005 #include "datebookweeklstevent.h"
00006 
00007 #include <opie2/odebug.h>
00008 
00009 #include <qpe/config.h>
00010 
00011 #include <qlayout.h>
00012 #include <qtl.h>
00013 
00014 DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev,
00015                      const QDate &d, bool onM,
00016                      QWidget* parent,
00017                      const char* name, WFlags fl)
00018     : QWidget( parent, name, fl )
00019 {
00020     childs.clear();
00021     m_MainLayout = new QVBoxLayout( this );
00022     setEvents(ev,d,onM);
00023 }
00024 
00025 void DateBookWeekLstView::setEvents(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM)
00026 {
00027     QValueList<QObject*>::Iterator wIter;
00028     for (wIter=childs.begin();wIter!=childs.end();++wIter) {
00029         QObject*w = (*wIter);
00030         delete w;
00031     }
00032     childs.clear();
00033 
00034     setUpdatesEnabled(false);
00035 //    m_MainLayout->deleteAllItems();
00036     Config config("DateBook");
00037     config.setGroup("Main");
00038     int weeklistviewconfig=config.readNumEntry("weeklistviewconfig", NORMAL);
00039     odebug << "weeklistviewconfig: " << weeklistviewconfig << oendl;
00040 
00041     bStartOnMonday=onM;
00042     setPalette(white);
00043     setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
00044 
00045     qBubbleSort(ev);
00046     QValueListIterator<EffectiveEvent> it;
00047     it=ev.begin();
00048 
00049     int dayOrder[7];
00050     if (bStartOnMonday) {
00051         for (int d=0; d<7; d++) dayOrder[d]=d+1;
00052     } else {
00053         for (int d=0; d<7; d++) dayOrder[d]=d;
00054         dayOrder[0]=7;
00055     }
00056 
00057     // Calculate offset to first day of week.
00058     int dayoffset=d.dayOfWeek();
00059     if(bStartOnMonday) dayoffset--;
00060     else if( dayoffset == 7 ) dayoffset = 0;
00061 
00062     for (int i=0; i<7; i++) {
00063         QWidget*w = new QWidget(this);
00064         w->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
00065         w->setPalette(white);
00066         QVBoxLayout * tlayout = new QVBoxLayout(w);
00067         childs.append(w);
00068     // Header
00069         DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i-dayoffset), bStartOnMonday,w);
00070         connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int)));
00071         connect(hdr, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)),
00072             this, SIGNAL(addEvent(const QDateTime&,const QDateTime&,const QString&,const QString&)));
00073         tlayout->addWidget(hdr);
00074 
00075         // Events
00076         while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) {
00077             if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) {  // Skip events ending at 00:00 starting at another day.
00078                 DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,weeklistviewconfig,w);
00079                 tlayout->addWidget(l);
00080                 connect (l, SIGNAL(editEvent(const Event&)), this, SIGNAL(editEvent(const Event&)));
00081                 connect (l, SIGNAL(duplicateEvent(const Event &)), this, SIGNAL(duplicateEvent(const Event &)));
00082                 connect (l, SIGNAL(removeEvent(const Event &)), this, SIGNAL(removeEvent(const Event &)));
00083                 connect (l, SIGNAL(beamEvent(const Event &)), this, SIGNAL(beamEvent(const Event &)));
00084                 connect (l, SIGNAL(redraw()), this, SIGNAL(redraw()));
00085             }
00086             it++;
00087         }
00088         tlayout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding));
00089         m_MainLayout->addWidget(w);
00090 /*
00091         QSpacerItem * tmp = new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding);
00092         m_MainLayout->addItem(tmp);
00093 */
00094     }
00095     setUpdatesEnabled(true);
00096 }
00097 
00098 DateBookWeekLstView::~DateBookWeekLstView()
00099 {}
00100 
00101 void DateBookWeekLstView::keyPressEvent(QKeyEvent *e)
00102 {
00103     e->ignore();
00104 }

Generated on Sat Nov 5 16:15:49 2005 for OPIE by  doxygen 1.4.2