src/ChildWidget.cpp
/**
   * Export symbols from table to text file. eType identify export format:
   * 1 - one symbol per line
   * 2 - one row per line
   * 3 - one paragraph per line
   * Returns false if export was not possible for some reason.
   *
   * Export will work only on one column text correctly.
   * Words are identified if space between boxes is bigger than 6.
   * Lines are identified if space between boxes is bigger than -6.
   * Paragraph is identified based on left indentation (15) of from last left
   * margin.
*/
Export symbols from table to text file. eType identify export format:
1 - one symbol per line
2 - one row per line
3 - one paragraph per line
Returns false if export was not possible for some reason.

Export will work only on one column text correctly.
Words are identified if space between boxes is bigger than 6.
Lines are identified if space between boxes is bigger than -6.
Paragraph is identified based on left indentation (15) of from last left
margin.
Export symbols from table to text file . eType identify export format : 1 - one symbol per line 2 - one row per line 3 - one paragraph per line Returns false if export was not possible for some reason . Export will work only on one column text correctly . Words are identified if space between boxes is bigger than 6 . Lines are identified if space between boxes is bigger than - 6 . Paragraph is identified based on left indentation ( 15 ) of from last left margin .
bool ChildWidget::exportTxt(const int& eType, const QString& fileName) {
  if (DMESS > 10) qDebug() << Q_FUNC_INFO;
  QFile file(fileName);
  if (!file.open(QFile::WriteOnly | QFile::Text)) {
    QMessageBox::warning(
      this,
      SETTING_APPLICATION,
      tr("Cannot write file %1:\n%2.").arg(boxFile).arg(file.errorString()));
    return false;
  }
  QTextStream out(&file);
  out.setCodec("UTF-8");
  QApplication::setOverrideCursor(Qt::WaitCursor);
  QSettings settings(QSettings::IniFormat, QSettings::UserScope,
                     SETTING_ORGANIZATION, SETTING_APPLICATION);
  int line_start_prev = 0;
  int line_end_prev = 0;
  int right_prev = -1;
  int last_bottom = -1;
  int wordSpace = settings.value("Text/WordSpace").toInt();
  int paraIndent = settings.value("Text/ParagraphIndent").toInt();
  for (int row = 0; row < model->rowCount(); ++row) {
    QString letter = model->index(row, 0).data().toString();
    int left = model->index(row, 1).data().toInt();
    int bottom = model->index(row, 2).data().toInt();
    int right = model->index(row, 3).data().toInt();
    int top = model->index(row, 4).data().toInt();
    if (last_bottom == -1)
      last_bottom = top;
    if (eType == 1 && (right_prev != -1)) {
      out << "\n";
    }
    if (eType == 2) {
      if (((left - right_prev) >= wordSpace) && (right_prev != -1)) {
        out << " ";
      } else if (((left - right_prev) <= (2 * (left - right))) &&
                 (right_prev != -1)) {
        out << "\n";
      }
    }
    if (eType == 3) {
      if (((left - right_prev) >= wordSpace) && (right_prev != -1))
        out << " ";
      if (((left - right_prev) <= (2 * (left - right))) && (right_prev != -1)) {
        if (line_end_prev == 0)  
          line_end_prev = right;
        if ((left - line_start_prev >= paraIndent) ||  
            (top - last_bottom >= paraIndent) ||   
            (abs(right - line_end_prev) >= (paraIndent / 2)))
          out << "\n";
        else
          out << " ";
        line_start_prev = left;
        line_end_prev = right_prev;
      }
    }
    out << letter;
    right_prev = right;
    last_bottom = bottom;
  }
  out << "\n";
  QApplication::restoreOverrideCursor();
  return true;
}
bool ChildWidget :: exportTxt ( const int & eType , const QString & fileName ) { if ( DMESS > 10 ) qDebug ( ) << Q_FUNC_INFO ; QFile file ( fileName ) ; if ( ! file . open ( QFile :: WriteOnly | QFile :: Text ) ) { QMessageBox :: warning ( this , SETTING_APPLICATION , tr ( " \n " ) . arg ( boxFile ) . arg ( file . errorString ( ) ) ) ; return false ; } QTextStream out ( & file ) ; out . setCodec ( " " ) ; QApplication :: setOverrideCursor ( Qt :: WaitCursor ) ; QSettings settings ( QSettings :: IniFormat , QSettings :: UserScope , SETTING_ORGANIZATION , SETTING_APPLICATION ) ; int line_start_prev = 0 ; int line_end_prev = 0 ; int right_prev = -1 ; int last_bottom = -1 ; int wordSpace = settings . value ( " " ) . toInt ( ) ; int paraIndent = settings . value ( " " ) . toInt ( ) ; for ( int row = 0 ; row < model -> rowCount ( ) ; ++ row ) { QString letter = model -> index ( row , 0 ) . data ( ) . toString ( ) ; int left = model -> index ( row , 1 ) . data ( ) . toInt ( ) ; int bottom = model -> index ( row , 2 ) . data ( ) . toInt ( ) ; int right = model -> index ( row , 3 ) . data ( ) . toInt ( ) ; int top = model -> index ( row , 4 ) . data ( ) . toInt ( ) ; if ( last_bottom == -1 ) last_bottom = top ; if ( eType == 1 && ( right_prev != -1 ) ) { out << " \n " ; } if ( eType == 2 ) { if ( ( ( left - right_prev ) >= wordSpace ) && ( right_prev != -1 ) ) { out << " " ; } else if ( ( ( left - right_prev ) <= ( 2 * ( left - right ) ) ) && ( right_prev != -1 ) ) { out << " \n " ; } } if ( eType == 3 ) { if ( ( ( left - right_prev ) >= wordSpace ) && ( right_prev != -1 ) ) out << " " ; if ( ( ( left - right_prev ) <= ( 2 * ( left - right ) ) ) && ( right_prev != -1 ) ) { if ( line_end_prev == 0 ) line_end_prev = right ; if ( ( left - line_start_prev >= paraIndent ) || ( top - last_bottom >= paraIndent ) || ( abs ( right - line_end_prev ) >= ( paraIndent / 2 ) ) ) out << " \n " ; else out << " " ; line_start_prev = left ; line_end_prev = right_prev ; } } out << letter ; right_prev = right ; last_bottom = bottom ; } out << " \n " ; QApplication :: restoreOverrideCursor ( ) ; return true ; }
Export symbols from table to text file.
Export symbols from table to text file .
// line by line // new word // new line -> if negative difference is bigger than double of letter // width // new word // new line -> if negative difference is bigger than double of letter // width // first line // distance from left // distance between lines // distance from right