Ejemplo n.º 1
0
void PlacesView::onRenameBookmark() {
  PlacesModel::ItemAction* action = static_cast<PlacesModel::ItemAction*>(sender());
  if(!action->index().isValid())
    return;
  PlacesModelBookmarkItem* item = static_cast<PlacesModelBookmarkItem*>(model_->itemFromIndex(action->index()));
  setFocus();
  setCurrentIndex(item->index());
  edit(item->index());
}
Ejemplo n.º 2
0
// virtual
void PlacesView::commitData(QWidget * editor) {
  QTreeView::commitData(editor);
  PlacesModelBookmarkItem* item = static_cast<PlacesModelBookmarkItem*>(model_->itemFromIndex(currentIndex()));
  FmBookmarkItem* bookmarkItem = item->bookmark();
  FmBookmarks* bookmarks = fm_bookmarks_dup();
  // rename bookmark
  fm_bookmarks_rename(bookmarks, bookmarkItem, item->text().toUtf8().constData());
  g_object_unref(bookmarks);
}
Ejemplo n.º 3
0
PlacesModelBookmarkItem* PlacesModel::itemFromBookmark(FmBookmarkItem* bkitem) {
  int rowCount = bookmarksRoot->rowCount();
  for(int i = 0; i < rowCount; ++i) {
    PlacesModelBookmarkItem* item = static_cast<PlacesModelBookmarkItem*>(bookmarksRoot->child(i, 0));
    if(item->bookmark() == bkitem)
      return item;
  }
  return NULL;
}
Ejemplo n.º 4
0
void PlacesView::onDeleteBookmark() {
  PlacesModel::ItemAction* action = static_cast<PlacesModel::ItemAction*>(sender());
  if(!action->index().isValid())
    return;
  PlacesModelBookmarkItem* item = static_cast<PlacesModelBookmarkItem*>(model_->itemFromIndex(action->index()));
  FmBookmarkItem* bookmarkItem = item->bookmark();
  FmBookmarks* bookmarks = fm_bookmarks_dup();
  fm_bookmarks_remove(bookmarks, bookmarkItem);
  g_object_unref(bookmarks);
}
Ejemplo n.º 5
0
void PlacesView::onMoveBookmarkDown()
{
  PlacesModel::ItemAction* action = static_cast<PlacesModel::ItemAction*>(sender());
  if(!action->index().isValid())
    return;
  PlacesModelBookmarkItem* item = static_cast<PlacesModelBookmarkItem*>(model_->itemFromIndex(action->index()));

  int row = item->row();
  if(row < model_->rowCount()) {
    FmBookmarkItem* bookmarkItem = item->bookmark();
    FmBookmarks* bookmarks = fm_bookmarks_dup();
    fm_bookmarks_reorder(bookmarks, bookmarkItem, row + 1);
    g_object_unref(bookmarks);
  }
}