Merge branch 'master' of https://github.com/fluxer/kdelibs into devinfo

This commit is contained in:
Ivailo Monev 2021-08-07 18:11:58 +03:00
commit 7cb538b115
5 changed files with 13 additions and 61 deletions

View file

@ -250,7 +250,6 @@ endif()
#########################################################################
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
remove_definitions(-DQT3_SUPPORT_WARNINGS -DQT3_SUPPORT)
################# setup the include directories #################

View file

@ -20,7 +20,6 @@
#include "kmimemagicrule_p.h"
#include <QIODevice>
#include <kdebug.h>
#include <QByteArrayMatcher>
/*
* Historical note:
@ -55,50 +54,6 @@ static bool testMatches(QIODevice* device, qint64 deviceSize, QByteArray& availa
return false;
}
// Taken from QByteArray::indexOf, but that one uses strncmp so it stops on '\0',
// replaced with memcmp here...
static int indexOf(const QByteArray& that, const QByteArray &ba)
{
const int l = that.size();
const int ol = ba.size();
if (ol > l)
return -1;
if (ol == 0)
return 0;
if (ol == 1)
return that.indexOf(*ba.constData());
if (l > 500 && ol > 5)
return QByteArrayMatcher(ba).indexIn(that);
const char *needle = ba.data();
const char *haystack = that.data();
const char *end = that.data() + (l - ol);
const uint ol_minus_1 = ol - 1;
uint hashNeedle = 0, hashHaystack = 0;
int idx;
for (idx = 0; idx < ol; ++idx) {
hashNeedle = ((hashNeedle<<1) + needle[idx]);
hashHaystack = ((hashHaystack<<1) + haystack[idx]);
}
hashHaystack -= *(haystack + ol_minus_1);
while (haystack <= end) {
hashHaystack += *(haystack + ol_minus_1);
if (hashHaystack == hashNeedle && *needle == *haystack
&& memcmp(needle, haystack, ol) == 0)
return haystack - that.data();
if (ol_minus_1 < sizeof(uint) * 8 /*CHAR_BIT*/)
hashHaystack -= (*haystack) << ol_minus_1;
hashHaystack <<= 1;
++haystack;
}
return -1;
}
bool KMimeMagicRule::match(QIODevice* device, qint64 deviceSize, QByteArray& availableData) const
{
return testMatches(device, deviceSize, availableData, m_matches, m_mimetype);
@ -153,7 +108,7 @@ bool KMimeMagicMatch::match(QIODevice* device, qint64 deviceSize, QByteArray& av
bool found = false;
if (m_mask.isEmpty()) {
//kDebug() << "m_data=" << m_data;
found = ::indexOf(readData, m_data) != -1;
found = readData.indexOf(m_data) != -1;
//if (found)
// kDebug() << "Matched readData=" << readData << "with m_data=" << m_data << "so this is" << mimeType;
} else {

View file

@ -525,15 +525,16 @@ void KIconEffect::semiTransparent(QImage &img)
if(img.format() == QImage::Format_ARGB32_Premultiplied)
img = img.convertToFormat(QImage::Format_ARGB32);
int width = img.width();
int height = img.height();
int height = img.height();
if(painterSupportsAntialiasing()){
unsigned char *line;
for(y=0; y<height; ++y){
if(QSysInfo::ByteOrder == QSysInfo::BigEndian)
line = img.scanLine(y);
else
line = img.scanLine(y) + 3;
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
line = img.scanLine(y);
#else
line = img.scanLine(y) + 3;
#endif
for(x=0; x<width; ++x){
*line >>= 1;
line += 4;

View file

@ -967,13 +967,13 @@ KDbusImageStruct KStatusNotifierItemPrivate::imageToStruct(const QImage &image)
}
//swap to network byte order if we are little endian
if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
quint32 *uintBuf = (quint32 *) icon.data.data();
for (uint i = 0; i < icon.data.size()/sizeof(quint32); ++i) {
*uintBuf = htonl(*uintBuf);
++uintBuf;
}
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
quint32 *uintBuf = (quint32 *) icon.data.data();
for (uint i = 0; i < icon.data.size()/sizeof(quint32); ++i) {
*uintBuf = htonl(*uintBuf);
++uintBuf;
}
#endif
return icon;
}

View file

@ -1,6 +1,3 @@
#define QT3_SUPPORT
#define QT3_SUPPORT_WARNINGS
#include <QtGui/QWidget>
#include <QtGui/QMessageBox>
#include <QtGui/QTextEdit>