[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    Re: [Kde-pim] [PATCH] KAgenda L&F changes
From:       Tim Jansen <ml () tjansen ! de>
Date:       2003-07-23 20:13:50
[Download RAW message or body]

On Wednesday 23 July 2003 11:53, Cornelius Schumacher wrote:
> Some nitpicking and some more serious issues:
> - KOAgendaItem::updateIcons(): Instead of "if(mIncidence->isReadOnly())
> mIconReadonly = true; else mIconReadonly = false;" you could simply write
> "mIconReadOnly = mIncidence->isReadOnly()", same for the other lines like
> that. 

Indeed. That's because I just converted the old QPixmap to booleans. Changed 
in the attached patch.

> Does it make sense at all to use all this variables. Wouldn't it be 
> easier to access the values by mIncidence and the appropriate functions in
> the painting code?

I think it makes sense to separate it, as for some icons the code is 
relatively complicated and it would be a bad idea to mix the algorithms to 
determine the icons with the rendering code itself. 

> - You should put the opening brace of a function on a new line (see e.g.
> conditionalPaint() )

Done.

> - Please don't use tabs (some of the KWordWrap calls contain tabs).

Ok, done.

> - Why do you rename the config file group for the category colors? This
> means that the user loses hist custom category color settings, right?

That was the intention, yes :)
The problem is that otherwise KOrganizer uses the default colors that have 
been stored in the config file before, and they usually look bad with the 
frame.


> - All-day events shouldn't never have a time header.

Why? They currently have a special form of headers: on the first day they show 
the start time, and on the last day the end time. The events between them 
don't have a header. IMHO this is consistent with the rest. The header line 
is also needed for icons.

> - Wouldn't it look better to center the text on the item, at least when it
> isn't wrapped? Especially with multiple day all-day events it looks odd
> when the text is on the

IMHO this looks better for one-line descriptions, but bad when the description 
has several lines. Having 10 lines h-centered looks really odd. Changed it 
this way.

> - When the highlight color is very dark, the text becomes invisible when
> the item is selected. The text of the item should be switched to white, if
> the background color becomes to dark to provide sufficient contrast.

Ok, done.

> - When the highlight color is very similar to the color of the event (e.g.
> because of a category color), it becomes impossible to tell, if an event is
> selected or not. I think we need another way to indicate selection of an
> event than only changing the color.

What about changing the frame color? Changed the patch to make the frame 
brighter when selected.

> - Todos shouldn't have an end time shown.

Done.

> - I'm not sure that I agree with you on the pixel spacing between items.

Ok, removed it.

bye...

["korganizer-agenda.patch" (text/x-diff)]

Index: koagenda.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/koagenda.cpp,v
retrieving revision 1.66
diff -u -3 -p -r1.66 koagenda.cpp
--- koagenda.cpp	22 Jul 2003 18:56:44 -0000	1.66
+++ koagenda.cpp	23 Jul 2003 20:09:21 -0000
@@ -855,6 +855,7 @@ void KOAgenda::placeSubCells(KOAgendaIte
     moveChild(placeItem,x,y);
   }
   placeItem->setConflictItems(conflictItems);
