summaryrefslogtreecommitdiffstats
path: root/kmail/folderviewtooltip.h
blob: f7e3953e22a6f04989a897a19c9021af89a6c4ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef __FOLDERVIEWTOOLTIP_H__
#define __FOLDERVIEWTOOLTIP_H__

#include <kmfoldercachedimap.h>

#include <tqtooltip.h>

namespace KMail {

class FolderViewToolTip : public TQToolTip
{
  public:
    FolderViewToolTip( TQListView* parent ) :
      TQToolTip( parent->viewport() ),
      mListView( parent ) {}

  protected:
    void maybeTip( const TQPoint &point )
    {
      KMFolderTreeItem *item = dynamic_cast<KMFolderTreeItem*>( mListView->itemAt( point ) );
      if  ( !item )
        return;
      const TQRect itemRect = mListView->itemRect( item );
      if ( !itemRect.isValid() )
        return;
      const TQRect headerRect = mListView->header()->sectionRect( 0 );
      if ( !headerRect.isValid() )
        return;
      
      if ( !item->folder() || item->folder()->noContent() )
        return;
      
      item->updateCount();
      TQString tipText = i18n("<qt><b>%1</b><br>Total: %2<br>Unread: %3<br>Size: %4" )
          .arg( item->folder()->prettyURL().replace( " ", "&nbsp;" ) )
          .arg( item->totalCount() < 0 ? "-" : TQString::number( item->totalCount() ) )
          .arg( item->unreadCount() < 0 ? "-" : TQString::number( item->unreadCount() ) )
          .arg( TDEIO::convertSize( item->folderSize() ) );
      
      if ( KMFolderCachedImap* imap = dynamic_cast<KMFolderCachedImap*>( item->folder()->storage() ) ) {
          QuotaInfo info = imap->quotaInfo();
          if ( info.isValid() && !info.isEmpty() )
              tipText += i18n("<br>Quota: %1").arg( info.toString() );
      }
      
      tip( TQRect( headerRect.left(), itemRect.top(), headerRect.width(), itemRect.height() ), tipText );
    }

  private:
    TQListView *mListView;
};

}

#endif /* __FOLDERVIEWTOOLTIP_H__ */