Commit d26810c9 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Modernize API of make_actions_from_data()

Use a std::vector instead of a C array and template magic.

GnuPG-bug-id: 5688
parent b22938a6
......@@ -417,7 +417,7 @@ void MainWindow::Private::setupActions()
KActionCollection *const coll = q->actionCollection();
const action_data action_data[] = {
const std::vector<action_data> action_data = {
// most have been MOVED TO keylistcontroller.cpp
// Tools menu
#ifndef Q_OS_WIN
......@@ -466,7 +466,7 @@ void MainWindow::Private::setupActions()
// most have been MOVED TO keylistcontroller.cpp
};
make_actions_from_data(action_data, /*sizeof action_data / sizeof *action_data,*/ coll);
make_actions_from_data(action_data, coll);
if (!Settings().groupsEnabled()) {
if (auto action = coll->action(QStringLiteral("configure_groups"))) {
......
......@@ -51,9 +51,9 @@ QAction *Kleo::make_action_from_data(const action_data &ad, KActionCollection *c
return a;
}
void Kleo::make_actions_from_data(const action_data *ads, unsigned int size, KActionCollection *coll)
void Kleo::make_actions_from_data(const std::vector<action_data> &data, KActionCollection *coll)
{
for (unsigned int i = 0; i < size; ++i) {
coll->addAction(QLatin1String(ads[i].name), make_action_from_data(ads[i], coll));
for (const auto &actionData : data) {
coll->addAction(QLatin1String(actionData.name), make_action_from_data(actionData, coll));
}
}
......@@ -30,13 +30,7 @@ struct action_data {
bool enabled;
};
void make_actions_from_data(const action_data *data, unsigned int numData, KActionCollection *collection);
template <unsigned int N>
inline void make_actions_from_data(const action_data(&data)[N], KActionCollection *collection)
{
make_actions_from_data(data, N, collection);
}
void make_actions_from_data(const std::vector<action_data> &data, KActionCollection *collection);
QAction *make_action_from_data(const action_data &ad, KActionCollection *coll);
QAction *createAction(const action_data &ad, KActionCollection *coll);
......
......@@ -344,7 +344,7 @@ TabWidget *KeyListController::tabWidget() const
void KeyListController::createActions(KActionCollection *coll)
{
const action_data action_data[] = {
const std::vector<action_data> action_data = {
// File menu
{
"file_new_certificate", i18n("New Key Pair..."), QString(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment