[welcome] Factor out check for a filled requirements-model
This commit is contained in:
parent
fc653adcc0
commit
11d7870d68
@ -217,11 +217,10 @@ ResultsListWidget::retranslate()
|
|||||||
void
|
void
|
||||||
ResultsListWidget::requirementsChanged()
|
ResultsListWidget::requirementsChanged()
|
||||||
{
|
{
|
||||||
if ( m_config->requirementsModel()->count() < m_requirementsSeen )
|
if ( !isModelFilled() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_requirementsSeen = m_config->requirementsModel()->count();
|
|
||||||
|
|
||||||
// Check that all are satisfied (gives warnings if not) and
|
// Check that all are satisfied (gives warnings if not) and
|
||||||
// all *mandatory* entries are satisfied (gives errors if not).
|
// all *mandatory* entries are satisfied (gives errors if not).
|
||||||
@ -281,6 +280,18 @@ ResultsListWidget::requirementsChanged()
|
|||||||
retranslate();
|
retranslate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ResultsListWidget::isModelFilled()
|
||||||
|
{
|
||||||
|
if ( m_config->requirementsModel()->count() < m_requirementsSeen )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m_requirementsSeen = m_config->requirementsModel()->count();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "utils/moc-warnings.h"
|
#include "utils/moc-warnings.h"
|
||||||
|
|
||||||
#include "ResultsListWidget.moc"
|
#include "ResultsListWidget.moc"
|
||||||
|
@ -33,17 +33,31 @@ private:
|
|||||||
|
|
||||||
void retranslate();
|
void retranslate();
|
||||||
|
|
||||||
QList< ResultWidget* > m_resultWidgets; ///< One widget for each unsatisfied entry
|
/** @brief The model can be reset and re-filled, is it full yet?
|
||||||
|
*
|
||||||
|
* We count how many requirements we have seen; since the model
|
||||||
|
* does not shrink, we can avoid reacting to model-is-cleared
|
||||||
|
* events because the size of the model is then (briefly) smaller
|
||||||
|
* than what we expect.
|
||||||
|
*
|
||||||
|
* Returns true if the model contains at least m_requirementsSeen
|
||||||
|
* elements, and updates m_requirementsSeen. (Which is why the
|
||||||
|
* method is not const)
|
||||||
|
*/
|
||||||
|
bool isModelFilled();
|
||||||
|
|
||||||
|
/** @brief A list of widgets, one per entry in the requirements model
|
||||||
|
*
|
||||||
|
* Unsatisfied entries have a non-null widget pointer, while requirements
|
||||||
|
* entries that **are** satisfied have no widget.
|
||||||
|
*/
|
||||||
|
QList< ResultWidget* > m_resultWidgets;
|
||||||
Config* m_config = nullptr;
|
Config* m_config = nullptr;
|
||||||
|
|
||||||
// UI parts, which need updating when the model changes
|
// UI parts, which need updating when the model changes
|
||||||
QLabel* m_explanation = nullptr;
|
QLabel* m_explanation = nullptr;
|
||||||
QBoxLayout* m_mainLayout = nullptr;
|
QBoxLayout* m_mainLayout = nullptr;
|
||||||
QBoxLayout* m_entriesLayout = nullptr;
|
QBoxLayout* m_entriesLayout = nullptr;
|
||||||
// We count how many requirements we have seen; since the model
|
|
||||||
// does not shrink, we can avoid reacting to model-is-cleared
|
|
||||||
// events because the size of the model is then (briefly) smaller
|
|
||||||
// than what we expect.
|
|
||||||
int m_requirementsSeen = 0;
|
int m_requirementsSeen = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user