Commit 61a8257b authored by hjk's avatar hjk

Core: Clean up ExternalToolsManager interface

Change-Id: I8ea81de7350bdb0c6243d65596196d615845ffc4
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 9d1cc971
This diff is collapsed.
......@@ -37,30 +37,23 @@
#include <QList>
#include <QString>
QT_FORWARD_DECLARE_CLASS(QAction)
namespace Core {
class ActionContainer;
namespace Internal {
class ExternalToolRunner;
class ExternalTool;
}
namespace Internal { class ExternalTool; }
class CORE_EXPORT ExternalToolManager : public QObject
{
Q_OBJECT
public:
static ExternalToolManager *instance() { return m_instance; }
ExternalToolManager();
~ExternalToolManager();
QMap<QString, QList<Internal::ExternalTool *> > toolsByCategory() const;
QMap<QString, Internal::ExternalTool *> toolsById() const;
void setToolsByCategory(const QMap<QString, QList<Internal::ExternalTool *> > &tools);
static QObject *instance();
static QMap<QString, QList<Internal::ExternalTool *> > toolsByCategory();
static QMap<QString, Internal::ExternalTool *> toolsById();
static void setToolsByCategory(const QMap<QString, QList<Internal::ExternalTool *> > &tools);
static void emitReplaceSelectionRequested(const QString &output);
signals:
void replaceSelectionRequested(const QString &text);
......@@ -68,30 +61,9 @@ signals:
private slots:
void menuActivated();
void openPreferences();
private:
void initialize();
void parseDirectory(const QString &directory,
QMap<QString, QMultiMap<int, Internal::ExternalTool*> > *categoryMenus,
QMap<QString, Internal::ExternalTool *> *tools,
bool isPreset = false);
void readSettings(const QMap<QString, Internal::ExternalTool *> &tools,
QMap<QString, QList<Internal::ExternalTool*> > *categoryPriorityMap);
void writeSettings();
static ExternalToolManager *m_instance;
QMap<QString, Internal::ExternalTool *> m_tools;
QMap<QString, QList<Internal::ExternalTool *> > m_categoryMap;
QMap<QString, QAction *> m_actions;
QMap<QString, ActionContainer *> m_containers;
QAction *m_configureSeparator;
QAction *m_configureAction;
// for sending the replaceSelectionRequested signal
friend class Core::Internal::ExternalToolRunner;
};
} // Core
} // namespace Core
#endif // EXTERNALTOOLMANAGER_H
......@@ -64,13 +64,12 @@ bool ToolSettings::matches(const QString & searchKeyWord) const
QWidget *ToolSettings::createPage(QWidget *parent)
{
m_widget = new ExternalToolConfig(parent);
m_widget->setTools(ExternalToolManager::instance()->toolsByCategory());
m_widget->setTools(ExternalToolManager::toolsByCategory());
if (m_searchKeywords.isEmpty())
m_searchKeywords = m_widget->searchKeywords();
return m_widget;
}
static QString getUserFilePath(const QString &proposalFileName)
{
QDir resourceDir(ICore::userResourcePath());
......@@ -132,7 +131,7 @@ void ToolSettings::apply()
if (!m_widget)
return;
m_widget->apply();
QMap<QString, ExternalTool *> originalTools = ExternalToolManager::instance()->toolsById();
QMap<QString, ExternalTool *> originalTools = ExternalToolManager::toolsById();
QMap<QString, QList<ExternalTool *> > newToolsMap = m_widget->tools();
QMap<QString, QList<ExternalTool *> > resultMap;
QMapIterator<QString, QList<ExternalTool *> > it(newToolsMap);
......@@ -202,10 +201,9 @@ void ToolSettings::apply()
QFile::remove(tool->fileName());
}
ExternalToolManager::instance()->setToolsByCategory(resultMap);
ExternalToolManager::setToolsByCategory(resultMap);
}
void ToolSettings::finish()
{
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment