File indexing completed on 2024-05-05 04:40:55

0001 /*
0002     SPDX-FileCopyrightText: 2018 Amish K. Naidu <amhndu@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef SCRATCHPAD_H
0008 #define SCRATCHPAD_H
0009 
0010 #include <interfaces/iplugin.h>
0011 
0012 #include <QFileIconProvider>
0013 
0014 class ScratchpadToolViewFactory;
0015 
0016 class QStandardItemModel;
0017 class QModelIndex;
0018 class QFileInfo;
0019 class QString;
0020 class QAction;
0021 
0022 class Scratchpad
0023     : public KDevelop::IPlugin
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028     Scratchpad(QObject* parent, const QVariantList& args);
0029 
0030     QStandardItemModel* model() const;
0031 
0032     QAction* runAction() const;
0033 
0034     static QString dataDirectory();
0035 
0036     void createActionsForMainWindow(Sublime::MainWindow* window, QString& xmlFile, KActionCollection& actions) override;
0037 
0038     enum ExtraRoles {
0039         FullPathRole = Qt::UserRole + 1,
0040         RunCommandRole,
0041     };
0042 
0043 public Q_SLOTS:
0044     void openScratch(const QModelIndex& index);
0045     void runScratch(const QModelIndex& index);
0046     void removeScratch(const QModelIndex& index);
0047     void createScratch(const QString& name);
0048     void renameScratch(const QModelIndex& index, const QString& previousName);
0049     void setCommand(const QModelIndex& index, const QString& command);
0050 
0051 Q_SIGNALS:
0052     void actionFailed(const QString& message);
0053 
0054 private:
0055     void addFileToModel(const QFileInfo& fileInfo);
0056 
0057     ScratchpadToolViewFactory* m_factory;
0058     QStandardItemModel* m_model;
0059     QFileIconProvider m_iconProvider;
0060 
0061     QAction* const m_runAction;
0062 };
0063 
0064 #endif // SCRATCHPAD_H