File indexing completed on 2025-02-23 04:34:25

0001 /**
0002  * \file timestampdelegate.h
0003  * Delegate for time stamps in synchronized lyrics and event timing codes.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 14 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 <QItemDelegate>
0030 
0031 /**
0032  * Delegate for time stamps in synchronized lyrics and event timing codes.
0033  */
0034 class TimeStampDelegate : public QItemDelegate {
0035   Q_OBJECT
0036 public:
0037   /**
0038    * Constructor.
0039    * @param parent parent object
0040    */
0041   explicit TimeStampDelegate(QObject* parent);
0042 
0043   /**
0044    * Destructor.
0045    */
0046   ~TimeStampDelegate() override = default;
0047 
0048   /**
0049    * Create an editor to edit the cell contents.
0050    * @param parent parent widget
0051    * @param option style
0052    * @param index  index of item
0053    * @return time editor widget.
0054    */
0055   QWidget* createEditor(
0056     QWidget* parent, const QStyleOptionViewItem& option,
0057     const QModelIndex& index) const override;
0058 
0059   /**
0060    * Render delegate.
0061    * @param painter painter to be used
0062    * @param option style
0063    * @param index index of item
0064    */
0065   void paint(QPainter* painter, const QStyleOptionViewItem& option,
0066              const QModelIndex& index) const override;
0067 
0068 private slots:
0069   void commitAndCloseEditor();
0070 };