kylin-tablet-desktop-general/kylin-tablet-desktop-backend/types.h

157 lines
4.0 KiB
C++

/*
* Copyright 2022 KylinSoft Co., Ltd.
*
* This program 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 3 of the License, or (at your option) any later
* version.
*
* This program 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 <https://www.gnu.org/licenses/>.
*/
#ifndef TYPES_H
#define TYPES_H
#include <QtGlobal>
#include <QRect>
#include <QString>
#include <QList>
#include <QDebug>
namespace UKUI {
enum class Categories {
Android = 0, // 0 安卓
Network, // 1 网络
Messaging, // 2 社交
Audio, // 3 影音
Development, // 4 开发
Graphics, // 5 图像
Game, // 6 游戏
Office, // 7 办公
Education, // 8 教育
System, // 9 系统
Other // 10 其他
};
enum class Type {
Icon = 1,
Group,
Container,
Widget,
Unknown
};
class BaseItem {
public:
BaseItem(QString name, qint32 id, QList<int> categories = {-1}, Type type = Type::Unknown, QList<int> placeholder = {1,1}) :
m_name(name), m_identify(id), m_type(type), m_placeholder(placeholder), m_categories(categories) {}
virtual ~BaseItem() {}
void setName(QString name) {
m_name = name;
}
QString getName() {
return m_name;
}
void setId(qint32 id) {
m_identify = id;
}
quint32 getId() {
return m_identify;
}
void setType(Type type) {
m_type = type;
}
Type getType() {
return m_type;
}
void setPlaceHolder(QList<int> place) {
m_placeholder = place;
}
QList<int> getPlaceHolder() {
return m_placeholder;
}
void setCategories(QList<int> categories) {
m_categories = categories;
}
QList<int> getCategories() {
return m_categories;
}
private:
QString m_name;
quint32 m_identify;
Type m_type;
QList<int> m_placeholder;
QList<int> m_categories;
};
class IconItem : public BaseItem
{
public:
IconItem(QString desktopName, QString name, qint32 id, QString iconName, QList<int> categories, Type type = Type::Icon) :
BaseItem(name, id, categories, type), m_desktopName(desktopName), m_icon(iconName) {}
~IconItem() {}
QString getDesktopName() {
return m_desktopName;
}
const QString getIconName() {
return m_icon;
}
void setIconName(QString name) {
m_icon = name;
}
private:
QString m_desktopName;
QString m_icon;
};
class Widget : public BaseItem
{
public:
Widget(QString name, qint32 id, QList<int> placeholder, Type type = Type::Widget) :
BaseItem(name, id, {-1}, type, placeholder) {}
~Widget() {}
};
class GroupItem : public BaseItem
{
public:
GroupItem(QString name, qint32 id, Type type = Type::Group, bool isScrollable = false) :
BaseItem(name, id, {-1}, type) {}
bool isScrollLayout() {
return isScrollable;
}
void setScrollLayout(bool scroll) {
isScrollable = scroll;
}
~GroupItem() {}
private:
bool isScrollable;
};
class ContainerItem : public BaseItem
{
public:
ContainerItem(QString name, qint32 id, QList<int> placeholder = {2,2}, Type type = Type::Container, bool isScrollable = false) :
BaseItem(name, id, {-1}, type, placeholder) {}
~ContainerItem() {}
bool isScrollLayout() {
return isScrollable;
}
void setScrollLayout(bool scroll) {
isScrollable = scroll;
}
private:
bool isScrollable;
};
}
#endif // TYPES_H