diff --git a/sources/ElementsCollection/elementscollectionmodel.cpp b/sources/ElementsCollection/elementscollectionmodel.cpp index 7e28f678e..b7305ffaa 100644 --- a/sources/ElementsCollection/elementscollectionmodel.cpp +++ b/sources/ElementsCollection/elementscollectionmodel.cpp @@ -172,10 +172,12 @@ bool ElementsCollectionModel::dropMimeData(const QMimeData *data, const QModelIndex &parent) { Q_UNUSED(action) - QStandardItem *qsi = itemFromIndex( - parent.QModelIndex::model()->index(row, column)); - if (!qsi) - qsi = itemFromIndex(parent); + + const QAbstractItemModel* qaim = parent.QModelIndex::model(); + if (! qaim) return false; + + QStandardItem* qsi = itemFromIndex(qaim->index(row, column)); + if (! qsi) qsi = itemFromIndex(parent); if (qsi->type() == FileElementCollectionItem::Type) { diff --git a/sources/ElementsCollection/elementscollectionwidget.cpp b/sources/ElementsCollection/elementscollectionwidget.cpp index d86a35266..584bfa6ae 100644 --- a/sources/ElementsCollection/elementscollectionwidget.cpp +++ b/sources/ElementsCollection/elementscollectionwidget.cpp @@ -591,37 +591,32 @@ void ElementsCollectionWidget::resetShowThisDir() */ void ElementsCollectionWidget::dirProperties() { - ElementCollectionItem *eci = elementCollectionItemForIndex( - m_index_at_context_menu); - //When the user right-clicks on the collection tree and - //selects the collection property, the collection name, - //file path and number of elements will be added - //to the qInfo log file. - qInfo() <localName()) - <elementsChild().size() - <(eci)->fileSystemPath()); - if (eci && eci->isDir()) { - QString txt1 = tr("Le dossier %1 contient").arg( - eci->localName()); - QString txt2 = tr("%n élément(s), répartie(s)", - "", - eci->elementsChild().size()); - QString txt3 = tr("dans %n dossier(s).", - "" , - eci->directoriesChild().size()); - QString txt4 = tr("Chemin de la collection : %1").arg( - eci->collectionPath()); - QString txt5; + ElementCollectionItem* eci = + elementCollectionItemForIndex(m_index_at_context_menu); + + if (eci && eci->isDir()) + { + QString filePath; if (eci->type() == FileElementCollectionItem::Type) { - txt5 = tr("Chemin dans le système de fichiers : %1") - .arg(static_cast(eci)->fileSystemPath()); + filePath = tr("Chemin dans le système de fichiers : %1") + .arg( + static_cast(eci) + ->fileSystemPath()); } + QString out = + tr("Le dossier %1 contient").arg(eci->localName()) % " " + % tr("%n élément(s), répartie(s)", "", eci->elementsChild().size()) + % " " + % tr("dans %n dossier(s).", "", eci->directoriesChild().size()) + % "\n\n" + % tr("Chemin de la collection : %1").arg(eci->collectionPath()) + % "\n" % filePath; + qInfo() << out; QMessageBox::information( this, tr("Propriété du dossier %1").arg(eci->localName()), - txt1 % " " % txt2 % " " % txt3 % "\n\n" % txt4 % "\n" % txt5); - } + out); + } } /** diff --git a/sources/ElementsCollection/elementstreeview.cpp b/sources/ElementsCollection/elementstreeview.cpp index e84b6a3ce..00f39b529 100644 --- a/sources/ElementsCollection/elementstreeview.cpp +++ b/sources/ElementsCollection/elementstreeview.cpp @@ -82,7 +82,11 @@ void ElementsTreeView::startElementDrag(const ElementsLocation &location) { if (! location.exist()) return; +#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0) + QDrag* drag = new QDrag(this); +#else QScopedPointer drag(new QDrag(this)); +#endif QString location_str = location.toString(); QMimeData *mime_data = new QMimeData(); diff --git a/sources/print/projectprintwindow.cpp b/sources/print/projectprintwindow.cpp index 6522020d3..4b234e418 100644 --- a/sources/print/projectprintwindow.cpp +++ b/sources/print/projectprintwindow.cpp @@ -234,9 +234,9 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter { ////Prepare the print//// - //Deselect all + // Deselect all diagram->deselectAll(); - //Disable focus flags + // Disable focus flags QList focusable_items; for (auto qgi : diagram->items()) { if (qgi->flags() & QGraphicsItem::ItemIsFocusable) { @@ -244,7 +244,7 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter qgi->setFlag(QGraphicsItem::ItemIsFocusable, false); } } - //Disable interaction + // Disable interaction for (auto view : diagram->views()) { view->setInteractive(false); } @@ -254,7 +254,7 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter auto full_page = printer->fullPage(); - auto diagram_rect = diagramRect(diagram, option); + auto diagram_rect = QRectF(diagramRect(diagram, option)); if (fit_page) { diagram->render(painter, QRectF(), diagram_rect, Qt::KeepAspectRatio); } else { @@ -266,57 +266,58 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter #pragma message("@TODO remove code for QT 6 or later") #endif qDebug()<<"Help code for QT 6 or later"; - auto printed_rect = full_page ? printer->paperRect(QPrinter::Millimeter) : printer->pageRect(QPrinter::Millimeter); + auto printed_rect = full_page ? printer->paperRect(QPrinter::Millimeter) : + printer->pageRect(QPrinter::Millimeter); #endif auto used_width = printed_rect.width(); auto used_height = printed_rect.height(); auto h_pages_count = horizontalPagesCount(diagram, option, full_page); auto v_pages_count = verticalPagesCount(diagram, option, full_page); - QVector> page_grid; - //The diagram is printed on a matrix of sheet - //scrolls through the rows of the matrix + QVector> page_grid; + // The diagram is printed on a matrix of sheet + // scrolls through the rows of the matrix auto y_offset = 0; - for (auto i=0 ; i(); - //scrolls through the lines of sheet + page_grid << QVector(); + // scrolls through the lines of sheet auto x_offset = 0; for (auto j=0 ; j page_to_print; + // Retains only the pages to be printed + QVector page_to_print; for (auto i=0 ; i < v_pages_count ; ++i) { for (int j=0 ; j < h_pages_count ; ++j) { page_to_print << page_grid.at(i).at(j); } } - //Scrolls through the page for print + // Scrolls through the page for print bool first_ = true; - for (auto page : page_to_print) + for (auto& page : page_to_print) { first_ ? first_ = false : m_printer->newPage(); - diagram->render(painter, QRect(QPoint(0,0), page.size()), page.translated(diagram_rect.topLeft()), Qt::KeepAspectRatio); + diagram->render( + painter, + QRectF(QPoint(0, 0), page.size()), + page.translated(diagram_rect.topLeft()), + Qt::KeepAspectRatio); } } - ////Print is finished, restore diagram and graphics item properties + ////Print is finished, restore diagram and graphics item properties for (auto view : diagram->views()) { view->setInteractive(true); } diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 8e8b8c263..ca1868d97 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -775,12 +775,12 @@ void QETDiagramEditor::setUpToolBar() void QETDiagramEditor::setUpMenu() { - QMenu *menu_fichier = new QMenu(tr("&Fichier")); - QMenu *menu_edition = new QMenu(tr("&Édition")); - QMenu *menu_project = new QMenu(tr("&Projet")); - QMenu *menu_affichage = new QMenu(tr("Afficha&ge")); - //QMenu *menu_outils = new QMenu(tr("O&utils")); - windows_menu = new QMenu(tr("Fe&nêtres")); + QMenu* menu_fichier = new QMenu(tr("&Fichier"), this); + QMenu* menu_edition = new QMenu(tr("&Édition"), this); + QMenu* menu_project = new QMenu(tr("&Projet"), this); + QMenu* menu_affichage = new QMenu(tr("Afficha&ge"), this); + // QMenu *menu_outils = new QMenu(tr("O&utils"), this); + windows_menu = new QMenu(tr("Fe&nêtres"), this); insertMenu(settings_menu_, menu_fichier); insertMenu(settings_menu_, menu_edition); diff --git a/sources/qetmainwindow.cpp b/sources/qetmainwindow.cpp index db20a1a93..c9f4c9570 100644 --- a/sources/qetmainwindow.cpp +++ b/sources/qetmainwindow.cpp @@ -142,13 +142,12 @@ void QETMainWindow::initCommonActions() */ void QETMainWindow::initCommonMenus() { - settings_menu_ = new QMenu(tr("&Configuration", "window menu")); + settings_menu_ = new QMenu(tr("&Configuration", "window menu"), this); settings_menu_ -> addAction(fullscreen_action_); settings_menu_ -> addAction(configure_action_); connect(settings_menu_, SIGNAL(aboutToShow()), this, SLOT(checkToolbarsmenu())); - - help_menu_ = new QMenu(tr("&Aide", "window menu")); + help_menu_ = new QMenu(tr("&Aide", "window menu"), this); help_menu_ -> addAction(whatsthis_action_); help_menu_ -> addSeparator(); help_menu_ -> addAction(manual_online_); diff --git a/sources/titleblock/qettemplateeditor.cpp b/sources/titleblock/qettemplateeditor.cpp index d270567cd..07dfb2d48 100644 --- a/sources/titleblock/qettemplateeditor.cpp +++ b/sources/titleblock/qettemplateeditor.cpp @@ -437,8 +437,8 @@ void QETTitleBlockTemplateEditor::initActions() */ void QETTitleBlockTemplateEditor::initMenus() { - file_menu_ = new QMenu(tr("&Fichier", "menu title"), this); - edit_menu_ = new QMenu(tr("&Édition", "menu title"), this); + file_menu_ = new QMenu(tr("&Fichier", "menu title"), this); + edit_menu_ = new QMenu(tr("&Édition", "menu title"), this); display_menu_ = new QMenu(tr("Afficha&ge", "menu title"), this); file_menu_ -> addAction(new_); diff --git a/sources/ui/titleblockpropertieswidget.cpp b/sources/ui/titleblockpropertieswidget.cpp index e1fb9e250..109362380 100644 --- a/sources/ui/titleblockpropertieswidget.cpp +++ b/sources/ui/titleblockpropertieswidget.cpp @@ -338,7 +338,7 @@ void TitleBlockPropertiesWidget::initDialog( this, SLOT(duplicateCurrentTitleBlockTemplate())); - m_tbt_menu = new QMenu(tr("Title block templates actions")); + m_tbt_menu = new QMenu(tr("Title block templates actions"), ui->m_tbt_pb); m_tbt_menu -> addAction(m_tbt_edit); m_tbt_menu -> addAction(m_tbt_duplicate); ui -> m_tbt_pb -> setMenu(m_tbt_menu);