}
-/**@todo possibly implement
- 1. sorting based on lesson name
- 2. sorting based on lesson index and original.
-*/
-
-class KEduVocDocumentSortHelper
-{
-public:
- inline KEduVocDocumentSortHelper(int column, Qt::SortOrder order) : sort_column(column), sort_order(order) {}
-
- inline bool operator()(const KEduVocExpression &e1, const KEduVocExpression &e2) const
- {
- if (sort_order == Qt::AscendingOrder)
- if (sort_column == 0)
- return e1.original().toLower() < e2.original().toLower();
- else
- return e1.translation(sort_column).toLower() < e2.translation(sort_column).toLower();
- else
- if (sort_column == 0)
- return !(e1.original().toLower() < e2.original().toLower());
- else
- return !(e1.translation(sort_column).toLower() < e2.translation(sort_column).toLower());
- }
-
-private:
- int sort_column;
- Qt::SortOrder sort_order;
-};
-
-
KEduVocDocument::KEduVocDocument(QObject *parent)
: QObject(parent), d(new Private(this))
{
}
-bool KEduVocDocument::sort(int index, Qt::SortOrder order)
-{
- bool result = false;
- if (d->m_sortingEnabled && index < identifierCount())
- {
- if (d->m_sortIdentifier.count() < d->m_identifiers.count())
- for (int i = d->m_sortIdentifier.count(); i < d->m_identifiers.count(); i++)
- d->m_sortIdentifier.append(false);
-
- d->m_sortIdentifier[index] = (order == Qt::AscendingOrder);
- result = sort(index);
- }
- return result;
-}
-
-bool KEduVocDocument::sort(int index)
-{
- bool result = false;
- if (d->m_sortingEnabled && index < identifierCount())
- {
- if (d->m_sortIdentifier.count() < d->m_identifiers.count())
- for (int i = d->m_sortIdentifier.count(); i < d->m_identifiers.count(); i++)
- d->m_sortIdentifier.append(false);
-
- KEduVocDocumentSortHelper sh(index, d->m_sortIdentifier[index] ? Qt::AscendingOrder : Qt::DescendingOrder);
- qSort(d->m_vocabulary.begin(), d->m_vocabulary.end(), sh);
- d->m_sortIdentifier[index] = !d->m_sortIdentifier[index];
- result = d->m_sortIdentifier[index];
- }
- return result;
-}
-
-
-bool KEduVocDocument::sortByLessonAlpha ()
-{
- ///@todo remove?
- return false;
-}
-
-
-bool KEduVocDocument::sortByLessonIndex ()
-{
- ///@todo remove?
- return false;
-}
-
-
void KEduVocDocument::setSortingEnabled(bool enable)
{
d->m_sortingEnabled = enable;
*/
void removeEntry(int index);
- /**
- * Sorts vocabulary alphabetically
- *
- * @param index index identifier (0 = original, 1..n = translations
- * @returns the direction of sorting: true = ascending
- */
- bool sort(int index);
-
- /**
- * Sorts vocabulary alphabetically
- *
- * @param index index identifier (0 = original, 1..n = translations
- * @param order the order used when sorting
- * @returns the direction of sorting: true = ascending
- */
- bool sort(int index, Qt::SortOrder order);
-
/**
* Shuffles vocabulary in a random order
*/
*/
int cleanUp();
- /**
- * Sorts vocabulary by lesson indices
- * @returns direction of sorting: true = ascending
- */
- bool sortByLessonIndex();
-
- /**
- * Sorts vocabulary by lesson name
- * @returns direction of sorting: true = ascending
- */
- bool sortByLessonAlpha();
-
/**
* Enables sorting
*/