svn path=/trunk/KDE/kdebase/apps/; revision=685767
dolphiniconsview.cpp
dolphincolumnview.cpp
dolphinitemcategorizer.cpp
dolphiniconsview.cpp
dolphincolumnview.cpp
dolphinitemcategorizer.cpp
ksortfilterproxymodel.cpp
kitemcategorizer.cpp
dolphinsettings.cpp
ksortfilterproxymodel.cpp
kitemcategorizer.cpp
dolphinsettings.cpp
#include <QPoint>
DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) :
#include <QPoint>
DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) :
+ KCategorizedView(parent),
m_controller(controller),
m_dragging(false)
{
m_controller(controller),
m_dragging(false)
{
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
Q_ASSERT(settings != 0);
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
Q_ASSERT(settings != 0);
- m_viewOptions = KListView::viewOptions();
+ m_viewOptions = KCategorizedView::viewOptions();
m_viewOptions.showDecorationSelected = true;
QFont font(settings->fontFamily(), settings->fontSize());
m_viewOptions.showDecorationSelected = true;
QFont font(settings->fontFamily(), settings->fontSize());
void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
{
void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
{
- KListView::contextMenuEvent(event);
+ KCategorizedView::contextMenuEvent(event);
m_controller->triggerContextMenuRequest(event->pos());
}
m_controller->triggerContextMenuRequest(event->pos());
}
- KListView::mousePressEvent(event);
+ KCategorizedView::mousePressEvent(event);
}
void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
}
void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
void DolphinIconsView::dragLeaveEvent(QDragLeaveEvent* event)
{
void DolphinIconsView::dragLeaveEvent(QDragLeaveEvent* event)
{
- KListView::dragLeaveEvent(event);
+ KCategorizedView::dragLeaveEvent(event);
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
m_dragging = false;
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
m_dragging = false;
void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
{
void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
{
- KListView::dragMoveEvent(event);
+ KCategorizedView::dragMoveEvent(event);
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
const QModelIndex index = indexAt(event->pos());
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
const QModelIndex index = indexAt(event->pos());
event->acceptProposedAction();
}
}
event->acceptProposedAction();
}
}
- KListView::dropEvent(event);
+ KCategorizedView::dropEvent(event);
m_dragging = false;
}
void DolphinIconsView::paintEvent(QPaintEvent* event)
{
m_dragging = false;
}
void DolphinIconsView::paintEvent(QPaintEvent* event)
{
- KListView::paintEvent(event);
+ KCategorizedView::paintEvent(event);
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
if (m_dragging) {
// TODO: remove this code when the issue #160611 is solved in Qt 4.4
if (m_dragging) {
#ifndef DOLPHINICONSVIEW_H
#define DOLPHINICONSVIEW_H
#ifndef DOLPHINICONSVIEW_H
#define DOLPHINICONSVIEW_H
+#include <kcategorizedview.h>
#include <kitemcategorizer.h>
#include <QtGui/QStyleOption>
#include <libdolphin_export.h>
#include <kitemcategorizer.h>
#include <QtGui/QStyleOption>
#include <libdolphin_export.h>
* It is also possible that instead of the icon a preview of the item
* content is shown.
*/
* It is also possible that instead of the icon a preview of the item
* content is shown.
*/
-class LIBDOLPHINPRIVATE_EXPORT DolphinIconsView : public KListView
+class LIBDOLPHINPRIVATE_EXPORT DolphinIconsView : public KCategorizedView
* Boston, MA 02110-1301, USA.
*/
* Boston, MA 02110-1301, USA.
*/
-#include "klistview.h"
-#include "klistview_p.h"
+#include "kcategorizedview.h"
+#include "kcategorizedview_p.h"
#include <math.h> // trunc on C99 compliant systems
#include <kdefakes.h> // trunc for not C99 compliant systems
#include <math.h> // trunc on C99 compliant systems
#include <kdefakes.h> // trunc for not C99 compliant systems
//==============================================================================
//==============================================================================
-KListView::Private::Private(KListView *listView)
+KCategorizedView::Private::Private(KCategorizedView *listView)
: listView(listView)
, itemCategorizer(0)
, mouseButtonPressed(false)
: listView(listView)
, itemCategorizer(0)
, mouseButtonPressed(false)
-KListView::Private::~Private()
+KCategorizedView::Private::~Private()
-const QModelIndexList &KListView::Private::intersectionSet(const QRect &rect)
+const QModelIndexList &KCategorizedView::Private::intersectionSet(const QRect &rect)
{
QModelIndex index;
QRect indexVisualRect;
{
QModelIndex index;
QRect indexVisualRect;
return intersectedIndexes;
}
return intersectedIndexes;
}
-QRect KListView::Private::visualRectInViewport(const QModelIndex &index) const
+QRect KCategorizedView::Private::visualRectInViewport(const QModelIndex &index) const
{
if (!index.isValid())
return QRect();
{
if (!index.isValid())
return QRect();
-QRect KListView::Private::visualCategoryRectInViewport(const QString &category)
+QRect KCategorizedView::Private::visualCategoryRectInViewport(const QString &category)
const
{
QRect retRect(listView->spacing(),
const
{
QRect retRect(listView->spacing(),
}
// We're sure elementsPosition doesn't contain index
}
// We're sure elementsPosition doesn't contain index
-const QRect &KListView::Private::cacheIndex(const QModelIndex &index)
+const QRect &KCategorizedView::Private::cacheIndex(const QModelIndex &index)
{
QRect rect = visualRectInViewport(index);
elementsPosition[index] = rect;
{
QRect rect = visualRectInViewport(index);
elementsPosition[index] = rect;
}
// We're sure categoriesPosition doesn't contain category
}
// We're sure categoriesPosition doesn't contain category
-const QRect &KListView::Private::cacheCategory(const QString &category)
+const QRect &KCategorizedView::Private::cacheCategory(const QString &category)
{
QRect rect = visualCategoryRectInViewport(category);
categoriesPosition[category] = rect;
{
QRect rect = visualCategoryRectInViewport(category);
categoriesPosition[category] = rect;
return categoriesPosition[category];
}
return categoriesPosition[category];
}
-const QRect &KListView::Private::cachedRectIndex(const QModelIndex &index)
+const QRect &KCategorizedView::Private::cachedRectIndex(const QModelIndex &index)
{
if (elementsPosition.contains(index)) // If we have it cached
{ // return it
{
if (elementsPosition.contains(index)) // If we have it cached
{ // return it
-const QRect &KListView::Private::cachedRectCategory(const QString &category)
+const QRect &KCategorizedView::Private::cachedRectCategory(const QString &category)
{
if (categoriesPosition.contains(category)) // If we have it cached
{ // return it
{
if (categoriesPosition.contains(category)) // If we have it cached
{ // return it
-QRect KListView::Private::visualRect(const QModelIndex &index)
+QRect KCategorizedView::Private::visualRect(const QModelIndex &index)
{
QModelIndex mappedIndex = proxyModel->mapToSource(index);
{
QModelIndex mappedIndex = proxyModel->mapToSource(index);
-QRect KListView::Private::categoryVisualRect(const QString &category)
+QRect KCategorizedView::Private::categoryVisualRect(const QString &category)
{
QRect retRect = cachedRectCategory(category);
int dx = -listView->horizontalOffset();
{
QRect retRect = cachedRectCategory(category);
int dx = -listView->horizontalOffset();
-void KListView::Private::drawNewCategory(const QModelIndex &index,
+void KCategorizedView::Private::drawNewCategory(const QModelIndex &index,
int sortRole,
const QStyleOption &option,
QPainter *painter)
int sortRole,
const QStyleOption &option,
QPainter *painter)
-void KListView::Private::updateScrollbars()
+void KCategorizedView::Private::updateScrollbars()
{
int lastItemBottom = cachedRectIndex(lastIndex).bottom() +
listView->spacing() - listView->viewport()->height();
{
int lastItemBottom = cachedRectIndex(lastIndex).bottom() +
listView->spacing() - listView->viewport()->height();
listView->verticalScrollBar()->setRange(0, lastItemBottom);
}
listView->verticalScrollBar()->setRange(0, lastItemBottom);
}
-void KListView::Private::drawDraggedItems(QPainter *painter)
+void KCategorizedView::Private::drawDraggedItems(QPainter *painter)
{
QStyleOptionViewItemV3 option = listView->viewOptions();
option.state &= ~QStyle::State_MouseOver;
{
QStyleOptionViewItemV3 option = listView->viewOptions();
option.state &= ~QStyle::State_MouseOver;
-void KListView::Private::drawDraggedItems()
+void KCategorizedView::Private::drawDraggedItems()
{
QRect rectToUpdate;
QRect currentRect;
{
QRect rectToUpdate;
QRect currentRect;
//==============================================================================
//==============================================================================
-KListView::KListView(QWidget *parent)
+KCategorizedView::KCategorizedView(QWidget *parent)
: QListView(parent)
, d(new Private(this))
{
}
: QListView(parent)
, d(new Private(this))
{
}
+KCategorizedView::~KCategorizedView()
-void KListView::setModel(QAbstractItemModel *model)
+void KCategorizedView::setModel(QAbstractItemModel *model)
{
d->lastSelection = QItemSelection();
d->currentViewIndex = QModelIndex();
{
d->lastSelection = QItemSelection();
d->currentViewIndex = QModelIndex();
-QRect KListView::visualRect(const QModelIndex &index) const
+QRect KCategorizedView::visualRect(const QModelIndex &index) const
- if ((viewMode() != KListView::IconMode) || !d->proxyModel ||
+ if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
!d->itemCategorizer)
{
return QListView::visualRect(index);
!d->itemCategorizer)
{
return QListView::visualRect(index);
return d->visualRect(index);
}
return d->visualRect(index);
}
-KItemCategorizer *KListView::itemCategorizer() const
+KItemCategorizer *KCategorizedView::itemCategorizer() const
{
return d->itemCategorizer;
}
{
return d->itemCategorizer;
}
-void KListView::setItemCategorizer(KItemCategorizer *itemCategorizer)
+void KCategorizedView::setItemCategorizer(KItemCategorizer *itemCategorizer)
{
d->lastSelection = QItemSelection();
d->currentViewIndex = QModelIndex();
{
d->lastSelection = QItemSelection();
d->currentViewIndex = QModelIndex();
-QModelIndex KListView::indexAt(const QPoint &point) const
+QModelIndex KCategorizedView::indexAt(const QPoint &point) const
- if ((viewMode() != KListView::IconMode) || !d->proxyModel ||
+ if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
!d->itemCategorizer)
{
return QListView::indexAt(point);
!d->itemCategorizer)
{
return QListView::indexAt(point);
+void KCategorizedView::reset()
d->mouseButtonPressed = false;
}
d->mouseButtonPressed = false;
}
-void KListView::paintEvent(QPaintEvent *event)
+void KCategorizedView::paintEvent(QPaintEvent *event)
- if ((viewMode() != KListView::IconMode) || !d->proxyModel ||
+ if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
!d->itemCategorizer)
{
QListView::paintEvent(event);
!d->itemCategorizer)
{
QListView::paintEvent(event);
-void KListView::resizeEvent(QResizeEvent *event)
+void KCategorizedView::resizeEvent(QResizeEvent *event)
{
QListView::resizeEvent(event);
{
QListView::resizeEvent(event);
d->categoriesPosition.clear();
d->forcedSelectionPosition = 0;
d->categoriesPosition.clear();
d->forcedSelectionPosition = 0;
- if ((viewMode() != KListView::IconMode) || !d->proxyModel ||
+ if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
!d->itemCategorizer)
{
return;
!d->itemCategorizer)
{
return;
-void KListView::setSelection(const QRect &rect,
+void KCategorizedView::setSelection(const QRect &rect,
QItemSelectionModel::SelectionFlags flags)
{
QItemSelectionModel::SelectionFlags flags)
{
- if ((viewMode() != KListView::IconMode) || !d->proxyModel ||
+ if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
!d->itemCategorizer)
{
QListView::setSelection(rect, flags);
!d->itemCategorizer)
{
QListView::setSelection(rect, flags);
selectionModel()->select(selection, flags);
}
selectionModel()->select(selection, flags);
}
-void KListView::mouseMoveEvent(QMouseEvent *event)
+void KCategorizedView::mouseMoveEvent(QMouseEvent *event)
{
QListView::mouseMoveEvent(event);
{
QListView::mouseMoveEvent(event);
- if ((viewMode() != KListView::IconMode) || !d->proxyModel ||
+ if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
!d->itemCategorizer)
{
return;
!d->itemCategorizer)
{
return;
-void KListView::mousePressEvent(QMouseEvent *event)
+void KCategorizedView::mousePressEvent(QMouseEvent *event)
{
d->dragLeftViewport = false;
{
d->dragLeftViewport = false;
QListView::mousePressEvent(event);
}
QListView::mousePressEvent(event);
}
-void KListView::mouseReleaseEvent(QMouseEvent *event)
+void KCategorizedView::mouseReleaseEvent(QMouseEvent *event)
{
d->mouseButtonPressed = false;
QListView::mouseReleaseEvent(event);
{
d->mouseButtonPressed = false;
QListView::mouseReleaseEvent(event);
- if ((viewMode() != KListView::IconMode) || !d->proxyModel ||
+ if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
!d->itemCategorizer)
{
return;
!d->itemCategorizer)
{
return;
viewport()->update(d->categoryVisualRect(d->hoveredCategory));
}
viewport()->update(d->categoryVisualRect(d->hoveredCategory));
}
-void KListView::leaveEvent(QEvent *event)
+void KCategorizedView::leaveEvent(QEvent *event)
{
d->hovered = QModelIndex();
d->hoveredCategory = QString();
{
d->hovered = QModelIndex();
d->hoveredCategory = QString();
QListView::leaveEvent(event);
}
QListView::leaveEvent(event);
}
-void KListView::startDrag(Qt::DropActions supportedActions)
+void KCategorizedView::startDrag(Qt::DropActions supportedActions)
{
QListView::startDrag(supportedActions);
{
QListView::startDrag(supportedActions);
viewport()->update(d->lastDraggedItemsRect);
}
viewport()->update(d->lastDraggedItemsRect);
}
-void KListView::dragMoveEvent(QDragMoveEvent *event)
+void KCategorizedView::dragMoveEvent(QDragMoveEvent *event)
{
d->mousePosition = event->pos();
{
d->mousePosition = event->pos();
d->dragLeftViewport = false;
d->dragLeftViewport = false;
- if ((viewMode() != KListView::IconMode) || !d->proxyModel ||
+ if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
!d->itemCategorizer)
{
QListView::dragMoveEvent(event);
!d->itemCategorizer)
{
QListView::dragMoveEvent(event);
-void KListView::dragLeaveEvent(QDragLeaveEvent *event)
+void KCategorizedView::dragLeaveEvent(QDragLeaveEvent *event)
{
d->dragLeftViewport = true;
QListView::dragLeaveEvent(event);
}
{
d->dragLeftViewport = true;
QListView::dragLeaveEvent(event);
}
-QModelIndex KListView::moveCursor(CursorAction cursorAction,
+QModelIndex KCategorizedView::moveCursor(CursorAction cursorAction,
Qt::KeyboardModifiers modifiers)
{
Qt::KeyboardModifiers modifiers)
{
- if ((viewMode() != KListView::IconMode) || !d->proxyModel ||
+ if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
!d->itemCategorizer)
{
return QListView::moveCursor(cursorAction, modifiers);
!d->itemCategorizer)
{
return QListView::moveCursor(cursorAction, modifiers);
return QListView::moveCursor(cursorAction, modifiers);
}
return QListView::moveCursor(cursorAction, modifiers);
}
-void KListView::rowsInserted(const QModelIndex &parent,
+void KCategorizedView::rowsInserted(const QModelIndex &parent,
int start,
int end)
{
QListView::rowsInserted(parent, start, end);
int start,
int end)
{
QListView::rowsInserted(parent, start, end);
- if ((viewMode() != KListView::IconMode) || !d->proxyModel ||
+ if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
!d->itemCategorizer)
{
d->lastSelection = QItemSelection();
!d->itemCategorizer)
{
d->lastSelection = QItemSelection();
rowsInsertedArtifficial(parent, start, end);
}
rowsInsertedArtifficial(parent, start, end);
}
-void KListView::rowsInsertedArtifficial(const QModelIndex &parent,
+void KCategorizedView::rowsInsertedArtifficial(const QModelIndex &parent,
-void KListView::rowsRemoved(const QModelIndex &parent,
+void KCategorizedView::rowsRemoved(const QModelIndex &parent,
- if ((viewMode() == KListView::IconMode) && d->proxyModel &&
+ if ((viewMode() == KCategorizedView::IconMode) && d->proxyModel &&
d->itemCategorizer)
{
// Force the view to update all elements
d->itemCategorizer)
{
// Force the view to update all elements
-void KListView::updateGeometries()
+void KCategorizedView::updateGeometries()
- if ((viewMode() != KListView::IconMode) || !d->proxyModel ||
+ if ((viewMode() != KCategorizedView::IconMode) || !d->proxyModel ||
!d->itemCategorizer)
{
QListView::updateGeometries();
!d->itemCategorizer)
{
QListView::updateGeometries();
QAbstractItemView::updateGeometries();
}
QAbstractItemView::updateGeometries();
}
-void KListView::slotSortingRoleChanged()
+void KCategorizedView::slotSortingRoleChanged()
- if ((viewMode() == KListView::IconMode) && d->proxyModel &&
+ if ((viewMode() == KCategorizedView::IconMode) && d->proxyModel &&
d->itemCategorizer)
{
// Force the view to update all elements
d->itemCategorizer)
{
// Force the view to update all elements
-#include "klistview.moc"
+#include "kcategorizedview.moc"
* Boston, MA 02110-1301, USA.
*/
* Boston, MA 02110-1301, USA.
*/
-#ifndef KLISTVIEW_H
-#define KLISTVIEW_H
+#ifndef KCATEGORIZEDVIEW_H
+#define KCATEGORIZEDVIEW_H
#include <QtGui/QListView>
#include <QtGui/QListView>
/**
* @short Item view for listing items
*
/**
* @short Item view for listing items
*
- * KListView allows you to use it as it were a QListView. You can add an
+ * KCategorizedView allows you to use it as it were a QListView. You can add an
* itemCategorizer to it, so your items became categorized depending on the
* KItemCategorizer inherited class rules.
*
* itemCategorizer to it, so your items became categorized depending on the
* KItemCategorizer inherited class rules.
*
*
* @author Rafael Fernández López <ereslibre@gmail.com>
*/
*
* @author Rafael Fernández López <ereslibre@gmail.com>
*/
-class LIBDOLPHINPRIVATE_EXPORT KListView
+class LIBDOLPHINPRIVATE_EXPORT KCategorizedView
: public QListView
{
Q_OBJECT
public:
: public QListView
{
Q_OBJECT
public:
- KListView(QWidget *parent = 0);
+ KCategorizedView(QWidget *parent = 0);
virtual void setModel(QAbstractItemModel *model);
virtual void setModel(QAbstractItemModel *model);
+#endif // KCATEGORIZEDVIEW_H
* Boston, MA 02110-1301, USA.
*/
* Boston, MA 02110-1301, USA.
*/
-#ifndef KLISTVIEW_P_H
-#define KLISTVIEW_P_H
+#ifndef KCATEGORIZEDVIEW_P_H
+#define KCATEGORIZEDVIEW_P_H
class KSortFilterProxyModel;
/**
* @internal
*/
class KSortFilterProxyModel;
/**
* @internal
*/
-class KListView::Private
+class KCategorizedView::Private
- Private(KListView *listView);
+ Private(KCategorizedView *listView);
+ KCategorizedView *listView;
KItemCategorizer *itemCategorizer;
// Behavior data
KItemCategorizer *itemCategorizer;
// Behavior data
QModelIndex lastIndex;
};
QModelIndex lastIndex;
};
+#endif // KCATEGORIZEDVIEW_P_H