Sheet: enable Split action only if only one merged cell is selected
Both main menu and context menu Partially fixes #6744
This commit is contained in:
@@ -162,7 +162,10 @@ bool CmdSpreadsheetSplitCell::isActive()
|
||||
Sheet * sheet = sheetView->getSheet();
|
||||
|
||||
if (current.isValid())
|
||||
return sheet->isMergedCell(CellAddress(current.row(), current.column()));
|
||||
{
|
||||
return (sheetView->selectedIndexesRaw().size() == 1 &&
|
||||
sheet->isMergedCell(CellAddress(current.row(), current.column())));
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -274,6 +274,11 @@ std::vector<Range> SheetTableView::selectedRanges() const
|
||||
return result;
|
||||
}
|
||||
|
||||
QModelIndexList SheetTableView::selectedIndexesRaw() const
|
||||
{
|
||||
return selectedIndexes();
|
||||
}
|
||||
|
||||
void SheetTableView::insertRows()
|
||||
{
|
||||
assert(sheet != nullptr);
|
||||
@@ -966,7 +971,8 @@ void SheetTableView::contextMenuEvent(QContextMenuEvent *)
|
||||
actionCut->setEnabled(true);
|
||||
actionCopy->setEnabled(true);
|
||||
actionDel->setEnabled(true);
|
||||
actionSplit->setEnabled(true);
|
||||
actionSplit->setEnabled(selectedIndexes().size() == 1 &&
|
||||
sheet->isMergedCell(CellAddress(currentIndex().row(),currentIndex().column())));
|
||||
actionMerge->setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
void edit(const QModelIndex &index);
|
||||
void setSheet(Spreadsheet::Sheet *_sheet);
|
||||
std::vector<App::Range> selectedRanges() const;
|
||||
QModelIndexList selectedIndexesRaw() const;
|
||||
QString toHtml() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
@@ -483,6 +483,11 @@ QModelIndexList SheetView::selectedIndexes() const
|
||||
return ui->cells->selectionModel()->selectedIndexes();
|
||||
}
|
||||
|
||||
QModelIndexList SheetView::selectedIndexesRaw() const
|
||||
{
|
||||
return ui->cells->selectedIndexesRaw();
|
||||
}
|
||||
|
||||
void SpreadsheetGui::SheetView::select(App::CellAddress cell, QItemSelectionModel::SelectionFlags flags)
|
||||
{
|
||||
ui->cells->selectionModel()->select(model->index(cell.row(), cell.col()), flags);
|
||||
|
||||
@@ -81,6 +81,7 @@ public:
|
||||
std::vector<App::Range> selectedRanges() const;
|
||||
|
||||
QModelIndexList selectedIndexes() const;
|
||||
QModelIndexList selectedIndexesRaw() const;
|
||||
|
||||
void select(App::CellAddress cell, QItemSelectionModel::SelectionFlags flags);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user