provide basic implementation of ExportTemplateDlg
parent
0943ecb42e
commit
a45b97a2b1
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2021 Michail Vourlakos <mvourlakos@gmail.com>
|
||||
*
|
||||
* This file is part of Latte-Dock
|
||||
*
|
||||
* Latte-Dock is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Latte-Dock is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "exporttemplatehandler.h"
|
||||
|
||||
// local
|
||||
#include "ui_exporttemplatedialog.h"
|
||||
#include "../controllers/layoutscontroller.h"
|
||||
#include "../dialogs/exporttemplatedialog.h"
|
||||
#include "../models/appletsmodel.h"
|
||||
#include "../../data/appletdata.h"
|
||||
#include "../../layouts/storage.h"
|
||||
|
||||
namespace Latte {
|
||||
namespace Settings {
|
||||
namespace Handler {
|
||||
|
||||
ExportTemplateHandler::ExportTemplateHandler(Dialog::ExportTemplateDialog *parentDialog)
|
||||
: Generic(parentDialog),
|
||||
m_parentDialog(parentDialog),
|
||||
m_ui(m_parentDialog->ui()),
|
||||
m_appletsModel(new Model::Applets(this, parentDialog->corona()))
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
ExportTemplateHandler::~ExportTemplateHandler()
|
||||
{
|
||||
}
|
||||
|
||||
void ExportTemplateHandler::init()
|
||||
{
|
||||
//! Layouts
|
||||
m_appletsProxyModel = new QSortFilterProxyModel(this);
|
||||
m_appletsProxyModel->setSourceModel(m_appletsModel);
|
||||
m_appletsProxyModel->setSortRole(Model::Applets::SORTINGROLE);
|
||||
m_appletsProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
m_appletsProxyModel->sort(Model::Applets::NAMECOLUMN, Qt::AscendingOrder);
|
||||
|
||||
m_ui->appletsTable->setModel(m_appletsProxyModel);
|
||||
|
||||
loadCurrentLayoutApplets();
|
||||
}
|
||||
|
||||
void ExportTemplateHandler::loadCurrentLayoutApplets()
|
||||
{
|
||||
Data::Layout o_layout = m_parentDialog->layoutsController()->selectedLayoutOriginalData();
|
||||
c_data = Latte::Layouts::Storage::self()->plugins(o_layout.id);
|
||||
o_data = c_data;
|
||||
|
||||
m_appletsModel->setData(c_data);
|
||||
}
|
||||
|
||||
bool ExportTemplateHandler::dataAreChanged() const
|
||||
{
|
||||
return o_data != c_data;
|
||||
}
|
||||
|
||||
bool ExportTemplateHandler::inDefaultValues() const
|
||||
{
|
||||
//nothing special
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ExportTemplateHandler::reset()
|
||||
{
|
||||
c_data = o_data;
|
||||
}
|
||||
|
||||
void ExportTemplateHandler::resetDefaults()
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
|
||||
void ExportTemplateHandler::save()
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2021 Michail Vourlakos <mvourlakos@gmail.com>
|
||||
*
|
||||
* This file is part of Latte-Dock
|
||||
*
|
||||
* Latte-Dock is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Latte-Dock is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EXPORTTEMPLATEHANDLER_H
|
||||
#define EXPORTTEMPLATEHANDLER_H
|
||||
|
||||
// local
|
||||
#include "generichandler.h"
|
||||
#include "../../data/appletdata.h"
|
||||
|
||||
// Qt
|
||||
#include <QButtonGroup>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
namespace Ui {
|
||||
class ExportTemplateDialog;
|
||||
}
|
||||
|
||||
namespace Latte{
|
||||
namespace Settings{
|
||||
namespace Dialog{
|
||||
class ExportTemplateDialog;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Latte{
|
||||
namespace Settings{
|
||||
namespace Model {
|
||||
class Applets;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace Latte {
|
||||
namespace Settings {
|
||||
namespace Handler {
|
||||
|
||||
//! Handlers are objects to handle the UI elements that semantically associate with specific
|
||||
//! ui::tabs or different windows. They are responsible also to handle the user interaction
|
||||
//! between controllers and views
|
||||
|
||||
class ExportTemplateHandler : public Generic
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ExportTemplateHandler(Dialog::ExportTemplateDialog *parentDialog);
|
||||
~ExportTemplateHandler();
|
||||
|
||||
bool dataAreChanged() const override;
|
||||
bool inDefaultValues() const override;
|
||||
|
||||
void reset() override;
|
||||
void resetDefaults() override;
|
||||
void save() override;
|
||||
|
||||
Latte::Data::AppletsTable currentData() const;
|
||||
|
||||
private:
|
||||
void init();
|
||||
void loadCurrentLayoutApplets();
|
||||
|
||||
private:
|
||||
Dialog::ExportTemplateDialog *m_parentDialog{nullptr};
|
||||
Ui::ExportTemplateDialog *m_ui{nullptr};
|
||||
|
||||
//! current data
|
||||
Model::Applets *m_appletsModel{nullptr};
|
||||
QSortFilterProxyModel *m_appletsProxyModel{nullptr};
|
||||
|
||||
Latte::Data::AppletsTable o_data;
|
||||
Latte::Data::AppletsTable c_data;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue