| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#ifndef AVOGADRO_QTPLUGINS_SCRIPTFILEFORMATS_H |
| 7 |
#define AVOGADRO_QTPLUGINS_SCRIPTFILEFORMATS_H |
| 8 |
|
| 9 |
#include <avogadro/core/avogadrocore.h> |
| 10 |
#include <avogadro/qtgui/extensionplugin.h> |
| 11 |
|
| 12 |
#include <QtCore/QMultiHash> |
| 13 |
#include <QtCore/QVariant> |
| 14 |
|
| 15 |
namespace Avogadro { |
| 16 |
namespace QtPlugins { |
| 17 |
|
| 18 |
/** |
| 19 |
* @brief This extension registers FileFormat reader/writers that are |
| 20 |
* implemented as external scripts. |
| 21 |
*/ |
| 22 |
class ScriptFileFormats : public QtGui::ExtensionPlugin |
| 23 |
{ |
| 24 |
Q_OBJECT |
| 25 |
|
| 26 |
public: |
| 27 |
explicit ScriptFileFormats(QObject* parent = nullptr); |
| 28 |
~ScriptFileFormats() override; |
| 29 |
|
| 30 |
QString name() const override { return tr("Script File Formats"); } |
| 31 |
|
| 32 |
QString description() const override |
| 33 |
{ |
| 34 |
return tr("Load file reader/writers from external scripts."); |
| 35 |
} |
| 36 |
|
| 37 |
QList<QAction*> actions() const override; |
| 38 |
|
| 39 |
QStringList menuPath(QAction*) const override; |
| 40 |
|
| 41 |
void setMolecule(QtGui::Molecule* mol) override; |
| 42 |
|
| 43 |
/** |
| 44 |
* Handle a feature registered by PackageManager. |
| 45 |
*/ |
| 46 |
void registerFeature(const QString& type, const QString& packageDir, |
| 47 |
const QString& command, const QString& identifier, |
| 48 |
const QVariantMap& metadata); |
| 49 |
|
| 50 |
/** |
| 51 |
* Handle a feature removed by PackageManager. |
| 52 |
*/ |
| 53 |
void unregisterFeature(const QString& type, const QString& packageDir, |
| 54 |
const QString& command, const QString& identifier); |
| 55 |
|
| 56 |
private: |
| 57 |
QList<Io::FileFormat*> m_formats; |
| 58 |
QMultiHash<QString, QString> m_packageFormats; |
| 59 |
|
| 60 |
void refreshFileFormats(); |
| 61 |
void unregisterFileFormats(); |
| 62 |
void registerFileFormats(); |
| 63 |
}; |
| 64 |
} // namespace QtPlugins |
| 65 |
} // namespace Avogadro |
| 66 |
|
| 67 |
#endif // AVOGADRO_QTPLUGINS_QUANTUMOUTPUT_H |