mirror of
https://github.com/parchlinux/calamares.git
synced 2025-07-05 05:15:38 -04:00
[calamares] Add reload() to update model after underlying data
This commit is contained in:
parent
2a3ab4dbe7
commit
2bd03ad3c0
2 changed files with 21 additions and 6 deletions
|
@ -70,15 +70,21 @@ findNth( const VariantModel::IndexVector& skiplist, quintptr value, int n )
|
|||
VariantModel::VariantModel( const QVariant* p )
|
||||
: m_p( p )
|
||||
{
|
||||
int x = 0;
|
||||
overallLength( *p, x, -1, nullptr );
|
||||
m_rows.reserve( x );
|
||||
x = 0;
|
||||
overallLength( *p, x, -1, &m_rows );
|
||||
reload();
|
||||
}
|
||||
|
||||
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
|
||||
VariantModel::columnCount( const QModelIndex& index ) const
|
||||
{
|
||||
|
|
|
@ -33,7 +33,9 @@
|
|||
* VariantMap's data structure.
|
||||
*
|
||||
* 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
|
||||
{
|
||||
|
@ -56,6 +58,13 @@ public:
|
|||
|
||||
~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 rowCount( const QModelIndex& index ) const override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue