File indexing completed on 2024-04-28 05:08:17
0001 /*************************************************************************** 0002 Copyright (C) 2001-2009 Robby Stephenson <robby@periapsis.org> 0003 ***************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or * 0008 * modify it under the terms of the GNU General Public License as * 0009 * published by the Free Software Foundation; either version 2 of * 0010 * the License or (at your option) version 3 or any later version * 0011 * accepted by the membership of KDE e.V. (or its successor approved * 0012 * by the membership of KDE e.V.), which shall act as a proxy * 0013 * defined in Section 14 of version 3 of the license. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0022 * * 0023 ***************************************************************************/ 0024 0025 #ifndef TELLICO_DETAILEDLISTVIEW_H 0026 #define TELLICO_DETAILEDLISTVIEW_H 0027 0028 #include "gui/treeview.h" 0029 #include "observer.h" 0030 #include "filter.h" 0031 0032 #include <QStringList> 0033 #include <QEvent> 0034 #include <QVector> 0035 0036 class QMenu; 0037 0038 namespace Tellico { 0039 class DetailedEntryItem; 0040 class EntryModel; 0041 0042 /** 0043 * The DetailedListView class shows detailed information about entries in the 0044 * collection. 0045 * 0046 * @author Robby Stephenson 0047 */ 0048 class DetailedListView : public GUI::TreeView, public Observer { 0049 Q_OBJECT 0050 0051 public: 0052 /** 0053 * The constructor initializes the popup menu, but no columns are inserted. 0054 * 0055 * @param parent A pointer to the parent widget 0056 */ 0057 DetailedListView(QWidget* parent); 0058 virtual ~DetailedListView(); 0059 0060 EntryModel* sourceModel() const; 0061 0062 /** 0063 * Event filter used to popup the menu 0064 */ 0065 bool eventFilter(QObject* obj, QEvent* ev) Q_DECL_OVERRIDE; 0066 /** 0067 * Selects the item which refers to a certain entry. 0068 * 0069 * @param entry A pointer to the entry 0070 */ 0071 void setEntriesSelected(Data::EntryList entries); 0072 void setFilter(FilterPtr filter); 0073 FilterPtr filter() const; 0074 0075 QString sortColumnTitle1() const; 0076 QString sortColumnTitle2() const; 0077 QString sortColumnTitle3() const; 0078 QStringList visibleColumns() const; 0079 Data::EntryList visibleEntries(); 0080 0081 /** 0082 * @param coll A pointer to the collection 0083 */ 0084 void addCollection(Data::CollPtr coll); 0085 /** 0086 * Removes all items which refers to a entry within a collection. 0087 * 0088 * @param coll A pointer to the collection 0089 */ 0090 void removeCollection(Data::CollPtr coll); 0091 0092 /** 0093 * Adds a new list item showing the details for a entry. 0094 * 0095 * @param entry A pointer to the entry 0096 */ 0097 virtual void addEntries(Data::EntryList entries) Q_DECL_OVERRIDE; 0098 /** 0099 * Modifies any item which refers to a entry, resetting the column contents. 0100 * 0101 * @param entry A pointer to the entry 0102 */ 0103 virtual void modifyEntries(Data::EntryList entries) Q_DECL_OVERRIDE; 0104 /** 0105 * Removes any item which refers to a certain entry. 0106 * 0107 * @param entry A pointer to the entry 0108 */ 0109 virtual void removeEntries(Data::EntryList entries) Q_DECL_OVERRIDE; 0110 0111 virtual void addField(Data::CollPtr, Data::FieldPtr field) Q_DECL_OVERRIDE; 0112 void addField(Data::FieldPtr field, int width); 0113 virtual void modifyField(Data::CollPtr, Data::FieldPtr oldField, Data::FieldPtr newField) Q_DECL_OVERRIDE; 0114 virtual void removeField(Data::CollPtr, Data::FieldPtr field) Q_DECL_OVERRIDE; 0115 0116 void reorderFields(const Data::FieldList& fields); 0117 /** 0118 * saveConfig is only needed for custom collections */ 0119 void saveConfig(Data::CollPtr coll, int saveConfig); 0120 /** 0121 * Select all visible items. 0122 */ 0123 void selectAllVisible(); 0124 int visibleItems() const; 0125 void resetEntryStatus(); 0126 0127 public Q_SLOTS: 0128 /** 0129 * Resets the list view, clearing and deleting all items. 0130 */ 0131 void slotReset(); 0132 /** 0133 * Refreshes the view, repopulating all items. 0134 */ 0135 void slotRefresh(); 0136 void slotRefreshImages(); 0137 0138 private Q_SLOTS: 0139 void slotDoubleClicked(const QModelIndex& index); 0140 void slotColumnMenuActivated(QAction* action); 0141 void updateHeaderMenu(); 0142 void showAllColumns(); 0143 void hideAllColumns(); 0144 void hideCurrentColumn(); 0145 void resizeColumnsToContents(); 0146 void hideNewColumn(const QModelIndex& index, int start, int end); 0147 // void slotCacheColumnWidth(int section, int oldSize, int newSize); 0148 void updateColumnDelegates(); 0149 0150 private: 0151 void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE; 0152 void setState(Tellico::Data::EntryList entries_, int state); 0153 void adjustColumnWidths(); 0154 void checkHeader(); 0155 QString columnFieldName(int ncol) const; 0156 0157 struct ConfigInfo { 0158 QStringList cols; 0159 QList<int> widths; 0160 QList<int> order; 0161 int prevSort; 0162 int prev2Sort; 0163 int sortOrder; 0164 }; 0165 0166 QMenu* m_headerMenu; 0167 QMenu* m_columnMenu; 0168 bool m_loadingCollection; 0169 int m_currentContextColumn; 0170 }; 0171 0172 } // end namespace; 0173 #endif