-rw-r--r-- | core/pim/datebook/datebookdayallday.cpp | 25 | ||||
-rw-r--r-- | core/pim/datebook/datebookdayallday.h | 4 |
2 files changed, 19 insertions, 10 deletions
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp index 985f31a..6014eca 100644 --- a/core/pim/datebook/datebookdayallday.cpp +++ b/core/pim/datebook/datebookdayallday.cpp @@ -8,104 +8,112 @@ ****************************************************************************/ #include "datebookdayallday.h" #include <qpushbutton.h> #include <qlayout.h> #include <qvariant.h> #include <qtooltip.h> #include <qwhatsthis.h> #include <qobjectlist.h> #include <qpe/event.h> #include <qpe/ir.h> #include <qpe/datebookdb.h> #include <qpe/resource.h> #include <qpopupmenu.h> #include <qtimer.h> #include <qregexp.h> #include <qdatetime.h> #include "datebookday.h" /* * Constructs a DatebookdayAllday which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ -DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags fl ) - : QWidget( parent, name,fl ),item_count(0),dateBook(db) +DatebookdayAllday::DatebookdayAllday(DateBookDB* db, QWidget* parent, const char* name, WFlags ) + : QScrollView( parent, name ),item_count(0),dateBook(db) { if ( !name ) setName( "DatebookdayAllday" ); setMinimumSize( QSize( 0, 0 ) ); + setMaximumHeight(3* (QFontMetrics(font()).height()+4) ); - datebookdayalldayLayout = new QVBoxLayout( this ); + m_MainFrame = new QFrame(viewport()); + m_MainFrame->setFrameStyle(QFrame::NoFrame|QFrame::Plain); + setFrameStyle(QFrame::NoFrame|QFrame::Plain); + setResizePolicy( QScrollView::AutoOneFit ); + addChild(m_MainFrame); + + datebookdayalldayLayout = new QVBoxLayout( m_MainFrame ); datebookdayalldayLayout->setSpacing( 0 ); datebookdayalldayLayout->setMargin( 0 ); lblDesc = new DatebookEventDesc(parent->parentWidget(),""); lblDesc->setBackgroundColor(Qt::yellow); lblDesc->hide(); subWidgets.setAutoDelete(true); } /* * Destroys the object and frees any allocated resources */ DatebookdayAllday::~DatebookdayAllday() { // no need to delete child widgets, Qt does it all for us } DatebookAlldayDisp* DatebookdayAllday::addEvent(const EffectiveEvent&ev) { DatebookAlldayDisp * lb; - lb = new DatebookAlldayDisp(dateBook,ev,this,NULL); + lb = new DatebookAlldayDisp(dateBook,ev,m_MainFrame,NULL); datebookdayalldayLayout->addWidget(lb); subWidgets.append(lb); - + connect(lb,SIGNAL(displayMe(const Event &)),lblDesc,SLOT(disp_event(const Event&))); ++item_count; return lb; } void DatebookdayAllday::removeAllEvents() { subWidgets.clear(); item_count = 0; } DatebookAlldayDisp::DatebookAlldayDisp(DateBookDB *db,const EffectiveEvent& ev, QWidget* parent,const char* name,WFlags f) : QLabel(parent,name,f),m_Ev(ev),dateBook(db) { QString strDesc = m_Ev.description(); strDesc = strDesc.replace(QRegExp("<"),"<"); setBackgroundColor(yellow); setText(strDesc); setFrameStyle(QFrame::Raised|QFrame::Panel); - QSize s = sizeHint(); - setMaximumSize( QSize( 32767, s.height()-4 ) ); - setMinimumSize( QSize( 0, s.height()-4 ) ); + + int s = QFontMetrics(font()).height()+4; + setMaximumHeight( s ); + setMinimumSize( QSize( 0, s ) ); } DatebookAlldayDisp::~DatebookAlldayDisp() { } void DatebookAlldayDisp::beam_single_event() { // 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 { @@ -202,25 +210,24 @@ void DatebookEventDesc::mousePressEvent(QMouseEvent*) 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/datebookdayallday.h b/core/pim/datebook/datebookdayallday.h index c781785..f5867e5 100644 --- a/core/pim/datebook/datebookdayallday.h +++ b/core/pim/datebook/datebookdayallday.h @@ -1,55 +1,57 @@ #ifndef DATEBOOKDAYALLDAYBASE_H #define DATEBOOKDAYALLDAYBASE_H #include <qvariant.h> #include <qframe.h> +#include <qscrollview.h> #include <qlabel.h> #include <qlist.h> #include <qpe/event.h> class QVBoxLayout; class QHBoxLayout; class QGridLayout; class DatebookAlldayDisp; class DatebookEventDesc; class DateBookDB; -class DatebookdayAllday : public QWidget +class DatebookdayAllday : public QScrollView { Q_OBJECT public: DatebookdayAllday(DateBookDB* db, QWidget* parent = 0, const char* name = 0, WFlags fl = 0); ~DatebookdayAllday(); DatebookAlldayDisp* addEvent(const EffectiveEvent&e); const unsigned int items()const{return item_count;} public slots: void removeAllEvents(); protected: + QFrame * m_MainFrame; QVBoxLayout* datebookdayalldayLayout; DatebookEventDesc * lblDesc; unsigned int item_count; QList<DatebookAlldayDisp> subWidgets; DateBookDB *dateBook; }; class DatebookAlldayDisp : public QLabel { Q_OBJECT public: DatebookAlldayDisp(DateBookDB* db,const EffectiveEvent& e, QWidget* parent=0,const char* name = 0, WFlags fl=0); virtual ~DatebookAlldayDisp(); signals: void deleteMe( const Event &e ); void duplicateMe( const Event &e ); void editMe( const Event &e ); void beamMe( const Event &e ); void displayMe(const Event &e); public slots: |