qskinny/src/controls/QskListView.h

111 lines
3.3 KiB
C
Raw Normal View History

2017-07-21 18:21:34 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#ifndef QSK_LIST_VIEW_H
#define QSK_LIST_VIEW_H
#include "QskScrollView.h"
#include "QskTextOptions.h"
class QSK_EXPORT QskListView : public QskScrollView
{
Q_OBJECT
Q_PROPERTY( bool alternatingRowColors READ alternatingRowColors
WRITE setAlternatingRowColors NOTIFY alternatingRowColorsChanged FINAL )
Q_PROPERTY( SelectionMode selectionMode READ selectionMode
WRITE setSelectionMode NOTIFY selectionModeChanged FINAL )
Q_PROPERTY( int selectedRow READ selectedRow
WRITE setSelectedRow NOTIFY selectedRowChanged FINAL )
Q_PROPERTY( QskTextOptions textOptions READ textOptions
WRITE setTextOptions NOTIFY textOptionsChanged FINAL )
Q_PROPERTY( bool preferredWidthFromColumns READ preferredWidthFromColumns
WRITE setPreferredWidthFromColumns NOTIFY preferredWidthFromColumnsChanged() )
using Inherited = QskScrollView;
2018-08-03 08:15:28 +02:00
public:
2017-07-21 18:21:34 +02:00
/*
Everything, that can have a skin state, needs to be a QskSkinnable.
Of course this is no option for the cells considering that we might
have many, many of them.
So for the moment we simply use Cell/Text and CellSelected/TextSelected
as workaround until we found a solution that fits into the design.
TODO ...
*/
QSK_SUBCONTROLS( Cell, Text, CellSelected, TextSelected )
enum SelectionMode
{
NoSelection,
SingleSelection,
MultiSelection // not implemented yet
};
Q_ENUM( SelectionMode )
QskListView( QQuickItem* parent = nullptr );
2018-07-31 17:32:25 +02:00
~QskListView() override;
2017-07-21 18:21:34 +02:00
void setPreferredWidthFromColumns( bool );
bool preferredWidthFromColumns() const;
void setAlternatingRowColors( bool );
bool alternatingRowColors() const;
void setSelectionMode( SelectionMode );
SelectionMode selectionMode() const;
void setTextOptions( const QskTextOptions& textOptions );
QskTextOptions textOptions() const;
Q_INVOKABLE int selectedRow() const;
virtual int rowCount() const = 0;
virtual int columnCount() const = 0;
virtual qreal columnWidth( int col ) const = 0;
virtual qreal rowHeight() const = 0;
Q_INVOKABLE virtual QVariant valueAt( int row, int col ) const = 0;
#if 1
virtual QskColorFilter graphicFilterAt( int row, int col ) const;
virtual QskAspect::Subcontrol textSubControlAt( int row, int col ) const;
#endif
2018-08-03 08:15:28 +02:00
public Q_SLOTS:
2017-07-21 18:21:34 +02:00
void setSelectedRow( int row );
2018-08-03 08:15:28 +02:00
Q_SIGNALS:
2017-07-21 18:21:34 +02:00
void selectedRowChanged( int row );
void selectionModeChanged();
void alternatingRowColorsChanged();
void preferredWidthFromColumnsChanged();
void textOptionsChanged();
2018-08-03 08:15:28 +02:00
protected:
2018-07-31 17:32:25 +02:00
void keyPressEvent( QKeyEvent* ) override;
void keyReleaseEvent( QKeyEvent* ) override;
2017-07-21 18:21:34 +02:00
2018-07-31 17:32:25 +02:00
void mousePressEvent( QMouseEvent* ) override;
void mouseReleaseEvent( QMouseEvent* ) override;
2017-07-21 18:21:34 +02:00
void updateScrollableSize();
QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override;
2018-07-31 17:32:25 +02:00
void componentComplete() override;
2017-07-21 18:21:34 +02:00
2018-08-03 08:15:28 +02:00
private:
2017-07-21 18:21:34 +02:00
class PrivateData;
std::unique_ptr< PrivateData > m_data;
};
#endif