summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookday.cpp10
-rw-r--r--core/pim/datebook/datebookday.h2
-rw-r--r--core/pim/datebook/datebookdayallday.cpp11
-rw-r--r--core/pim/datebook/datebookweek.cpp4
4 files changed, 13 insertions, 14 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp
index 4d64099..751a1da 100644
--- a/core/pim/datebook/datebookday.cpp
+++ b/core/pim/datebook/datebookday.cpp
@@ -750,111 +750,113 @@ void DateBookDayWidget::paintEvent( QPaintEvent *e )
d = 20;
}
if ( ev.event().hasRepeat() ) {
p.drawPixmap( width() - 16, y, Resource::loadPixmap( "repeat" ) );
d = 20;
y += 20;
}
QSimpleRichText rt( text, font() );
rt.setWidth( geom.width() - d - 6 );
rt.draw( &p, 7, 0, e->region(), colorGroup() );
}
/*
* we need to find the real start date for a uid
* we need to check from one day to another...
*/
QDate DateBookDay::findRealStart( int uid, const QDate& isIncluded , DateBookDB* db) {
QDate dt( isIncluded );
QDate fnd = dt;
bool doAgain = true;
do{
dt = dt.addDays( -1 );
QValueList<EffectiveEvent> events = db->getEffectiveEvents( dt, dt );
for (QValueList<EffectiveEvent>::Iterator it = events.begin(); it != events.end(); ++it ) {
EffectiveEvent ev = (*it);
if ( uid == ev.event().uid() && ev.start() != QTime(0, 0, 0 ) )
return ev.date();
}
}while (doAgain );
return fnd;
}
void DateBookDayWidget::mousePressEvent( QMouseEvent *e )
{
DateBookDayWidget *item;
item = dateBook->getSelectedWidget();
if (item)
item->update();
dateBook->setSelectedWidget(this);
update();
dateBook->repaint();
+ Event eve = ev.event();
+
QPopupMenu m;
m.insertItem( tr( "Edit" ), 1 );
m.insertItem( tr( "Duplicate" ), 4 );
m.insertItem( tr( "Delete" ), 2 );
if(Ir::supported()) m.insertItem( tr( "Beam" ), 3 );
if(Ir::supported() && ev.event().doRepeat() ) m.insertItem( tr( "Beam this occurence"), 5 );
int r = m.exec( e->globalPos() );
if ( r == 1 ) {
- emit editMe( ev.event() );
+ emit editMe( eve );
} else if ( r == 2 ) {
- emit deleteMe( ev.event() );
+ emit deleteMe( eve );
} else if ( r == 3 ) {
- emit beamMe( ev.event() );
+ emit beamMe( eve );
} else if ( r == 4 ) {
- emit duplicateMe( ev.event() );
+ emit duplicateMe( eve );
} else if ( r == 5 ) {
// 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 events
* If it is a multi day event we need to find the real start and end date...
*/
if ( ev.event().start().date() == ev.event().end().date() ) {
Event event( ev.event() );
QDateTime dt( ev.date(), ev.start() );
event.setStart( dt );
dt.setTime( ev.end() );
event.setEnd( dt );
emit beamMe( event );
}else {
/*
* at least the the Times are right now
*/
QDateTime start( ev.event().start() );
QDateTime end ( ev.event().end () );
/*
* ok we know the start date or we need to find it
*/
if ( ev.start() != QTime( 0, 0, 0 ) ) {
start.setDate( ev.date() );
}else {
QDate dt = DateBookDay::findRealStart( ev.event().uid(), ev.date(), dateBook->db );
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 ( ev.end() != QTime(23, 59, 59 ) ) {
end.setDate( ev.date() );
}else{
int days = ev.event().start().date().daysTo( ev.event().end().date() );
end.setDate( start.date().addDays( days ) );
}
diff --git a/core/pim/datebook/datebookday.h b/core/pim/datebook/datebookday.h
index 3898cbc..c8cb26b 100644
--- a/core/pim/datebook/datebookday.h
+++ b/core/pim/datebook/datebookday.h
@@ -79,97 +79,97 @@ protected:
virtual void paintFocus( QPainter *p, const QRect &cr );
virtual void resizeEvent( QResizeEvent *e );
void keyPressEvent( QKeyEvent *e );
void contentsMouseReleaseEvent( QMouseEvent *e );
void initHeader();
private:
bool ampm;
QDate currDate;
DateBookDayViewQuickLineEdit *quickLineEdit;
};
class DateBookDay;
class DateBookDayWidget : public QWidget
{
Q_OBJECT
public:
DateBookDayWidget( const EffectiveEvent &e, DateBookDay *db );
~DateBookDayWidget();
const QRect &geometry() { return geom; }
void setGeometry( const QRect &r );
const EffectiveEvent &event() const { return ev; }
signals:
void deleteMe( const Event &e );
void duplicateMe( const Event &e );
void editMe( const Event &e );
void beamMe( const Event &e );
protected:
void paintEvent( QPaintEvent *e );
void mousePressEvent( QMouseEvent *e );
private:
/**
* Sets the text for an all day Event
* All day events have no time associated
*/
void setAllDayText( QString& text );
/**
* Sets the EventText
* it got a start and an end Time
*/
void setEventText( QString& text );
- const EffectiveEvent ev;
+ EffectiveEvent ev;
DateBookDay *dateBook;
QString text;
QRect geom;
};
//Marker for current time in the dayview
class DateBookDayTimeMarker : public QWidget
{
Q_OBJECT
public:
DateBookDayTimeMarker( DateBookDay *db );
~DateBookDayTimeMarker();
const QRect &geometry() { return geom; }
void setGeometry( const QRect &r );
void setTime( const QTime &t );
signals:
protected:
void paintEvent( QPaintEvent *e );
private:
QRect geom;
QTime time;
DateBookDay *dateBook;
};
//reimplemented the compareItems function so that it sorts DayWidgets by geometry heights
class WidgetListClass : public QList<DateBookDayWidget>
{
private:
int compareItems( QCollection::Item s1, QCollection::Item s2 )
{
//hmm, don't punish me for that ;)
if (reinterpret_cast<DateBookDayWidget*>(s1)->geometry().height() > reinterpret_cast<DateBookDayWidget*>(s2)->geometry().height())
{
return -1;
} else
{
return 1;
}
}
};
diff --git a/core/pim/datebook/datebookdayallday.cpp b/core/pim/datebook/datebookdayallday.cpp
index 2294f3c..1244fd3 100644
--- a/core/pim/datebook/datebookdayallday.cpp
+++ b/core/pim/datebook/datebookdayallday.cpp
@@ -111,125 +111,126 @@ void DatebookAlldayDisp::beam_single_event()
*/
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;
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( m_Ev.event() );
+ emit editMe( ev );
break;
case 2:
- emit deleteMe( m_Ev.event() );
+ emit deleteMe( ev );
break;
case 3:
- emit beamMe( m_Ev.event() );
+ emit beamMe( ev );
break;
case 4:
- emit duplicateMe( m_Ev.event() );
+ emit duplicateMe( ev );
break;
case 5:
beam_single_event();
break;
case 6:
- emit displayMe( m_Ev.event() );
+ 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/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index 8435132..933e191 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -37,99 +37,96 @@ DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e )
{
// with the current implementation change the color for all day events
if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) {
c = Qt::green;
} else {
c = ev.event().hasAlarm() ? Qt::red : Qt::blue;
}
}
void DateBookWeekItem::setGeometry( int x, int y, int w, int h )
{
r.setRect( x, y, w, h );
}
//------------------=---------------------------------------------
DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday,
QWidget *parent, const char *name )
: QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ),
showingEvent( false )
{
items.setAutoDelete( true );
viewport()->setBackgroundMode( PaletteBase );
header = new QHeader( this );
header->addLabel( "" );
header->setMovingEnabled( false );
header->setResizeEnabled( false );
header->setClickEnabled( false, 0 );
initNames();
connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) );
QObject::connect(qApp, SIGNAL(clockChanged(bool)),
this, SLOT(slotChangeClock(bool)));
QFontMetrics fm( font() );
rowHeight = fm.height()+2;
resizeContents( width(), 24*rowHeight );
}
void DateBookWeekView::initNames()
{
-#warning Please review this ! (eilers)
-
- // Ok, I am Mr. Pedantic, but shouldn't we count until 6 instead of 7, if bOnMonday is false ? (eilers)
static bool bFirst = true;
if ( bFirst ) {
if ( bOnMonday ) {
for ( int i = 1; i<=7; i++ ) {
header->addLabel( Calendar::nameOfDay( i ) );
}
} else {
header->addLabel( Calendar::nameOfDay( 7 ) );
for ( int i = 1; i<7; i++ ) {
header->addLabel( Calendar::nameOfDay( i ) );
}
}
bFirst = false;
} else {
// we are change things...
if ( bOnMonday ) {
for ( int i = 1; i<=7; i++ ) {
header->setLabel( i, Calendar::nameOfDay( i ) );
}
} else {
header->setLabel( 1, Calendar::nameOfDay( 7 ) );
for ( int i = 1; i<7; i++ ) {
header->setLabel( i+1, Calendar::nameOfDay( i ) );
}
}
}
}
void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev )
{
items.clear();
QValueListIterator<EffectiveEvent> it;
for ( it = ev.begin(); it != ev.end(); ++it ) {
DateBookWeekItem *i = new DateBookWeekItem( *it );
if(!((i->event().end().hour()==0) && (i->event().end().minute()==0) && (i->event().startDate()!=i->event().date()))) { // Skip events ending at 00:00 starting at another day.
positionItem( i );
items.append( i );
}
}
viewport()->update();
}
@@ -269,97 +266,96 @@ void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch
p->setPen( black );
for ( int t = 0; t < 24; t++ ) {
int y = t*rowHeight;
if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) {
QString s;
if ( ampm ) {
if ( t == 0 )
s = QString::number( 12 );
else if ( t == 12 )
s = QString::number(12) + tr( "p" );
else if ( t > 12 ) {
if ( t - 12 < 10 )
s = " ";
else
s = "";
s += QString::number( t - 12 ) + tr("p");
} else {
if ( 12 - t < 3 )
s = "";
else
s = " ";
s += QString::number( t );
}
} else {
s = QString::number( t );
if ( s.length() == 1 )
s.prepend( "0" );
}
p->drawText( 1, y+p->fontMetrics().ascent()+1, s );
}
}
QListIterator<DateBookWeekItem> it(items);
for ( ; it.current(); ++it ) {
DateBookWeekItem *i = it.current();
if ( i->geometry().intersects( ur ) ) {
p->setBrush( i->color() );
p->drawRect( i->geometry() );
}
}
}
void DateBookWeekView::resizeEvent( QResizeEvent *e )
{
const int hourWidth = 20;
QScrollView::resizeEvent( e );
-#warning check the geometry i have choosen BRANCH_1_0 (waspe)
//HEAD
/*
int avail = visibleWidth();
header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(),
visibleWidth(), header->sizeHint().height() );
setMargins( 0, header->sizeHint().height(), 0, 0 );
*/
//BRANCH_1_0
int avail = width()-qApp->style().scrollBarExtent().width()-1;
header->setGeometry( 0, 0, avail, header->sizeHint().height() );
setMargins( 0, header->height(), 0, 0 );
header->resizeSection( 0, hourWidth );
int sw = (avail - hourWidth) / 7;
for ( int i = 1; i < 7; i++ )
header->resizeSection( i, sw );
header->resizeSection( 7, avail - hourWidth - sw*6 );
}
void DateBookWeekView::setStartOfWeek( bool bStartOnMonday )
{
bOnMonday = bStartOnMonday;
initNames();
}
//-------------------------------------------------------------------
DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB,
QWidget *parent, const char *name )
: QWidget( parent, name ),
db( newDB ),
startTime( 0 ),
ampm( ap ),
bStartOnMonday( startOnMonday )
{
setFocusPolicy(StrongFocus);
QVBoxLayout *vb = new QVBoxLayout( this );
header = new DateBookWeekHeader( bStartOnMonday, this );
view = new DateBookWeekView( ampm, startOnMonday, this );
vb->addWidget( header );
vb->addWidget( view );
lblDesc = new QLabel( this, "event label" );
lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box );
lblDesc->setBackgroundColor( yellow );
lblDesc->hide();