@@ -540,7 +540,7 @@ int OutputEditorHOCR::currentPage() {
540540}
541541
542542void OutputEditorHOCR::showItemProperties (const QModelIndex& index, const QModelIndex& prev) {
543- m_tool->setAction (DisplayerToolHOCR::ACTION_NONE );
543+ m_tool->setAction (DisplayerToolHOCR::ACTION_NONE , QModelIndex () );
544544 const HOCRItem* prevItem = m_document->itemAtIndex (prev);
545545 ui.tableWidgetProperties ->setRowCount (0 );
546546 ui.plainTextEditOutput ->setPlainText (" " );
@@ -685,10 +685,9 @@ void OutputEditorHOCR::itemAttributeChanged(const QModelIndex& itemIndex, const
685685 }
686686}
687687
688- void OutputEditorHOCR::bboxDrawn (const QRect& bbox, int action) {
688+ void OutputEditorHOCR::bboxDrawn (const QRect& bbox, int action, QModelIndex index ) {
689689 QDomDocument doc;
690- QModelIndex current = ui.treeViewHOCR ->selectionModel ()->currentIndex ();
691- const HOCRItem* currentItem = m_document->itemAtIndex (current);
690+ const HOCRItem* currentItem = m_document->itemAtIndex (index);
692691 if (!currentItem) {
693692 return ;
694693 }
@@ -746,7 +745,7 @@ void OutputEditorHOCR::bboxDrawn(const QRect& bbox, int action) {
746745 } else {
747746 return ;
748747 }
749- QModelIndex newIndex = m_document->addItem (current , newElement);
748+ QModelIndex newIndex = m_document->addItem (index , newElement);
750749 if (newIndex.isValid ()) {
751750 ui.treeViewHOCR ->selectionModel ()->setCurrentIndex (newIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
752751 }
@@ -864,21 +863,21 @@ void OutputEditorHOCR::showTreeWidgetContextMenu(const QPoint& point) {
864863 return ;
865864 }
866865 if (clickedAction == actionAddGraphic) {
867- m_tool->setAction (DisplayerToolHOCR::ACTION_DRAW_GRAPHIC_RECT );
866+ m_tool->setAction (DisplayerToolHOCR::ACTION_DRAW_GRAPHIC_RECT , index );
868867 } else if (clickedAction == actionAddCArea) {
869- m_tool->setAction (DisplayerToolHOCR::ACTION_DRAW_CAREA_RECT );
868+ m_tool->setAction (DisplayerToolHOCR::ACTION_DRAW_CAREA_RECT , index );
870869 } else if (clickedAction == actionAddPar) {
871- m_tool->setAction (DisplayerToolHOCR::ACTION_DRAW_PAR_RECT );
870+ m_tool->setAction (DisplayerToolHOCR::ACTION_DRAW_PAR_RECT , index );
872871 } else if (clickedAction == actionAddLine) {
873- m_tool->setAction (DisplayerToolHOCR::ACTION_DRAW_LINE_RECT );
872+ m_tool->setAction (DisplayerToolHOCR::ACTION_DRAW_LINE_RECT , index );
874873 } else if (clickedAction == actionAddWord) {
875- m_tool->setAction (DisplayerToolHOCR::ACTION_DRAW_WORD_RECT );
874+ m_tool->setAction (DisplayerToolHOCR::ACTION_DRAW_WORD_RECT , index );
876875 } else if (clickedAction == actionSplit) {
877876 QModelIndex newIndex = m_document->splitItem (index.parent (), index.row (), index.row ());
878877 ui.treeViewHOCR ->selectionModel ()->setCurrentIndex (newIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
879878 expandCollapseChildren (newIndex, true );
880879 } else if (clickedAction == actionRemove) {
881- m_document->removeItem (ui. treeViewHOCR -> selectionModel ()-> currentIndex () );
880+ m_document->removeItem (index );
882881 } else if (clickedAction == actionExpand) {
883882 expandCollapseChildren (index, true );
884883 } else if (clickedAction == actionCollapse) {
0 commit comments