File indexing completed on 2024-04-28 16:31:57
0001 /*************************************************************************** 0002 Copyright (C) 2002-2009 Robby Stephenson <robby@periapsis.org> 0003 Copyright (C) 2011 Pedro Miguel Carvalho <kde@pmc.com.pt> 0004 ***************************************************************************/ 0005 0006 /*************************************************************************** 0007 * * 0008 * This program is free software; you can redistribute it and/or * 0009 * modify it under the terms of the GNU General Public License as * 0010 * published by the Free Software Foundation; either version 2 of * 0011 * the License or (at your option) version 3 or any later version * 0012 * accepted by the membership of KDE e.V. (or its successor approved * 0013 * by the membership of KDE e.V.), which shall act as a proxy * 0014 * defined in Section 14 of version 3 of the license. * 0015 * * 0016 * This program is distributed in the hope that it will be useful, * 0017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0019 * GNU General Public License for more details. * 0020 * * 0021 * You should have received a copy of the GNU General Public License * 0022 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0023 * * 0024 ***************************************************************************/ 0025 0026 #ifndef TELLICO_ENTRYICONVIEW_H 0027 #define TELLICO_ENTRYICONVIEW_H 0028 0029 #include "observer.h" 0030 0031 #include <QListView> 0032 0033 namespace { 0034 static const int MIN_ENTRY_ICON_SIZE = 64; 0035 static const int MAX_ENTRY_ICON_SIZE = 512; 0036 static const int SMALL_INCREMENT_ICON_SIZE = 1; 0037 static const int LARGE_INCREMENT_ICON_SIZE = 8; 0038 } 0039 0040 namespace Tellico { 0041 0042 /** 0043 * @author Robby Stephenson 0044 */ 0045 class EntryIconView : public QListView, public Observer { 0046 Q_OBJECT 0047 0048 public: 0049 EntryIconView(QWidget* parent); 0050 ~EntryIconView(); 0051 0052 void setModel(QAbstractItemModel* model) Q_DECL_OVERRIDE; 0053 int maxAllowedIconWidth() const { return m_maxAllowedIconWidth; } 0054 0055 public Q_SLOTS: 0056 void setMaxAllowedIconWidth(int width); 0057 0058 protected: 0059 void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE; 0060 0061 private Q_SLOTS: 0062 void slotDoubleClicked(const QModelIndex& index); 0063 void slotSortMenuActivated(QAction* action); 0064 void slotOpenUrlMenuActivated(QAction* action=nullptr); 0065 void updateModelColumn(); 0066 0067 private: 0068 int m_maxAllowedIconWidth; 0069 }; 0070 0071 } // end namespace 0072 #endif