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:
Ivo Anjo 2008-10-18 14:52:52 +00:00
parent a08297e318
commit a0bfc7316f
2 changed files with 9 additions and 1 deletions

View file

@ -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)

View file

@ -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;