Example #1
0
QList<Task> TaskModel::tasks(const Core::Id &categoryId) const
{
    if (categoryId.uniqueIdentifier() == 0)
        return m_tasks;

    QList<Task> taskList;
    foreach (const Task &t, m_tasks) {
        if (t.category.uniqueIdentifier() == categoryId.uniqueIdentifier())
            taskList.append(t);
    }
    return taskList;
}
Example #2
0
void TaskWindow::setCategoryVisibility(const Core::Id &categoryId, bool visible)
{
    if (categoryId.uniqueIdentifier() == 0)
        return;

    QList<Core::Id> categories = d->m_filter->filteredCategories();

    if (visible) {
        categories.removeOne(categoryId);
    } else {
        categories.append(categoryId);
    }

    d->m_filter->setFilteredCategories(categories);

    int count = 0;
    if (d->m_filter->filterIncludesErrors())
        count += d->m_model->errorTaskCount(categoryId);
    if (d->m_filter->filterIncludesWarnings())
        count += d->m_model->warningTaskCount(categoryId);
    if (visible)
        d->m_badgeCount += count;
    else
        d->m_badgeCount -= count;
    setBadgeNumber(d->m_badgeCount);
}
Example #3
0
void TaskModel::clearTasks(const Core::Id &categoryId)
{
    if (categoryId.uniqueIdentifier() == 0) {
        if (m_tasks.count() == 0)
            return;
        beginRemoveRows(QModelIndex(), 0, m_tasks.count() -1);
        m_tasks.clear();
        foreach (const Core::Id &key, m_categories.keys())
            m_categories[key].clear();
        endRemoveRows();
    } else {
Example #4
0
void TaskWindow::setCategoryVisibility(const Core::Id &categoryId, bool visible)
{
    if (categoryId.uniqueIdentifier() == 0)
        return;

    QList<Core::Id> categories = d->m_filter->filteredCategories();

    if (visible) {
        categories.removeOne(categoryId);
    } else {
        categories.append(categoryId);
    }

    d->m_filter->setFilteredCategories(categories);
}
Example #5
0
void TaskModel::clearTasks(const Core::Id &categoryId)
{
    typedef QHash<Core::Id,CategoryData>::ConstIterator IdCategoryConstIt;

    if (categoryId.uniqueIdentifier() == 0) {
        if (m_tasks.count() == 0)
            return;
        beginRemoveRows(QModelIndex(), 0, m_tasks.count() -1);
        m_tasks.clear();
        const IdCategoryConstIt cend = m_categories.constEnd();
        for (IdCategoryConstIt it = m_categories.constBegin(); it != cend; ++it)
            m_categories[it.key()].clear();
        endRemoveRows();
    } else {
        int index = 0;
        int start = 0;
        CategoryData &global = m_categories[Core::Id()];
        CategoryData &cat = m_categories[categoryId];

        while (index < m_tasks.count()) {
            while (index < m_tasks.count() && m_tasks.at(index).category != categoryId) {
                ++start;
                ++index;
            }
            if (index == m_tasks.count())
                break;
            while (index < m_tasks.count() && m_tasks.at(index).category == categoryId)
                ++index;

            // Index is now on the first non category
            beginRemoveRows(QModelIndex(), start, index - 1);

            for (int i = start; i < index; ++i) {
                global.removeTask(m_tasks.at(i));
                cat.removeTask(m_tasks.at(i));
            }

            m_tasks.erase(m_tasks.begin() + start, m_tasks.begin() + index);

            endRemoveRows();
            index = start;
        }
    }
    m_maxSizeOfFileName = 0;
    m_lastMaxSizeIndex = 0;
}
Example #6
0
void TaskWindow::clearTasks(const Core::Id &categoryId)
{
    if (categoryId.uniqueIdentifier() != 0 && !d->m_filter->filteredCategories().contains(categoryId)) {
        if (d->m_filter->filterIncludesErrors())
            d->m_badgeCount -= d->m_model->errorTaskCount(categoryId);
        if (d->m_filter->filterIncludesWarnings())
            d->m_badgeCount -= d->m_model->warningTaskCount(categoryId);
        if (d->m_filter->filterIncludesUnknowns())
            d->m_badgeCount -= d->m_model->unknownTaskCount(categoryId);
    } else {
        d->m_badgeCount = 0;
    }

    d->m_model->clearTasks(categoryId);

    emit tasksChanged();
    emit tasksCleared();
    navigateStateChanged();

    setBadgeNumber(d->m_badgeCount);
}