summaryrefslogtreecommitdiffstats
path: root/kdesktop/kdiconview.cc
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-03 09:14:57 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-03 09:14:57 +0000
commit27856879bf962f178d88e79144e37a47e731b122 (patch)
treea3bd3f489b755cd2941e7c53b90d12d6bfd4fbe3 /kdesktop/kdiconview.cc
parentc5228d52f504d6d2c0fefdd625ec08ebb8e91f85 (diff)
downloadtdebase-27856879bf962f178d88e79144e37a47e731b122.tar.gz
tdebase-27856879bf962f178d88e79144e37a47e731b122.zip
* 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
Diffstat (limited to 'kdesktop/kdiconview.cc')
-rw-r--r--kdesktop/kdiconview.cc120
1 files changed, 111 insertions, 9 deletions
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"<<endl;
+ m_dotDirectory = new KSimpleConfig( dotDirectoryPath(), true );
+ // recursion
+ slotNewItems( entries );
+ delete m_dotDirectory;
+ m_dotDirectory = 0;
+ return;
+ }
+
for (; it.current(); ++it)
{
KURL url = it.current()->url();
@@ -1026,15 +1038,6 @@ void KDIconView::slotNewItems( const KFileItemList & entries )
kdDebug(1214)<<"Using saved position"<<endl;
}
}
- else
- {
- // Not found, we'll need to save the new pos
- kdDebug(1214)<<"slotNewItems(): New item without position information, try to find a sane location"<<endl;
-
- moveToFreePosition(fileIVI);
-
- m_bNeedSave = true;
- }
}
}
@@ -1638,6 +1641,98 @@ void KDIconView::moveToFreePosition(TQIconViewItem *item )
}
+TQPoint KDIconView::findPlaceForIconCol( int column, int dx, int dy)
+{
+ if (column < 0)
+ return TQPoint();
+
+ TQRect rect;
+ rect.moveTopLeft( TQPoint(column * dx, 0) );
+ rect.setWidth(dx);
+ rect.setHeight(dy);
+
+ if (rect.right() > 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"