mirror of
https://invent.kde.org/system/dolphin
synced 2024-07-04 17:30:55 +00:00
Initial step for moving to KDirModel. Large code parts have been deleted, as a step by step migration makes no sense. Check KDE3 version of Dolphin as reference how things have been done before.
svn path=/trunk/playground/utils/dolphin/; revision=607513
This commit is contained in:
parent
c2c719839c
commit
0e3d1576d5
|
@ -7,47 +7,46 @@ include_directories( ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} )
|
||||||
|
|
||||||
########### next target ###############
|
########### next target ###############
|
||||||
|
|
||||||
set(dolphin_SRCS
|
set(dolphin_SRCS
|
||||||
main.cpp
|
main.cpp
|
||||||
dolphin.cpp
|
dolphin.cpp
|
||||||
dolphinview.cpp
|
dolphinview.cpp
|
||||||
urlnavigator.cpp
|
urlnavigator.cpp
|
||||||
urlnavigatorbutton.cpp
|
urlnavigatorbutton.cpp
|
||||||
viewpropertiesdialog.cpp
|
viewpropertiesdialog.cpp
|
||||||
dolphinstatusbar.cpp
|
dolphinstatusbar.cpp
|
||||||
dolphindirlister.cpp
|
dolphindirlister.cpp
|
||||||
viewproperties.cpp
|
viewproperties.cpp
|
||||||
dolphindetailsview.cpp
|
dolphindetailsview.cpp
|
||||||
dolphiniconsview.cpp
|
dolphiniconsview.cpp
|
||||||
dolphinsettings.cpp
|
dolphinsettings.cpp
|
||||||
bookmarkselector.cpp
|
bookmarkselector.cpp
|
||||||
urlbutton.cpp
|
urlbutton.cpp
|
||||||
itemeffectsmanager.cpp
|
dolphincontextmenu.cpp
|
||||||
dolphincontextmenu.cpp
|
undomanager.cpp
|
||||||
undomanager.cpp
|
progressindicator.cpp
|
||||||
progressindicator.cpp
|
iconsviewsettingspage.cpp
|
||||||
iconsviewsettingspage.cpp
|
pixmapviewer.cpp
|
||||||
pixmapviewer.cpp
|
dolphinsettingsdialog.cpp
|
||||||
dolphinsettingsdialog.cpp
|
viewsettingspage.cpp
|
||||||
viewsettingspage.cpp
|
detailsviewsettingspage.cpp
|
||||||
detailsviewsettingspage.cpp
|
statusbarmessagelabel.cpp
|
||||||
statusbarmessagelabel.cpp
|
generalsettingspage.cpp
|
||||||
generalsettingspage.cpp
|
bookmarkssettingspage.cpp
|
||||||
bookmarkssettingspage.cpp
|
editbookmarkdialog.cpp
|
||||||
editbookmarkdialog.cpp
|
settingspagebase.cpp
|
||||||
settingspagebase.cpp
|
sidebar.cpp
|
||||||
sidebar.cpp
|
sidebarpage.cpp
|
||||||
sidebarpage.cpp
|
bookmarkssidebarpage.cpp
|
||||||
bookmarkssidebarpage.cpp
|
infosidebarpage.cpp
|
||||||
infosidebarpage.cpp
|
statusbarspaceinfo.cpp
|
||||||
statusbarspaceinfo.cpp
|
renamedialog.cpp
|
||||||
renamedialog.cpp
|
filterbar.cpp
|
||||||
filterbar.cpp
|
|
||||||
protocolcombo.cpp )
|
protocolcombo.cpp )
|
||||||
|
|
||||||
kde4_automoc(${dolphin_SRCS})
|
kde4_automoc(${dolphin_SRCS})
|
||||||
|
|
||||||
kde4_add_kcfg_files(dolphin_SRCS
|
kde4_add_kcfg_files(dolphin_SRCS
|
||||||
directoryviewpropertysettings.kcfgc
|
directoryviewpropertysettings.kcfgc
|
||||||
generalsettings.kcfgc
|
generalsettings.kcfgc
|
||||||
iconsmodesettings.kcfgc
|
iconsmodesettings.kcfgc
|
||||||
|
|
|
@ -19,800 +19,14 @@
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "dolphindetailsview.h"
|
#include "dolphindetailsview.h"
|
||||||
|
|
||||||
#include <qpainter.h>
|
|
||||||
#include <qobject.h>
|
|
||||||
#include <q3header.h>
|
|
||||||
#include <qclipboard.h>
|
|
||||||
#include <qpainter.h>
|
|
||||||
//Added by qt3to4:
|
|
||||||
#include <Q3ValueList>
|
|
||||||
#include <QPixmap>
|
|
||||||
#include <QDragMoveEvent>
|
|
||||||
#include <QDropEvent>
|
|
||||||
#include <QResizeEvent>
|
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QEvent>
|
|
||||||
#include <QPaintEvent>
|
|
||||||
#include <QStyleOptionFocusRect>
|
|
||||||
#include <klocale.h>
|
|
||||||
#include <kglobalsettings.h>
|
|
||||||
#include <kicontheme.h>
|
|
||||||
#include <qscrollbar.h>
|
|
||||||
#include <qcursor.h>
|
|
||||||
#include <qstyle.h>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "dolphinview.h"
|
#include "dolphinview.h"
|
||||||
#include "viewproperties.h"
|
|
||||||
#include "dolphin.h"
|
|
||||||
#include "kiconeffect.h"
|
|
||||||
#include "dolphinsettings.h"
|
|
||||||
#include "dolphinstatusbar.h"
|
|
||||||
#include "detailsmodesettings.h"
|
|
||||||
|
|
||||||
DolphinDetailsView::DolphinDetailsView(DolphinView* parent) :
|
DolphinDetailsView::DolphinDetailsView(DolphinView* parent) :
|
||||||
KFileDetailView(parent),
|
QListView(parent)
|
||||||
m_dolphinView(parent),
|
|
||||||
m_resizeTimer(0),
|
|
||||||
m_scrollTimer(0),
|
|
||||||
m_rubber(0)
|
|
||||||
{
|
{
|
||||||
m_resizeTimer = new QTimer(this);
|
|
||||||
connect(m_resizeTimer, SIGNAL(timeout()),
|
|
||||||
this, SLOT(updateColumnsWidth()));
|
|
||||||
|
|
||||||
setAcceptDrops(true);
|
|
||||||
setSelectionMode(KFile::Extended);
|
|
||||||
setHScrollBarMode(Q3ScrollView::AlwaysOff);
|
|
||||||
|
|
||||||
setColumnAlignment(SizeColumn, Qt::AlignRight);
|
|
||||||
for (int i = DateColumn; i <= GroupColumn; ++i) {
|
|
||||||
setColumnAlignment(i, Qt::AlignHCenter);
|
|
||||||
}
|
|
||||||
|
|
||||||
Dolphin& dolphin = Dolphin::mainWin();
|
|
||||||
|
|
||||||
connect(this, SIGNAL(onItem(Q3ListViewItem*)),
|
|
||||||
this, SLOT(slotOnItem(Q3ListViewItem*)));
|
|
||||||
connect(this, SIGNAL(onViewport()),
|
|
||||||
this, SLOT(slotOnViewport()));
|
|
||||||
connect(this, SIGNAL(contextMenuRequested(Q3ListViewItem*, const QPoint&, int)),
|
|
||||||
this, SLOT(slotContextMenuRequested(Q3ListViewItem*, const QPoint&, int)));
|
|
||||||
connect(this, SIGNAL(selectionChanged()),
|
|
||||||
&dolphin, SLOT(slotSelectionChanged()));
|
|
||||||
connect(&dolphin, SIGNAL(activeViewChanged()),
|
|
||||||
this, SLOT(slotActivationUpdate()));
|
|
||||||
connect(this, SIGNAL(itemRenamed(Q3ListViewItem*, const QString&, int)),
|
|
||||||
this, SLOT(slotItemRenamed(Q3ListViewItem*, const QString&, int)));
|
|
||||||
connect(this, SIGNAL(dropped(QDropEvent*, const KUrl::List&, const KUrl&)),
|
|
||||||
parent, SLOT(slotUrlListDropped(QDropEvent*, const KUrl::List&, const KUrl&)));
|
|
||||||
|
|
||||||
QClipboard* clipboard = QApplication::clipboard();
|
|
||||||
connect(clipboard, SIGNAL(dataChanged()),
|
|
||||||
this, SLOT(slotUpdateDisabledItems()));
|
|
||||||
|
|
||||||
Q3Header* viewHeader = header();
|
|
||||||
viewHeader->setResizeEnabled(false);
|
|
||||||
viewHeader->setMovingEnabled(false);
|
|
||||||
connect(viewHeader, SIGNAL(clicked(int)),
|
|
||||||
this, SLOT(slotHeaderClicked(int)));
|
|
||||||
|
|
||||||
setMouseTracking(true);
|
|
||||||
setDefaultRenameAction(Q3ListView::Accept);
|
|
||||||
|
|
||||||
refreshSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinDetailsView::~DolphinDetailsView()
|
DolphinDetailsView::~DolphinDetailsView()
|
||||||
{
|
{
|
||||||
delete m_rubber;
|
|
||||||
m_rubber = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::beginItemUpdates()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::endItemUpdates()
|
|
||||||
{
|
|
||||||
updateDisabledItems();
|
|
||||||
|
|
||||||
// Restore the current item. Use the information stored in the history if
|
|
||||||
// available. Otherwise use the first item as current item.
|
|
||||||
|
|
||||||
const KFileListViewItem* item = static_cast<const KFileListViewItem*>(firstChild());
|
|
||||||
if (item != 0) {
|
|
||||||
setCurrentItem(item->fileInfo());
|
|
||||||
}
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
const Q3ValueList<UrlNavigator::HistoryElem> history = m_dolphinView->urlHistory(index);
|
|
||||||
if (!history.isEmpty()) {
|
|
||||||
KFileView* fileView = static_cast<KFileView*>(this);
|
|
||||||
fileView->setCurrentItem(history[index].currentFileName());
|
|
||||||
setContentsPos(history[index].contentsX(), history[index].contentsY());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateColumnsWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::insertItem(KFileItem* fileItem)
|
|
||||||
{
|
|
||||||
KFileView::insertItem(fileItem);
|
|
||||||
|
|
||||||
DolphinListViewItem* item = new DolphinListViewItem(static_cast<Q3ListView*>(this), fileItem);
|
|
||||||
|
|
||||||
QDir::SortFlags spec = KFileView::sorting();
|
|
||||||
if (spec & QDir::Time) {
|
|
||||||
item->setKey(sortingKey(fileItem->time(KIO::UDS_MODIFICATION_TIME),
|
|
||||||
fileItem->isDir(),
|
|
||||||
spec));
|
|
||||||
}
|
|
||||||
else if (spec & QDir::Size) {
|
|
||||||
item->setKey(sortingKey(fileItem->size(), fileItem->isDir(), spec));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
item->setKey(sortingKey(fileItem->text(), fileItem->isDir(), spec));
|
|
||||||
}
|
|
||||||
|
|
||||||
fileItem->setExtraData(this, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DolphinDetailsView::isOnFilename(const Q3ListViewItem* item, const QPoint& pos) const
|
|
||||||
{
|
|
||||||
const QPoint absPos(mapToGlobal(QPoint(0, 0)));
|
|
||||||
return (pos.x() - absPos.x()) <= filenameWidth(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::refreshSettings()
|
|
||||||
{
|
|
||||||
const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
|
||||||
assert(settings != 0);
|
|
||||||
|
|
||||||
if (!settings->showGroup()) {
|
|
||||||
removeColumn(GroupColumn);
|
|
||||||
}
|
|
||||||
if (!settings->showOwner()) {
|
|
||||||
removeColumn(OwnerColumn);
|
|
||||||
}
|
|
||||||
if (!settings->showPermissions()) {
|
|
||||||
removeColumn(PermissionsColumn);
|
|
||||||
}
|
|
||||||
if (!settings->showDate()) {
|
|
||||||
removeColumn(DateColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
QFont adjustedFont(font());
|
|
||||||
adjustedFont.setFamily(settings->fontFamily());
|
|
||||||
adjustedFont.setPointSize(settings->fontSize());
|
|
||||||
setFont(adjustedFont);
|
|
||||||
|
|
||||||
updateView(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::zoomIn()
|
|
||||||
{
|
|
||||||
if (isZoomInPossible()) {
|
|
||||||
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
|
||||||
switch (settings->iconSize()) {
|
|
||||||
case K3Icon::SizeSmall: settings->setIconSize(K3Icon::SizeMedium); break;
|
|
||||||
case K3Icon::SizeMedium: settings->setIconSize(K3Icon::SizeLarge); break;
|
|
||||||
default: assert(false); break;
|
|
||||||
}
|
|
||||||
ItemEffectsManager::zoomIn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::zoomOut()
|
|
||||||
{
|
|
||||||
if (isZoomOutPossible()) {
|
|
||||||
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
|
||||||
switch (settings->iconSize()) {
|
|
||||||
case K3Icon::SizeLarge: settings->setIconSize(K3Icon::SizeMedium); break;
|
|
||||||
case K3Icon::SizeMedium: settings->setIconSize(K3Icon::SizeSmall); break;
|
|
||||||
default: assert(false); break;
|
|
||||||
}
|
|
||||||
ItemEffectsManager::zoomOut();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DolphinDetailsView::isZoomInPossible() const
|
|
||||||
{
|
|
||||||
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
|
||||||
return settings->iconSize() < K3Icon::SizeLarge;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DolphinDetailsView::isZoomOutPossible() const
|
|
||||||
{
|
|
||||||
DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
|
||||||
return settings->iconSize() > K3Icon::SizeSmall;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::resizeContents(int width, int height)
|
|
||||||
{
|
|
||||||
KFileDetailView::resizeContents(width, height);
|
|
||||||
|
|
||||||
// When loading several 1000 items a punch of resize events
|
|
||||||
// drops in. As updating the column width is a quite expensive
|
|
||||||
// operation, this operation will be postponed until there is
|
|
||||||
// no resize event for at least 50 milliseconds.
|
|
||||||
m_resizeTimer->stop();
|
|
||||||
m_resizeTimer->start(50, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::slotOnItem(Q3ListViewItem* item)
|
|
||||||
{
|
|
||||||
if (isOnFilename(item, QCursor::pos())) {
|
|
||||||
activateItem(item);
|
|
||||||
KFileItem* fileItem = static_cast<KFileListViewItem*>(item)->fileInfo();
|
|
||||||
m_dolphinView->requestItemInfo(fileItem->url());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resetActivatedItem();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::slotOnViewport()
|
|
||||||
{
|
|
||||||
resetActivatedItem();
|
|
||||||
m_dolphinView->requestItemInfo(KUrl());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::setContextPixmap(void* context,
|
|
||||||
const QPixmap& pixmap)
|
|
||||||
{
|
|
||||||
reinterpret_cast<KFileListViewItem*>(context)->setPixmap(0, pixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
const QPixmap* DolphinDetailsView::contextPixmap(void* context)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<KFileListViewItem*>(context)->pixmap(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* DolphinDetailsView::firstContext()
|
|
||||||
{
|
|
||||||
return reinterpret_cast<void*>(firstChild());
|
|
||||||
}
|
|
||||||
|
|
||||||
void* DolphinDetailsView::nextContext(void* context)
|
|
||||||
{
|
|
||||||
KFileListViewItem* listViewItem = reinterpret_cast<KFileListViewItem*>(context);
|
|
||||||
return reinterpret_cast<void*>(listViewItem->nextSibling());
|
|
||||||
}
|
|
||||||
|
|
||||||
KFileItem* DolphinDetailsView::contextFileInfo(void* context)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<KFileListViewItem*>(context)->fileInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DolphinDetailsView::contentsDragMoveEvent(QDragMoveEvent* event)
|
|
||||||
{
|
|
||||||
KFileDetailView::contentsDragMoveEvent(event);
|
|
||||||
|
|
||||||
// If a dragging is done above a directory, show the icon as 'active' for
|
|
||||||
// a visual feedback
|
|
||||||
KFileListViewItem* item = static_cast<KFileListViewItem*>(itemAt(event->pos()));
|
|
||||||
|
|
||||||
bool showActive = false;
|
|
||||||
if (item != 0) {
|
|
||||||
const KFileItem* fileInfo = item->fileInfo();
|
|
||||||
showActive = (fileInfo != 0) && fileInfo->isDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showActive) {
|
|
||||||
slotOnItem(item);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
slotOnViewport();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::resizeEvent(QResizeEvent* event)
|
|
||||||
{
|
|
||||||
KFileDetailView::resizeEvent(event);
|
|
||||||
|
|
||||||
// When loading several 1000 items a punch of resize events
|
|
||||||
// drops in. As updating the column width is a quite expensive
|
|
||||||
// operation, this operation will be postponed until there is
|
|
||||||
// no resize event for at least 50 milliseconds.
|
|
||||||
m_resizeTimer->stop();
|
|
||||||
m_resizeTimer->start(50, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DolphinDetailsView::acceptDrag(QDropEvent* event) const
|
|
||||||
{
|
|
||||||
KUrl::List uriList = KUrl::List::fromMimeData( event->mimeData() );
|
|
||||||
bool accept = !uriList.isEmpty() &&
|
|
||||||
(event->action() == QDropEvent::Copy ||
|
|
||||||
event->action() == QDropEvent::Move ||
|
|
||||||
event->action() == QDropEvent::Link);
|
|
||||||
if (accept) {
|
|
||||||
if (static_cast<const QWidget*>(event->source()) == this) {
|
|
||||||
KFileListViewItem* item = static_cast<KFileListViewItem*>(itemAt(event->pos()));
|
|
||||||
accept = (item != 0);
|
|
||||||
if (accept) {
|
|
||||||
KFileItem* fileItem = item->fileInfo();
|
|
||||||
accept = fileItem->isDir();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return accept;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::contentsDropEvent(QDropEvent* event)
|
|
||||||
{
|
|
||||||
// KFileDetailView::contentsDropEvent does not care whether the mouse
|
|
||||||
// cursor is above a filename or not, the destination Url is always
|
|
||||||
// the Url of the item. This is fixed here in a way that the destination
|
|
||||||
// Url is only the Url of the item if the cursor is above the filename.
|
|
||||||
const QPoint pos(QCursor::pos());
|
|
||||||
const QPoint viewportPos(viewport()->mapToGlobal(QPoint(0, 0)));
|
|
||||||
Q3ListViewItem* item = itemAt(QPoint(pos.x() - viewportPos.x(), pos.y() - viewportPos.y()));
|
|
||||||
if ((item == 0) || ((item != 0) && isOnFilename(item, pos))) {
|
|
||||||
// dropping is done on the viewport or directly above a filename
|
|
||||||
KFileDetailView::contentsDropEvent(event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dropping is done above an item, but the mouse cursor is not above the file name.
|
|
||||||
// In this case the signals of the base implementation will be blocked and send
|
|
||||||
// in a corrected manner afterwards.
|
|
||||||
assert(item != 0);
|
|
||||||
const bool block = signalsBlocked();
|
|
||||||
blockSignals(true);
|
|
||||||
KFileDetailView::contentsDropEvent(event);
|
|
||||||
blockSignals(block);
|
|
||||||
|
|
||||||
if (!acceptDrag(event)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit dropped(event, 0);
|
|
||||||
KUrl::List urls = KUrl::List::fromMimeData( event->mimeData() );
|
|
||||||
if (!urls.isEmpty()) {
|
|
||||||
emit dropped(event, urls, KUrl());
|
|
||||||
sig->dropURLs(0, event, urls);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::contentsMousePressEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
if (m_rubber != 0) {
|
|
||||||
drawRubber();
|
|
||||||
delete m_rubber;
|
|
||||||
m_rubber = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Swallow the base implementation of the mouse press event
|
|
||||||
// if the mouse cursor is not above the filename. This prevents
|
|
||||||
// that the item gets selected and simulates an equal usability
|
|
||||||
// like in the icon view.
|
|
||||||
const QPoint pos(QCursor::pos());
|
|
||||||
const QPoint viewportPos(viewport()->mapToGlobal(QPoint(0, 0)));
|
|
||||||
Q3ListViewItem* item = itemAt(QPoint(pos.x() - viewportPos.x(), pos.y() - viewportPos.y()));
|
|
||||||
if ((item != 0) && isOnFilename(item, pos)) {
|
|
||||||
KFileDetailView::contentsMousePressEvent(event);
|
|
||||||
}
|
|
||||||
else if (event->button() == Qt::LeftButton) {
|
|
||||||
const Qt::KeyboardModifiers keyboardState = QApplication::keyboardModifiers();
|
|
||||||
const bool isSelectionActive = (keyboardState & Qt::ShiftModifier) ||
|
|
||||||
(keyboardState & Qt::ControlModifier);
|
|
||||||
if (!isSelectionActive) {
|
|
||||||
clearSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(m_rubber == 0);
|
|
||||||
m_rubber = new QRect(event->x(), event->y(), 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
resetActivatedItem();
|
|
||||||
emit signalRequestActivation();
|
|
||||||
|
|
||||||
m_dolphinView->statusBar()->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::contentsMouseMoveEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
if (m_rubber != 0) {
|
|
||||||
slotAutoScroll();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
KFileDetailView::contentsMouseMoveEvent(event);
|
|
||||||
|
|
||||||
const QPoint& pos = event->globalPos();
|
|
||||||
const QPoint viewportPos = viewport()->mapToGlobal(QPoint(0, 0));
|
|
||||||
Q3ListViewItem* item = itemAt(QPoint(pos.x() - viewportPos.x(), pos.y() - viewportPos.y()));
|
|
||||||
if ((item != 0) && isOnFilename(item, pos)) {
|
|
||||||
activateItem(item);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resetActivatedItem();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::contentsMouseReleaseEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
if (m_rubber != 0) {
|
|
||||||
drawRubber();
|
|
||||||
delete m_rubber;
|
|
||||||
m_rubber = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_scrollTimer != 0) {
|
|
||||||
disconnect(m_scrollTimer, SIGNAL(timeout()),
|
|
||||||
this, SLOT(slotAutoScroll()));
|
|
||||||
m_scrollTimer->stop();
|
|
||||||
delete m_scrollTimer;
|
|
||||||
m_scrollTimer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
KFileDetailView::contentsMouseReleaseEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::paintEmptyArea(QPainter* painter, const QRect& rect)
|
|
||||||
{
|
|
||||||
if (m_dolphinView->isActive()) {
|
|
||||||
KFileDetailView::paintEmptyArea(painter, rect);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const QBrush brush(colorGroup().background());
|
|
||||||
painter->fillRect(rect, brush);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::drawRubber()
|
|
||||||
{
|
|
||||||
// Parts of the following code have been taken
|
|
||||||
// from the class KonqBaseListViewWidget located in
|
|
||||||
// konqueror/listview/konq_listviewwidget.h of Konqueror.
|
|
||||||
// (Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
|
|
||||||
// 2001, 2002, 2004 Michael Brade <brade@kde.org>)
|
|
||||||
if (m_rubber == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPainter p;
|
|
||||||
p.begin(viewport());
|
|
||||||
//p.setRasterOp(NotROP);
|
|
||||||
p.setPen(QPen(Qt::color0, 1));
|
|
||||||
p.setBrush(Qt::NoBrush);
|
|
||||||
|
|
||||||
QPoint point(m_rubber->x(), m_rubber->y());
|
|
||||||
point = contentsToViewport(point);
|
|
||||||
QStyleOptionFocusRect option;
|
|
||||||
option.initFrom(this);
|
|
||||||
option.rect = QRect(point.x(), point.y(), m_rubber->width(), m_rubber->height());
|
|
||||||
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &p);
|
|
||||||
p.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::viewportPaintEvent(QPaintEvent* paintEvent)
|
|
||||||
{
|
|
||||||
drawRubber();
|
|
||||||
KFileDetailView::viewportPaintEvent(paintEvent);
|
|
||||||
drawRubber();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::leaveEvent(QEvent* event)
|
|
||||||
{
|
|
||||||
KFileDetailView::leaveEvent(event);
|
|
||||||
slotOnViewport();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::slotActivationUpdate()
|
|
||||||
{
|
|
||||||
update();
|
|
||||||
|
|
||||||
// TODO: there must be a simpler way to say
|
|
||||||
// "update all children"
|
|
||||||
const QList<QObject*> list = children();
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QListIterator<QObject*> it(list);
|
|
||||||
QObject* object = 0;
|
|
||||||
while (it.hasNext()) {
|
|
||||||
object = it.next();
|
|
||||||
if (object->inherits("QWidget")) {
|
|
||||||
QWidget* widget = static_cast<QWidget*>(object);
|
|
||||||
widget->update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::slotContextMenuRequested(Q3ListViewItem* item,
|
|
||||||
const QPoint& pos,
|
|
||||||
int /* col */)
|
|
||||||
{
|
|
||||||
KFileItem* fileInfo = 0;
|
|
||||||
if ((item != 0) && isOnFilename(item, pos)) {
|
|
||||||
fileInfo = static_cast<KFileListViewItem*>(item)->fileInfo();
|
|
||||||
}
|
|
||||||
m_dolphinView->openContextMenu(fileInfo, pos);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::slotUpdateDisabledItems()
|
|
||||||
{
|
|
||||||
updateDisabledItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::slotAutoScroll()
|
|
||||||
{
|
|
||||||
// Parts of the following code have been taken
|
|
||||||
// from the class KonqBaseListViewWidget located in
|
|
||||||
// konqueror/listview/konq_listviewwidget.h of Konqueror.
|
|
||||||
// (Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
|
|
||||||
// 2001, 2002, 2004 Michael Brade <brade@kde.org>)
|
|
||||||
|
|
||||||
const QPoint pos(viewport()->mapFromGlobal(QCursor::pos()));
|
|
||||||
const QPoint vc(viewportToContents(pos));
|
|
||||||
|
|
||||||
if (vc == m_rubber->bottomRight()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
drawRubber();
|
|
||||||
|
|
||||||
m_rubber->setBottomRight(vc);
|
|
||||||
|
|
||||||
Q3ListViewItem* item = itemAt(QPoint(0,0));
|
|
||||||
|
|
||||||
const bool block = signalsBlocked();
|
|
||||||
blockSignals(true);
|
|
||||||
|
|
||||||
const QRect rubber(m_rubber->normalize());
|
|
||||||
const int bottom = contentsY() + visibleHeight() - 1;
|
|
||||||
|
|
||||||
// select all items which intersect with the rubber, deselect all others
|
|
||||||
bool bottomReached = false;
|
|
||||||
while ((item != 0) && !bottomReached) {
|
|
||||||
QRect rect(itemRect(item));
|
|
||||||
rect.setWidth(filenameWidth(item));
|
|
||||||
rect = QRect(viewportToContents(rect.topLeft()),
|
|
||||||
viewportToContents(rect.bottomRight()));
|
|
||||||
if (rect.isValid() && (rect.top() <= bottom)) {
|
|
||||||
const KFileItem* fileItem = static_cast<KFileListViewItem*>(item)->fileInfo();
|
|
||||||
setSelected(fileItem, rect.intersects(rubber));
|
|
||||||
item = item->itemBelow();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
bottomReached = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
blockSignals(block);
|
|
||||||
emit selectionChanged();
|
|
||||||
|
|
||||||
drawRubber();
|
|
||||||
|
|
||||||
// scroll the viewport if the top or bottom margin is reached
|
|
||||||
const int scrollMargin = 40;
|
|
||||||
ensureVisible(vc.x(), vc.y(), scrollMargin, scrollMargin);
|
|
||||||
const bool scroll = !QRect(scrollMargin,
|
|
||||||
scrollMargin,
|
|
||||||
viewport()->width() - 2 * scrollMargin,
|
|
||||||
viewport()->height() - 2 * scrollMargin).contains(pos);
|
|
||||||
if (scroll) {
|
|
||||||
if (m_scrollTimer == 0) {
|
|
||||||
m_scrollTimer = new QTimer( this );
|
|
||||||
connect(m_scrollTimer, SIGNAL(timeout()),
|
|
||||||
this, SLOT(slotAutoScroll()));
|
|
||||||
m_scrollTimer->start(100, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (m_scrollTimer != 0) {
|
|
||||||
disconnect(m_scrollTimer, SIGNAL(timeout()),
|
|
||||||
this, SLOT(slotAutoScroll()));
|
|
||||||
m_scrollTimer->stop();
|
|
||||||
delete m_scrollTimer;
|
|
||||||
m_scrollTimer = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::updateColumnsWidth()
|
|
||||||
{
|
|
||||||
const int columnCount = columns();
|
|
||||||
int requiredWidth = 0;
|
|
||||||
for (int i = 1; i < columnCount; ++i) {
|
|
||||||
// When a directory contains no items, a minimum width for
|
|
||||||
// the column must be available, so that the header is readable.
|
|
||||||
// TODO: use header data instead of the hardcoded 64 value...
|
|
||||||
int columnWidth = 64;
|
|
||||||
QFontMetrics fontMetrics(font());
|
|
||||||
for (Q3ListViewItem* item = firstChild(); item != 0; item = item->nextSibling()) {
|
|
||||||
const int width = item->width(fontMetrics, this, i);
|
|
||||||
if (width > columnWidth) {
|
|
||||||
columnWidth = width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
columnWidth += 16; // add custom margin
|
|
||||||
setColumnWidth(i, columnWidth);
|
|
||||||
requiredWidth += columnWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
// resize the first column in a way that the
|
|
||||||
// whole available width is used
|
|
||||||
int firstColumnWidth = visibleWidth() - requiredWidth;
|
|
||||||
if (firstColumnWidth < 128) {
|
|
||||||
firstColumnWidth = 128;
|
|
||||||
}
|
|
||||||
setColumnWidth(0, firstColumnWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::slotItemRenamed(Q3ListViewItem* item,
|
|
||||||
const QString& name,
|
|
||||||
int /* column */)
|
|
||||||
{
|
|
||||||
KFileItem* fileInfo = static_cast<KFileListViewItem*>(item)->fileInfo();
|
|
||||||
m_dolphinView->rename(KUrl(fileInfo->url()), name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::slotHeaderClicked(int /* section */)
|
|
||||||
{
|
|
||||||
// The sorting has already been changed in QListView if this slot is
|
|
||||||
// invoked, but Dolphin was not informed about this (no signal is available
|
|
||||||
// which indicates a change of the sorting). This is bypassed by changing
|
|
||||||
// the sorting and sort order to a temporary other value and readjust it again.
|
|
||||||
const int column = sortColumn();
|
|
||||||
if (column <= DateColumn) {
|
|
||||||
DolphinView::Sorting sorting = DolphinView::SortByName;
|
|
||||||
switch (column) {
|
|
||||||
case SizeColumn: sorting = DolphinView::SortBySize; break;
|
|
||||||
case DateColumn: sorting = DolphinView::SortByDate; break;
|
|
||||||
case NameColumn:
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const Qt::SortOrder currSortOrder = sortOrder();
|
|
||||||
|
|
||||||
// temporary adjust the sorting and sort order to different values...
|
|
||||||
const DolphinView::Sorting tempSorting = (sorting == DolphinView::SortByName) ?
|
|
||||||
DolphinView::SortBySize :
|
|
||||||
DolphinView::SortByName;
|
|
||||||
m_dolphinView->setSorting(tempSorting);
|
|
||||||
const Qt::SortOrder tempSortOrder = (currSortOrder == Qt::Ascending) ?
|
|
||||||
Qt::Descending : Qt::Ascending;
|
|
||||||
m_dolphinView->setSortOrder(tempSortOrder);
|
|
||||||
|
|
||||||
// ... so that setting them again results in storing the new setting.
|
|
||||||
m_dolphinView->setSorting(sorting);
|
|
||||||
m_dolphinView->setSortOrder(currSortOrder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DolphinDetailsView::DolphinListViewItem::DolphinListViewItem(Q3ListView* parent,
|
|
||||||
KFileItem* fileItem) :
|
|
||||||
KFileListViewItem(parent, fileItem)
|
|
||||||
{
|
|
||||||
const int iconSize = DolphinSettings::instance().detailsModeSettings()->iconSize();
|
|
||||||
KFileItem* info = fileInfo();
|
|
||||||
setPixmap(DolphinDetailsView::NameColumn, info->pixmap(iconSize));
|
|
||||||
|
|
||||||
// The base class KFileListViewItem represents the column 'Size' only as byte values.
|
|
||||||
// Adjust those values in a way that a mapping to GBytes, MBytes, KBytes and Bytes
|
|
||||||
// is done. As the file size for directories is useless (only the size of the directory i-node
|
|
||||||
// is given), it is removed completely.
|
|
||||||
if (fileItem->isDir()) {
|
|
||||||
setText(SizeColumn, " - ");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
QString sizeText(KIO::convertSize(fileItem->size()));
|
|
||||||
sizeText.append(" ");
|
|
||||||
setText(SizeColumn, sizeText);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dolphin allows to remove specific columns, but the base class KFileListViewItem
|
|
||||||
// is not aware about this (or at least the class KFileDetailView does not react on
|
|
||||||
// QListView::remove()). Therefore the columns are rearranged here.
|
|
||||||
const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
|
|
||||||
assert(settings != 0);
|
|
||||||
|
|
||||||
int column_idx = DateColumn; // the columns for 'name' and 'size' cannot get removed
|
|
||||||
for (int i = DolphinDetailsView::DateColumn; i <= DolphinDetailsView::GroupColumn; ++i) {
|
|
||||||
if (column_idx < i) {
|
|
||||||
setText(column_idx, text(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool inc = false;
|
|
||||||
switch (i) {
|
|
||||||
case DateColumn: inc = settings->showDate(); break;
|
|
||||||
case PermissionsColumn: inc = settings->showPermissions(); break;
|
|
||||||
case OwnerColumn: inc = settings->showOwner(); break;
|
|
||||||
case GroupColumn: inc = settings->showGroup(); break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inc) {
|
|
||||||
++column_idx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DolphinDetailsView::DolphinListViewItem::~DolphinListViewItem()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::DolphinListViewItem::paintCell(QPainter* painter,
|
|
||||||
const QColorGroup& colorGroup,
|
|
||||||
int column,
|
|
||||||
int cellWidth,
|
|
||||||
int alignment)
|
|
||||||
{
|
|
||||||
const Q3ListView* view = listView();
|
|
||||||
const bool isActive = view->parent() == Dolphin::mainWin().activeView();
|
|
||||||
if (isSelected()) {
|
|
||||||
// Per default the selection is drawn above the whole width of the item. As a consistent
|
|
||||||
// behavior with the icon view is wanted, only the the column containing the file name
|
|
||||||
// should be shown as selected.
|
|
||||||
QColorGroup defaultColorGroup(colorGroup);
|
|
||||||
const QColor highlightColor(isActive ? backgroundColor(column) : view->colorGroup().background());
|
|
||||||
defaultColorGroup.setColor(QColorGroup::Highlight , highlightColor);
|
|
||||||
defaultColorGroup.setColor(QColorGroup::HighlightedText, colorGroup.color(QColorGroup::Text));
|
|
||||||
KFileListViewItem::paintCell(painter, defaultColorGroup, column, cellWidth, alignment);
|
|
||||||
|
|
||||||
if (column == 0) {
|
|
||||||
// draw the selection only on the first column
|
|
||||||
Q3ListView* parent = listView();
|
|
||||||
const int itemWidth = width(parent->fontMetrics(), parent, 0);
|
|
||||||
if (isActive) {
|
|
||||||
KFileListViewItem::paintCell(painter, colorGroup, column, itemWidth, alignment);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Q3ListViewItem::paintCell(painter, colorGroup, column, itemWidth, alignment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (isActive) {
|
|
||||||
KFileListViewItem::paintCell(painter, colorGroup, column, cellWidth, alignment);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Q3ListViewItem::paintCell(painter, colorGroup, column, cellWidth, alignment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (column < listView()->columns() - 1) {
|
|
||||||
// draw a separator between columns
|
|
||||||
painter->setPen(KGlobalSettings::buttonBackground());
|
|
||||||
painter->drawLine(cellWidth - 1, 0, cellWidth - 1, height() - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinDetailsView::DolphinListViewItem::paintFocus(QPainter* painter,
|
|
||||||
const QColorGroup& colorGroup,
|
|
||||||
const QRect& rect)
|
|
||||||
{
|
|
||||||
// draw the focus consistently with the selection (see implementation notes
|
|
||||||
// in DolphinListViewItem::paintCell)
|
|
||||||
Q3ListView* parent = listView();
|
|
||||||
int visibleWidth = width(parent->fontMetrics(), parent, 0);
|
|
||||||
const int colWidth = parent->columnWidth(0);
|
|
||||||
if (visibleWidth > colWidth) {
|
|
||||||
visibleWidth = colWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect focusRect(rect);
|
|
||||||
focusRect.setWidth(visibleWidth);
|
|
||||||
|
|
||||||
KFileListViewItem::paintFocus(painter, colorGroup, focusRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
int DolphinDetailsView::filenameWidth(const Q3ListViewItem* item) const
|
|
||||||
{
|
|
||||||
assert(item != 0);
|
|
||||||
|
|
||||||
int visibleWidth = item->width(fontMetrics(), this, 0);
|
|
||||||
const int colWidth = columnWidth(0);
|
|
||||||
if (visibleWidth > colWidth) {
|
|
||||||
visibleWidth = colWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
return visibleWidth;
|
|
||||||
}
|
}
|
||||||
#include "dolphindetailsview.moc"
|
#include "dolphindetailsview.moc"
|
||||||
|
|
|
@ -21,19 +21,8 @@
|
||||||
#ifndef DOLPHINDETAILSVIEW_H
|
#ifndef DOLPHINDETAILSVIEW_H
|
||||||
#define DOLPHINDETAILSVIEW_H
|
#define DOLPHINDETAILSVIEW_H
|
||||||
|
|
||||||
#include <kfiledetailview.h>
|
#include <QListView>
|
||||||
#include <itemeffectsmanager.h>
|
|
||||||
//Added by qt3to4:
|
|
||||||
#include <QPixmap>
|
|
||||||
#include <QResizeEvent>
|
|
||||||
#include <QEvent>
|
|
||||||
#include <QDropEvent>
|
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QDragMoveEvent>
|
|
||||||
#include <QPaintEvent>
|
|
||||||
|
|
||||||
class QRect;
|
|
||||||
class QTimer;
|
|
||||||
class DolphinView;
|
class DolphinView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,179 +35,13 @@ class DolphinView;
|
||||||
*
|
*
|
||||||
* @author Peter Penz
|
* @author Peter Penz
|
||||||
*/
|
*/
|
||||||
class DolphinDetailsView : public KFileDetailView, public ItemEffectsManager
|
class DolphinDetailsView : public QListView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
* Maps the column indices of KFileDetailView to a
|
|
||||||
* descriptive column name.
|
|
||||||
*/
|
|
||||||
enum ColumnName {
|
|
||||||
NameColumn = 0,
|
|
||||||
SizeColumn = 1,
|
|
||||||
DateColumn = 2,
|
|
||||||
PermissionsColumn = 3,
|
|
||||||
OwnerColumn = 4,
|
|
||||||
GroupColumn = 5
|
|
||||||
};
|
|
||||||
|
|
||||||
DolphinDetailsView(DolphinView* parent);
|
DolphinDetailsView(DolphinView* parent);
|
||||||
|
|
||||||
virtual ~DolphinDetailsView();
|
virtual ~DolphinDetailsView();
|
||||||
|
|
||||||
/** @see ItemEffectsManager::updateItems */
|
|
||||||
virtual void beginItemUpdates();
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::updateItems */
|
|
||||||
virtual void endItemUpdates();
|
|
||||||
|
|
||||||
/** @see KFileView::insertItem */
|
|
||||||
virtual void insertItem(KFileItem* fileItem);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return True, if the position \a pos is above the name of
|
|
||||||
* item \a item.
|
|
||||||
*/
|
|
||||||
bool isOnFilename(const Q3ListViewItem* item, const QPoint& pos) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads out the dolphin settings for the details view and refreshs
|
|
||||||
* the details view.
|
|
||||||
*/
|
|
||||||
// TODO: Other view implementations use a similar interface. When using
|
|
||||||
// Interview in Qt4 this method should be moved to a base class (currently
|
|
||||||
// not possible due to having different base classes for the views).
|
|
||||||
void refreshSettings();
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::zoomIn() */
|
|
||||||
virtual void zoomIn();
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::zoomOut() */
|
|
||||||
virtual void zoomOut();
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::isZoomInPossible() */
|
|
||||||
virtual bool isZoomInPossible() const;
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::isZoomOutPossible() */
|
|
||||||
virtual bool isZoomOutPossible() const;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
/**
|
|
||||||
* Is send, if the details view should be activated. Usually an activation
|
|
||||||
* is triggered by a mouse click.
|
|
||||||
*/
|
|
||||||
void signalRequestActivation();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
/** @see KFileDetailView::resizeContents */
|
|
||||||
virtual void resizeContents(int width, int height);
|
|
||||||
|
|
||||||
/** Is connected to the onItem-signal from KFileDetailView. */
|
|
||||||
void slotOnItem(Q3ListViewItem* item);
|
|
||||||
|
|
||||||
/** Is connected to the onViewport-signal from KFileDetailView. */
|
|
||||||
void slotOnViewport();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/** @see ItemEffectsManager::setContextPixmap() */
|
|
||||||
virtual void setContextPixmap(void* context,
|
|
||||||
const QPixmap& pixmap);
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::setContextPixmap() */
|
|
||||||
virtual const QPixmap* contextPixmap(void* context);
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::setContextPixmap() */
|
|
||||||
virtual void* firstContext();
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::setContextPixmap() */
|
|
||||||
virtual void* nextContext(void* context);
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::setContextPixmap() */
|
|
||||||
virtual KFileItem* contextFileInfo(void* context);
|
|
||||||
|
|
||||||
/** @see KFileDetailView::contentsDragMoveEvent() */
|
|
||||||
virtual void contentsDragMoveEvent(QDragMoveEvent* event);
|
|
||||||
|
|
||||||
/** @see KFileDetailView::resizeEvent() */
|
|
||||||
virtual void resizeEvent(QResizeEvent* event);
|
|
||||||
|
|
||||||
/** @see KFileDetailView::acceptDrag() */
|
|
||||||
virtual bool acceptDrag (QDropEvent* event) const;
|
|
||||||
|
|
||||||
/** @see KFileDetailView::contentsDropEvent() */
|
|
||||||
virtual void contentsDropEvent(QDropEvent* event);
|
|
||||||
|
|
||||||
/** @see KFileDetailView::contentsMousePressEvent() */
|
|
||||||
virtual void contentsMousePressEvent(QMouseEvent* event);
|
|
||||||
|
|
||||||
/** @see KFileDetailView::contentsMouseMoveEvent() */
|
|
||||||
virtual void contentsMouseMoveEvent(QMouseEvent* event);
|
|
||||||
|
|
||||||
/** @see KFileDetailView::contentsMouseReleaseEvent() */
|
|
||||||
virtual void contentsMouseReleaseEvent(QMouseEvent* event);
|
|
||||||
|
|
||||||
/** @see QListView::paintEmptyArea() */
|
|
||||||
virtual void paintEmptyArea(QPainter* painter, const QRect& rect);
|
|
||||||
|
|
||||||
/** Draws the selection rubber. */
|
|
||||||
void drawRubber();
|
|
||||||
|
|
||||||
/** @see QListView::viewportPaintEvent() */
|
|
||||||
virtual void viewportPaintEvent(QPaintEvent* paintEvent);
|
|
||||||
|
|
||||||
/** @see QWidget::leaveEvent() */
|
|
||||||
virtual void leaveEvent(QEvent* event);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void slotActivationUpdate();
|
|
||||||
void slotContextMenuRequested(Q3ListViewItem* item,
|
|
||||||
const QPoint& pos,
|
|
||||||
int col);
|
|
||||||
void slotUpdateDisabledItems();
|
|
||||||
void slotAutoScroll();
|
|
||||||
void updateColumnsWidth();
|
|
||||||
void slotItemRenamed(Q3ListViewItem* item,
|
|
||||||
const QString& name,
|
|
||||||
int column);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is invoked when a section from the header has
|
|
||||||
* been clicked and stores the sort column and sort
|
|
||||||
* order.
|
|
||||||
*/
|
|
||||||
void slotHeaderClicked(int section);
|
|
||||||
|
|
||||||
private:
|
|
||||||
class DolphinListViewItem : public KFileListViewItem {
|
|
||||||
public:
|
|
||||||
DolphinListViewItem(Q3ListView* parent,
|
|
||||||
KFileItem* fileItem);
|
|
||||||
virtual ~DolphinListViewItem();
|
|
||||||
virtual void paintCell(QPainter* painter,
|
|
||||||
const QColorGroup& colorGroup,
|
|
||||||
int column,
|
|
||||||
int cellWidth,
|
|
||||||
int alignment);
|
|
||||||
|
|
||||||
virtual void paintFocus(QPainter* painter,
|
|
||||||
const QColorGroup& colorGroup,
|
|
||||||
const QRect& rect);
|
|
||||||
};
|
|
||||||
|
|
||||||
DolphinView* m_dolphinView;
|
|
||||||
QTimer* m_resizeTimer;
|
|
||||||
QTimer* m_scrollTimer;
|
|
||||||
QRect* m_rubber;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the width of the filename in pixels including
|
|
||||||
* the icon. It is assured that the returned width is
|
|
||||||
* <= the width of the filename column.
|
|
||||||
*/
|
|
||||||
int filenameWidth(const Q3ListViewItem* item) const;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,495 +19,15 @@
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "dolphiniconsview.h"
|
#include "dolphiniconsview.h"
|
||||||
#include <qpainter.h>
|
|
||||||
//Added by qt3to4:
|
|
||||||
#include <QDragMoveEvent>
|
|
||||||
#include <QDropEvent>
|
|
||||||
#include <Q3ValueList>
|
|
||||||
#include <QPixmap>
|
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QDragEnterEvent>
|
|
||||||
#include <kiconeffect.h>
|
|
||||||
#include <kapplication.h>
|
|
||||||
#include <qobject.h>
|
|
||||||
#include <kglobalsettings.h>
|
|
||||||
#include <qclipboard.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <kaction.h>
|
|
||||||
#include <kstdaction.h>
|
|
||||||
#include <kfileitem.h>
|
|
||||||
#include <kactioncollection.h>
|
|
||||||
|
|
||||||
#include "dolphinview.h"
|
#include "dolphinview.h"
|
||||||
#include "viewproperties.h"
|
|
||||||
#include "dolphin.h"
|
|
||||||
#include "dolphinstatusbar.h"
|
|
||||||
#include "dolphinsettings.h"
|
|
||||||
#include "iconsmodesettings.h"
|
|
||||||
|
|
||||||
DolphinIconsView::DolphinIconsView(DolphinView* parent, LayoutMode layoutMode) :
|
DolphinIconsView::DolphinIconsView(DolphinView* parent) :
|
||||||
KFileIconView(parent, 0),
|
QListView(parent)
|
||||||
m_previewIconSize(-1),
|
|
||||||
m_layoutMode(layoutMode),
|
|
||||||
m_dolphinView(parent)
|
|
||||||
{
|
{
|
||||||
setAcceptDrops(true);
|
|
||||||
setMode(K3IconView::Execute);
|
|
||||||
setSelectionMode(KFile::Extended);
|
|
||||||
Dolphin& dolphin = Dolphin::mainWin();
|
|
||||||
|
|
||||||
connect(this, SIGNAL(onItem(Q3IconViewItem*)),
|
|
||||||
this, SLOT(slotOnItem(Q3IconViewItem*)));
|
|
||||||
connect(this, SIGNAL(onViewport()),
|
|
||||||
this, SLOT(slotOnViewport()));
|
|
||||||
connect(this, SIGNAL(contextMenuRequested(Q3IconViewItem*, const QPoint&)),
|
|
||||||
this, SLOT(slotContextMenuRequested(Q3IconViewItem*, const QPoint&)));
|
|
||||||
connect(this, SIGNAL(selectionChanged()),
|
|
||||||
&dolphin, SLOT(slotSelectionChanged()));
|
|
||||||
connect(&dolphin, SIGNAL(activeViewChanged()),
|
|
||||||
this, SLOT(slotActivationUpdate()));
|
|
||||||
connect(this, SIGNAL(itemRenamed(Q3IconViewItem*, const QString&)),
|
|
||||||
this, SLOT(slotItemRenamed(Q3IconViewItem*, const QString&)));
|
|
||||||
connect(this, SIGNAL(dropped(QDropEvent*, const KUrl::List&, const KUrl&)),
|
|
||||||
parent, SLOT(slotUrlListDropped(QDropEvent*, const KUrl::List&, const KUrl&)));
|
|
||||||
|
|
||||||
QClipboard* clipboard = QApplication::clipboard();
|
|
||||||
connect(clipboard, SIGNAL(dataChanged()),
|
|
||||||
this, SLOT(slotUpdateDisabledItems()));
|
|
||||||
|
|
||||||
// KFileIconView creates two actions for zooming, which are directly connected to the
|
|
||||||
// slots KFileIconView::zoomIn() and KFileIconView::zoomOut(). As this behavior is not
|
|
||||||
// wanted and the slots are not virtual, the actions are disabled here.
|
|
||||||
KAction* zoomInAction = actionCollection()->action("zoomIn");
|
|
||||||
assert(zoomInAction != 0);
|
|
||||||
zoomInAction->setEnabled(false);
|
|
||||||
|
|
||||||
KAction* zoomOutAction = actionCollection()->action("zoomOut");
|
|
||||||
assert(zoomOutAction != 0);
|
|
||||||
zoomOutAction->setEnabled(false);
|
|
||||||
|
|
||||||
setItemsMovable(true);
|
|
||||||
setWordWrapIconText(true);
|
|
||||||
if (m_layoutMode == Previews) {
|
|
||||||
showPreviews();
|
|
||||||
}
|
|
||||||
refreshSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinIconsView::~DolphinIconsView()
|
DolphinIconsView::~DolphinIconsView()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinIconsView::setLayoutMode(LayoutMode mode)
|
|
||||||
{
|
|
||||||
if (m_layoutMode != mode) {
|
|
||||||
m_layoutMode = mode;
|
|
||||||
refreshSettings();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::beginItemUpdates()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::endItemUpdates()
|
|
||||||
{
|
|
||||||
arrangeItemsInGrid();
|
|
||||||
|
|
||||||
// TODO: KFileIconView does not emit any signal when the preview
|
|
||||||
// has been finished. Using a delay of 300 ms is a temporary workaround
|
|
||||||
// until the DolphinIconsView will implement the previews by it's own in
|
|
||||||
// future releases.
|
|
||||||
QTimer::singleShot(300, this, SLOT(slotUpdateDisabledItems()));
|
|
||||||
|
|
||||||
const KFileIconViewItem* item = static_cast<const KFileIconViewItem*>(firstItem());
|
|
||||||
if (item != 0) {
|
|
||||||
setCurrentItem(item->fileInfo());
|
|
||||||
}
|
|
||||||
|
|
||||||
int index = 0;
|
|
||||||
const Q3ValueList<UrlNavigator::HistoryElem> history = m_dolphinView->urlHistory(index);
|
|
||||||
if (!history.isEmpty()) {
|
|
||||||
KFileView* fileView = static_cast<KFileView*>(this);
|
|
||||||
fileView->setCurrentItem(history[index].currentFileName());
|
|
||||||
setContentsPos(history[index].contentsX(), history[index].contentsY());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::refreshSettings()
|
|
||||||
{
|
|
||||||
const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
|
|
||||||
assert(settings != 0);
|
|
||||||
|
|
||||||
setIconSize(settings->iconSize());
|
|
||||||
|
|
||||||
const Q3IconView::Arrangement arrangement = settings->arrangement() == "LeftToRight" ? // TODO: use enum directly in settings
|
|
||||||
Q3IconView::LeftToRight : Q3IconView::TopToBottom;
|
|
||||||
const Q3IconView::ItemTextPos textPos = (arrangement == Q3IconView::LeftToRight) ?
|
|
||||||
Q3IconView::Bottom :
|
|
||||||
Q3IconView::Right;
|
|
||||||
setArrangement(arrangement);
|
|
||||||
setItemTextPos(textPos);
|
|
||||||
|
|
||||||
// TODO: tempory crash; will get changed anyway for KDE 4
|
|
||||||
/*setGridX(settings->gridWidth());
|
|
||||||
setGridY(settings->gridHeight());
|
|
||||||
setSpacing(settings->gridSpacing());*/
|
|
||||||
|
|
||||||
QFont adjustedFont(font());
|
|
||||||
adjustedFont.setFamily(settings->fontFamily());
|
|
||||||
adjustedFont.setPointSize(settings->fontSize());
|
|
||||||
setFont(adjustedFont);
|
|
||||||
setIconTextHeight(settings->numberOfTexlines());
|
|
||||||
|
|
||||||
if (m_layoutMode == Previews) {
|
|
||||||
// There is no getter method for the current size in KFileIconView. To
|
|
||||||
// prevent a flickering the current size is stored in m_previewIconSize and
|
|
||||||
// setPreviewSize is only invoked if the size really has changed.
|
|
||||||
showPreviews();
|
|
||||||
|
|
||||||
const int size = settings->previewSize();
|
|
||||||
if (size != m_previewIconSize) {
|
|
||||||
m_previewIconSize = size;
|
|
||||||
setPreviewSize(size);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::zoomIn()
|
|
||||||
{
|
|
||||||
if (isZoomInPossible()) {
|
|
||||||
IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
|
|
||||||
const int textWidthHint = DolphinSettings::instance().textWidthHint(); // TODO: remove for KDE4
|
|
||||||
|
|
||||||
const int iconSize = increasedIconSize(settings->iconSize());
|
|
||||||
settings->setIconSize(iconSize);
|
|
||||||
|
|
||||||
if (m_layoutMode == Previews) {
|
|
||||||
const int previewSize = increasedIconSize(settings->previewSize());
|
|
||||||
settings->setPreviewSize(previewSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
DolphinSettings::instance().calculateGridSize(textWidthHint); // TODO: remove for KDE4
|
|
||||||
ItemEffectsManager::zoomIn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::zoomOut()
|
|
||||||
{
|
|
||||||
if (isZoomOutPossible()) {
|
|
||||||
IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
|
|
||||||
const int textWidthHint = DolphinSettings::instance().textWidthHint(); // TODO: remove for KDE4
|
|
||||||
|
|
||||||
const int iconSize = decreasedIconSize(settings->iconSize());
|
|
||||||
settings->setIconSize(iconSize);
|
|
||||||
|
|
||||||
if (m_layoutMode == Previews) {
|
|
||||||
const int previewSize = decreasedIconSize(settings->previewSize());
|
|
||||||
settings->setPreviewSize(previewSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
DolphinSettings::instance().calculateGridSize(textWidthHint); // TODO: remove for KDE4
|
|
||||||
ItemEffectsManager::zoomOut();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DolphinIconsView::isZoomInPossible() const
|
|
||||||
{
|
|
||||||
IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
|
|
||||||
const int size = (m_layoutMode == Icons) ? settings->iconSize() : settings->previewSize();
|
|
||||||
return size < K3Icon::SizeEnormous;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DolphinIconsView::isZoomOutPossible() const
|
|
||||||
{
|
|
||||||
IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
|
|
||||||
return settings->iconSize() > K3Icon::SizeSmall;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::arrangeItemsInGrid( bool updated )
|
|
||||||
{
|
|
||||||
|
|
||||||
KFileIconView::arrangeItemsInGrid(updated);
|
|
||||||
|
|
||||||
if (m_layoutMode == Previews) {
|
|
||||||
// The class KFileIconView has a bug when the size of the previews differs from the size
|
|
||||||
// of the icons: For specific MIME types the y-position and the height is calculated in
|
|
||||||
// a wrong manner. The following code bypasses this issue. No bugreport has been submitted
|
|
||||||
// as this functionality is not used by any KDE3 application and the core developers are
|
|
||||||
// busy enough for KDE4 now :-)
|
|
||||||
|
|
||||||
KFileIconViewItem* item = static_cast<KFileIconViewItem*>(Q3IconView::firstItem());
|
|
||||||
QString mimetype;
|
|
||||||
while (item != 0) {
|
|
||||||
mimetype = item->fileInfo()->mimetype();
|
|
||||||
const bool fixSize = mimetype.contains("text") ||
|
|
||||||
mimetype.contains("application/x-");
|
|
||||||
if (fixSize) {
|
|
||||||
item->setPixmapSize(QSize(m_previewIconSize, m_previewIconSize));
|
|
||||||
}
|
|
||||||
item = static_cast<KFileIconViewItem *>(item->nextItem());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::setContextPixmap(void* context,
|
|
||||||
const QPixmap& pixmap)
|
|
||||||
{
|
|
||||||
reinterpret_cast<KFileIconViewItem*>(context)->setPixmap(pixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
const QPixmap* DolphinIconsView::contextPixmap(void* context)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<KFileIconViewItem*>(context)->pixmap();
|
|
||||||
}
|
|
||||||
|
|
||||||
void* DolphinIconsView::firstContext()
|
|
||||||
{
|
|
||||||
return reinterpret_cast<void*>(firstItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
void* DolphinIconsView::nextContext(void* context)
|
|
||||||
{
|
|
||||||
KFileIconViewItem* iconViewItem = reinterpret_cast<KFileIconViewItem*>(context);
|
|
||||||
return reinterpret_cast<void*>(iconViewItem->nextItem());
|
|
||||||
}
|
|
||||||
|
|
||||||
KFileItem* DolphinIconsView::contextFileInfo(void* context)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<KFileIconViewItem*>(context)->fileInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::contentsMousePressEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
KFileIconView::contentsMousePressEvent(event);
|
|
||||||
resetActivatedItem();
|
|
||||||
emit signalRequestActivation();
|
|
||||||
m_dolphinView->statusBar()->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::contentsMouseReleaseEvent(QMouseEvent* event)
|
|
||||||
{
|
|
||||||
KFileIconView::contentsMouseReleaseEvent(event);
|
|
||||||
|
|
||||||
// The KFileIconView does not send any selectionChanged signal if
|
|
||||||
// a selection is done by using the "select-during-button-pressed" feature.
|
|
||||||
// Hence inform Dolphin about the selection change manually:
|
|
||||||
Dolphin::mainWin().slotSelectionChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::drawBackground(QPainter* painter, const QRect& rect)
|
|
||||||
{
|
|
||||||
if (m_dolphinView->isActive()) {
|
|
||||||
KFileIconView::drawBackground(painter, rect);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const QBrush brush(colorGroup().background());
|
|
||||||
painter->fillRect(0, 0, width(), height(), brush);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Q3DragObject* DolphinIconsView::dragObject()
|
|
||||||
{
|
|
||||||
KUrl::List urls;
|
|
||||||
QListIterator<KFileItem*> it(*KFileView::selectedItems());
|
|
||||||
while (it.hasNext()) {
|
|
||||||
KFileItem *item = it.next();
|
|
||||||
urls.append(item->url());
|
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap pixmap;
|
|
||||||
if(urls.count() > 1) {
|
|
||||||
pixmap = DesktopIcon("kmultiple", iconSize());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
KFileIconViewItem* item = static_cast<KFileIconViewItem*>(currentItem());
|
|
||||||
if ((item != 0) && (item->pixmap() != 0)) {
|
|
||||||
pixmap = *(item->pixmap());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pixmap.isNull()) {
|
|
||||||
pixmap = currentFileItem()->pixmap(iconSize());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This should be ported to QMimeData
|
|
||||||
Q3DragObject* dragObj = new KUrlDrag(urls, widget());
|
|
||||||
dragObj->setPixmap(pixmap);
|
|
||||||
return dragObj;
|
|
||||||
*/
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::contentsDragEnterEvent(QDragEnterEvent* event)
|
|
||||||
{
|
|
||||||
// TODO: The method KFileIconView::contentsDragEnterEvent() does
|
|
||||||
// not allow drag and drop inside itself, which prevents the possability
|
|
||||||
// to move a file into a directory. As the method KFileIconView::acceptDrag()
|
|
||||||
// is not virtual, we must overwrite the method
|
|
||||||
// KFileIconView::contentsDragEnterEvent() and do some cut/copy/paste for this
|
|
||||||
// usecase. Corresponding to the documentation the method KFileIconView::acceptDrag()
|
|
||||||
// will get virtual in KDE 4, which will simplify the code.
|
|
||||||
|
|
||||||
if (event->source() != this) {
|
|
||||||
KFileIconView::contentsDragEnterEvent(event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
KUrl::List uriList = KUrl::List::fromMimeData( event->mimeData() );
|
|
||||||
const bool accept = !uriList.isEmpty() &&
|
|
||||||
(event->action() == QDropEvent::Copy ||
|
|
||||||
event->action() == QDropEvent::Move ||
|
|
||||||
event->action() == QDropEvent::Link );
|
|
||||||
if (accept) {
|
|
||||||
event->acceptAction();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
event->ignore();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::contentsDragMoveEvent(QDragMoveEvent* event)
|
|
||||||
{
|
|
||||||
KFileIconView::contentsDragMoveEvent(event);
|
|
||||||
|
|
||||||
// If a dragging is done above a directory, show the icon as 'active' for
|
|
||||||
// a visual feedback
|
|
||||||
KFileIconViewItem* item = static_cast<KFileIconViewItem*>(findItem(contentsToViewport(event->pos())));
|
|
||||||
|
|
||||||
bool showActive = false;
|
|
||||||
if (item != 0) {
|
|
||||||
const KFileItem* fileInfo = item->fileInfo();
|
|
||||||
showActive = (fileInfo != 0) && fileInfo->isDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showActive) {
|
|
||||||
slotOnItem(item);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
slotOnViewport();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::contentsDropEvent(QDropEvent* event)
|
|
||||||
{
|
|
||||||
// TODO: Most of the following code is a copy of
|
|
||||||
// KFileIconView::contentsDropEvent. See comment in
|
|
||||||
// DolphinIconsView::contentsDragEnterEvent for details.
|
|
||||||
|
|
||||||
if (event->source() != this) {
|
|
||||||
KFileIconView::contentsDropEvent(event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
KFileIconViewItem* item = static_cast<KFileIconViewItem*>(findItem(contentsToViewport(event->pos())));
|
|
||||||
KUrl::List urls = KUrl::List::fromMimeData( event->mimeData() );
|
|
||||||
const bool accept = !urls.isEmpty() &&
|
|
||||||
(event->action() == QDropEvent::Copy ||
|
|
||||||
event->action() == QDropEvent::Move ||
|
|
||||||
event->action() == QDropEvent::Link ) &&
|
|
||||||
(item != 0);
|
|
||||||
if (!accept) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
KFileItem* fileItem = item->fileInfo();
|
|
||||||
if (!fileItem->isDir()) {
|
|
||||||
// the file is not a directory, hence don't accept any drop
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emit dropped(event, fileItem);
|
|
||||||
if (!urls.isEmpty()) {
|
|
||||||
emit dropped(event, urls, fileItem != 0 ? fileItem->url() : KUrl());
|
|
||||||
sig->dropURLs(fileItem, event, urls);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::slotOnItem(Q3IconViewItem* item)
|
|
||||||
{
|
|
||||||
assert(item != 0);
|
|
||||||
activateItem(reinterpret_cast<void*>(item));
|
|
||||||
|
|
||||||
KFileItem* fileItem = static_cast<KFileIconViewItem*>(item)->fileInfo();
|
|
||||||
m_dolphinView->requestItemInfo(fileItem->url());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::slotOnViewport()
|
|
||||||
{
|
|
||||||
resetActivatedItem();
|
|
||||||
m_dolphinView->requestItemInfo(KUrl());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::slotContextMenuRequested(Q3IconViewItem* item,
|
|
||||||
const QPoint& pos)
|
|
||||||
{
|
|
||||||
KFileItem* fileInfo = 0;
|
|
||||||
if (item != 0) {
|
|
||||||
fileInfo = static_cast<KFileIconViewItem*>(item)->fileInfo();
|
|
||||||
}
|
|
||||||
m_dolphinView->openContextMenu(fileInfo, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::slotItemRenamed(Q3IconViewItem* item,
|
|
||||||
const QString& name)
|
|
||||||
{
|
|
||||||
KFileItem* fileInfo = static_cast<KFileIconViewItem*>(item)->fileInfo();
|
|
||||||
m_dolphinView->rename(KUrl(fileInfo->url()), name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::slotActivationUpdate()
|
|
||||||
{
|
|
||||||
update();
|
|
||||||
|
|
||||||
// TODO: there must be a simpler way to say
|
|
||||||
// "update all children"
|
|
||||||
const QList<QObject*> list = children();
|
|
||||||
if (list.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QListIterator<QObject*> it(list);
|
|
||||||
QObject* object = 0;
|
|
||||||
while (it.hasNext()) {
|
|
||||||
object = it.next();
|
|
||||||
if (object->inherits("QWidget")) {
|
|
||||||
QWidget* widget = static_cast<QWidget*>(object);
|
|
||||||
widget->update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinIconsView::slotUpdateDisabledItems()
|
|
||||||
{
|
|
||||||
updateDisabledItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
int DolphinIconsView::increasedIconSize(int size) const
|
|
||||||
{
|
|
||||||
int incSize = 0;
|
|
||||||
switch (size) {
|
|
||||||
case K3Icon::SizeSmall: incSize = K3Icon::SizeSmallMedium; break;
|
|
||||||
case K3Icon::SizeSmallMedium: incSize = K3Icon::SizeMedium; break;
|
|
||||||
case K3Icon::SizeMedium: incSize = K3Icon::SizeLarge; break;
|
|
||||||
case K3Icon::SizeLarge: incSize = K3Icon::SizeHuge; break;
|
|
||||||
case K3Icon::SizeHuge: incSize = K3Icon::SizeEnormous; break;
|
|
||||||
default: assert(false); break;
|
|
||||||
}
|
|
||||||
return incSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
int DolphinIconsView::decreasedIconSize(int size) const
|
|
||||||
{
|
|
||||||
int decSize = 0;
|
|
||||||
switch (size) {
|
|
||||||
case K3Icon::SizeSmallMedium: decSize = K3Icon::SizeSmall; break;
|
|
||||||
case K3Icon::SizeMedium: decSize = K3Icon::SizeSmallMedium; break;
|
|
||||||
case K3Icon::SizeLarge: decSize = K3Icon::SizeMedium; break;
|
|
||||||
case K3Icon::SizeHuge: decSize = K3Icon::SizeLarge; break;
|
|
||||||
case K3Icon::SizeEnormous: decSize = K3Icon::SizeHuge; break;
|
|
||||||
default: assert(false); break;
|
|
||||||
}
|
|
||||||
return decSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "dolphiniconsview.moc"
|
#include "dolphiniconsview.moc"
|
||||||
|
|
|
@ -21,15 +21,7 @@
|
||||||
#ifndef DOLPHINICONSVIEW_H
|
#ifndef DOLPHINICONSVIEW_H
|
||||||
#define DOLPHINICONSVIEW_H
|
#define DOLPHINICONSVIEW_H
|
||||||
|
|
||||||
#include <kfileiconview.h>
|
#include <QListView>
|
||||||
#include <qpixmap.h>
|
|
||||||
//Added by qt3to4:
|
|
||||||
#include <QDragEnterEvent>
|
|
||||||
#include <QDropEvent>
|
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QDragMoveEvent>
|
|
||||||
#include <kurl.h>
|
|
||||||
#include <itemeffectsmanager.h>
|
|
||||||
|
|
||||||
class DolphinView;
|
class DolphinView;
|
||||||
|
|
||||||
|
@ -41,133 +33,13 @@ class DolphinView;
|
||||||
*
|
*
|
||||||
* @author Peter Penz
|
* @author Peter Penz
|
||||||
*/
|
*/
|
||||||
class DolphinIconsView : public KFileIconView, public ItemEffectsManager
|
class DolphinIconsView : public QListView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum LayoutMode {
|
DolphinIconsView(DolphinView* parent);
|
||||||
Icons,
|
|
||||||
Previews
|
|
||||||
};
|
|
||||||
|
|
||||||
DolphinIconsView(DolphinView *parent, LayoutMode layoutMode);
|
|
||||||
|
|
||||||
virtual ~DolphinIconsView();
|
virtual ~DolphinIconsView();
|
||||||
|
|
||||||
void setLayoutMode(LayoutMode mode);
|
|
||||||
LayoutMode layoutMode() const { return m_layoutMode; }
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::updateItems */
|
|
||||||
virtual void beginItemUpdates();
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::updateItems */
|
|
||||||
virtual void endItemUpdates();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads out the dolphin settings for the icons view and refreshs
|
|
||||||
* the details view.
|
|
||||||
*/
|
|
||||||
// TODO: Other view implementations use a similar interface. When using
|
|
||||||
// Interview in Qt4 this method should be moved to a base class (currently
|
|
||||||
// not possible due to having different base classes for the views).
|
|
||||||
void refreshSettings();
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::zoomIn() */
|
|
||||||
virtual void zoomIn();
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::zoomOut() */
|
|
||||||
virtual void zoomOut();
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::isZoomInPossible() */
|
|
||||||
virtual bool isZoomInPossible() const;
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::isZoomOutPossible() */
|
|
||||||
virtual bool isZoomOutPossible() const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
/**
|
|
||||||
* Bypass a layout issue in KFileIconView in combination with previews.
|
|
||||||
* @see KFileIconView::arrangeItemsInGrid
|
|
||||||
*/
|
|
||||||
virtual void arrangeItemsInGrid(bool updated = true);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
/**
|
|
||||||
* Is send, if the details view should be activated. Usually an activation
|
|
||||||
* is triggered by a mouse click.
|
|
||||||
*/
|
|
||||||
void signalRequestActivation();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
/** @see ItemEffectsManager::setContextPixmap */
|
|
||||||
virtual void setContextPixmap(void* context,
|
|
||||||
const QPixmap& pixmap);
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::contextPixmap */
|
|
||||||
virtual const QPixmap* contextPixmap(void* context);
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::firstContext */
|
|
||||||
virtual void* firstContext();
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::nextContext */
|
|
||||||
virtual void* nextContext(void* context);
|
|
||||||
|
|
||||||
/** @see ItemEffectsManager::contextFileInfo */
|
|
||||||
virtual KFileItem* contextFileInfo(void* context);
|
|
||||||
|
|
||||||
/** @see KFileIconView::contentsMousePressEvent */
|
|
||||||
virtual void contentsMousePressEvent(QMouseEvent* event);
|
|
||||||
|
|
||||||
/** @see KFileIconView::contentsMouseReleaseEvent */
|
|
||||||
virtual void contentsMouseReleaseEvent(QMouseEvent* event);
|
|
||||||
|
|
||||||
/** @see KFileIconView::drawBackground */
|
|
||||||
virtual void drawBackground(QPainter* painter, const QRect& rect);
|
|
||||||
|
|
||||||
/** @see KFileIconView::dragObject */
|
|
||||||
virtual Q3DragObject* dragObject();
|
|
||||||
|
|
||||||
/** @see KFileIconView::contentsDragEnterEvent */
|
|
||||||
virtual void contentsDragEnterEvent(QDragEnterEvent* event);
|
|
||||||
|
|
||||||
/** @see KFileIconView::contentsDragMoveEvent */
|
|
||||||
virtual void contentsDragMoveEvent(QDragMoveEvent* event);
|
|
||||||
|
|
||||||
/** @see KFileIconView::contentsDropEvent */
|
|
||||||
virtual void contentsDropEvent(QDropEvent* event);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
/** Is connected to the onItem-signal from KFileIconView. */
|
|
||||||
void slotOnItem(Q3IconViewItem* item);
|
|
||||||
|
|
||||||
/** Is connected to the onViewport-signal from KFileIconView. */
|
|
||||||
void slotOnViewport();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Opens the context menu for the item \a item on the given
|
|
||||||
* position \a pos.
|
|
||||||
*/
|
|
||||||
void slotContextMenuRequested(Q3IconViewItem* item,
|
|
||||||
const QPoint& pos);
|
|
||||||
|
|
||||||
/** Renames the item \a item to the name \a name. */
|
|
||||||
void slotItemRenamed(Q3IconViewItem* item,
|
|
||||||
const QString& name);
|
|
||||||
|
|
||||||
void slotActivationUpdate();
|
|
||||||
void slotUpdateDisabledItems();
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_previewIconSize;
|
|
||||||
LayoutMode m_layoutMode;
|
|
||||||
DolphinView* m_dolphinView;
|
|
||||||
|
|
||||||
/** Returns the increased icon size for the size \a size. */
|
|
||||||
int increasedIconSize(int size) const;
|
|
||||||
|
|
||||||
/** Returns the decreased icon size for the size \a size. */
|
|
||||||
int decreasedIconSize(int size) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
|
|
||||||
#include "dolphinview.h"
|
#include "dolphinview.h"
|
||||||
|
|
||||||
|
#include <kdirmodel.h>
|
||||||
|
|
||||||
|
|
||||||
#include <qlayout.h>
|
#include <qlayout.h>
|
||||||
//Added by qt3to4:
|
//Added by qt3to4:
|
||||||
#include <Q3ValueList>
|
#include <Q3ValueList>
|
||||||
|
@ -54,8 +57,6 @@ DolphinView::DolphinView(QWidget *parent,
|
||||||
m_refreshing(false),
|
m_refreshing(false),
|
||||||
m_showProgress(false),
|
m_showProgress(false),
|
||||||
m_mode(mode),
|
m_mode(mode),
|
||||||
m_iconsView(0),
|
|
||||||
m_detailsView(0),
|
|
||||||
m_statusBar(0),
|
m_statusBar(0),
|
||||||
m_iconSize(0),
|
m_iconSize(0),
|
||||||
m_folderCount(0),
|
m_folderCount(0),
|
||||||
|
@ -102,25 +103,28 @@ DolphinView::DolphinView(QWidget *parent,
|
||||||
this, SLOT(slotInfoMessage(const QString&)));
|
this, SLOT(slotInfoMessage(const QString&)));
|
||||||
connect(m_dirLister, SIGNAL(errorMessage(const QString&)),
|
connect(m_dirLister, SIGNAL(errorMessage(const QString&)),
|
||||||
this, SLOT(slotErrorMessage(const QString&)));
|
this, SLOT(slotErrorMessage(const QString&)));
|
||||||
connect(m_dirLister, SIGNAL(refreshItems(const KFileItemList&)),
|
|
||||||
this, SLOT(slotRefreshItems(const KFileItemList&)));
|
m_iconsView = new DolphinIconsView(this);
|
||||||
connect(m_dirLister, SIGNAL(redirection(const KUrl&, const KUrl&)),
|
connect(m_iconsView, SIGNAL(clicked(const QModelIndex&)),
|
||||||
this, SIGNAL(redirection(const KUrl&, const KUrl&)));
|
this, SLOT(triggerItem(const QModelIndex&)));
|
||||||
connect(m_dirLister, SIGNAL(newItems(const KFileItemList&)),
|
|
||||||
this, SLOT(slotAddItems(const KFileItemList&)));
|
KDirModel* model = new KDirModel();
|
||||||
|
model->setDirLister(m_dirLister);
|
||||||
|
m_iconsView->setModel(model);
|
||||||
|
|
||||||
m_iconSize = K3Icon::SizeMedium;
|
m_iconSize = K3Icon::SizeMedium;
|
||||||
|
|
||||||
m_topLayout->addWidget(m_urlNavigator);
|
|
||||||
createView();
|
|
||||||
|
|
||||||
m_filterBar = new FilterBar(this);
|
m_filterBar = new FilterBar(this);
|
||||||
m_filterBar->hide();
|
m_filterBar->hide();
|
||||||
m_topLayout->addWidget(m_filterBar);
|
|
||||||
connect(m_filterBar, SIGNAL(signalFilterChanged(const QString&)),
|
connect(m_filterBar, SIGNAL(signalFilterChanged(const QString&)),
|
||||||
this, SLOT(slotChangeNameFilter(const QString&)));
|
this, SLOT(slotChangeNameFilter(const QString&)));
|
||||||
|
|
||||||
|
m_topLayout->addWidget(m_urlNavigator);
|
||||||
|
m_topLayout->addWidget(m_iconsView);
|
||||||
|
m_topLayout->addWidget(m_filterBar);
|
||||||
m_topLayout->addWidget(m_statusBar);
|
m_topLayout->addWidget(m_statusBar);
|
||||||
|
|
||||||
|
startDirLister(m_urlNavigator->url());
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinView::~DolphinView()
|
DolphinView::~DolphinView()
|
||||||
|
@ -155,23 +159,13 @@ void DolphinView::setMode(Mode mode)
|
||||||
return; // the wished mode is already set
|
return; // the wished mode is already set
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget* view = (m_iconsView != 0) ? static_cast<QWidget*>(m_iconsView) :
|
|
||||||
static_cast<QWidget*>(m_detailsView);
|
|
||||||
if (view != 0) {
|
|
||||||
m_topLayout->remove(view);
|
|
||||||
view->close();
|
|
||||||
view->deleteLater();
|
|
||||||
m_iconsView = 0;
|
|
||||||
m_detailsView = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_mode = mode;
|
m_mode = mode;
|
||||||
|
|
||||||
createView();
|
|
||||||
|
|
||||||
ViewProperties props(m_urlNavigator->url());
|
ViewProperties props(m_urlNavigator->url());
|
||||||
props.setViewMode(m_mode);
|
props.setViewMode(m_mode);
|
||||||
|
|
||||||
|
startDirLister(m_urlNavigator->url());
|
||||||
|
|
||||||
emit signalModeChanged();
|
emit signalModeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,11 +273,12 @@ void DolphinView::renameSelectedItems()
|
||||||
// Only one item has been selected for renaming. Use the custom
|
// Only one item has been selected for renaming. Use the custom
|
||||||
// renaming mechanism from the views.
|
// renaming mechanism from the views.
|
||||||
assert(urls.count() == 1);
|
assert(urls.count() == 1);
|
||||||
if (m_mode == DetailsView) {
|
// TODO:
|
||||||
Q3ListViewItem* item = m_detailsView->firstChild();
|
/*if (m_mode == DetailsView) {
|
||||||
|
Q3ListViewItem* item = m_iconsView->firstChild();
|
||||||
while (item != 0) {
|
while (item != 0) {
|
||||||
if (item->isSelected()) {
|
if (item->isSelected()) {
|
||||||
m_detailsView->rename(item, DolphinDetailsView::NameColumn);
|
m_iconsView->rename(item, DolphinDetailsView::NameColumn);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
item = item->nextSibling();
|
item = item->nextSibling();
|
||||||
|
@ -298,18 +293,18 @@ void DolphinView::renameSelectedItems()
|
||||||
}
|
}
|
||||||
item = static_cast<KFileIconViewItem*>(item->nextItem());
|
item = static_cast<KFileIconViewItem*>(item->nextItem());
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::selectAll()
|
void DolphinView::selectAll()
|
||||||
{
|
{
|
||||||
fileView()->selectAll();
|
//fileView()->selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::invertSelection()
|
void DolphinView::invertSelection()
|
||||||
{
|
{
|
||||||
fileView()->invertSelection();
|
//fileView()->invertSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinStatusBar* DolphinView::statusBar() const
|
DolphinStatusBar* DolphinView::statusBar() const
|
||||||
|
@ -319,33 +314,18 @@ DolphinStatusBar* DolphinView::statusBar() const
|
||||||
|
|
||||||
int DolphinView::contentsX() const
|
int DolphinView::contentsX() const
|
||||||
{
|
{
|
||||||
return scrollView()->contentsX();
|
|
||||||
|
return 0; //scrollView()->contentsX();
|
||||||
}
|
}
|
||||||
|
|
||||||
int DolphinView::contentsY() const
|
int DolphinView::contentsY() const
|
||||||
{
|
{
|
||||||
return scrollView()->contentsY();
|
return 0; //scrollView()->contentsY();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::refreshSettings()
|
void DolphinView::refreshSettings()
|
||||||
{
|
{
|
||||||
if (m_iconsView != 0) {
|
startDirLister(m_urlNavigator->url());
|
||||||
m_iconsView->refreshSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_detailsView != 0) {
|
|
||||||
// TODO: There is no usable interface in QListView/KFileDetailView
|
|
||||||
// to hide/show columns. The easiest approach is to delete
|
|
||||||
// the current instance and recreate a new one, which automatically
|
|
||||||
// refreshs the settings. If a proper interface is available in Qt4
|
|
||||||
// m_detailsView->refreshSettings() would be enough.
|
|
||||||
m_topLayout->remove(m_detailsView);
|
|
||||||
m_detailsView->close();
|
|
||||||
m_detailsView->deleteLater();
|
|
||||||
m_detailsView = 0;
|
|
||||||
|
|
||||||
createView();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::updateStatusBar()
|
void DolphinView::updateStatusBar()
|
||||||
|
@ -383,28 +363,28 @@ bool DolphinView::isUrlEditable() const
|
||||||
|
|
||||||
void DolphinView::zoomIn()
|
void DolphinView::zoomIn()
|
||||||
{
|
{
|
||||||
itemEffectsManager()->zoomIn();
|
//itemEffectsManager()->zoomIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::zoomOut()
|
void DolphinView::zoomOut()
|
||||||
{
|
{
|
||||||
itemEffectsManager()->zoomOut();
|
//itemEffectsManager()->zoomOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DolphinView::isZoomInPossible() const
|
bool DolphinView::isZoomInPossible() const
|
||||||
{
|
{
|
||||||
return itemEffectsManager()->isZoomInPossible();
|
return false; //itemEffectsManager()->isZoomInPossible();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DolphinView::isZoomOutPossible() const
|
bool DolphinView::isZoomOutPossible() const
|
||||||
{
|
{
|
||||||
return itemEffectsManager()->isZoomOutPossible();
|
return false; //itemEffectsManager()->isZoomOutPossible();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::setSorting(Sorting sorting)
|
void DolphinView::setSorting(Sorting sorting)
|
||||||
{
|
{
|
||||||
if (sorting != this->sorting()) {
|
if (sorting != this->sorting()) {
|
||||||
KFileView* view = fileView();
|
/*KFileView* view = fileView();
|
||||||
int spec = view->sorting() & ~QDir::Name & ~QDir::Size & ~QDir::Time & ~QDir::Unsorted;
|
int spec = view->sorting() & ~QDir::Name & ~QDir::Size & ~QDir::Time & ~QDir::Unsorted;
|
||||||
|
|
||||||
switch (sorting) {
|
switch (sorting) {
|
||||||
|
@ -419,13 +399,13 @@ void DolphinView::setSorting(Sorting sorting)
|
||||||
|
|
||||||
view->setSorting(static_cast<QDir::SortFlags>(spec));
|
view->setSorting(static_cast<QDir::SortFlags>(spec));
|
||||||
|
|
||||||
emit signalSortingChanged(sorting);
|
emit signalSortingChanged(sorting);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DolphinView::Sorting DolphinView::sorting() const
|
DolphinView::Sorting DolphinView::sorting() const
|
||||||
{
|
{
|
||||||
const QDir::SortFlags spec = fileView()->sorting();
|
/*const QDir::SortFlags spec = fileView()->sorting();
|
||||||
|
|
||||||
if (spec & QDir::Time) {
|
if (spec & QDir::Time) {
|
||||||
return SortByDate;
|
return SortByDate;
|
||||||
|
@ -433,7 +413,7 @@ DolphinView::Sorting DolphinView::sorting() const
|
||||||
|
|
||||||
if (spec & QDir::Size) {
|
if (spec & QDir::Size) {
|
||||||
return SortBySize;
|
return SortBySize;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return SortByName;
|
return SortByName;
|
||||||
}
|
}
|
||||||
|
@ -441,7 +421,7 @@ DolphinView::Sorting DolphinView::sorting() const
|
||||||
void DolphinView::setSortOrder(Qt::SortOrder order)
|
void DolphinView::setSortOrder(Qt::SortOrder order)
|
||||||
{
|
{
|
||||||
if (sortOrder() != order) {
|
if (sortOrder() != order) {
|
||||||
KFileView* view = fileView();
|
/*KFileView* view = fileView();
|
||||||
int sorting = view->sorting();
|
int sorting = view->sorting();
|
||||||
sorting = (order == Qt::Ascending) ? (sorting & ~QDir::Reversed) :
|
sorting = (order == Qt::Ascending) ? (sorting & ~QDir::Reversed) :
|
||||||
(sorting | QDir::Reversed);
|
(sorting | QDir::Reversed);
|
||||||
|
@ -451,13 +431,14 @@ void DolphinView::setSortOrder(Qt::SortOrder order)
|
||||||
|
|
||||||
view->setSorting(static_cast<QDir::SortFlags>(sorting));
|
view->setSorting(static_cast<QDir::SortFlags>(sorting));
|
||||||
|
|
||||||
emit signalSortOrderChanged(order);
|
emit signalSortOrderChanged(order);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::SortOrder DolphinView::sortOrder() const
|
Qt::SortOrder DolphinView::sortOrder() const
|
||||||
{
|
{
|
||||||
return fileView()->isReversed() ? Qt::Descending : Qt::Ascending;
|
//return fileView()->isReversed() ? Qt::Descending : Qt::Ascending;
|
||||||
|
return Qt::Descending;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::goBack()
|
void DolphinView::goBack()
|
||||||
|
@ -498,14 +479,14 @@ bool DolphinView::hasSelection() const
|
||||||
|
|
||||||
const KFileItemList* DolphinView::selectedItems() const
|
const KFileItemList* DolphinView::selectedItems() const
|
||||||
{
|
{
|
||||||
return fileView()->selectedItems();
|
return 0; //fileView()->selectedItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
KUrl::List DolphinView::selectedUrls() const
|
KUrl::List DolphinView::selectedUrls() const
|
||||||
{
|
{
|
||||||
KUrl::List urls;
|
KUrl::List urls;
|
||||||
|
|
||||||
const KFileItemList* list = fileView()->selectedItems();
|
/*const KFileItemList* list = fileView()->selectedItems();
|
||||||
if (list != 0) {
|
if (list != 0) {
|
||||||
KFileItemList::const_iterator it = list->begin();
|
KFileItemList::const_iterator it = list->begin();
|
||||||
const KFileItemList::const_iterator end = list->end();
|
const KFileItemList::const_iterator end = list->end();
|
||||||
|
@ -514,14 +495,14 @@ KUrl::List DolphinView::selectedUrls() const
|
||||||
urls.append(item->url());
|
urls.append(item->url());
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
const KFileItem* DolphinView::currentFileItem() const
|
const KFileItem* DolphinView::currentFileItem() const
|
||||||
{
|
{
|
||||||
return fileView()->currentFileItem();
|
return 0; // fileView()->currentFileItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::openContextMenu(KFileItem* fileInfo, const QPoint& pos)
|
void DolphinView::openContextMenu(KFileItem* fileInfo, const QPoint& pos)
|
||||||
|
@ -661,37 +642,43 @@ void DolphinView::triggerIconsViewItem(Q3IconViewItem* item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::triggerDetailsViewItem(Q3ListViewItem* item,
|
void DolphinView::triggerItem(const QModelIndex& index)
|
||||||
const QPoint& pos,
|
|
||||||
int /* column */)
|
|
||||||
{
|
{
|
||||||
|
KDirModel* dirModel = static_cast<KDirModel*>(m_iconsView->model());
|
||||||
|
KFileItem* item = dirModel->itemForIndex(index);
|
||||||
if (item == 0) {
|
if (item == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_detailsView->isOnFilename(item, pos)) {
|
if (item->isDir()) {
|
||||||
// Updating the Url must be done outside the scope of this slot,
|
// Prefer the local path over the Url. This assures that the
|
||||||
// as listview items will get deleted.
|
// volume space information is correct. Assuming that the Url is media:/sda1,
|
||||||
QTimer::singleShot(0, this, SLOT(updateUrl()));
|
// and the local path is /windows/C: For the Url the space info is related
|
||||||
Dolphin::mainWin().setActiveView(this);
|
// to the root partition (and hence wrong) and for the local path the space
|
||||||
|
// info is related to the windows partition (-> correct).
|
||||||
|
//m_dirLister->stop();
|
||||||
|
//m_dirLister->openUrl(item->url());
|
||||||
|
//return;
|
||||||
|
|
||||||
|
const QString localPath(item->localPath());
|
||||||
|
if (localPath.isEmpty()) {
|
||||||
|
setUrl(item->url());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setUrl(KUrl(localPath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_detailsView->clearSelection();
|
item->run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::triggerDetailsViewItem(Q3ListViewItem* item)
|
|
||||||
{
|
|
||||||
const QPoint pos(0, item->itemPos());
|
|
||||||
triggerDetailsViewItem(item, pos, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinView::updateUrl()
|
void DolphinView::updateUrl()
|
||||||
{
|
{
|
||||||
KFileView* fileView = (m_iconsView != 0) ? static_cast<KFileView*>(m_iconsView) :
|
//KFileView* fileView = (m_iconsView != 0) ? static_cast<KFileView*>(m_iconsView) :
|
||||||
static_cast<KFileView*>(m_detailsView);
|
// static_cast<KFileView*>(m_iconsView);
|
||||||
|
|
||||||
KFileItem* fileItem = fileView->currentFileItem();
|
KFileItem* fileItem = 0; // TODO: fileView->currentFileItem();
|
||||||
if (fileItem == 0) {
|
if (fileItem == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -724,13 +711,13 @@ void DolphinView::slotPercent(int percent)
|
||||||
|
|
||||||
void DolphinView::slotClear()
|
void DolphinView::slotClear()
|
||||||
{
|
{
|
||||||
fileView()->clearView();
|
//fileView()->clearView();
|
||||||
updateStatusBar();
|
updateStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::slotDeleteItem(KFileItem* item)
|
void DolphinView::slotDeleteItem(KFileItem* item)
|
||||||
{
|
{
|
||||||
fileView()->removeItem(item);
|
//fileView()->removeItem(item);
|
||||||
updateStatusBar();
|
updateStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -738,17 +725,17 @@ void DolphinView::slotCompleted()
|
||||||
{
|
{
|
||||||
m_refreshing = true;
|
m_refreshing = true;
|
||||||
|
|
||||||
KFileView* view = fileView();
|
//KFileView* view = fileView();
|
||||||
view->clearView();
|
//view->clearView();
|
||||||
|
|
||||||
// TODO: in Qt4 the code should get a lot
|
// TODO: in Qt4 the code should get a lot
|
||||||
// simpler and nicer due to Interview...
|
// simpler and nicer due to Interview...
|
||||||
if (m_iconsView != 0) {
|
/*if (m_iconsView != 0) {
|
||||||
m_iconsView->beginItemUpdates();
|
m_iconsView->beginItemUpdates();
|
||||||
}
|
}
|
||||||
if (m_detailsView != 0) {
|
if (m_iconsView != 0) {
|
||||||
m_detailsView->beginItemUpdates();
|
m_iconsView->beginItemUpdates();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (m_showProgress) {
|
if (m_showProgress) {
|
||||||
m_statusBar->setProgressText(QString::null);
|
m_statusBar->setProgressText(QString::null);
|
||||||
|
@ -765,7 +752,7 @@ void DolphinView::slotCompleted()
|
||||||
|
|
||||||
while (it != end) {
|
while (it != end) {
|
||||||
KFileItem* item = *it;
|
KFileItem* item = *it;
|
||||||
view->insertItem(item);
|
//view->insertItem(item);
|
||||||
if (item->isDir()) {
|
if (item->isDir()) {
|
||||||
++m_folderCount;
|
++m_folderCount;
|
||||||
}
|
}
|
||||||
|
@ -777,26 +764,17 @@ void DolphinView::slotCompleted()
|
||||||
|
|
||||||
updateStatusBar();
|
updateStatusBar();
|
||||||
|
|
||||||
if (m_iconsView != 0) {
|
/*if (m_iconsView != 0) {
|
||||||
// Prevent a flickering of the icon view widget by giving a small
|
// Prevent a flickering of the icon view widget by giving a small
|
||||||
// timeslot to swallow asynchronous update events.
|
// timeslot to swallow asynchronous update events.
|
||||||
m_iconsView->setUpdatesEnabled(false);
|
m_iconsView->setUpdatesEnabled(false);
|
||||||
QTimer::singleShot(10, this, SLOT(slotDelayedUpdate()));
|
QTimer::singleShot(10, this, SLOT(slotDelayedUpdate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_detailsView != 0) {
|
|
||||||
m_detailsView->endItemUpdates();
|
|
||||||
m_refreshing = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinView::slotDelayedUpdate()
|
|
||||||
{
|
|
||||||
if (m_iconsView != 0) {
|
if (m_iconsView != 0) {
|
||||||
m_iconsView->setUpdatesEnabled(true);
|
|
||||||
m_iconsView->endItemUpdates();
|
m_iconsView->endItemUpdates();
|
||||||
}
|
m_refreshing = false;
|
||||||
m_refreshing = false;
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::slotInfoMessage(const QString& msg)
|
void DolphinView::slotInfoMessage(const QString& msg)
|
||||||
|
@ -809,17 +787,6 @@ void DolphinView::slotErrorMessage(const QString& msg)
|
||||||
m_statusBar->setMessage(msg, DolphinStatusBar::Error);
|
m_statusBar->setMessage(msg, DolphinStatusBar::Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::slotRefreshItems(const KFileItemList& /* list */)
|
|
||||||
{
|
|
||||||
QTimer::singleShot(0, this, SLOT(reload()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinView::slotAddItems(const KFileItemList& list)
|
|
||||||
{
|
|
||||||
fileView()->addItemList(list);
|
|
||||||
fileView()->updateView();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DolphinView::slotGrabActivation()
|
void DolphinView::slotGrabActivation()
|
||||||
{
|
{
|
||||||
Dolphin::mainWin().setActiveView(this);
|
Dolphin::mainWin().setActiveView(this);
|
||||||
|
@ -835,76 +802,21 @@ void DolphinView::slotContentsMoving(int x, int y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::createView()
|
/*KFileView* DolphinView::fileView() const
|
||||||
{
|
{
|
||||||
assert(m_iconsView == 0);
|
return (m_mode == DetailsView) ? static_cast<KFileView*>(m_iconsView) :
|
||||||
assert(m_detailsView == 0);
|
|
||||||
|
|
||||||
switch (m_mode) {
|
|
||||||
case IconsView:
|
|
||||||
case PreviewsView: {
|
|
||||||
const DolphinIconsView::LayoutMode layoutMode = (m_mode == IconsView) ?
|
|
||||||
DolphinIconsView::Icons :
|
|
||||||
DolphinIconsView::Previews;
|
|
||||||
m_iconsView = new DolphinIconsView(this, layoutMode);
|
|
||||||
m_topLayout->insertWidget(1, m_iconsView);
|
|
||||||
setFocusProxy(m_iconsView);
|
|
||||||
|
|
||||||
connect(m_iconsView, SIGNAL(executed(Q3IconViewItem*)),
|
|
||||||
this, SLOT(triggerIconsViewItem(Q3IconViewItem*)));
|
|
||||||
connect(m_iconsView, SIGNAL(returnPressed(Q3IconViewItem*)),
|
|
||||||
this, SLOT(triggerIconsViewItem(Q3IconViewItem*)));
|
|
||||||
connect(m_iconsView, SIGNAL(signalRequestActivation()),
|
|
||||||
this, SLOT(slotGrabActivation()));
|
|
||||||
|
|
||||||
m_iconsView->endItemUpdates();
|
|
||||||
m_iconsView->show();
|
|
||||||
m_iconsView->setFocus();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case DetailsView: {
|
|
||||||
m_detailsView = new DolphinDetailsView(this);
|
|
||||||
m_topLayout->insertWidget(1, m_detailsView);
|
|
||||||
setFocusProxy(m_detailsView);
|
|
||||||
|
|
||||||
connect(m_detailsView, SIGNAL(executed(Q3ListViewItem*, const QPoint&, int)),
|
|
||||||
this, SLOT(triggerDetailsViewItem(Q3ListViewItem*, const QPoint&, int)));
|
|
||||||
connect(m_detailsView, SIGNAL(returnPressed(Q3ListViewItem*)),
|
|
||||||
this, SLOT(triggerDetailsViewItem(Q3ListViewItem*)));
|
|
||||||
connect(m_detailsView, SIGNAL(signalRequestActivation()),
|
|
||||||
this, SLOT(slotGrabActivation()));
|
|
||||||
m_detailsView->show();
|
|
||||||
m_detailsView->setFocus();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(scrollView(), SIGNAL(contentsMoving(int, int)),
|
|
||||||
this, SLOT(slotContentsMoving(int, int)));
|
|
||||||
|
|
||||||
startDirLister(m_urlNavigator->url());
|
|
||||||
}
|
|
||||||
|
|
||||||
KFileView* DolphinView::fileView() const
|
|
||||||
{
|
|
||||||
return (m_mode == DetailsView) ? static_cast<KFileView*>(m_detailsView) :
|
|
||||||
static_cast<KFileView*>(m_iconsView);
|
static_cast<KFileView*>(m_iconsView);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
Q3ScrollView* DolphinView::scrollView() const
|
Q3ScrollView* DolphinView::scrollView() const
|
||||||
{
|
{
|
||||||
return (m_mode == DetailsView) ? static_cast<Q3ScrollView*>(m_detailsView) :
|
return 0; //(m_mode == DetailsView) ? static_cast<Q3ScrollView*>(m_iconsView) :
|
||||||
static_cast<Q3ScrollView*>(m_iconsView);
|
// static_cast<Q3ScrollView*>(m_iconsView);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemEffectsManager* DolphinView::itemEffectsManager() const
|
ItemEffectsManager* DolphinView::itemEffectsManager() const
|
||||||
{
|
{
|
||||||
return (m_mode == DetailsView) ? static_cast<ItemEffectsManager*>(m_detailsView) :
|
return 0;
|
||||||
static_cast<ItemEffectsManager*>(m_iconsView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::startDirLister(const KUrl& url, bool reload)
|
void DolphinView::startDirLister(const KUrl& url, bool reload)
|
||||||
|
@ -1069,14 +981,14 @@ void DolphinView::slotChangeNameFilter(const QString& nameFilter)
|
||||||
// stay as they are by filtering, only an inserting of an item
|
// stay as they are by filtering, only an inserting of an item
|
||||||
// results to an automatic adjusting of the item position. In Qt4/KDE4
|
// results to an automatic adjusting of the item position. In Qt4/KDE4
|
||||||
// this workaround should get obsolete due to Interview.
|
// this workaround should get obsolete due to Interview.
|
||||||
KFileView* view = fileView();
|
/*KFileView* view = fileView();
|
||||||
if (view == m_iconsView) {
|
if (view == m_iconsView) {
|
||||||
KFileItem* first = view->firstFileItem();
|
KFileItem* first = view->firstFileItem();
|
||||||
if (first != 0) {
|
if (first != 0) {
|
||||||
view->removeItem(first);
|
view->removeItem(first);
|
||||||
view->insertItem(first);
|
view->insertItem(first);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DolphinView::isFilterBarVisible()
|
bool DolphinView::isFilterBarVisible()
|
||||||
|
|
|
@ -34,15 +34,18 @@
|
||||||
#include <kio/job.h>
|
#include <kio/job.h>
|
||||||
#include <urlnavigator.h>
|
#include <urlnavigator.h>
|
||||||
|
|
||||||
|
#include <QListView>
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
class KUrl;
|
class KUrl;
|
||||||
|
class KDirModel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class UrlNavigator;
|
class UrlNavigator;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class Q3IconViewItem;
|
class Q3IconViewItem;
|
||||||
class Q3ListViewItem;
|
class Q3ListViewItem;
|
||||||
class Q3VBoxLayout;
|
class Q3VBoxLayout;
|
||||||
class KFileView;
|
//class KFileView;
|
||||||
class Dolphin;
|
class Dolphin;
|
||||||
class DolphinDirLister;
|
class DolphinDirLister;
|
||||||
class DolphinStatusBar;
|
class DolphinStatusBar;
|
||||||
|
@ -53,6 +56,9 @@ class Q3ScrollView;
|
||||||
class KProgress;
|
class KProgress;
|
||||||
class ItemEffectsManager;
|
class ItemEffectsManager;
|
||||||
class FilterBar;
|
class FilterBar;
|
||||||
|
|
||||||
|
class QModelIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @short Represents a view for the directory content
|
* @short Represents a view for the directory content
|
||||||
* including the navigation bar and status bar.
|
* including the navigation bar and status bar.
|
||||||
|
@ -378,21 +384,15 @@ protected:
|
||||||
private slots:
|
private slots:
|
||||||
void slotUrlChanged(const KUrl& kurl);
|
void slotUrlChanged(const KUrl& kurl);
|
||||||
void triggerIconsViewItem(Q3IconViewItem *item);
|
void triggerIconsViewItem(Q3IconViewItem *item);
|
||||||
void triggerDetailsViewItem(Q3ListViewItem* item,
|
void triggerItem(const QModelIndex& index);
|
||||||
const QPoint& pos,
|
|
||||||
int column);
|
|
||||||
void triggerDetailsViewItem(Q3ListViewItem* item);
|
|
||||||
void updateUrl();
|
void updateUrl();
|
||||||
|
|
||||||
void slotPercent(int percent);
|
void slotPercent(int percent);
|
||||||
void slotClear();
|
void slotClear();
|
||||||
void slotDeleteItem(KFileItem* item);
|
void slotDeleteItem(KFileItem* item);
|
||||||
void slotCompleted();
|
void slotCompleted();
|
||||||
void slotDelayedUpdate();
|
|
||||||
void slotInfoMessage(const QString& msg);
|
void slotInfoMessage(const QString& msg);
|
||||||
void slotErrorMessage(const QString& msg);
|
void slotErrorMessage(const QString& msg);
|
||||||
void slotRefreshItems(const KFileItemList& list);
|
|
||||||
void slotAddItems(const KFileItemList& list);
|
|
||||||
|
|
||||||
void slotGrabActivation();
|
void slotGrabActivation();
|
||||||
|
|
||||||
|
@ -411,8 +411,7 @@ private slots:
|
||||||
void slotChangeNameFilter(const QString& nameFilter);
|
void slotChangeNameFilter(const QString& nameFilter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createView();
|
//KFileView* fileView() const;
|
||||||
KFileView* fileView() const;
|
|
||||||
Q3ScrollView* scrollView() const;
|
Q3ScrollView* scrollView() const;
|
||||||
ItemEffectsManager* itemEffectsManager() const;
|
ItemEffectsManager* itemEffectsManager() const;
|
||||||
void startDirLister(const KUrl& url, bool reload = false);
|
void startDirLister(const KUrl& url, bool reload = false);
|
||||||
|
@ -441,9 +440,7 @@ private:
|
||||||
|
|
||||||
Q3VBoxLayout* m_topLayout;
|
Q3VBoxLayout* m_topLayout;
|
||||||
UrlNavigator* m_urlNavigator;
|
UrlNavigator* m_urlNavigator;
|
||||||
|
|
||||||
DolphinIconsView* m_iconsView;
|
DolphinIconsView* m_iconsView;
|
||||||
DolphinDetailsView* m_detailsView;
|
|
||||||
DolphinStatusBar* m_statusBar;
|
DolphinStatusBar* m_statusBar;
|
||||||
|
|
||||||
int m_iconSize;
|
int m_iconSize;
|
||||||
|
|
|
@ -39,10 +39,10 @@
|
||||||
#define GRID_SPACING_BASE 8
|
#define GRID_SPACING_BASE 8
|
||||||
#define GRID_SPACING_INC 12
|
#define GRID_SPACING_INC 12
|
||||||
|
|
||||||
IconsViewSettingsPage::IconsViewSettingsPage(DolphinIconsView::LayoutMode mode,
|
IconsViewSettingsPage::IconsViewSettingsPage(/*DolphinIconsView::LayoutMode mode,*/
|
||||||
QWidget* parent) :
|
QWidget* parent) :
|
||||||
KVBox(parent),
|
KVBox(parent),
|
||||||
m_mode(mode),
|
//m_mode(mode),
|
||||||
m_iconSizeSlider(0),
|
m_iconSizeSlider(0),
|
||||||
m_previewSizeSlider(0),
|
m_previewSizeSlider(0),
|
||||||
m_textWidthBox(0),
|
m_textWidthBox(0),
|
||||||
|
@ -89,7 +89,7 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinIconsView::LayoutMode mode,
|
||||||
m_iconSizeViewer->setEraseColor(iconBackgroundColor);
|
m_iconSizeViewer->setEraseColor(iconBackgroundColor);
|
||||||
slotIconSizeChanged(m_iconSizeSlider->value());
|
slotIconSizeChanged(m_iconSizeSlider->value());
|
||||||
|
|
||||||
if (m_mode == DolphinIconsView::Previews) {
|
if (false /*m_mode == DolphinIconsView::Previews*/) {
|
||||||
// create 'Preview Size' group including slider and preview
|
// create 'Preview Size' group including slider and preview
|
||||||
Q3GroupBox* previewSizeGroup = new Q3GroupBox(2, Qt::Vertical, i18n("Preview Size"), sizesLayout);
|
Q3GroupBox* previewSizeGroup = new Q3GroupBox(2, Qt::Vertical, i18n("Preview Size"), sizesLayout);
|
||||||
previewSizeGroup->setSizePolicy(sizePolicy);
|
previewSizeGroup->setSizePolicy(sizePolicy);
|
||||||
|
@ -173,8 +173,8 @@ void IconsViewSettingsPage::applySettings()
|
||||||
const int defaultSize = iconSize(m_iconSizeSlider->value());
|
const int defaultSize = iconSize(m_iconSizeSlider->value());
|
||||||
settings->setIconSize(defaultSize);
|
settings->setIconSize(defaultSize);
|
||||||
|
|
||||||
int previewSize = (m_mode == DolphinIconsView::Previews) ?
|
int previewSize = //(m_mode == DolphinIconsView::Previews) ?
|
||||||
iconSize(m_previewSizeSlider->value()) :
|
//iconSize(m_previewSizeSlider->value()) :
|
||||||
defaultSize;
|
defaultSize;
|
||||||
if (previewSize < defaultSize) {
|
if (previewSize < defaultSize) {
|
||||||
// assure that the preview size is never smaller than the icon size
|
// assure that the preview size is never smaller than the icon size
|
||||||
|
|
|
@ -55,7 +55,7 @@ class IconsViewSettingsPage : public KVBox
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IconsViewSettingsPage(DolphinIconsView::LayoutMode mode,
|
IconsViewSettingsPage(/*DolphinIconsView::LayoutMode mode,*/
|
||||||
QWidget* parent);
|
QWidget* parent);
|
||||||
virtual ~IconsViewSettingsPage();
|
virtual ~IconsViewSettingsPage();
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ private slots:
|
||||||
void slotPreviewSizeChanged(int value);
|
void slotPreviewSizeChanged(int value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DolphinIconsView::LayoutMode m_mode;
|
//DolphinIconsView::LayoutMode m_mode;
|
||||||
|
|
||||||
QSlider* m_iconSizeSlider;
|
QSlider* m_iconSizeSlider;
|
||||||
PixmapViewer* m_iconSizeViewer;
|
PixmapViewer* m_iconSizeViewer;
|
||||||
|
|
|
@ -1,189 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* 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., *
|
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#include "itemeffectsmanager.h"
|
|
||||||
#include <kiconeffect.h>
|
|
||||||
#include <kapplication.h>
|
|
||||||
#include <qobject.h>
|
|
||||||
//Added by qt3to4:
|
|
||||||
#include <QPixmap>
|
|
||||||
#include <kglobalsettings.h>
|
|
||||||
#include <qclipboard.h>
|
|
||||||
#include <klocale.h>
|
|
||||||
|
|
||||||
#include "dolphin.h"
|
|
||||||
#include "dolphinstatusbar.h"
|
|
||||||
|
|
||||||
ItemEffectsManager::ItemEffectsManager()
|
|
||||||
{
|
|
||||||
m_pixmapCopy = new QPixmap();
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemEffectsManager::~ItemEffectsManager()
|
|
||||||
{
|
|
||||||
delete m_pixmapCopy;
|
|
||||||
m_pixmapCopy = 0;
|
|
||||||
|
|
||||||
m_highlightedUrl = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemEffectsManager::zoomIn()
|
|
||||||
{
|
|
||||||
Dolphin::mainWin().refreshViews();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemEffectsManager::zoomOut()
|
|
||||||
{
|
|
||||||
Dolphin::mainWin().refreshViews();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemEffectsManager::activateItem(void* context)
|
|
||||||
{
|
|
||||||
KFileItem* fileInfo = contextFileInfo(context);
|
|
||||||
const KUrl itemUrl(fileInfo->url());
|
|
||||||
if (m_highlightedUrl == itemUrl) {
|
|
||||||
// the item is already highlighted
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
resetActivatedItem();
|
|
||||||
|
|
||||||
const QPixmap* itemPixmap = contextPixmap(context);
|
|
||||||
if (itemPixmap != 0) {
|
|
||||||
// remember the pixmap and item to be able to
|
|
||||||
// restore it to the old state later
|
|
||||||
*m_pixmapCopy = *itemPixmap;
|
|
||||||
m_highlightedUrl = itemUrl;
|
|
||||||
|
|
||||||
// apply an icon effect to the item below the mouse pointer
|
|
||||||
KIconEffect iconEffect;
|
|
||||||
QPixmap pixmap = iconEffect.apply(*itemPixmap,
|
|
||||||
K3Icon::Desktop,
|
|
||||||
K3Icon::ActiveState);
|
|
||||||
setContextPixmap(context, pixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Dolphin::mainWin().activeView()->hasSelection()) {
|
|
||||||
DolphinStatusBar* statusBar = Dolphin::mainWin().activeView()->statusBar();
|
|
||||||
statusBar->setMessage(statusBarText(fileInfo), DolphinStatusBar::Default);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemEffectsManager::resetActivatedItem()
|
|
||||||
{
|
|
||||||
if (m_highlightedUrl.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (void* context = firstContext(); context != 0; context = nextContext(context)) {
|
|
||||||
KUrl itemUrl(contextFileInfo(context)->url());
|
|
||||||
if (itemUrl == m_highlightedUrl) {
|
|
||||||
// the highlighted item has been found and is restored to the default state
|
|
||||||
KIconEffect iconEffect;
|
|
||||||
QPixmap pixmap = iconEffect.apply(*m_pixmapCopy,
|
|
||||||
K3Icon::Desktop,
|
|
||||||
K3Icon::DefaultState);
|
|
||||||
|
|
||||||
// TODO: KFileIconView does not emit any signal when the preview has been finished.
|
|
||||||
// Hence check the size to prevent that a preview is hidden by restoring a
|
|
||||||
// non-preview pixmap.
|
|
||||||
const QPixmap* highlightedPixmap = contextPixmap(context);
|
|
||||||
const bool restore = (pixmap.width() == highlightedPixmap->width()) &&
|
|
||||||
(pixmap.height() == highlightedPixmap->height());
|
|
||||||
if (restore) {
|
|
||||||
setContextPixmap(context, pixmap);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_highlightedUrl = 0;
|
|
||||||
|
|
||||||
DolphinStatusBar* statusBar = Dolphin::mainWin().activeView()->statusBar();
|
|
||||||
statusBar->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemEffectsManager::updateDisabledItems()
|
|
||||||
{
|
|
||||||
if (!m_disabledItems.isEmpty()) {
|
|
||||||
// restore all disabled items with their original pixmap
|
|
||||||
for (void* context = firstContext(); context != 0; context = nextContext(context)) {
|
|
||||||
const KFileItem* fileInfo = contextFileInfo(context);
|
|
||||||
const KUrl& fileUrl = fileInfo->url();
|
|
||||||
Q3ValueListIterator<DisabledItem> it = m_disabledItems.begin();
|
|
||||||
while (it != m_disabledItems.end()) {
|
|
||||||
if (fileUrl == (*it).url) {
|
|
||||||
setContextPixmap(context, (*it).pixmap);
|
|
||||||
}
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_disabledItems.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Dolphin::mainWin().clipboardContainsCutData()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QClipboard* clipboard = QApplication::clipboard();
|
|
||||||
const QMimeData* data = clipboard->mimeData();
|
|
||||||
KUrl::List urls = KUrl::List::fromMimeData(data);
|
|
||||||
if (urls.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The clipboard contains items, which have been cutted. Change the pixmaps of all those
|
|
||||||
// items to the disabled state.
|
|
||||||
for (void* context = firstContext(); context != 0; context = nextContext(context)) {
|
|
||||||
const KFileItem* fileInfo = contextFileInfo(context);
|
|
||||||
const KUrl& fileUrl = fileInfo->url();
|
|
||||||
for(KUrl::List::ConstIterator it = urls.begin(); it != urls.end(); ++it) {
|
|
||||||
if (fileUrl == (*it)) {
|
|
||||||
const QPixmap* itemPixmap = contextPixmap(context);
|
|
||||||
if (itemPixmap != 0) {
|
|
||||||
// remember old pixmap
|
|
||||||
DisabledItem disabledItem;
|
|
||||||
disabledItem.url = fileUrl;
|
|
||||||
disabledItem.pixmap = *itemPixmap;
|
|
||||||
m_disabledItems.append(disabledItem);
|
|
||||||
|
|
||||||
KIconEffect iconEffect;
|
|
||||||
QPixmap disabledPixmap = iconEffect.apply(*itemPixmap,
|
|
||||||
K3Icon::Desktop,
|
|
||||||
K3Icon::DisabledState);
|
|
||||||
setContextPixmap(context, disabledPixmap);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ItemEffectsManager::statusBarText(KFileItem* fileInfo) const
|
|
||||||
{
|
|
||||||
if (fileInfo->isDir()) {
|
|
||||||
// KFileItem::getStatusBar() returns "MyDocuments/ Folder" as
|
|
||||||
// status bar text for a folder 'MyDocuments'. This is adjusted
|
|
||||||
// to "MyDocuments (Folder)" in Dolphin.
|
|
||||||
return i18n("%1 (Folder)",fileInfo->name());
|
|
||||||
}
|
|
||||||
|
|
||||||
return fileInfo->getStatusBarInfo();
|
|
||||||
}
|
|
|
@ -1,120 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* 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., *
|
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#ifndef ITEMEFFECTSMANAGER_H
|
|
||||||
#define ITEMEFFECTSMANAGER_H
|
|
||||||
|
|
||||||
#include <qobject.h>
|
|
||||||
#include <qpixmap.h>
|
|
||||||
#include <kurl.h>
|
|
||||||
#include <q3valuelist.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 Qt4 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 QListView and QIconView of Qt3.
|
|
||||||
*
|
|
||||||
* @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 QPixmap& pixmap) = 0;
|
|
||||||
virtual const QPixmap* 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;
|
|
||||||
QPixmap pixmap;
|
|
||||||
};
|
|
||||||
|
|
||||||
QPixmap* m_pixmapCopy;
|
|
||||||
KUrl m_highlightedUrl;
|
|
||||||
|
|
||||||
// contains all items which have been disabled by a 'cut' operation
|
|
||||||
Q3ValueList<DisabledItem> m_disabledItems;
|
|
||||||
|
|
||||||
/** Returns the text for the statusbar for an activated item. */
|
|
||||||
QString statusBarText(KFileItem* fileInfo) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <Q3VBoxLayout>
|
#include <Q3VBoxLayout>
|
||||||
#include <kdialog.h>
|
#include <kdialog.h>
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
|
#include <kiconloader.h>
|
||||||
#include "iconsviewsettingspage.h"
|
#include "iconsviewsettingspage.h"
|
||||||
#include "detailsviewsettingspage.h"
|
#include "detailsviewsettingspage.h"
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ ViewSettingsPage::ViewSettingsPage(QWidget *parent) :
|
||||||
QTabWidget* tabWidget = new QTabWidget(parent);
|
QTabWidget* tabWidget = new QTabWidget(parent);
|
||||||
|
|
||||||
// initialize 'Icons' tab
|
// initialize 'Icons' tab
|
||||||
m_iconsPage = new IconsViewSettingsPage(DolphinIconsView::Icons, tabWidget);
|
m_iconsPage = new IconsViewSettingsPage(/*DolphinIconsView::Icons,*/ tabWidget);
|
||||||
tabWidget->addTab(m_iconsPage, SmallIcon("view_icon"), i18n("Icons"));
|
tabWidget->addTab(m_iconsPage, SmallIcon("view_icon"), i18n("Icons"));
|
||||||
|
|
||||||
// initialize 'Details' tab
|
// initialize 'Details' tab
|
||||||
|
@ -48,7 +49,7 @@ ViewSettingsPage::ViewSettingsPage(QWidget *parent) :
|
||||||
tabWidget->addTab(m_detailsPage, SmallIcon("view_text"), i18n("Details"));
|
tabWidget->addTab(m_detailsPage, SmallIcon("view_text"), i18n("Details"));
|
||||||
|
|
||||||
// initialize 'Previews' tab
|
// initialize 'Previews' tab
|
||||||
m_previewsPage = new IconsViewSettingsPage(DolphinIconsView::Previews, tabWidget);
|
m_previewsPage = new IconsViewSettingsPage(/*DolphinIconsView::Previews,*/ tabWidget);
|
||||||
tabWidget->addTab(m_previewsPage, SmallIcon("gvdirpart"), i18n("Previews"));
|
tabWidget->addTab(m_previewsPage, SmallIcon("gvdirpart"), i18n("Previews"));
|
||||||
|
|
||||||
topLayout->addWidget(tabWidget, 0, 0 );
|
topLayout->addWidget(tabWidget, 0, 0 );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user