Commit ffed41c5 authored by Mark Nauwelaerts's avatar Mark Nauwelaerts
Browse files

build-plugin: pick and build default target when so requested

parent 227f5d99
......@@ -63,6 +63,23 @@ void TargetModel::setDefaultCmd(int rootRow, const QString &defCmd)
}
}
int TargetModel::getDefaultCmdIndex(int rootRow) const
{
if (rootRow < 0 || rootRow >= m_targets.size()) {
qDebug() << "rootRow not valid";
return 0;
}
auto defCmd = m_targets[rootRow].defaultCmd;
for (int i = 0; i < m_targets[rootRow].commands.size(); i++) {
if (defCmd == m_targets[rootRow].commands[i].first) {
return i;
}
}
return 0;
}
int TargetModel::addTargetSet(const QString &setName, const QString &workDir)
{
// make the name unique
......@@ -155,18 +172,9 @@ QModelIndex TargetModel::copyTargetOrSet(const QModelIndex &index)
return createIndex(m_targets[rootRow].commands.count() - 1, 0, rootRow);
}
QModelIndex TargetModel::defaultTarget(const QModelIndex &index)
QModelIndex TargetModel::defaultTarget(int targetSet)
{
int targetRow = 0;
if (index.isValid()) {
if (index.internalId() == InvalidIndex) {
targetRow = index.row();
} else {
targetRow = index.internalId();
}
}
return createIndex(0, 0, targetRow);
return createIndex(getDefaultCmdIndex(targetSet), 0, targetSet);
}
void TargetModel::deleteItem(const QModelIndex &index)
......
......@@ -59,7 +59,7 @@ public Q_SLOTS:
QModelIndex copyTargetOrSet(const QModelIndex &index);
/** This function returns the model index of the default command of the target-set */
QModelIndex defaultTarget(const QModelIndex &index);
QModelIndex defaultTarget(int targetSet);
/** This function deletes the index */
void deleteItem(const QModelIndex &index);
......@@ -76,6 +76,7 @@ public Q_SLOTS:
const QString cmdName(const QModelIndex &itemIndex) const;
const QString workDir(const QModelIndex &itemIndex) const;
const QString targetName(const QModelIndex &itemIndex) const;
int getDefaultCmdIndex(int rootRow) const;
Q_SIGNALS:
......
......@@ -779,7 +779,7 @@ void KateBuildView::slotBuildPreviousTarget()
/******************************************************************/
void KateBuildView::slotBuildDefaultTarget()
{
QModelIndex defaultTarget = m_targetsUi->targetsModel.defaultTarget(m_targetsUi->targetsView->currentIndex());
QModelIndex defaultTarget = m_targetsUi->targetsModel.defaultTarget(m_targetsUi->targetCombo->currentIndex());
m_targetsUi->targetsView->setCurrentIndex(defaultTarget);
buildCurrentTarget();
}
......
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