Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.1:Test
kdepim4
r889488.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File r889488.diff of Package kdepim4
Subject: kjots: fix paste of richtext and tabs becoming spaces bugs From: wstephenson@suse.de Bug: kde#160600,kde#175100 Patch-upstream: 889488 --- kjots/kjotsedit.cpp (revision 889487) +++ kjots/kjotsedit.cpp (revision 889488) @@ -39,6 +39,8 @@ #include "kjotslinkdialog.h" #include "bookshelf.h" +#include <kdebug.h> + KJotsEdit::KJotsEdit ( QWidget *parent ) : KRichTextWidget(parent) { setAcceptRichText(true); @@ -207,6 +209,37 @@ void KJotsEdit::insertFromMimeData ( con insertHtml(html); } } + } else if( source->hasHtml() ) { + // Don't have an action to set top and bottom margins on paragraphs yet. + // Remove the margins for all inserted html. +// kDebug() << source->html(); + QString str = source->html(); + int styleBegin = 0; + while ((styleBegin = str.indexOf("style=\"", styleBegin, Qt::CaseInsensitive) + 7) != (-1 + 7)) { + int styleEnd = str.indexOf('"', styleBegin); + int styleFragmentStart = styleBegin; + int styleFragmentEnd = styleBegin; + while ((styleFragmentEnd = str.indexOf(";", styleFragmentEnd) + 1) != (-1 + 1)) { + if (styleFragmentEnd > styleEnd) break; + int fragmentLength = styleFragmentEnd-styleFragmentStart; + if (str.mid(styleFragmentStart, fragmentLength).contains("margin", Qt::CaseInsensitive)) + { + str.remove(styleFragmentStart, fragmentLength); + styleEnd -= fragmentLength; + styleFragmentEnd = styleFragmentStart; + + if (styleBegin == styleEnd) + { + str.remove(styleBegin-7, 7+1); // remove the now empty style attribute. + } + } else { + styleFragmentStart = styleFragmentEnd; + } + } + styleBegin = styleEnd; + } +// kDebug() << str; + insertHtml(str); } else { KTextEdit::insertFromMimeData(source); } --- kjots/kjotsentry.cpp (revision 889487) +++ kjots/kjotsentry.cpp (revision 889488) @@ -190,7 +190,7 @@ void KJotsEntry::parseXml( QDomElement & bool KJotsEntry::isKJotsLink(const QString &link) { - return link.startsWith(kjotsLinkStringPrefix()); + return link.startsWith(kjotsLinkStringPrefix()); } QString KJotsEntry::kjotsLinkUrl() @@ -653,6 +653,11 @@ KJotsPage::KJotsPage() setIcon(0, KIconLoader::global()->loadIcon(QString("text-x-generic"), KIconLoader::Small)); setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled); + // Don't have an action to set top and bottom margins on paragraphs. + // Set the margins to 0 for all inserted html. Lists get some padding top and bottom. + // See http://bugs.kde.org/show_bug.cgi?id=160600. + document.setDefaultStyleSheet( "p,h1,h2,h3,h4,h5,h6,pre,br{margin-top:0px;margin-bottom:0px;}ul{margin-top:12px;margin-bottom:12px;}" ); + connect(&document, SIGNAL(modificationChanged(bool)), SLOT(documentModified(bool))); } @@ -750,10 +755,12 @@ void KJotsPage::parseXml( QDomElement &m } if ( oldBook ) { - bodyText = Qt::convertFromPlainText(bodyText, Qt::WhiteSpaceNormal); + // Ensure that whitespace is reproduced as in kjots of kde3.5. + // https://bugs.kde.org/show_bug.cgi?id=175100 + document.setPlainText(bodyText); + } else { + document.setHtml(bodyText); } - - document.setHtml(bodyText); } else { @@ -792,13 +799,13 @@ void KJotsPage::generateHtml( KJotsEntry } } else { //We need to fake QUrl in to thinking this is a real URL - + html = "<table><tr><td>"; html += QString("<h3><a name=\"%1\"> </a><a href=\"%2\" >%3</a></h3>").arg(id()).arg(kjotsLinkUrl()).arg(htmlSubject); html += "</td></tr></table>"; } html += "<br>"; - + cursorOut->insertFragment(QTextDocumentFragment::fromHtml(html)); cursorOut->insertBlock(defaultBlockFormat, defaultCharFormat); html.clear(); //stop myself from making the same mistake over and over again. Index: kjots/kjotsedit.cpp =================================================================== Index: kjots/kjotsentry.cpp ===================================================================
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor