provide genericbasictable through meta system

work/spdx
Michail Vourlakos 4 years ago
parent 55018eae0d
commit 2b1464fb1b

@ -24,6 +24,7 @@ add_subdirectory(settings/exporttemplatedialog/delegates)
add_subdirectory(settings/settingsdialog)
add_subdirectory(settings/settingsdialog/delegates)
add_subdirectory(settings/viewsdialog)
add_subdirectory(settings/viewsdialog/delegates)
add_subdirectory(shortcuts)
add_subdirectory(templates)
add_subdirectory(tools)

@ -2,6 +2,7 @@ set(lattedock-app_SRCS
${lattedock-app_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/activitydata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/appletdata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/genericbasictable.cpp
${CMAKE_CURRENT_SOURCE_DIR}/genericdata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/generictable.cpp
${CMAKE_CURRENT_SOURCE_DIR}/layoutdata.cpp

@ -0,0 +1,42 @@
/*
* 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 "genericbasictable.h"
namespace Latte {
namespace Data {
GenericBasicTable::GenericBasicTable()
: GenericTable<Generic>()
{
}
GenericBasicTable::GenericBasicTable(GenericBasicTable &&o)
: GenericTable<Generic>(o)
{
}
GenericBasicTable::GenericBasicTable(const GenericBasicTable &o)
: GenericTable<Generic>(o)
{
}
}
}

@ -0,0 +1,48 @@
/*
* 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 GENERICBASICTABLE_H
#define GENERICBASICTABLE_H
// local
#include "genericdata.h"
#include "generictable.h"
// Qt
#include <QMetaType>
namespace Latte {
namespace Data {
class GenericBasicTable : public GenericTable<Generic>
{
public:
GenericBasicTable();
GenericBasicTable(GenericBasicTable &&o);
GenericBasicTable(const GenericBasicTable &o);
};
}
}
Q_DECLARE_METATYPE(Latte::Data::Generic)
Q_DECLARE_METATYPE(Latte::Data::GenericBasicTable)
#endif

@ -23,10 +23,6 @@
namespace Latte {
namespace Data {
Generic::Generic()
{
}
Generic::Generic(Generic &&o)
: id(o.id),
name(o.name)

@ -21,7 +21,10 @@
#ifndef GENERICDATA_H
#define GENERICDATA_H
//! Qt
// local
#include "generictable.h"
// Qt
#include <QString>
namespace Latte {
@ -30,7 +33,7 @@ namespace Data {
class Generic
{
public:
Generic();
Generic() = default;
Generic(Generic &&o);
Generic(const Generic &o);
@ -48,4 +51,6 @@ public:
}
}
#endif

@ -30,7 +30,7 @@
namespace Latte {
namespace Data {
template <class T = Generic>
template <class T>
class GenericTable
{

@ -64,5 +64,6 @@ typedef GenericTable<Screen> ScreensTable;
}
Q_DECLARE_METATYPE(Latte::Data::Screen)
Q_DECLARE_METATYPE(Latte::Data::ScreensTable)
#endif

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

@ -0,0 +1,70 @@
/*
* 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 "singleoptiondelegate.h"
// local
#include "../viewsmodel.h"
#include "../../../data/genericbasictable.h"
// Qt
#include <QMenu>
#include <QPushButton>
namespace Latte {
namespace Settings {
namespace View {
namespace Delegate {
SingleOption::SingleOption(QObject *parent)
: QStyledItemDelegate(parent)
{
}
QWidget *SingleOption::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QPushButton *button = new QPushButton(parent);
QMenu *menu = new QMenu(button);
button->setMenu(menu);
menu->setMinimumWidth(option.rect.width());
bool isViewActive = index.data(Model::Views::ISACTIVEROLE).toBool();
QString currentChoice = index.data(Qt::UserRole).toString();
Latte::Data::GenericBasicTable choices = index.data(Model::Views::CHOICESROLE).value<Latte::Data::GenericBasicTable>();
for (int i=0; i<choices.rowCount(); ++i) {
QAction *action = new QAction(choices[i].name);
action->setData(choices[i].id);
if (choices[i].id == currentChoice) {
action->setIcon(QIcon::fromTheme("dialog-yes"));
}
menu->addAction(action);
}
return button;
}
}
}
}
}

@ -0,0 +1,59 @@
/*
* 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 SINGLEOPTIONDELEGATE_H
#define SINGLEOPTIONDELEGATE_H
// local
#include "../../../data/genericdata.h"
// Qt
#include <QMenu>
#include <QStyledItemDelegate>
class QModelIndex;
class QWidget;
class QVariant;
namespace Latte {
namespace Settings {
namespace View {
namespace Delegate {
class SingleOption : public QStyledItemDelegate
{
Q_OBJECT
public:
SingleOption(QObject *parent);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
// void setEditorData(QWidget *editor, const QModelIndex &index) const override;
// void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
// void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
//void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
// virtual bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override;
};
}
}
}
}
#endif

@ -55,9 +55,7 @@ public:
IDROLE = Qt::UserRole + 1,
NAMEROLE,
ISACTIVEROLE,
SCREENSLISTROLE,
EDGESLISTROLE,
SUBCONTAINMENTSIDSROLE,
CHOICESROLE,
SORTINGROLE
};

Loading…
Cancel
Save