Apply clang-tidy's modernize-use-auto

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5449 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
scorpio810
2018-07-19 16:27:20 +00:00
parent e4b1ba9797
commit b97b01d63c
98 changed files with 427 additions and 427 deletions

View File

@@ -145,10 +145,10 @@ void TitleBlockDimensionWidget::initWidgets() {
Initialize the layout of the dialog.
*/
void TitleBlockDimensionWidget::initLayouts() {
QHBoxLayout *hlayout0 = new QHBoxLayout();
auto *hlayout0 = new QHBoxLayout();
hlayout0 -> addWidget(spinbox_label_);
hlayout0 -> addWidget(spinbox_);
QVBoxLayout *vlayout0 = new QVBoxLayout();
auto *vlayout0 = new QVBoxLayout();
vlayout0 -> addLayout(hlayout0);
if (complete_) {
vlayout0 -> addWidget(absolute_button_);

View File

@@ -246,7 +246,7 @@ bool QETTitleBlockTemplateEditor::edit(QETProject *project, const QString &templ
*/
bool QETTitleBlockTemplateEditor::edit(const QString &file_path) {
// get title block template object from the file, edit it
TitleBlockTemplate *tbt = new TitleBlockTemplate();
auto *tbt = new TitleBlockTemplate();
bool loading = tbt -> loadFromXmlFile(file_path);
if (!loading) {
/// TODO the file opening failed, warn the user?
@@ -301,7 +301,7 @@ void QETTitleBlockTemplateEditor::editLogos() {
logo_manager_ -> layout() -> setContentsMargins(0, 0, 0, 0);
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close);
QVBoxLayout *vlayout0 = new QVBoxLayout();
auto *vlayout0 = new QVBoxLayout();
vlayout0 -> addWidget(logo_manager_);
vlayout0 -> addWidget(buttons);
@@ -320,7 +320,7 @@ void QETTitleBlockTemplateEditor::editLogos() {
Launch a new title block template editor.
*/
void QETTitleBlockTemplateEditor::newTemplate() {
QETTitleBlockTemplateEditor *qet_template_editor = new QETTitleBlockTemplateEditor();
auto *qet_template_editor = new QETTitleBlockTemplateEditor();
qet_template_editor -> edit(TitleBlockTemplateLocation());
qet_template_editor -> show();
}
@@ -882,7 +882,7 @@ TitleBlockTemplateLocation QETTitleBlockTemplateEditor::getTitleBlockTemplateLoc
}
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QVBoxLayout *dialog_layout = new QVBoxLayout();
auto *dialog_layout = new QVBoxLayout();
dialog_layout -> addWidget(widget);
dialog_layout -> addWidget(buttons);
@@ -932,7 +932,7 @@ void QETTitleBlockTemplateEditor::editTemplateInformation() {
#endif
dialog_author.setMinimumSize(400, 260);
dialog_author.setWindowTitle(tr("Éditer les informations complémentaires", "window title"));
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_author);
auto *dialog_layout = new QVBoxLayout(&dialog_author);
// explanation label
QLabel *information_label = new QLabel(tr("Vous pouvez utiliser ce champ libre pour mentionner les auteurs du cartouche, sa licence, ou tout autre renseignement que vous jugerez utile."));
@@ -941,7 +941,7 @@ void QETTitleBlockTemplateEditor::editTemplateInformation() {
dialog_layout -> addWidget(information_label);
// add a QTextEdit to the dialog
QTextEdit *text_field = new QTextEdit();
auto *text_field = new QTextEdit();
text_field -> setAcceptRichText(false);
text_field -> setPlainText(tb_template_ -> information());
text_field -> setReadOnly(read_only_);

View File

@@ -96,11 +96,11 @@ void TitleBlockTemplateCellWidget::initWidgets() {
font_adjust_input_ = new QCheckBox(tr("Ajuster la taille de police si besoin"));
// layout
QHBoxLayout *label_edition = new QHBoxLayout();
auto *label_edition = new QHBoxLayout();
label_edition -> addWidget(label_input_);
label_edition -> addWidget(label_edit_);
QHBoxLayout *value_edition = new QHBoxLayout();
auto *value_edition = new QHBoxLayout();
value_edition -> addWidget(value_input_);
value_edition -> addWidget(value_edit_);
@@ -375,7 +375,7 @@ bool TitleBlockTemplateCellWidget::isReadOnly() const {
@param title Title of the dialog window
*/
void TitleBlockTemplateCellWidget::editTranslatableValue(NamesList &names, const QString &attribute, const QString &title) const {
NamesListWidget *names_widget = new NamesListWidget();
auto *names_widget = new NamesListWidget();
names_widget -> setNames(names);
QDialogButtonBox * buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
@@ -386,7 +386,7 @@ void TitleBlockTemplateCellWidget::editTranslatableValue(NamesList &names, const
QLabel *def_var_label = new QLabel(defaultVariablesString());
def_var_label -> setTextFormat(Qt::RichText);
QVBoxLayout *editor_layout = new QVBoxLayout();
auto *editor_layout = new QVBoxLayout();
editor_layout -> addWidget(information);
editor_layout -> addWidget(names_widget);
editor_layout -> addWidget(def_var_label);
@@ -416,7 +416,7 @@ void TitleBlockTemplateCellWidget::emitModification(const QString &attribute, co
// avoid creating a QUndoCommand object when no modification was actually done
if (edited_cell_ -> attribute(attribute) == new_value) return;
ModifyTitleBlockCellCommand *command = new ModifyTitleBlockCellCommand(edited_cell_);
auto *command = new ModifyTitleBlockCellCommand(edited_cell_);
command -> addModification(attribute, new_value);
command -> setText(
tr("Édition d'une cellule : %1", "label of and undo command when editing a cell")

View File

@@ -55,7 +55,7 @@ int ModifyTitleBlockCellCommand::id() const {
@return true on success, false otherwise
*/
bool ModifyTitleBlockCellCommand::mergeWith(const QUndoCommand *command) {
const ModifyTitleBlockCellCommand *other = static_cast<const ModifyTitleBlockCellCommand *>(command);
const auto *other = static_cast<const ModifyTitleBlockCellCommand *>(command);
if (other) {
if (other -> modified_cell_ == modified_cell_) {
if (other -> new_values_.keys() == new_values_.keys()) {
@@ -226,7 +226,7 @@ ModifyTemplateGridCommand *ModifyTemplateGridCommand::addRow(TitleBlockTemplate
if (!tbtemplate) return(nullptr);
// create the command itself
ModifyTemplateGridCommand *add_row_command = new ModifyTemplateGridCommand(tbtemplate);
auto *add_row_command = new ModifyTemplateGridCommand(tbtemplate);
add_row_command -> setInsertion(true);
add_row_command -> setType(true);
add_row_command -> setCells(tbtemplate -> createRow());
@@ -247,7 +247,7 @@ ModifyTemplateGridCommand *ModifyTemplateGridCommand::addColumn(TitleBlockTempla
if (!tbtemplate) return(nullptr);
// create the command itself
ModifyTemplateGridCommand *add_column_command = new ModifyTemplateGridCommand(tbtemplate);
auto *add_column_command = new ModifyTemplateGridCommand(tbtemplate);
add_column_command -> setInsertion(true);
add_column_command -> setType(false);
add_column_command -> setCells(tbtemplate -> createColumn());
@@ -268,7 +268,7 @@ ModifyTemplateGridCommand *ModifyTemplateGridCommand::deleteRow(TitleBlockTempla
if (!tbtemplate) return(nullptr);
// create the command itself
ModifyTemplateGridCommand *del_row_command = new ModifyTemplateGridCommand(tbtemplate);
auto *del_row_command = new ModifyTemplateGridCommand(tbtemplate);
del_row_command -> setInsertion(false);
del_row_command -> setType(true);
del_row_command -> setIndex(index);
@@ -287,7 +287,7 @@ ModifyTemplateGridCommand *ModifyTemplateGridCommand::deleteColumn(TitleBlockTem
if (!tbtemplate) return(nullptr);
// create the command itself
ModifyTemplateGridCommand *del_column_command = new ModifyTemplateGridCommand(tbtemplate);
auto *del_column_command = new ModifyTemplateGridCommand(tbtemplate);
del_column_command -> setInsertion(false);
del_column_command -> setType(false);
del_column_command -> setIndex(index);

View File

@@ -154,7 +154,7 @@ void TitleBlockTemplateLogoManager::fillView() {
current_icon = QIcon(*svg_pixmap);
}
}
QListWidgetItem *qlwi = new QListWidgetItem(current_icon, logo_name);
auto *qlwi = new QListWidgetItem(current_icon, logo_name);
qlwi -> setTextAlignment(Qt::AlignBottom | Qt::AlignHCenter);
logos_view_ -> insertItem(0, qlwi);
}
@@ -192,18 +192,18 @@ QString TitleBlockTemplateLogoManager::confirmLogoName(const QString &initial_na
rd_label = new QLabel();
rd_label -> setWordWrap(true);
rd_input = new QLineEdit();
QDialogButtonBox *rd_buttons = new QDialogButtonBox();
auto *rd_buttons = new QDialogButtonBox();
QPushButton *replace_button = rd_buttons -> addButton(tr("Remplacer"), QDialogButtonBox::YesRole);
QPushButton *rename_button = rd_buttons -> addButton(tr("Renommer"), QDialogButtonBox::NoRole);
QPushButton *cancel_button = rd_buttons -> addButton(QDialogButtonBox::Cancel);
QVBoxLayout *rd_vlayout0 = new QVBoxLayout();
auto *rd_vlayout0 = new QVBoxLayout();
rd_vlayout0 -> addWidget(rd_label);
rd_vlayout0 -> addWidget(rd_input);
rd_vlayout0 -> addWidget(rd_buttons);
rename_dialog -> setLayout(rd_vlayout0);
QSignalMapper *signal_mapper = new QSignalMapper(rename_dialog);
auto *signal_mapper = new QSignalMapper(rename_dialog);
signal_mapper -> setMapping(replace_button, QDialogButtonBox::YesRole);
signal_mapper -> setMapping(rename_button, QDialogButtonBox::NoRole);
signal_mapper -> setMapping(cancel_button, QDialogButtonBox::RejectRole);

View File

@@ -199,7 +199,7 @@ TitleBlockTemplate *TitleBlockTemplatesProjectCollection::getTemplate(const QStr
}
// Ok, we have its XML description, we have to generate a TitleBlockTemplate object
TitleBlockTemplate *titleblock_template = new TitleBlockTemplate(this);
auto *titleblock_template = new TitleBlockTemplate(this);
if (titleblock_template -> loadFromXmlElement(titleblock_templates_xml_[template_name])) {
titleblock_templates_.insert(template_name, titleblock_template);
return(titleblock_template);
@@ -403,7 +403,7 @@ QStringList TitleBlockTemplatesFilesCollection::templates() {
TitleBlockTemplate *TitleBlockTemplatesFilesCollection::getTemplate(const QString &template_name) {
if (!templates().contains(template_name)) return(nullptr);
TitleBlockTemplate *tbtemplate = new TitleBlockTemplate();
auto *tbtemplate = new TitleBlockTemplate();
QString tbt_file_path = path(template_name);
bool loading = tbtemplate -> loadFromXmlFile(tbt_file_path);
@@ -431,7 +431,7 @@ QDomElement TitleBlockTemplatesFilesCollection::getTemplateXmlDescription(const
return(QDomElement());
}
QDomDocument *xml_document = new QDomDocument();
auto *xml_document = new QDomDocument();
bool xml_parsing = xml_document -> setContent(&xml_file);
if (!xml_parsing) {
delete xml_document;

View File

@@ -140,7 +140,7 @@ QList<TitleBlockCell *> TitleBlockTemplateView::cut() {
QList<TitleBlockCell *> copied_cells = copy();
if (!copied_cells.isEmpty()) {
CutTemplateCellsCommand *cut_command = new CutTemplateCellsCommand(tbtemplate_);
auto *cut_command = new CutTemplateCellsCommand(tbtemplate_);
cut_command -> setCutCells(copied_cells);
requestGridModification(cut_command);
}
@@ -247,7 +247,7 @@ void TitleBlockTemplateView::paste() {
// change num_row and num_col attributes of pasted cells so they get positionned relatively to selected_cell
normalizeCells(pasted_cells, erased_cell -> num_row, erased_cell -> num_col);
PasteTemplateCellsCommand *paste_command = new PasteTemplateCellsCommand(tbtemplate_);
auto *paste_command = new PasteTemplateCellsCommand(tbtemplate_);
foreach (TitleBlockCell cell, pasted_cells) {
TitleBlockCell *erased_cell = tbtemplate_ -> cell(cell.num_row, cell.num_col);
if (!erased_cell) continue;
@@ -334,7 +334,7 @@ void TitleBlockTemplateView::editColumn(HelperCell *cell) {
dialog.setValue(dimension_before);
int user_answer = dialog.exec();
if (!read_only_ && user_answer == QDialog::Accepted) {
ModifyTemplateDimension *command = new ModifyTemplateDimension(tbtemplate_);
auto *command = new ModifyTemplateDimension(tbtemplate_);
command -> setType(false);
command -> setIndex(index);
command -> setDimensionBefore(dimension_before);
@@ -360,7 +360,7 @@ void TitleBlockTemplateView::editRow(HelperCell *cell) {
dialog.setValue(dimension_before);
int user_answer = dialog.exec();
if (!read_only_ && user_answer == QDialog::Accepted) {
ModifyTemplateDimension *command = new ModifyTemplateDimension(tbtemplate_);
auto *command = new ModifyTemplateDimension(tbtemplate_);
command -> setType(true);
command -> setIndex(index);
command -> setDimensionBefore(dimension_before);
@@ -394,7 +394,7 @@ void TitleBlockTemplateView::mergeSelectedCells() {
// retrieve the selected cells
TitleBlockTemplateCellsSet selected_cells = selectedCellsSet();
MergeCellsCommand *merge_command = new MergeCellsCommand(selected_cells, tbtemplate_);
auto *merge_command = new MergeCellsCommand(selected_cells, tbtemplate_);
if (merge_command -> isValid()) requestGridModification(merge_command);
}
@@ -405,7 +405,7 @@ void TitleBlockTemplateView::splitSelectedCell() {
// retrieve the selected cells
TitleBlockTemplateCellsSet selected_cells = selectedCellsSet();
SplitCellsCommand *split_command = new SplitCellsCommand(selected_cells, tbtemplate_);
auto *split_command = new SplitCellsCommand(selected_cells, tbtemplate_);
if (split_command -> isValid()) requestGridModification(split_command);
}
@@ -578,7 +578,7 @@ void TitleBlockTemplateView::applyColumnsWidths(bool animate) {
// no animation on first call
tbgrid_ -> setColumnFixedWidth(COL_OFFSET + i, widths.at(i));
} else {
GridLayoutAnimation *animation = new GridLayoutAnimation(tbgrid_, form_);
auto *animation = new GridLayoutAnimation(tbgrid_, form_);
animation -> setIndex(COL_OFFSET + i);
animation -> setActsOnRows(false);
animation -> setStartValue(QVariant(tbgrid_ -> columnMinimumWidth(COL_OFFSET + i)));
@@ -643,7 +643,7 @@ void TitleBlockTemplateView::applyRowsHeights(bool animate) {
// no animation on first call
tbgrid_ -> setRowFixedHeight(ROW_OFFSET + i, heights.at(i));
} else {
GridLayoutAnimation *animation = new GridLayoutAnimation(tbgrid_, form_);
auto *animation = new GridLayoutAnimation(tbgrid_, form_);
animation -> setIndex(ROW_OFFSET + i);
animation -> setActsOnRows(true);
animation -> setStartValue(QVariant(tbgrid_ -> rowMinimumHeight(ROW_OFFSET + i)));
@@ -665,7 +665,7 @@ void TitleBlockTemplateView::updateRowsHelperCells() {
int row_count = tbtemplate_ -> rowsCount();
QList<int> heights = tbtemplate_ -> rowsHeights();
for (int i = 0 ; i < row_count ; ++ i) {
HelperCell *current_row_cell = static_cast<HelperCell *>(tbgrid_ -> itemAt(ROW_OFFSET + i, 0));
auto *current_row_cell = static_cast<HelperCell *>(tbgrid_ -> itemAt(ROW_OFFSET + i, 0));
if (current_row_cell) {
current_row_cell -> setType(QET::Absolute); // rows always have absolute heights
current_row_cell -> setLabel(QString(tr("%1px", "format displayed in rows helper cells")).arg(heights.at(i)));
@@ -680,7 +680,7 @@ void TitleBlockTemplateView::updateColumnsHelperCells() {
int col_count = tbtemplate_ -> columnsCount();
for (int i = 0 ; i < col_count ; ++ i) {
TitleBlockDimension current_col_dim = tbtemplate_ -> columnDimension(i);
HelperCell *current_col_cell = static_cast<HelperCell *>(tbgrid_ -> itemAt(1, COL_OFFSET + i));
auto *current_col_cell = static_cast<HelperCell *>(tbgrid_ -> itemAt(1, COL_OFFSET + i));
if (current_col_cell) {
current_col_cell -> setType(current_col_dim.type);
current_col_cell -> setLabel(current_col_dim.toString());
@@ -714,7 +714,7 @@ void TitleBlockTemplateView::addCells() {
// we add one cell per column to show their respective width
for (int i = 0 ; i < col_count ; ++ i) {
TitleBlockDimension current_col_dim = tbtemplate_ -> columnDimension(i);
HelperCell *current_col_cell = new HelperCell();
auto *current_col_cell = new HelperCell();
current_col_cell -> setType(current_col_dim.type);
current_col_cell -> setLabel(current_col_dim.toString());
current_col_cell -> setActions(columnsActions());
@@ -728,7 +728,7 @@ void TitleBlockTemplateView::addCells() {
// we add one cell per row to show their respective height
QList<int> heights = tbtemplate_ -> rowsHeights();
for (int i = 0 ; i < row_count ; ++ i) {
HelperCell *current_row_cell = new HelperCell();
auto *current_row_cell = new HelperCell();
current_row_cell -> setType(QET::Absolute); // rows always have absolute heights
current_row_cell -> setLabel(QString(tr("%1px")).arg(heights.at(i)));
current_row_cell -> orientation = Qt::Vertical;
@@ -744,7 +744,7 @@ void TitleBlockTemplateView::addCells() {
for (int j = 0 ; j < row_count ; ++ j) {
TitleBlockCell *cell = tbtemplate_ -> cell(j, i);
if (cell -> spanner_cell) continue;
TitleBlockTemplateVisualCell *cell_item = new TitleBlockTemplateVisualCell();
auto *cell_item = new TitleBlockTemplateVisualCell();
cell_item -> setTemplateCell(tbtemplate_, cell);
int row_span = 0, col_span = 0;
@@ -768,7 +768,7 @@ void TitleBlockTemplateView::refresh() {
for (int i = 0 ; i < col_count ; ++ i) {
for (int j = 0 ; j < row_count ; ++ j) {
if (QGraphicsLayoutItem *item = tbgrid_ -> itemAt(ROW_OFFSET + j, COL_OFFSET + i)) {
if (QGraphicsItem *qgi = dynamic_cast<QGraphicsItem *>(item)) {
if (auto *qgi = dynamic_cast<QGraphicsItem *>(item)) {
qgi -> update();
}
}
@@ -800,7 +800,7 @@ void TitleBlockTemplateView::fillWithEmptyCells() {
for (int i = 0 ; i < col_count ; ++ i) {
for (int j = 0 ; j < row_count ; ++ j) {
if (tbgrid_ -> itemAt(ROW_OFFSET + j, COL_OFFSET + i)) continue;
TitleBlockTemplateVisualCell *cell_item = new TitleBlockTemplateVisualCell();
auto *cell_item = new TitleBlockTemplateVisualCell();
if (TitleBlockCell *target_cell = tbtemplate_ -> cell(j, i)) {
qDebug() << Q_FUNC_INFO << "target_cell" << target_cell;
cell_item -> setTemplateCell(tbtemplate_, target_cell);
@@ -1057,7 +1057,7 @@ void TitleBlockTemplateView::removeItem(QGraphicsLayoutItem *item) {
TitleBlockTemplateCellsSet TitleBlockTemplateView::makeCellsSetFromGraphicsItems(const QList<QGraphicsItem *> &items) const {
TitleBlockTemplateCellsSet set(this);
foreach (QGraphicsItem *item, items) {
if (TitleBlockTemplateVisualCell *cell_view = dynamic_cast<TitleBlockTemplateVisualCell *>(item)) {
if (auto *cell_view = dynamic_cast<TitleBlockTemplateVisualCell *>(item)) {
if (cell_view -> cell() && cell_view -> cell() -> num_row != -1) {
set << cell_view;
}