2020-08-15 18:59:17 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "widgets/listview/GenericItemDelegate.hpp"
|
|
|
|
#include "widgets/listview/GenericListItem.hpp"
|
|
|
|
|
2021-11-21 18:46:21 +01:00
|
|
|
#include <QListView>
|
|
|
|
|
2020-08-15 18:59:17 +02:00
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
class GenericListModel;
|
|
|
|
class Theme;
|
|
|
|
|
|
|
|
class GenericListView : public QListView
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
GenericListView();
|
|
|
|
|
|
|
|
virtual void setModel(QAbstractItemModel *model) override;
|
|
|
|
void setModel(GenericListModel *);
|
2020-08-23 11:28:22 +02:00
|
|
|
void setInvokeActionOnTab(bool);
|
2020-08-15 18:59:17 +02:00
|
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
|
|
|
|
|
|
|
GenericListModel *model_{};
|
|
|
|
SwitcherItemDelegate itemDelegate_;
|
|
|
|
|
|
|
|
void refreshTheme(const Theme &theme);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void closeRequested();
|
2020-08-23 11:28:22 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool invokeActionOnTab_{};
|
2021-11-21 18:46:21 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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();
|
2020-08-15 18:59:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace chatterino
|