Commit 4334309e authored by con's avatar con
Browse files

Add more editing of tools. Doesn't save yet.

parent 0c1d21fb
......@@ -47,9 +47,10 @@ ExternalToolConfig::ExternalToolConfig(QWidget *parent) :
ui->setupUi(this);
ui->toolTree->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed);
connect(ui->toolTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
this, SLOT(showInfoForItem(QTreeWidgetItem*)));
this, SLOT(handleCurrentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
connect(ui->toolTree, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
this, SLOT(updateItem(QTreeWidgetItem *)));
this, SLOT(updateItemName(QTreeWidgetItem *)));
showInfoForItem(0);
}
......@@ -108,6 +109,34 @@ void ExternalToolConfig::setTools(const QMap<QString, QList<ExternalTool *> > &t
ui->toolTree->blockSignals(blocked); // unblock itemChanged
}
void ExternalToolConfig::handleCurrentItemChanged(QTreeWidgetItem *now, QTreeWidgetItem *previous)
{
updateItem(previous);
showInfoForItem(now);
}
void ExternalToolConfig::updateItem(QTreeWidgetItem *item)
{
ExternalTool *tool = 0;
if (item)
tool = item->data(0, Qt::UserRole).value<ExternalTool *>();
if (!tool)
return;
tool->setDescription(ui->description->text());
QStringList executables = tool->executables();
if (executables.size() > 0)
executables[0] = ui->executable->path();
else
executables << ui->executable->path();
tool->setExecutables(executables);
tool->setArguments(ui->arguments->text());
tool->setWorkingDirectory(ui->workingDirectory->path());
tool->setOutputHandling((ExternalTool::OutputHandling)ui->outputBehavior->currentIndex());
tool->setErrorHandling((ExternalTool::OutputHandling)ui->errorOutputBehavior->currentIndex());
tool->setModifiesCurrentDocument(ui->modifiesDocumentCheckbox->checkState());
tool->setInput(ui->inputText->toPlainText());
}
void ExternalToolConfig::showInfoForItem(QTreeWidgetItem *item)
{
ExternalTool *tool = 0;
......@@ -135,7 +164,7 @@ void ExternalToolConfig::showInfoForItem(QTreeWidgetItem *item)
ui->arguments->setCursorPosition(0);
}
void ExternalToolConfig::updateItem(QTreeWidgetItem *item)
void ExternalToolConfig::updateItemName(QTreeWidgetItem *item)
{
ExternalTool *tool = 0;
if (item)
......@@ -182,3 +211,13 @@ void ExternalToolConfig::updateItem(QTreeWidgetItem *item)
ui->toolTree->blockSignals(blocked); // unblock itemChanged
}
}
QMap<QString, QList<ExternalTool *> > ExternalToolConfig::tools() const
{
return m_tools;
}
void ExternalToolConfig::apply()
{
updateItem(ui->toolTree->currentItem());
}
......@@ -55,13 +55,16 @@ public:
~ExternalToolConfig();
void setTools(const QMap<QString, QList<ExternalTool *> > &tools);
QMap<QString, QList<ExternalTool *> > tools() const { return m_tools; }
QMap<QString, QList<ExternalTool *> > tools() const;
void apply();
QString searchKeywords() const;
private slots:
void handleCurrentItemChanged(QTreeWidgetItem *now, QTreeWidgetItem *previous);
void showInfoForItem(QTreeWidgetItem *item);
void updateItem(QTreeWidgetItem *item);
void updateItemName(QTreeWidgetItem *item);
private:
Ui::ExternalToolConfig *ui;
......
......@@ -125,14 +125,6 @@ QString ExternalTool::displayName() const
return m_displayName;
}
void ExternalTool::setDisplayName(const QString &name)
{
if (name == m_displayName)
return;
m_isDisplayNameChanged = true;
m_displayName = name;
}
QString ExternalTool::displayCategory() const
{
return m_displayCategory;
......@@ -178,6 +170,85 @@ bool ExternalTool::modifiesCurrentDocument() const
return m_modifiesCurrentDocument;
}
void ExternalTool::setDisplayName(const QString &name)
{
if (name == m_displayName)
return;
m_isDisplayNameChanged = true;
m_displayName = name;
}
void ExternalTool::setDescription(const QString &description)
{
if (description == m_description)
return;
m_isChanged = true;
m_description = description;
}
void ExternalTool::setOutputHandling(OutputHandling handling)
{
if (handling == m_outputHandling)
return;
m_isChanged = true;
m_outputHandling = handling;
}
void ExternalTool::setErrorHandling(OutputHandling handling)
{
if (handling == m_errorHandling)
return;
m_isChanged = true;
m_errorHandling = handling;
}
void ExternalTool::setModifiesCurrentDocument(bool modifies)
{
if (modifies == m_modifiesCurrentDocument)
return;
m_isChanged = true;
m_modifiesCurrentDocument = modifies;
}
void ExternalTool::setExecutables(const QStringList &executables)
{
if (executables == m_executables)
return;
m_isChanged = true;
m_executables = executables;
}
void ExternalTool::setArguments(const QString &arguments)
{
if (arguments == m_arguments)
return;
m_isChanged = true;
m_arguments = arguments;
}
void ExternalTool::setInput(const QString &input)
{
if (input == m_input)
return;
m_isChanged = true;
m_input = input;
}
void ExternalTool::setWorkingDirectory(const QString &workingDirectory)
{
if (workingDirectory == m_workingDirectory)
return;
m_isChanged = true;
m_workingDirectory = workingDirectory;
}
static QStringList splitLocale(const QString &locale)
{
QString value = locale;
......
......@@ -64,7 +64,6 @@ public:
QString id() const;
QString description() const;
QString displayName() const;
void setDisplayName(const QString &name);
QString displayCategory() const;
int order() const;
OutputHandling outputHandling() const;
......@@ -78,11 +77,21 @@ public:
static ExternalTool *createFromXml(const QByteArray &xml, QString *errorMessage = 0, const QString &locale = QString());
// if the display name is different from the one in the original xml
bool isDisplayNameChanged() const { return m_isDisplayNameChanged; }
// ignores changed state
bool operator==(const ExternalTool &other);
void setDisplayName(const QString &name);
void setDescription(const QString &description);
void setOutputHandling(OutputHandling handling);
void setErrorHandling(OutputHandling handling);
void setModifiesCurrentDocument(bool modifies);
void setExecutables(const QStringList &executables);
void setArguments(const QString &arguments);
void setInput(const QString &input);
void setWorkingDirectory(const QString &workingDirectory);
// if the display name is different from the one in the original xml
bool isDisplayNameChanged() const { return m_isDisplayNameChanged; }
bool isChanged() const { return m_isChanged; }
private:
QString m_id;
QString m_description;
......@@ -98,6 +107,7 @@ private:
bool m_modifiesCurrentDocument;
bool m_isDisplayNameChanged;
bool m_isChanged;
};
class ExternalToolRunner : public QObject
......
......@@ -92,6 +92,7 @@ void ToolSettings::apply()
{
if (!m_widget)
return;
m_widget->apply();
QMap<QString, ExternalTool *> originalTools = ExternalToolManager::instance()->toolsById();
QMap<QString, QList<ExternalTool *> > newToolsMap = m_widget->tools();
QMap<QString, QList<ExternalTool *> > resultMap;
......
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