various cleanups

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2019-06-07 13:52:33 +00:00
parent ad9372dfc7
commit 39701195bb
16 changed files with 53 additions and 162 deletions

View file

@ -1,6 +1,8 @@
#!/usr/bin/python
import sys, os, re
import os, re
regex = re.compile('(#include [<|"](?:.*)[>|"])')
cppfiles = []
for root, dirs, files in os.walk(os.curdir):
@ -14,7 +16,7 @@ for cpp in cppfiles:
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

View file

@ -367,7 +367,6 @@ for cpp in cppfiles:
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:

View file

@ -1,6 +1,6 @@
#!/usr/bin/python
import sys, os, re
import os, re
# generated via find /usr/include/katie/ -name 'Q*' -printf ' "%f",\n' | sort -u
classlist = {

View file

@ -1,23 +1,23 @@
#!/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)

View file

@ -76,49 +76,6 @@ template <typename T> inline void qToUnaligned(const T src, uchar *dest)
* 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)
{
@ -158,56 +115,11 @@ template <> inline qint32 qFromLittleEndian<qint32>(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)
@ -251,7 +163,7 @@ template <> inline qint32 qFromBigEndian<qint32>(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.

View file

@ -464,11 +464,11 @@ QT_BEGIN_NAMESPACE
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.

View file

@ -997,8 +997,7 @@ public:
enum TextFormat {
PlainText,
RichText,
AutoText,
LogText
AutoText
};
enum AspectRatioMode {

View file

@ -2171,9 +2171,6 @@
\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.
*/
/*!

View file

@ -74,11 +74,7 @@ class QVector
typedef QVectorTypedData<T> Data;
union {
QVectorData *d;
#if defined(Q_CC_SUN) && (__SUNPRO_CC <= 0x550)
QVectorTypedData<T> *p;
#else
Data *p;
#endif
};
public:

View file

@ -250,7 +250,7 @@ void QDeclarativeTextEdit::setText(const QString &text)
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);
@ -264,17 +264,17 @@ void QDeclarativeTextEdit::setText(const QString &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().
@ -289,12 +289,12 @@ Column {
}
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>"
}
}
@ -302,19 +302,19 @@ Column {
\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);
@ -328,7 +328,7 @@ void QDeclarativeTextEdit::setTextFormat(TextFormat format)
updateSize();
}
d->format = format;
d->control->setAcceptRichText(d->format != PlainText);
d->control->setAcceptRichText(d->format != Qt::PlainText);
emit textFormatChanged(d->format);
}

View file

@ -54,7 +54,6 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextEdit : public QDeclarativeImplicitSizePa
Q_OBJECT
Q_ENUMS(VAlignment)
Q_ENUMS(HAlignment)
Q_ENUMS(TextFormat)
Q_ENUMS(WrapMode)
Q_ENUMS(SelectionMode)
@ -69,7 +68,7 @@ class Q_AUTOTEST_EXPORT QDeclarativeTextEdit : public QDeclarativeImplicitSizePa
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)
@ -102,12 +101,6 @@ public:
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,
@ -126,8 +119,8 @@ public:
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);
@ -224,7 +217,7 @@ Q_SIGNALS:
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();

View file

@ -61,10 +61,10 @@ class QDeclarativeTextEditPrivate : public QDeclarativeImplicitSizePaintedItemPr
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)
{
@ -87,29 +87,24 @@ public:
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;

View file

@ -728,7 +728,6 @@ void RichTextEditor::setDefaultFont(QFont font)
QString RichTextEditor::text(Qt::TextFormat format) const
{
switch (format) {
case Qt::LogText:
case Qt::PlainText:
return toPlainText();
case Qt::RichText:

View file

@ -424,7 +424,7 @@ QTextHtmlImporter::QTextHtmlImporter(QTextDocument *_doc, const QString &_html,
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);

View file

@ -298,9 +298,8 @@ protected:
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);

View file

@ -2384,7 +2384,7 @@ void QTextEdit::setText(const QString &text)
{
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