File indexing completed on 2025-02-23 04:34:24
0001 /** 0002 * \file frametable.h 0003 * Table to edit frames. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 05 Sep 2007 0008 * 0009 * Copyright (C) 2007-2024 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include <QTableView> 0030 0031 class QAction; 0032 class QPoint; 0033 class FrameTableModel; 0034 class GenreModel; 0035 0036 /** 0037 * Table to edit frames. 0038 */ 0039 class FrameTable : public QTableView { 0040 Q_OBJECT 0041 public: 0042 /** 0043 * Constructor. 0044 * 0045 * @param model frame table model 0046 * @param genreModel genre model 0047 * @param parent parent widget 0048 */ 0049 explicit FrameTable(FrameTableModel* model, GenreModel* genreModel, 0050 QWidget* parent = nullptr); 0051 0052 /** 0053 * Destructor. 0054 */ 0055 ~FrameTable() override = default; 0056 0057 /** 0058 * Filters events if this object has been installed as an event filter 0059 * for the watched object. 0060 * This method is reimplemented to keep track of the current open editor. 0061 * It has to be installed on the viewport of the table. 0062 * @param watched watched object 0063 * @param event event 0064 * @return true to filter event out. 0065 */ 0066 bool eventFilter(QObject* watched, QEvent* event) override; 0067 0068 /** 0069 * Commit data from the current editor. 0070 * This is used to avoid losing the changes in open editors e.g. when 0071 * the file is changed using Alt-Up or Alt-Down. 0072 * 0073 * @return true if data was committed. 0074 */ 0075 bool acceptEdit(); 0076 0077 /** 0078 * Get current editor widget if the table is currently in edit state. 0079 * @return current editor widget, 0 if not in edit state. 0080 */ 0081 const QWidget* getCurrentEditor() const; 0082 0083 /** 0084 * Select in the editor of a value row. 0085 * @param row row number 0086 * @param start start position 0087 * @param length number of characters to select 0088 */ 0089 void setValueSelection(int row, int start, int length); 0090 0091 private slots: 0092 /** 0093 * Display context menu. 0094 * 0095 * @param row row at which context menu is displayed 0096 * @param col column at which context menu is displayed 0097 * @param pos position where context menu is drawn on screen 0098 */ 0099 void contextMenu(int row, int col, const QPoint& pos); 0100 0101 /** 0102 * Display custom context menu. 0103 * 0104 * @param pos position where context menu is drawn on screen 0105 */ 0106 void customContextMenu(const QPoint& pos); 0107 0108 private: 0109 QWidget* m_currentEditor; 0110 };