view include/gui/widgets/sidebar.h @ 222:b9f111d84d95

*: move to semver, remove old macos build, add library files I'm retarded and can't commit files right
author Paper <paper@paper.us.eu.org>
date Mon, 08 Jan 2024 13:22:09 -0500
parents 80f49f623d30
children 862d0d8619f6
line wrap: on
line source

#ifndef __gui__sidebar_h
#define __gui__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 // __gui__sidebar_h