summaryrefslogtreecommitdiffstats
path: root/src/part/radialMap/widget.h
blob: 3b8ae0035ba6456e6fb9d39ef0edbe92fa98007a (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//Author:    Max Howell <max.howell@methylblue.com>, (C) 2004
//Copyright: See COPYING file that comes with this distribution

#ifndef WIDGET_H
#define WIDGET_H

#include <kurl.h>
#include <tqtimer.h>
#include "segmentTip.h"

template <class T> class Chain;
class Directory;
class File;
namespace TDEIO { class Job; }
class KURL;

namespace RadialMap
{
    class Segment;

    class Map : public KPixmap
    {
    public:
        Map();
        ~Map();

        void make( const Directory *, bool = false );
        bool resize( const TQRect& );

        bool isNull() const { return ( m_signature == 0 ); }
        void invalidate( const bool );

        friend class Builder;
        friend class Widget;

    private:
        void paint( uint = 1 );
        void aaPaint();
        void colorise();
        void setRingBreadth();

        Chain<Segment> *m_signature;

        TQRect   m_rect;
        uint    m_ringBreadth;  ///ring breadth
        uint    m_innerRadius;  ///radius of inner circle
        uint    m_visibleDepth; ///visible level depth of system
        TQString m_centerText;

        uint MAP_2MARGIN;
    };

    class Widget : public TQWidget
    {
        Q_OBJECT
  

    public:
        Widget( TQWidget* = 0, const char* = 0 );
        ~Widget() { delete m_tip; }

        TQString path() const;
        KURL url( File const * const = 0 ) const;

        bool isValid() const { return m_tree != 0; }

        friend class Label; //FIXME badness

    public slots:
        void zoomIn();
        void zoomOut();
        void create( const Directory* );
        void invalidate( const bool = true );
        void refresh( int );

    private slots:
        void resizeTimeout();
        void sendFakeMouseEvent();
        void deleteJobFinished( TDEIO::Job* );
        void createFromCache( const Directory* );

    signals:
        void activated( const KURL& );
        void invalidated( const KURL& );
        void created( const Directory* );
        void mouseHover( const TQString& );
        void giveMeTreeFor( const KURL& );

    protected:
        virtual void paintEvent( TQPaintEvent* );
        virtual void resizeEvent( TQResizeEvent* );
        virtual void mouseMoveEvent( TQMouseEvent* );
        virtual void mousePressEvent( TQMouseEvent* );
        virtual void dragEnterEvent( TQDragEnterEvent* );
        virtual void dropEvent( TQDropEvent* );

    protected:
        const Segment *segmentAt( TQPoint& ) const; //FIXME const reference for a library others can use
        const Segment *rootSegment() const { return m_rootSegment; } ///never == 0
        const Segment *focusSegment() const { return m_focus; } ///0 == nothing in focus

    private:
        void paintExplodedLabels( TQPainter& ) const;

        const Directory *m_tree;
        const Segment   *m_focus;
        TQPoint           m_offset;
        TQTimer           m_timer;
        Map              m_map;
        SegmentTip       *m_tip;
        Segment         *m_rootSegment;
    };
}

#endif