File indexing completed on 2024-10-06 04:26:01

0001 /* 
0002     SPDX-FileCopyrightText: 2011 Michal Malek <michalm@jabster.pl>
0003     SPDX-FileCopyrightText: 1998-2007 Sebastian Trueg <trueg@k3b.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef _K3B_MODEL_UTILS_H_
0009 #define _K3B_MODEL_UTILS_H_
0010 
0011 #include <QModelIndexList>
0012 
0013 class QAbstractItemModel;
0014 class QString;
0015 
0016 namespace K3b
0017 {
0018 namespace ModelUtils
0019 {
0020     
0021     /**
0022      * @returns common check state for a specified index list. When indexes has a various check states, Qt::PartiallyChecked is returned.
0023      */
0024     Qt::CheckState commonCheckState( const QModelIndexList& indexes );
0025     
0026     /**
0027      * Toggles check state of a multiple indexes.
0028      */
0029     void toggleCommonCheckState( QAbstractItemModel* model, const QModelIndexList& indexes );
0030     
0031     /**
0032      * @returns common text from a specified index list. When data values are different, a null string is returned.
0033      */
0034     QString commonText( const QModelIndexList& indexes, int role = Qt::DisplayRole );
0035     
0036     /**
0037      * Sets the same text for a multiple model indexes. The data is set when value is non-empty.
0038      */
0039     void setCommonText( QAbstractItemModel* model, const QModelIndexList& indexes, const QString& value, int role = Qt::EditRole );
0040     
0041 } // namespace ModelUtils
0042 } // namespace K3b
0043 
0044 #endif // #ifndef _K3B_MODEL_UTILS_H_