view include/gui/widgets/sidebar.h @ 261:3ec7804abf17

include: make header guards more sane The C++ standard[1] says: Each identifier that contains a double underscore __ or begins with an underscore followed by an uppercase letter is reserved to the implementation for any use. [1]: https://timsong-cpp.github.io/cppwp/n4659/lex.name#3.1
author Paper <paper@paper.us.eu.org>
date Wed, 03 Apr 2024 20:04:28 -0400
parents 862d0d8619f6
children 99cbc51433e4
line wrap: on
line source

#ifndef MINORI_GUI_WIDGETS_SIDEBAR_H_
#define MINORI_GUI_WIDGETS_SIDEBAR_H_

#include <QItemSelectionModel>
#include <QListWidget>

class QListWidgetItem;

class SideBar final : public QListWidget {
	Q_OBJECT

public:
	SideBar(QWidget* parent = nullptr);
	QListWidgetItem* AddItem(QString name, QIcon icon = QIcon());
	QListWidgetItem* AddSeparator();
	int GetCurrentItem();
	bool IndexIsSeparator(QModelIndex index) const;
	static QIcon CreateIcon(const char* file);
	void SetBackgroundColor(QColor color);

signals:
	void CurrentItemChanged(int index);

public slots:
	void SetCurrentItem(int index);

protected:
	virtual void mouseMoveEvent(QMouseEvent* event) override;
	QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex& index, const QEvent* event) const override;
	int RemoveSeparatorsFromIndex(int index);
	int AddSeparatorsToIndex(int index);
};

#endif // MINORI_GUI_WIDGETS_SIDEBAR_H_