mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 00:55:09 -07:00
* Add card completion popups to chats and search fields Completes @mention and [[card]] in chat, and card names in the deck editor, EDHREC, Archidekt, card art rules, and user card settings searches. Pops up a styled list with mana pips and a card image preview, flipping the list order when the popup opens above the text field. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
41 lines
972 B
C++
41 lines
972 B
C++
/**
|
|
* @file card_search_model.h
|
|
* @ingroup CardDatabaseModels
|
|
*/
|
|
//! \todo Document this file.
|
|
|
|
#ifndef CARD_SEARCH_MODEL_H
|
|
#define CARD_SEARCH_MODEL_H
|
|
|
|
#include "../card_database_display_model.h"
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
class CardSearchModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
enum CardSearchRoles
|
|
{
|
|
CardInfoRole = Qt::UserRole + 1,
|
|
};
|
|
|
|
explicit CardSearchModel(CardDatabaseDisplayModel *sourceModel, QObject *parent = nullptr);
|
|
|
|
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
void updateSearchResults(const QString &query); // Update results based on input
|
|
|
|
private:
|
|
struct SearchResult
|
|
{
|
|
CardInfoPtr card;
|
|
int distance;
|
|
};
|
|
|
|
CardDatabaseDisplayModel *sourceModel;
|
|
QList<SearchResult> searchResults;
|
|
};
|
|
|
|
#endif // CARD_SEARCH_MODEL_H
|