@@ -354,139 +354,6 @@ int QGCodeEditor::getLineCount()
354354// By saving a copy of what was loaded and then comparing it to what is present, it
355355// reports accurately on any change.
356356
357- /* *
358- * @brief Checks if the document has been modified
359- * @return true if the document content differs from original, false otherwise
360- *
361- * Compares current document content against the stored original content
362- * to accurately detect modifications.
363- */
364- bool QGCodeEditor::isModified ()
365- {
366- QString txt = toPlainText ();
367- QStringList list = txt.split ( " \n " );
368-
369- if ( contents->size () != list.size () )
370- return true ;
371-
372- for (int x = 0 ; x < contents->size (); x++)
373- {
374- if ( contents->at (x) != list[x] )
375- return true ;
376- }
377- return false ;
378- }
379-
380-
381- /* *
382- * @brief Gets the text at the current cursor position
383- * @return Text of the line at cursor position, trimmed
384- */
385- QString QGCodeEditor::getCurrentText ()
386- {
387- QTextDocument *doc = document ();
388-
389- QTextBlock block = doc->findBlock ( textCursor ().position ());
390- return (block.text ().trimmed ().toLatin1 ());
391- }
392-
393- /* *
394- * @brief Moves cursor up one block
395- */
396- void QGCodeEditor::cursorUp ()
397- {
398- moveCursor (QTextCursor::PreviousBlock);
399- }
400-
401- /* *
402- * @brief Moves cursor down one block
403- */
404- void QGCodeEditor::cursorDown ()
405- {
406- moveCursor (QTextCursor::NextBlock);
407- }
408-
409- /* *
410- * @brief Gets the current line number
411- * @return Line number where cursor is positioned (1-based)
412- */
413- int QGCodeEditor::getLineNo ()
414- {
415- int numBlocks = blockCount ();
416- QTextDocument *doc = document ();
417-
418- QTextBlock blk = doc->findBlock ( textCursor ().position () );
419- QTextBlock blk2 = doc->begin ();
420-
421- for (int x = 1 ; x <= numBlocks; x++)
422- {
423- if (blk == blk2)
424- return x;
425- blk2 = blk2.next ();
426- }
427- return 0 ;
428- }
429-
430- /* *
431- * @brief Moves cursor to specified line
432- * @param line Line number to highlight (1-based)
433- */
434- void QGCodeEditor::highlightLine (int line)
435- {
436- int num = 0 ;
437-
438- // when file loaded, highlights first blank line at end with EOF,
439- // so never matched and returns 0 unless go up 1 first
440-
441- if ( blockCount ())
442- {
443- if (line > 0 && line <= blockCount ())
444- {
445- cursorUp ();
446- num = getLineNo ();
447- if (num > line)
448- {
449- do
450- {
451- cursorUp ();
452- num--;
453- }while (num > line);
454- }
455- else
456- {
457- while (num < line)
458- {
459- cursorDown ();
460- num++;
461- }
462- }
463- }
464- else
465- qDebug () << " Invalid line number passed" ;
466- }
467- else
468- qDebug () << " No blocks found" ;
469- }
470-
471- /* *
472- * @brief Gets the total line count
473- * @return Number of lines in the document
474- */
475- int QGCodeEditor::getLineCount ()
476- {
477- return blockCount () - 1 ;
478- }
479-
480- int space;
481- #if QT_VERSION > QT_VERSION_CHECK(5, 3, 2)
482- space = 3 + fontMetrics().horizontalAdvance(QLatin1Char(' 9' )) * digits;
483- #else
484- space = 3 + fontMetrics().width(QLatin1Char(' 9' )) * digits;
485- #endif
486-
487- return space;
488- }
489-
490357/* *
491358 * @brief Updates the line number area width
492359 * @param newBlockCount Number of blocks (unused, kept for signature compatibility)
0 commit comments