File indexing completed on 2024-05-19 04:50:28
0001 /**************************************************************************************** 0002 * Copyright (c) 2012 Matěj Laitl <matej@laitl.cz> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef STATSYNCING_COMMONMODEL_H 0018 #define STATSYNCING_COMMONMODEL_H 0019 0020 #include "statsyncing/Options.h" 0021 #include "statsyncing/Track.h" 0022 0023 #include <QList> 0024 #include <QVariant> 0025 0026 namespace StatSyncing 0027 { 0028 /** 0029 * Helper class for {Matched,Single}TracksModel's to avoid code duplication 0030 */ 0031 class CommonModel 0032 { 0033 public: 0034 enum { 0035 ResizeModeRole = Qt::UserRole, 0036 FieldRole, 0037 UserRole 0038 }; 0039 static const QSize s_ratingSize; 0040 0041 explicit CommonModel( const QList<qint64> &columns, const Options &options ); 0042 0043 QVariant headerData( int section, Qt::Orientation orientation, 0044 int role = Qt::DisplayRole ) const; 0045 0046 protected: 0047 QVariant sizeHintData( qint64 field ) const; 0048 QVariant textAlignmentData( qint64 field ) const; 0049 0050 QVariant trackData( const TrackPtr &track, qint64 field, int role ) const; 0051 QVariant trackTitleData( const TrackPtr &track ) const; 0052 QVariant trackToolTipData( const TrackPtr &track ) const; 0053 0054 QList<qint64> m_columns; 0055 Options m_options; 0056 }; 0057 0058 } // namespace StatSyncing 0059 0060 #endif // STATSYNCING_COMMONMODEL_H