[niepce: 8/29] engine+rust: LibFolder is now implemented in Rust
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce: 8/29] engine+rust: LibFolder is now implemented in Rust
- Date: Fri, 22 Sep 2017 00:42:23 +0000 (UTC)
commit 608444edbeeeeecc8aad5539f93793413ba92542
Author: Hubert Figuière <hub figuiere net>
Date: Wed Jun 7 20:30:00 2017 -0400
engine+rust: LibFolder is now implemented in Rust
src/engine/db/keyword.rs | 24 ++++++
src/engine/db/libfolder.cpp | 20 ++++--
src/engine/db/libfolder.hpp | 71 ++++++------------
src/engine/db/libfolder.rs | 133 +++++++++++++++++++++++++++++++++
src/engine/db/library.cpp | 27 +++----
src/engine/db/library.hpp | 6 +-
src/engine/db/mod.rs | 29 +-------
src/engine/db/test_library.cpp | 23 +++---
src/engine/library/commands.cpp | 16 ++--
src/engine/library/notification.hpp | 2 +-
src/niepce/ui/workspacecontroller.cpp | 17 ++--
src/niepce/ui/workspacecontroller.hpp | 2 +-
12 files changed, 242 insertions(+), 128 deletions(-)
---
diff --git a/src/engine/db/keyword.rs b/src/engine/db/keyword.rs
index ae4abed..2d55e7e 100644
--- a/src/engine/db/keyword.rs
+++ b/src/engine/db/keyword.rs
@@ -18,6 +18,8 @@
*/
use super::LibraryId;
+use libc::c_char;
+use std::ffi::CStr;
use std::ffi::CString;
pub struct Keyword {
@@ -42,3 +44,25 @@ impl Keyword {
&self.keyword
}
}
+
+#[no_mangle]
+pub extern fn engine_db_keyword_new(id: i64, keyword: *const c_char) -> *mut Keyword {
+ let kw = Box::new(Keyword::new(id, &*unsafe { CStr::from_ptr(keyword) }.to_string_lossy()));
+ Box::into_raw(kw)
+}
+
+#[no_mangle]
+pub extern fn engine_db_keyword_id(this: &Keyword) -> i64 {
+ this.id() as i64
+}
+
+#[no_mangle]
+pub extern fn engine_db_keyword_keyword(this: &mut Keyword) -> *const c_char {
+ this.cstr = CString::new(this.keyword().clone()).unwrap();
+ this.cstr.as_ptr()
+}
+
+#[no_mangle]
+pub extern fn engine_db_keyword_delete(kw: *mut Keyword) {
+ unsafe { Box::from_raw(kw) };
+}
diff --git a/src/engine/db/libfolder.cpp b/src/engine/db/libfolder.cpp
index 57a0b52..176f60e 100644
--- a/src/engine/db/libfolder.cpp
+++ b/src/engine/db/libfolder.cpp
@@ -19,14 +19,22 @@
#include "libfolder.hpp"
+extern "C" eng::LibFolder* engine_db_libfolder_new(eng::library_id_t id, const char* name);
+extern "C" void engine_db_libfolder_delete(eng::LibFolder*);
+
namespace eng {
-const char* LibFolder::read_db_columns()
+LibFolderPtr libfolder_new(eng::library_id_t id, const char* name) {
+ return LibFolderPtr(
+ engine_db_libfolder_new(id, name), &engine_db_libfolder_delete);
+}
+
+const char* libfolder_read_db_columns()
{
return "id,name,virtual,locked,expanded";
}
-LibFolder::Ptr LibFolder::read_from(const db::IConnectionDriver::Ptr & db)
+LibFolderPtr libfolder_read_from(const db::IConnectionDriver::Ptr & db)
{
library_id_t id;
std::string name;
@@ -36,10 +44,10 @@ LibFolder::Ptr LibFolder::read_from(const db::IConnectionDriver::Ptr & db)
db->get_column_content(2, virt_type);
db->get_column_content(3, locked);
db->get_column_content(4, expanded);
- LibFolder::Ptr f(new LibFolder(id, name));
- f->set_virtual_type((VirtualType)virt_type);
- f->set_is_locked((bool)locked);
- f->set_expanded((bool)expanded);
+ LibFolderPtr f(libfolder_new(id, name.c_str()));
+ engine_db_libfolder_set_virtual_type(f.get(), virt_type);
+ engine_db_libfolder_set_locked(f.get(), (bool)locked);
+ engine_db_libfolder_set_expanded(f.get(), (bool)expanded);
return f;
}
diff --git a/src/engine/db/libfolder.hpp b/src/engine/db/libfolder.hpp
index 9f56457..d654bc3 100644
--- a/src/engine/db/libfolder.hpp
+++ b/src/engine/db/libfolder.hpp
@@ -1,7 +1,7 @@
/*
* niepce - eng/db/libfolder.hpp
*
- * Copyright (C) 2007-2013 Hubert Figuiere
+ * Copyright (C) 2007-2017 Hubert Figuière
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,9 +18,7 @@
*/
-
-#ifndef __NIEPCE_DB_LIBFOLDER_H__
-#define __NIEPCE_DB_LIBFOLDER_H__
+#pragma once
#include <string>
#include <list>
@@ -30,57 +28,34 @@
#include "fwk/utils/db/iconnectiondriver.hpp"
namespace eng {
+class LibFolder;
+typedef std::shared_ptr<LibFolder> LibFolderPtr;
+typedef std::list<LibFolderPtr> LibFolderList;
+typedef std::shared_ptr<LibFolderList> LibFolderListPtr;
-class LibFolder
-{
-public:
- typedef std::shared_ptr< LibFolder > Ptr;
- typedef std::list< Ptr > List;
- typedef std::shared_ptr< List > ListPtr;
- enum class VirtualType {
- NONE = 0,
- TRASH = 1,
+enum class LibFolderVirtualType {
+ NONE = 0,
+ TRASH = 1,
- _LAST
- };
+ _LAST
+};
- LibFolder(library_id_t _id, std::string _name)
- : m_id(_id), m_name(_name)
- , m_locked(false)
- , m_virtual(VirtualType::NONE)
- {
- }
- library_id_t id() const
- { return m_id; }
- const std::string & name() const
- { return m_name; }
+const char * libfolder_read_db_columns();
+LibFolderPtr libfolder_read_from(const db::IConnectionDriver::Ptr & db);
- bool is_locked() const
- { return m_locked; }
- void set_is_locked(bool _locked)
- { m_locked = _locked; }
- bool is_expanded() const
- { return m_expanded; }
- void set_expanded(bool _exp)
- { m_expanded = _exp; }
- VirtualType virtual_type() const
- { return m_virtual; }
- void set_virtual_type(VirtualType _virtual)
- { m_virtual = _virtual; }
+LibFolderPtr libfolder_new(library_id_t id, const char* name);
- /** database persistance */
- static const char * read_db_columns();
- static Ptr read_from(const db::IConnectionDriver::Ptr & db);
-private:
- library_id_t m_id;
- std::string m_name;
- bool m_locked;
- bool m_expanded;
- VirtualType m_virtual;
-};
+extern "C" library_id_t engine_db_libfolder_id(const LibFolder*);
+extern "C" const char* engine_db_libfolder_name(const LibFolder*);
+extern "C" int32_t engine_db_libfolder_virtual_type(const LibFolder*);
+extern "C" bool engine_db_libfolder_expanded(const LibFolder*);
+extern "C" void engine_db_libfolder_set_locked(const LibFolder*, bool);
+extern "C" void engine_db_libfolder_set_expanded(const LibFolder*, bool);
+extern "C" void engine_db_libfolder_set_virtual_type(const LibFolder*, int32_t);
}
+
/*
Local Variables:
mode:c++
@@ -90,5 +65,3 @@ private:
fill-column:80
End:
*/
-
-#endif
diff --git a/src/engine/db/libfolder.rs b/src/engine/db/libfolder.rs
new file mode 100644
index 0000000..9a7a124
--- /dev/null
+++ b/src/engine/db/libfolder.rs
@@ -0,0 +1,133 @@
+/*
+ * niepce - eng/db/libfolder.rs
+ *
+ * Copyright (C) 2017 Hubert Figuière
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+use libc::c_char;
+use std::ffi::CStr;
+use std::ffi::CString;
+
+use super::LibraryId;
+
+#[repr(i32)]
+#[derive(Clone)]
+pub enum VirtualType {
+ NONE = 0,
+ TRASH = 1
+}
+
+pub struct LibFolder {
+ id: LibraryId,
+ name: String,
+ locked: bool,
+ expanded: bool,
+ virt: VirtualType,
+ cstr: CString,
+}
+
+impl LibFolder {
+ pub fn new(id: LibraryId, name: &str) -> LibFolder {
+ LibFolder {
+ id: id, name: String::from(name), locked: false,
+ expanded: false, virt: VirtualType::NONE,
+ cstr: CString::new("").unwrap(),
+ }
+ }
+
+ pub fn id(&self) -> LibraryId {
+ self.id
+ }
+
+ pub fn name(&self) -> &String {
+ &self.name
+ }
+
+ pub fn locked(&self) -> bool {
+ self.locked
+ }
+
+ pub fn set_locked(&mut self, locked: bool) {
+ self.locked = locked;
+ }
+
+ pub fn expanded(&self) -> bool {
+ self.expanded
+ }
+
+ pub fn set_expanded(&mut self, expanded: bool) {
+ self.expanded = expanded;
+ }
+
+ pub fn virtual_type(&self) -> VirtualType {
+ self.virt.to_owned()
+ }
+
+ pub fn set_virtual_type(&mut self, virt: VirtualType) {
+ self.virt = virt;
+ }
+}
+
+#[no_mangle]
+pub extern fn engine_db_libfolder_new(id: i64, name: *const c_char) -> *mut LibFolder {
+ let lf = Box::new(LibFolder::new(id, &*unsafe { CStr::from_ptr(name) }.to_string_lossy()));
+ Box::into_raw(lf)
+}
+
+#[no_mangle]
+pub extern fn engine_db_libfolder_delete(lf: *mut LibFolder) {
+ unsafe { Box::from_raw(lf) };
+}
+
+#[no_mangle]
+pub extern fn engine_db_libfolder_id(this: &LibFolder) -> i64 {
+ this.id() as i64
+}
+
+#[no_mangle]
+pub extern fn engine_db_libfolder_name(this: &mut LibFolder) -> *const c_char {
+ this.cstr = CString::new(this.name().clone()).unwrap();
+ this.cstr.as_ptr()
+}
+
+#[no_mangle]
+pub extern fn engine_db_libfolder_virtual_type(this: &LibFolder) -> i32 {
+ this.virtual_type() as i32
+}
+
+#[no_mangle]
+pub extern fn engine_db_libfolder_expanded(this: &LibFolder) -> bool {
+ this.expanded
+}
+
+#[no_mangle]
+pub extern fn engine_db_libfolder_set_locked(this: &mut LibFolder, locked: bool) {
+ this.set_locked(locked);
+}
+
+#[no_mangle]
+pub extern fn engine_db_libfolder_set_expanded(this: &mut LibFolder, expanded: bool) {
+ this.set_expanded(expanded);
+}
+
+#[no_mangle]
+pub extern fn engine_db_libfolder_set_virtual_type(this: &mut LibFolder, t: i32) {
+ this.set_virtual_type(match t {
+ 0 => VirtualType::NONE,
+ 1 => VirtualType::TRASH,
+ _ => VirtualType::NONE,
+ });
+}
diff --git a/src/engine/db/library.cpp b/src/engine/db/library.cpp
index b55d8f2..5eefd97 100644
--- a/src/engine/db/library.cpp
+++ b/src/engine/db/library.cpp
@@ -137,7 +137,7 @@ bool Library::_initDb()
boost::format("insert into folders (name, locked, virtual, parent_id) "
" values ('%1%', 1, %2%, 0)")
% _("Trash")
- % int(LibFolder::VirtualType::TRASH));
+ % int(LibFolderVirtualType::TRASH));
SQLStatement fileTable("CREATE TABLE files (id INTEGER PRIMARY KEY,"
" main_file INTEGER, name TEXT, parent_id INTEGER,"
" orientation INTEGER, file_type INTEGER, "
@@ -342,12 +342,12 @@ library_id_t Library::addFileAndFolder(const std::string & folder,
const std::string & file,
Managed manage)
{
- LibFolder::Ptr f;
+ LibFolderPtr f;
f = getFolder(folder);
if(f == NULL) {
ERR_OUT("Folder %s not found", folder.c_str());
}
- return addFile(f ? f->id() : -1, file, manage);
+ return addFile(f ? engine_db_libfolder_id(f.get()) : -1, file, manage);
}
library_id_t Library::addBundle(library_id_t folder_id,
@@ -412,17 +412,17 @@ bool Library::addJpegFileToBundle(library_id_t file_id, library_id_t fsfile_id)
}
-LibFolder::Ptr Library::getFolder(const std::string & folder)
+LibFolderPtr Library::getFolder(const std::string & folder)
{
- LibFolder::Ptr f;
+ LibFolderPtr f;
SQLStatement sql(boost::format("SELECT %1% "
"FROM folders WHERE path='%2%'")
- % LibFolder::read_db_columns() % folder);
+ % libfolder_read_db_columns() % folder);
try {
if(m_dbdrv->execute_statement(sql)) {
if(m_dbdrv->read_next_row()) {
- f = LibFolder::read_from(m_dbdrv);
+ f = libfolder_read_from(m_dbdrv);
}
}
}
@@ -434,9 +434,9 @@ LibFolder::Ptr Library::getFolder(const std::string & folder)
}
-LibFolder::Ptr Library::addFolder(const std::string & folder)
+LibFolderPtr Library::addFolder(const std::string & folder)
{
- LibFolder::Ptr f;
+ LibFolderPtr f;
SQLStatement sql(boost::format("INSERT INTO folders "
"(path,name,vault_id,parent_id) "
"VALUES('%1%', '%2%', '0', '0')")
@@ -445,8 +445,7 @@ LibFolder::Ptr Library::addFolder(const std::string & folder)
if(m_dbdrv->execute_statement(sql)) {
library_id_t id = m_dbdrv->last_row_id();
DBG_OUT("last row inserted %Ld", (long long)id);
- f = LibFolder::Ptr(new LibFolder(id,
- fwk::path_basename(folder)));
+ f = libfolder_new(id, fwk::path_basename(folder).c_str());
}
}
catch(fwk::Exception & e)
@@ -457,14 +456,14 @@ LibFolder::Ptr Library::addFolder(const std::string & folder)
}
-void Library::getAllFolders(const LibFolder::ListPtr & l)
+void Library::getAllFolders(const LibFolderListPtr & l)
{
SQLStatement sql(boost::format("SELECT %1% FROM folders")
- % LibFolder::read_db_columns());
+ % libfolder_read_db_columns());
try {
if(m_dbdrv->execute_statement(sql)) {
while(m_dbdrv->read_next_row()) {
- LibFolder::Ptr f = LibFolder::read_from(m_dbdrv);
+ LibFolderPtr f = libfolder_read_from(m_dbdrv);
l->push_back(f);
}
}
diff --git a/src/engine/db/library.hpp b/src/engine/db/library.hpp
index 05068de..001dd02 100644
--- a/src/engine/db/library.hpp
+++ b/src/engine/db/library.hpp
@@ -129,16 +129,16 @@ public:
* @param folder the folder path to check
* @return the folder, NULL if not found
*/
- LibFolder::Ptr getFolder(const std::string & folder);
+ LibFolderPtr getFolder(const std::string & folder);
/** Add a folder
* @param folder the folder path
*/
- LibFolder::Ptr addFolder(const std::string & folder);
+ LibFolderPtr addFolder(const std::string & folder);
/** List all the folders.
* @param l the list of LibFolder
*/
- void getAllFolders(const LibFolder::ListPtr & l);
+ void getAllFolders(const LibFolderListPtr & l);
/** List the folder content
* @param folder_id id of the folder
diff --git a/src/engine/db/mod.rs b/src/engine/db/mod.rs
index ada2df1..28fabfe 100644
--- a/src/engine/db/mod.rs
+++ b/src/engine/db/mod.rs
@@ -17,33 +17,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-mod keyword;
+pub mod keyword;
+pub mod libfolder;
pub type LibraryId = i64;
-use self::keyword::Keyword;
-use libc::c_char;
-use std::ffi::CStr;
-use std::ffi::CString;
-
-#[no_mangle]
-pub extern fn engine_db_keyword_new(id: i64, keyword: *const c_char) -> *mut Keyword {
- let kw = Box::new(Keyword::new(id, &*unsafe { CStr::from_ptr(keyword) }.to_string_lossy()));
- Box::into_raw(kw)
-}
-
-#[no_mangle]
-pub extern fn engine_db_keyword_id(this: &Keyword) -> i64 {
- this.id() as i64
-}
-
-#[no_mangle]
-pub extern fn engine_db_keyword_keyword(this: &mut Keyword) -> *const c_char {
- this.cstr = CString::new(this.keyword().clone()).unwrap();
- this.cstr.as_ptr()
-}
-
-#[no_mangle]
-pub extern fn engine_db_keyword_delete(kw: *mut Keyword) {
- unsafe { Box::from_raw(kw) };
-}
diff --git a/src/engine/db/test_library.cpp b/src/engine/db/test_library.cpp
index 7b7c1e8..45be8bd 100644
--- a/src/engine/db/test_library.cpp
+++ b/src/engine/db/test_library.cpp
@@ -43,31 +43,32 @@ int test_main(int, char *[])
db::IConnectionDriver::Ptr db(lib.dbDriver());
- eng::LibFolder::Ptr folder_added(lib.addFolder("foo"));
+ eng::LibFolderPtr folder_added(lib.addFolder("foo"));
BOOST_CHECK(folder_added);
- BOOST_CHECK(folder_added->id() > 0);
- eng::LibFolder::Ptr f(lib.getFolder("foo"));
+ BOOST_CHECK(engine_db_libfolder_id(folder_added.get()) > 0);
+ eng::LibFolderPtr f(lib.getFolder("foo"));
BOOST_CHECK(f);
- BOOST_CHECK(f->id() == folder_added->id());
+ BOOST_CHECK(engine_db_libfolder_id(f.get()) == engine_db_libfolder_id(folder_added.get()));
lib.addFolder("bar");
BOOST_CHECK(lib.getFolder("bar"));
- eng::LibFolder::ListPtr l( new eng::LibFolder::List );
- lib.getAllFolders( l );
+ eng::LibFolderListPtr l(new eng::LibFolderList);
+ lib.getAllFolders(l);
// now we have the Trash folder created at startup
- BOOST_CHECK( l->size() == 3 );
+ BOOST_CHECK(l->size() == 3);
- int file_id = lib.addFile(folder_added->id(), "foo/myfile", eng::Library::Managed::NO);
+ int file_id = lib.addFile(engine_db_libfolder_id(folder_added.get()),
+ "foo/myfile", eng::Library::Managed::NO);
BOOST_CHECK(file_id > 0);
BOOST_CHECK(lib.moveFileToFolder(file_id, 100) == false);
- BOOST_CHECK(lib.moveFileToFolder(file_id, folder_added->id()));
+ BOOST_CHECK(lib.moveFileToFolder(file_id, engine_db_libfolder_id(folder_added.get())));
- int count = lib.countFolder(folder_added->id());
+ int count = lib.countFolder(engine_db_libfolder_id(folder_added.get()));
BOOST_CHECK(count == 1);
const eng::LibFile::ListPtr fl(new eng::LibFile::List);
- lib.getFolderContent(folder_added->id(), fl);
+ lib.getFolderContent(engine_db_libfolder_id(folder_added.get()), fl);
BOOST_CHECK(fl->size() == (size_t)count);
BOOST_CHECK(fl->front()->id() == file_id);
diff --git a/src/engine/library/commands.cpp b/src/engine/library/commands.cpp
index eb533cb..64c43c0 100644
--- a/src/engine/library/commands.cpp
+++ b/src/engine/library/commands.cpp
@@ -48,7 +48,7 @@ void Commands::cmdListAllKeywords(const Library::Ptr & lib)
void Commands::cmdListAllFolders(const Library::Ptr & lib)
{
- LibFolder::ListPtr l(new LibFolder::List);
+ LibFolderListPtr l(new LibFolderList);
lib->getAllFolders(l);
/////
// notify folder added l
@@ -67,14 +67,14 @@ void Commands::cmdImportFile(const Library::Ptr & lib,
std::string folder = fwk::path_dirname(file_path);
- LibFolder::Ptr pf = lib->getFolder(folder);
+ LibFolderPtr pf = lib->getFolder(folder);
if(!pf) {
pf = lib->addFolder(folder);
- LibFolder::ListPtr l(new LibFolder::List);
+ LibFolderListPtr l(new LibFolderList);
l->push_back(pf);
lib->notify(LibNotification::make<LibNotification::Type::ADDED_FOLDERS>({l}));
}
- lib->addBundle(pf->id(), bundle, manage);
+ lib->addBundle(engine_db_libfolder_id(pf.get()), bundle, manage);
lib->notify(LibNotification::make<LibNotification::Type::ADDED_FILES>({}));
}
@@ -87,16 +87,16 @@ void Commands::cmdImportFiles(const Library::Ptr & lib,
FileBundle::ListPtr bundles = FileBundle::filter_bundles(files);
- LibFolder::Ptr pf = lib->getFolder(folder);
+ LibFolderPtr pf = lib->getFolder(folder);
if(!pf) {
pf = lib->addFolder(folder);
- LibFolder::ListPtr l( new LibFolder::List );
+ LibFolderListPtr l( new LibFolderList );
l->push_back(pf);
lib->notify(LibNotification::make<LibNotification::Type::ADDED_FOLDERS>({l}));
}
std::for_each(bundles->begin(), bundles->end(),
[&lib, &pf, manage] (const auto& fb) {
- lib->addBundle(pf->id(), fb, manage);
+ lib->addBundle(engine_db_libfolder_id(pf.get()), fb, manage);
});
lib->notify(LibNotification::make<LibNotification::Type::ADDED_FILES>({}));
}
@@ -105,7 +105,7 @@ void Commands::cmdImportFiles(const Library::Ptr & lib,
void Commands::cmdQueryFolderContent(const Library::Ptr & lib,
library_id_t folder_id)
{
- LibFile::ListPtr fl(new LibFile::List());
+ LibFile::ListPtr fl(new LibFile::List);
lib->getFolderContent(folder_id, fl);
lib->notify(LibNotification::make<LibNotification::Type::FOLDER_CONTENT_QUERIED>(
{folder_id, fl}));
diff --git a/src/engine/library/notification.hpp b/src/engine/library/notification.hpp
index 7241dee..85fa8fa 100644
--- a/src/engine/library/notification.hpp
+++ b/src/engine/library/notification.hpp
@@ -57,7 +57,7 @@ public:
};
struct AddedFolders {
- LibFolder::ListPtr folders;
+ LibFolderListPtr folders;
};
struct AddedKeyword {
diff --git a/src/niepce/ui/workspacecontroller.cpp b/src/niepce/ui/workspacecontroller.cpp
index 5ab6874..0fe83bf 100644
--- a/src/niepce/ui/workspacecontroller.cpp
+++ b/src/niepce/ui/workspacecontroller.cpp
@@ -89,7 +89,7 @@ void WorkspaceController::on_lib_notification(const eng::LibNotification &ln)
auto l = ln.get<eng::LibNotification::Type::ADDED_FOLDERS>().folders;
DBG_OUT("received added folders # %lu", l->size());
for_each(l->cbegin(), l->cend(),
- [this] (const eng::LibFolder::Ptr& f) {
+ [this] (const eng::LibFolderPtr& f) {
this->add_folder_item(f);
});
break;
@@ -224,23 +224,24 @@ void WorkspaceController::add_keyword_item(const eng::KeywordPtr & k)
}
}
-void WorkspaceController::add_folder_item(const eng::LibFolder::Ptr & f)
+void WorkspaceController::add_folder_item(const eng::LibFolderPtr & f)
{
int icon_idx = ICON_ROLL;
- if(f->virtual_type() == eng::LibFolder::VirtualType::TRASH) {
+ if(engine_db_libfolder_virtual_type(f.get()) == (int32_t)eng::LibFolderVirtualType::TRASH) {
icon_idx = ICON_TRASH;
- getLibraryClient()->set_trash_id(f->id());
+ getLibraryClient()->set_trash_id(engine_db_libfolder_id(f.get()));
}
auto children = m_folderNode->children();
bool was_empty = children.empty();
auto iter = add_item(m_treestore, children,
m_icons[icon_idx],
- f->name(), f->id(), FOLDER_ITEM);
- if(f->is_expanded()) {
+ engine_db_libfolder_name(f.get()),
+ engine_db_libfolder_id(f.get()), FOLDER_ITEM);
+ if(engine_db_libfolder_expanded(f.get())) {
m_librarytree.expand_row(m_treestore->get_path(iter), false);
}
- getLibraryClient()->countFolder(f->id());
- m_folderidmap[f->id()] = iter;
+ getLibraryClient()->countFolder(engine_db_libfolder_id(f.get()));
+ m_folderidmap[engine_db_libfolder_id(f.get())] = iter;
// expand if needed. Because Gtk is stupid and doesn't expand empty
if(was_empty) {
expand_from_cfg("workspace_folders_expanded", m_folderNode);
diff --git a/src/niepce/ui/workspacecontroller.hpp b/src/niepce/ui/workspacecontroller.hpp
index 6b2e033..3430a6f 100644
--- a/src/niepce/ui/workspacecontroller.hpp
+++ b/src/niepce/ui/workspacecontroller.hpp
@@ -98,7 +98,7 @@ private:
fwk::Configuration::Ptr getLibraryConfig() const;
/** add a folder item to the treeview */
- void add_folder_item(const eng::LibFolder::Ptr & f);
+ void add_folder_item(const eng::LibFolderPtr & f);
/** add a keyword item to the treeview */
void add_keyword_item(const eng::KeywordPtr & k);
/** add a tree item in the treeview
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]