~ubuntu-branches/ubuntu/lucid/kdebase/lucid-updates

« back to all changes in this revision

Viewing changes to apps/dolphin/src/dolphincolumnwidget.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2009-12-02 13:28:20 UTC
  • mfrom: (1.1.35 upstream)
  • Revision ID: james.westby@ubuntu.com-20091202132820-yaqzqr7livmarip5
Tags: 4:4.3.80-0ubuntu1
* New upstream release:
  - Drop kubuntu_05_konsole_colour_scheme.diff, applied upstream
  - Drop kubuntu_15-17.diff, applied upstream
  - Bump build-depend versions
  - Add build-depend on shared-desktop-ontologies for nepomuk support
  - Update various .install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright (C) 2007 by Peter Penz <peter.penz@gmx.at>                  *
3
 
 *                                                                         *
4
 
 *   This program is free software; you can redistribute it and/or modify  *
5
 
 *   it under the terms of the GNU General Public License as published by  *
6
 
 *   the Free Software Foundation; either version 2 of the License, or     *
7
 
 *   (at your option) any later version.                                   *
8
 
 *                                                                         *
9
 
 *   This program is distributed in the hope that it will be useful,       *
10
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12
 
 *   GNU General Public License for more details.                          *
13
 
 *                                                                         *
14
 
 *   You should have received a copy of the GNU General Public License     *
15
 
 *   along with this program; if not, write to the                         *
16
 
 *   Free Software Foundation, Inc.,                                       *
17
 
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
18
 
 ***************************************************************************/
19
 
 
20
 
#ifndef DOLPHINCOLUMNWIDGET_H
21
 
#define DOLPHINCOLUMNWIDGET_H
22
 
 
23
 
#include "dolphinview.h"
24
 
 
25
 
#include <QFont>
26
 
#include <QListView>
27
 
#include <QSize>
28
 
#include <QStyleOption>
29
 
 
30
 
#include <kurl.h>
31
 
 
32
 
class DolphinColumnView;
33
 
class DolphinModel;
34
 
class DolphinSortFilterProxyModel;
35
 
class DolphinDirLister;
36
 
class DolphinViewAutoScroller;
37
 
class KFilePreviewGenerator;
38
 
class KJob;
39
 
class KFileItem;
40
 
class KFileItemList;
41
 
class SelectionManager;
42
 
class ToolTipManager;
43
 
class QPixmap;
44
 
 
45
 
/**
46
 
 * Represents one column inside the DolphinColumnView and has been
47
 
 * extended to respect view options and hovering information.
48
 
 */
49
 
class DolphinColumnWidget : public QListView
50
 