+  placeItem->update();
 }
 
 /*
@@ -916,6 +917,8 @@ void KOAgenda::drawContents(QPainter* p,
                  mSelectionHeight, KOPrefs::instance()->mHighlightColor );
   }
 
+  dbp.setPen( KOPrefs::instance()->mAgendaBgColor.dark(150) );
+
   // Draw vertical lines of grid
   //  kdDebug(5850) << "drawContents cx: " << cx << " cy: " << cy << " cw: " << cw \
<< " ch: " << ch << endl;  int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
@@ -1015,7 +1018,6 @@ KOAgendaItem *KOAgenda::insertItem (Inci
   }
 
   KOAgendaItem *agendaItem = new KOAgendaItem (event,qd,viewport());
-  agendaItem->setFrameStyle(WinPanel|Raised);
 
   int YSize = YBottom - YTop + 1;
   if (YSize < 0) {
@@ -1053,7 +1055,6 @@ KOAgendaItem *KOAgenda::insertAllDayItem
   }
 
   KOAgendaItem *agendaItem = new KOAgendaItem (event,qd,viewport());
-  agendaItem->setFrameStyle(WinPanel|Raised);
 
   agendaItem->setCellXY(XBegin,0,0);
   agendaItem->setCellXWidth(XEnd);
Index: koagenda.h
===================================================================
RCS file: /home/kde/kdepim/korganizer/koagenda.h,v
retrieving revision 1.32
diff -u -3 -p -r1.32 koagenda.h
--- koagenda.h	7 Apr 2003 21:43:06 -0000	1.32
+++ koagenda.h	23 Jul 2003 20:09:22 -0000
@@ -24,6 +24,7 @@
 #define KOAGENDA_H
 
 #include <qscrollview.h>
+#include <qlabel.h>
 #include <qtimer.h>
 #include <qmemarray.h>
 #include <qguardedptr.h>
Index: koagendaitem.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/koagendaitem.cpp,v
retrieving revision 1.37
diff -u -3 -p -r1.37 koagendaitem.cpp
--- koagendaitem.cpp	9 Apr 2003 18:57:50 -0000	1.37
+++ koagendaitem.cpp	23 Jul 2003 20:09:22 -0000
@@ -17,15 +17,14 @@
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
-#include <qlabel.h>
-#include <qlayout.h>
-#include <qhbox.h>
 #include <qtooltip.h>
 #include <qdragobject.h>
+#include <qpainter.h>
 
 #include <kiconloader.h>
 #include <kdebug.h>
 #include <klocale.h>
+#include <kwordwrap.h>
 
 #include <libkcal/icaldrag.h>
 #include <libkcal/vcaldrag.h>
@@ -43,61 +42,16 @@ QToolTipGroup *KOAgendaItem::mToolTipGro
 
 KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,
                            const char *name,WFlags) :
-  QFrame(parent, name), mIncidence(incidence), mDate(qd)
+  QWidget(parent, name), mIncidence(incidence), mDate(qd),
+  mLabelText(mIncidence->summary()), mIconAlarm(false),
+  mIconRecur(false), mIconReadonly(false), mIconReply(false),
+  mIconGroup(false), mIconOrganizer(false)
 {
+  setBackgroundMode(Qt::NoBackground);
   mFirstMultiItem = 0;
   mNextMultiItem = 0;
   mLastMultiItem = 0;
 
-  QHBox *box = 0;
-
-  if ( incidence->type() == "Todo" )
-  {
-    static const QPixmap todoPxmp = SmallIcon("todo");
-    static const QPixmap completedPxmp = SmallIcon("checkedbox");
-
-    box = new QHBox(this);
-    QLabel *todoIcon = new QLabel(box);
-
-    if ( (static_cast<Todo*>(incidence))->isCompleted() )
-      todoIcon->setPixmap(completedPxmp);
-    else
-      todoIcon->setPixmap(todoPxmp);
-
-    todoIcon->setAlignment(AlignLeft|AlignTop);
-
-    mItemLabel = new QLabel(mIncidence->summary(),box,"KOAgendaItem::itemLabel");
-  }
-  else
-    mItemLabel = new QLabel(mIncidence->summary(),this,"KOAgendaItem::itemLabel");
-
-  // if a Todo item is overdue and not completed, always show it in overdue color
-  if ( (incidence->type() == "Todo") &&
-       ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
-         ((static_cast<Todo*>(incidence))->dtDue() < QDate::currentDate()) ) )
-    setPalette(QPalette(KOPrefs::instance()->mTodoOverdueColor,
-                        KOPrefs::instance()->mTodoOverdueColor));
-  else {
-    QStringList categories = mIncidence->categories();
-    QString cat = categories.first();
-    if (cat.isEmpty()) {
-      setPalette(QPalette(KOPrefs::instance()->mEventColor,
-                          KOPrefs::instance()->mEventColor));
-    } else {
-      setPalette(QPalette(*(KOPrefs::instance()->categoryColor(cat)),
-                          *(KOPrefs::instance()->categoryColor(cat))));
-    }
-  }
-
-  mItemLabel->setAlignment(AlignCenter|WordBreak);
-  mItemLabel->setMouseTracking(true);
-
-  mItemLabel->installEventFilter(this);
-
-  mItemLabel->setFrameStyle(Panel|Sunken);
-
-  mItemLabel->setFont(KOPrefs::instance()->mAgendaViewFont);
-
   setCellXY(0,0,1);
   setCellXWidth(0);
   setSubCell(0);
@@ -106,59 +60,6 @@ KOAgendaItem::KOAgendaItem(Incidence *in
   setMultiItem(0,0,0);
 
   startMove();
-
-  mIconAlarm = new QLabel(this,"KOAgendaItem::IconAlarmLabel");
-  mIconRecur = new QLabel(this,"KOAgendaItem::IconRecurLabel");
-  mIconReadonly = new QLabel(this,"KOAgendaItem::IconReadonlyLabel");
-  mIconReply = new QLabel(this,"KOAgendaItem::IconReplyLabel");
-  mIconGroup = new QLabel(this,"KOAgendaItem::IconGroupLabel");
-  mIconOrganizer = new QLabel(this,"KOAgendaItem::IconOrganizerLabel");
-
-  mIconAlarm->installEventFilter(this);
-  mIconRecur->installEventFilter(this);
-  mIconReadonly->installEventFilter(this);
-  mIconReply->installEventFilter(this);
-  mIconGroup->installEventFilter(this);
-  mIconOrganizer->installEventFilter(this);
-
-  mIconAlarm->setMouseTracking(true);
-  mIconRecur->setMouseTracking(true);
-  mIconReadonly->setMouseTracking(true);
-  mIconReply->setMouseTracking(true);
-  mIconGroup->setMouseTracking(true);
-  mIconOrganizer->setMouseTracking(true);
-
-  static const QPixmap alarmPxmp = SmallIcon("bell");
-  static const QPixmap recurPxmp = SmallIcon("recur");
-  static const QPixmap readonlyPxmp = SmallIcon("readonlyevent");
-  static const QPixmap replyPxmp = SmallIcon("mail_reply");
-  static const QPixmap groupPxmp = SmallIcon("groupevent");
-  static const QPixmap organizerPxmp = SmallIcon("organizer");
-
-  mIconAlarm->setPixmap(alarmPxmp);
-  mIconRecur->setPixmap(recurPxmp);
-  mIconReadonly->setPixmap(readonlyPxmp);
-  mIconReply->setPixmap(replyPxmp);
-  mIconGroup->setPixmap(groupPxmp);
-  mIconOrganizer->setPixmap(organizerPxmp);
-
-  QVBoxLayout *topLayout = new QVBoxLayout(this,margin()+3);
-  if ( incidence->type() == "Todo" )
-    topLayout->addWidget(box, 1);
-  else
-    topLayout->addWidget(mItemLabel,1);
-
-  QBoxLayout *iconLayout = new QHBoxLayout;
-  topLayout->addLayout(iconLayout);
-
-  iconLayout->addWidget(mIconAlarm);
-  iconLayout->addWidget(mIconRecur);
-  iconLayout->addWidget(mIconReadonly);
-  iconLayout->addWidget(mIconReply);
-  iconLayout->addWidget(mIconGroup);
-  iconLayout->addWidget(mIconOrganizer);
-  iconLayout->addStretch(1);
-
   updateIcons();
 
   // select() does nothing, if state hasn't change, so preset mSelected.
@@ -195,47 +96,37 @@ KOAgendaItem::KOAgendaItem(Incidence *in
 
 void KOAgendaItem::updateIcons()
 {
-  if (mIncidence->isReadOnly()) mIconReadonly->show();
-  else mIconReadonly->hide();
-
-  if (mIncidence->recurrence()->doesRecur()) mIconRecur->show();
-  else mIconRecur->hide();
-
-  if (mIncidence->isAlarmEnabled()) mIconAlarm->show();
-  else mIconAlarm->hide();
-
+  mIconReadonly = mIncidence->isReadOnly();
+  mIconRecur = mIncidence->recurrence()->doesRecur();
+  mIconAlarm = mIncidence->isAlarmEnabled();
   if (mIncidence->attendeeCount()>0) {
     if (mIncidence->organizer() == KOPrefs::instance()->email()) {
-      mIconReply->hide();
-      mIconGroup->hide();
-      mIconOrganizer->show();
+      mIconReply = false;
+      mIconGroup = false;
+      mIconOrganizer = true;
     }
     else {
       Attendee *me = \
mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
  if (me!=0) {
         if (me->status()==Attendee::NeedsAction && me->RSVP()) {
-          mIconReply->show();
-          mIconGroup->hide();
-          mIconOrganizer->hide();
+          mIconReply = true;
+          mIconGroup = false;
+          mIconOrganizer = false;
         }
         else {
-          mIconReply->hide();
-          mIconGroup->show();
-          mIconOrganizer->hide();
+          mIconReply = false;
+          mIconGroup = true;
+          mIconOrganizer = false;
         }
       }
       else {
-        mIconReply->hide();
-        mIconGroup->show();
-        mIconOrganizer->hide();
+        mIconReply = false;
+        mIconGroup = true;
+        mIconOrganizer = false;
       }
     }
   }
-  else {
-    mIconReply->hide();
-    mIconGroup->hide();
-    mIconOrganizer->hide();
-  }
+  update();
 }
 
 
@@ -243,36 +134,8 @@ void KOAgendaItem::select(bool selected)
 {
   if (mSelected == selected) return;
   mSelected = selected;
-  if (mSelected) {
-    mItemLabel->setFrameStyle(Panel|Sunken);
-    mItemLabel->setLineWidth(1);
-  } else {
-    mItemLabel->setFrameStyle(Panel|Plain);
-    mItemLabel->setLineWidth(0);
-  }
-}
-
 
-/*
-  The eventFilter has to filter the mouse events of the agenda item childs. The
-  events are fed into the event handling method of KOAgendaItem. This allows the
-  KOAgenda to handle the KOAgendaItems by using an eventFilter.
-*/
-bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
-{
-//  kdDebug(5850) << "KOAgendaItem::eventFilter" << endl;
-  if (e->type() == QEvent::MouseButtonPress ||
-      e->type() == QEvent::MouseButtonDblClick ||
-      e->type() == QEvent::MouseButtonRelease ||
-      e->type() == QEvent::MouseMove) {
-    QMouseEvent *me = (QMouseEvent *)e;
-    QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
-                                         mapToGlobal(me->pos()));
-    QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
-    return event(&returnEvent);
-  } else {
-    return false;
-  }
+  update();
 }
 
 
