Spreadsheet: move to new style connect()

This commit is contained in:
wmayer
2023-01-13 20:02:46 +01:00
parent d6b3efc7a8
commit 3818dec66a
8 changed files with 62 additions and 60 deletions

View File

@@ -130,7 +130,7 @@ DlgBindSheet::DlgBindSheet(Sheet *sheet, const std::vector<Range> &ranges, QWidg
}
}
connect(ui->btnDiscard, SIGNAL(clicked()), this, SLOT(onDiscard()));
connect(ui->btnDiscard, &QPushButton::clicked, this, &DlgBindSheet::onDiscard);
}
DlgBindSheet::~DlgBindSheet()

View File

@@ -55,7 +55,7 @@ DlgSheetConf::DlgSheetConf(Sheet *sheet, Range range, QWidget *parent)
ui->lineEditProp->setDocumentObject(sheet,false);
connect(ui->btnDiscard, SIGNAL(clicked()), this, SLOT(onDiscard()));
connect(ui->btnDiscard, &QPushButton::clicked, this, &DlgSheetConf::onDiscard);
CellAddress from,to;
std::string rangeConf;

View File

@@ -105,30 +105,30 @@ PropertiesDialog::PropertiesDialog(Sheet *_sheet, const std::vector<Range> &_ran
ui->alias->setText(Base::Tools::fromStdString(alias));
// Colors
connect(ui->foregroundColor, SIGNAL(colorChanged(QColor)), this, SLOT(foregroundColorChanged(QColor)));
connect(ui->backgroundColor, SIGNAL(colorChanged(QColor)), this, SLOT(backgroundColorChanged(QColor)));
connect(ui->foregroundColor, &QtColorPicker::colorChanged, this, &PropertiesDialog::foregroundColorChanged);
connect(ui->backgroundColor, &QtColorPicker::colorChanged, this, &PropertiesDialog::backgroundColorChanged);
// Alignment
connect(ui->alignLeft, SIGNAL(clicked()), this, SLOT(alignmentChanged()));
connect(ui->alignRight, SIGNAL(clicked()), this, SLOT(alignmentChanged()));
connect(ui->alignHCenter, SIGNAL(clicked()), this, SLOT(alignmentChanged()));
connect(ui->alignTop, SIGNAL(clicked()), this, SLOT(alignmentChanged()));
connect(ui->alignVCenter, SIGNAL(clicked()), this, SLOT(alignmentChanged()));
connect(ui->alignBottom, SIGNAL(clicked()), this, SLOT(alignmentChanged()));
connect(ui->alignLeft, &QRadioButton::clicked, this, &PropertiesDialog::alignmentChanged);
connect(ui->alignRight, &QRadioButton::clicked, this, &PropertiesDialog::alignmentChanged);
connect(ui->alignHCenter, &QRadioButton::clicked, this, &PropertiesDialog::alignmentChanged);
connect(ui->alignTop, &QRadioButton::clicked, this, &PropertiesDialog::alignmentChanged);
connect(ui->alignVCenter, &QRadioButton::clicked, this, &PropertiesDialog::alignmentChanged);
connect(ui->alignBottom, &QRadioButton::clicked, this, &PropertiesDialog::alignmentChanged);
// Style
connect(ui->styleBold, SIGNAL(clicked()), this, SLOT(styleChanged()));
connect(ui->styleItalic, SIGNAL(clicked()), this, SLOT(styleChanged()));
connect(ui->styleUnderline, SIGNAL(clicked()), this, SLOT(styleChanged()));
connect(ui->styleBold, &QCheckBox::clicked, this, &PropertiesDialog::styleChanged);
connect(ui->styleItalic, &QCheckBox::clicked, this, &PropertiesDialog::styleChanged);
connect(ui->styleUnderline, &QCheckBox::clicked, this, &PropertiesDialog::styleChanged);
// Display unit
connect(ui->displayUnit, SIGNAL(textEdited(QString)), this, SLOT(displayUnitChanged(QString)));
connect(ui->displayUnit, &QLineEdit::textEdited, this, &PropertiesDialog::displayUnitChanged);
// Alias is only allowed for a single cell
ui->tabWidget->widget(4)->setEnabled(_ranges.size() == 1 && _ranges[0].size() == 1);
// Alias
connect(ui->alias, SIGNAL(textEdited(QString)), this, SLOT(aliasChanged(QString)));
connect(ui->alias, &QLineEdit::textEdited, this, &PropertiesDialog::aliasChanged);
ui->tabWidget->setCurrentIndex(0);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(displayUnitOk && aliasOk);

View File

@@ -126,18 +126,18 @@ SheetTableView::SheetTableView(QWidget *parent)
/*: This is shown in the context menu for the vertical header in a spreadsheet.
The number refers to how many lines are selected and will be inserted. */
auto insertBefore = menu.addAction(tr("Insert %n row(s) above", "", selection.size()));
connect(insertBefore, SIGNAL(triggered()), this, SLOT(insertRows()));
connect(insertBefore, &QAction::triggered, this, &SheetTableView::insertRows);
if (max < model()->rowCount() - 1) {
auto insertAfter = menu.addAction(tr("Insert %n row(s) below", "", selection.size()));
connect(insertAfter, SIGNAL(triggered()), this, SLOT(insertRowsAfter()));
connect(insertAfter, &QAction::triggered, this, &SheetTableView::insertRowsAfter);
}
} else {
auto insert = menu.addAction(tr("Insert %n non-contiguous rows", "", selection.size()));
connect(insert, SIGNAL(triggered()), this, SLOT(insertRows()));
connect(insert, &QAction::triggered, this, &SheetTableView::insertRows);
}
auto remove = menu.addAction(tr("Remove row(s)", "", selection.size()));
connect(remove, SIGNAL(triggered()), this, SLOT(removeRows()));
connect(remove, &QAction::triggered, this, &SheetTableView::removeRows);
menu.exec(verticalHeader()->mapToGlobal(point));
});
@@ -151,18 +151,18 @@ SheetTableView::SheetTableView(QWidget *parent)
/*: This is shown in the context menu for the horizontal header in a spreadsheet.
The number refers to how many lines are selected and will be inserted. */
auto insertAbove = menu.addAction(tr("Insert %n column(s) left", "", selection.size()));
connect(insertAbove, SIGNAL(triggered()), this, SLOT(insertColumns()));
connect(insertAbove, &QAction::triggered, this, &SheetTableView::insertColumns);
if (max < model()->columnCount() - 1) {
auto insertAfter = menu.addAction(tr("Insert %n column(s) right", "", selection.size()));
connect(insertAfter, SIGNAL(triggered()), this, SLOT(insertColumnsAfter()));
connect(insertAfter, &QAction::triggered, this, &SheetTableView::insertColumnsAfter);
}
} else {
auto insert = menu.addAction(tr("Insert %n non-contiguous columns", "", selection.size()));
connect(insert, SIGNAL(triggered()), this, SLOT(insertColumns()));
connect(insert, &QAction::triggered, this, &SheetTableView::insertColumns);
}
auto remove = menu.addAction(tr("Remove column(s)", "", selection.size()));
connect(remove, SIGNAL(triggered()), this, SLOT(removeColumns()));
connect(remove, &QAction::triggered, this, &SheetTableView::removeColumns);
menu.exec(horizontalHeader()->mapToGlobal(point));
});
@@ -175,19 +175,19 @@ SheetTableView::SheetTableView(QWidget *parent)
contextMenu = new QMenu(this);
contextMenu->addAction(actionProperties);
connect(actionProperties, SIGNAL(triggered()), this, SLOT(cellProperties()));
connect(actionProperties, &QAction::triggered, this, &SheetTableView::cellProperties);
contextMenu->addSeparator();
actionRecompute = new QAction(tr("Recompute"),this);
connect(actionRecompute, SIGNAL(triggered()), this, SLOT(onRecompute()));
connect(actionRecompute, &QAction::triggered, this, &SheetTableView::onRecompute);
contextMenu->addAction(actionRecompute);
actionBind = new QAction(tr("Bind..."),this);
connect(actionBind, SIGNAL(triggered()), this, SLOT(onBind()));
connect(actionBind, &QAction::triggered, this, &SheetTableView::onBind);
contextMenu->addAction(actionBind);
actionConf = new QAction(tr("Configuration table..."),this);
connect(actionConf, SIGNAL(triggered()), this, SLOT(onConfSetup()));
connect(actionConf, &QAction::triggered, this, &SheetTableView::onConfSetup);
contextMenu->addAction(actionConf);
horizontalHeader()->addAction(actionBind);
@@ -195,19 +195,19 @@ SheetTableView::SheetTableView(QWidget *parent)
contextMenu->addSeparator();
actionMerge = contextMenu->addAction(tr("Merge cells"));
connect(actionMerge,SIGNAL(triggered()), this, SLOT(mergeCells()));
connect(actionMerge, &QAction::triggered, this, &SheetTableView::mergeCells);
actionSplit = contextMenu->addAction(tr("Split cells"));
connect(actionSplit,SIGNAL(triggered()), this, SLOT(splitCell()));
connect(actionSplit, &QAction::triggered, this, &SheetTableView::splitCell);
contextMenu->addSeparator();
actionCut = contextMenu->addAction(tr("Cut"));
connect(actionCut,SIGNAL(triggered()), this, SLOT(cutSelection()));
connect(actionCut, &QAction::triggered, this, &SheetTableView::cutSelection);
actionCopy = contextMenu->addAction(tr("Copy"));
connect(actionCopy,SIGNAL(triggered()), this, SLOT(copySelection()));
connect(actionCopy, &QAction::triggered, this, &SheetTableView::copySelection);
actionPaste = contextMenu->addAction(tr("Paste"));
connect(actionPaste,SIGNAL(triggered()), this, SLOT(pasteClipboard()));
connect(actionPaste, &QAction::triggered, this, &SheetTableView::pasteClipboard);
actionDel = contextMenu->addAction(tr("Delete"));
connect(actionDel,SIGNAL(triggered()), this, SLOT(deleteSelection()));
connect(actionDel, &QAction::triggered, this, &SheetTableView::deleteSelection);
setTabKeyNavigation(false);

