'Refresh Libraries' feature in File menu, new GSI method Library#refresh_all (static)

This commit is contained in:
Matthias Koefferlein 2025-10-11 21:14:56 +02:00
parent 5625fb95dd
commit 67de518611
6 changed files with 36 additions and 0 deletions

View File

@ -248,6 +248,16 @@ LibraryManager::lib_internal (lib_id_type id) const
}
}
void
LibraryManager::refresh_all ()
{
for (std::vector<Library *>::iterator l = m_libs.begin (); l != m_libs.end (); ++l) {
if (*l) {
(*l)->refresh ();
}
}
}
void
LibraryManager::clear ()
{

View File

@ -212,6 +212,11 @@ public:
*/
void clear ();
/**
* @brief Refreshes all libraries
*/
void refresh_all ();
private:
std::vector<Library *> m_libs;
lib_name_map m_lib_by_name;

View File

@ -65,6 +65,11 @@ static std::vector<db::lib_id_type> library_ids ()
return r;
}
static void refresh_all ()
{
db::LibraryManager::instance ().refresh_all ();
}
static void register_lib (db::Library *lib, const std::string &name)
{
lib->set_name (name);
@ -184,6 +189,11 @@ LibraryClass<db::Library> decl_Library ("db", "LibraryBase",
"\n"
"This method has been introduced in version 0.27."
) +
gsi::method ("refresh_all", &refresh_all,
"@brief Calls \\refresh on all libraries.\n"
"\n"
"This convenience method has been introduced in version 0.30.4."
) +
gsi::method_ext ("register", &register_lib, gsi::arg ("name"),
"@brief Registers the library with the given name\n"
"\n"

View File

@ -73,6 +73,7 @@ static const char *cm_symbols[] = {
"cm_save",
"cm_save_all",
"cm_reload",
"cm_refresh",
"cm_close",
"cm_close_all",
"cm_clone",

View File

@ -2555,6 +2555,12 @@ MainWindow::cm_writer_options ()
mp_layout_save_options->edit_global_options (dispatcher (), db::Technologies::instance ());
}
void
MainWindow::cm_refresh ()
{
db::LibraryManager::instance ().refresh_all ();
}
void
MainWindow::cm_new_panel ()
{
@ -4036,6 +4042,8 @@ MainWindow::menu_activated (const std::string &symbol)
cm_reader_options ();
} else if (symbol == "cm_writer_options") {
cm_writer_options ();
} else if (symbol == "cm_refresh") {
cm_refresh ();
} else if (symbol == "cm_new_panel") {
cm_new_panel ();
} else if (symbol == "cm_new_layout") {
@ -4449,6 +4457,7 @@ public:
menu_entries.push_back (lay::menu_item ("cm_close_all", "close_all:edit", at, tl::to_string (QObject::tr ("Close All(Shift+Ctrl+W)"))));
menu_entries.push_back (lay::menu_item ("cm_clone", "clone", at, tl::to_string (QObject::tr ("Clone Panel"))));
menu_entries.push_back (lay::menu_item ("cm_reload", "reload:edit", at, tl::to_string (QObject::tr ("Reload(Ctrl+R)"))));
menu_entries.push_back (lay::menu_item ("cm_refresh", "refresh:edit", at, tl::to_string (QObject::tr ("Refresh Libraries"))));
menu_entries.push_back (lay::menu_item ("cm_pull_in", "pull_in:edit", at, tl::to_string (QObject::tr ("Pull In Other Layout"))));
menu_entries.push_back (lay::menu_item ("cm_reader_options", "reader_options", at, tl::to_string (QObject::tr ("Reader Options"))));
menu_entries.push_back (lay::separator ("open_recent_group", at));

View File

@ -837,6 +837,7 @@ private:
void cm_pull_in ();
void cm_reader_options ();
void cm_writer_options ();
void cm_refresh ();
void cm_new_panel ();
void cm_new_layout ();
void cm_clone ();