@@ -457,3 +320,209 @@ void KOAgendaItem::addConflictItem(KOAge
   if (mConflictItems.find(ci)<0)
     mConflictItems.append(ci);
 }
+
+void KOAgendaItem::paintFrame(QPainter *p,
+                              const QColor &color)
+{
+  p->setPen( color );
+  p->drawRect( 0, 0, width(), height() );
+  p->drawRect( 1, 1, width()-2, height()-2 );
+}
+
+static void conditionalPaint(QPainter *p, bool cond, int &x, int ft,
+                             const QPixmap &pxmp)
+{
+  if (!cond)
+    return;
+  p->drawPixmap( x, ft, pxmp);
+  x += pxmp.width() + ft;
+}
+
+void KOAgendaItem::paintTodoIcon(QPainter *p, int &x, int ft)
+{
+  static const QPixmap todoPxmp = SmallIcon("todo");
+  static const QPixmap completedPxmp = SmallIcon("checkedbox");
+  if ( mIncidence->type() != "Todo" )
+    return;
+  bool b = (static_cast<Todo*>(mIncidence))->isCompleted();
+  conditionalPaint(p, b, x, ft, todoPxmp);
+  conditionalPaint(p, !b, x, ft, completedPxmp);
+}
+
+static QColor getTextColor(const QColor &c) {
+  float luminance = (c.red() * 0.299) + (c.green() * 0.587) + (c.blue() * 0.114);
+  return (luminance > 128.0) ? QColor( 0, 0 ,0 ) : QColor( 255, 255 ,255 );
+}
+
+void KOAgendaItem::paintEvent(QPaintEvent *)
+{
+  QPainter p(this);
+  const int ft = 2; // frame thickness for layout, see paintFrame()
+  const int margin = 1 + ft; // frame + space between frame and content
+
+  static const QPixmap alarmPxmp = SmallIcon("bell");
+  static const QPixmap recurPxmp = SmallIcon("recur");
+  static const QPixmap readonlyPxmp = SmallIcon("readonlyevent");
+  static const QPixmap replyPxmp = SmallIcon("mail_reply");
+  static const QPixmap groupPxmp = SmallIcon("groupevent");
+  static const QPixmap organizerPxmp = SmallIcon("organizer");
+
+  QColor bgColor;
+  if ( (mIncidence->type() == "Todo") &&
+       ( !((static_cast<Todo*>(mIncidence))->isCompleted()) &&
+         ((static_cast<Todo*>(mIncidence))->dtDue() < QDate::currentDate()) ) )
+    bgColor = KOPrefs::instance()->mTodoOverdueColor;
+  else {
+    QStringList categories = mIncidence->categories();
+    QString cat = categories.first();
+    if (cat.isEmpty())
+      bgColor = KOPrefs::instance()->mEventColor;
+    else
+      bgColor = *(KOPrefs::instance()->categoryColor(cat));
+  }
+
+  QColor frameColor = mSelected ? bgColor.light(115) : bgColor.dark(115);
+  QColor textColor = getTextColor(bgColor);
+  p.setPen( textColor );
+  p.setBackgroundColor( bgColor );
+  p.setFont(KOPrefs::instance()->mAgendaViewFont);
+  QFontMetrics fm = p.fontMetrics();
+
+  int singleLineHeight = fm.boundingRect( mLabelText ).height();
+
+  // case 1: do not draw text when not even a single line fits
+  if ( ( singleLineHeight > height() ) || // ignore margin, be gentle..
+       ( width() < 16 ) ) {
+    p.eraseRect( 0, 0, width(), height() );
+    int x = margin;
+    paintTodoIcon( &p, x, ft );
+    paintFrame( &p, frameColor );
+    return;
+  }
+
+  // case 2: draw a single line when no more space
+  if ( (2 * singleLineHeight) > (height() - 2 * margin) ) {
+    p.eraseRect( 0, 0, width(), height() );
+    int x = margin;
+    paintTodoIcon( &p, x, ft );
+    int y = ((height() - 2 * ft - singleLineHeight) / 2) + fm.ascent();
+    KWordWrap::drawFadeoutText( &p, x, y,
+                                width() - margin - x, mLabelText );
+    paintFrame( &p, frameColor );
+    return;
+  }
+
+  KWordWrap *ww = KWordWrap::formatText( fm,
+                                         QRect(0, 0,
+                                         width() - (2 * margin), 0),
+                                         0,
+                                         mLabelText );
+  int th = ww->boundingRect().height();
+  delete ww;
+
+  // calculate the height of the full version (case 4) to test whether it is
+  // possible
+  QString shortH;
+  QString longH;
+  if ( (!mFirstMultiItem) && (!mNextMultiItem) ) {
+    shortH = KGlobal::locale()->formatTime(mIncidence->dtStart().time());
+    if (mIncidence->type() != "Todo")
+      longH = i18n("%1 - %2").arg(shortH)
+               .arg(KGlobal::locale()->formatTime(mIncidence->dtEnd().time()));
+    else
+      longH = shortH;
+  }
+  else if ( !mFirstMultiItem ) {
+    shortH = KGlobal::locale()->formatTime(mIncidence->dtStart().time());
+    longH = shortH;
+  }
+  else {
+    shortH = KGlobal::locale()->formatTime(mIncidence->dtEnd().time());
+    longH = i18n("- %1").arg(shortH);
+  }
+
+  int hlHeight = QMAX(fm.boundingRect(longH).height(),
+     QMAX(alarmPxmp.height(), QMAX(recurPxmp.height(),
+     QMAX(readonlyPxmp.height(), QMAX(replyPxmp.height(),
+     QMAX(groupPxmp.height(), organizerPxmp.height()))))));
+  bool completelyRenderable =
+    th <= (height() - 2 * ft - hlHeight);
+
+  // case 3: enough for 2-5 lines, but not for the header.
+  //         Also used for the middle days in multi-events
+  if ( ((!completelyRenderable) &&
+        ((height() - (2 * margin)) <= (5 * singleLineHeight)) ) ||
+         (mNextMultiItem && mFirstMultiItem) ) {
+    int x = margin;
+    ww = KWordWrap::formatText( fm,
+                                QRect(0, 0, width() - margin - x,
+                                height() - (2 * margin)),
+                                0,
+                                mLabelText );
+    p.eraseRect( 0, 0, width(), height() );
+    paintTodoIcon( &p, x, ft );
+    ww->drawText( &p, x, margin, Qt::AlignAuto | KWordWrap::FadeOut );
+    delete ww;
+    paintFrame( &p, frameColor );
+    return;
+  }
+
+  // case 4: paint everything, with header:
+  // consists of (vertically) ft + headline&icons + ft + text + margin
+  int y = 2 * ft + hlHeight;
+  if ( completelyRenderable )
+    y += (height() - (2 * ft) - margin - hlHeight - th) / 2;
+  ww = KWordWrap::formatText( fm,
+                              QRect(0, 0, width() - (2 * margin),
+                              height() - margin - y),
+                              0,
+                              mLabelText );
+
+  p.eraseRect( 0, 0, width(), height() );
+
+  // paint headline
+  p.fillRect( 0, 0, width(), (ft/2) + margin + hlHeight,
+              QBrush( frameColor ) );
+
+  int x = margin;
+  paintTodoIcon( &p, x, ft );
+  conditionalPaint( &p, mIconAlarm, x, ft, alarmPxmp );
+  conditionalPaint( &p, mIconRecur, x, ft, recurPxmp );
+  conditionalPaint( &p, mIconReadonly, x, ft, readonlyPxmp );
+  conditionalPaint( &p, mIconReply, x, ft, replyPxmp );
+  conditionalPaint( &p, mIconGroup, x, ft, groupPxmp );
+  conditionalPaint( &p, mIconOrganizer, x, ft, organizerPxmp );
+
+  QString headline;
+  int hw = fm.boundingRect( longH ).width();
+  if ( hw > (width() - x - margin) ) {
+    headline = shortH;
+    hw = fm.boundingRect( shortH ).width();
+    if ( hw < (width() - x - margin) )
+      x += (width() - x - margin - hw) / 2;
+    else
+      headline = "";
+  }
+  else {
+    headline = longH;
+    x += (width() - x - margin - hw) / 2;
+  }
+  p.setBackgroundColor( frameColor );
+  p.setPen( getTextColor( frameColor ) );
+  KWordWrap::drawFadeoutText( &p, x, ft + fm.ascent(),
+                              width() - margin - x, headline );
+
+  // draw event text
+  p.setBackgroundColor( bgColor );
+  p.setPen( textColor );
+  QString ws = ww->wrappedString();
+  if ( ws.left( ws.length()-1 ).find( '\n' ) >= 0 )
+    ww->drawText( &p, margin, y,
+                  Qt::AlignAuto | KWordWrap::FadeOut );
+  else
+    ww->drawText( &p, margin + (width()-ww->boundingRect().width()-2*margin)/2,
+                  y, Qt::AlignHCenter | KWordWrap::FadeOut );
+  delete ww;
+  paintFrame( &p, frameColor );
+}
+
Index: koagendaitem.h
===================================================================
RCS file: /home/kde/kdepim/korganizer/koagendaitem.h,v
retrieving revision 1.20
diff -u -3 -p -r1.20 koagendaitem.h
--- koagendaitem.h	26 Jun 2003 15:00:52 -0000	1.20
+++ koagendaitem.h	23 Jul 2003 20:09:22 -0000
@@ -20,7 +20,6 @@
 #define KOAGENDAITEM_H
 
 #include <qframe.h>
