kontact

iconsidepane.h
1 /*
2  This file is part of the KDE Kontact.
3 
4  Copyright (C) 2003 Cornelius Schumacher <schumacher@kde.org>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; see the file COPYING. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 #ifndef KONTACT_ICONSIDEPANEBASE_H
22 #define KONTACT_ICONSIDEPANEBASE_H
23 
24 #include <tqtooltip.h>
25 
26 #include <tdelistbox.h>
27 
28 #include "sidepanebase.h"
29 #include "prefs.h"
30 
31 
32 class TQSignalMapper;
33 
34 namespace KParts { class Part; }
35 
36 namespace Kontact
37 {
38 
39 class Core;
40 class IconSidePane;
41 class Plugin;
42 class Navigator;
43 
44 enum IconViewMode { LargeIcons = 48, NormalIcons = 32, SmallIcons = 22, ShowText = 3, ShowIcons = 5 };
45 
46 
51 class EntryItem : public TQListBoxItem
52 {
53  public:
55  ~EntryItem();
56 
57  Kontact::Plugin *plugin() const { return mPlugin; }
58 
59  const TQPixmap *pixmap() const { return &mPixmap; }
60 
61  Navigator* navigator() const;
62 
63  void setHover( bool );
64  void setPaintActive( bool );
65  bool paintActive() const { return mPaintActive; }
69  virtual int width( const TQListBox * ) const;
73  virtual int height( const TQListBox * ) const;
74 
75  protected:
76  void reloadPixmap();
77 
78  virtual void paint( TQPainter *p );
79 
80  private:
81  Kontact::Plugin *mPlugin;
82  TQPixmap mPixmap;
83  bool mHasHover;
84  bool mPaintActive;
85 };
86 
91 class EntryItemToolTip : public TQToolTip
92 {
93  public:
94  EntryItemToolTip( TQListBox* parent )
95  : TQToolTip( parent->viewport() ), mListBox( parent )
96  {}
97  protected:
98  void maybeTip( const TQPoint& p ) {
99  // We only show tooltips when there are no texts shown
100  if ( Prefs::self()->sidePaneShowText() ) return;
101  if ( !mListBox ) return;
102  TQListBoxItem* item = mListBox->itemAt( p );
103  if ( !item ) return;
104  const TQRect itemRect = mListBox->itemRect( item );
105  if ( !itemRect.isValid() ) return;
106 
107  const EntryItem *entryItem = static_cast<EntryItem*>( item );
108  TQString tipStr = entryItem->text();
109  tip( itemRect, tipStr );
110  }
111  private:
112  TQListBox* mListBox;
113 };
114 
118 class Navigator : public TDEListBox
119 {
120  TQ_OBJECT
121 
122  public:
123  Navigator( IconSidePane *parent = 0, const char *name = 0 );
124 
125  virtual void setSelected( TQListBoxItem *, bool );
126 
127  void updatePlugins( TQValueList<Kontact::Plugin*> plugins );
128 
129  TQSize sizeHint() const;
130 
131  void highlightItem( EntryItem* item );
132 
133  IconViewMode viewMode() { return mViewMode; }
134  IconViewMode sizeIntToEnum(int size) const;
135  const TQPtrList<TDEAction> & actions() { return mActions; }
136  bool showIcons() const { return mShowIcons; }
137  bool showText() const { return mShowText; }
138  signals:
139  void pluginActivated( Kontact::Plugin * );
140 
141  protected:
142  void dragEnterEvent( TQDragEnterEvent * );
143  void dragMoveEvent ( TQDragMoveEvent * );
144  void dropEvent( TQDropEvent * );
145  void resizeEvent( TQResizeEvent * );
146  void enterEvent( TQEvent* );
147  void leaveEvent( TQEvent* );
148 
149  void setHoverItem( TQListBoxItem*, bool );
150  void setPaintActiveItem( TQListBoxItem*, bool );
151 
152  protected slots:
153  void slotExecuted( TQListBoxItem * );
154  void slotMouseOn( TQListBoxItem *item );
155  void slotMouseOff();
156  void slotShowRMBMenu( TQListBoxItem *, const TQPoint& );
157  void shortCutSelected( int );
158  void slotStopHighlight();
159 
160  private:
161  IconSidePane *mSidePane;
162  IconViewMode mViewMode;
163 
164  TQListBoxItem* mMouseOn;
165 
166  EntryItem* mHighlightItem;
167 
168  TQSignalMapper *mMapper;
169  TQPtrList<TDEAction> mActions;
170  bool mShowIcons;
171  bool mShowText;
172 };
173 
174 class IconSidePane : public SidePaneBase
175 {
176  TQ_OBJECT
177 
178  public:
179  IconSidePane( Core *core, TQWidget *parent, const char *name = 0 );
180  ~IconSidePane();
181 
182  virtual void indicateForegrunding( Kontact::Plugin* );
183 
184  public slots:
185  virtual void updatePlugins();
186  virtual void selectPlugin( Kontact::Plugin* );
187  virtual void selectPlugin( const TQString &name );
188  const TQPtrList<TDEAction> & actions() { return mNavigator->actions(); }
189 
190  private:
191  Navigator *mNavigator;
192 };
193 
194 }
195 
196 #endif
This class provides the interface to the Kontact core for the plugins.
Definition: core.h:42
Tooltip that changes text depending on the item it is above.
Definition: iconsidepane.h:92
A TQListBoxPixmap Square Box with an optional icon and a text underneath.
Definition: iconsidepane.h:52
virtual int width(const TQListBox *) const
returns the width of this item.
virtual int height(const TQListBox *) const
returns the height of this item.
Navigation pane showing all parts relevant to the user.
Definition: iconsidepane.h:119
Base class for all Plugins in Kontact.
Definition: plugin.h:59