mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-20 00:41:23 +00:00
Fix crash when dragging and dropping a bookmark below the last row.
Fix compiler warning. svn path=/trunk/KDE/kdebase/apps/; revision=873021
This commit is contained in:
parent
a08297e318
commit
a0bfc7316f
|
@ -80,10 +80,12 @@ QVariant KBookmarkModel::data(const QModelIndex &index, int role) const
|
|||
{
|
||||
KBookmark bk = bookmarkForIndex(index);
|
||||
if(bk.address().isEmpty())
|
||||
{
|
||||
if(index.column() == 0)
|
||||
return QVariant( i18n("Bookmarks") );
|
||||
else
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
switch( index.column() )
|
||||
{
|
||||
|
@ -185,6 +187,10 @@ QModelIndex KBookmarkModel::index(int row, int column, const QModelIndex &parent
|
|||
return createIndex(row, column, d->mRootItem);
|
||||
|
||||
TreeItem * item = static_cast<TreeItem *>(parent.internalPointer());
|
||||
if(row == item->childCount()) {// Received drop below last row, simulate drop on last row
|
||||
return createIndex(row-1, column, item->child(row-1));
|
||||
}
|
||||
|
||||
return createIndex(row, column, item->child(row));
|
||||
}
|
||||
|
||||
|
@ -281,6 +287,7 @@ bool KBookmarkModel::dropMimeData(const QMimeData * data, Qt::DropAction action,
|
|||
Q_UNUSED(action)
|
||||
|
||||
//FIXME this only works for internal drag and drops
|
||||
//FIXME Moving is *very* buggy
|
||||
|
||||
QModelIndex idx;
|
||||
if(row == -1)
|
||||
|
|
|
@ -35,7 +35,7 @@ TreeItem * TreeItem::child(int row)
|
|||
{
|
||||
if(!init)
|
||||
initChildren();
|
||||
if(row < 0 || row > children.count())
|
||||
if(row < 0 || row >= children.count())
|
||||
return parent();
|
||||
return children.at(row);
|
||||
}
|
||||
|
@ -127,3 +127,4 @@ TreeItem * TreeItem::treeItemForBookmark(const KBookmark& bk)
|
|||
}
|
||||
}
|
||||
|
||||
// kate: space-indent on; indent-width 4; replace-tabs on;
|
||||
|
|
Loading…
Reference in a new issue