summaryrefslogtreecommitdiffstats
path: root/src/itemeffectsmanager.h
blob: abfc0090b043ed1c8677b1800823bbcf67f8e050 (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
/***************************************************************************
 *   Copyright (C) 2006 by Peter Penz                                      *
 *   peter.penz@gmx.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; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 ***************************************************************************/

#ifndef ITEMEFFECTSMANAGER_H
#define ITEMEFFECTSMANAGER_H

#include <tqobject.h>
#include <tqpixmap.h>
#include <kurl.h>
#include <tqvaluelist.h>
class KFileItem;

/**
 * @brief Abstract class to implement item effects for a Dolphin view.
 *
 * Derived classes must implement the following pure virtual methods:
 * - ItemEffectsManager::setContextPixmap()
 * - ItemEffectsManager::contextPixmap()
 * - ItemEffectsManager::firstContext()
 * - ItemEffectsManager::nextContext()
 * - ItemEffectsManager::contextFileInfo()
 *
 * The item effects manager highlights currently active items and also
 * respects cutted items. A 'context' is defined as abstract data type,
 * which usually is represented by a KFileListViewItem or
 * a KFileIconViewItem.
 *
 * In TQt4 the item effects manager should get integrated as part of Interview
 * and hence no abstract context handling should be necessary anymore. The main
 * purpose of the current interface is to prevent code duplication as there is
 * no common model shared by TQListView and TQIconView of TQt3.
 *
 * @see DolphinIconsView
 * @see DolphinDetailsView
 * @author Peter Penz <peter.penz@gmx.at>
 */
class ItemEffectsManager
{
public:
    ItemEffectsManager();
    virtual ~ItemEffectsManager();

    /** Is invoked before the items get updated. */
    virtual void beginItemUpdates() = 0;

    /** Is invoked after the items have been updated. */
    virtual void endItemUpdates() = 0;

    /**
     * Increases the size of the current set view mode and refreshes
     * all views. Derived implementations must invoke the base implementation
     * if zooming in had been done.
     */
    virtual void zoomIn();

    /**
     * Decreases the size of the current set view mode and refreshes
     * all views. Derived implementations must invoke the base implementation
     * if zooming out had been done.
     */
    virtual void zoomOut();

    /**
     * Returns true, if zooming in is possible. If false is returned,
     * the minimal zoom size is possible.
     */
    virtual bool isZoomInPossible() const = 0;

    /**
     * Returns true, if zooming in is possible. If false is returned,
     * the minimal zoom size is possible.
     */
    virtual bool isZoomOutPossible() const = 0;

protected:
    virtual void setContextPixmap(void* context,
                                  const TQPixmap& pixmap) = 0;
    virtual const TQPixmap* contextPixmap(void* context) = 0;
    virtual void* firstContext() = 0;
    virtual void* nextContext(void* context) = 0;
    virtual KFileItem* contextFileInfo(void* context) = 0;

    void activateItem(void* context);
    void resetActivatedItem();
    void updateDisabledItems();

private:
    struct DisabledItem {
        KURL url;
        TQPixmap pixmap;
    };

    TQPixmap* m_pixmapCopy;
    KURL m_highlightedURL;

    // contains all items which have been disabled by a 'cut' operation
    TQValueList<DisabledItem> m_disabledItems;

    /** Returns the text for the statusbar for an activated item. */
    TQString statusBarText(KFileItem* fileInfo) const;
};

#endif