void PlaybackController::loadIndex() { if(m_reader->isCompressed()) { emit indexLoadError(tr("Cannot index compressed recordings."), false); return; } QFileInfo indexfile(indexFileName()); if(!indexfile.exists()) { emit indexLoadError(tr("Index not yet generated"), true); return; } m_indexloader = new IndexLoader(m_reader->filename(), indexFileName()); if(!m_indexloader->open()) { delete m_indexloader; m_indexloader = nullptr; emit indexLoadError(tr("Error loading index!"), true); return; } emit markersChanged(); emit indexLoaded(); }
void HaiQTextEdit::remove_marker(const QString &marker_id) { if (!markers.contains(marker_id)) { qWarning() << "HaiQTextEdit does not contain marker" << marker_id; return; } bool hold_emit_modification_changed=do_emit_modification_changed; haiq_marker marker=markers[marker_id]; do_emit_modification_changed=false; if (marker.marker_type==MARKER_TYPE_TEMPORARY) has_temporary_marker=false; QTextBlock block=marker_blocks[marker_id]; markers.remove(marker_id); marker_blocks.remove(marker_id); bool markers_changed=false; if (block.isValid()) { QTextCursor cursor(block); defaultedit_blockdata *data=(defaultedit_blockdata *)block.userData(); if (data) { data->remove_marker(marker_id); marker_blocks.remove(marker_id); markers_changed=true; do_marker_highlighting(cursor); } else { qWarning() << "data is NULL in HaiQDefaultEdit::remove_marker"; } } else { qWarning() << "block is not valid in HaiQDefaultEdit::remove_marker"; } do_emit_modification_changed=hold_emit_modification_changed; if (markers_changed) emit markersChanged(); }
void HaiQTextEdit::add_marker(haiq_marker marker) { bool hold_emit_modification_changed=do_emit_modification_changed; do_emit_modification_changed=false; if ((has_temporary_marker)&&(marker.marker_type==MARKER_TYPE_TEMPORARY)) { remove_markers_of_type(MARKER_TYPE_TEMPORARY); } QTextCursor cursor=textCursor(); int num=cursor.blockNumber(); if (num<marker.line_number-1) { cursor.movePosition(QTextCursor::NextBlock,QTextCursor::MoveAnchor,(marker.line_number-1)-num); } else if (num>marker.line_number-1) { cursor.movePosition(QTextCursor::PreviousBlock,QTextCursor::MoveAnchor,num-(marker.line_number-1)); } cursor.movePosition(QTextCursor::StartOfBlock); QTextBlock block=cursor.block(); defaultedit_blockdata *block_data=(defaultedit_blockdata *)block.userData(); if (!block_data) { block_data=new defaultedit_blockdata; block.setUserData(block_data); } if (block_data->has_marker(marker.marker_type)) return; //already has such a marker block_data->add_marker(marker); if (marker.marker_type==MARKER_TYPE_TEMPORARY) { has_temporary_marker=true; } do_marker_highlighting(cursor); markers[marker.id]=marker; marker_blocks[marker.id]=cursor.block(); do_emit_modification_changed=hold_emit_modification_changed; emit markersChanged(); };
void PlaybackController::addMarker(const QString &text) { if(!m_indexloader) return; m_indexloader->index().addMarker(m_reader->currentPosition(), m_reader->currentIndex(), text); emit markersChanged(); }
void MarkerWidget::contextMenuEvent( QContextMenuEvent *e ) { QPopupMenu m( 0, "editor_breakpointsmenu" ); int toggleBreakPoint = 0; // int editBreakpoints = 0; QTextParagraph *p = ( (Editor*)viewManager->currentView() )->document()->firstParagraph(); int yOffset = ( (Editor*)viewManager->currentView() )->contentsY(); bool supports = ( (Editor*)viewManager->currentView() )->supportsBreakPoints(); while ( p && supports ) { if ( e->y() >= p->rect().y() - yOffset && e->y() <= p->rect().y() + p->rect().height() - yOffset ) { if ( ( (ParagData*)p->extraData() )->marker == ParagData::Breakpoint ) toggleBreakPoint = m.insertItem( tr( "Clear Breakpoint\tF9" ) ); else toggleBreakPoint = m.insertItem( tr( "Set Breakpoint\tF9" ) ); // editBreakpoints = m.insertItem( tr( "Edit Breakpoints..." ) ); m.insertSeparator(); break; } p = p->next(); } const int collapseAll = m.insertItem( tr( "Collapse All" ) ); const int expandAll = m.insertItem( tr( "Expand All" ) ); const int collapseFunctions = m.insertItem( tr( "Collapse all Functions" ) ); const int expandFunctions = m.insertItem( tr( "Expand all Functions" ) ); int res = m.exec( e->globalPos() ); if ( res == -1) return; if ( res == collapseAll ) { emit collapse( TRUE ); } else if ( res == collapseFunctions ) { emit collapse( FALSE ); } else if ( res == expandAll ) { emit expand( TRUE ); } else if ( res == expandFunctions ) { emit expand( FALSE ); } else if ( res == toggleBreakPoint ) { if ( ( (ParagData*)p->extraData() )->marker == ParagData::Breakpoint ) { ( (ParagData*)p->extraData() )->marker = ParagData::NoMarker; } else { bool ok; isBreakpointPossible( ok, ( (Editor*)viewManager->currentView() )->text(), p->paragId() ); if ( ok ) ( (ParagData*)p->extraData() )->marker = ParagData::Breakpoint; else emit showMessage( tr( "<font color=red>Can't set breakpoint here!</font>" ) ); } // } else if ( res == editBreakpoints ) { // emit editBreakPoints(); } doRepaint(); emit markersChanged(); }
bool ViewManager::qt_emit( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->signalOffset() ) { case 0: markersChanged(); break; case 1: expandFunction((QTextParagraph*)static_QUType_ptr.get(_o+1)); break; case 2: collapseFunction((QTextParagraph*)static_QUType_ptr.get(_o+1)); break; case 3: collapse((bool)static_QUType_bool.get(_o+1)); break; case 4: expand((bool)static_QUType_bool.get(_o+1)); break; case 5: editBreakPoints(); break; case 6: isBreakpointPossible((bool&)static_QUType_bool.get(_o+1),(const QString&)static_QUType_QString.get(_o+2),(int)static_QUType_int.get(_o+3)); break; default: return QWidget::qt_emit(_id,_o); } return TRUE; }
void MarkerWidget::mousePressEvent( QMouseEvent *e ) { if ( e->button() != LeftButton ) return; bool supports = ( (Editor*)viewManager->currentView() )->supportsBreakPoints(); QTextParagraph *p = ( (Editor*)viewManager->currentView() )->document()->firstParagraph(); int yOffset = ( (Editor*)viewManager->currentView() )->contentsY(); while ( p ) { if ( e->y() >= p->rect().y() - yOffset && e->y() <= p->rect().y() + p->rect().height() - yOffset ) { QTextParagraphData *d = p->extraData(); if ( !d ) return; ParagData *data = (ParagData*)d; if ( supports && ( e->x() < width() - 15 ) ) { if ( data->marker == ParagData::Breakpoint ) { data->marker = ParagData::NoMarker; } else { bool ok = TRUE; isBreakpointPossible( ok, ( (Editor*)viewManager->currentView() )->text(), p->paragId() ); if ( ok ) data->marker = ParagData::Breakpoint; else emit showMessage( tr( "<font color=red>Can't set breakpoint here!</font>" ) ); } } else { if ( data->lineState == ParagData::FunctionStart ) { if ( data->functionOpen ) emit collapseFunction( p ); else emit expandFunction( p ); } } break; } p = p->next(); } doRepaint(); emit markersChanged(); }
void HaiQTextEdit::toggle_marker(int marker_type,QString path) { bool markers_changed=false; QTextCursor cursor=textCursor(); QTextBlock block=cursor.block(); defaultedit_blockdata *block_data=(defaultedit_blockdata *)block.userData(); if (!block_data) { block_data=new defaultedit_blockdata; block.setUserData(block_data); } if (block_data->has_marker(marker_type)) { block_data->remove_markers_of_type(marker_type); markers_changed=true; } else { haiq_marker marker; marker.path=path; marker.marker_type=marker_type; marker.line_number=textCursor().blockNumber()+1; set_random_id(marker); add_marker(marker); } do_marker_highlighting(cursor); if (markers_changed) emit markersChanged(); }
void EditorInterfaceImpl::onBreakPointChange( QObject *receiver, const char *slot ) { if ( !viewManager ) return; connect( viewManager, SIGNAL( markersChanged() ), receiver, slot ); }