mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Merge pull request #401 from Evilscrack/master
Minor corrections to prevent crashes
This commit is contained in:
commit
3cadedaf9e
@ -172,10 +172,12 @@ bool ElementsCollectionModel::dropMimeData(const QMimeData *data,
|
|||||||
const QModelIndex &parent)
|
const QModelIndex &parent)
|
||||||
{
|
{
|
||||||
Q_UNUSED(action)
|
Q_UNUSED(action)
|
||||||
QStandardItem *qsi = itemFromIndex(
|
|
||||||
parent.QModelIndex::model()->index(row, column));
|
const QAbstractItemModel* qaim = parent.QModelIndex::model();
|
||||||
if (!qsi)
|
if (! qaim) return false;
|
||||||
qsi = itemFromIndex(parent);
|
|
||||||
|
QStandardItem* qsi = itemFromIndex(qaim->index(row, column));
|
||||||
|
if (! qsi) qsi = itemFromIndex(parent);
|
||||||
|
|
||||||
if (qsi->type() == FileElementCollectionItem::Type)
|
if (qsi->type() == FileElementCollectionItem::Type)
|
||||||
{
|
{
|
||||||
|
@ -591,36 +591,31 @@ void ElementsCollectionWidget::resetShowThisDir()
|
|||||||
*/
|
*/
|
||||||
void ElementsCollectionWidget::dirProperties()
|
void ElementsCollectionWidget::dirProperties()
|
||||||
{
|
{
|
||||||
ElementCollectionItem *eci = elementCollectionItemForIndex(
|
ElementCollectionItem* eci =
|
||||||
m_index_at_context_menu);
|
elementCollectionItemForIndex(m_index_at_context_menu);
|
||||||
//When the user right-clicks on the collection tree and
|
|
||||||
//selects the collection property, the collection name,
|
if (eci && eci->isDir())
|
||||||
//file path and number of elements will be added
|
{
|
||||||
//to the qInfo log file.
|
QString filePath;
|
||||||
qInfo() <<tr("Le dossier") <<(eci->localName())
|
|
||||||
<<tr("contient")<<eci->elementsChild().size()
|
|
||||||
<<tr("éléments") <<"\n"<< "Path:"
|
|
||||||
<<(static_cast<FileElementCollectionItem*>(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;
|
|
||||||
if (eci->type() == FileElementCollectionItem::Type) {
|
if (eci->type() == FileElementCollectionItem::Type) {
|
||||||
txt5 = tr("Chemin dans le système de fichiers : %1")
|
filePath = tr("Chemin dans le système de fichiers : %1")
|
||||||
.arg(static_cast<FileElementCollectionItem*>(eci)->fileSystemPath());
|
.arg(
|
||||||
|
static_cast<FileElementCollectionItem*>(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(
|
QMessageBox::information(
|
||||||
this,
|
this,
|
||||||
tr("Propriété du dossier %1").arg(eci->localName()),
|
tr("Propriété du dossier %1").arg(eci->localName()),
|
||||||
txt1 % " " % txt2 % " " % txt3 % "\n\n" % txt4 % "\n" % txt5);
|
out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,11 @@ void ElementsTreeView::startElementDrag(const ElementsLocation &location)
|
|||||||
{
|
{
|
||||||
if (! location.exist()) return;
|
if (! location.exist()) return;
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
|
||||||
|
QDrag* drag = new QDrag(this);
|
||||||
|
#else
|
||||||
QScopedPointer<QDrag> drag(new QDrag(this));
|
QScopedPointer<QDrag> drag(new QDrag(this));
|
||||||
|
#endif
|
||||||
|
|
||||||
QString location_str = location.toString();
|
QString location_str = location.toString();
|
||||||
QMimeData *mime_data = new QMimeData();
|
QMimeData *mime_data = new QMimeData();
|
||||||
|
@ -254,7 +254,7 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter
|
|||||||
|
|
||||||
|
|
||||||
auto full_page = printer->fullPage();
|
auto full_page = printer->fullPage();
|
||||||
auto diagram_rect = diagramRect(diagram, option);
|
auto diagram_rect = QRectF(diagramRect(diagram, option));
|
||||||
if (fit_page) {
|
if (fit_page) {
|
||||||
diagram->render(painter, QRectF(), diagram_rect, Qt::KeepAspectRatio);
|
diagram->render(painter, QRectF(), diagram_rect, Qt::KeepAspectRatio);
|
||||||
} else {
|
} else {
|
||||||
@ -266,41 +266,38 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter
|
|||||||
#pragma message("@TODO remove code for QT 6 or later")
|
#pragma message("@TODO remove code for QT 6 or later")
|
||||||
#endif
|
#endif
|
||||||
qDebug()<<"Help code for QT 6 or later";
|
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
|
#endif
|
||||||
auto used_width = printed_rect.width();
|
auto used_width = printed_rect.width();
|
||||||
auto used_height = printed_rect.height();
|
auto used_height = printed_rect.height();
|
||||||
auto h_pages_count = horizontalPagesCount(diagram, option, full_page);
|
auto h_pages_count = horizontalPagesCount(diagram, option, full_page);
|
||||||
auto v_pages_count = verticalPagesCount(diagram, option, full_page);
|
auto v_pages_count = verticalPagesCount(diagram, option, full_page);
|
||||||
|
|
||||||
QVector<QVector<QRect>> page_grid;
|
QVector<QVector<QRectF>> page_grid;
|
||||||
// The diagram is printed on a matrix of sheet
|
// The diagram is printed on a matrix of sheet
|
||||||
// scrolls through the rows of the matrix
|
// scrolls through the rows of the matrix
|
||||||
auto y_offset = 0;
|
auto y_offset = 0;
|
||||||
for (auto i = 0; i < v_pages_count; ++i)
|
for (auto i = 0; i < v_pages_count; ++i)
|
||||||
{
|
{
|
||||||
page_grid << QVector<QRect>();
|
page_grid << QVector<QRectF>();
|
||||||
// scrolls through the lines of sheet
|
// scrolls through the lines of sheet
|
||||||
auto x_offset = 0;
|
auto x_offset = 0;
|
||||||
for (auto j=0 ; j<h_pages_count ; ++j)
|
for (auto j=0 ; j<h_pages_count ; ++j)
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 1) // ### Qt 6: remove
|
page_grid.last() << QRectF(
|
||||||
page_grid.last() << QRect(QPoint(x_offset, y_offset),
|
QPoint(x_offset, y_offset),
|
||||||
QSize(qMin(used_width, diagram_rect.width() - x_offset),
|
QSize(
|
||||||
|
qMin(used_width, diagram_rect.width() - x_offset),
|
||||||
qMin(used_height, diagram_rect.height() - y_offset)));
|
qMin(used_height, diagram_rect.height() - y_offset)));
|
||||||
#else
|
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO remove code for QT 6 or later")
|
|
||||||
#endif
|
|
||||||
qDebug()<<"Help code for QT 6 or later";
|
|
||||||
#endif
|
|
||||||
x_offset += used_width;
|
x_offset += used_width;
|
||||||
}
|
}
|
||||||
y_offset += used_height;
|
y_offset += used_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retains only the pages to be printed
|
// Retains only the pages to be printed
|
||||||
QVector<QRect> page_to_print;
|
QVector<QRectF> page_to_print;
|
||||||
for (auto i=0 ; i < v_pages_count ; ++i) {
|
for (auto i=0 ; i < v_pages_count ; ++i) {
|
||||||
for (int j=0 ; j < h_pages_count ; ++j) {
|
for (int j=0 ; j < h_pages_count ; ++j) {
|
||||||
page_to_print << page_grid.at(i).at(j);
|
page_to_print << page_grid.at(i).at(j);
|
||||||
@ -309,10 +306,14 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter
|
|||||||
|
|
||||||
// Scrolls through the page for print
|
// Scrolls through the page for print
|
||||||
bool first_ = true;
|
bool first_ = true;
|
||||||
for (auto page : page_to_print)
|
for (auto& page : page_to_print)
|
||||||
{
|
{
|
||||||
first_ ? first_ = false : m_printer->newPage();
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -775,12 +775,12 @@ void QETDiagramEditor::setUpToolBar()
|
|||||||
void QETDiagramEditor::setUpMenu()
|
void QETDiagramEditor::setUpMenu()
|
||||||
{
|
{
|
||||||
|
|
||||||
QMenu *menu_fichier = new QMenu(tr("&Fichier"));
|
QMenu* menu_fichier = new QMenu(tr("&Fichier"), this);
|
||||||
QMenu *menu_edition = new QMenu(tr("&Édition"));
|
QMenu* menu_edition = new QMenu(tr("&Édition"), this);
|
||||||
QMenu *menu_project = new QMenu(tr("&Projet"));
|
QMenu* menu_project = new QMenu(tr("&Projet"), this);
|
||||||
QMenu *menu_affichage = new QMenu(tr("Afficha&ge"));
|
QMenu* menu_affichage = new QMenu(tr("Afficha&ge"), this);
|
||||||
//QMenu *menu_outils = new QMenu(tr("O&utils"));
|
// QMenu *menu_outils = new QMenu(tr("O&utils"), this);
|
||||||
windows_menu = new QMenu(tr("Fe&nêtres"));
|
windows_menu = new QMenu(tr("Fe&nêtres"), this);
|
||||||
|
|
||||||
insertMenu(settings_menu_, menu_fichier);
|
insertMenu(settings_menu_, menu_fichier);
|
||||||
insertMenu(settings_menu_, menu_edition);
|
insertMenu(settings_menu_, menu_edition);
|
||||||
|
@ -142,13 +142,12 @@ void QETMainWindow::initCommonActions()
|
|||||||
*/
|
*/
|
||||||
void QETMainWindow::initCommonMenus()
|
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(fullscreen_action_);
|
||||||
settings_menu_ -> addAction(configure_action_);
|
settings_menu_ -> addAction(configure_action_);
|
||||||
connect(settings_menu_, SIGNAL(aboutToShow()), this, SLOT(checkToolbarsmenu()));
|
connect(settings_menu_, SIGNAL(aboutToShow()), this, SLOT(checkToolbarsmenu()));
|
||||||
|
|
||||||
|
help_menu_ = new QMenu(tr("&Aide", "window menu"), this);
|
||||||
help_menu_ = new QMenu(tr("&Aide", "window menu"));
|
|
||||||
help_menu_ -> addAction(whatsthis_action_);
|
help_menu_ -> addAction(whatsthis_action_);
|
||||||
help_menu_ -> addSeparator();
|
help_menu_ -> addSeparator();
|
||||||
help_menu_ -> addAction(manual_online_);
|
help_menu_ -> addAction(manual_online_);
|
||||||
|
@ -338,7 +338,7 @@ void TitleBlockPropertiesWidget::initDialog(
|
|||||||
this,
|
this,
|
||||||
SLOT(duplicateCurrentTitleBlockTemplate()));
|
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_edit);
|
||||||
m_tbt_menu -> addAction(m_tbt_duplicate);
|
m_tbt_menu -> addAction(m_tbt_duplicate);
|
||||||
ui -> m_tbt_pb -> setMenu(m_tbt_menu);
|
ui -> m_tbt_pb -> setMenu(m_tbt_menu);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user