File indexing completed on 2024-05-19 05:28:47
0001 ////////////////////////////////////////////////////////////////////////////// 0002 // itemmodel.cpp 0003 // ------------------- 0004 // 0005 // SPDX-FileCopyrightText: 2009-2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0006 // 0007 // SPDX-License-Identifier: MIT 0008 ////////////////////////////////////////////////////////////////////////////// 0009 0010 #include "breezeitemmodel.h" 0011 0012 namespace Breeze 0013 { 0014 //_______________________________________________________________ 0015 ItemModel::ItemModel(QObject *parent) 0016 : QAbstractItemModel(parent) 0017 { 0018 } 0019 0020 //____________________________________________________________ 0021 void ItemModel::sort(int column, Qt::SortOrder order) 0022 { 0023 // store column and order 0024 m_sortColumn = column; 0025 m_sortOrder = order; 0026 0027 // emit signals and call private methods 0028 emit layoutAboutToBeChanged(); 0029 privateSort(column, order); 0030 emit layoutChanged(); 0031 } 0032 0033 //____________________________________________________________ 0034 QModelIndexList ItemModel::indexes(int column, const QModelIndex &parent) const 0035 { 0036 QModelIndexList out; 0037 int rows(rowCount(parent)); 0038 for (int row = 0; row < rows; row++) { 0039 QModelIndex index(this->index(row, column, parent)); 0040 if (!index.isValid()) { 0041 continue; 0042 } 0043 out.append(index); 0044 out += indexes(column, index); 0045 } 0046 0047 return out; 0048 } 0049 0050 }