Remove metatypes from headers

This commit is contained in:
Nicolas Werner 2020-01-31 16:08:30 +01:00
parent 4cd260bfcf
commit 127fb9370b
16 changed files with 42 additions and 43 deletions

View file

@ -80,7 +80,7 @@ using CachedReceipts = std::multimap<uint64_t, std::string, std::greater<uint64_
using Receipts = std::map<std::string, std::map<std::string, uint64_t>>; using Receipts = std::map<std::string, std::map<std::string, uint64_t>>;
Q_DECLARE_METATYPE(SearchResult) Q_DECLARE_METATYPE(SearchResult)
Q_DECLARE_METATYPE(QVector<SearchResult>) Q_DECLARE_METATYPE(std::vector<SearchResult>)
Q_DECLARE_METATYPE(RoomMember) Q_DECLARE_METATYPE(RoomMember)
Q_DECLARE_METATYPE(mtx::responses::Timeline) Q_DECLARE_METATYPE(mtx::responses::Timeline)
Q_DECLARE_METATYPE(RoomSearchResult) Q_DECLARE_METATYPE(RoomSearchResult)
@ -1834,7 +1834,7 @@ Cache::searchRooms(const std::string &query, std::uint8_t max_items)
return results; return results;
} }
QVector<SearchResult> std::vector<SearchResult>
Cache::searchUsers(const std::string &room_id, const std::string &query, std::uint8_t max_items) Cache::searchUsers(const std::string &room_id, const std::string &query, std::uint8_t max_items)
{ {
std::multimap<int, std::pair<std::string, std::string>> items; std::multimap<int, std::pair<std::string, std::string>> items;
@ -1857,7 +1857,7 @@ Cache::searchUsers(const std::string &room_id, const std::string &query, std::ui
else if (items.size() > 0) else if (items.size() > 0)
std::advance(end, items.size()); std::advance(end, items.size());
QVector<SearchResult> results; std::vector<SearchResult> results;
for (auto it = items.begin(); it != end; it++) { for (auto it = items.begin(); it != end; it++) {
const auto user = it->second; const auto user = it->second;
results.push_back(SearchResult{QString::fromStdString(user.first), results.push_back(SearchResult{QString::fromStdString(user.first),
@ -2390,12 +2390,11 @@ void
init(const QString &user_id) init(const QString &user_id)
{ {
qRegisterMetaType<SearchResult>(); qRegisterMetaType<SearchResult>();
qRegisterMetaType<QVector<SearchResult>>(); qRegisterMetaType<std::vector<SearchResult>>();
qRegisterMetaType<RoomMember>(); qRegisterMetaType<RoomMember>();
qRegisterMetaType<RoomSearchResult>(); qRegisterMetaType<RoomSearchResult>();
qRegisterMetaType<RoomInfo>(); qRegisterMetaType<RoomInfo>();
qRegisterMetaType<QMap<QString, RoomInfo>>(); qRegisterMetaType<QMap<QString, RoomInfo>>();
qRegisterMetaType<QMap<QString, mtx::responses::Notifications>>();
qRegisterMetaType<std::map<QString, RoomInfo>>(); qRegisterMetaType<std::map<QString, RoomInfo>>();
qRegisterMetaType<std::map<QString, mtx::responses::Timeline>>(); qRegisterMetaType<std::map<QString, mtx::responses::Timeline>>();
@ -2734,7 +2733,7 @@ calculateRoomReadStatus()
instance_->calculateRoomReadStatus(); instance_->calculateRoomReadStatus();
} }
QVector<SearchResult> std::vector<SearchResult>
searchUsers(const std::string &room_id, const std::string &query, std::uint8_t max_items) searchUsers(const std::string &room_id, const std::string &query, std::uint8_t max_items)
{ {
return instance_->searchUsers(room_id, query, max_items); return instance_->searchUsers(room_id, query, max_items);

View file

@ -218,7 +218,7 @@ calculateRoomReadStatus(const std::string &room_id);
void void
calculateRoomReadStatus(); calculateRoomReadStatus();
QVector<SearchResult> std::vector<SearchResult>
searchUsers(const std::string &room_id, const std::string &query, std::uint8_t max_items = 5); searchUsers(const std::string &room_id, const std::string &query, std::uint8_t max_items = 5);
std::vector<RoomSearchResult> std::vector<RoomSearchResult>
searchRooms(const std::string &query, std::uint8_t max_items = 5); searchRooms(const std::string &query, std::uint8_t max_items = 5);

View file

@ -172,9 +172,9 @@ public:
bool calculateRoomReadStatus(const std::string &room_id); bool calculateRoomReadStatus(const std::string &room_id);
void calculateRoomReadStatus(); void calculateRoomReadStatus();
QVector<SearchResult> searchUsers(const std::string &room_id, std::vector<SearchResult> searchUsers(const std::string &room_id,
const std::string &query, const std::string &query,
std::uint8_t max_items = 5); std::uint8_t max_items = 5);
std::vector<RoomSearchResult> searchRooms(const std::string &query, std::vector<RoomSearchResult> searchRooms(const std::string &query,
std::uint8_t max_items = 5); std::uint8_t max_items = 5);

View file

@ -19,6 +19,7 @@
#include <QStyleOption> #include <QStyleOption>
#include <mtx/identifiers.hpp> #include <mtx/identifiers.hpp>
#include <mtx/responses/login.hpp>
#include "Config.h" #include "Config.h"
#include "Logging.h" #include "Logging.h"

View file

@ -2,6 +2,26 @@
#include <memory> #include <memory>
#include <QMetaType>
#include <QObject>
#include <QString>
#include "nlohmann/json.hpp"
#include <mtx/responses.hpp>
Q_DECLARE_METATYPE(mtx::responses::Login)
Q_DECLARE_METATYPE(mtx::responses::Messages)
Q_DECLARE_METATYPE(mtx::responses::Notifications)
Q_DECLARE_METATYPE(mtx::responses::Rooms)
Q_DECLARE_METATYPE(mtx::responses::Sync)
Q_DECLARE_METATYPE(mtx::responses::JoinedGroups)
Q_DECLARE_METATYPE(mtx::responses::GroupProfile)
Q_DECLARE_METATYPE(nlohmann::json)
Q_DECLARE_METATYPE(std::string)
Q_DECLARE_METATYPE(std::vector<std::string>)
Q_DECLARE_METATYPE(std::vector<QString>)
namespace { namespace {
auto client_ = std::make_shared<mtx::http::Client>(); auto client_ = std::make_shared<mtx::http::Client>();
} }

View file

@ -1,25 +1,7 @@
#pragma once #pragma once
#include <QMetaType>
#include <QObject>
#include <QString>
#include "nlohmann/json.hpp"
#include <mtx/responses.hpp>
#include <mtxclient/http/client.hpp> #include <mtxclient/http/client.hpp>
Q_DECLARE_METATYPE(mtx::responses::Login)
Q_DECLARE_METATYPE(mtx::responses::Messages)
Q_DECLARE_METATYPE(mtx::responses::Notifications)
Q_DECLARE_METATYPE(mtx::responses::Rooms)
Q_DECLARE_METATYPE(mtx::responses::Sync)
Q_DECLARE_METATYPE(mtx::responses::JoinedGroups)
Q_DECLARE_METATYPE(mtx::responses::GroupProfile)
Q_DECLARE_METATYPE(std::string)
Q_DECLARE_METATYPE(nlohmann::json)
Q_DECLARE_METATYPE(std::vector<std::string>)
Q_DECLARE_METATYPE(std::vector<QString>)
namespace http { namespace http {
mtx::http::Client * mtx::http::Client *
client(); client();

View file

@ -26,6 +26,8 @@
#include "QuickSwitcher.h" #include "QuickSwitcher.h"
#include "popups/SuggestionsPopup.h" #include "popups/SuggestionsPopup.h"
Q_DECLARE_METATYPE(std::vector<RoomSearchResult>)
RoomSearchInput::RoomSearchInput(QWidget *parent) RoomSearchInput::RoomSearchInput(QWidget *parent)
: TextField(parent) : TextField(parent)
{} {}

View file

@ -25,8 +25,6 @@
#include "popups/SuggestionsPopup.h" #include "popups/SuggestionsPopup.h"
#include "ui/TextField.h" #include "ui/TextField.h"
Q_DECLARE_METATYPE(std::vector<RoomSearchResult>)
class RoomSearchInput : public TextField class RoomSearchInput : public TextField
{ {
Q_OBJECT Q_OBJECT

View file

@ -19,6 +19,8 @@
#include <QStyleOption> #include <QStyleOption>
#include <QTimer> #include <QTimer>
#include <mtx/responses/register.hpp>
#include "Config.h" #include "Config.h"
#include "Logging.h" #include "Logging.h"
#include "MainWindow.h" #include "MainWindow.h"

View file

@ -17,15 +17,12 @@
#pragma once #pragma once
#include <QMetaType>
#include <QPushButton> #include <QPushButton>
#include <QScrollArea> #include <QScrollArea>
#include <QSharedPointer> #include <QSharedPointer>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QWidget> #include <QWidget>
#include <mtx.hpp>
class LeaveRoomDialog; class LeaveRoomDialog;
class OverlayModal; class OverlayModal;
class RoomInfoListItem; class RoomInfoListItem;

View file

@ -109,7 +109,7 @@ FilteredTextEdit::FilteredTextEdit(QWidget *parent)
} }
void void
FilteredTextEdit::showResults(const QVector<SearchResult> &results) FilteredTextEdit::showResults(const std::vector<SearchResult> &results)
{ {
QPoint pos; QPoint pos;

View file

@ -76,13 +76,13 @@ signals:
//! Trigger the suggestion popup. //! Trigger the suggestion popup.
void showSuggestions(const QString &query); void showSuggestions(const QString &query);
void resultsRetrieved(const QVector<SearchResult> &results); void resultsRetrieved(const std::vector<SearchResult> &results);
void selectNextSuggestion(); void selectNextSuggestion();
void selectPreviousSuggestion(); void selectPreviousSuggestion();
void selectHoveredSuggestion(); void selectHoveredSuggestion();
public slots: public slots:
void showResults(const QVector<SearchResult> &results); void showResults(const std::vector<SearchResult> &results);
protected: protected:
void keyPressEvent(QKeyEvent *event) override; void keyPressEvent(QKeyEvent *event) override;

View file

@ -15,6 +15,8 @@
using namespace dialogs; using namespace dialogs;
Q_DECLARE_METATYPE(std::vector<DeviceInfo>)
constexpr int BUTTON_SIZE = 36; constexpr int BUTTON_SIZE = 36;
constexpr int BUTTON_RADIUS = BUTTON_SIZE / 2; constexpr int BUTTON_RADIUS = BUTTON_SIZE / 2;
constexpr int WIDGET_MARGIN = 20; constexpr int WIDGET_MARGIN = 20;

View file

@ -15,8 +15,6 @@ struct DeviceInfo
QString display_name; QString display_name;
}; };
Q_DECLARE_METATYPE(std::vector<DeviceInfo>)
class Proxy : public QObject class Proxy : public QObject
{ {
Q_OBJECT Q_OBJECT

View file

@ -60,9 +60,9 @@ SuggestionsPopup::addRooms(const std::vector<RoomSearchResult> &rooms)
} }
void void
SuggestionsPopup::addUsers(const QVector<SearchResult> &users) SuggestionsPopup::addUsers(const std::vector<SearchResult> &users)
{ {
if (users.isEmpty()) { if (users.empty()) {
hide(); hide();
return; return;
} }

View file

@ -9,8 +9,6 @@
#include "ChatPage.h" #include "ChatPage.h"
#include "PopupItem.h" #include "PopupItem.h"
Q_DECLARE_METATYPE(QVector<SearchResult>)
class SuggestionsPopup : public QWidget class SuggestionsPopup : public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -33,7 +31,7 @@ public:
} }
public slots: public slots:
void addUsers(const QVector<SearchResult> &users); void addUsers(const std::vector<SearchResult> &users);
void addRooms(const std::vector<RoomSearchResult> &rooms); void addRooms(const std::vector<RoomSearchResult> &rooms);
//! Move to the next available suggestion item. //! Move to the next available suggestion item.