diff options
Diffstat (limited to 'src')
26 files changed, 363 insertions, 243 deletions
diff --git a/src/kvilib/CMakeLists.txt b/src/kvilib/CMakeLists.txt index d13326c09..8d4b42e4f 100644 --- a/src/kvilib/CMakeLists.txt +++ b/src/kvilib/CMakeLists.txt @@ -67,11 +67,12 @@ SET(kvilib_SRCS ext/KviDataBuffer.cpp ext/KviDbusAdaptor.cpp ext/KviDebugContext.cpp - ext/KviMediaType.cpp + ext/KviMediaManager.cpp ext/KviMiscUtils.cpp ext/KviMessageTypeSettings.cpp ext/KviOsInfo.cpp ext/KviPixmap.cpp + ext/KviPixmapUtils.cpp ext/KviAnimatedPixmap.cpp ext/KviAnimatedPixmapCache.cpp ext/KviNickColors.cpp diff --git a/src/kvilib/ext/KviCommandFormatter.cpp b/src/kvilib/ext/KviCommandFormatter.cpp index f474053fc..8edd4284e 100644 --- a/src/kvilib/ext/KviCommandFormatter.cpp +++ b/src/kvilib/ext/KviCommandFormatter.cpp @@ -24,196 +24,202 @@ #include "KviCommandFormatter.h" +#include "KviQString.h" namespace KviCommandFormatter { - bool hasLeadingChars(KviCString ** array,char c) + bool hasLeadingChars(KviCString ** pszArray, char c) { - if(!(*array))return false; // can't have more leading chars + if(!(*pszArray)) + return false; // can't have more leading chars + bool bGotIt = false; - while(*array) + while(*pszArray) { - if(*((*array)->ptr()) == c) + if(*((*pszArray)->ptr()) == c) { // found at least one such leading char bGotIt = true; } else { // we pretend this line to be empty - KviCString tmp = *(*array); - tmp.trimmed(); - if(tmp.hasData())return false; - *(*array) = ""; // set it to empty also in the main buffer + KviCString szTmp = *(*pszArray); + szTmp.trimmed(); + if(szTmp.hasData()) + return false; + *(*pszArray) = ""; // set it to empty also in the main buffer } - array++; + pszArray++; } return bGotIt; } - bool hasLeadingChars(QStringList &list,const QChar &c) + bool hasLeadingChars(QStringList & list, const QChar & c) { bool bGotIt = false; - for(QStringList::Iterator it = list.begin();it != list.end();++it) + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { - if((*it).length() < 1)continue; + if((*it).length() < 1) + continue; if((*it).at(0) == c) { // found at least one such leading char bGotIt = true; } else { // we pretend this line to be empty - QString tmp = *it; - tmp = tmp.trimmed(); + QString szTmp = *it; + szTmp = szTmp.trimmed(); - if(!tmp.isEmpty())return false; + if(!szTmp.isEmpty()) + return false; *it = ""; // set it to empty also in the main buffer } } return bGotIt; } - void trimLeading(KviCString ** array) + void trimLeading(KviCString ** pszArray) { - while(*array) + while(*pszArray) { - if((*array)->hasData())(*array)->cutLeft(1); - array++; + if((*pszArray)->hasData()) + (*pszArray)->cutLeft(1); + pszArray++; } } - void trimLeading(QStringList &list) + void trimLeading(QStringList & list) { - for(QStringList::Iterator it = list.begin();it != list.end();++it) + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { (*it).remove(0,1); } } - - void addLeading(KviCString ** array,char c) + void addLeading(KviCString ** pszArray, char c) { - while(*array) + while(*pszArray) { - if((*array)->hasData())(*array)->prepend(c); - array++; + if((*pszArray)->hasData()) + (*pszArray)->prepend(c); + pszArray++; } } - void addLeading(QStringList &list,const QChar & c) + void addLeading(QStringList & list, const QChar & c) { - for(QStringList::Iterator it = list.begin();it != list.end();++it) + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { (*it).prepend(c); } } - - void unindent(KviCString &buffer) + void unindent(KviCString & szBuffer) { // we can format correctly up to 65536 lines (that's really enough) - int realLen; - KviCString ** array = buffer.splitToArray('\n',65536,&realLen); - if(array) + int iRealLen; + KviCString ** pszArray = szBuffer.splitToArray('\n',65536,&iRealLen); + if(pszArray) { - while(hasLeadingChars(array,'\t') || hasLeadingChars(array,' '))trimLeading(array); - buffer.joinFromArray(array,"\n",true); - KviCString::freeArray(array); + while(hasLeadingChars(pszArray,'\t') || hasLeadingChars(pszArray,' '))trimLeading(pszArray); + szBuffer.joinFromArray(pszArray,"\n",true); + KviCString::freeArray(pszArray); } } - - void unindent(QString &buffer) + void unindent(QString & szBuffer) { - QStringList list = buffer.split("\n",QString::KeepEmptyParts); + QStringList list = szBuffer.split("\n",QString::KeepEmptyParts); while(hasLeadingChars(list,QChar('\t')) || hasLeadingChars(list,QChar(' ')))trimLeading(list); - //buffer = list.join("\n"); join implementation sux :D + //szBuffer = list.join("\n"); join implementation sux :D // we WANT the last newline - buffer = ""; + szBuffer = ""; for(QStringList::Iterator it = list.begin();it != list.end();++it) { - buffer.append(*it); - buffer.append(QChar('\n')); + szBuffer.append(*it); + szBuffer.append(QChar('\n')); } } - void bufferFromBlock(KviCString &buffer) + void bufferFromBlock(KviCString & szBuffer) { - buffer.trimmed(); + szBuffer.trimmed(); - if((*(buffer.ptr()) == '{') && buffer.lastCharIs('}')) + if((*(szBuffer.ptr()) == '{') && szBuffer.lastCharIs('}')) { // leading and trailing { must be stripped - buffer.cutLeft(1); - buffer.cutRight(1); + szBuffer.cutLeft(1); + szBuffer.cutRight(1); } - unindent(buffer); + unindent(szBuffer); - buffer.trimmed(); + szBuffer.trimmed(); } - void bufferFromBlock(QString &buffer) + void bufferFromBlock(QString & szBuffer) { - buffer = buffer.trimmed(); + szBuffer = szBuffer.trimmed(); - if(buffer.isEmpty())return; + if(szBuffer.isEmpty()) + return; - if((buffer.at(0) == QChar('{')) && buffer.endsWith(QChar('}'))) + if((szBuffer.at(0) == QChar('{')) && szBuffer.endsWith(QChar('}'))) { - buffer.remove(0,1); - buffer.remove(buffer.length() - 1,1); - while((buffer.length() > 0) && ((buffer.at(0) == QChar('\n')) || (buffer.at(0) == QChar('\r')))) - buffer.remove(0,1); + szBuffer.remove(0,1); + szBuffer.remove(szBuffer.length() - 1,1); + while((szBuffer.length() > 0) && ((szBuffer.at(0) == QChar('\n')) || (szBuffer.at(0) == QChar('\r')))) + szBuffer.remove(0,1); } - unindent(buffer); - buffer = buffer.trimmed(); + unindent(szBuffer); + szBuffer = szBuffer.trimmed(); } - void indent(KviCString &buffer) + void indent(KviCString & szBuffer) { // we can format correctly up to 65536 lines (that's really enough) - int realLen; - KviCString ** array = buffer.splitToArray('\n',65536,&realLen); - if(array) + int iRealLen; + KviCString ** pszArray = szBuffer.splitToArray('\n',65536,&iRealLen); + if(pszArray) { - addLeading(array,'\t'); - buffer.joinFromArray(array,"\n",true); - KviCString::freeArray(array); + addLeading(pszArray,'\t'); + szBuffer.joinFromArray(pszArray,"\n",true); + KviCString::freeArray(pszArray); } } - void indent(QString &buffer) + void indent(QString & szBuffer) { - QStringList list = buffer.split("\n",QString::KeepEmptyParts); + QStringList list = szBuffer.split("\n",QString::KeepEmptyParts); addLeading(list,QChar('\t')); - //buffer = list.join("\n"); join implementation sux :D + //szBuffer = list.join("\n"); join implementation sux :D // we WANT the last newline - buffer = ""; - for(QStringList::Iterator it = list.begin();it != list.end();++it) + szBuffer = ""; + for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) { - buffer.append(*it); - buffer.append(QChar('\n')); + szBuffer.append(*it); + szBuffer.append(QChar('\n')); } } - void blockFromBuffer(KviCString &buffer) + void blockFromBuffer(KviCString & szBuffer) { - indent(buffer); - buffer.prepend("{\n"); - buffer.stripRightWhiteSpace(); - buffer.ensureLastCharIs('\n'); - buffer.append("}\n"); + indent(szBuffer); + szBuffer.prepend("{\n"); + szBuffer.stripRightWhiteSpace(); + szBuffer.ensureLastCharIs('\n'); + szBuffer.append("}\n"); } - void blockFromBuffer(QString &buffer) + void blockFromBuffer(QString & szBuffer) { - indent(buffer); - buffer.prepend("{\n"); - KviQString::stripRightWhiteSpace(buffer); - KviQString::ensureLastCharIs(buffer,'\n'); - buffer.append("}\n"); + indent(szBuffer); + szBuffer.prepend("{\n"); + KviQString::stripRightWhiteSpace(szBuffer); + KviQString::ensureLastCharIs(szBuffer,'\n'); + szBuffer.append("}\n"); } } diff --git a/src/kvilib/ext/KviCommandFormatter.h b/src/kvilib/ext/KviCommandFormatter.h index edc3e20e5..bdea17b54 100644 --- a/src/kvilib/ext/KviCommandFormatter.h +++ b/src/kvilib/ext/KviCommandFormatter.h @@ -28,37 +28,36 @@ #include "KviCString.h" #include "kvi_settings.h" -#include "KviQString.h" #include <QStringList> namespace KviCommandFormatter { - extern KVILIB_API bool hasLeadingChars(KviCString * array,char c); - extern KVILIB_API bool hasLeadingChars(QStringList &list,const QChar &c); + extern KVILIB_API bool hasLeadingChars(KviCString * pszArray, char c); + extern KVILIB_API bool hasLeadingChars(QStringList & list, const QChar & c); - extern KVILIB_API void trimLeading(KviCString ** array); + extern KVILIB_API void trimLeading(KviCString ** pszArray); extern KVILIB_API void trimLeading(QStringList &list); - extern KVILIB_API void addLeading(KviCString ** array,char c); - extern KVILIB_API void addLeading(QStringList &list,const QChar &c); + extern KVILIB_API void addLeading(KviCString ** pszArray, char c); + extern KVILIB_API void addLeading(QStringList & list, const QChar & c); - extern KVILIB_API void trimBlockBraces(KviCString &buffer); - extern KVILIB_API void trimBlockBraces(QString &buffer); + extern KVILIB_API void trimBlockBraces(KviCString & szBuffer); + extern KVILIB_API void trimBlockBraces(QString & szBuffer); - extern KVILIB_API void unindent(KviCString &buffer); - extern KVILIB_API void unindent(QString &buffer); + extern KVILIB_API void unindent(KviCString & szBuffer); + extern KVILIB_API void unindent(QString & szBuffer); - extern KVILIB_API void bufferFromBlock(KviCString &buffer); - extern KVILIB_API void bufferFromBlock(QString &buffer); + extern KVILIB_API void bufferFromBlock(KviCString & szBuffer); + extern KVILIB_API void bufferFromBlock(QString & szBuffer); - extern KVILIB_API void addBlockBraces(KviCString &buffer); - extern KVILIB_API void addBlockBraces(QString &buffer); + extern KVILIB_API void addBlockBraces(KviCString & szBuffer); + extern KVILIB_API void addBlockBraces(QString & szBuffer); - extern KVILIB_API void indent(KviCString &buffer); - extern KVILIB_API void indent(QString &buffer); + extern KVILIB_API void indent(KviCString & szBuffer); + extern KVILIB_API void indent(QString & szBuffer); - extern KVILIB_API void blockFromBuffer(KviCString &buffer); - extern KVILIB_API void blockFromBuffer(QString &buffer); + extern KVILIB_API void blockFromBuffer(KviCString & szBuffer); + extern KVILIB_API void blockFromBuffer(QString & szBuffer); } #endif //_KVI_CMDFORMATTER_H_ diff --git a/src/kvilib/ext/KviDbusAdaptor.cpp b/src/kvilib/ext/KviDbusAdaptor.cpp index 6a99d64df..453043350 100644 --- a/src/kvilib/ext/KviDbusAdaptor.cpp +++ b/src/kvilib/ext/KviDbusAdaptor.cpp @@ -26,7 +26,8 @@ #ifdef COMPILE_DBUS_SUPPORT -KviDbusAdaptor::KviDbusAdaptor(QObject * obj) : QDBusAbstractAdaptor(obj) +KviDbusAdaptor::KviDbusAdaptor(QObject * pObj) +: QDBusAbstractAdaptor(pObj) { } diff --git a/src/kvilib/ext/KviDbusAdaptor.h b/src/kvilib/ext/KviDbusAdaptor.h index 6abf4c664..1d23c1013 100644 --- a/src/kvilib/ext/KviDbusAdaptor.h +++ b/src/kvilib/ext/KviDbusAdaptor.h @@ -37,8 +37,8 @@ Q_CLASSINFO("KVIrc D-Bus Interface", "org.kvirc.KVIrc") public: - KviDbusAdaptor(QObject * obj); + KviDbusAdaptor(QObject * pObj); }; #endif // COMPILE_DBUS_SUPPORT -#endif //!_KVI_DBUSADAPTOR_H_ +#endif // _KVI_DBUSADAPTOR_H_ diff --git a/src/kvilib/ext/KviDebugContext.cpp b/src/kvilib/ext/KviDebugContext.cpp index bdc0f934a..00a8be75e 100644 --- a/src/kvilib/ext/KviDebugContext.cpp +++ b/src/kvilib/ext/KviDebugContext.cpp @@ -8,20 +8,18 @@ //============================================================================= #include "KviDebugContext.h" - #include "kvi_stdarg.h" -#include "KviCString.h" #include "kvi_debug.h" static KviCString g_szIndentPrefix; -KviDebugContext::KviDebugContext(const char * szContext,...) +KviDebugContext::KviDebugContext(const char * pcContext, ...) { kvi_va_list list; - kvi_va_start(list,szContext); + kvi_va_start(list,pcContext); - m_szContext.vsprintf(szContext,list); + m_szContext.vsprintf(pcContext,list); kvi_va_end(list); @@ -35,7 +33,6 @@ KviDebugContext::KviDebugContext(const char * szContext,...) g_szIndentPrefix.append(" "); } - KviDebugContext::~KviDebugContext() { KVI_ASSERT(g_szIndentPrefix.len() >= 2); @@ -50,13 +47,13 @@ KviDebugContext::~KviDebugContext() qDebug(szPrefix.ptr(),m_szContext.ptr()); } -void KviDebugContext::trace(const char * szFmt,...) +void KviDebugContext::trace(const char * pcFmt, ...) { kvi_va_list list; - kvi_va_start(list,szFmt); + kvi_va_start(list,pcFmt); KviCString szOut; - szOut.vsprintf(szFmt,list); + szOut.vsprintf(pcFmt,list); kvi_va_end(list); @@ -67,4 +64,3 @@ void KviDebugContext::trace(const char * szFmt,...) qDebug(szPrefix.ptr(),szOut.ptr()); } - diff --git a/src/kvilib/ext/KviDebugContext.h b/src/kvilib/ext/KviDebugContext.h index c0877344b..83046ba10 100644 --- a/src/kvilib/ext/KviDebugContext.h +++ b/src/kvilib/ext/KviDebugContext.h @@ -1,49 +1,72 @@ -#ifndef _KviDebugContext_h_ -#define _KviDebugContext_h_ +#ifndef _KVIDEBUGCONTEXT_H_ +#define _KVIDEBUGCONTEXT_H_ + //============================================================================= // -// File : KviDebugContext.h -// Creation date : Tue 13 Jul 2010 23:27:23 -// Project : KVIrc Irc client -// Author : Szymon Stefanek <pragma at kvirc dot net> +// File : KviDebugContext.h +// Creation date : Tue Jul 13 2010 23:27:23 CEST by Szymon Stefanek +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2010 Szymon Stefanek (pragma at kvirc dot net) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // //============================================================================= +/** +* \file KviDebugContext.h +* \author Szymon Stefanek +* \brief Debug context +*/ + #include "kvi_settings.h" #include "KviCString.h" -/// -/// \class KviDebugContext -/// \brief The KviDebugContext class -/// -/// This class... -/// +/** +* \class KviDebugContext +* \brief The KviDebugContext class +* +* This class... +*/ class KVILIB_API KviDebugContext { public: + /** + * \brief Creates an instance of KviDebugContext + * \param pcContext The format list argument + * \param ... The succeding arguments + * \return KviDebugContext + */ + KviDebugContext(const char * pcContext, ...); - /// - /// Creates an instance of KviDebugContext - /// - KviDebugContext(const char * szContext,...); - - /// - /// Destroys the instance of KviDebugContext - /// and frees all the relevant resources - /// + /** + * \brief Destroys the instance of KviDebugContext and frees all the relevant resources + */ ~KviDebugContext(); - -public: - static void trace(const char * szFmt,...); - private: KviCString m_szContext; - +public: + /** + * \brief + * \param szFmt The format list argument + * \param ... The succeding arguments + * \return void + */ + static void trace(const char * pcFmt, ...); private: - KviDebugContext(const KviDebugContext &){}; const KviDebugContext & operator = (const KviDebugContext &){ return *this; }; +}; -}; // class KviDebugContext - - -#endif //!_KviDebugContext_h_ +#endif // _KVIDEBUGCONTEXT_H_ diff --git a/src/kvilib/ext/KviMediaType.cpp b/src/kvilib/ext/KviMediaManager.cpp index 7455dd140..bac3b5816 100644 --- a/src/kvilib/ext/KviMediaType.cpp +++ b/src/kvilib/ext/KviMediaManager.cpp @@ -1,10 +1,10 @@ //============================================================================= // -// File : KviMediaType.cpp -// Creation date : Mon Aug 21 2000 17:51:56 CEST by Szymon Stefanek +// File : KviMediaManager.cpp +// Creation date : Wed Dec 29 2010 00:37:56 CEST by Elvio basello // // This file is part of the KVirc irc client distribution -// Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net) +// Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com) // // This program is FREE software. You can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -26,9 +26,8 @@ //#define _KVI_DEBUG_CHECK_RANGE_ - +#include "KviMediaManager.h" #include "kvi_debug.h" -#include "KviMediaType.h" #include "KviConfigurationFile.h" #include "KviFileUtils.h" #include "KviLocale.h" @@ -424,15 +423,6 @@ KviMediaType * KviMediaManager::findMediaTypeForRegularFile(const char * szFullP return mtd; } -typedef struct _KviDefaultMediaType -{ - const char * filemask; - const char * magicbytes; - const char * ianatype; - const char * description; - const char * commandline; -} KviDefaultMediaType; - // FIXME : default handlers for windows ? diff --git a/src/kvilib/ext/KviMediaManager.h b/src/kvilib/ext/KviMediaManager.h new file mode 100644 index 000000000..321fc3bee --- /dev/null +++ b/src/kvilib/ext/KviMediaManager.h @@ -0,0 +1,58 @@ +#ifndef _KVI_MEDIAMANAGER_H_ +#define _KVI_MEDIAMANAGER_H_ + +//============================================================================= +// +// File : KviMediaManager.h +// Creation date : Wed Dec 29 2010 00:37:56 CEST by Elvio basello +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +// This file was originally part of KviMediaType.h + +#include "KviMediaType.h" +#include "kvi_settings.h" +#include "KviThread.h" +#include "KviPointerList.h" + +class KVILIB_API KviMediaManager : public KviMutex +{ +public: + KviMediaManager(); + ~KviMediaManager(); +protected: + KviPointerList<KviMediaType> * m_pMediaTypeList; +private: + KviMediaType * findMediaTypeForRegularFile(const char * pcFullPath, const char * pcFileName, bool bCheckMagic); +public: + KviPointerList<KviMediaType> * mediaTypeList(){ return m_pMediaTypeList; }; + KviMediaType * findMediaTypeByFileMask(const char * pcFilemask); + KviMediaType * findMediaTypeByIanaType(const char * pcIanaType); + bool removeMediaType(KviMediaType * pType){ return m_pMediaTypeList->removeRef(pType); }; + void clear(){ m_pMediaTypeList->clear(); }; + void insertMediaType(KviMediaType * pType); + KviMediaType * findMediaType(const char * pcFilename, bool bCheckMagic = true); + static void copyMediaType(KviMediaType * pDst, KviMediaType * pSrc); + + void load(const QString & szFilename); + void save(const QString & szFilename); +}; + +#endif // _KVI_MEDIAMANAGER_H_ diff --git a/src/kvilib/ext/KviMediaType.h b/src/kvilib/ext/KviMediaType.h index 3141784f1..f2836fb82 100644 --- a/src/kvilib/ext/KviMediaType.h +++ b/src/kvilib/ext/KviMediaType.h @@ -1,5 +1,6 @@ #ifndef _KVI_MEDIATYPE_H_ #define _KVI_MEDIATYPE_H_ + //============================================================================= // // File : KviMediaType.h @@ -27,9 +28,6 @@ #include "kvi_settings.h" #include "KviHeapObject.h" #include "KviCString.h" -#include "KviThread.h" - -#include "KviPointerList.h" // @@ -41,6 +39,14 @@ // to KviMediaManager::lock() and KviMediaManager::unlock() // +typedef struct _KviDefaultMediaType +{ + const char * filemask; + const char * magicbytes; + const char * ianatype; + const char * description; + const char * commandline; +} KviDefaultMediaType; class KVILIB_API KviMediaType : public KviHeapObject { @@ -58,28 +64,4 @@ public: KviCString szIcon; }; -class KVILIB_API KviMediaManager : public KviMutex -{ -public: - KviMediaManager(); - ~KviMediaManager(); -protected: - KviPointerList<KviMediaType> * m_pMediaTypeList; -private: - KviMediaType * findMediaTypeForRegularFile(const char * szFullPath,const char * szFileName,bool bCheckMagic); -public: - KviPointerList<KviMediaType> * mediaTypeList(){ return m_pMediaTypeList; }; - KviMediaType * findMediaTypeByFileMask(const char * filemask); - KviMediaType * findMediaTypeByIanaType(const char * ianaType); - bool removeMediaType(KviMediaType * t){ return m_pMediaTypeList->removeRef(t); }; - void clear(){ m_pMediaTypeList->clear(); }; - void insertMediaType(KviMediaType * t); - KviMediaType * findMediaType(const char * filename,bool bCheckMagic = true); - static void copyMediaType(KviMediaType * dst,KviMediaType * src); - - void load(const QString &filename); - void save(const QString &filename); -}; - - #endif //_KVI_MEDIATYPE_H_ diff --git a/src/kvilib/ext/KviPixmap.cpp b/src/kvilib/ext/KviPixmap.cpp index 95e58aa7c..7c1302ee4 100644 --- a/src/kvilib/ext/KviPixmap.cpp +++ b/src/kvilib/ext/KviPixmap.cpp @@ -29,8 +29,6 @@ #include "KviPixmap.h" #include "KviQString.h" -#include <QPainter> - KviPixmap::KviPixmap() { m_pPix = 0; @@ -155,41 +153,3 @@ KviPixmap & KviPixmap::operator=(const KviPixmap &pix) } return (*this); } - - -void KviPixmapUtils::drawPixmapWithPainter(QPainter* p,QPixmap * pix,int flags,const QRect& paintRect,int iWidgetWidth,int iWidgetHeight,int dx,int dy) -{ - if(!pix)return; - if(!flags) - { - p->drawTiledPixmap(paintRect.left(),paintRect.top(),paintRect.width(),paintRect.height(),*pix,dx,dy); - return; - } - - int iPixWidth=pix->width(); - int iPixHeight=pix->height(); - int x=0; - int y=0; - - if( !(flags & Qt::AlignHorizontal_Mask )) - x=-1; - else if ( flags & Qt::AlignRight ) - x=iWidgetWidth - iPixWidth; - else if( flags & Qt::AlignHCenter ) - x=(iWidgetWidth - iPixWidth)/2; - - if( !(flags & Qt::AlignVertical_Mask )) - y=-1; - else if ( flags & Qt::AlignBottom ) - y=iWidgetHeight - iPixHeight; - else if( flags & Qt::AlignVCenter ) - y=(iWidgetHeight - iPixHeight)/2; - - if(x==-1) { - p->drawTiledPixmap(paintRect.left(),y,paintRect.width(),iPixHeight,*pix,dx,dy); - } else if(y==-1) { - p->drawTiledPixmap(x,paintRect.top(),iPixWidth,paintRect.height(),*pix,dx,dy); - } else { - p->drawPixmap(x,y,*pix); - } -} diff --git a/src/kvilib/ext/KviPixmap.h b/src/kvilib/ext/KviPixmap.h index b87902b7a..424015c2e 100644 --- a/src/kvilib/ext/KviPixmap.h +++ b/src/kvilib/ext/KviPixmap.h @@ -52,11 +52,4 @@ public: void setNull(); }; -namespace KviPixmapUtils -{ - extern KVILIB_API void drawPixmapWithPainter(QPainter* p,QPixmap * pix,int flags,const QRect& paintRect,int iWidgetWidth,int iWidgetHeight,int dx,int dy); - inline void drawPixmapWithPainter(QPainter* p,QPixmap * pix,int flags,const QRect& paintRect,int iWidgetWidth,int iWidgetHeight) - { KviPixmapUtils::drawPixmapWithPainter(p,pix,flags,paintRect,iWidgetWidth,iWidgetHeight,paintRect.left(),paintRect.top()); } -} - #endif //_KVI_PIXMAP_H_ diff --git a/src/kvilib/ext/KviPixmapUtils.cpp b/src/kvilib/ext/KviPixmapUtils.cpp new file mode 100644 index 000000000..8f01eaae3 --- /dev/null +++ b/src/kvilib/ext/KviPixmapUtils.cpp @@ -0,0 +1,65 @@ +//============================================================================= +// +// File : KviPixmapUtils.h +// Creation date : Wed Dec 29 2010 01:10:05 CEST by Elvio Basello +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +#include "KviPixmapUtils.h" + +namespace KviPixmapUtils +{ + void drawPixmapWithPainter(QPainter* p,QPixmap * pix,int flags,const QRect& paintRect,int iWidgetWidth,int iWidgetHeight,int dx,int dy) + { + if(!pix)return; + if(!flags) + { + p->drawTiledPixmap(paintRect.left(),paintRect.top(),paintRect.width(),paintRect.height(),*pix,dx,dy); + return; + } + + int iPixWidth=pix->width(); + int iPixHeight=pix->height(); + int x=0; + int y=0; + + if( !(flags & Qt::AlignHorizontal_Mask )) + x=-1; + else if ( flags & Qt::AlignRight ) + x=iWidgetWidth - iPixWidth; + else if( flags & Qt::AlignHCenter ) + x=(iWidgetWidth - iPixWidth)/2; + + if( !(flags & Qt::AlignVertical_Mask )) + y=-1; + else if ( flags & Qt::AlignBottom ) + y=iWidgetHeight - iPixHeight; + else if( flags & Qt::AlignVCenter ) + y=(iWidgetHeight - iPixHeight)/2; + + if(x==-1) { + p->drawTiledPixmap(paintRect.left(),y,paintRect.width(),iPixHeight,*pix,dx,dy); + } else if(y==-1) { + p->drawTiledPixmap(x,paintRect.top(),iPixWidth,paintRect.height(),*pix,dx,dy); + } else { + p->drawPixmap(x,y,*pix); + } + } +} diff --git a/src/kvilib/ext/KviPixmapUtils.h b/src/kvilib/ext/KviPixmapUtils.h new file mode 100644 index 000000000..4918acb8e --- /dev/null +++ b/src/kvilib/ext/KviPixmapUtils.h @@ -0,0 +1,40 @@ +#ifndef _KVIPIXMAPUTILS_H_ +#define _KVIPIXMAPUTILS_H_ + +//============================================================================= +// +// File : KviPixmapUtils.h +// Creation date : Wed Dec 29 2010 01:10:05 CEST by Elvio Basello +// +// This file is part of the KVirc irc client distribution +// Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com) +// +// This program is FREE software. You can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your opinion) any later version. +// +// This program is distributed in the HOPE that it will be USEFUL, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, write to the Free Software Foundation, +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//============================================================================= + +// this file was originally part of KviPixmap.h + +#include "kvi_settings.h" + +#include <QPainter> + +namespace KviPixmapUtils +{ + extern KVILIB_API void drawPixmapWithPainter(QPainter* p,QPixmap * pix,int flags,const QRect& paintRect,int iWidgetWidth,int iWidgetHeight,int dx,int dy); + inline void drawPixmapWithPainter(QPainter* p,QPixmap * pix,int flags,const QRect& paintRect,int iWidgetWidth,int iWidgetHeight){ KviPixmapUtils::drawPixmapWithPainter(p,pix,flags,paintRect,iWidgetWidth,iWidgetHeight,paintRect.left(),paintRect.top()); } +} + +#endif // _KVIPIXMAPUTILS_H_
\ No newline at end of file diff --git a/src/kvirc/kernel/KviApplication.cpp b/src/kvirc/kernel/KviApplication.cpp index 9d365bc99..5f449ca79 100644 --- a/src/kvirc/kernel/KviApplication.cpp +++ b/src/kvirc/kernel/KviApplication.cpp @@ -41,7 +41,7 @@ #include "KviOptions.h" #include "KviIrcServerParser.h" #include "KviModuleManager.h" -#include "KviMediaType.h" +#include "KviMediaManager.h" #include "KviRegisteredUserDataBase.h" #include "KviThread.h" #include "KviSharedFilesManager.h" diff --git a/src/kvirc/kernel/KviApplication_filesystem.cpp b/src/kvirc/kernel/KviApplication_filesystem.cpp index 3642a033e..d7c63e439 100644 --- a/src/kvirc/kernel/KviApplication_filesystem.cpp +++ b/src/kvirc/kernel/KviApplication_filesystem.cpp @@ -27,7 +27,7 @@ #include "KviApplication.h" #include "KviLocale.h" #include "KviFileUtils.h" -#include "KviMediaType.h" +#include "KviMediaManager.h" #include "KviEnvironment.h" #include "KviTimeUtils.h" #include "KviOptions.h" diff --git a/src/kvirc/ui/KviFileDialog.cpp b/src/kvirc/ui/KviFileDialog.cpp index 9a9dd52d3..8754ab867 100644 --- a/src/kvirc/ui/KviFileDialog.cpp +++ b/src/kvirc/ui/KviFileDialog.cpp @@ -23,7 +23,7 @@ //============================================================================= #include "KviFileDialog.h" -#include "KviMediaType.h" +#include "KviMediaManager.h" #include "KviIconManager.h" #include "KviLocale.h" #include "KviApplication.h" diff --git a/src/kvirc/ui/KviInputEditor.cpp b/src/kvirc/ui/KviInputEditor.cpp index 045d50801..32dc39352 100644 --- a/src/kvirc/ui/KviInputEditor.cpp +++ b/src/kvirc/ui/KviInputEditor.cpp @@ -39,6 +39,7 @@ #include "KviMdiManager.h" #include "KviMircCntrl.h" #include "KviOptions.h" +#include "KviPixmapUtils.h" #include "KviQString.h" #include "kvi_out.h" #include "KviTalPopupMenu.h" diff --git a/src/kvirc/ui/KviIrcToolBar.cpp b/src/kvirc/ui/KviIrcToolBar.cpp index 8061bec7a..b0eddc52a 100644 --- a/src/kvirc/ui/KviIrcToolBar.cpp +++ b/src/kvirc/ui/KviIrcToolBar.cpp @@ -42,6 +42,7 @@ #include "KviLagMeter.h" #include "KviTalPopupMenu.h" #include "KviMdiManager.h" +#include "KviPixmapUtils.h" #include <QStyle> #include <QPainter> diff --git a/src/kvirc/ui/KviIrcView.cpp b/src/kvirc/ui/KviIrcView.cpp index 682a63614..d24e5fbf8 100644 --- a/src/kvirc/ui/KviIrcView.cpp +++ b/src/kvirc/ui/KviIrcView.cpp @@ -98,6 +98,7 @@ #include "KviUserInput.h" #include "KviTalPopupMenu.h" #include "KviAnimatedPixmap.h" +#include "KviPixmapUtils.h" #include <QBitmap> #include <QPainter> diff --git a/src/kvirc/ui/KviTreeWindowList.cpp b/src/kvirc/ui/KviTreeWindowList.cpp index 808128a3f..239e35e9c 100644 --- a/src/kvirc/ui/KviTreeWindowList.cpp +++ b/src/kvirc/ui/KviTreeWindowList.cpp @@ -32,6 +32,7 @@ #include "KviTalPopupMenu.h" #include "KviWindow.h" #include "KviTreeWindowList.h" +#include "KviPixmapUtils.h" #include <QHeaderView> #include <QMouseEvent> diff --git a/src/kvirc/ui/KviUserListView.cpp b/src/kvirc/ui/KviUserListView.cpp index 2860986dd..f2be55881 100644 --- a/src/kvirc/ui/KviUserListView.cpp +++ b/src/kvirc/ui/KviUserListView.cpp @@ -46,6 +46,7 @@ #include "KviStringConversion.h" #include "KviIrcConnection.h" #include "KviIrcConnectionServerInfo.h" +#include "KviPixmapUtils.h" #include <QLabel> #include <QScrollBar> diff --git a/src/modules/dcc/broker.cpp b/src/modules/dcc/broker.cpp index 5474729f0..40fdc9e48 100644 --- a/src/modules/dcc/broker.cpp +++ b/src/modules/dcc/broker.cpp @@ -45,7 +45,7 @@ #include "KviConsoleWindow.h" #include "KviFileUtils.h" #include "kvi_out.h" -#include "KviMediaType.h" +#include "KviMediaManager.h" #include "KviIrcConnection.h" #include "KviSharedFilesManager.h" diff --git a/src/modules/dcc/send.cpp b/src/modules/dcc/send.cpp index 6c5463eea..2a145e599 100644 --- a/src/modules/dcc/send.cpp +++ b/src/modules/dcc/send.cpp @@ -45,7 +45,7 @@ #include "KviMemory.h" #include "KviThread.h" #include "KviIrcSocket.h" -#include "KviMediaType.h" +#include "KviMediaManager.h" #include "kvi_socket.h" #include "KviKvsEventTriggers.h" #include "KviParameterList.h" diff --git a/src/modules/notifier/notifierwindowtab.cpp b/src/modules/notifier/notifierwindowtab.cpp index 67f1c931a..7f48d15f6 100644 --- a/src/modules/notifier/notifierwindowtab.cpp +++ b/src/modules/notifier/notifierwindowtab.cpp @@ -33,6 +33,7 @@ #include "KviLocale.h" #include "KviMainWindow.h" #include "KviOptions.h" +#include "KviPixmapUtils.h" #include "KviWindow.h" #include <QScrollBar> diff --git a/src/modules/options/optw_mediatypes.h b/src/modules/options/optw_mediatypes.h index aec8a6f2d..d3e22608b 100644 --- a/src/modules/options/optw_mediatypes.h +++ b/src/modules/options/optw_mediatypes.h @@ -25,7 +25,7 @@ //============================================================================= #include "KviOptionsWidget.h" -#include "KviMediaType.h" +#include "KviMediaManager.h" #include <QTreeWidget> #include <QLineEdit> |
