Port to declarative type registration

This commit is contained in:
Tobias Fella
2023-09-23 14:05:50 +00:00
parent 4ed4f3f628
commit 3a4f71de7f
202 changed files with 604 additions and 532 deletions

View File

@@ -9,6 +9,7 @@
#include <QCoroTask>
#include <QObject>
#include <QPointer>
#include <QQmlEngine>
#include <QVector>
#include <Quotient/connection.h>
@@ -23,6 +24,8 @@
class AccountEmoticonModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The connection to get emoticons from.
*/

View File

@@ -4,6 +4,7 @@
#pragma once
#include <QConcatenateTablesProxyModel>
#include <QQmlEngine>
#include <QSortFilterProxyModel>
#include "roomlistmodel.h"
@@ -24,6 +25,7 @@ class RoomListModel;
class CompletionModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The current text to search for completions.

View File

@@ -4,6 +4,7 @@
#pragma once
#include <QAbstractListModel>
#include <QQmlEngine>
#include <QRegularExpression>
#include <memory>
@@ -27,6 +28,8 @@ struct CustomEmoji {
class CustomEmojiModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
public:
/**
@@ -48,6 +51,10 @@ public:
static CustomEmojiModel _instance;
return _instance;
}
static CustomEmojiModel *create(QQmlEngine *, QJSEngine *)
{
return &instance();
}
/**
* @brief Get the given role value at the given index.

View File

@@ -5,6 +5,7 @@
#include <QAbstractListModel>
#include <QPointer>
#include <QQmlEngine>
#include <Quotient/csapi/definitions/client_device.h>
@@ -25,6 +26,7 @@ class Connection;
class DevicesModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The current connection that the model is getting its devices from.

View File

@@ -3,11 +3,14 @@
#pragma once
#include <QQmlEngine>
#include <QSortFilterProxyModel>
class DevicesProxyModel : public QSortFilterProxyModel
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(int type READ type WRITE setType NOTIFY typeChanged)
public:

View File

@@ -5,6 +5,7 @@
#include <QAbstractListModel>
#include <QObject>
#include <QQmlEngine>
#include <QSettings>
struct Emoji {
@@ -59,6 +60,8 @@ Q_DECLARE_METATYPE(Emoji)
class EmojiModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
/**
* @brief Return a list of recently used emojis.
@@ -83,6 +86,10 @@ public:
static EmojiModel _instance;
return _instance;
}
static EmojiModel *create(QQmlEngine *, QJSEngine *)
{
return &instance();
}
/**
* @brief Defines the model roles.

View File

@@ -3,6 +3,7 @@
#pragma once
#include <QQmlEngine>
#include <QSortFilterProxyModel>
/**
@@ -14,6 +15,7 @@
class EmoticonFilterModel : public QSortFilterProxyModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief Whether stickers should be shown

View File

@@ -6,6 +6,7 @@
#include "events/imagepackevent.h"
#include <QAbstractListModel>
#include <QPointer>
#include <QQmlEngine>
#include <QVector>
class NeoChatRoom;
@@ -21,6 +22,7 @@ class NeoChatRoom;
class ImagePacksModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The current room that the model is being used in.

View File

@@ -8,6 +8,7 @@
#include <QAbstractListModel>
#include <QPointer>
#include <QQmlEngine>
#include <QRectF>
struct LiveLocationData {
@@ -24,6 +25,8 @@ bool operator<(const LiveLocationData &lhs, const LiveLocationData &rhs);
class LiveLocationsModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
Q_PROPERTY(NeoChatRoom *room MEMBER m_room NOTIFY roomChanged)
/** The event id of the beacon start event, ie. the one all suspequent
* events use to relate to the same beacon.

View File

@@ -5,6 +5,7 @@
#include <QAbstractListModel>
#include <QPointer>
#include <QQmlEngine>
#include <QRectF>
#include "neochatroom.h"
@@ -15,6 +16,7 @@
class LocationsModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
public:
enum Roles {

View File

@@ -3,8 +3,8 @@
#pragma once
#include <QQmlEngine>
#include <QSortFilterProxyModel>
#include <qobjectdefs.h>
#include "models/messagefiltermodel.h"
@@ -20,6 +20,8 @@ class MessageFilterModel;
class MediaMessageFilterModel : public QSortFilterProxyModel
{
Q_OBJECT
QML_ELEMENT
public:
enum MediaType {
Image = 0,

View File

@@ -5,6 +5,7 @@
#include <KFormat>
#include <QAbstractListModel>
#include <QQmlEngine>
#include "linkpreviewer.h"
#include "neochatroom.h"
@@ -25,6 +26,7 @@ class ReactionModel;
class MessageEventModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The current room that the model is getting its messages from.

View File

@@ -3,6 +3,7 @@
#pragma once
#include <QQmlEngine>
#include <QSortFilterProxyModel>
#include "messageeventmodel.h"
@@ -21,6 +22,8 @@
class MessageFilterModel : public QSortFilterProxyModel
{
Q_OBJECT
QML_ELEMENT
public:
/**
* @brief Defines the model roles.

View File

@@ -5,6 +5,7 @@
#include <QAbstractListModel>
#include <QObject>
#include <QQmlEngine>
#include <Quotient/csapi/list_public_rooms.h>
@@ -27,6 +28,7 @@ class Connection;
class PublicRoomListModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The current connection that the model is getting its rooms from.

View File

@@ -4,6 +4,7 @@
#pragma once
#include <QAbstractListModel>
#include <QQmlEngine>
#include <Quotient/csapi/definitions/push_rule.h>
@@ -20,6 +21,8 @@
class PushNotificationKind : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("")
public:
/**
@@ -71,6 +74,8 @@ public:
class PushNotificationSection : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("")
public:
/**
@@ -130,6 +135,7 @@ public:
class PushRuleModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The default state for any newly created keyword rule.

View File

@@ -4,6 +4,7 @@
#pragma once
#include <QAbstractListModel>
#include <QQmlEngine>
namespace Quotient
{
@@ -18,6 +19,7 @@ class User;
class ReactionModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
public:
/**

View File

@@ -6,6 +6,7 @@
#include <Quotient/events/roomevent.h>
#include <QAbstractListModel>
#include <QQmlEngine>
class NeoChatRoom;
@@ -18,6 +19,8 @@ class Room;
class NeoChatRoomType : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("")
public:
/**
@@ -42,6 +45,7 @@ public:
class RoomListModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The current connection that the model is getting its rooms from.

View File

@@ -4,6 +4,7 @@
#pragma once
#include <QAbstractListModel>
#include <QQmlEngine>
#include <QString>
#include <Quotient/csapi/search.h>
@@ -23,6 +24,7 @@ class NeoChatRoom;
class SearchModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The text to search messages for.

View File

@@ -7,6 +7,7 @@
#include <QAbstractListModel>
#include <QPointer>
#include <QQmlEngine>
#include <QUrl>
/**
@@ -24,6 +25,7 @@
class ServerListModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
public:
/**

View File

@@ -3,6 +3,7 @@
#pragma once
#include <QQmlEngine>
#include <QSortFilterProxyModel>
/**
@@ -27,6 +28,7 @@
class SortFilterRoomListModel : public QSortFilterProxyModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The order by which the rooms will be sorted.

View File

@@ -3,6 +3,7 @@
#pragma once
#include <QQmlEngine>
#include <QSortFilterProxyModel>
/**
@@ -16,6 +17,8 @@
class SortFilterSpaceListModel : public QSortFilterProxyModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The number of spaces in the model.
*/

View File

@@ -3,6 +3,7 @@
#pragma once
#include <QQmlEngine>
#include <QSortFilterProxyModel>
/**
@@ -14,6 +15,7 @@
class StateFilterModel : public QSortFilterProxyModel
{
Q_OBJECT
QML_ELEMENT
public:
/**

View File

@@ -4,6 +4,7 @@
#pragma once
#include <QAbstractListModel>
#include <QQmlEngine>
#include "neochatroom.h"
@@ -15,6 +16,7 @@
class StateModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The current room that the model is getting its state events from.

View File

@@ -7,6 +7,7 @@
#include "neochatroom.h"
#include <QAbstractListModel>
#include <QObject>
#include <QQmlEngine>
#include <QVector>
class ImagePacksModel;
@@ -22,6 +23,7 @@ class ImagePacksModel;
class StickerModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The image pack that the stickers come from.

View File

@@ -5,6 +5,7 @@
#include <QAbstractListModel>
#include <QObject>
#include <QQmlEngine>
#include <Quotient/csapi/users.h>
@@ -26,6 +27,7 @@ class Connection;
class UserDirectoryListModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The current connection that the model is getting users from.

View File

@@ -3,6 +3,7 @@
#pragma once
#include <QQmlEngine>
#include <QSortFilterProxyModel>
/**
@@ -15,6 +16,7 @@
class UserFilterModel : public QSortFilterProxyModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief This property hold the text of the filter.

View File

@@ -8,6 +8,7 @@
#include <QAbstractListModel>
#include <QObject>
#include <QPointer>
#include <QQmlEngine>
class NeoChatRoom;
@@ -29,6 +30,7 @@ class User;
class UserListModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The room that the model is getting its users from.

View File

@@ -10,7 +10,7 @@
#endif
#include <KStringHandler>
struct KWebShortcutModelPrivate {
struct WebShortcutModelPrivate {
QString selectedText;
#ifdef HAVE_KIO
KUriFilterData filterData;
@@ -18,27 +18,27 @@ struct KWebShortcutModelPrivate {
QStringList searchProviders;
};
KWebShortcutModel::KWebShortcutModel(QObject *parent)
WebShortcutModel::WebShortcutModel(QObject *parent)
: QAbstractListModel(parent)
, d(new KWebShortcutModelPrivate)
, d(new WebShortcutModelPrivate)
{
}
KWebShortcutModel::~KWebShortcutModel()
WebShortcutModel::~WebShortcutModel()
{
}
QString KWebShortcutModel::selectedText() const
QString WebShortcutModel::selectedText() const
{
return d->selectedText;
}
QString KWebShortcutModel::trunkatedSearchText() const
QString WebShortcutModel::trunkatedSearchText() const
{
return KStringHandler::rsqueeze(d->selectedText, 21);
}
bool KWebShortcutModel::enabled() const
bool WebShortcutModel::enabled() const
{
#ifdef HAVE_KIO
return true;
@@ -47,7 +47,7 @@ bool KWebShortcutModel::enabled() const
#endif
}
void KWebShortcutModel::setSelectedText(const QString &selectedText)
void WebShortcutModel::setSelectedText(const QString &selectedText)
{
if (d->selectedText == selectedText) {
return;
@@ -80,7 +80,7 @@ void KWebShortcutModel::setSelectedText(const QString &selectedText)
Q_EMIT selectedTextChanged();
}
int KWebShortcutModel::rowCount(const QModelIndex &parent) const
int WebShortcutModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
#ifdef HAVE_KIO
@@ -91,7 +91,7 @@ int KWebShortcutModel::rowCount(const QModelIndex &parent) const
return 0;
}
QVariant KWebShortcutModel::data(const QModelIndex &index, int role) const
QVariant WebShortcutModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid()) {
return {};
@@ -110,7 +110,7 @@ QVariant KWebShortcutModel::data(const QModelIndex &index, int role) const
return {};
}
void KWebShortcutModel::trigger(const QString &data)
void WebShortcutModel::trigger(const QString &data)
{
#ifdef HAVE_KIO
KUriFilterData filterData(data);
@@ -122,7 +122,7 @@ void KWebShortcutModel::trigger(const QString &data)
#endif
}
void KWebShortcutModel::configureWebShortcuts()
void WebShortcutModel::configureWebShortcuts()
{
#ifdef HAVE_KIO
auto job = new KIO::CommandLauncherJob(QStringLiteral("kcmshell5"), QStringList() << QStringLiteral("webshortcuts"), this);

View File

@@ -4,12 +4,13 @@
#pragma once
#include <QAbstractListModel>
#include <QQmlEngine>
#include <memory>
struct KWebShortcutModelPrivate;
struct WebShortcutModelPrivate;
/**
* @class KWebShortcutModel
* @class WebShortcutModel
*
* This class defines the model for listing web shortcuts for a specified selectedText.
*
@@ -45,9 +46,10 @@ struct KWebShortcutModelPrivate;
* }
* ```
*/
class KWebShortcutModel : public QAbstractListModel
class WebShortcutModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
/**
* @brief The text to find web shortcuts for.
@@ -64,8 +66,8 @@ class KWebShortcutModel : public QAbstractListModel
*/
Q_PROPERTY(bool enabled READ enabled CONSTANT)
public:
explicit KWebShortcutModel(QObject *parent = nullptr);
~KWebShortcutModel();
explicit WebShortcutModel(QObject *parent = nullptr);
~WebShortcutModel();
QString selectedText() const;
void setSelectedText(const QString &selectedText);
@@ -103,5 +105,5 @@ Q_SIGNALS:
void openUrl(const QUrl &url);
private:
std::unique_ptr<KWebShortcutModelPrivate> d;
std::unique_ptr<WebShortcutModelPrivate> d;
};