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

0001 /**
0002  * \file textimportdialog.h
0003  * Dialog to import from a text (file or clipboard).
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 19 Jun 2011
0008  *
0009  * Copyright (C) 2011-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 <QDialog>
0030 #include <QScopedPointer>
0031 
0032 class TextImporter;
0033 class TrackDataModel;
0034 class FormatListEdit;
0035 class IPlatformTools;
0036 
0037 /**
0038  * Dialog to import from a text (file or clipboard).
0039  */
0040 class TextImportDialog : public QDialog {
0041   Q_OBJECT
0042 
0043 public:
0044   /**
0045    * Constructor.
0046    *
0047    * @param platformTools platform tools
0048    * @param parent  parent widget
0049    * @param trackDataModel track data to be filled with imported values
0050    */
0051   TextImportDialog(IPlatformTools* platformTools, QWidget* parent,
0052                    TrackDataModel* trackDataModel);
0053 
0054   /**
0055    * Destructor.
0056    */
0057   ~TextImportDialog() override;
0058 
0059   /**
0060    * Clear dialog data.
0061    */
0062   void clear();
0063 
0064 private slots:
0065   /**
0066    * Let user select file, assign file contents to text and preview in
0067    * table.
0068    */
0069   void fromFile();
0070 
0071   /**
0072    * Assign clipboard contents to text and preview in table.
0073    */
0074   void fromClipboard();
0075 
0076   /**
0077    * Save the local settings to the configuration.
0078    */
0079   void saveConfig();
0080 
0081   /**
0082    * Show help.
0083    */
0084   void showHelp();
0085 
0086 signals:
0087   /**
0088    * Emitted when the m_trackDataVector was updated with new imported data.
0089    */
0090   void trackDataUpdated();
0091 
0092 private:
0093   /**
0094    * Import from a file.
0095    *
0096    * @param fn file name
0097    *
0098    * @return true if ok.
0099    */
0100   bool importFromFile(const QString& fn);
0101 
0102   /**
0103    * Set the format combo box and line edits from the configuration.
0104    */
0105   void setFormatFromConfig();
0106 
0107   IPlatformTools* m_platformTools;
0108   /** format editor */
0109   FormatListEdit* m_formatListEdit;
0110   /** text importer */
0111   QScopedPointer<TextImporter> m_textImporter;
0112 };