Warning, file /multimedia/amarok/src/dialogs/TrackOrganizer.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /*************************************************************************** 0002 * Copyright (c) 2010 Casey Link <unnamedrambler@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU General Public License as published by * 0006 * the Free Software Foundation; either version 2 of the License, or * 0007 * (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the * 0016 * Free Software Foundation, Inc., * 0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0018 ***************************************************************************/ 0019 0020 #ifndef TRACKORGANIZER_H 0021 #define TRACKORGANIZER_H 0022 0023 #include "amarok_export.h" 0024 #include "core/meta/forward_declarations.h" 0025 0026 #include <QObject> 0027 #include <QMap> 0028 0029 /** 0030 * Generates a list of paths formatted according to the specified 0031 * format string. 0032 * @author Casey Link 0033 */ 0034 class AMAROK_EXPORT TrackOrganizer : public QObject 0035 { 0036 Q_OBJECT 0037 public: 0038 explicit TrackOrganizer( const Meta::TrackList &tracks, QObject* parent = nullptr ); 0039 0040 /** 0041 * Sets the format string. Required. 0042 * @param format the format, e.g., %artist - %title.%filetype 0043 */ 0044 void setFormatString( const QString &format ); 0045 /** 0046 * Sets the folder (i.e. collection prefix) 0047 * @param prefix the folder prefix, e.g., /home/user/Music/ 0048 */ 0049 void setFolderPrefix( const QString &prefix ); 0050 0051 /** 0052 * Sets whether to move the "the" in an artist name to the end of the name. 0053 * Default value is false. 0054 * @param flag turns the option on 0055 */ 0056 void setPostfixThe( bool flag ); 0057 /** 0058 * Sets whether to restrict filenames to ASCII 0059 * Default value is false. 0060 * @param flag turns the option on 0061 */ 0062 void setAsciiOnly( bool flag ); 0063 /** 0064 * Sets whether to replaces spaces with underscores.auto 0065 * Default value is false. 0066 * @param flag turns the option on 0067 */ 0068 void setReplaceSpaces( bool flag ); 0069 /** 0070 * Sets whether to restrict filenames to VFAT safe names. 0071 * Default value is false. 0072 * @param flag turns the option on 0073 */ 0074 void setVfatSafe( bool flag); 0075 /** 0076 * Sets a regex and replacement string to perform custom replacement 0077 * @param regex the regex value 0078 * @param string the string substitute for the regex match 0079 */ 0080 void setReplace( const QString ®ex, const QString &string ); 0081 /** 0082 * Sets a new file extension for the target file names. 0083 * @param fileExtension the file extension 0084 */ 0085 void setTargetFileExtension( const QString &fileExtension ); 0086 0087 /** 0088 * Get the list of processed destinations 0089 * Only call after setting all the appropriate options 0090 * @see setFormatString 0091 * @arg batchSize How many to return this run of the function. If 0 (default) will calculate the 0092 * complete list. This function can return a shorter list at the end of the results list. 0093 * Over consecutive runs of this function the same number of results as the length of the 0094 * tracklist passed in the constructor will be returned. 0095 */ 0096 QMap<Meta::TrackPtr, QString> getDestinations( unsigned int batchSize = 0 ); 0097 0098 /** Call this function if you want getDestinations to return results starting from the 0099 first track. */ 0100 void resetTrackOffset() { m_trackOffset = 0; } 0101 0102 0103 private: 0104 QString buildDestination( const QString &format, const Meta::TrackPtr &track ) const; 0105 QString cleanPath( const QString &path ) const; 0106 0107 /** Returns the number of characters that are the same in both strings beginning. */ 0108 static int commonPrefixLength( const QString &a, const QString &b ); 0109 0110 Meta::TrackList m_allTracks; 0111 /** The starting track that is to be processed. */ 0112 int m_trackOffset; 0113 0114 //options 0115 QString m_format; 0116 QString m_folderPrefix; 0117 bool m_postfixThe; 0118 bool m_AsciiOnly; 0119 bool m_UnderscoresNotSpaces; 0120 bool m_vfatSafe; 0121 QString m_regexPattern; 0122 QString m_replaceString; 0123 QString m_targetFileExtension; 0124 }; 0125 0126 #endif // TRACKORGANIZER_H