[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kfile
From: Kevin Ottens <ervin () kde ! org>
Date: 2010-06-14 21:20:39
Message-ID: 20100614212039.0DEFFAC8D3 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1137988 by ervin:
"Add Entry" now adds the newly created entry just after the one where we
triggered the context menu.
BUG: 208015
M +6 -1 kfileplacesitem.cpp
M +2 -1 kfileplacesitem_p.h
M +12 -0 kfileplacesmodel.cpp
M +1 -0 kfileplacesmodel.h
M +1 -1 kfileplacesview.cpp
M +16 -0 tests/kfileplacesmodeltest.cpp
--- trunk/KDE/kdelibs/kfile/kfileplacesitem.cpp #1137987:1137988
@@ -222,7 +222,8 @@
KBookmark KFilePlacesItem::createBookmark(KBookmarkManager *manager,
const QString &label,
const KUrl &url,
- const QString &iconName)
+ const QString &iconName,
+ KFilePlacesItem *after)
{
KBookmarkGroup root = manager->root();
if (root.isNull())
@@ -238,6 +239,10 @@
KBookmark bookmark = root.addBookmark(label, url, empty_icon);
bookmark.setMetaDataItem("ID", generateNewId());
+ if (after) {
+ root.moveBookmark(bookmark, after->bookmark());
+ }
+
return bookmark;
}
--- trunk/KDE/kdelibs/kfile/kfileplacesitem_p.h #1137987:1137988
@@ -55,7 +55,8 @@
static KBookmark createBookmark(KBookmarkManager *manager,
const QString &label,
const KUrl &url,
- const QString &iconName);
+ const QString &iconName,
+ KFilePlacesItem *after = 0);
static KBookmark createSystemBookmark(KBookmarkManager *manager,
const QString &untranslatedLabel,
const QString &translatedLabel,
--- trunk/KDE/kdelibs/kfile/kfileplacesmodel.cpp #1137987:1137988
@@ -636,6 +636,13 @@
void KFilePlacesModel::addPlace(const QString &text, const KUrl &url,
const QString &iconName, const QString &appName)
{
+ addPlace(text, url, iconName, appName, QModelIndex());
+}
+
+void KFilePlacesModel::addPlace(const QString &text, const KUrl &url,
+ const QString &iconName, const QString &appName,
+ const QModelIndex &after)
+{
KBookmark bookmark = KFilePlacesItem::createBookmark(d->bookmarkManager,
text, url, iconName);
@@ -643,6 +650,11 @@
bookmark.setMetaDataItem("OnlyInApp", appName);
}
+ if (after.isValid()) {
+ KFilePlacesItem *item = \
static_cast<KFilePlacesItem*>(after.internalPointer()); + \
d->bookmarkManager->root().moveBookmark(bookmark, item->bookmark()); + }
+
d->reloadAndSignal();
}
--- trunk/KDE/kdelibs/kfile/kfileplacesmodel.h #1137987:1137988
@@ -68,6 +68,7 @@
void requestSetup(const QModelIndex &index);
void addPlace(const QString &text, const KUrl &url, const QString &iconName = \
QString(), const QString &appName = QString()); + void addPlace(const QString \
&text, const KUrl &url, const QString &iconName, const QString &appName, const \
QModelIndex &after);
void editPlace(const QModelIndex &index, const QString &text, const KUrl &url, \
const QString &iconName = QString(), const QString &appName = QString()); void \
removePlace(const QModelIndex &index) const; void setPlaceHidden(const QModelIndex \
&index, bool hidden);
--- trunk/KDE/kdelibs/kfile/kfileplacesview.cpp #1137987:1137988
@@ -680,7 +680,7 @@
QString appName;
if (appLocal) appName = KGlobal::mainComponent().componentName();
- placesModel->addPlace(label, url, iconName, appName);
+ placesModel->addPlace(label, url, iconName, appName, index);
}
}
--- trunk/KDE/kdelibs/kfile/tests/kfileplacesmodeltest.cpp #1137987:1137988
@@ -531,6 +531,22 @@
QCOMPARE(args.at(0).value<QModelIndex>(), QModelIndex());
QCOMPARE(args.at(1).toInt(), 3);
QCOMPARE(args.at(2).toInt(), 3);
+
+ m_places->addPlace("Foo", KUrl("/home/foo"), QString(), QString(), \
m_places->index(1, 0)); +
+ urls.clear();
+ urls << KUser().homeDir() << "remote:/" << "/home/foo" << KDE_ROOT_PATH
+ << "trash:/" << "/media/floppy0" << "/foreign" << "/media/XO-Y4";
+
+ CHECK_PLACES_URLS(urls);
+ QCOMPARE(spy_inserted.count(), 1);
+ args = spy_inserted.takeFirst();
+ QCOMPARE(args.at(0).value<QModelIndex>(), QModelIndex());
+ QCOMPARE(args.at(1).toInt(), 2);
+ QCOMPARE(args.at(2).toInt(), 2);
+ QCOMPARE(spy_removed.count(), 0);
+
+ m_places->removePlace(m_places->index(2, 0));
}
void KFilePlacesModelTest::testDevicePlugging()
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic