1 /** 2 * \file configtable.h 3 * Table with context menu to add, delete and clear rows. 4 * 5 * \b Project: Kid3 6 * \author Urs Fleisch 7 * \date 10 Oct 2005 8 * 9 * Copyright (C) 2005-2018 Urs Fleisch 10 * 11 * This file is part of Kid3. 12 * 13 * Kid3 is free software; you can redistribute it and/or modify 14 * it under the terms of the GNU General Public License as published by 15 * the Free Software Foundation; either version 2 of the License, or 16 * (at your option) any later version. 17 * 18 * Kid3 is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License 24 * along with this program. If not, see <http://www.gnu.org/licenses/>. 25 */ 26 27 #pragma once 28 29 #include <QTableView> 30 #include <QList> 31 #include <QHeaderView> 32 #include "abstractlistedit.h" 33 34 enum class ModelSectionResizeMode : int; 35 36 /** 37 * Context menu commands configuration table. 38 */ 39 class ConfigTable : public AbstractListEdit { 40 Q_OBJECT 41 public: 42 /** 43 * Constructor. 44 * 45 * @param model item model 46 * @param parent parent widget 47 */ 48 explicit ConfigTable(QAbstractItemModel* model, QWidget* parent = nullptr); 49 50 /** 51 * Destructor. 52 */ 53 virtual ~ConfigTable() override = default; 54 55 /** 56 * Set the resize modes to be used for the columns. 57 * @param resizeModes list of resize modes for the columns 58 */ 59 void setHorizontalResizeModes(const QList<ModelSectionResizeMode>& resizeModes); 60 61 public slots: 62 /** 63 * Add a new item. 64 */ 65 virtual void addItem() override; 66 67 /** 68 * Edit the selected item. 69 */ 70 virtual void editItem() override; 71 72 /** 73 * Insert a new row into the table. 74 * 75 * @param row the new row is inserted after this row 76 */ 77 void addRow(int row); 78 79 /** 80 * Delete a row from the table. 81 * 82 * @param row row to delete 83 */ 84 void deleteRow(int row); 85 86 /** 87 * Clear a row in the table. 88 * 89 * @param row row to clear 90 */ 91 void clearRow(int row); 92 93 /** 94 * Execute a context menu action. 95 * 96 * @param action action of selected menu 97 */ 98 void executeAction(QAction* action); 99 100 /** 101 * Display context menu. 102 * 103 * @param row row at which context menu is displayed 104 * @param col column at which context menu is displayed 105 * @param pos position where context menu is drawn on screen 106 */ 107 void contextMenu(int row, int col, const QPoint& pos); 108 109 /** 110 * Display custom context menu. 111 * 112 * @param pos position where context menu is drawn on screen 113 */ 114 void customContextMenu(const QPoint& pos); 115 116 private: 117 QTableView* m_tableView; 118 }; 119