mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-13 10:04:13 +02:00
Add "Insert folio above/below" to the elements panel's folio menu
"Add folio" always appends to the end of the project, ignoring whatever folio is currently selected in the left panel -- even though the panel already tracks the selected diagram's position for its existing move up/down/top actions, and QETProject::addNewDiagram(pos) already accepts an arbitrary insertion index, pushed as an undoable AddDiagramCommand (QetGraphicsTableFactory::create() already relies on this exact mechanism to insert a folio right after a specific one). Add two new context-menu actions that compute the target position from the selected diagram's folioIndex() and pass it straight through the existing machinery -- no changes needed to QETProject or AddDiagramCommand. New requestForNewDiagramAt/addDiagramToProjectAt signal/slot pair added alongside the existing requestForNewDiagram/addDiagramToProject rather than changing it, so the plain "Add folio" action's append-at-end behavior is untouched.
This commit is contained in:
@@ -61,6 +61,8 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
||||
prj_edit_prop = new QAction(QET::Icons::DialogInformation, tr("Propriétés du projet"), this);
|
||||
prj_prop_diagram = new QAction(QET::Icons::DialogInformation, tr("Propriétés du folio"), this);
|
||||
prj_add_diagram = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un folio"), this);
|
||||
prj_insert_diagram_above = new QAction(QET::Icons::DiagramAdd, tr("Insérer un folio au-dessus"), this);
|
||||
prj_insert_diagram_below = new QAction(QET::Icons::DiagramAdd, tr("Insérer un folio en dessous"), this);
|
||||
prj_duplicate_diagram = new QAction(QET::Icons::IC_CopyFile, tr("Copier et coller"), this);
|
||||
prj_del_diagram = new QAction(QET::Icons::DiagramDelete, tr("Supprimer ce folio"), this);
|
||||
prj_move_diagram_up = new QAction(QET::Icons::GoUp, tr("Remonter ce folio"), this);
|
||||
@@ -101,6 +103,8 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
||||
connect(prj_edit_prop, SIGNAL(triggered()), this, SLOT(editProjectProperties()));
|
||||
connect(prj_prop_diagram, SIGNAL(triggered()), this, SLOT(editDiagramProperties()));
|
||||
connect(prj_add_diagram, SIGNAL(triggered()), this, SLOT(newDiagram()));
|
||||
connect(prj_insert_diagram_above, SIGNAL(triggered()), this, SLOT(insertDiagramAbove()));
|
||||
connect(prj_insert_diagram_below, SIGNAL(triggered()), this, SLOT(insertDiagramBelow()));
|
||||
connect(prj_del_diagram, SIGNAL(triggered()), this, SLOT(deleteDiagram()));
|
||||
connect(prj_duplicate_diagram, SIGNAL(triggered()), this, SLOT(duplicateDiagram()));
|
||||
connect(prj_move_diagram_up, SIGNAL(triggered()), this, SLOT(moveDiagramUp()));
|
||||
@@ -245,6 +249,32 @@ void ElementsPanelWidget::newDiagram()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementsPanelWidget::insertDiagramAbove
|
||||
Emit requestForNewDiagramAt with the position of the currently
|
||||
selected diagram, inserting the new folio right before it.
|
||||
*/
|
||||
void ElementsPanelWidget::insertDiagramAbove()
|
||||
{
|
||||
if (Diagram *selected_diagram = elements_panel -> selectedDiagram()) {
|
||||
QETProject *project = selected_diagram->project();
|
||||
emit(requestForNewDiagramAt(project, project->folioIndex(selected_diagram)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementsPanelWidget::insertDiagramBelow
|
||||
Emit requestForNewDiagramAt with the position right after the
|
||||
currently selected diagram, inserting the new folio right after it.
|
||||
*/
|
||||
void ElementsPanelWidget::insertDiagramBelow()
|
||||
{
|
||||
if (Diagram *selected_diagram = elements_panel -> selectedDiagram()) {
|
||||
QETProject *project = selected_diagram->project();
|
||||
emit(requestForNewDiagramAt(project, project->folioIndex(selected_diagram) + 1));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Emet le signal requestForDiagramsDeletion avec les schemas selectionnes
|
||||
*/
|
||||
@@ -451,6 +481,8 @@ void ElementsPanelWidget::updateButtons()
|
||||
|
||||
prj_del_diagram -> setEnabled(is_writable);
|
||||
prj_duplicate_diagram -> setEnabled(is_writable);
|
||||
prj_insert_diagram_above -> setEnabled(is_writable);
|
||||
prj_insert_diagram_below -> setEnabled(is_writable);
|
||||
prj_move_diagram_up -> setEnabled(is_writable && min_position > 0);
|
||||
prj_move_diagram_down -> setEnabled(is_writable && max_position < project_diagrams_count - 1);
|
||||
prj_move_diagram_top -> setEnabled(is_writable && min_position > 0);
|
||||
@@ -504,6 +536,8 @@ void ElementsPanelWidget::handleContextMenu(const QPoint &pos) {
|
||||
break;
|
||||
case QET::Diagram:
|
||||
context_menu -> addAction(prj_prop_diagram);
|
||||
context_menu -> addAction(prj_insert_diagram_above);
|
||||
context_menu -> addAction(prj_insert_diagram_below);
|
||||
context_menu -> addAction(prj_del_diagram);
|
||||
context_menu -> addAction(prj_duplicate_diagram);
|
||||
context_menu -> addAction(prj_move_diagram_top);
|
||||
|
||||
Reference in New Issue
Block a user