-#include <qlabel.h>
 #include <qdatetime.h>
 
 #include <libkcal/incidence.h>
@@ -37,7 +36,7 @@ using namespace KCal;
   eventfiler for its children, if it has children, and it has to pass mouse
   events from the cildren to itself. See eventFilter().
 */
-class KOAgendaItem : public QFrame
+class KOAgendaItem : public QWidget
 {
     Q_OBJECT
   public:
@@ -79,17 +78,15 @@ class KOAgendaItem : public QFrame
 
     Incidence *incidence() const { return mIncidence; }
     QDate itemDate() { return mDate; }
-    
-    /** Update the date of this item's occurrence (not in the event) */ 
+
+    /** Update the date of this item's occurrence (not in the event) */
     void setItemDate(QDate qd);
-    
-    void setText ( const QString & text ) { mItemLabel->setText(text); }
-    QString text () { return mItemLabel->text(); }
 
-    virtual bool eventFilter ( QObject *, QEvent * );
+    void setText ( const QString & text ) { mLabelText = text; }
+    QString text () { return mLabelText; }
 
     static QToolTipGroup *toolTipGroup();
-    
+
     QPtrList<KOAgendaItem> conflictItems();
     void setConflictItems(QPtrList<KOAgendaItem>);
     void addConflictItem(KOAgendaItem *ci);
@@ -101,6 +98,9 @@ class KOAgendaItem : public QFrame
   protected:
     void dragEnterEvent(QDragEnterEvent *e);
     void dropEvent(QDropEvent *e);
+    void paintEvent(QPaintEvent *e);
+    void paintFrame(QPainter *p, const QColor &color);
+    void paintTodoIcon(QPainter *p, int &x, int ft);
 
   private:
     int mCellX;
@@ -121,10 +121,9 @@ class KOAgendaItem : public QFrame
 
     Incidence *mIncidence; // corresponding event or todo
     QDate mDate; //date this events occurs (for recurrence)
-
-    QLabel *mItemLabel;
-    QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
-    QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
+    QString mLabelText;
+    bool mIconAlarm, mIconRecur, mIconReadonly;
+    bool mIconReply, mIconGroup, mIconOrganizer;
 
     static QToolTipGroup *mToolTipGroup;
 
Index: komonthview.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/komonthview.cpp,v
retrieving revision 1.71
diff -u -3 -p -r1.71 komonthview.cpp
--- komonthview.cpp	22 Jul 2003 18:56:45 -0000	1.71
+++ komonthview.cpp	23 Jul 2003 20:09:22 -0000
@@ -32,6 +32,7 @@
 #include <kglobal.h>
 #include <kconfig.h>
 #include <kiconloader.h>
+#include <kwordwrap.h>
 
 #include <kcalendarsystem.h>
 
@@ -47,6 +48,7 @@
 #include "komonthview.h"
 #include "komonthview.moc"
 
+
 KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
   : QListBox(parent, name),
     mSqueezing(false)
@@ -138,12 +140,6 @@ MonthViewItem::MonthViewItem( Incidence 
   mReply = false;
 }
 
-static QColor mixColors(double p1, QColor c1, QColor c2) {
-  return QColor(int(c1.red() * p1 + c2.red() * (1.0-p1)),
-                int(c1.green() * p1 + c2.green() * (1.0-p1)),
-		int(c1.blue() * p1 + c2.blue() * (1.0-p1)));
-}
-
 void MonthViewItem::paint(QPainter *p)
 {
 #if QT_VERSION >= 0x030000
@@ -184,33 +180,7 @@ void MonthViewItem::paint(QPainter *p)
 	  QColorGroup::HighlightedText : QColorGroup::Foreground );
   p->setPen( textColor );
 
-  // try to fade out the text if it does not fit
-  QString t = text();
-  int maxW = listBox()->width() - x;
-  if ( ( fm.boundingRect( t ).width() > maxW ) && ( t.length() > 1 ) ) {
-    uint tl = 0;
-    int w = 0;
-    while ( tl < t.length() ) {
-      w += fm.charWidth( t, tl );
-      if ( w >= maxW )
-        break;
-      tl++;
-    }
-
-    if (tl > 3) {
-      p->drawText( x, yPos, t.left( tl - 3 ) );
-      x += fm.width( t.left( tl - 3 ) );
-    }
-    int n = QMIN( tl, 3);
-    for (int i = 0; i < n; i++) {
-      p->setPen( mixColors( 0.70 - i * 0.25, textColor, bgColor ) );
-      QString s( t.at( tl - n + i ) );
-      p->drawText( x, yPos, s );
-      x += fm.width( s );
-    }
-  }
-  else
-    p->drawText( x, yPos, t );
+  KWordWrap::drawFadeoutText(p, x, yPos, listBox()->width() - x, text());
 }
 
 int MonthViewItem::height(const QListBox *lb) const