{
51
 
    Q_OBJECT
52
 
 
53
 
public:
54
 
    DolphinColumnWidget(QWidget* parent,
55
 
                        DolphinColumnView* columnView,
56
 
                        const KUrl& url);
57
 
    virtual ~DolphinColumnWidget();
58
 
 
59
 
    /** Sets the size of the icons. */
60
 
    void setDecorationSize(const QSize& size);
61
 
 
62
 
    /**
63
 
     * An active column is defined as column, which shows the same URL
64
 
     * as indicated by the URL navigator. The active column is usually
65
 
     * drawn in a lighter color. All operations are applied to this column.
66
 
     */
67
 
    void setActive(bool active);
68
 
    bool isActive() const;
69
 
 
70
 
    /**
71
 
     * Sets the directory URL of the child column that is shown next to
72
 
     * this column. This property is only used for a visual indication
73
 
     * of the shown directory, it does not trigger a loading of the model.
74
 
     */
75
 
    void setChildUrl(const KUrl& url);
76
 
    const KUrl& childUrl() const;
77
 
 
78
 
    /** Sets the directory URL that is shown inside the column widget. */
79
 
    void setUrl(const KUrl& url);
80
 
 
81
 
    /** Returns the directory URL that is shown inside the column widget. */
82
 
    const KUrl& url() const;
83
 
 
84
 
    /** Reloads the directory DolphinColumnWidget::url(). */
85
 
    void reload();
86
 
 
87
 
    void setSorting(DolphinView::Sorting sorting);
88
 
    void setSortOrder(Qt::SortOrder order);
89
 
    void setSortFoldersFirst(bool foldersFirst);
90
 
    void setShowHiddenFiles(bool show);
91
 
    void setShowPreview(bool show);
92
 
 
93
 
    /**
94
 
     * Updates the background color dependent from the activation state
95
 
     * \a isViewActive of the column view.
96
 
     */
97
 
    void updateBackground();
98
 
 
99
 
    /**
100
 
     * Filters the currently shown items by \a nameFilter. All items
101
 
     * which contain the given filter string will be shown.
102
 
     */
103
 
    void setNameFilter(const QString& nameFilter);
104
 
 
105
 
    /**
106
 
     * Does an inline editing for the item \a item.
107
 
     */
108
 
    void editItem(const KFileItem& item);
109
 
 
110
 
    /**
111
 
     * Returns the item on the position \a pos. The KFileItem instance
112
 
     * is null if no item is below the position.
113
 
     */
114
 
    KFileItem itemAt(const QPoint& pos) const;
115
 
 
116
 
    KFileItemList selectedItems() const;
117
 
 
118
 
    /**
119
 
     * Returns the MIME data for the selected items.
120
 
     */
121
 
    QMimeData* selectionMimeData() const;
122
 
 
123
 
protected:
124
 
    virtual QStyleOptionViewItem viewOptions() const;
125
 
    virtual void startDrag(Qt::DropActions supportedActions);
126
 
    virtual void dragEnterEvent(QDragEnterEvent* event);
127
 
    virtual void dragLeaveEvent(QDragLeaveEvent* event);
128
 
    virtual void dragMoveEvent(QDragMoveEvent* event);
129
 
    virtual void dropEvent(QDropEvent* event);
130
 
    virtual void paintEvent(QPaintEvent* event);
131
 
    virtual void mousePressEvent(QMouseEvent* event);
132
 
    virtual void keyPressEvent(QKeyEvent* event);
133
 
    virtual void contextMenuEvent(QContextMenuEvent* event);
134
 
    virtual void wheelEvent(QWheelEvent* event);
135
 
    virtual void leaveEvent(QEvent* event);
136
 
    virtual void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
137
 
    virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
138
 
 
139
 
private slots:
140
 
    void slotEntered(const QModelIndex& index);
141
 
    void requestActivation();
142
 
    void updateFont();
143
 
 
144
 
private:
145
 
    /** Used by DolphinColumnWidget::setActive(). */
146
 
    void activate();
147
 
 
148
 
    /** Used by DolphinColumnWidget::setActive(). */
149
 
    void deactivate();
150
 
 
151
 
private:
152
 
    bool m_active;
153
 
    DolphinColumnView* m_view;
154
 
    SelectionManager* m_selectionManager;
155
 
    DolphinViewAutoScroller* m_autoScroller;
156
 
    KUrl m_url;      // URL of the directory that is shown
157
 
    KUrl m_childUrl; // URL of the next column that is shown
158
 
 
159
 
    QFont m_font;
160
 
    QSize m_decorationSize;
161
 
 
162
 
    DolphinDirLister* m_dirLister;
163
 
    DolphinModel* m_dolphinModel;
164
 
    DolphinSortFilterProxyModel* m_proxyModel;
165
 
 
166
 
    KFilePreviewGenerator* m_previewGenerator;
167
 
 
168
 
    ToolTipManager* m_toolTipManager;
169
 
 
170
 
    QRect m_dropRect;
171
 
 
172
 
    friend class DolphinColumnView;
173
 
};
174
 
 
175
 
inline bool DolphinColumnWidget::isActive() const
176
 
{
177
 
    return m_active;
178
 
}
179
 
 
180
 
inline void DolphinColumnWidget::setChildUrl(const KUrl& url)
181
 
{
182
 
    m_childUrl = url;
183
 
}
184
 
 
185
 
inline const KUrl& DolphinColumnWidget::childUrl() const
186
 
{
187
 
    return m_childUrl;
188
 
}
189
 
 
190
 
inline void DolphinColumnWidget::setUrl(const KUrl& url)
191
 
{
192
 
    if (url != m_url) {
193
 
        m_url = url;
194
 
        reload();
195
 
    }
196
 
}
197
 
 
198
 
inline const KUrl& DolphinColumnWidget::url() const
199
 
{
200
 
    return m_url;
201
 
}
202
 
 
203
 
#endif