korganizer Library API Documentation

koincidencetooltip.h

00001 /*
00002     This file is part of KOrganizer.
00003     Copyright (c) 2003
00004     Reinhold Kainhofer <reinhhold@kainhofer.com>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 #ifndef KOINCIDENCETOOLTIP_H
00025 #define KOINCIDENCETOOLTIP_H
00026 
00027 #include <qtooltip.h>
00028 #include "koagendaitem.h"
00029 
00030 namespace KCal
00031 {
00032 class Incidence;
00033 class Event;
00034 class Todo;
00035 class Journal;
00036 }
00037 using namespace KCal;
00038 template<class T> class ToolTipVisitor;
00042 template<class T>
00043 class KOIncidenceToolTip : public QToolTip
00044 {
00045   public:
00046     KOIncidenceToolTip(T* widget, QToolTipGroup * group = 0 ):QToolTip (widget, group) {}
00047 /*    ~KOIncidenceToolTip();*/
00048 
00049   public:
00050     static void add ( T* item,
00051                       QToolTipGroup * group = 0,
00052                       const QString & longText = "" )
00053     {
00054         if ( !item || !item->incidence() ) return;
00055         QString tipText;
00056         ToolTipVisitor<T> v;
00057         v.act( item, &tipText, true );
00058         QToolTip::add(item, tipText, group, longText);
00059     }
00060 
00061 };
00062 
00063 template<class T>
00064 class ToolTipVisitor : public Incidence::Visitor
00065 {
00066   public:
00067     ToolTipVisitor()
00068         : mRichText( true ),
00069           mTipText(0),
00070           mItem(0)
00071     {}
00072 
00073     bool act( T* item, QString* tipText, bool richText=true)
00074     {
00075       mTipText = tipText;
00076       mRichText = richText;
00077       mItem = item;
00078       return item->incidence() ? item->incidence()->accept( *this ) : false;
00079     }
00080 
00081   protected:
00082     bool visit( Event *event );
00083     bool visit( Todo *todo );
00084     bool visit( Journal *journal );
00085 
00086     QString dateRangeText( Event*event );
00087     QString dateRangeText( Todo *todo );
00088     QString dateRangeText( Journal *journal );
00089 
00090     bool generateToolTip( Incidence* incidence, QString dtRangeText );
00091 
00092   protected:
00093     bool mRichText;
00094     QString *mTipText;
00095     T *mItem;
00096 };
00097 
00098 
00099 #endif
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Dec 21 14:25:45 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003