[calamares] Add reload() to update model after underlying data
This commit is contained in:
parent
2a3ab4dbe7
commit
2bd03ad3c0
@ -70,15 +70,21 @@ findNth( const VariantModel::IndexVector& skiplist, quintptr value, int n )
|
|||||||
VariantModel::VariantModel( const QVariant* p )
|
VariantModel::VariantModel( const QVariant* p )
|
||||||
: m_p( p )
|
: m_p( p )
|
||||||
{
|
{
|
||||||
int x = 0;
|
reload();
|
||||||
overallLength( *p, x, -1, nullptr );
|
|
||||||
m_rows.reserve( x );
|
|
||||||
x = 0;
|
|
||||||
overallLength( *p, x, -1, &m_rows );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VariantModel::~VariantModel() {}
|
VariantModel::~VariantModel() {}
|
||||||
|
|
||||||
|
void VariantModel::reload()
|
||||||
|
{
|
||||||
|
int x = 0;
|
||||||
|
overallLength( *m_p, x, -1, nullptr );
|
||||||
|
m_rows.clear(); // Start over
|
||||||
|
m_rows.reserve( x ); // We'll need this much
|
||||||
|
x = 0;
|
||||||
|
overallLength( *m_p, x, -1, &m_rows );
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
VariantModel::columnCount( const QModelIndex& index ) const
|
VariantModel::columnCount( const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,9 @@
|
|||||||
* VariantMap's data structure.
|
* VariantMap's data structure.
|
||||||
*
|
*
|
||||||
* Take care of object lifetimes and that the underlying
|
* Take care of object lifetimes and that the underlying
|
||||||
* QVariant does not change during use.
|
* QVariant does not change during use. If the QVariant
|
||||||
|
* **does** change, call reload() to re-build the internal
|
||||||
|
* representation of the tree.
|
||||||
*/
|
*/
|
||||||
class VariantModel : public QAbstractItemModel
|
class VariantModel : public QAbstractItemModel
|
||||||
{
|
{
|
||||||
@ -56,6 +58,13 @@ public:
|
|||||||
|
|
||||||
~VariantModel() override;
|
~VariantModel() override;
|
||||||
|
|
||||||
|
/** @brief Re-build the internal tree
|
||||||
|
*
|
||||||
|
* Call this when the underlying variant is changed, which
|
||||||
|
* might impact how the tree is laid out.
|
||||||
|
*/
|
||||||
|
void reload();
|
||||||
|
|
||||||
int columnCount( const QModelIndex& index ) const override;
|
int columnCount( const QModelIndex& index ) const override;
|
||||||
int rowCount( const QModelIndex& index ) const override;
|
int rowCount( const QModelIndex& index ) const override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user