File indexing completed on 2025-02-23 04:34:25
0001 /** 0002 * \file timeeventeditor.h 0003 * Editor for time events (synchronized lyrics and event timing codes). 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 15 Mar 2014 0008 * 0009 * Copyright (C) 2014-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 <QWidget> 0030 #include "frame.h" 0031 0032 class QLabel; 0033 class QModelIndex; 0034 class IPlatformTools; 0035 class Kid3Application; 0036 class TimeEventModel; 0037 class EventCodeDelegate; 0038 class TaggedFile; 0039 class TimeEventTableView; 0040 0041 /** 0042 * Editor for time events (synchronized lyrics and event timing codes). 0043 */ 0044 class TimeEventEditor : public QWidget { 0045 Q_OBJECT 0046 public: 0047 /** 0048 * Constructor. 0049 * 0050 * @param platformTools platform tools 0051 * @param app application context 0052 * @param parent parent widget 0053 * @param field field containing binary data 0054 * @param taggedFile tagged file 0055 * @param tagNr tag number 0056 */ 0057 TimeEventEditor(IPlatformTools* platformTools, Kid3Application* app, 0058 QWidget* parent, const Frame::Field& field, 0059 const TaggedFile* taggedFile, Frame::TagNumber tagNr); 0060 0061 /** 0062 * Destructor. 0063 */ 0064 ~TimeEventEditor() override = default; 0065 0066 /** 0067 * Set time event model. 0068 * @param model time event model 0069 */ 0070 void setModel(TimeEventModel* model); 0071 0072 protected: 0073 /** 0074 * Connect to player when editor is shown. 0075 * @param event event 0076 */ 0077 void showEvent(QShowEvent* event) override; 0078 0079 /** 0080 * Disconnect from player when editor is hidden. 0081 * @param event event 0082 */ 0083 void hideEvent(QHideEvent* event) override; 0084 0085 private slots: 0086 /** 0087 * Make sure that player is visible and in the edited file. 0088 */ 0089 void preparePlayer(); 0090 0091 /** 0092 * Add a time event at the current player position. 0093 */ 0094 void addItem(); 0095 0096 /** 0097 * Load LRC data from clipboard. 0098 */ 0099 void clipData(); 0100 0101 /** 0102 * Import data in LRC format. 0103 */ 0104 void importData(); 0105 0106 /** 0107 * Export data in LRC format. 0108 */ 0109 void exportData(); 0110 0111 /** 0112 * Insert a new row after the current row. 0113 */ 0114 void insertRow(); 0115 0116 /** 0117 * Delete the selected rows. 0118 */ 0119 void deleteRows(); 0120 0121 /** 0122 * Clear the selected cells. 0123 */ 0124 void clearCells(); 0125 0126 /** 0127 * Add offset to time stamps. 0128 */ 0129 void addOffset(); 0130 0131 /** 0132 * Seek to position of current time stamp. 0133 */ 0134 void seekPosition(); 0135 0136 /** 0137 * Display custom context menu. 0138 * 0139 * @param pos position where context menu is drawn on screen 0140 */ 0141 void customContextMenu(const QPoint& pos); 0142 0143 /** 0144 * Called when the played track changed. 0145 * @param filePath path to file being played 0146 */ 0147 void onTrackChanged(const QString& filePath); 0148 0149 /** 0150 * Called when the player position changed. 0151 * @param position time in ms 0152 */ 0153 void onPositionChanged(qint64 position); 0154 0155 /** 0156 * Show help. 0157 */ 0158 void showHelp(); 0159 0160 private: 0161 QString getLrcNameFilter() const; 0162 0163 IPlatformTools* m_platformTools; 0164 Kid3Application* m_app; 0165 QLabel* m_label; 0166 TimeEventTableView* m_tableView; 0167 EventCodeDelegate* m_eventCodeDelegate; 0168 TimeEventModel* m_model; 0169 const TaggedFile* m_taggedFile; 0170 Frame::TagNumber m_tagNr; 0171 QByteArray m_byteArray; 0172 bool m_fileIsPlayed; 0173 };