From 38f1d820b108185773eceaf04d9eebddccdb688e Mon Sep 17 00:00:00 2001 From: scorpio810 Date: Sun, 20 Apr 2014 18:53:10 +0000 Subject: [PATCH] Update richtexteditor git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3014 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- ico/32x32/simplifyrichtext.png | Bin 0 -> 1933 bytes qelectrotech.qrc | 1 + sources/richtext/richtexteditor.cpp | 189 +++++++++++++++++++--------- 3 files changed, 130 insertions(+), 60 deletions(-) create mode 100644 ico/32x32/simplifyrichtext.png diff --git a/ico/32x32/simplifyrichtext.png b/ico/32x32/simplifyrichtext.png new file mode 100644 index 0000000000000000000000000000000000000000..e251cf7b9c248861f128d3508e2c1793679d935f GIT binary patch literal 1933 zcmb7Fdr%X19*@FVq=opP4uz(!8xX1_*$sIv1k6(+hDV6PiGoYAkO;|!-GwChs=#o<%3b~|Jv^zsI!&Y;rpT*`qG7(;Htb1*<_Me{H{ zhMHW3m$6s|!)Lw4kU?eWRw72+%0;~xuG4C#*$hT(ywi>v^Dzp@!SXCN88~?UA_!Pa zGB91JgLHN!X0{}h5LjAClEGM#ZR8j6wmYwZKLqP8s-27oqpwYaR$Z zgHZW0@VQeNx)eZ(6Br=mLL4I`f&dZBg`)*xu{a9gLomdH_&k`;fyGEPAAum?#RJmT z2vaViS7~0@qE9l=Oi^}($8$IwTt_q)C-Qi(R4Vmq@cA4X!698X3UzX9Bzsyxg^@9Jqk_+2z< zaM>}Q9wYH0!bsO6mpx6UbN9!Fyg=F;B$=?#ML`QxxUtBJ*(j|_1{M`rOo&9F)=0%7 zp;#>tsx&aHkc$OswL&2g2q1x&FP#?nEs>VwnrNgt$``n zoSZ&o$C8ZjupMh&U-;1nrvBBPd#XFmEpnefFo5;6R`i~@N=3vh?wA}Rx#ZR1%~M-# z?AMsg(2<4hH*Q3pc(U&MB9>04gDSSVoHq+%e!TMZ(xpqsXZl4rL(f@Cfg2anRy6h& zW?u=@d7{4R>dJaGEVNB9|LqOxR=FZy_Y(KymGhY%0IOuhe5mkL)oc@ z1}XdgA+Wpb3$}et8--Z&A4?a@9S^@tI@kHZ)CM+CUVHj9FG3y5XQh8{*an~t-fJlcZX+}{bQX6)P6*G zimIz0HoM<#+M(W39(fsPRUcA3b)^iC&K`d>RxuRyX3MpP0q2GX{rxO5X>a7w!C9#n z!WpF(;rNX#+h1D)S=jZqm6rP(jmG%|4Sg%d{N%Pu0>;d2;f#7BTqtGVD>X$RLz&bTMmcmJQTzH|SB-lC`6+ z{ajo5OFN2A%GY|T$J+a{CQCTt$8OWugipe2JXr14BkSxV7G7GnGs3aNqODuu$)~{VCl}zGQ*yG zi#iXC$8DW+usmUfD+-=anjaA0kp&jw_M%IF+Sr|ywymMzm09&WJ?ico/22x22/applications-development-translation.png ico/48x48/view-pim-journal.png ico/24x16/nl.png + ico/32x32/simplifyrichtext.png diff --git a/sources/richtext/richtexteditor.cpp b/sources/richtext/richtexteditor.cpp index e7739265f..fa5e8eeaa 100644 --- a/sources/richtext/richtexteditor.cpp +++ b/sources/richtext/richtexteditor.cpp @@ -53,9 +53,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include @@ -78,10 +78,103 @@ QT_BEGIN_NAMESPACE -//static const char *RichTextDialogC = "RichTextDialog"; -//static const char *Geometry = "Geometry"; +static const char RichTextDialogGroupC[] = "RichTextDialog"; +static const char GeometryKeyC[] = "Geometry"; +static const char TabKeyC[] = "Tab"; + +const bool simplifyRichTextDefault = true; namespace qdesigner_internal { + // Richtext simplification filter helpers: Elements to be discarded + static inline bool filterElement(const QStringRef &name) + { + return name != QLatin1String("meta") && name != QLatin1String("style"); + } + + // Richtext simplification filter helpers: Filter attributes of elements + static inline void filterAttributes(const QStringRef &name, + QXmlStreamAttributes *atts, + bool *paragraphAlignmentFound) + { + typedef QXmlStreamAttributes::iterator AttributeIt; + + if (atts->isEmpty()) + return; + + // No style attributes for + if (name == QLatin1String("body")) { + atts->clear(); + return; + } + + // Clean out everything except 'align' for 'p' + if (name == QLatin1String("p")) { + for (AttributeIt it = atts->begin(); it != atts->end(); ) { + if (it->name() == QLatin1String("align")) { + ++it; + *paragraphAlignmentFound = true; + } else { + it = atts->erase(it); + } + } + return; + } + } + + // Richtext simplification filter helpers: Check for blank QStringRef. + static inline bool isWhiteSpace(const QStringRef &in) + { + const int count = in.size(); + for (int i = 0; i < count; i++) + if (!in.at(i).isSpace()) + return false; + return true; + } + + // Richtext simplification filter: Remove hard-coded font settings, + //