File indexing completed on 2024-03-03 06:06:27

0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2010 Dominik Seichter <domseichter@web.de>
0003 
0004 #ifndef KRENAMETOKENSORTER_H
0005 #define KRENAMETOKENSORTER_H
0006 
0007 #include "krenamefile.h"
0008 
0009 #include <QMap>
0010 #include <QString>
0011 
0012 #include <QUrl>
0013 
0014 class BatchRenamer;
0015 class Plugin;
0016 
0017 bool ascendingKRenameFileLessThan(const KRenameFile &file1, const KRenameFile &file2);
0018 bool descendingKRenameFileLessThan(const KRenameFile &file1, const KRenameFile &file2);
0019 bool numericKRenameFileLessThan(const KRenameFile &file1, const KRenameFile &file2);
0020 
0021 class KRenameTokenSorter
0022 {
0023 public:
0024 
0025     enum ESimpleSortMode {
0026         eSimpleSortMode_Ascending,
0027         eSimpleSortMode_Descending,
0028         eSimpleSortMode_Numeric
0029     };
0030 
0031     KRenameTokenSorter(BatchRenamer *renamer, const QString &token, const KRenameFile::List &list, ESimpleSortMode eSortMode);
0032 
0033     bool operator()(const KRenameFile &file1, const KRenameFile &file2);
0034 
0035 private:
0036     QString processString(int index) const;
0037 
0038 private:
0039     BatchRenamer *m_renamer;
0040     const QString &m_token;
0041     const KRenameFile::List &m_list;
0042     ESimpleSortMode m_eSortMode;
0043     Plugin *m_plugin;
0044     QMap<QUrl, QString> m_values;
0045 };
0046 
0047 #endif // KRENAMETOKENSORTER_H