View File

@@ -80,18 +80,18 @@ SheetView::SheetView(Gui::Document *pcDocument, App::DocumentObject *docObj, QWi
ui->cells->setSheet(sheet);
// Connect signals
connect(ui->cells->selectionModel(), SIGNAL( currentChanged( QModelIndex, QModelIndex ) ),
this, SLOT( currentChanged( QModelIndex, QModelIndex ) ) );
connect(ui->cells->selectionModel(), &QItemSelectionModel::currentChanged,
this, &SheetView::currentChanged);
connect(ui->cells->horizontalHeader(), SIGNAL(resizeFinished()),
this, SLOT(columnResizeFinished()));
connect(ui->cells->horizontalHeader(), SIGNAL(sectionResized ( int, int, int ) ),
this, SLOT(columnResized(int, int, int)));
connect(dynamic_cast<SheetViewHeader*>(ui->cells->horizontalHeader()), &SheetViewHeader::resizeFinished,
this, &SheetView::columnResizeFinished);
connect(ui->cells->horizontalHeader(), &QHeaderView::sectionResized,
this, &SheetView::columnResized);
connect(ui->cells->verticalHeader(), SIGNAL(resizeFinished()),
this, SLOT(rowResizeFinished()));
connect(ui->cells->verticalHeader(), SIGNAL(sectionResized ( int, int, int ) ),
this, SLOT(rowResized(int, int, int)));
connect(dynamic_cast<SheetViewHeader*>(ui->cells->verticalHeader()), &SheetViewHeader::resizeFinished,
this, &SheetView::rowResizeFinished);
connect(ui->cells->verticalHeader(), &QHeaderView::sectionResized,
this, &SheetView::rowResized);
connect(delegate, &SpreadsheetDelegate::finishedWithKey, this, &SheetView::editingFinishedWithKey);
connect(ui->cellContent, &ExpressionLineEdit::returnPressed, this, [this]() {confirmContentChanged(ui->cellContent->text()); });
@@ -101,7 +101,7 @@ SheetView::SheetView(Gui::Document *pcDocument, App::DocumentObject *docObj, QWi
columnWidthChangedConnection = sheet->columnWidthChanged.connect(bind(&SheetView::resizeColumn, this, bp::_1, bp::_2));
rowHeightChangedConnection = sheet->rowHeightChanged.connect(bind(&SheetView::resizeRow, this, bp::_1, bp::_2));
connect( model, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(modelUpdated(const QModelIndex &, const QModelIndex &)));
connect( model, &QAbstractItemModel::dataChanged, this, &SheetView::modelUpdated);
QPalette palette = ui->cells->palette();
palette.setColor(QPalette::Base, QColor(255, 255, 255));
@@ -231,8 +231,8 @@ void SheetView::printPreview()
QPrinter printer(QPrinter::ScreenResolution);
printer.setPageOrientation(QPageLayout::Landscape);
QPrintPreviewDialog dlg(&printer, this);
connect(&dlg, SIGNAL(paintRequested (QPrinter *)),
this, SLOT(print(QPrinter *)));
connect(&dlg, &QPrintPreviewDialog::paintRequested,
this, qOverload<QPrinter*>(&SheetView::print));
dlg.exec();
}

View File

@@ -86,7 +86,7 @@ void Workbench::activated()
foregroundColor->setObjectName(QString::fromLatin1("Spreadsheet_ForegroundColor"));
foregroundColor->setStandardColors();
foregroundColor->setCurrentColor(palette.color(QPalette::WindowText));
QObject::connect(foregroundColor, SIGNAL(colorSet(QColor)), workbenchHelper.get(), SLOT(setForegroundColor(QColor)));
QObject::connect(foregroundColor, &QtColorPicker::colorSet, workbenchHelper.get(), &WorkbenchHelper::setForegroundColor);
}
foregroundColor->setToolTip(QObject::tr("Set cell(s) foreground color"));
foregroundColor->setWhatsThis(QObject::tr("Sets the Spreadsheet cell(s) foreground color"));
@@ -101,7 +101,7 @@ void Workbench::activated()
backgroundColor->setObjectName(QString::fromLatin1("Spreadsheet_BackgroundColor"));
backgroundColor->setStandardColors();
backgroundColor->setCurrentColor(palette.color(QPalette::Base));
QObject::connect(backgroundColor, SIGNAL(colorSet(QColor)), workbenchHelper.get(), SLOT(setBackgroundColor(QColor)));
QObject::connect(backgroundColor, &QtColorPicker::colorSet, workbenchHelper.get(), &WorkbenchHelper::setBackgroundColor);
}
backgroundColor->setToolTip(QObject::tr("Set cell(s) background color"));
backgroundColor->setWhatsThis(QObject::tr("Sets the Spreadsheet cell(s) background color"));

