VcsBase: Move some private pieces off vcsplugin.h

By themselves not worth a pimpl, but since we have one already...

Change-Id: I867e68c5e82f71ebbe16a55eb190d87f981a550b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2023-05-08 13:38:30 +02:00
parent aa8a76c357
commit 6f253b0694
2 changed files with 39 additions and 34 deletions

View File

@@ -32,12 +32,45 @@ using namespace Core;
using namespace ProjectExplorer;
using namespace Utils;
namespace VcsBase {
namespace Internal {
namespace VcsBase::Internal {
class VcsPluginPrivate
{
public:
explicit VcsPluginPrivate(VcsPlugin *plugin)
: q(plugin)
{
QObject::connect(&m_settingsPage, &CommonOptionsPage::settingsChanged,
[this] { slotSettingsChanged(); });
slotSettingsChanged();
}
QStandardItemModel *nickNameModel()
{
if (!m_nickNameModel) {
m_nickNameModel = NickNameDialog::createModel(q);
populateNickNameModel();
}
return m_nickNameModel;
}
void populateNickNameModel()
{
QString errorMessage;
if (!NickNameDialog::populateModelFromMailCapFile(m_settingsPage.settings().nickNameMailMap.filePath(),
m_nickNameModel,
&errorMessage)) {
qWarning("%s", qPrintable(errorMessage));
}
}
void slotSettingsChanged()
{
if (m_nickNameModel)
populateNickNameModel();
}
VcsPlugin *q;
CommonOptionsPage m_settingsPage;
QStandardItemModel *m_nickNameModel = nullptr;
};
@@ -59,7 +92,7 @@ VcsPlugin::~VcsPlugin()
void VcsPlugin::initialize()
{
d = new VcsPluginPrivate;
d = new VcsPluginPrivate(this);
EditorManager::addCloseEditorListener([this](IEditor *editor) -> bool {
bool result = true;
@@ -70,9 +103,6 @@ void VcsPlugin::initialize()
connect(&d->m_settingsPage, &CommonOptionsPage::settingsChanged,
this, &VcsPlugin::settingsChanged);
connect(&d->m_settingsPage, &CommonOptionsPage::settingsChanged,
this, &VcsPlugin::slotSettingsChanged);
slotSettingsChanged();
JsonWizardFactory::registerPageFactory(new Internal::VcsConfigurationPageFactory);
JsonWizardFactory::registerPageFactory(new Internal::VcsCommandPageFactory);
@@ -124,28 +154,8 @@ CommonVcsSettings &VcsPlugin::settings() const
/* Delayed creation/update of the nick name model. */
QStandardItemModel *VcsPlugin::nickNameModel()
{
if (!d->m_nickNameModel) {
d->m_nickNameModel = NickNameDialog::createModel(this);
populateNickNameModel();
}
return d->m_nickNameModel;
QTC_ASSERT(d, return nullptr);
return d->nickNameModel();
}
void VcsPlugin::populateNickNameModel()
{
QString errorMessage;
if (!NickNameDialog::populateModelFromMailCapFile(settings().nickNameMailMap.filePath(),
d->m_nickNameModel,
&errorMessage)) {
qWarning("%s", qPrintable(errorMessage));
}
}
void VcsPlugin::slotSettingsChanged()
{
if (d->m_nickNameModel)
populateNickNameModel();
}
} // namespace Internal
} // namespace VcsBase
} // VcsBase::Internal