/******************************************************************* * Destructor *******************************************************************/ IArrestClientMgr :: ~IArrestClientMgr() { ISequence<IArrest *> tempList; IArrest * arrest; // if (dResultWrapper) // delete dResultWrapper; if (dResultListWrapper) { IVSequence<IArrest*>::Cursor cursor(*dResultListWrapper); forCursor( cursor ) tempList.addAsFirst( dResultListWrapper->elementAt( cursor ) ); dResultListWrapper->removeAll( ); ISequence<IArrest*>::Cursor tempCursor( tempList ); forCursor( cursor ) { arrest = tempList.elementAt ( tempCursor ); delete arrest; } tempList.removeAll( ); delete dResultListWrapper; } }
QString LiteEditorWidget::cursorToHtml(QTextCursor cursor) const { QTextDocument *tempDocument = new QTextDocument; QTextCursor tempCursor(tempDocument); tempCursor.insertFragment(cursor.selection()); // Apply the additional formats set by the syntax highlighter QTextBlock start = document()->findBlock(cursor.selectionStart()); QTextBlock end = document()->findBlock(cursor.selectionEnd()); end = end.next(); const int selectionStart = cursor.selectionStart(); const int endOfDocument = tempDocument->characterCount() - 1; for (QTextBlock current = start; current.isValid() && current != end; current = current.next()) { const QTextLayout *layout = current.layout(); foreach (const QTextLayout::FormatRange &range, layout->additionalFormats()) { const int start = current.position() + range.start - selectionStart; const int end = start + range.length; if (end <= 0 || start >= endOfDocument) continue; tempCursor.setPosition(qMax(start, 0)); tempCursor.setPosition(qMin(end, endOfDocument), QTextCursor::KeepAnchor); tempCursor.setCharFormat(range.format); } } // Reset the user states since they are not interesting for (QTextBlock block = tempDocument->begin(); block.isValid(); block = block.next()) block.setUserState(-1); // Make sure the text appears pre-formatted tempCursor.setPosition(0); tempCursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor); QTextBlockFormat blockFormat = tempCursor.blockFormat(); blockFormat.setNonBreakableLines(true); tempCursor.setBlockFormat(blockFormat); QString html = tempCursor.selection().toHtml();//("utf-8"); html.replace("\t","    "); delete tempDocument; return html; }