summaryrefslogtreecommitdiffstats
path: root/libkonq/konq_drag.h
blob: 685569db952d82fbfce5b1df59d0984702dc92d8 (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
116
117
118
119
120
121
122
/*  This file is part of the KDE project
    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>

    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; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#ifndef __konqdrag_h__
#define __konqdrag_h__

#include <tqdragobject.h>
#include <tqrect.h>
#include <tqstring.h>
#include <tqiconview.h>

#include <libkonq_export.h>

#include <kurl.h>

/*****************************************************************************
 *
 * Class KonqIconDrag
 *
 *****************************************************************************/

// Clipboard/dnd data for: Icons + URLS + isCut
class LIBKONQ_EXPORT KonqIconDrag : public QIconDrag
{
    Q_OBJECT

public:
    KonqIconDrag( TQWidget * dragSource, const char* name = 0 );
    virtual ~KonqIconDrag() {}

    const char* format( int i ) const;
    TQByteArray tqencodedData( const char* mime ) const;

    void append( const TQIconDragItem &item, const TQRect &pr,
                 const TQRect &tr, const TQString &url );

    void setMoveSelection( bool move ) { m_bCutSelection = move; }

    static bool canDecode( const TQMimeSource* e );

protected: // KDE4: private. And d pointer...
    TQStringList urls;
    bool m_bCutSelection;
};

/**
 * Clipboard/dnd data for: Icons + URLs + MostLocal URLs + isCut
 * KDE4: merge with KonqIconDrag
 * @since 3.5
 */
class LIBKONQ_EXPORT KonqIconDrag2 : public KonqIconDrag
{
    Q_OBJECT

public:
    KonqIconDrag2( TQWidget * dragSource );
    virtual ~KonqIconDrag2() {}

    virtual const char* format( int i ) const;
    virtual TQByteArray tqencodedData( const char* mime ) const;

    void append( const TQIconDragItem &item, const TQRect &pr,
                 const TQRect &tr, const TQString &url, const KURL &mostLocalURL );

private:
    TQStringList m_kdeURLs;
};

// Clipboard/dnd data for: URLS + isCut
class LIBKONQ_EXPORT KonqDrag : public QUriDrag
{
public:
    // KDE4: remove, use KonqDrag constructor instead
    static KonqDrag * newDrag( const KURL::List & urls,
                               bool move, TQWidget * dragSource = 0, const char* name = 0 );

    /**
     * Create a KonqDrag object.
     * @param urls a list of URLs, which can use KDE-specific protocols, like system:/
     * @param mostLocalUrls a list of URLs, which should be resolved to most-local urls, i.e. file:/
     * @param cut false for copying, true for "cutting"
     * @param dragSource parent object
     * @since 3.5
     */
    KonqDrag( const KURL::List & urls, const KURL::List& mostLocalUrls, bool cut, TQWidget * dragSource = 0 );

protected:
    // KDE4: remove
    KonqDrag( const TQStrList & urls, bool cut, TQWidget * dragSource, const char* name );

public:
    virtual ~KonqDrag() {}

    virtual const char* format( int i ) const;
    virtual TQByteArray tqencodedData( const char* mime ) const;

    void setMoveSelection( bool move ) { m_bCutSelection = move; }

    // Returns true if the data was cut (used for KonqIconDrag too)
    static bool decodeIsCutSelection( const TQMimeSource *e );

protected: // KDE4: private. And d pointer...
    bool m_bCutSelection;
    TQStrList m_urls; // this is set to the "most local urls". KDE4: KURL::List
};

#endif