File indexing completed on 2025-02-23 04:34:19
0001 /** 0002 * \file servertrackimportdialog.h 0003 * Generic dialog for track based import from a server. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 13 Sep 2005 0008 * 0009 * Copyright (C) 2005-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 <QString> 0031 #include <QVector> 0032 0033 class QTableView; 0034 class QLineEdit; 0035 class QLabel; 0036 class QComboBox; 0037 class QPushButton; 0038 class QCheckBox; 0039 class QStatusBar; 0040 class QModelIndex; 0041 class StandardTableModel; 0042 class TrackDataModel; 0043 class ImportTrackData; 0044 class ImportTrackDataVector; 0045 class ServerTrackImporter; 0046 0047 /** 0048 * Generic dialog for track based import from a server. 0049 */ 0050 class ServerTrackImportDialog : public QDialog { 0051 Q_OBJECT 0052 0053 public: 0054 /** 0055 * Constructor. 0056 * 0057 * @param parent parent widget 0058 * @param trackDataModel track data to be filled with imported values, 0059 * is passed with filenames set 0060 */ 0061 ServerTrackImportDialog(QWidget* parent, 0062 TrackDataModel* trackDataModel); 0063 0064 /** 0065 * Destructor. 0066 */ 0067 ~ServerTrackImportDialog() override; 0068 0069 /** 0070 * Set importer to be used. 0071 * 0072 * @param source import source to use 0073 */ 0074 void setImportSource(ServerTrackImporter* source); 0075 0076 /** 0077 * Initialize the table model. 0078 * Has to be called before reusing the dialog with new track data. 0079 */ 0080 void initTable(); 0081 0082 /** 0083 * Get string with server and port. 0084 * 0085 * @return "servername:port". 0086 */ 0087 QString getServer() const; 0088 0089 /** 0090 * Set string with server and port. 0091 * 0092 * @param srv "servername:port" 0093 */ 0094 void setServer(const QString& srv); 0095 0096 signals: 0097 /** 0098 * Emitted when the m_trackDataModel was updated with new imported data. 0099 */ 0100 void trackDataUpdated(); 0101 0102 public slots: 0103 /** 0104 * Shows the dialog as a modal dialog. 0105 */ 0106 int exec() override; 0107 0108 protected slots: 0109 /** 0110 * Hides the dialog and sets the result to QDialog::Accepted. 0111 */ 0112 void accept() override; 0113 0114 /** 0115 * Hides the dialog and sets the result to QDialog::Rejected. 0116 */ 0117 void reject() override; 0118 0119 private slots: 0120 /** 0121 * Apply imported data. 0122 */ 0123 void apply(); 0124 0125 /** 0126 * Set the status of a file. 0127 * 0128 * @param index index of file 0129 * @param status status string 0130 */ 0131 void setFileStatus(int index, const QString& status); 0132 0133 /** 0134 * Update the track data combo box of a file. 0135 * 0136 * @param index index of file 0137 */ 0138 void updateFileTrackData(int index); 0139 0140 /** 0141 * Set result list for a file. 0142 * 0143 * @param index index of file 0144 * @param trackDataVector result list 0145 */ 0146 void setResults(int index, const ImportTrackDataVector& trackDataVector); 0147 0148 /** 0149 * Save the local settings to the configuration. 0150 */ 0151 void saveConfig(); 0152 0153 /** 0154 * Show help. 0155 */ 0156 void showHelp(); 0157 0158 /** 0159 * Show the name of the current track in the status bar. 0160 * 0161 * @param index model index 0162 */ 0163 void showFilenameInStatusBar(const QModelIndex& index); 0164 0165 private: 0166 /** 0167 * Clear all results. 0168 */ 0169 void clearResults(); 0170 0171 /** 0172 * Create and start the track import client. 0173 */ 0174 void startClient(); 0175 0176 /** 0177 * Stop and destroy the track import client. 0178 */ 0179 void stopClient(); 0180 0181 QLabel* m_serverLabel; 0182 QComboBox* m_serverComboBox; 0183 QTableView* m_albumTable; 0184 QPushButton* m_helpButton; 0185 QPushButton* m_saveButton; 0186 StandardTableModel* m_albumTableModel; 0187 QStatusBar* m_statusBar; 0188 ServerTrackImporter* m_client; 0189 TrackDataModel* m_trackDataModel; 0190 QVector<ImportTrackDataVector> m_trackResults; 0191 };