Index: koprefs.cpp
===================================================================
RCS file: /home/kde/kdepim/korganizer/koprefs.cpp,v
retrieving revision 1.71
diff -u -3 -p -r1.71 koprefs.cpp
--- koprefs.cpp	15 Jul 2003 07:45:40 -0000	1.71
+++ koprefs.cpp	23 Jul 2003 20:09:23 -0000
@@ -48,13 +48,13 @@ KOPrefs::KOPrefs() :
 {
   mCategoryColors.setAutoDelete(true);
 
-  mDefaultCategoryColor           = QColor(196,196,196);
-  QColor defaultHolidayColor      = QColor("red");
-  QColor defaultHighlightColor    = KGlobalSettings::highlightColor(); 
-  QColor defaultAgendaBgColor     = QColor(128,128,128);
-  QColor defaultWorkingHoursColor = QColor(160,160,160);
-  QColor defaultTodoDueTodayColor = QColor("orange");
-  QColor defaultTodoOverdueColor  = QColor("red");
+  mDefaultCategoryColor           = QColor(151, 235, 121);
+  QColor defaultHolidayColor      = QColor(255, 100, 100);
+  QColor defaultHighlightColor    = QColor(100, 100, 255);
+  QColor defaultAgendaBgColor     = QColor(255, 255, 255);
+  QColor defaultWorkingHoursColor = QColor(225, 225, 255);
+  QColor defaultTodoDueTodayColor = QColor(255, 200, 50);
+  QColor defaultTodoOverdueColor  = QColor(255, 100, 100);
 
   mDefaultTimeBarFont = KGlobalSettings::generalFont();
   mDefaultViewFont = KGlobalSettings::generalFont();
@@ -100,7 +100,7 @@ KOPrefs::KOPrefs() :
   addItemFont("AgendaView Font",mAgendaViewFont, mDefaultViewFont);
   addItemFont("MarcusBains Font",mMarcusBainsFont, mDefaultViewFont);
 
-  KPrefs::setCurrentGroup("Colors");
+  KPrefs::setCurrentGroup("Colors2");
 
   addItemColor("Holiday Color",mHolidayColor,defaultHolidayColor);
   addItemColor("Highlight Color",mHighlightColor,defaultHighlightColor);
@@ -258,7 +258,7 @@ void KOPrefs::usrReadConfig()
   mEmail = config()->readEntry("user_email");
   fillMailDefaults();
 
-  config()->setGroup("Category Colors");
+  config()->setGroup("Category Colors2");
   QStringList::Iterator it;
   for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
     setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
@@ -281,7 +281,7 @@ void KOPrefs::usrWriteConfig()
   config()->writeEntry("user_name",mName);
   config()->writeEntry("user_email",mEmail);
 
-  config()->setGroup("Category Colors");
+  config()->setGroup("Category Colors2");
   QDictIterator<QColor> it(mCategoryColors);
   while (it.current()) {
     config()->writeEntry(it.currentKey(),*(it.current()));



_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic