#!/usr/bin/python
-import sys, os, re
+import os, re
+
+regex = re.compile('(#include [<|"](?:.*)[>|"])')
cppfiles = []
for root, dirs, files in os.walk(os.curdir):
with open(cpp, 'r') as f:
cppcontent = f.read()
includes = []
- for match in re.findall('(#include [<|"](?:.*)[>|"])', cppcontent):
+ for match in regex.findall(cppcontent):
if match in includes:
print('multiple inclusions of: %s, in %s' % (match, cpp))
continue
inc1 = '%s/%s' % (key, key2)
inc2 = key2
replacement = '#include <%s/%s>' % (key, incmap[key][key2])
- # print(inc1, inc2, replacement)
for match in re.findall('(#include [<|"](?:%s|%s)[>|"])' % (inc1, inc2), cppcontent):
with open(cpp, 'w') as f:
if replacement in replaced:
#!/usr/bin/python
-import sys, os, re
+import os, re
# generated via find /usr/include/katie/ -name 'Q*' -printf ' "%f",\n' | sort -u
classlist = {
#!/usr/bin/python
-import sys, os, re
+import os, re
regex = re.compile('(#ifndef (?:.*)_H\n#define .*$)', re.MULTILINE)
-cppfiles = []
+hppfiles = []
for root, dirs, files in os.walk(os.curdir):
for f in files:
if f.endswith(('.hpp', '.h')):
- cppfiles.append('%s/%s' % (root, f))
+ hppfiles.append('%s/%s' % (root, f))
-for cpp in cppfiles:
- cpp = os.path.realpath(cpp)
- with open(cpp, 'r') as f:
+for hpp in hppfiles:
+ hpp = os.path.realpath(hpp)
+ with open(hpp, 'r') as f:
cppcontent = f.read()
if '#pragma once' in cppcontent:
continue
for match in regex.findall(cppcontent):
- with open(cpp, 'w') as f:
- print('adding pragma once to: %s' % cpp)
+ with open(hpp, 'w') as f:
+ print('adding pragma once to: %s' % hpp)
cppcontent = cppcontent.replace(match, '#pragma once\n\n%s' % match)
f.write(cppcontent)
* and return the value in host-endian encoding.
* There is no requirement that \a src must be aligned.
*/
-#if defined Q_CC_SUN
-inline quint64 qFromLittleEndian_helper(const uchar *src, quint64 *dest)
-{
- return 0
- | src[0]
- | src[1] * Q_UINT64_C(0x0000000000000100)
- | src[2] * Q_UINT64_C(0x0000000000010000)
- | src[3] * Q_UINT64_C(0x0000000001000000)
- | src[4] * Q_UINT64_C(0x0000000100000000)
- | src[5] * Q_UINT64_C(0x0000010000000000)
- | src[6] * Q_UINT64_C(0x0001000000000000)
- | src[7] * Q_UINT64_C(0x0100000000000000);
-}
-
-inline quint32 qFromLittleEndian_helper(const uchar *src, quint32 *dest)
-{
- return 0
- | src[0]
- | src[1] * quint32(0x00000100)
- | src[2] * quint32(0x00010000)
- | src[3] * quint32(0x01000000);
-}
-
-inline quint16 qFromLittleEndian_helper(const uchar *src, quint16 *dest)
-{
- return 0
- | src[0]
- | src[1] * 0x0100;
-}
-
-inline qint64 qFromLittleEndian_helper(const uchar *src, qint64 * dest)
-{ return static_cast<qint64>(qFromLittleEndian_helper(src, reinterpret_cast<quint64*>(0))); }
-inline qint32 qFromLittleEndian_helper(const uchar *src, qint32 * dest)
-{ return static_cast<qint32>(qFromLittleEndian_helper(src, reinterpret_cast<quint32*>(0))); }
-inline qint16 qFromLittleEndian_helper(const uchar *src, qint16 * dest)
-{ return static_cast<qint16>(qFromLittleEndian_helper(src, reinterpret_cast<quint16*>(0))); }
-
-template <class T> inline T qFromLittleEndian(const uchar *src)
-{
- return qFromLittleEndian_helper(src, reinterpret_cast<T*>(0));
-}
-
-#else
template <typename T> inline T qFromLittleEndian(const uchar *src);
template <> inline quint64 qFromLittleEndian<quint64>(const uchar *src)
{
template <> inline qint16 qFromLittleEndian<qint16>(const uchar *src)
{ return static_cast<qint16>(qFromLittleEndian<quint16>(src)); }
-#endif
/* This function will read a big-endian (also known as network order) encoded value from \a src
* and return the value in host-endian encoding.
* There is no requirement that \a src must be aligned.
*/
-#if defined Q_CC_SUN
-inline quint64 qFromBigEndian_helper(const uchar *src, quint64 *dest)
-{
- return 0
- | src[7]
- | src[6] * Q_UINT64_C(0x0000000000000100)
- | src[5] * Q_UINT64_C(0x0000000000010000)
- | src[4] * Q_UINT64_C(0x0000000001000000)
- | src[3] * Q_UINT64_C(0x0000000100000000)
- | src[2] * Q_UINT64_C(0x0000010000000000)
- | src[1] * Q_UINT64_C(0x0001000000000000)
- | src[0] * Q_UINT64_C(0x0100000000000000);
-}
-
-inline quint32 qFromBigEndian_helper(const uchar *src, quint32 * dest)
-{
- return 0
- | src[3]
- | src[2] * quint32(0x00000100)
- | src[1] * quint32(0x00010000)
- | src[0] * quint32(0x01000000);
-}
-
-inline quint16 qFromBigEndian_helper(const uchar *src, quint16 * des)
-{
- return 0
- | src[1]
- | src[0] * 0x0100;
-}
-
-
-inline qint64 qFromBigEndian_helper(const uchar *src, qint64 * dest)
-{ return static_cast<qint64>(qFromBigEndian_helper(src, reinterpret_cast<quint64*>(0))); }
-inline qint32 qFromBigEndian_helper(const uchar *src, qint32 * dest)
-{ return static_cast<qint32>(qFromBigEndian_helper(src, reinterpret_cast<quint32*>(0))); }
-inline qint16 qFromBigEndian_helper(const uchar *src, qint16 * dest)
-{ return static_cast<qint16>(qFromBigEndian_helper(src, reinterpret_cast<quint16*>(0))); }
-
-template <class T> inline T qFromBigEndian(const uchar *src)
-{
- return qFromBigEndian_helper(src, reinterpret_cast<T*>(0));
-}
-
-#else
template <class T> inline T qFromBigEndian(const uchar *src);
template<>
inline quint64 qFromBigEndian<quint64>(const uchar *src)
template <> inline qint16 qFromBigEndian<qint16>(const uchar *src)
{ return static_cast<qint16>(qFromBigEndian<quint16>(src)); }
-#endif
+
/*
* T qbswap(T source).
* Changes the byte order of a value from big endian to little endian or vice versa.
The <QtGlobal> header file provides a range of macros (Q_CC_*)
that are defined if the application is compiled using the
- specified platforms. For example, the Q_CC_SUN macro is defined if
- the application is compiled using Forte Developer, or Sun Studio
- C++. The header file also declares a range of macros (Q_OS_*)
- that are defined for the specified platforms. For example,
- Q_OS_WIN32 which is defined for Microsoft Windows.
+ specified platforms. For example, the Q_CC_GNU macro is defined
+ if the application is compiled using GNU Compiler Collection.
+ The header file also declares a range of macros (Q_OS_*) that
+ are defined for the specified platforms. For example, Q_OS_WIN32
+ which is defined for Microsoft Windows.
The purpose of these macros is to enable programmers to add
compiler or platform specific code to their application.
enum TextFormat {
PlainText,
RichText,
- AutoText,
- LogText
+ AutoText
};
enum AspectRatioMode {
\value AutoText The text string is interpreted as for
Qt::RichText if Qt::mightBeRichText() returns true, otherwise
as Qt::PlainText.
-
- \value LogText A special, limited text format which is only used
- by Q3TextEdit in an optimized mode.
*/
/*!
typedef QVectorTypedData<T> Data;
union {
QVectorData *d;
-#if defined(Q_CC_SUN) && (__SUNPRO_CC <= 0x550)
- QVectorTypedData<T> *p;
-#else
Data *p;
-#endif
};
public:
if (QDeclarativeTextEdit::text() == text)
return;
- d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(text));
+ d->richText = d->format == Qt::RichText || (d->format == Qt::AutoText && Qt::mightBeRichText(text));
if (d->richText) {
#ifndef QT_NO_TEXTHTMLPARSER
d->control->setHtml(text);
}
/*!
- \qmlproperty enumeration TextEdit::textFormat
+ \qmlproperty enumeration Qt::textFormat
The way the text property should be displayed.
\list
- \o TextEdit.AutoText
- \o TextEdit.PlainText
- \o TextEdit.RichText
+ \o Qt.AutoText
+ \o Qt.PlainText
+ \o Qt.RichText
\endlist
- The default is TextEdit.AutoText. If the text format is TextEdit.AutoText the text edit
+ The default is Qt.AutoText. If the text format is Qt.AutoText the text edit
will automatically determine whether the text should be treated as
rich text. This determination is made using Qt::mightBeRichText().
}
TextEdit {
font.pointSize: 24
- textFormat: TextEdit.RichText
+ textFormat: Qt.RichText
text: "<b>Hello</b> <i>World!</i>"
}
TextEdit {
font.pointSize: 24
- textFormat: TextEdit.PlainText
+ textFormat: Qt.PlainText
text: "<b>Hello</b> <i>World!</i>"
}
}
\o \image declarative-textformat.png
\endtable
*/
-QDeclarativeTextEdit::TextFormat QDeclarativeTextEdit::textFormat() const
+Qt::TextFormat QDeclarativeTextEdit::textFormat() const
{
Q_D(const QDeclarativeTextEdit);
return d->format;
}
-void QDeclarativeTextEdit::setTextFormat(TextFormat format)
+void QDeclarativeTextEdit::setTextFormat(Qt::TextFormat format)
{
Q_D(QDeclarativeTextEdit);
if (format == d->format)
return;
bool wasRich = d->richText;
- d->richText = format == RichText || (format == AutoText && Qt::mightBeRichText(d->text));
+ d->richText = format == Qt::RichText || (format == Qt::AutoText && Qt::mightBeRichText(d->text));
if (wasRich && !d->richText) {
d->control->setPlainText(d->text);
updateSize();
}
d->format = format;
- d->control->setAcceptRichText(d->format != PlainText);
+ d->control->setAcceptRichText(d->format != Qt::PlainText);
emit textFormatChanged(d->format);
}
Q_OBJECT
Q_ENUMS(VAlignment)
Q_ENUMS(HAlignment)
- Q_ENUMS(TextFormat)
Q_ENUMS(WrapMode)
Q_ENUMS(SelectionMode)
Q_PROPERTY(int lineCount READ lineCount NOTIFY lineCountChanged REVISION 1)
Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
- Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
+ Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
AlignVCenter = Qt::AlignVCenter
};
- enum TextFormat {
- PlainText = Qt::PlainText,
- RichText = Qt::RichText,
- AutoText = Qt::AutoText
- };
-
enum WrapMode { NoWrap = QTextOption::NoWrap,
WordWrap = QTextOption::WordWrap,
WrapAnywhere = QTextOption::WrapAnywhere,
QString text() const;
void setText(const QString &);
- TextFormat textFormat() const;
- void setTextFormat(TextFormat format);
+ Qt::TextFormat textFormat() const;
+ void setTextFormat(Qt::TextFormat format);
QFont font() const;
void setFont(const QFont &font);
void verticalAlignmentChanged(VAlignment alignment);
void wrapModeChanged();
void lineCountChanged();
- void textFormatChanged(TextFormat textFormat);
+ void textFormatChanged(Qt::TextFormat textFormat);
void readOnlyChanged(bool isReadOnly);
void cursorVisibleChanged(bool isCursorVisible);
void cursorDelegateChanged();
public:
QDeclarativeTextEditPrivate()
: color("black"), hAlign(QDeclarativeTextEdit::AlignLeft), vAlign(QDeclarativeTextEdit::AlignTop),
- imgDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true),
+ dirty(false), richText(false), cursorVisible(false), focusOnPress(true),
showInputPanelOnFocus(true), clickCausedFocus(false), persistentSelection(true), requireImplicitWidth(false),
hAlignImplicit(true), rightToLeftText(false), textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0),
- cursorComponent(0), cursor(0), format(QDeclarativeTextEdit::AutoText), document(0), wrapMode(QDeclarativeTextEdit::NoWrap),
+ cursorComponent(0), cursor(0), format(Qt::AutoText), document(0), wrapMode(QDeclarativeTextEdit::NoWrap),
mouseSelectionMode(QDeclarativeTextEdit::SelectCharacters), lineCount(0), selectByMouse(false), canPaste(false),
yoff(0)
{
QColor color;
QColor selectionColor;
QColor selectedTextColor;
- QString style;
- QColor styleColor;
- QPixmap imgCache;
- QPixmap imgStyleCache;
QDeclarativeTextEdit::HAlignment hAlign;
QDeclarativeTextEdit::VAlignment vAlign;
- bool imgDirty : 1;
- bool dirty : 1;
- bool richText : 1;
- bool cursorVisible : 1;
- bool focusOnPress : 1;
- bool showInputPanelOnFocus : 1;
- bool clickCausedFocus : 1;
- bool persistentSelection : 1;
- bool requireImplicitWidth:1;
- bool hAlignImplicit:1;
- bool rightToLeftText:1;
+ bool dirty;
+ bool richText;
+ bool cursorVisible;
+ bool focusOnPress;
+ bool showInputPanelOnFocus;
+ bool clickCausedFocus;
+ bool persistentSelection;
+ bool requireImplicitWidth;
+ bool hAlignImplicit;
+ bool rightToLeftText;
qreal textMargin;
int lastSelectionStart;
int lastSelectionEnd;
QDeclarativeComponent* cursorComponent;
QDeclarativeItem* cursor;
- QDeclarativeTextEdit::TextFormat format;
+ Qt::TextFormat format;
QTextDocument *document;
QTextControl *control;
QDeclarativeTextEdit::WrapMode wrapMode;
QString RichTextEditor::text(Qt::TextFormat format) const
{
switch (format) {
- case Qt::LogText:
case Qt::PlainText:
return toPlainText();
case Qt::RichText:
QString html = _html;
const int startFragmentPos = html.indexOf(QLatin1String("<!--StartFragment-->"));
if (startFragmentPos != -1) {
- QString qt3RichTextHeader(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));
+ QLatin1String qt3RichTextHeader("<meta name=\"qrichtext\" content=\"1\" />");
// Hack for Qt3
const bool hasQtRichtextMetaTag = html.contains(qt3RichTextHeader);
const QModelIndex &index) const {
if (isSeparator(index)) {
QRect rect = option.rect;
- if (const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const QStyleOptionViewItemV3*>(&option))
- if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(v3->widget))
- rect.setWidth(view->viewport()->width());
+ if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(option.widget))
+ rect.setWidth(view->viewport()->width());
QStyleOption opt;
opt.rect = rect;
mCombo->style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &opt, painter, mCombo);
{
Qt::TextFormat format = Qt::mightBeRichText(text) ? Qt::RichText : Qt::PlainText;
#ifndef QT_NO_TEXTHTMLPARSER
- if (format == Qt::RichText || format == Qt::LogText)
+ if (format == Qt::RichText)
setHtml(text);
else
#endif