mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
703f3717e2
Co-authored-by: LosFarmosCTL <80157503+LosFarmosCTL@users.noreply.github.com> Co-authored-by: Paweł <zneix@zneix.eu> Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
60 lines
1.4 KiB
C++
60 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "widgets/listview/GenericItemDelegate.hpp"
|
|
#include "widgets/listview/GenericListItem.hpp"
|
|
|
|
#include <QListView>
|
|
|
|
namespace chatterino {
|
|
|
|
class GenericListModel;
|
|
class Theme;
|
|
|
|
class GenericListView : public QListView
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
GenericListView();
|
|
|
|
virtual void setModel(QAbstractItemModel *model) override;
|
|
void setModel(GenericListModel *);
|
|
void setInvokeActionOnTab(bool);
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
|
|
|
GenericListModel *model_{};
|
|
SwitcherItemDelegate itemDelegate_;
|
|
|
|
void refreshTheme(const Theme &theme);
|
|
|
|
signals:
|
|
void closeRequested();
|
|
|
|
private:
|
|
bool invokeActionOnTab_{};
|
|
|
|
/**
|
|
* @brief Gets the currently selected item (if any) and calls its action
|
|
*
|
|
* @return true if an action was called on an item, false if no item was selected and thus no action was called
|
|
**/
|
|
bool acceptCompletion();
|
|
|
|
/**
|
|
* @brief Select the next item in the list. Wraps around if the bottom of the list has been reached.
|
|
**/
|
|
void focusNextCompletion();
|
|
|
|
/**
|
|
* @brief Select the previous item in the list. Wraps around if the top of the list has been reached.
|
|
**/
|
|
void focusPreviousCompletion();
|
|
|
|
/**
|
|
* @brief Request for the GUI powering this list view to be closed. Shorthand for emit this->closeRequested()
|
|
**/
|
|
void requestClose();
|
|
};
|
|
|
|
} // namespace chatterino
|