blob: 6a0157a1ae163e53bc6b8319298fc00273771652 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#pragma once
#include <QWidget>
#include "CacheStructs.h"
class QVBoxLayout;
class QLayoutItem;
class SuggestionsPopup : public QWidget
{
Q_OBJECT
public:
explicit SuggestionsPopup(QWidget *parent = nullptr);
void selectHoveredSuggestion();
public slots:
void addRooms(const std::vector<RoomSearchResult> &rooms);
//! Move to the next available suggestion item.
void selectNextSuggestion();
//! Move to the previous available suggestion item.
void selectPreviousSuggestion();
//! Remove hovering from all items.
void resetHovering();
//! Set hovering to the item in the given layout position.
void setHovering(int pos);
protected:
void paintEvent(QPaintEvent *event) override;
signals:
void itemSelected(const QString &user);
private:
QString displayName(QString roomid, QString userid);
void hoverSelection();
void resetSelection() { selectedItem_ = -1; }
void selectFirstItem() { selectedItem_ = 0; }
void selectLastItem();
void removeLayoutItemsAfter(size_t startingPos);
QVBoxLayout *layout_;
//! Counter for tab completion (cycling).
int selectedItem_ = -1;
};
|