introduce layouts controller for MVC approach

--the new controller will take all functionality
from Layouts model that is currently found in settings
window and that way the settings window will be
simplified and is going to be responsible only for
the UI elements of the window and NOT the QTableView
internals
pull/11/head
Michail Vourlakos 5 years ago
parent 6ff1102e1f
commit c6e8f6f032

@ -14,6 +14,7 @@ add_subdirectory(layouts)
add_subdirectory(package)
add_subdirectory(plasma/extended)
add_subdirectory(settings)
add_subdirectory(settings/controllers)
add_subdirectory(settings/data)
add_subdirectory(settings/delegates)
add_subdirectory(settings/models)

@ -0,0 +1,5 @@
set(lattedock-app_SRCS
${lattedock-app_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/layoutscontroller.cpp
PARENT_SCOPE
)

@ -0,0 +1,42 @@
/*
* Copyright 2020 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 "layoutscontroller.h"
namespace Latte {
namespace Settings {
namespace Controller {
Layouts::Layouts(QObject *parent, Latte::Corona *corona)
: QObject(parent),
m_corona(corona),
m_model(new Model::Layouts(this, corona))
{
}
Model::Layouts *Layouts::model() const
{
return m_model;
}
}
}
}

@ -0,0 +1,51 @@
/*
* Copyright 2020 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 SETTINGSLAYOUTSCONTROLLER_H
#define SETTINGSLAYOUTSCONTROLLER_H
// local
#include "../models/layoutsmodel.h"
#include "../../lattecorona.h"
namespace Latte {
namespace Settings {
namespace Controller {
class Layouts : public QObject
{
Q_OBJECT
public:
explicit Layouts(QObject *parent, Latte::Corona *corona);
Model::Layouts *model() const;
private:
Latte::Corona *m_corona{nullptr};
Model::Layouts *m_model{nullptr};
};
}
}
}
#endif

@ -101,9 +101,10 @@ SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona)
connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked
, this, &SettingsDialog::restoreDefaults);
m_model = new Settings::Model::Layouts(this, m_corona);
m_layoutsController = new Settings::Controller::Layouts(this, m_corona);
m_model = m_layoutsController->model();
ui->layoutsView->setModel(m_model);
ui->layoutsView->setModel(m_layoutsController->model());
ui->layoutsView->horizontalHeader()->setStretchLastSection(true);
ui->layoutsView->verticalHeader()->setVisible(false);

@ -26,6 +26,7 @@
#include "../liblatte2/types.h"
#include "data/layoutstable.h"
#include "models/layoutsmodel.h"
#include "controllers/layoutscontroller.h"
// Qt
#include <QObject>
@ -158,6 +159,7 @@ private:
//QStandardItemModel *m_model{nullptr};
Settings::Model::Layouts *m_model{nullptr};
Settings::Controller::Layouts *m_layoutsController{nullptr};
Ui::SettingsDialog *ui;
//! SharedLayout #settingsid, Shares #settingsid

Loading…
Cancel
Save