summaryrefslogtreecommitdiffstats
path: root/tdeui/tdelistview.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2013-11-06 19:48:25 +0100
committerSlávek Banko <slavek.banko@axis.cz>2013-11-06 19:51:41 +0100
commit6bf8e926c7ec585e83451444fa81fd1cec1d2a6b (patch)
treeb4898b78519b17970b191607a3682f9aeb21f272 /tdeui/tdelistview.cpp
parent645993e7d8ffafbd9d4d0d70cc53f04cfd0c6c3a (diff)
downloadtdelibs-6bf8e926c7ec585e83451444fa81fd1cec1d2a6b.tar.gz
tdelibs-6bf8e926c7ec585e83451444fa81fd1cec1d2a6b.zip
Enhance renaming in Konqueror listview
This relates to Bug 1677
Diffstat (limited to 'tdeui/tdelistview.cpp')
-rw-r--r--tdeui/tdelistview.cpp91
1 files changed, 65 insertions, 26 deletions
diff --git a/tdeui/tdelistview.cpp b/tdeui/tdelistview.cpp
index c60070d4a..32e7273af 100644
--- a/tdeui/tdelistview.cpp
+++ b/tdeui/tdelistview.cpp
@@ -17,6 +17,7 @@
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
+
#include "config.h"
#include <tqdragobject.h>
@@ -72,8 +73,8 @@ public:
autoSelectDelay(0),
useSmallExecuteArea(false),
dragOverItem(0),
- dragDelay (TDEGlobalSettings::dndEventDelay()),
- editor (new TDEListViewLineEdit (listview)),
+ dragDelay(TDEGlobalSettings::dndEventDelay()),
+ editor(new TDEListViewLineEdit(listview)),
cursorInExecuteArea(false),
itemsMovable (true),
selectedBySimpleMove(false),
@@ -106,6 +107,8 @@ public:
{
renameable.append(0);
connect(editor, TQT_SIGNAL(done(TQListViewItem*,int)), listview, TQT_SLOT(doneEditing(TQListViewItem*,int)));
+ connect(editor, TQT_SIGNAL(renameNext(TQListViewItem*,int)), listview, TQT_SLOT(renameNextProxy(TQListViewItem*,int)));
+ connect(editor, TQT_SIGNAL(renamePrev(TQListViewItem*,int)), listview, TQT_SLOT(renamePrevProxy(TQListViewItem*,int)));
}
~TDEListViewPrivate ()
@@ -176,13 +179,13 @@ public:
TDEListViewLineEdit::TDEListViewLineEdit(TDEListView *parent)
- : KLineEdit(parent->viewport()), item(0), col(0), p(parent)
+ : KLineEdit(parent->viewport()), item(0), col(0), p(parent), m_renSett()
{
- setFrame( false );
- hide();
- connect( parent, TQT_SIGNAL( selectionChanged() ), TQT_SLOT( slotSelectionChanged() ));
- connect( parent, TQT_SIGNAL( itemRemoved( TQListViewItem * ) ),
- TQT_SLOT( slotItemRemoved( TQListViewItem * ) ));
+ setFrame( false );
+ hide();
+ connect( parent, TQT_SIGNAL( selectionChanged() ), TQT_SLOT( slotSelectionChanged() ));
+ connect( parent, TQT_SIGNAL( itemRemoved( TQListViewItem * ) ),
+ TQT_SLOT( slotItemRemoved( TQListViewItem * ) ));
}
TDEListViewLineEdit::~TDEListViewLineEdit()
@@ -323,37 +326,58 @@ void TDEListViewLineEdit::selectNextCell (TQListViewItem *pitem, int column, boo
#undef KeyPress
#endif
-bool TDEListViewLineEdit::event (TQEvent *pe)
+bool TDEListViewLineEdit::event(TQEvent *pe)
{
if (pe->type() == TQEvent::KeyPress)
{
- TQKeyEvent *k = (TQKeyEvent *) pe;
-
- if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) &&
- p->tabOrderedRenaming() && p->itemsRenameable() &&
- !(k->state() & ControlButton || k->state() & AltButton))
+ TQKeyEvent *k = (TQKeyEvent*)pe;
+ KKey kk(k);
+ if (m_renSett.m_useRenameSignals &&
+ (m_renSett.m_SCNext.contains(kk) || m_renSett.m_SCPrev.contains(kk)))
+ {
+ keyPressEvent(k);
+ return true;
+ }
+ else if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) &&
+ p->tabOrderedRenaming() && p->itemsRenameable() &&
+ !(k->state() & ControlButton || k->state() & AltButton))
{
- selectNextCell(item, col,
- (k->key() == Key_Tab && !(k->state() & ShiftButton)));
+ selectNextCell(item, col, (k->key() == Key_Tab && !(k->state() & ShiftButton)));
return true;
- }
+ }
}
-
return KLineEdit::event(pe);
}
void TDEListViewLineEdit::keyPressEvent(TQKeyEvent *e)
{
- if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )
+ KKey kk(e);
+ if (m_renSett.m_useRenameSignals &&
+ (m_renSett.m_SCNext.contains(kk) || m_renSett.m_SCPrev.contains(kk)))
+ {
+ TQListViewItem *i=item;
+ int c=col;
+ terminate(true);
+ KLineEdit::keyPressEvent(e);
+ if (m_renSett.m_SCNext.contains(kk))
+ {
+ emit renameNext(i,c);
+ }
+ else
+ {
+ emit renamePrev(i,c);
+ }
+ }
+ else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter)
terminate(true);
else if(e->key() == Qt::Key_Escape)
terminate(false);
- else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up)
- {
+ else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up)
+ {
terminate(true);
- KLineEdit::keyPressEvent(e);
- }
- else
+ KLineEdit::keyPressEvent(e);
+ }
+ else
KLineEdit::keyPressEvent(e);
}
@@ -425,8 +449,7 @@ void TDEListViewLineEdit::slotItemRemoved(TQListViewItem *i)
TDEListView::TDEListView( TQWidget *parent, const char *name )
- : TQListView( parent, name ),
- d (new TDEListViewPrivate (this))
+ : TQListView(parent, name), d(new TDEListViewPrivate(this))
{
setDragAutoScroll(true);
@@ -1416,6 +1439,17 @@ void TDEListView::doneEditing(TQListViewItem *item, int row)
emit itemRenamed(item);
}
+void TDEListView::renameNextProxy(TQListViewItem *item, int col)
+{
+ emit renameNext(item, col);
+}
+
+void TDEListView::renamePrevProxy(TQListViewItem *item, int col)
+{
+ emit renamePrev(item, col);
+}
+
+
bool TDEListView::acceptDrag(TQDropEvent* e) const
{
return acceptDrops() && itemsMovable() && (e->source()==viewport());
@@ -2424,6 +2458,11 @@ bool TDEListView::useSmallExecuteArea() const
return d->useSmallExecuteArea;
}
+void TDEListView::setRenameSettings(const TDEListViewRenameSettings &renSett)
+{
+ d->editor->setRenameSettings(renSett);
+}
+
void TDEListView::virtual_hook( int, void* )
{ /*BASE::virtual_hook( id, data );*/ }