Enhance renaming in Konqueror listview

This resolves Bug 1677
pull/2/head
Michele Calgaro 11 years ago committed by Slávek Banko
parent 7d025dfef0
commit b42f6dbb13

@ -161,6 +161,14 @@ void ListViewBrowserExtension::rename()
{ {
TQListViewItem* item = m_listView->listViewWidget()->currentItem(); TQListViewItem* item = m_listView->listViewWidget()->currentItem();
Q_ASSERT ( item ); Q_ASSERT ( item );
// Update shurtcuts for the 'rename and move' actions. Must be done every time since the
// shortcuts may have been changed by the user in the meanwhile
const TDEShortcut moveNextSC=m_listView->m_paRenameMoveNext->shortcut();
const TDEShortcut movePrevSC=m_listView->m_paRenameMovePrev->shortcut();
m_listView->listViewWidget()->setRenameSettings(TDEListViewRenameSettings(
!(moveNextSC.isNull() && movePrevSC.isNull()), moveNextSC, movePrevSC));
m_listView->listViewWidget()->rename( item, 0 ); m_listView->listViewWidget()->rename( item, 0 );
// Enhanced rename: Don't highlight the file extension. // Enhanced rename: Don't highlight the file extension.
@ -671,6 +679,22 @@ void KonqListView::setupActions()
m_paUnselectAll = new TDEAction( i18n( "Unselect All" ), CTRL+Key_U, this, TQT_SLOT( slotUnselectAll() ), actionCollection(), "unselectall" ); m_paUnselectAll = new TDEAction( i18n( "Unselect All" ), CTRL+Key_U, this, TQT_SLOT( slotUnselectAll() ), actionCollection(), "unselectall" );
m_paInvertSelection = new TDEAction( i18n( "&Invert Selection" ), CTRL+Key_Asterisk, this, TQT_SLOT( slotInvertSelection() ), actionCollection(), "invertselection" ); m_paInvertSelection = new TDEAction( i18n( "&Invert Selection" ), CTRL+Key_Asterisk, this, TQT_SLOT( slotInvertSelection() ), actionCollection(), "invertselection" );
// These 2 actions are 'fake' actions. They are defined so that the keyboard shortcuts
// can be set from the 'Configure Shortcuts..." dialog.
// The real actions are performed in the TDEListViewLineEdit::keyPressEvent() in tdeui
m_paRenameMoveNext = new TDEAction(i18n( "&Rename and move to next item" ), Key_Tab,
NULL, NULL, actionCollection(), "renameMoveNext" );
m_paRenameMoveNext->setWhatsThis(i18n("Pressing this button completes the current rename operation,"
"moves to the next item and starts a new rename operation."));
m_paRenameMoveNext->setToolTip( i18n("Complete rename operation and move the next item"));
m_paRenameMoveNext->setEnabled(false);
m_paRenameMovePrev = new TDEAction( i18n( "&Rename and move to previous item" ), SHIFT+Key_BackTab,
NULL, NULL, actionCollection(), "renameMovePrev" );
m_paRenameMovePrev->setWhatsThis(i18n("Pressing this button completes the current rename operation,"
"moves to the previous item and starts a new rename operation."));
m_paRenameMovePrev->setToolTip( i18n("Complete rename operation and move the previous item"));
m_paRenameMovePrev->setEnabled(false);
m_paShowDot = new TDEToggleAction( i18n( "Show &Hidden Files" ), 0, this, TQT_SLOT( slotShowDot() ), actionCollection(), "show_dot" ); m_paShowDot = new TDEToggleAction( i18n( "Show &Hidden Files" ), 0, this, TQT_SLOT( slotShowDot() ), actionCollection(), "show_dot" );
// m_paShowDot->setCheckedState(i18n("Hide &Hidden Files")); // m_paShowDot->setCheckedState(i18n("Hide &Hidden Files"));
m_paCaseInsensitive = new TDEToggleAction(i18n("Case Insensitive Sort"), 0, this, TQT_SLOT(slotCaseInsensitive()),actionCollection(), "sort_caseinsensitive" ); m_paCaseInsensitive = new TDEToggleAction(i18n("Case Insensitive Sort"), 0, this, TQT_SLOT(slotCaseInsensitive()),actionCollection(), "sort_caseinsensitive" );

@ -62,6 +62,7 @@ private:
class KonqListView : public KonqDirPart class KonqListView : public KonqDirPart
{ {
friend class KonqBaseListViewWidget; friend class KonqBaseListViewWidget;
friend class ListViewBrowserExtension;
Q_OBJECT Q_OBJECT
TQ_PROPERTY( bool supportsUndo READ supportsUndo ) TQ_PROPERTY( bool supportsUndo READ supportsUndo )
public: public:
@ -153,6 +154,12 @@ private:
TDEAction *m_paUnselectAll; TDEAction *m_paUnselectAll;
TDEAction *m_paInvertSelection; TDEAction *m_paInvertSelection;
// These 2 actions are 'fake' actions. They are defined so that the keyboard shortcuts
// can be set from the 'Configure Shortcuts..." dialog.
// The real actions are performed in the TDEListViewLineEdit::keyPressEvent() in tdeui
TDEAction *m_paRenameMoveNext;
TDEAction *m_paRenameMovePrev;
TDEToggleAction *m_paCaseInsensitive; TDEToggleAction *m_paCaseInsensitive;
TDEToggleAction *m_paShowDot; TDEToggleAction *m_paShowDot;

@ -129,13 +129,16 @@ KonqBaseListViewWidget::KonqBaseListViewWidget( KonqListView *parent, TQWidget *
this, TQT_SLOT(slotMouseButtonClicked2( int, TQListViewItem *, const TQPoint&, int )) ); this, TQT_SLOT(slotMouseButtonClicked2( int, TQListViewItem *, const TQPoint&, int )) );
connect( this, TQT_SIGNAL(executed( TQListViewItem * )), connect( this, TQT_SIGNAL(executed( TQListViewItem * )),
this, TQT_SLOT(slotExecuted( TQListViewItem * )) ); this, TQT_SLOT(slotExecuted( TQListViewItem * )) );
connect( this, TQT_SIGNAL(currentChanged( TQListViewItem * )), connect( this, TQT_SIGNAL(currentChanged( TQListViewItem * )),
this, TQT_SLOT(slotCurrentChanged( TQListViewItem * )) ); this, TQT_SLOT(slotCurrentChanged( TQListViewItem * )) );
connect( this, TQT_SIGNAL(itemRenamed( TQListViewItem *, const TQString &, int )), connect( this, TQT_SIGNAL(itemRenamed( TQListViewItem *, const TQString &, int )),
this, TQT_SLOT(slotItemRenamed( TQListViewItem *, const TQString &, int )) ); this, TQT_SLOT(slotItemRenamed( TQListViewItem *, const TQString &, int )) );
connect( this, TQT_SIGNAL(contextMenuRequested( TQListViewItem *, const TQPoint&, int )), connect( this, TQT_SIGNAL(contextMenuRequested( TQListViewItem *, const TQPoint&, int )),
this, TQT_SLOT(slotPopupMenu( TQListViewItem *, const TQPoint&, int )) ); this, TQT_SLOT(slotPopupMenu( TQListViewItem *, const TQPoint&, int )) );
connect( this, TQT_SIGNAL(renameNext( TQListViewItem *, int )),
this, TQT_SLOT(slotRenameNextItem( TQListViewItem*, int)) );
connect( this, TQT_SIGNAL(renamePrev( TQListViewItem *, int )),
this, TQT_SLOT(slotRenamePrevItem( TQListViewItem*, int)) );
connect( this, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(slotSelectionChanged()) ); connect( this, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(slotSelectionChanged()) );
connect( horizontalScrollBar(), TQT_SIGNAL(valueChanged( int )), connect( horizontalScrollBar(), TQT_SIGNAL(valueChanged( int )),
@ -878,6 +881,38 @@ void KonqBaseListViewWidget::slotItemRenamed( TQListViewItem *item, const TQStri
setFocus(); setFocus();
} }
void KonqBaseListViewWidget::slotRenameNextItem(TQListViewItem *item, int)
{
TQListViewItem *nextItem = item->itemBelow();
if (!nextItem)
{
nextItem=this->firstChild();
if (!nextItem)
return;
}
setCurrentItem(nextItem);
ListViewBrowserExtension *lvbe = dynamic_cast<ListViewBrowserExtension*>(m_pBrowserView->m_extension);
if (lvbe)
lvbe->rename();
}
void KonqBaseListViewWidget::slotRenamePrevItem(TQListViewItem *item, int)
{
TQListViewItem *prevItem = item->itemAbove();
if (!prevItem)
{
prevItem=this->lastItem();
if (!prevItem)
return;
}
setCurrentItem(prevItem);
ListViewBrowserExtension *lvbe = dynamic_cast<ListViewBrowserExtension*>(m_pBrowserView->m_extension);
if (lvbe)
lvbe->rename();
}
void KonqBaseListViewWidget::reportItemCounts() void KonqBaseListViewWidget::reportItemCounts()
{ {
KFileItemList lst = selectedFileItems(); KFileItemList lst = selectedFileItems();

@ -158,6 +158,8 @@ public slots:
void slotMouseButtonClicked2( int _button, TQListViewItem *_item, const TQPoint& pos, int ); void slotMouseButtonClicked2( int _button, TQListViewItem *_item, const TQPoint& pos, int );
virtual void slotExecuted( TQListViewItem *_item ); virtual void slotExecuted( TQListViewItem *_item );
void slotItemRenamed( TQListViewItem *, const TQString &, int ); void slotItemRenamed( TQListViewItem *, const TQString &, int );
void slotRenameNextItem(TQListViewItem *item, int col);
void slotRenamePrevItem(TQListViewItem *item, int col);
protected slots: protected slots:
void slotAutoScroll(); void slotAutoScroll();

Loading…
Cancel
Save