Exemple #1
0
void DescriptionManager::truncate()
{
	while (!StringList.isEmpty() && StringList.size() > MaxNumberOfDescriptions)
	{
		// We need a copy here, otherwise removeDescription() will emit singal descriptionRemoved()
		// with a reference to QString which will be already removed by then.
		QString last = StringList.last();
		removeDescription(last);
	}
}
void DescriptionManager::addDescription(const QString &description)
{
	if (description.isEmpty())
		return;

	if (StringList.contains(description))
		removeDescription(description);

	emit descriptionAboutToBeAdded(description);
	StringList.prepend(description);
	emit descriptionAdded(description);

	truncate();
}
void DescriptionManager::truncate()
{
	while (!StringList.isEmpty() && StringList.size() > MaxNumberOfDescriptions)
		removeDescription(StringList.last());
}