File indexing completed on 2024-05-19 05:08:12

0001 /*
0002     SPDX-FileCopyrightText: 2008 Thomas Baumgart <tbaumgart@kde.org>
0003     SPDX-FileCopyrightText: 2017 Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "kloadtemplatedlg.h"
0008 
0009 // ----------------------------------------------------------------------------
0010 // QT Includes
0011 
0012 #include <QList>
0013 
0014 // ----------------------------------------------------------------------------
0015 // KDE Includes
0016 
0017 // ----------------------------------------------------------------------------
0018 // Project Includes
0019 
0020 #include "ui_kloadtemplatedlg.h"
0021 
0022 #include "mymoneytemplate.h"
0023 #include "kaccounttemplateselector.h"
0024 #include "templateloader.h"
0025 
0026 class KLoadTemplateDlgPrivate
0027 {
0028     Q_DISABLE_COPY_MOVE(KLoadTemplateDlgPrivate)
0029 
0030 public:
0031     KLoadTemplateDlgPrivate()
0032         : ui(new Ui::KLoadTemplateDlg)
0033     {}
0034 
0035     Ui::KLoadTemplateDlg* ui;
0036     TemplatesModel        model;
0037     TemplateLoader        loader;
0038 };
0039 
0040 KLoadTemplateDlg::KLoadTemplateDlg(QWidget* parent) :
0041     QDialog(parent),
0042     d_ptr(new KLoadTemplateDlgPrivate)
0043 {
0044     Q_D(KLoadTemplateDlg);
0045     d->ui->setupUi(this);
0046     connect(d->ui->buttonBox, &QDialogButtonBox::helpRequested, this, &KLoadTemplateDlg::slotHelp);
0047 
0048     d->loader.load(&d->model);
0049     d->ui->m_templateSelector->setModel(&d->model);
0050 
0051     connect(&d->loader, &TemplateLoader::loadingFinished, d->ui->m_templateSelector, &KAccountTemplateSelector::setupInitialSelection);
0052 }
0053 
0054 KLoadTemplateDlg::~KLoadTemplateDlg()
0055 {
0056     Q_D(KLoadTemplateDlg);
0057     delete d;
0058 }
0059 
0060 QList<MyMoneyTemplate> KLoadTemplateDlg::templates() const
0061 {
0062     Q_D(const KLoadTemplateDlg);
0063     return d->ui->m_templateSelector->selectedTemplates();
0064 }
0065 
0066 void KLoadTemplateDlg::slotHelp()
0067 {
0068 }