Prevent that a manual call to save changed bookmarks is
necessary.
void KStandardItemModel::onItemChanged(int index, const QSet<QByteArray>& changedRoles)
{
Q_UNUSED(index);
void KStandardItemModel::onItemChanged(int index, const QSet<QByteArray>& changedRoles)
{
Q_UNUSED(index);
+ Q_UNUSED(changedRoles);
}
void KStandardItemModel::onItemRemoved(int index)
}
void KStandardItemModel::onItemRemoved(int index)
PlacesItem::PlacesItem(const PlacesItem& item) :
KStandardItem(item),
PlacesItem::PlacesItem(const PlacesItem& item) :
KStandardItem(item),
- m_device(),
- m_access(),
- m_volume(),
- m_disc(),
+ m_device(item.m_device),
+ m_access(item.m_access),
+ m_volume(item.m_volume),
+ m_disc(item.m_disc),
+ m_bookmark(item.m_bookmark)
+ if (item.m_accessListener) {
+ m_accessListener = new PlacesItemStorageAccessListener(this);
+ }
}
PlacesItem::~PlacesItem()
}
PlacesItem::~PlacesItem()
m_systemBookmarks(),
m_systemBookmarksIndexes(),
m_hiddenItems(),
m_systemBookmarks(),
m_systemBookmarksIndexes(),
m_hiddenItems(),
- m_hiddenItemToRemove(-1)
+ m_hiddenItemToRemove(-1),
+ m_saveBookmarksTimer(0)
{
#ifdef HAVE_NEPOMUK
m_nepomukRunning = (Nepomuk::ResourceManager::instance()->initialized());
{
#ifdef HAVE_NEPOMUK
m_nepomukRunning = (Nepomuk::ResourceManager::instance()->initialized());
createSystemBookmarks();
initializeAvailableDevices();
loadBookmarks();
createSystemBookmarks();
initializeAvailableDevices();
loadBookmarks();
+
+ m_saveBookmarksTimer = new QTimer(this);
+ m_saveBookmarksTimer->setInterval(100);
+ m_saveBookmarksTimer->setSingleShot(true);
+ connect(m_saveBookmarksTimer, SIGNAL(timeout()), this, SLOT(saveBookmarks()));
}
PlacesItemModel::~PlacesItemModel()
{
}
PlacesItemModel::~PlacesItemModel()
{
qDeleteAll(m_hiddenItems);
m_hiddenItems.clear();
}
qDeleteAll(m_hiddenItems);
m_hiddenItems.clear();
}
} else {
// Move all items of the model, where the "isHidden" property is true, to
// m_hiddenItems.
} else {
// Move all items of the model, where the "isHidden" property is true, to
// m_hiddenItems.
- //Q_ASSERT(m_hiddenItems.count() == count());
+ Q_ASSERT(m_hiddenItems.count() == count());
for (int i = count() - 1; i >= 0; --i) {
PlacesItem* visibleItem = placesItem(i);
if (visibleItem->isHidden()) {
for (int i = count() - 1; i >= 0; --i) {
PlacesItem* visibleItem = placesItem(i);
if (visibleItem->isHidden()) {
-
-void PlacesItemModel::save()
-{
- // TODO: Temporary deactivated until 100 % backward compatibility is provided
- // m_bookmarkManager->emitChanged(m_bookmarkManager->root());
-}
-
void PlacesItemModel::onItemInserted(int index)
{
if (index == count() - 1) {
void PlacesItemModel::onItemInserted(int index)
{
if (index == count() - 1) {
}
m_hiddenItems.insert(hiddenIndex, 0);
}
m_hiddenItems.insert(hiddenIndex, 0);
+ m_saveBookmarksTimer->start();
+
#ifdef PLACESITEMMODEL_DEBUG
kDebug() << "Inserted item" << index;
showModelState();
#ifdef PLACESITEMMODEL_DEBUG
kDebug() << "Inserted item" << index;
showModelState();
const int removeIndex = hiddenIndex(index);
Q_ASSERT(!m_hiddenItems[removeIndex]);
m_hiddenItems.removeAt(removeIndex);
const int removeIndex = hiddenIndex(index);
Q_ASSERT(!m_hiddenItems[removeIndex]);
m_hiddenItems.removeAt(removeIndex);
+
+ m_saveBookmarksTimer->start();
+
#ifdef PLACESITEMMODEL_DEBUG
kDebug() << "Removed item" << index;
showModelState();
#ifdef PLACESITEMMODEL_DEBUG
kDebug() << "Removed item" << index;
showModelState();
if (changedRoles.contains("isHidden")) {
const PlacesItem* shownItem = placesItem(index);
Q_ASSERT(shownItem);
if (changedRoles.contains("isHidden")) {
const PlacesItem* shownItem = placesItem(index);
Q_ASSERT(shownItem);
- const bool hide = shownItem->isHidden();
-
- if (!m_hiddenItemsShown && hide) {
+ if (!m_hiddenItemsShown && shownItem->isHidden()) {
m_hiddenItemToRemove = index;
QTimer::singleShot(0, this, SLOT(removeHiddenItem()));
}
}
m_hiddenItemToRemove = index;
QTimer::singleShot(0, this, SLOT(removeHiddenItem()));
}
}
+ m_saveBookmarksTimer->start();
}
void PlacesItemModel::slotDeviceAdded(const QString& udi)
}
void PlacesItemModel::slotDeviceAdded(const QString& udi)
PlacesItem* hiddenItem = new PlacesItem(*shownItem);
removeItem(m_hiddenItemToRemove);
m_hiddenItems.insert(newIndex, hiddenItem);
PlacesItem* hiddenItem = new PlacesItem(*shownItem);
removeItem(m_hiddenItemToRemove);
m_hiddenItems.insert(newIndex, hiddenItem);
+ m_saveBookmarksTimer->start();
}
m_hiddenItemToRemove = -1;
}
}
m_hiddenItemToRemove = -1;
}
+
+void PlacesItemModel::saveBookmarks()
+{
+ // TODO: Temporary deactivated until 100 % backward compatibility is provided
+ // m_bookmarkManager->emitChanged(m_bookmarkManager->root());
+}
+
void PlacesItemModel::loadBookmarks()
{
KBookmarkGroup root = m_bookmarkManager->root();
void PlacesItemModel::loadBookmarks()
{
KBookmarkGroup root = m_bookmarkManager->root();
class KBookmarkManager;
class PlacesItem;
class QAction;
class KBookmarkManager;
class PlacesItem;
class QAction;
// #define PLACESITEMMODEL_DEBUG
// #define PLACESITEMMODEL_DEBUG
void requestEject(int index);
void requestTeardown(int index);
void requestEject(int index);
void requestTeardown(int index);
signals:
void errorMessage(const QString& message);
signals:
void errorMessage(const QString& message);
void slotDeviceRemoved(const QString& udi);
void slotStorageTeardownDone(Solid::ErrorType error, const QVariant& errorData);
void removeHiddenItem();
void slotDeviceRemoved(const QString& udi);
void slotStorageTeardownDone(Solid::ErrorType error, const QVariant& errorData);
void removeHiddenItem();
/**
* Helper method for loadBookmarks(): Adds the items
/**
* Helper method for loadBookmarks(): Adds the items
// asynchronously as in the scope of onItemChanged()
// removing an item is not allowed.
int m_hiddenItemToRemove;
// asynchronously as in the scope of onItemChanged()
// removing an item is not allowed.
int m_hiddenItemToRemove;
+
+ QTimer* m_saveBookmarksTimer;
editEntry(index);
} else if (action == removeAction) {
m_model->removeItem(index);
editEntry(index);
} else if (action == removeAction) {
m_model->removeItem(index);
} else if (action == hideAction) {
item->setHidden(hideAction->isChecked());
} else if (action == hideAction) {
item->setHidden(hideAction->isChecked());
} else if (action == openInNewTabAction) {
const KUrl url = m_model->item(index)->dataValue("url").value<KUrl>();
emit placeMiddleClicked(url);
} else if (action == openInNewTabAction) {
const KUrl url = m_model->item(index)->dataValue("url").value<KUrl>();
emit placeMiddleClicked(url);
}
void PlacesPanel::editEntry(int index)
}
void PlacesPanel::editEntry(int index)
}
void PlacesPanel::selectClosestItem()
}
void PlacesPanel::selectClosestItem()