File: oxygenitemmodel.cpp

package info (click to toggle)
oxygen 4%3A6.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 26,896 kB
  • sloc: cpp: 23,036; python: 39; sh: 14; makefile: 5
file content (50 lines) | stat: -rw-r--r-- 1,360 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//////////////////////////////////////////////////////////////////////////////
// itemmodel.cpp
// -------------------
//
// SPDX-FileCopyrightText: 2009-2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
//
// SPDX-License-Identifier: MIT
//////////////////////////////////////////////////////////////////////////////

#include "oxygenitemmodel.h"

namespace Oxygen
{
//_______________________________________________________________
ItemModel::ItemModel(QObject *parent)
    : QAbstractItemModel(parent)
    , _sortColumn(0)
    , _sortOrder(Qt::AscendingOrder)
{
}

//____________________________________________________________
void ItemModel::sort(int column, Qt::SortOrder order)
{
    // store column and order
    _sortColumn = column;
    _sortOrder = order;

    // emit signals and call private methods
    emit layoutAboutToBeChanged();
    privateSort(column, order);
    emit layoutChanged();
}

//____________________________________________________________
QModelIndexList ItemModel::indexes(int column, const QModelIndex &parent) const
{
    QModelIndexList out;
    int rows(rowCount(parent));
    for (int row = 0; row < rows; row++) {
        QModelIndex index(this->index(row, column, parent));
        if (!index.isValid())
            continue;
        out.append(index);
        out += indexes(column, index);
    }

    return out;
}
}