-rw-r--r-- | microkde/kdeui/klistview.cpp | 9 | ||||
-rw-r--r-- | microkde/kdeui/klistview.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp index 25327aa..f7d2187 100644 --- a/microkde/kdeui/klistview.cpp +++ b/microkde/kdeui/klistview.cpp @@ -383,193 +383,202 @@ void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) terminate(true); } void KListViewLineEdit::paintEvent( QPaintEvent *e ) { KLineEdit::paintEvent( e ); if ( !frame() ) { QPainter p( this ); p.setClipRegion( e->region() ); p.drawRect( rect() ); } } // selection changed -> terminate. As our "item" can be already deleted, // we can't call terminate(false), because that would emit done() with // a dangling pointer to "item". void KListViewLineEdit::slotSelectionChanged() { item = 0; col = 0; hide(); } */ KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse ) : QListView( parent, name ), d (new KListViewPrivate (this)) { #ifndef DESKTOP_VERSION if ( emulateRightMouse ) QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif //US setDragAutoScroll(true); connect( this, SIGNAL( onViewport() ), this, SLOT( slotOnViewport() ) ); connect( this, SIGNAL( onItem( QListViewItem * ) ), this, SLOT( slotOnItem( QListViewItem * ) ) ); connect (this, SIGNAL(contentsMoving(int,int)), this, SLOT(cleanDropVisualizer())); connect (this, SIGNAL(contentsMoving(int,int)), this, SLOT(cleanItemHighlighter())); /*US slotSettingsChanged(KApplication::SETTINGS_MOUSE); if (kapp) { connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); kapp->addKipcEventMask( KIPC::SettingsChanged ); } */ slotSettingsChanged(1); //US do this to initialize the connections connect(&d->autoSelect, SIGNAL( timeout() ), this, SLOT( slotAutoSelect() ) ); connect(&d->dragExpand, SIGNAL( timeout() ), this, SLOT( slotDragExpand() ) ); // context menu handling if (d->showContextMenusOnPress) { connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); } else { connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); } connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), this, SLOT (emitContextMenu (KListView*, QListViewItem*))); //qDebug("KListView::KListView make alternate color configurable"); d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); } KListView::~KListView() { delete d; } bool KListView::isExecuteArea( const QPoint& point ) { if ( itemAt( point ) ) return isExecuteArea( point.x() ); return false; } +QSize KListView::sizeHint() const +{ + //qDebug("KListView::QSize sizeHint() "); +#ifdef DESKTOP_VERSION + QListView::sizeHint(); +#else + return QSize ( 40, 40 ); +#endif +} bool KListView::isExecuteArea( int x ) { if( allColumnsShowFocus() ) return true; else { int offset = 0; int width = columnWidth( 0 ); int pos = header()->mapToIndex( 0 ); for ( int index = 0; index < pos; index++ ) offset += columnWidth( header()->mapToSection( index ) ); x += contentsX(); // in case of a horizontal scrollbar return ( x > offset && x < ( offset + width ) ); } } void KListView::slotOnItem( QListViewItem *item ) { QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { d->autoSelect.start( d->autoSelectDelay, true ); d->pCurrentItem = item; } } void KListView::slotOnViewport() { if ( d->bChangeCursorOverItem ) viewport()->unsetCursor(); d->autoSelect.stop(); d->pCurrentItem = 0L; } void KListView::slotSettingsChanged(int category) { //qDebug("KListView::slotSettingsChanged has to be verified"); switch (category) { //US I create my private category (=1) to set the settings case 1: d->dragDelay = 2; //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); if( d->bUseSingle ) connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); if( !d->bUseSingle || !d->bChangeCursorOverItem ) viewport()->unsetCursor(); break; /*US case KApplication::SETTINGS_MOUSE: d->dragDelay = KGlobalSettings::dndEventDelay(); d->bUseSingle = KGlobalSettings::singleClick(); disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); if( d->bUseSingle ) connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); if( !d->bUseSingle || !d->bChangeCursorOverItem ) viewport()->unsetCursor(); break; case KApplication::SETTINGS_POPUPMENU: d->contextMenuKey = KGlobalSettings::contextMenuKey (); d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); if (d->showContextMenusOnPress) { disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); } else { disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); diff --git a/microkde/kdeui/klistview.h b/microkde/kdeui/klistview.h index 0058416..9f0d9fd 100644 --- a/microkde/kdeui/klistview.h +++ b/microkde/kdeui/klistview.h @@ -37,192 +37,193 @@ class KLineEdit; * This Widget extends the functionality of QListView to honor the system * wide settings for Single Click/Double Click mode, AutoSelection and * ChangeCursorOverLink (TM). * * There is a new signal executed(). It gets connected to either * @ref QListView::clicked() or @ref QListView::doubleClicked() depending on the KDE * wide Single Click/Double Click settings. It is strongly recommended that * you use this signal instead of the above mentioned. This way you dont * need to care about the current settings. * If you want to get informed when the user selects something connect to the * QListView::selectionChanged() signal. * * Drag-and-Drop is supported with the signal @ref #dropped(), just @ref #setAcceptDrops(true) * and connect it to a suitable slot. * To see where you are dropping, @ref setDropVisualizer(true). * And also you'll need @ref acceptDrag(QDropEvent*) * * KListView is drag-enabled, too: to benefit from that you've got derive from it. * Reimplement @ref dragObject() and (possibly) @ref startDrag(), * and @ref setDragEnabled(true). * * @version $Id$ */ class KListView : public QListView { Q_OBJECT Q_ENUMS( SelectionModeExt ) Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth ) Q_PROPERTY( bool itemsMovable READ itemsMovable WRITE setItemsMovable ) Q_PROPERTY( bool itemsRenameable READ itemsRenameable WRITE setItemsRenameable ) Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled ) Q_PROPERTY( bool autoOpen READ autoOpen WRITE setAutoOpen ) Q_PROPERTY( bool dropVisualizer READ dropVisualizer WRITE setDropVisualizer ) //US Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn ) Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setDropVisualizerWidth ) Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE setAlternateBackground ) Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt ) public: /** * Possible selection modes. * * The first four correspond directly to QListView::SelectionMode, while * the FileManager selection mode is defined as follows: * @li home: move to the first * @li end: move to the last * @li PgUp/PgDn: move one page up/down * @li up/down: move one item up/down * @li insert: toggle selection of current and move to the next * @li space: toggle selection of the current * @li CTRL+up: move to the previous item and toggle selection of this one * @li CTRL+down: toggle selection of the current item and move to the next * @li CTRL+end: toggle selection from (including) the current * item to (including) the last item * @li CTRL+home: toggle selection from (including) the current * item to the (including) the first item * @li CTRL+PgDn: toggle selection from (including) the current * item to (excluding) the item one page down * @li CTRL+PgUp: toggle selection from (excluding) the current * item to (including) the item one page up * * The combinations work the same with SHIFT instead of CTRL, except * that if you start selecting something using SHIFT everything selected * before will be deselected first. * * Additionally the current item is always selected automatically when * navigating using the keyboard, except other items were selected explicitely. * * This way e.g. SHIFT+up/PgUp then SHIFT+down/PgDn leaves no item selected */ enum SelectionModeExt { Single = QListView::Single, Multi = QListView::Multi, Extended = QListView::Extended, NoSelection = QListView::NoSelection, FileManager }; void repaintContents( bool erase = true ) { QScrollView::repaintContents( contentsX(), contentsY(), visibleWidth(), visibleHeight(), erase ); }; /** * Constructor. * * The parameters @p parent and @p name are handled by * @ref QListView, as usual. */ KListView (QWidget *parent = 0, const char *name = 0, bool emulateRightMouse = true ); /** * Destructor. */ virtual ~KListView(); + virtual QSize sizeHint() const; /** * Reimplemented for internal reasons. * Further reimplementations should call this function or else * some features may not work correctly. * * The API is unaffected. */ virtual void setAcceptDrops (bool); /** * This function determines whether the given coordinates are within the * execute area. The execute area is the part of a @ref QListViewItem where mouse * clicks or double clicks respectively generate a @ref #executed() signal. * Depending on @ref QListView::allColumnsShowFocus() this is either the * whole item or only the first column. * @return true if point is inside execute area of an item, false in all * other cases including the case that it is over the viewport. */ virtual bool isExecuteArea( const QPoint& point ); /** * Same thing, but from an x coordinate only. This only checks if x is in * the first column (if all columns don't show focus), without testing if * the y coordinate is over an item or not. */ bool isExecuteArea( int x ); /** * @return a list containing the currently selected items. */ QPtrList<QListViewItem> selectedItems() const; // ### BIC: KDE 4: use an implicitly shared class! (QValueList?) /** * Arbitrarily move @p item to @p parent, positioned immediately after item @p after. */ void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after); /** * @return the last item (not child!) of this listview. * * @see lastChild() */ QListViewItem *lastItem() const; /** * @return the last child of this listview. * * @see lastItem() */ QListViewItem* lastChild () const; /** * @return the lineedit used for inline renaming. * Use that to setup a @ref KCompletion or @ref QValidator for the lineedit * * @since 3.2 */ KLineEdit* renameLineEdit() const; /** * @returns if it is legal to move items in the list view. True by default. * * @see #setDragEnabled() * @see #setItemsMovable() */ bool itemsMovable() const; /** * @return whether inplace-renaming has been enabled. False by default. * * @see #setItemsRenameable() */ bool itemsRenameable() const; /** * @return whether dragging is enabled. False by default. * * @see #setDragEnabled() */ bool dragEnabled() const; /** * @return true if AutoOpen is enabled (not implemented currently). * * @see #setAutoOpen() */ bool autoOpen() const; /** * @return true if @p column is renamable. * * @see #setRenameable() */ bool isRenameable (int column) const; /** |