summaryrefslogtreecommitdiffstats
path: root/src/multibuffer.h
blob: c60e779ebbd379e6e6a2a5d915c6153d614ec1b7 (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
/*
 * KDevelop Multiple Buffer Support
 *
 * Copyright (c) 2005 Adam Treat <treat@kde.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Library 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; if not, write to the
 * Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
#ifndef MULTIBUFFER_H
#define MULTIBUFFER_H

#include <tqpair.h>
#include <tqsplitter.h>
#include <tqguardedptr.h>

namespace KParts
{
class Part;
class Factory;
class ReadOnlyPart;
}

class KURL;

typedef TQMap< KURL, KParts::Part* > BufferMap;
typedef TQMap< KParts::Part*, TQPair<int, int> > ActivationMap;

class MultiBuffer : public TQSplitter
{
    Q_OBJECT
  
public:
    MultiBuffer( TQWidget * parent = 0 );
    virtual ~MultiBuffer();

    KParts::Part *activeBuffer() const;
    bool hasURL( const KURL &url ) const;
    bool hasPart( KParts::Part *part );
    int numberOfBuffers() const;
    bool isActivated() const;
    void setDelayedActivation( bool delayed );

    KParts::Part* createPart( const TQString &mimeType,
                              const TQString &partType,
                              const TQString &className,
                              const TQString &preferredName = TQString() );

    KParts::Part* openURL( const KURL &url );
    bool closeURL( const KURL &url );

    void registerURL( const KURL &url, KParts::Part *part );
    void registerDelayedActivation( KParts::Part *part, int line, int col );

    void updateUrlForPart( KParts::Part *part, KURL url );

public slots:
    virtual void show();
    virtual void setOrientation( Qt::Orientation );
    void activePartChanged( const KURL &url );

protected:
    virtual void focusInEvent( TQFocusEvent *ev );

private:
    KParts::Part* createPart( const KURL &url );

private:
    BufferMap m_buffers;
    TQGuardedPtr<KParts::Factory> m_editorFactory;
    ActivationMap m_delayedActivation;
    bool m_delayActivate;
    bool m_activated;
    TQGuardedPtr<KParts::Part> m_activeBuffer;
};

#endif

// kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on