File indexing completed on 2024-05-12 05:12:40
0001 /* 0002 Copyright (C) 2012 Kevin Krammer <krammer@kde.org> 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 along 0015 with this program; if not, write to the Free Software Foundation, Inc., 0016 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 0017 */ 0018 0019 #ifndef ADDCOMMAND_H 0020 #define ADDCOMMAND_H 0021 0022 #include "abstractcommand.h" 0023 0024 #include <Akonadi/Collection> 0025 0026 #include <QHash> 0027 #include <QMap> 0028 #include <QSet> 0029 #include <QMimeType> 0030 0031 class KJob; 0032 0033 class AddCommand : public AbstractCommand 0034 { 0035 Q_OBJECT 0036 0037 public: 0038 enum AddDirectoryMode { 0039 AddDirOnly = 0, 0040 AddRecursive 0041 }; 0042 0043 explicit AddCommand(QObject *parent = nullptr); 0044 virtual ~AddCommand() = default; 0045 0046 QString name() const override; 0047 0048 public Q_SLOTS: 0049 void start() override; 0050 0051 protected: 0052 void setupCommandOptions(QCommandLineParser *parser) override; 0053 int initCommand(QCommandLineParser *parser) override; 0054 0055 private: 0056 QSet<QString> mFiles; 0057 QMap<QString, AddDirectoryMode> mDirectories; 0058 QHash<QString, Akonadi::Collection> mCollectionsByPath; 0059 QString mBasePath; 0060 QHash<QString, QString> mBasePaths; 0061 bool mFlatMode; 0062 Akonadi::Collection mBaseCollection; 0063 QMimeType mMimeType; 0064 0065 private Q_SLOTS: 0066 void processNextDirectory(); 0067 void processNextFile(); 0068 void onTargetFetched(KJob *job); 0069 void onCollectionCreated(KJob *job); 0070 void onCollectionFetched(KJob *job); 0071 void onItemCreated(KJob *job); 0072 }; 0073 0074 #endif // ADDCOMMAND_H