Commit b8eda868 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Got rid of friend declaration to static template function

Made the function a private member instead.

Reviewed-by: ossi
parent 35be3a3b
......@@ -34,7 +34,6 @@
#include "quickopentoolwindow.h"
#include "opendocumentsfilter.h"
#include "filesystemfilter.h"
#include "directoryfilter.h"
#include "settingspage.h"
#include <QtCore/QSettings>
......@@ -144,39 +143,6 @@ void QuickOpenPlugin::startSettingsLoad()
connect(&m_loadWatcher, SIGNAL(finished()), this, SLOT(settingsLoaded()));
}
namespace QuickOpen {
namespace Internal {
template <typename S>
static void loadSettingsHelper(QuickOpenPlugin *p, S *settings)
{
settings->beginGroup("QuickOpen");
p->m_refreshTimer.setInterval(settings->value("RefreshInterval", 60).toInt() * 60000);
foreach (IQuickOpenFilter *filter, p->m_filters) {
if (settings->contains(filter->name())) {
const QByteArray state = settings->value(filter->name()).toByteArray();
if (!state.isEmpty())
filter->restoreState(state);
}
}
settings->beginGroup("CustomFilters");
QList<IQuickOpenFilter *> customFilters;
const QStringList keys = settings->childKeys();
foreach (const QString &key, keys) {
IQuickOpenFilter *filter = new DirectoryFilter;
filter->restoreState(settings->value(key).toByteArray());
p->m_filters.append(filter);
customFilters.append(filter);
}
p->setCustomFilters(customFilters);
settings->endGroup();
settings->endGroup();
}
} // namespace Internal
} // namespace QuickOpen
void QuickOpenPlugin::loadSettings()
{
Core::ICore *core = Core::ICore::instance();
......@@ -184,10 +150,10 @@ void QuickOpenPlugin::loadSettings()
// Backwards compatibility to old settings location
if (qs->contains("QuickOpen/FiltersFilter")) {
loadSettingsHelper(this, qs);
loadSettingsHelper(qs);
} else {
Core::SettingsDatabase *settings = core->settingsDatabase();
loadSettingsHelper(this, settings);
loadSettingsHelper(settings);
}
qs->remove("QuickOpen");
......
......@@ -31,6 +31,7 @@
#define QUICKOPENPLUGIN_H
#include "iquickopenfilter.h"
#include "directoryfilter.h"
#include <extensionsystem/iplugin.h>
......@@ -45,6 +46,7 @@ class QuickOpenToolWindow;
class OpenDocumentsFilter;
class FileSystemFilter;
class SettingsPage;
class QuickOpenPlugin;
class QuickOpenPlugin : public ExtensionSystem::IPlugin
{
......@@ -76,6 +78,9 @@ private slots:
private:
void loadSettings();
template <typename S>
void loadSettingsHelper(S *settings);
QuickOpenToolWindow *m_quickOpenToolWindow;
SettingsPage *m_settingsPage;
......@@ -86,11 +91,35 @@ private:
OpenDocumentsFilter *m_openDocumentsFilter;
FileSystemFilter *m_fileSystemFilter;
QFutureWatcher<void> m_loadWatcher;
template <typename S>
friend static void loadSettingsHelper(QuickOpenPlugin *p, S *settings);
};
template <typename S>
void QuickOpenPlugin::loadSettingsHelper(S *settings)
{
settings->beginGroup("QuickOpen");
m_refreshTimer.setInterval(settings->value("RefreshInterval", 60).toInt() * 60000);
foreach (IQuickOpenFilter *filter, m_filters) {
if (settings->contains(filter->name())) {
const QByteArray state = settings->value(filter->name()).toByteArray();
if (!state.isEmpty())
filter->restoreState(state);
}
}
settings->beginGroup("CustomFilters");
QList<IQuickOpenFilter *> customFilters;
const QStringList keys = settings->childKeys();
foreach (const QString &key, keys) {
IQuickOpenFilter *filter = new DirectoryFilter;
filter->restoreState(settings->value(key).toByteArray());
m_filters.append(filter);
customFilters.append(filter);
}
setCustomFilters(customFilters);
settings->endGroup();
settings->endGroup();
}
} // namespace Internal
} // namespace QuickOpen
......
Supports Markdown
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