/***************************************************************************

    source::worx xtree
    Copyright © 2024-2025 c.holzheuer
    christoph.holzheuer@gmail.com

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

***************************************************************************/


#ifndef XQTREETABLE_H
#define XQTREETABLE_H

#include <QTreeView>
#include <QMouseEvent>
#include <QDebug>

class XQItem;
class XQViewModel;

/**
 * @brief A specialized QTreeView that will handle the drawing of
 * empty or non-existing items in the future.
 */

class XQTreeTable : public QTreeView
{
  Q_OBJECT
  // wird hier lieber ncht benutzt
  //Q_DECLARE_PRIVATE(QTreeView)

public:

  XQTreeTable(QWidget* parent = nullptr );
  virtual ~XQTreeTable() = default;

  XQViewModel* viewModel();
  XQItem&  xqItemFromIndex(const QModelIndex& index );

  void toggleRowsHidden(int fstRow, int lstRow );

protected:

  void currentChanged(const QModelIndex& current, const QModelIndex& previous) override;

  void mouseMoveEvent(QMouseEvent* event) override;
  void mouseReleaseEvent(QMouseEvent* event) override;
  void mousePressEvent(QMouseEvent* event) override;
  void mouseResizeHeaderEntry(int xpos);
  void wheelEvent(QWheelEvent* event) override;

  //! used by the mouse events
  QModelIndex _indexToResize;
};

#endif // XQTREETABLE_H
