summaryrefslogtreecommitdiffstats
path: root/libkonq/konq_filetip.h
blob: 667204e6c0eb02b96a0717835f74615acff28d21 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* This file is part of the KDE projects
   Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
   Copyright (C) 2000, 2001, 2002 David Faure <david@mandrakesoft.com>
   Copyright (C) 2004 Martin Koller <m.koller@surfeu.at>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef KONQ_FILETIP_H
#define KONQ_FILETIP_H

#include <tqframe.h>
#include <tqpixmap.h>
#include <kio/previewjob.h>

#include <libkonq_export.h>

class KFileItem;
class QLabel;
class QScrollView;
class QTimer;

//--------------------------------------------------------------------------------

class LIBKONQ_EXPORT KonqFileTip : public QFrame
{
  Q_OBJECT

  public:
    KonqFileTip( TQScrollView *parent );
    ~KonqFileTip();

    void setPreview(bool on);

    /**
      @param on show tooltip at all
      @param preview include file preview in tooltip
      @param num the number of tooltip texts to get from KFileItem
      */
    void setOptions( bool on, bool preview, int num );

    /** Set the item from which to get the tip information
      @param item the item from which to get the tip information
      @param rect the rectangle around which the tip will be shown
      @param pixmap the pixmap to be shown. If 0, no pixmap is shown
      */
    void setItem( KFileItem *item, const TQRect &rect = TQRect(),
                  const TQPixmap *pixmap = 0 );

    virtual bool eventFilter( TQObject *, TQEvent *e );

  protected:
    virtual void drawContents( TQPainter *p );
    virtual void resizeEvent( TQResizeEvent * );

  private slots:
    void gotPreview( const KFileItem*, const TQPixmap& );
    void gotPreviewResult();

    void startDelayed();
    void showTip();
    void hideTip();

  private:
    void setFilter( bool enable );

    void reposition();

    TQLabel*    m_iconLabel;
    TQLabel*    m_textLabel;
    bool       m_on : 1;
    bool       m_preview : 1;  // shall the preview icon be shown
    bool       m_filter : 1;
    TQPixmap    m_corners[4];
    int        m_corner;
    int        m_num;
    TQScrollView* m_view;
    KFileItem* m_item;
    KIO::PreviewJob* m_previewJob;
    TQRect      m_rect;
    TQTimer*    m_timer;
};

#endif