View File

@@ -40,9 +40,10 @@ namespace SpreadsheetGui {
class SpreadsheetGuiExport WorkbenchHelper : public QObject
{
Q_OBJECT
protected Q_SLOTS:
void setForegroundColor(const QColor &color);
void setBackgroundColor(const QColor &color);
public Q_SLOTS:
void setForegroundColor(const QColor &color);
void setBackgroundColor(const QColor &color);
};
class SpreadsheetGuiExport Workbench : public Gui::StdWorkbench

View File

@@ -558,13 +558,14 @@ ColorPickerPopup::ColorPickerPopup(int width, bool withColorDialog,
cols = width;
if (withColorDialog) {
moreButton = new ColorPickerButton(this);
moreButton->setFixedWidth(24);
moreButton->setFixedHeight(21);
moreButton->setFrameRect(QRect(2, 2, 20, 17));
connect(moreButton, SIGNAL(clicked()), SLOT(getColorFromDialog()));
} else {
moreButton = nullptr;
moreButton = new ColorPickerButton(this);
moreButton->setFixedWidth(24);
moreButton->setFixedHeight(21);
moreButton->setFrameRect(QRect(2, 2, 20, 17));
connect(moreButton, &ColorPickerButton::clicked, this, &ColorPickerPopup::getColorFromDialog);
}
else {
moreButton = nullptr;
}
eventLoop = nullptr;
@@ -628,10 +629,10 @@ void ColorPickerPopup::insertColor(const QColor &col, const QString &text, int i
}
item->setFocus();
connect(item, SIGNAL(selected()), SLOT(updateSelected()));
connect(item, &ColorPickerItem::selected, this, &ColorPickerPopup::updateSelected);
if (index == -1)
index = items.count();
index = items.count();
items.insert((unsigned int)index, item);
regenerateGrid();