mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
provide an option to rename files inline
CCMAIL: fredrik@kde.org svn path=/trunk/KDE/kdebase/apps/; revision=789208
This commit is contained in:
parent
71afbc513b
commit
cfb135f24e
6 changed files with 43 additions and 22 deletions
|
@ -249,6 +249,11 @@ void DolphinColumnView::showColumn(const KUrl& url)
|
||||||
assureVisibleActiveColumn();
|
assureVisibleActiveColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DolphinColumnView::editItem(const KFileItem& item)
|
||||||
|
{
|
||||||
|
activeColumn()->editItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
void DolphinColumnView::selectAll()
|
void DolphinColumnView::selectAll()
|
||||||
{
|
{
|
||||||
activeColumn()->selectAll();
|
activeColumn()->selectAll();
|
||||||
|
@ -305,13 +310,12 @@ void DolphinColumnView::setSelection(const QRect& rect, QItemSelectionModel::Sel
|
||||||
{
|
{
|
||||||
Q_UNUSED(rect);
|
Q_UNUSED(rect);
|
||||||
Q_UNUSED(flags);
|
Q_UNUSED(flags);
|
||||||
//activeColumn()->setSelection(rect, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRegion DolphinColumnView::visualRegionForSelection(const QItemSelection& selection) const
|
QRegion DolphinColumnView::visualRegionForSelection(const QItemSelection& selection) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(selection);
|
Q_UNUSED(selection);
|
||||||
return QRegion(); //activeColumn()->visualRegionForSelection(selection);
|
return QRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
int DolphinColumnView::horizontalOffset() const
|
int DolphinColumnView::horizontalOffset() const
|
||||||
|
|
|
@ -91,6 +91,12 @@ public:
|
||||||
*/
|
*/
|
||||||
void showColumn(const KUrl& url);
|
void showColumn(const KUrl& url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does an inline editing for the item \a item
|
||||||
|
* inside the active column.
|
||||||
|
*/
|
||||||
|
void editItem(const KFileItem& item);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/** @see QAbstractItemView::selectAll() */
|
/** @see QAbstractItemView::selectAll() */
|
||||||
virtual void selectAll();
|
virtual void selectAll();
|
||||||
|
|
|
@ -229,6 +229,14 @@ void DolphinColumnWidget::setNameFilter(const QString& nameFilter)
|
||||||
m_proxyModel->setFilterRegExp(nameFilter);
|
m_proxyModel->setFilterRegExp(nameFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DolphinColumnWidget::editItem(const KFileItem& item)
|
||||||
|
{
|
||||||
|
const QModelIndex dirIndex = m_dolphinModel->indexForItem(item);
|
||||||
|
const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
|
||||||
|
if (proxyIndex.isValid()) {
|
||||||
|
edit(proxyIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QStyleOptionViewItem DolphinColumnWidget::viewOptions() const
|
QStyleOptionViewItem DolphinColumnWidget::viewOptions() const
|
||||||
{
|
{
|
||||||
|
@ -305,15 +313,11 @@ void DolphinColumnWidget::paintEvent(QPaintEvent* event)
|
||||||
if (proxyIndex.isValid() && !selectionModel()->isSelected(proxyIndex)) {
|
if (proxyIndex.isValid() && !selectionModel()->isSelected(proxyIndex)) {
|
||||||
const QRect itemRect = visualRect(proxyIndex);
|
const QRect itemRect = visualRect(proxyIndex);
|
||||||
QPainter painter(viewport());
|
QPainter painter(viewport());
|
||||||
painter.save();
|
|
||||||
|
|
||||||
QColor color = KColorScheme(QPalette::Active, KColorScheme::View).foreground().color();
|
QColor color = KColorScheme(QPalette::Active, KColorScheme::View).foreground().color();
|
||||||
color.setAlpha(32);
|
color.setAlpha(32);
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
painter.setBrush(color);
|
painter.setBrush(color);
|
||||||
painter.drawRect(itemRect);
|
painter.drawRect(itemRect);
|
||||||
|
|
||||||
painter.restore();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void setNameFilter(const QString& nameFilter);
|
void setNameFilter(const QString& nameFilter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does an inline editing for the item \a item.
|
||||||
|
*/
|
||||||
|
void editItem(const KFileItem& item);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QStyleOptionViewItem viewOptions() const;
|
virtual QStyleOptionViewItem viewOptions() const;
|
||||||
virtual void startDrag(Qt::DropActions supportedActions);
|
virtual void startDrag(Qt::DropActions supportedActions);
|
||||||
|
@ -140,6 +145,8 @@ private:
|
||||||
IconManager* m_iconManager;
|
IconManager* m_iconManager;
|
||||||
|
|
||||||
QRect m_dropRect;
|
QRect m_dropRect;
|
||||||
|
|
||||||
|
friend class DolphinColumnView;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool DolphinColumnWidget::isActive() const
|
inline bool DolphinColumnWidget::isActive() const
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <kactioncollection.h>
|
#include <kactioncollection.h>
|
||||||
#include <kcolorscheme.h>
|
#include <kcolorscheme.h>
|
||||||
#include <kdirlister.h>
|
#include <kdirlister.h>
|
||||||
|
#include <kfileitemdelegate.h>
|
||||||
#include <kiconeffect.h>
|
#include <kiconeffect.h>
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <kio/deletejob.h>
|
#include <kio/deletejob.h>
|
||||||
|
@ -49,7 +50,6 @@
|
||||||
#include "dolphinmodel.h"
|
#include "dolphinmodel.h"
|
||||||
#include "dolphincolumnview.h"
|
#include "dolphincolumnview.h"
|
||||||
#include "dolphincontroller.h"
|
#include "dolphincontroller.h"
|
||||||
#include "dolphinfileitemdelegate.h"
|
|
||||||
#include "dolphinsortfilterproxymodel.h"
|
#include "dolphinsortfilterproxymodel.h"
|
||||||
#include "dolphindetailsview.h"
|
#include "dolphindetailsview.h"
|
||||||
#include "dolphiniconsview.h"
|
#include "dolphiniconsview.h"
|
||||||
|
@ -866,16 +866,12 @@ void DolphinView::emitContentsMoved()
|
||||||
|
|
||||||
void DolphinView::showHoverInformation(const KFileItem& item)
|
void DolphinView::showHoverInformation(const KFileItem& item)
|
||||||
{
|
{
|
||||||
if (!hasSelection()) {
|
emit requestItemInfo(item);
|
||||||
emit requestItemInfo(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::clearHoverInformation()
|
void DolphinView::clearHoverInformation()
|
||||||
{
|
{
|
||||||
if (m_active) {
|
emit requestItemInfo(KFileItem());
|
||||||
emit requestItemInfo(KFileItem());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DolphinView::createView()
|
void DolphinView::createView()
|
||||||
|
@ -909,7 +905,7 @@ void DolphinView::createView()
|
||||||
|
|
||||||
m_controller->setItemView(view);
|
m_controller->setItemView(view);
|
||||||
|
|
||||||
m_fileItemDelegate = new DolphinFileItemDelegate(view);
|
m_fileItemDelegate = new KFileItemDelegate(view);
|
||||||
view->setItemDelegate(m_fileItemDelegate);
|
view->setItemDelegate(m_fileItemDelegate);
|
||||||
|
|
||||||
view->setModel(m_proxyModel);
|
view->setModel(m_proxyModel);
|
||||||
|
@ -1021,14 +1017,19 @@ void DolphinView::renameSelectedItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if (DolphinSettings::instance().generalSettings()->renameInline()) {
|
||||||
// Only one item has been selected for renaming. Use the custom
|
Q_ASSERT(items.count() == 1);
|
||||||
// renaming mechanism from the views.
|
|
||||||
|
if (isColumnViewActive()) {
|
||||||
|
m_columnView->editItem(items.first());
|
||||||
|
} else {
|
||||||
|
const QModelIndex dirIndex = m_dolphinModel->indexForItem(items.first());
|
||||||
|
const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
|
||||||
|
itemView()->edit(proxyIndex);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Q_ASSERT(items.count() == 1);
|
Q_ASSERT(items.count() == 1);
|
||||||
|
|
||||||
// TODO: Think about using KFileItemDelegate as soon as it supports editing.
|
|
||||||
// Currently the RenameDialog is used, but I'm not sure whether inline renaming
|
|
||||||
// is a benefit for the user at all -> let's wait for some input first...
|
|
||||||
RenameDialog dialog(this, items);
|
RenameDialog dialog(this, items);
|
||||||
if (dialog.exec() == QDialog::Rejected) {
|
if (dialog.exec() == QDialog::Rejected) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
class DolphinController;
|
class DolphinController;
|
||||||
class DolphinColumnView;
|
class DolphinColumnView;
|
||||||
class DolphinDetailsView;
|
class DolphinDetailsView;
|
||||||
class DolphinFileItemDelegate;
|
|
||||||
class DolphinIconsView;
|
class DolphinIconsView;
|
||||||
class DolphinMainWindow;
|
class DolphinMainWindow;
|
||||||
class DolphinModel;
|
class DolphinModel;
|
||||||
|
@ -636,7 +635,7 @@ private:
|
||||||
DolphinIconsView* m_iconsView;
|
DolphinIconsView* m_iconsView;
|
||||||
DolphinDetailsView* m_detailsView;
|
DolphinDetailsView* m_detailsView;
|
||||||
DolphinColumnView* m_columnView;
|
DolphinColumnView* m_columnView;
|
||||||
DolphinFileItemDelegate* m_fileItemDelegate;
|
KFileItemDelegate* m_fileItemDelegate;
|
||||||
QItemSelectionModel* m_selectionModel;
|
QItemSelectionModel* m_selectionModel;
|
||||||
|
|
||||||
DolphinModel* m_dolphinModel;
|
DolphinModel* m_dolphinModel;
|
||||||
|
|
Loading…
Reference in a new issue