From 27856879bf962f178d88e79144e37a47e731b122 Mon Sep 17 00:00:00 2001 From: tpearson Date: Fri, 3 Sep 2010 09:14:57 +0000 Subject: * Massive import of OpenSUSE patches, primarily for bugfixes * Added some infrastructure created by OpenSUSE to allow for future addition of the Kickoff menu as an option * Minor Slackware compilation fixes git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1171255 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kdesktop/kdiconview.cc | 120 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 111 insertions(+), 9 deletions(-) (limited to 'kdesktop/kdiconview.cc') diff --git a/kdesktop/kdiconview.cc b/kdesktop/kdiconview.cc index caa68feb9..5762458fd 100644 --- a/kdesktop/kdiconview.cc +++ b/kdesktop/kdiconview.cc @@ -962,6 +962,18 @@ void KDIconView::slotNewItems( const KFileItemList & entries ) kdDebug(1214) << "KDIconView::slotNewItems count=" << entries.count() << endl; KFileItemListIterator it(entries); KFileIVI* fileIVI = 0L; + + if (m_nextItemPos.isNull() && !m_dotDirectory) { + // Not found, we'll need to save the new pos + kdDebug(1214)<<"Neither a drop position stored nor m_dotDirectory set"<url(); @@ -1026,15 +1038,6 @@ void KDIconView::slotNewItems( const KFileItemList & entries ) kdDebug(1214)<<"Using saved position"< viewport()->width()) + return TQPoint(); + + while ( rect.bottom() < viewport()->height() - spacing() ) + { + if ( !isFreePosition(0,rect) ) + rect.moveBy(0, rect.height()); + else + return rect.topLeft(); + } + + return TQPoint(); +} + +TQPoint KDIconView::findPlaceForIconRow( int row, int dx, int dy ) +{ + if (row < 0) + return TQPoint(); + + TQRect rect; + rect.moveTopLeft(TQPoint(0, row * dy)); + rect.setWidth(dx); + rect.setHeight(dy); + + if (rect.bottom() > viewport()->height()) + return TQPoint(); + + while (rect.right() < viewport()->width() - spacing()) + { + if (!isFreePosition(0,rect)) + rect.moveBy(rect.width()+spacing(), 0); + else + return rect.topLeft(); + } + + return TQPoint(); +} + +TQPoint KDIconView::findPlaceForIcon( int column, int row) +{ + int dx = gridXValue(), dy = 0; + TQIconViewItem *item = firstItem(); + for ( ; item; item = item->nextItem() ) { + dx = QMAX( dx, item->width() ); + dy = QMAX( dy, item->height() ); + } + + dx += spacing(); + dy += spacing(); + + if (row == -1) { + int max_cols = viewport()->width() / dx; + int delta = 0; + TQPoint res; + do { + delta++; + res = findPlaceForIconCol(column + (delta / 2) * (-2 * (delta % 2) + 1), + dx, dy); + if (delta / 2 > QMAX(max_cols - column, column)) + return res; + } while (res.isNull()); + return res; + } + + if (column == -1) { + int max_rows = viewport()->height() / dy; + int delta = 0; + TQPoint res; + do { + delta++; + res = findPlaceForIconRow(row + (delta / 2) * (-2 * (delta % 2) + 1), + dx, dy); + if (delta / 2 > QMAX(max_rows - row, row)) + return res; + } while (res.isNull()); + return res; + } + + // very unlikely - if I may add that + return TQPoint(0, 0); +} + void KDIconView::saveIconPositions() { kdDebug(1214) << "KDIconView::saveIconPositions" << endl; @@ -1665,4 +1760,11 @@ void KDIconView::saveIconPositions() m_dotDirectory->sync(); } +void KDIconView::update( const TQString &_url ) +{ + if (m_dirLister) + m_dirLister->updateDirectory( _url ); +} + + #include "kdiconview.moc" -- cgit v1.2.1