/**
** This file is owned by VisualGear Technology Co., Ltd.
** Unauthorized copying of this file, via any medium is strictly prohibited
** Otherwise VisualGear Technology Co., Ltd. will have the right to pursue
** maximum responsibilities within scope of legal.
**
** Copyright 2018-2020 VisualGear All rights reserved.
**/

#pragma once

#include <QtWidgets/QTreeView>
#include <QtWidgets/QItemDelegate>
#include "UIGQWidgetBase.h"

namespace UIGQtLib
{
	class UIGQTreeViewImpl;
	class UIGQConerWidget;
	class UIGQViewport;
	class UIGQTreeConerWidget;
	class UIGQTreeViewport;
	class UIGQTreeHeader;
	class UIGQScrollBar;
	class UIGQTreeViewItemDelegate;

	class UIGEARSQTLIB_EXPORT UIGQTreeView : public QTreeView, public IUIGQWidgetBase
	{
        Q_OBJECT

	public:
		UIGQTreeView(QWidget* pParent = nullptr);
		~UIGQTreeView();

		UIG_QT_CTRL_DEF("qttree", UIGQTreeView);

		void setScrollbarBtnSize(bool isHorizontalScrollbar, int size);
		void setScrollbarSize(bool isHorizontalScrollbar, int size);
		void setScrollbarBackgroundStyle(bool isHorizontalScrollbar, const FillStyle& background);
		void setScrollbarThumbStyle(bool isHorizontalScrollbar, CtrlState state, const FillStyle& style);
		void setScrollbarButtonStyle(bool isHorizontalScrollbar, bool isUp, CtrlState state, const FillStyle& style);
		void setScrollbarButtonIcon(bool isHorizontalScrollbar, bool isUpOrLeft, const QString& iconPath);
		void setScrollbarButtonIconStyle(bool isHorizontalScrollbar, bool isUpOrLeft, const IconStyleDesc& style);
		void setScrollbarThumb(bool isHorizontalScrollbar, const QString& thumb);

		void setHeaderBgStyle(CtrlState state, const FillStyle& style);
		void setHeaderTextStyle(CtrlState state, const TextStyleDesc& style);

		void setBackground(CommonCtrlState state, const FillStyle& style);
		const FillStyle& getBackground(CommonCtrlState state);

		void setItemBackground(UIGQtLib::CtrlState state, const FillStyle& style);
		const FillStyle& getItemBackground(UIGQtLib::CtrlState state);

		void setItemTextStyle(UIGQtLib::CtrlState state, const TextStyleDesc& style);
		const TextStyleDesc& getItemTextStyle(UIGQtLib::CtrlState state);

		void setItemHeight(int height);
		int getItemHeight();

		void initDemoData();

	protected:
		void paintEvent(QPaintEvent * evt);
		bool eventFilter(QObject * watched, QEvent * event);

	private:
		UIGQTreeHeader*				_horHeader;
		UIGQTreeHeader*				_verHeader;
		UIGQScrollBar*				_horScrollBar;
		UIGQScrollBar*				_verScrollBar;
		UIGQTreeViewImpl*			_ctrlImpl;
		UIGQTreeViewItemDelegate*	_itemDelegate;
		UIGQTreeConerWidget*		_conerWidget;
		UIGQTreeViewport*			_viewport;

        UIGQT_GET_CONTROLBASE
	};
}
