provide genericbasictable through meta system
parent
55018eae0d
commit
2b1464fb1b
@ -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
|
@ -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
|
Loading…
Reference in New Issue