Commit f410f4c3 authored by Nikita Sirgienko's avatar Nikita Sirgienko
Browse files

[T12843] Add actions for selection

parent b1d624e1
......@@ -99,6 +99,8 @@ class CommandEntry : public WorksheetEntry
void removeResult(Cantor::Result* result);
void collapseResults();
void expandResults();
void excludeFromExecution();
void addToExecution();
void showCompletion() override;
void selectPreviousCompletion();
......@@ -158,8 +160,6 @@ class CommandEntry : public WorksheetEntry
void setMidPrompt();
void setHidePrompt();
void excludeFromExecution();
void addToExecution();
private:
static const double HorizontalSpacing;
......
......@@ -1665,6 +1665,24 @@ void Worksheet::populateMenu(QMenu *menu, QPointF pos)
menu->addAction(QIcon::fromTheme(QLatin1String("go-down")), i18n("Move Entries Down"), this, SLOT(selectionMoveDown()), 0);
menu->addAction(QIcon::fromTheme(QLatin1String("media-playback-start")), i18n("Evaluate Entries"), this, SLOT(selectionEvaluate()), 0);
menu->addAction(QIcon::fromTheme(QLatin1String("edit-delete")), i18n("Remove Entries"), this, SLOT(selectionRemove()), 0);
bool isAnyCommandEntryInSelection = false;
for (WorksheetEntry* entry : m_selectedEntries)
if (entry->type() == CommandEntry::Type)
{
isAnyCommandEntryInSelection = true;
break;
}
if (isAnyCommandEntryInSelection)
{
menu->addSeparator();
menu->addAction(QIcon(), i18n("Collapse Command Entry Results"), this, &Worksheet::collapseSelectionResults);
menu->addAction(QIcon(), i18n("Expand Command Entry Results"), this, &Worksheet::uncollapseSelectionResults);
menu->addAction(QIcon(), i18n("Remove Command Entry Results"), this, &Worksheet::removeSelectionResults);
menu->addAction(QIcon(), i18n("Exclude Command Entry From Execution"), this, &Worksheet::excludeFromExecutionSelection);
menu->addAction(QIcon(), i18n("Add Command Entry To Execution"), this, &Worksheet::addToExectuionSelection);
}
}
}
......@@ -2561,3 +2579,38 @@ void Worksheet::removeAllResults()
static_cast<CommandEntry*>(entry)->removeResults();
}
}
void Worksheet::addToExectuionSelection()
{
for (WorksheetEntry* entry : m_selectedEntries)
if (entry->type() == CommandEntry::Type)
static_cast<CommandEntry*>(entry)->addToExecution();
}
void Worksheet::excludeFromExecutionSelection()
{
for (WorksheetEntry* entry : m_selectedEntries)
if (entry->type() == CommandEntry::Type)
static_cast<CommandEntry*>(entry)->excludeFromExecution();
}
void Worksheet::collapseSelectionResults()
{
for (WorksheetEntry* entry : m_selectedEntries)
if (entry->type() == CommandEntry::Type)
static_cast<CommandEntry*>(entry)->collapseResults();
}
void Worksheet::uncollapseSelectionResults()
{
for (WorksheetEntry* entry : m_selectedEntries)
if (entry->type() == CommandEntry::Type)
static_cast<CommandEntry*>(entry)->expandResults();
}
void Worksheet::removeSelectionResults()
{
for (WorksheetEntry* entry : m_selectedEntries)
if (entry->type() == CommandEntry::Type)
static_cast<CommandEntry*>(entry)->removeResults();
}
......@@ -235,9 +235,14 @@ class Worksheet : public QGraphicsScene
void changeEntryType(WorksheetEntry* target, int newType);
void collapseSelectionResults();
void collapseAllResults();
void uncollapseSelectionResults();
void uncollapseAllResults();
void removeSelectionResults();
void removeAllResults();
void addToExectuionSelection();
void excludeFromExecutionSelection();
Q_SIGNALS:
void modified();
......
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