mirror-chatterino2/src/widgets/listview/GenericListView.hpp
Mm2PL 703f3717e2
Add custom hotkeys. (#2340)
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>
2021-11-21 17:46:21 +00:00

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