diff options
Diffstat (limited to 'src')
530 files changed, 5479 insertions, 5875 deletions
diff --git a/src/kvilib/CMakeLists.txt b/src/kvilib/CMakeLists.txt index ad8a3134e..8dc6c0e3d 100644 --- a/src/kvilib/CMakeLists.txt +++ b/src/kvilib/CMakeLists.txt @@ -130,20 +130,31 @@ endif() add_library(${KVILIB_BINARYNAME} SHARED ${kvilib_SRCS} ${kvilib_MOC_SRCS}) target_link_libraries(${KVILIB_BINARYNAME} ${LIBS}) -# Enable C++11 -set_property(TARGET ${KVILIB_BINARYNAME} PROPERTY CXX_STANDARD 11) +# Enable C++17 +set_property(TARGET ${KVILIB_BINARYNAME} PROPERTY CXX_STANDARD 17) set_property(TARGET ${KVILIB_BINARYNAME} PROPERTY CXX_STANDARD_REQUIRED ON) if(Qt5Widgets_FOUND) - qt5_use_modules(${KVILIB_BINARYNAME} ${qt5_kvirc_modules}) + target_link_libraries(${KVILIB_BINARYNAME} ${qt5_kvirc_modules}) endif() set_target_properties(${KVILIB_BINARYNAME} PROPERTIES VERSION ${VERSION_RELEASE} SOVERSION ${VERSION_MAJOR} LINK_FLAGS "${ADDITIONAL_LINK_FLAGS}") if(WANT_STRIP) - get_target_property(KVILIB_LOCATION ${KVILIB_BINARYNAME} LOCATION) - install(CODE "exec_program(${STRIP_EXECUTABLE} ARGS -s \"${KVILIB_LOCATION}\")") + IF(APPLE) + add_custom_command( + TARGET ${KVILIB_BINARYNAME} + POST_BUILD + COMMAND ${STRIP_EXECUTABLE} -x $<TARGET_FILE:${KVILIB_BINARYNAME}> + ) + ELSE() + add_custom_command( + TARGET ${KVILIB_BINARYNAME} + POST_BUILD + COMMAND ${STRIP_EXECUTABLE} -s $<TARGET_FILE:${KVILIB_BINARYNAME}> + ) + ENDIF() endif() # Installation directives diff --git a/src/kvilib/config/KviBuildInfo.cpp b/src/kvilib/config/KviBuildInfo.cpp index f6aecc120..9c89961ce 100644 --- a/src/kvilib/config/KviBuildInfo.cpp +++ b/src/kvilib/config/KviBuildInfo.cpp @@ -118,11 +118,6 @@ namespace KviBuildInfo return QString(KVIRC_BUILD_FLAGS); } - QString buildSystem() - { - return QString(KVIRC_BUILD_SYSTEM); - } - QString buildSystemName() { #ifdef COMPILE_ON_WINDOWS @@ -132,15 +127,6 @@ namespace KviBuildInfo #endif } - QString buildSystemVersion() - { -#ifdef COMPILE_ON_WINDOWS - return QString(); -#else - return QString(KVIRC_BUILD_SYSTEM_VERSION); -#endif - } - QString buildCPU() { return QString(KVIRC_BUILD_CPU); diff --git a/src/kvilib/config/KviBuildInfo.h b/src/kvilib/config/KviBuildInfo.h index ceb3fbdd0..d6d2e4ea1 100644 --- a/src/kvilib/config/KviBuildInfo.h +++ b/src/kvilib/config/KviBuildInfo.h @@ -77,14 +77,6 @@ namespace KviBuildInfo extern KVILIB_API QString buildFlags(); /** - * \brief Returns a description of the system - * - * The system refers to the one used to build the KVIrc executable. - * \return QString - */ - extern KVILIB_API QString buildSystem(); - - /** * \brief Returns the name part of the system * * The system name refers to the one used to build the KVIrc executable. @@ -93,14 +85,6 @@ namespace KviBuildInfo extern KVILIB_API QString buildSystemName(); /** - * \brief Returns the version part of the system - * - * The system version refers to the one used to build the KVIrc executable. - * \return QString - */ - extern KVILIB_API QString buildSystemVersion(); - - /** * \brief Returns a description of the CPU * * The CPU refers to the one used to build the KVIrc executable. diff --git a/src/kvilib/core/KviCString.cpp b/src/kvilib/core/KviCString.cpp index f3db9c12f..b4c8b4f07 100644 --- a/src/kvilib/core/KviCString.cpp +++ b/src/kvilib/core/KviCString.cpp @@ -360,7 +360,7 @@ bool kvi_matchWildExpr(const char * m1, const char * m2) bool kvi_matchWildExprCS(const char *m1,const char *m2) { if(!(m1 && m2 && (*m1)))return false; - const char * savePos1 = 0; + const char * savePos1 = nullptr; const char * savePos2 = m2; while(*m1){ //loop managed by m1 (initially first mask) if(*m1=='*'){ @@ -955,7 +955,7 @@ int kvi_strMatchRevCS(const char * str1, const char * str2, int index) s2--; // now start comparing - while(1) + while(true) { /* in this case, we have str1 = "lo" and str2 = "hello" */ if(s1 < str1 && !(s2 < str2)) diff --git a/src/kvilib/core/KviCString.h b/src/kvilib/core/KviCString.h index f295baa54..43fb25b2f 100644 --- a/src/kvilib/core/KviCString.h +++ b/src/kvilib/core/KviCString.h @@ -243,7 +243,7 @@ public: // Assignment KviCString & operator=(const KviCString & str); // deep copy - KviCString & operator=(const char * str); // str can be NULL here + KviCString & operator=(const char * str); // str can be nullptr here KviCString & operator=(char c); // 2 bytes allocated,m_len = 1 KviCString & operator=(const QString & str); KviCString & operator=(const QByteArray & str); @@ -366,7 +366,7 @@ public: // if sep is not 0, it is inserted between the strings // if bLastSep is true and sep is non 0, then sep is also appended at the end // of the buffer (after the last string) - void joinFromArray(KviCString ** strings, const char * sep = 0, bool bLastSep = false); + void joinFromArray(KviCString ** strings, const char * sep = nullptr, bool bLastSep = false); // Utils // encodes chars that have nonzero in the jumptable @@ -410,16 +410,16 @@ public: // Numbers // everything in base 10.... no overflow checks here - long toLong(bool * bOk = 0) const; - unsigned long toULong(bool * bOk = 0) const; - long long toLongLong(bool * bOk = 0) const; - unsigned long long toULongLong(bool * bOk = 0) const; - char toChar(bool * bOk = 0) const { return (char)toLong(bOk); }; - unsigned char toUChar(bool * bOk = 0) const { return (unsigned char)toULong(bOk); }; - int toInt(bool * bOk = 0) const { return (int)toLong(bOk); }; - unsigned int toUInt(bool * bOk = 0) const { return (unsigned int)toULong(bOk); }; - short toShort(bool * bOk = 0) const { return (short)toLong(bOk); }; - unsigned short toUShort(bool * bOk = 0) const { return (unsigned short)toLong(bOk); }; + long toLong(bool * bOk = nullptr) const; + unsigned long toULong(bool * bOk = nullptr) const; + long long toLongLong(bool * bOk = nullptr) const; + unsigned long long toULongLong(bool * bOk = nullptr) const; + char toChar(bool * bOk = nullptr) const { return (char)toLong(bOk); }; + unsigned char toUChar(bool * bOk = nullptr) const { return (unsigned char)toULong(bOk); }; + int toInt(bool * bOk = nullptr) const { return (int)toLong(bOk); }; + unsigned int toUInt(bool * bOk = nullptr) const { return (unsigned int)toULong(bOk); }; + short toShort(bool * bOk = nullptr) const { return (short)toLong(bOk); }; + unsigned short toUShort(bool * bOk = nullptr) const { return (unsigned short)toLong(bOk); }; KviCString & setNum(long num); KviCString & setNum(unsigned long num); @@ -439,8 +439,8 @@ public: bool isUnsignedNum() const; // special functions for multiple bases - long toLongExt(bool * bOk = 0, int base = 0); - // unsigned long toULongExt(bool *bOk = 0,int base = 0); //never used + long toLongExt(bool * bOk = nullptr, int base = 0); + // unsigned long toULongExt(bool *bOk = nullptr,int base = 0); //never used // returns an empty string... // this if often useful! @@ -450,7 +450,7 @@ public: // Transform a pointer to a string with all 0 and 1 // void pointerToBitString(const void * ptr); - // Get a pointer from a string all of 0 and 1 : return 0 if invalid + // Get a pointer from a string all of 0 and 1 : return nullptr if invalid // void * bitStringToPointer(); // "External string" helper functions @@ -486,19 +486,19 @@ __KVI_EXTERN KVILIB_API int kvi_irc_vsnprintf(char * buffer, const char * fmt, k // WILDCARD EXPRESSION MATCHING FUNCTIONS // Returns true if the two regular expressions with wildcards matches -__KVI_EXTERN KVILIB_API bool kvi_matchWildExpr(register const char * m1, register const char * m2); +__KVI_EXTERN KVILIB_API bool kvi_matchWildExpr(const char * m1, const char * m2); // Returns true if the two regular expressions with wildcards matches, case sensitive -//__KVI_EXTERN bool kvi_matchWildExprCS(register const char *m1,register const char *m2); // actually unused +//__KVI_EXTERN bool kvi_matchWildExprCS(const char *m1, const char *m2); // actually unused // Same as kvi_matchWildExpr but with an additional char that acts as string terminator // If there is a match this function returns true and puts the pointers where it stopped in r1 and r2 -__KVI_EXTERN KVILIB_API bool kvi_matchWildExprWithTerminator(register const char * m1, register const char * m2, char terminator, +__KVI_EXTERN KVILIB_API bool kvi_matchWildExprWithTerminator(const char * m1, const char * m2, char terminator, const char ** r1, const char ** r2); // Returns true if the wildcard expression exp matches the string str -__KVI_EXTERN KVILIB_API bool kvi_matchStringCI(register const char * exp, register const char * str); +__KVI_EXTERN KVILIB_API bool kvi_matchStringCI(const char * exp, const char * str); #define kvi_matchString kvi_matchStringCI -__KVI_EXTERN KVILIB_API bool kvi_matchStringCS(register const char * exp, register const char * str); -__KVI_EXTERN KVILIB_API bool kvi_matchStringWithTerminator(register const char * exp, register const char * str, char terminator, const char ** r1, const char ** r2); +__KVI_EXTERN KVILIB_API bool kvi_matchStringCS(const char * exp, const char * str); +__KVI_EXTERN KVILIB_API bool kvi_matchStringWithTerminator(const char * exp, const char * str, char terminator, const char ** r1, const char ** r2); // This function works like a particular case of strncmp. // It evaluates if str2 is the terminal part of str1. diff --git a/src/kvilib/core/KviError.cpp b/src/kvilib/core/KviError.cpp index dade349b3..714ba1726 100644 --- a/src/kvilib/core/KviError.cpp +++ b/src/kvilib/core/KviError.cpp @@ -34,7 +34,7 @@ #include <winsock2.h> // for the WSAE* error codes #endif -#include <errno.h> +#include <cerrno> #ifdef HAVE_STRERROR #include <string.h> // for strerror() diff --git a/src/kvilib/core/KviMemory.cpp b/src/kvilib/core/KviMemory.cpp index 90d936cf5..6d3a2f2b2 100644 --- a/src/kvilib/core/KviMemory.cpp +++ b/src/kvilib/core/KviMemory.cpp @@ -31,7 +31,7 @@ #define _KVI_MALLOC_CPP_ #include "KviMemory.h" -#include <stdio.h> +#include <cstdio> #ifdef COMPILE_MEMORY_PROFILE #include "KviPointerList.h" @@ -47,25 +47,25 @@ namespace KviMemory // Used to find memory leaks etc... // - typedef struct _KviMallocEntry + struct KviMallocEntry { - struct _KviMallocEntry * prev; + KviMallocEntry * prev; void * pointer; int size; void * return_addr1; void * return_addr2; - struct _KviMallocEntry * next; - } KviMallocEntry; + KviMallocEntry * next; + }; int g_iMaxRequestSize = 0; - void * g_pMaxRequestReturnAddress1 = 0; - void * g_pMaxRequestReturnAddress2 = 0; + void * g_pMaxRequestReturnAddress1 = nullptr; + void * g_pMaxRequestReturnAddress2 = nullptr; unsigned int g_iMallocCalls = 0; unsigned int g_iReallocCalls = 0; unsigned int g_iFreeCalls = 0; unsigned int g_iTotalMemAllocated = 0; unsigned int g_uAllocationPeak = 0; - KviMallocEntry * g_pEntries = 0; + KviMallocEntry * g_pEntries = nullptr; void * allocate(int size) { @@ -85,7 +85,7 @@ namespace KviMemory e->return_addr1 = __builtin_return_address(1); e->return_addr2 = __builtin_return_address(2); e->next = g_pEntries; - e->prev = 0; + e->prev = nullptr; if(g_pEntries) g_pEntries->prev = e; g_pEntries = e; @@ -151,7 +151,7 @@ namespace KviMemory if(e != g_pEntries) fprintf(stderr, "Mem profiling internal error!\n"); if(e->next) - e->next->prev = 0; + e->next->prev = nullptr; g_pEntries = e->next; } free(e); @@ -238,7 +238,7 @@ namespace KviMemory // WE WANT repnz; movsq\n"!!! - inline void copy(void * dst_ptr,const void *src_ptr,int len) + void copy(void * dst_ptr,const void *src_ptr,int len) { __asm__ __volatile__( " cld\n" @@ -256,7 +256,7 @@ namespace KviMemory ); } - inline void copy(void * dst_ptr,const void *src_ptr,int len) + void copy(void * dst_ptr,const void *src_ptr,int len) { __asm__ __volatile__( " cld\n" @@ -447,7 +447,7 @@ namespace KviMemory // only by gcc // - inline bool kvi_strEqualCS(const char * pcStr1, const char * pcStr2) + bool kvi_strEqualCS(const char * pcStr1, const char * pcStr2) { // An instruction pattern is really useful in this case. // When inlining, GCC can optimize to load esi and edi @@ -473,7 +473,7 @@ namespace KviMemory return bEax; } - inline bool kvi_strEqualCSN(const char * pcStr1, const char * pcStr2, int iLen) + bool kvi_strEqualCSN(const char * pcStr1, const char * pcStr2, int iLen) { register bool bEax; __asm__ __volatile__ ( @@ -508,7 +508,7 @@ namespace KviMemory // These will NOT work with localizable characters: // 'a' with umlaut will be not equal to 'A' with umlaut - inline bool kvi_strEqualNoLocaleCI(const char * pcStr1, const char * pcStr2) + bool kvi_strEqualNoLocaleCI(const char * pcStr1, const char * pcStr2) { // Trivial implementation // Ignores completely locales....only A-Z chars are transformed to a-z @@ -548,7 +548,7 @@ namespace KviMemory return bEax; } - inline bool kvi_strEqualNoLocaleCIN(const char * pcStr1, const char * pcStr2, int iLen) + bool kvi_strEqualNoLocaleCIN(const char * pcStr1, const char * pcStr2, int iLen) { register int iReg; @@ -589,7 +589,7 @@ namespace KviMemory return bEax; } - inline int kvi_strLen(const char * pcStr) + int kvi_strLen(const char * pcStr) { register int iEcx; __asm__ __volatile__( diff --git a/src/kvilib/core/KviPointerHashTable.h b/src/kvilib/core/KviPointerHashTable.h index 1d637577d..fa55be62f 100644 --- a/src/kvilib/core/KviPointerHashTable.h +++ b/src/kvilib/core/KviPointerHashTable.h @@ -137,7 +137,7 @@ inline void kvi_hash_key_destroy(const char *& szKey, bool bDeepCopy) */ inline const char *& kvi_hash_key_default(const char **) { - static const char * static_null = NULL; + static const char * static_null = nullptr; return static_null; } @@ -322,7 +322,7 @@ inline void kvi_hash_key_destroy(void *, bool) */ inline void *& kvi_hash_key_default(void *) { - static void * static_default = NULL; + static void * static_default = nullptr; return static_default; } @@ -457,13 +457,13 @@ protected: unsigned int m_uCount; bool m_bCaseSensitive; bool m_bDeepCopyKeys; - unsigned int m_uIteratorIdx; + unsigned int m_uIteratorIdx = 0; public: /** * \brief Returns the item associated to the key * - * Returns NULL if no such item exists in the hash table. + * Returns nullptr if no such item exists in the hash table. * Places the hash table iterator at the position of the item found. * \param hKey The key to find * \return T * @@ -472,19 +472,19 @@ public: { m_uIteratorIdx = kvi_hash_hash(hKey, m_bCaseSensitive) % m_uSize; if(!m_pDataArray[m_uIteratorIdx]) - return 0; + return nullptr; for(KviPointerHashTableEntry<Key, T> * e = m_pDataArray[m_uIteratorIdx]->first(); e; e = m_pDataArray[m_uIteratorIdx]->next()) { if(kvi_hash_key_equal(e->hKey, hKey, m_bCaseSensitive)) return (T *)e->pData; } - return 0; + return nullptr; } /** * \brief Returns the item associated to the key hKey * - * Returns NULL if no such item exists in the hash table. + * Returns nullptr if no such item exists in the hash table. * Places the hash table iterator at the position of the item found. * This is an alias to find(). * \param hKey The key to find @@ -594,7 +594,7 @@ public: if(m_pDataArray[uEntry]->isEmpty()) { delete m_pDataArray[uEntry]; - m_pDataArray[uEntry] = 0; + m_pDataArray[uEntry] = nullptr; } m_uCount--; return true; @@ -629,7 +629,7 @@ public: if(m_pDataArray[i]->isEmpty()) { delete m_pDataArray[i]; - m_pDataArray[i] = 0; + m_pDataArray[i] = nullptr; } m_uCount--; return true; @@ -670,7 +670,7 @@ public: if(m_pDataArray[i]) { delete m_pDataArray[i]; - m_pDataArray[i] = 0; + m_pDataArray[i] = nullptr; } } m_uCount = 0; @@ -679,7 +679,7 @@ public: /** * \brief Searches for the item pointer pRef * - * Returns its hash table entry, if found, and NULL otherwise. + * Returns its hash table entry, if found, and nullptr otherwise. * The hash table iterator is placed at the item found. * \param pRef The pointer to search * \return KviPointerHashTableEntry<Key,T> * @@ -697,7 +697,7 @@ public: } } } - return 0; + return nullptr; } /** @@ -710,10 +710,10 @@ public: KviPointerHashTableEntry<Key, T> * currentEntry() { if(m_uIteratorIdx >= m_uSize) - return 0; + return nullptr; if(m_pDataArray[m_uIteratorIdx]) return m_pDataArray[m_uIteratorIdx]->current(); - return 0; + return nullptr; } /** @@ -728,7 +728,7 @@ public: m_uIteratorIdx++; } if(m_uIteratorIdx == m_uSize) - return 0; + return nullptr; return m_pDataArray[m_uIteratorIdx]->first(); } @@ -742,7 +742,7 @@ public: KviPointerHashTableEntry<Key, T> * nextEntry() { if(m_uIteratorIdx >= m_uSize) - return 0; + return nullptr; if(m_uIteratorIdx < m_uSize) { @@ -759,7 +759,7 @@ public: } if(m_uIteratorIdx == m_uSize) - return 0; + return nullptr; return m_pDataArray[m_uIteratorIdx]->first(); } @@ -774,15 +774,15 @@ public: T * current() { if(m_uIteratorIdx >= m_uSize) - return 0; + return nullptr; if(m_pDataArray[m_uIteratorIdx]) { KviPointerHashTableEntry<Key, T> * e = m_pDataArray[m_uIteratorIdx]->current(); if(!e) - return 0; + return nullptr; return e->data(); } - return 0; + return nullptr; } /** @@ -795,15 +795,15 @@ public: const Key & currentKey() { if(m_uIteratorIdx >= m_uSize) - return kvi_hash_key_default(((Key *)NULL)); + return kvi_hash_key_default(((Key *)nullptr)); if(m_pDataArray[m_uIteratorIdx]) { KviPointerHashTableEntry<Key, T> * e = m_pDataArray[m_uIteratorIdx]->current(); if(!e) - return kvi_hash_key_default(((Key *)NULL)); + return kvi_hash_key_default(((Key *)nullptr)); return e->key(); } - return kvi_hash_key_default(((Key *)NULL)); + return kvi_hash_key_default(((Key *)nullptr)); } /** \brief Places the hash table iterator at the first entry @@ -819,10 +819,10 @@ public: m_uIteratorIdx++; } if(m_uIteratorIdx == m_uSize) - return 0; + return nullptr; KviPointerHashTableEntry<Key, T> * e = m_pDataArray[m_uIteratorIdx]->first(); if(!e) - return 0; + return nullptr; return e->data(); } @@ -836,7 +836,7 @@ public: T * next() { if(m_uIteratorIdx >= m_uSize) - return 0; + return nullptr; if(m_uIteratorIdx < m_uSize) { @@ -855,11 +855,11 @@ public: } if(m_uIteratorIdx == m_uSize) - return 0; + return nullptr; KviPointerHashTableEntry<Key, T> * e = m_pDataArray[m_uIteratorIdx]->first(); if(!e) - return 0; + return nullptr; return e->data(); } @@ -923,7 +923,7 @@ public: m_uSize = uSize > 0 ? uSize : 32; m_pDataArray = new KviPointerList<KviPointerHashTableEntry<Key, T>> *[m_uSize]; for(unsigned int i = 0; i < m_uSize; i++) - m_pDataArray[i] = NULL; + m_pDataArray[i] = nullptr; } /** @@ -942,7 +942,7 @@ public: m_uSize = t.m_uSize; m_pDataArray = new KviPointerList<KviPointerHashTableEntry<Key, T>> *[m_uSize]; for(unsigned int i = 0; i < m_uSize; i++) - m_pDataArray[i] = NULL; + m_pDataArray[i] = nullptr; copyFrom(t); } @@ -985,7 +985,7 @@ public: if(src.m_pIterator) m_pIterator = new KviPointerListIterator<KviPointerHashTableEntry<Key, T>>(*(src.m_pIterator)); else - m_pIterator = NULL; + m_pIterator = nullptr; } /** @@ -999,7 +999,7 @@ public: if(m_pIterator) { delete m_pIterator; - m_pIterator = NULL; + m_pIterator = nullptr; } m_uEntryIndex = 0; @@ -1016,7 +1016,7 @@ public: if(!bRet) { delete m_pIterator; - m_pIterator = NULL; + m_pIterator = nullptr; } return bRet; } @@ -1032,7 +1032,7 @@ public: if(m_pIterator) { delete m_pIterator; - m_pIterator = NULL; + m_pIterator = nullptr; } m_uEntryIndex = m_pHashTable->m_uSize; @@ -1046,7 +1046,7 @@ public: if(!bRet) { delete m_pIterator; - m_pIterator = NULL; + m_pIterator = nullptr; } return bRet; } @@ -1070,7 +1070,7 @@ public: if(m_pIterator) { delete m_pIterator; - m_pIterator = NULL; + m_pIterator = nullptr; } m_uEntryIndex++; while((m_uEntryIndex < m_pHashTable->m_uSize) && (!(m_pHashTable->m_pDataArray[m_uEntryIndex]))) @@ -1084,7 +1084,7 @@ public: if(!bRet) { delete m_pIterator; - m_pIterator = NULL; + m_pIterator = nullptr; } return bRet; } @@ -1119,7 +1119,7 @@ public: if(m_pIterator) { delete m_pIterator; - m_pIterator = NULL; + m_pIterator = nullptr; } if(m_uEntryIndex >= m_pHashTable->m_uSize) return false; @@ -1133,7 +1133,7 @@ public: if(!bRet) { delete m_pIterator; - m_pIterator = NULL; + m_pIterator = nullptr; } return bRet; } @@ -1164,7 +1164,7 @@ public: */ T * current() const { - return m_pIterator ? m_pIterator->current()->data() : NULL; + return m_pIterator ? m_pIterator->current()->data() : nullptr; } /** @@ -1176,7 +1176,7 @@ public: */ T * operator*() const { - return m_pIterator ? m_pIterator->current()->data() : NULL; + return m_pIterator ? m_pIterator->current()->data() : nullptr; } /** @@ -1189,19 +1189,19 @@ public: { if(m_pIterator) return m_pIterator->current()->key(); - return kvi_hash_key_default(((Key *)NULL)); + return kvi_hash_key_default(((Key *)nullptr)); } /** * \brief Moves the iterator to the first element of the hash table. * - * Returns the first item found or NULL if the hash table is empty. + * Returns the first item found or nullptr if the hash table is empty. * \return T * */ T * toFirst() { if(!moveFirst()) - return NULL; + return nullptr; return current(); } @@ -1215,7 +1215,7 @@ public: { m_pHashTable = &hTable; m_uEntryIndex = 0; - m_pIterator = NULL; + m_pIterator = nullptr; moveFirst(); } diff --git a/src/kvilib/core/KviPointerList.h b/src/kvilib/core/KviPointerList.h index 5eff4d07c..0f8d12b7d 100644 --- a/src/kvilib/core/KviPointerList.h +++ b/src/kvilib/core/KviPointerList.h @@ -45,7 +45,6 @@ * been removed from Qt4 in favor of the value based non-autodeleting * lists... anyway: here we go :) * -* \def NULL Define NULL type to 0 * \def KviPointerListBase Defines KviPointerListBase as KviPointerList */ @@ -56,10 +55,6 @@ class KviPointerList; template <typename T> class KviPointerListIterator; -#ifndef NULL -#define NULL 0 -#endif - /** * \class KviPointerListNode * \brief A KviPointerList node pointers. @@ -213,7 +208,7 @@ public: bool moveFirst() { m_pNode = m_pList->m_pHead; - return m_pNode != NULL; + return m_pNode != nullptr; } /** @@ -225,7 +220,7 @@ public: bool moveLast() { m_pNode = m_pList->m_pTail; - return m_pNode != NULL; + return m_pNode != nullptr; } /** @@ -240,7 +235,7 @@ public: if(!m_pNode) return false; m_pNode = m_pNode->m_pNext; - return m_pNode != NULL; + return m_pNode != nullptr; } /** @@ -256,7 +251,7 @@ public: if(!m_pNode) return false; m_pNode = m_pNode->m_pNext; - return m_pNode != NULL; + return m_pNode != nullptr; } /** @@ -272,7 +267,7 @@ public: if(!m_pNode) return false; m_pNode = m_pNode->m_pPrev; - return m_pNode != NULL; + return m_pNode != nullptr; } /** @@ -289,30 +284,30 @@ public: if(!m_pNode) return false; m_pNode = m_pNode->m_pPrev; - return m_pNode != NULL; + return m_pNode != nullptr; } /** * \brief Returns the value pointed by the iterator. * - * If the iterator is not valid, returns NULL. + * If the iterator is not valid, returns nullptr. * \return T * */ T * current() { - return m_pNode ? (T *)(m_pNode->m_pData) : NULL; + return m_pNode ? (T *)(m_pNode->m_pData) : nullptr; } /** * \brief Returns the value pointed by the iterator. * - * If the iterator is not valid, returns NULL. + * If the iterator is not valid, returns nullptr. * This is just an alias to current(). * \return T * */ T * operator*() { - return m_pNode ? (T *)(m_pNode->m_pData) : NULL; + return m_pNode ? (T *)(m_pNode->m_pData) : nullptr; } /** @@ -323,7 +318,7 @@ public: */ bool isValid() { - return m_pNode != NULL; + return m_pNode != nullptr; } }; @@ -379,7 +374,7 @@ class KviPointerList protected: bool m_bAutoDelete; //< do we automatically delete items when they are removed ? - KviPointerListNode * m_pHead; //< our list head pointer (NULL if there are no items in the list) + KviPointerListNode * m_pHead; //< our list head pointer (nullptr if there are no items in the list) KviPointerListNode * m_pTail; //< our list tail KviPointerListNode * m_pAux; //< our iteration pointer @@ -428,12 +423,12 @@ protected: if(pNewHead->m_pNext) { src->m_pHead = pNewHead->m_pNext; - src->m_pHead->m_pPrev = NULL; + src->m_pHead->m_pPrev = nullptr; } else { - src->m_pHead = NULL; - src->m_pTail = NULL; + src->m_pHead = nullptr; + src->m_pTail = nullptr; } if(m_pHead) @@ -446,7 +441,7 @@ protected: { m_pHead = pNewHead; m_pTail = pNewHead; - m_pHead->m_pNext = NULL; + m_pHead->m_pNext = nullptr; } m_uCount++; src->m_uCount--; @@ -468,7 +463,7 @@ protected: m_pTail = m_pAux->m_pPrev; const T * pAuxData = (const T *)(m_pAux->m_pData); delete m_pAux; - m_pAux = NULL; + m_pAux = nullptr; m_uCount--; if(m_bAutoDelete) delete pAuxData; // this can cause recursion, so do it at the end @@ -521,13 +516,13 @@ public: { m_pHead = n; m_pTail = n; - n->m_pPrev = NULL; + n->m_pPrev = nullptr; } m_pTail = src->m_pTail; } - src->m_pHead = NULL; - src->m_pTail = NULL; + src->m_pHead = nullptr; + src->m_pTail = nullptr; src->m_uCount = 0; } @@ -615,7 +610,7 @@ public: */ bool isEmpty() const { - return (m_pHead == NULL); + return (m_pHead == nullptr); } /** @@ -638,8 +633,8 @@ public: { if(!m_pHead) { - m_pAux = NULL; - return NULL; + m_pAux = nullptr; + return nullptr; } m_pAux = m_pHead; return (T *)(m_pAux->m_pData); @@ -655,21 +650,21 @@ public: T * takeFirst() { if(!m_pHead) - return NULL; + return nullptr; T * pData = (T *)m_pHead->m_pData; if(m_pHead->m_pNext) { m_pHead = m_pHead->m_pNext; delete m_pHead->m_pPrev; - m_pHead->m_pPrev = NULL; + m_pHead->m_pPrev = nullptr; } else { delete m_pHead; - m_pHead = NULL; - m_pTail = NULL; + m_pHead = nullptr; + m_pTail = nullptr; } - m_pAux = NULL; + m_pAux = nullptr; m_uCount--; return pData; } @@ -681,21 +676,21 @@ public: T * takeLast() { if(!m_pTail) - return NULL; + return nullptr; T * pData = (T *)m_pTail->m_pData; if(m_pTail->m_pPrev) { m_pTail = m_pTail->m_pPrev; delete m_pTail->m_pNext; - m_pTail->m_pNext = NULL; + m_pTail->m_pNext = nullptr; } else { delete m_pTail; - m_pHead = NULL; - m_pTail = NULL; + m_pHead = nullptr; + m_pTail = nullptr; } - m_pAux = NULL; + m_pAux = nullptr; m_uCount--; return pData; } @@ -720,8 +715,8 @@ public: { if(!m_pTail) { - m_pAux = NULL; - return NULL; + m_pAux = nullptr; + return nullptr; } m_pAux = m_pTail; return (T *)(m_pAux->m_pData); @@ -753,13 +748,13 @@ public: * * A call to this function should be preceded by a call to * first(),last(),at() or findRef(). - * This function will return a NULL pointer if the current item has + * This function will return a nullptr if the current item has * been invalidated due to a remove operation. * \return T * */ T * safeCurrent() { - return m_pAux ? (T *)(m_pAux->m_pData) : NULL; + return m_pAux ? (T *)(m_pAux->m_pData) : nullptr; } /** @@ -778,7 +773,7 @@ public: * \brief Returns the next item in the list * * Sets the iteration pointer to the next item in the list and - * returns that item (or 0 if the end of the list has been reached) + * returns that item (or nullptr if the end of the list has been reached) * A call to this function MUST be preceded by a _successfull_ call * to first(),last(),at() or findRef(). * \return T * @@ -786,11 +781,11 @@ public: T * next() { if(!m_pAux) - return NULL; + return nullptr; m_pAux = m_pAux->m_pNext; if(m_pAux) return (T *)(m_pAux->m_pData); - return NULL; + return nullptr; } /** @@ -806,11 +801,11 @@ public: T * prev() { if(!m_pAux) - return NULL; + return nullptr; m_pAux = m_pAux->m_pPrev; if(m_pAux) return (T *)(m_pAux->m_pData); - return NULL; + return nullptr; } /** @@ -832,7 +827,7 @@ public: t = next(); cnt++; } - return 0; + return nullptr; } /** @@ -851,7 +846,7 @@ public: n = n->m_pNext; cnt++; } - return KviPointerListIterator<T>(*this, NULL); + return KviPointerListIterator<T>(*this, nullptr); } /** @@ -889,7 +884,7 @@ public: return KviPointerListIterator<T>(*this, n); n = n->m_pNext; } - return KviPointerListIterator<T>(*this, NULL); + return KviPointerListIterator<T>(*this, nullptr); } /** @@ -902,8 +897,8 @@ public: if(!m_pHead) { m_pHead = new KviPointerListNode; - m_pHead->m_pPrev = NULL; - m_pHead->m_pNext = NULL; + m_pHead->m_pPrev = nullptr; + m_pHead->m_pNext = nullptr; m_pHead->m_pData = (void *)d; m_pTail = m_pHead; } @@ -911,7 +906,7 @@ public: { m_pTail->m_pNext = new KviPointerListNode; m_pTail->m_pNext->m_pPrev = m_pTail; - m_pTail->m_pNext->m_pNext = NULL; + m_pTail->m_pNext->m_pNext = nullptr; m_pTail->m_pNext->m_pData = (void *)d; m_pTail = m_pTail->m_pNext; } @@ -950,8 +945,8 @@ public: if(!m_pHead) { m_pHead = new KviPointerListNode; - m_pHead->m_pPrev = NULL; - m_pHead->m_pNext = NULL; + m_pHead->m_pPrev = nullptr; + m_pHead->m_pNext = nullptr; m_pHead->m_pData = (void *)d; m_pTail = m_pHead; } @@ -959,7 +954,7 @@ public: { m_pHead->m_pPrev = new KviPointerListNode; m_pHead->m_pPrev->m_pNext = m_pHead; - m_pHead->m_pPrev->m_pPrev = NULL; + m_pHead->m_pPrev->m_pPrev = nullptr; m_pHead->m_pPrev->m_pData = (void *)d; m_pHead = m_pHead->m_pPrev; m_uCount++; @@ -1008,16 +1003,16 @@ public: m_pHead = m_pHead->m_pNext; pAuxData = (const T *)(m_pHead->m_pPrev->m_pData); delete m_pHead->m_pPrev; - m_pHead->m_pPrev = NULL; + m_pHead->m_pPrev = nullptr; } else { pAuxData = (const T *)(m_pHead->m_pData); delete m_pHead; - m_pHead = NULL; - m_pTail = NULL; + m_pHead = nullptr; + m_pTail = nullptr; } - m_pAux = NULL; + m_pAux = nullptr; m_uCount--; if(m_bAutoDelete) delete pAuxData; @@ -1040,16 +1035,16 @@ public: m_pTail = m_pTail->m_pPrev; pAuxData = (const T *)(m_pTail->m_pNext->m_pData); delete m_pTail->m_pNext; - m_pTail->m_pNext = NULL; + m_pTail->m_pNext = nullptr; } else { pAuxData = (const T *)(m_pTail->m_pData); delete m_pTail; - m_pHead = NULL; - m_pTail = NULL; + m_pHead = nullptr; + m_pTail = nullptr; } - m_pAux = NULL; + m_pAux = nullptr; m_uCount--; if(m_bAutoDelete) delete pAuxData; @@ -1258,10 +1253,10 @@ public: KviPointerList<T>(bool bAutoDelete = true) { m_bAutoDelete = bAutoDelete; - m_pHead = NULL; - m_pTail = NULL; + m_pHead = nullptr; + m_pTail = nullptr; m_uCount = 0; - m_pAux = NULL; + m_pAux = nullptr; }; /** diff --git a/src/kvilib/core/KviPtrListIterator.h b/src/kvilib/core/KviPtrListIterator.h index 6ef974bf4..247bb0268 100644 --- a/src/kvilib/core/KviPtrListIterator.h +++ b/src/kvilib/core/KviPtrListIterator.h @@ -51,7 +51,7 @@ public: return *this; } - inline bool operator!=(const KviPtrListIterator & other) const + bool operator!=(const KviPtrListIterator & other) const { return this->c != other.c; } diff --git a/src/kvilib/core/KviQString.cpp b/src/kvilib/core/KviQString.cpp index 387f5f9f5..56c33a142 100644 --- a/src/kvilib/core/KviQString.cpp +++ b/src/kvilib/core/KviQString.cpp @@ -31,8 +31,8 @@ #include "KviMemory.h" #include "KviLocale.h" -#include <ctype.h> // for tolower() -#include <stdio.h> // for sprintf() +#include <cctype> // for tolower() +#include <cstdio> // for sprintf() #include <QRegExp> // kvi_string.cpp @@ -1080,7 +1080,7 @@ namespace KviQString QChar * pPtr = (QChar *)szExp.constData(); if(!pPtr) - return 0; + return false; while(pPtr->unicode()) { @@ -1102,7 +1102,7 @@ namespace KviQString szWildcard = szExp; } - QRegExp re(szWildcard, bCs ? Qt::CaseSensitive : Qt::CaseInsensitive, bIsRegExp ? QRegExp::RegExp : QRegExp::Wildcard); + QRegExp re(szWildcard, bCs ? Qt::CaseSensitive : Qt::CaseInsensitive, bIsRegExp ? QRegExp::RegExp2 : QRegExp::Wildcard); if(bExact) return re.exactMatch(szStr); diff --git a/src/kvilib/core/KviShortcut.h b/src/kvilib/core/KviShortcut.h index 4f7b0eac3..4de4fd309 100644 --- a/src/kvilib/core/KviShortcut.h +++ b/src/kvilib/core/KviShortcut.h @@ -40,9 +40,9 @@ private: ~KviShortcut(); public: - static QShortcut * create(const char * key, QWidget * parent, const char * member = 0, const char * ambiguousMember = 0, Qt::ShortcutContext context = Qt::WindowShortcut); - static QShortcut * create(const QKeySequence & key, QWidget * parent, const char * member = 0, const char * ambiguousMember = 0, Qt::ShortcutContext context = Qt::WindowShortcut); - static void create(QKeySequence::StandardKey key, QWidget * parent, const char * member = 0, const char * ambiguousMember = 0, Qt::ShortcutContext context = Qt::WindowShortcut, KviPointerList<QShortcut> * pBufferList = nullptr); + static QShortcut * create(const char * key, QWidget * parent, const char * member = nullptr, const char * ambiguousMember = nullptr, Qt::ShortcutContext context = Qt::WindowShortcut); + static QShortcut * create(const QKeySequence & key, QWidget * parent, const char * member = nullptr, const char * ambiguousMember = nullptr, Qt::ShortcutContext context = Qt::WindowShortcut); + static void create(QKeySequence::StandardKey key, QWidget * parent, const char * member = nullptr, const char * ambiguousMember = nullptr, Qt::ShortcutContext context = Qt::WindowShortcut, KviPointerList<QShortcut> * pBufferList = nullptr); }; #endif //_KVI_SHORTCUT_CLASSFILE_H_ diff --git a/src/kvilib/ext/KviAnimatedPixmap.h b/src/kvilib/ext/KviAnimatedPixmap.h index 6b5a86a52..afbc5f3cf 100644 --- a/src/kvilib/ext/KviAnimatedPixmap.h +++ b/src/kvilib/ext/KviAnimatedPixmap.h @@ -93,7 +93,7 @@ public: * Returns true if animation is started. * Returns false otherways. */ - inline bool isStarted() + bool isStarted() const { return m_iStarted > 0; } @@ -112,7 +112,7 @@ public: * Returns true if animation has at least one loaded frame. * Returns false otherways. */ - inline bool isValid() + bool isValid() const { return (m_pFrameData->count() > 0); } @@ -122,7 +122,7 @@ public: * Never fails. */ - inline QPixmap * pixmap() + QPixmap * pixmap() { if(m_pFrameData->count() > 0) return m_pFrameData->at(m_uCurrentFrameNumber).pixmap; @@ -133,7 +133,7 @@ public: /* * Returns active frame number */ - inline uint activeFrameNumber() + uint activeFrameNumber() const { return m_uCurrentFrameNumber; } @@ -141,7 +141,7 @@ public: /* * Returns animation frame count */ - inline uint framesCount() + uint framesCount() const { return m_pFrameData->count(); } @@ -149,7 +149,7 @@ public: /* * Returns current image size */ - inline const QSize & size() + const QSize & size() const { return m_pFrameData->size; } diff --git a/src/kvilib/ext/KviConfigurationFile.cpp b/src/kvilib/ext/KviConfigurationFile.cpp index 8b75384a5..27dd54c49 100644 --- a/src/kvilib/ext/KviConfigurationFile.cpp +++ b/src/kvilib/ext/KviConfigurationFile.cpp @@ -32,6 +32,7 @@ #include <QColor> #include <QRect> +#include <QSaveFile> KviConfigurationFile::KviConfigurationFile(const QString & filename, FileMode f, bool bLocal8Bit) { @@ -335,20 +336,11 @@ bool KviConfigurationFile::load() return true; } -bool KviConfigurationFile::ensureWritable() +bool KviConfigurationFile::saveIfDirty() { - if(m_bReadOnly) - return false; - - KviFile f(m_szFileName); - if(!f.open(QFile::WriteOnly | QFile::Truncate)) - return false; - if(f.write("# KVIrc configuration file\n", 27) != 27) - return false; - if(!f.flush()) - return false; - f.close(); - return true; + if(!m_bDirty) + return true; + return save(); } bool KviConfigurationFile::save() @@ -409,9 +401,11 @@ bool KviConfigurationFile::save() if(m_bReadOnly) return false; - KviFile f(m_szFileName); + QSaveFile f(m_szFileName); + if(!f.open(QFile::WriteOnly | QFile::Truncate)) return false; + if(f.write("# KVIrc configuration file\n", 27) != 27) return false; @@ -454,7 +448,10 @@ bool KviConfigurationFile::save() } ++it; } - f.close(); + + if(!f.commit()) + return false; + m_bDirty = false; return true; } @@ -907,25 +904,3 @@ unsigned char KviConfigurationFile::readUCharEntry(const QString & szKey, unsign unsigned char iVal = (unsigned char)p_str->toUInt(&bOk); return bOk ? iVal : iDefault; } - -#ifdef COMPILE_ON_WINDOWS - -// -// On windows we need to override new and delete operators -// to ensure that always the right new/delete pair is called for an object instance -// This bug is present in all the classes exported by a module that -// can be instantiated/destroyed from external modules. -// (this is a well known bug described in Q122675 of MSDN) -// - -void * KviConfigurationFile::operator new(size_t tSize) -{ - return KviMemory::allocate(tSize); -} - -void KviConfigurationFile::operator delete(void * p) -{ - KviMemory::free(p); -} - -#endif diff --git a/src/kvilib/ext/KviConfigurationFile.h b/src/kvilib/ext/KviConfigurationFile.h index 06e625f61..b2264550d 100644 --- a/src/kvilib/ext/KviConfigurationFile.h +++ b/src/kvilib/ext/KviConfigurationFile.h @@ -93,7 +93,8 @@ public: bool readOnly() { return m_bReadOnly; }; void setReadOnly(bool bReadOnly) { m_bReadOnly = bReadOnly; }; bool dirty() { return m_bDirty; }; - bool ensureWritable(); + bool saveIfDirty(); + // // This sets the save path for the config file // In this way you can load a system-wide read-only config file @@ -160,15 +161,6 @@ public: static void getFontProperties(KviCString & buffer, QFont * fnt); static void setFontProperties(KviCString & str, QFont * fnt); -#ifdef COMPILE_ON_WINDOWS - // On windows we need to override new and delete operators - // to ensure that always the right new/delete pair is called for an object instance - // This bug is present in all the classes exported by a module that - // can be instantiated/destroyed from external modules. - // (this is a well known bug described in Q122675 of MSDN) - void * operator new(size_t tSize); - void operator delete(void * p); -#endif }; #endif //!_KVI_CONFIG_H_INCLUDED_ diff --git a/src/kvilib/ext/KviCryptEngine.h b/src/kvilib/ext/KviCryptEngine.h index 6539cf1b5..b442417aa 100644 --- a/src/kvilib/ext/KviCryptEngine.h +++ b/src/kvilib/ext/KviCryptEngine.h @@ -80,7 +80,7 @@ public: }; KviCryptEngine(); - virtual ~KviCryptEngine(); + ~KviCryptEngine(); #ifdef COMPILE_CRYPT_SUPPORT private: @@ -125,7 +125,7 @@ protected: // // The following two should have clear meaning // - void clearLastError() { m_szLastError = ""; } + void clearLastError() { setLastError(""); } void setLastError(const QString & err) { m_szLastError = err; } #endif //COMPILE_CRYPT_SUPPORT }; diff --git a/src/kvilib/ext/KviCryptEngineDescription.h b/src/kvilib/ext/KviCryptEngineDescription.h index 8347b20e6..692bdfa29 100644 --- a/src/kvilib/ext/KviCryptEngineDescription.h +++ b/src/kvilib/ext/KviCryptEngineDescription.h @@ -40,17 +40,17 @@ class KVILIB_API KviCryptEngineDescription : public KviHeapObject { public: - KviCryptEngineDescription(){} - virtual ~KviCryptEngineDescription(){} + KviCryptEngineDescription() = default; + virtual ~KviCryptEngineDescription() = default; public: - QString m_szName; /**< engine name */ - QString m_szDescription; /**< details */ - QString m_szAuthor; /**< algorithm author */ - int m_iFlags; /**< properties */ - crypt_engine_allocator_func m_allocFunc; /**< engine allocator */ - crypt_engine_deallocator_func m_deallocFunc; /**< deallocation function (if called from outside the origin module) */ - void * m_providerHandle; /**< used to identify the provider module */ + QString m_szName; /**< engine name */ + QString m_szDescription; /**< details */ + QString m_szAuthor; /**< algorithm author */ + int m_iFlags = 0; /**< properties */ + crypt_engine_allocator_func m_allocFunc = nullptr; /**< engine allocator */ + crypt_engine_deallocator_func m_deallocFunc = nullptr; /**< deallocation function (if called from outside the origin module) */ + void * m_providerHandle = nullptr; /**< used to identify the provider module */ }; #endif //COMPILE_CRYPT_SUPPORT diff --git a/src/kvilib/ext/KviDataBuffer.h b/src/kvilib/ext/KviDataBuffer.h index 52d02d160..137fa2527 100644 --- a/src/kvilib/ext/KviDataBuffer.h +++ b/src/kvilib/ext/KviDataBuffer.h @@ -33,7 +33,7 @@ public: // uSize MUST be greater than 0 // if data is non-zero, it MUST point to a buffer at least uSize bytes long // and the data is COPIED from that buffer! - KviDataBuffer(int uSize, const unsigned char * data = 0); + KviDataBuffer(int uSize, const unsigned char * data = nullptr); KviDataBuffer(); ~KviDataBuffer(); diff --git a/src/kvilib/ext/KviMediaType.h b/src/kvilib/ext/KviMediaType.h index c1cd3c2f5..cf0d791d3 100644 --- a/src/kvilib/ext/KviMediaType.h +++ b/src/kvilib/ext/KviMediaType.h @@ -37,14 +37,14 @@ // to KviMediaManager::lock() and KviMediaManager::unlock() // -typedef struct _KviDefaultMediaType +struct KviDefaultMediaType { const char * filemask; const char * magicbytes; const char * ianatype; const char * description; const char * commandline; -} KviDefaultMediaType; +}; class KVILIB_API KviMediaType : public KviHeapObject { diff --git a/src/kvilib/ext/KviNickColors.cpp b/src/kvilib/ext/KviNickColors.cpp index 974252d1d..fdbe2bcf8 100644 --- a/src/kvilib/ext/KviNickColors.cpp +++ b/src/kvilib/ext/KviNickColors.cpp @@ -25,17 +25,15 @@ #include "KviNickColors.h" #include "KviMemory.h" -#include <stdio.h> +#include <cstdio> #include <QString> namespace KviNickColors { - -#define KVI_NUM_NICK_COLORS 95 - // FIXME: Maybe make this table settable via options? // Or maybe a kvc file... - static const char * g_nickColors[KVI_NUM_NICK_COLORS] = { + static const int g_numNickColors = 95; + static const char * g_nickColors[g_numNickColors] = { "0,1", "0,2", "0,3", "0,4", "0,5", "0,6", "0,10", "0,12", "0,14", //9 "1,0", "1,4", "1,7", "1,8", "1,9", "1,11", "1,15", //7 "2,0", "2,4", "2,7", "2,8", "2,9", "2,11", "2,15", //7 @@ -53,6 +51,10 @@ namespace KviNickColors "14,0", "14,8", "14,11", "14,15", //4 "15,1", "15,2", "15,3", "15,6", "15,14" //5 }; + static const int g_numNickColorsNoBg = 8; + static const char * g_nickColorsNoBg[g_numNickColorsNoBg] = { + "2", "3", "4", "5", "6", "7", "10", "12" //8 + }; int getSmartColorForNick(QString * szNick) { @@ -69,9 +71,12 @@ namespace KviNickColors return sum; } - const char * getSmartColor(int iPos) + const char * getSmartColor(int iPos, bool bWithBg) { - return g_nickColors[iPos % KVI_NUM_NICK_COLORS]; + if(bWithBg) + return g_nickColors[iPos % g_numNickColors]; + else + return g_nickColorsNoBg[iPos % g_numNickColorsNoBg]; } int getSmartColorIntByMircColor(unsigned char iFore, unsigned char iBack) @@ -86,7 +91,7 @@ namespace KviNickColors snprintf(comb, 6, "%d,%d", iFore % 16, iBack % 16); #endif // qDebug("Nick color %s",comb); - for(int i = 0; i < KVI_NUM_NICK_COLORS; ++i) + for(int i = 0; i < g_numNickColors; ++i) { int numc = 0; // strcmp diff --git a/src/kvilib/ext/KviNickColors.h b/src/kvilib/ext/KviNickColors.h index f4fdf89ea..b29d0891c 100644 --- a/src/kvilib/ext/KviNickColors.h +++ b/src/kvilib/ext/KviNickColors.h @@ -32,7 +32,7 @@ namespace KviNickColors { extern KVILIB_API int getSmartColorForNick(QString * szNick); - extern KVILIB_API const char * getSmartColor(int iPos); + extern KVILIB_API const char * getSmartColor(int iPos, bool bWithBg); extern KVILIB_API int getSmartColorIntByMircColor(unsigned char iFore, unsigned char iBack); } diff --git a/src/kvilib/ext/KviOggTheoraDecoder.cpp b/src/kvilib/ext/KviOggTheoraDecoder.cpp index 116477e43..82e1a047d 100644 --- a/src/kvilib/ext/KviOggTheoraDecoder.cpp +++ b/src/kvilib/ext/KviOggTheoraDecoder.cpp @@ -55,7 +55,7 @@ KviOggTheoraDecoder::KviOggTheoraDecoder(KviDataBuffer * videoSignal, KviDataBuf m_pTextSignal = textSignal; theora_p = 0; stateflag = 0; - ts = NULL; + ts = nullptr; thda = false; thtic = false; @@ -249,7 +249,7 @@ void KviOggTheoraDecoder::addData(KviDataBuffer * stream) { if(ogg_stream_packetout(&zo, &op) > 0) { - char * textPkt = 0; + char * textPkt = nullptr; int textSize = 0; if(irct_decode_packetin(&textPkt, &textSize, &op) == 0) { diff --git a/src/kvilib/ext/KviOggTheoraEncoder.cpp b/src/kvilib/ext/KviOggTheoraEncoder.cpp index ca0ced24d..e36685891 100644 --- a/src/kvilib/ext/KviOggTheoraEncoder.cpp +++ b/src/kvilib/ext/KviOggTheoraEncoder.cpp @@ -88,7 +88,7 @@ KviOggTheoraEncoder::KviOggTheoraEncoder(KviDataBuffer * stream, int iWidth, int y4m_dst_buf_sz = geometry.pic_w * geometry.pic_h * 3; // Set up Ogg output stream - srand(time(NULL)); + srand(time(nullptr)); ogg_stream_init(&to, rand()); ogg_stream_init(&zo, rand()); diff --git a/src/kvilib/ext/KviOggTheoraGeometry.h b/src/kvilib/ext/KviOggTheoraGeometry.h index b31b0d95c..5b8319375 100644 --- a/src/kvilib/ext/KviOggTheoraGeometry.h +++ b/src/kvilib/ext/KviOggTheoraGeometry.h @@ -36,7 +36,7 @@ * \typedef KviOggTheoraGeometry * \brief Contains all the needed geometry information of a theora video stream */ -typedef struct _KviOggTheoraGeometry +struct KviOggTheoraGeometry { int pic_w; /**< width of original picture geometry, chosen by the user */ int pic_h; /**< height of original picture geometry, chosen by the user */ @@ -46,7 +46,7 @@ typedef struct _KviOggTheoraGeometry int pic_x; /**< x offset of the picture inside the frame (calculated geometry) */ int pic_y; /**< y offset of the picture inside the frame (calculated geometry) */ -} KviOggTheoraGeometry; +}; #endif // COMPILE_DISABLE_OGG_THEORA #endif // _KVIOGGTHEORAGEOMETRY_H_ diff --git a/src/kvilib/ext/KviPixmap.cpp b/src/kvilib/ext/KviPixmap.cpp index a16ecaf25..6e8aaebec 100644 --- a/src/kvilib/ext/KviPixmap.cpp +++ b/src/kvilib/ext/KviPixmap.cpp @@ -27,6 +27,7 @@ #include "KviQString.h" #include <QString> +#include <memory> KviPixmap::KviPixmap() = default; @@ -55,7 +56,7 @@ bool KviPixmap::load(const QString & path) return false; } - m_pPix.reset(new QPixmap(path)); + m_pPix = std::make_unique<QPixmap>(path); if(m_pPix->isNull()) { @@ -76,7 +77,7 @@ void KviPixmap::set(const QPixmap & pix, const QString & szPath) return; } - m_pPix.reset(new QPixmap(pix)); + m_pPix = std::make_unique<QPixmap>(pix); m_szPath = szPath; } @@ -96,7 +97,7 @@ KviPixmap & KviPixmap::operator=(const KviPixmap & pix) if(!pix.path().isEmpty() && !pix.isNull()) { m_szPath = pix.path(); - m_pPix.reset(new QPixmap(*(pix.pixmap()))); + m_pPix = std::make_unique<QPixmap>(*(pix.pixmap())); } else setNull(); diff --git a/src/kvilib/ext/KviRegisteredUserDataBase.cpp b/src/kvilib/ext/KviRegisteredUserDataBase.cpp index cabe06fde..8b2e6f5a6 100644 --- a/src/kvilib/ext/KviRegisteredUserDataBase.cpp +++ b/src/kvilib/ext/KviRegisteredUserDataBase.cpp @@ -349,13 +349,13 @@ bool KviRegisteredUserDataBase::removeMask(const KviIrcMask & mask) return true; } } - return 0; + return false; } bool KviRegisteredUserDataBase::removeMaskByPointer(KviIrcMask * mask) { if(!mask) - return 0; + return false; if(mask->hasWildNick()) { // remove from the wild list diff --git a/src/kvilib/ext/KviRuntimeInfo.cpp b/src/kvilib/ext/KviRuntimeInfo.cpp index c75e2b13d..86dcfaf43 100644 --- a/src/kvilib/ext/KviRuntimeInfo.cpp +++ b/src/kvilib/ext/KviRuntimeInfo.cpp @@ -32,7 +32,7 @@ #if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW) #include <sys/utsname.h> -#include <stdlib.h> +#include <cstdlib> #include <unistd.h> #endif @@ -50,7 +50,7 @@ typedef BOOL(WINAPI * PGETPRODUCTINFO)(DWORD, DWORD, DWORD, DWORD, PDWORD); #define BUFSIZE 1024 -// stolen from WinNT.h (last updated from 10.0.10240.0 SDK) +// stolen from WinNT.h (last updated from 10.0.17763.0 SDK) // // Product types // This list grows with each OS release. @@ -63,10 +63,7 @@ typedef BOOL(WINAPI * PGETPRODUCTINFO)(DWORD, DWORD, DWORD, DWORD, PDWORD); // When a product-type 'X' gets dropped from a // OS release onwards, the value of 'X' continues // to be used in the mapping table of GetProductInfo. -// MSDN: If the product has not been activated and is no longer in -// the grace period, this parameter is set to -// PRODUCT_UNLICENSED (0xABCDABCD). - +// // clang-format off #define PRODUCT_UNDEFINED 0x00000000 @@ -163,7 +160,6 @@ typedef BOOL(WINAPI * PGETPRODUCTINFO)(DWORD, DWORD, DWORD, DWORD, PDWORD); #define PRODUCT_CORE_SINGLELANGUAGE 0x00000064 #define PRODUCT_CORE 0x00000065 #define PRODUCT_PROFESSIONAL_WMC 0x00000067 -#define PRODUCT_MOBILE_CORE 0x00000068 #define PRODUCT_EMBEDDED_INDUSTRY_EVAL 0x00000069 #define PRODUCT_EMBEDDED_INDUSTRY_E_EVAL 0x0000006A #define PRODUCT_EMBEDDED_EVAL 0x0000006B @@ -190,6 +186,37 @@ typedef BOOL(WINAPI * PGETPRODUCTINFO)(DWORD, DWORD, DWORD, DWORD, PDWORD); #define PRODUCT_PROFESSIONAL_S_N 0x00000080 #define PRODUCT_ENTERPRISE_S_EVALUATION 0x00000081 #define PRODUCT_ENTERPRISE_S_N_EVALUATION 0x00000082 +#define PRODUCT_HOLOGRAPHIC 0x00000087 +#define PRODUCT_PRO_SINGLE_LANGUAGE 0x0000008A +#define PRODUCT_PRO_CHINA 0x0000008B +#define PRODUCT_ENTERPRISE_SUBSCRIPTION 0x0000008C +#define PRODUCT_ENTERPRISE_SUBSCRIPTION_N 0x0000008D +#define PRODUCT_DATACENTER_NANO_SERVER 0x0000008F +#define PRODUCT_STANDARD_NANO_SERVER 0x00000090 +#define PRODUCT_DATACENTER_A_SERVER_CORE 0x00000091 +#define PRODUCT_STANDARD_A_SERVER_CORE 0x00000092 +#define PRODUCT_DATACENTER_WS_SERVER_CORE 0x00000093 +#define PRODUCT_STANDARD_WS_SERVER_CORE 0x00000094 +#define PRODUCT_UTILITY_VM 0x00000095 +#define PRODUCT_DATACENTER_EVALUATION_SERVER_CORE 0x0000009F +#define PRODUCT_STANDARD_EVALUATION_SERVER_CORE 0x000000A0 +#define PRODUCT_PRO_WORKSTATION 0x000000A1 +#define PRODUCT_PRO_WORKSTATION_N 0x000000A2 +#define PRODUCT_PRO_FOR_EDUCATION 0x000000A4 +#define PRODUCT_PRO_FOR_EDUCATION_N 0x000000A5 +#define PRODUCT_AZURE_SERVER_CORE 0x000000A8 +#define PRODUCT_AZURE_NANO_SERVER 0x000000A9 +#define PRODUCT_ENTERPRISEG 0x000000AB +#define PRODUCT_ENTERPRISEGN 0x000000AC +#define PRODUCT_SERVERRDSH 0x000000AF +#define PRODUCT_CLOUD 0x000000B2 +#define PRODUCT_CLOUDN 0x000000B3 +#define PRODUCT_HUBOS 0x000000B4 +#define PRODUCT_ONECOREUPDATEOS 0x000000B6 +#define PRODUCT_CLOUDE 0x000000B7 +#define PRODUCT_ANDROMEDA 0x000000B8 +#define PRODUCT_IOTOS 0x000000B9 +#define PRODUCT_CLOUDEN 0x000000BA #define PRODUCT_UNLICENSED 0xABCDABCD // clang-format on @@ -222,7 +249,7 @@ static QString queryWinInfo(QueryInfo info) pGNSI = (PGNSI)GetProcAddress( GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo"); - if(NULL != pGNSI) + if(nullptr != pGNSI) pGNSI(&si); else GetSystemInfo(&si); @@ -238,8 +265,14 @@ static QString queryWinInfo(QueryInfo info) { if(osvi.wProductType == VER_NT_WORKSTATION) szVersion += "Windows 10 "; - else - szVersion += "Windows Server 2016"; + else if(osvi.wProductType == VER_NT_SERVER || osvi.wProductType == VER_NT_DOMAIN_CONTROLLER ) + szVersion += "Windows Server "; + if(osvi.dwBuildNumber <= 14393) + szVersion += "2016 "; + else if(osvi.dwBuildNumber <= 17763) + szVersion += "2019 "; + else + szVersion += "vNext "; } if(osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 3) @@ -247,7 +280,7 @@ static QString queryWinInfo(QueryInfo info) if(osvi.wProductType == VER_NT_WORKSTATION) szVersion += "Windows 8.1 "; else - szVersion += "Windows Server 2012 R2"; + szVersion += "Windows Server 2012 R2 "; } if(osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 2) @@ -266,40 +299,17 @@ static QString queryWinInfo(QueryInfo info) szVersion += "Windows Server 2008 R2 "; } - if(osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) - { - if(osvi.wProductType == VER_NT_WORKSTATION) - szVersion += "Windows Vista "; - else - szVersion += "Windows Server 2008 "; - } - - if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) - { - if(GetSystemMetrics(SM_SERVERR2)) - szVersion += "Windows Server 2003 \"R2\" "; - else if(osvi.wProductType == VER_NT_WORKSTATION && si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) - { - szVersion += "Windows XP Professional x64 "; - } - else - szVersion += "Windows Server 2003, "; - } - - if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) - szVersion += "Windows XP "; - PGETPRODUCTINFO pGetProductInfo; pGetProductInfo = (PGETPRODUCTINFO)GetProcAddress( GetModuleHandle(TEXT("kernel32.dll")), "GetProductInfo"); - // from MSDN, Document Date 9/7/2012 - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms724358 + // from MSDN, Document Date 12/05/2018 + // https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-getproductinfo // the entire PRODUCT_CORE group has the base Windows version in the // returned value. rip out "Windows" of all PRODUCT values as well if(bOsVersionInfoEx) { DWORD dwPlatformInfo; - if(NULL != pGetProductInfo) + if(nullptr != pGetProductInfo) if(pGetProductInfo(osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.wServicePackMajor, osvi.wServicePackMinor, &dwPlatformInfo)) { @@ -318,20 +328,26 @@ static QString queryWinInfo(QueryInfo info) szVersion += "Server Hyper Core V"; break; case PRODUCT_CORE: - //szVersion+="Windows 8"; - break; - case PRODUCT_CORE_N: - szVersion += "N"; + //szVersion+="10 Home"; break; case PRODUCT_CORE_COUNTRYSPECIFIC: szVersion += "China"; break; + case PRODUCT_CORE_N: + szVersion += "N"; + break; case PRODUCT_CORE_SINGLELANGUAGE: szVersion += "Single Language"; break; case PRODUCT_DATACENTER_EVALUATION_SERVER: szVersion += "Server Datacenter (evaluation installation)"; break; + case PRODUCT_DATACENTER_A_SERVER_CORE: + szVersion += "Server Datacenter, Semi-Annual Channel (core installation)"; + break; + case PRODUCT_STANDARD_A_SERVER_CORE: + szVersion += "Server Standard, Semi-Annual Channel (core installation)"; + break; case PRODUCT_DATACENTER_SERVER: szVersion += "Server Datacenter (full installation)"; break; @@ -344,20 +360,38 @@ static QString queryWinInfo(QueryInfo info) case PRODUCT_DATACENTER_SERVER_V: szVersion += "Server Datacenter without Hyper-V (full installation)"; break; + case PRODUCT_EDUCATION: + szVersion += "Education"; + break; + case PRODUCT_EDUCATION_N: + szVersion += "Education N"; + break; case PRODUCT_ENTERPRISE: szVersion += "Enterprise"; break; case PRODUCT_ENTERPRISE_E: - //szVersion+="Not supported"; + szVersion+= "Enterprise E"; break; - case PRODUCT_ENTERPRISE_N_EVALUATION: - szVersion += "Enterprise N (evaluation installation)"; + case PRODUCT_ENTERPRISE_EVALUATION: + szVersion += "Enterprise Evaluation"; break; case PRODUCT_ENTERPRISE_N: szVersion += "Enterprise N"; break; - case PRODUCT_ENTERPRISE_EVALUATION: - szVersion += "Server Enterprise (evaluation installation)"; + case PRODUCT_ENTERPRISE_N_EVALUATION: + szVersion += "Enterprise N (evaluation installation)"; + break; + case PRODUCT_ENTERPRISE_S: + szVersion+= "Enterprise 2015 LTSB"; + break; + case PRODUCT_ENTERPRISE_S_EVALUATION: + szVersion += "Enterprise 2015 LTSB Evaluation"; + break; + case PRODUCT_ENTERPRISE_S_N: + szVersion += "Windows 10 Enterprise 2015 LTSB N"; + break; + case PRODUCT_ENTERPRISE_S_N_EVALUATION: + szVersion += "Windows 10 Enterprise 2015 LTSB N Evaluation"; break; case PRODUCT_ENTERPRISE_SERVER: szVersion += "Server Enterprise (full installation)"; @@ -374,18 +408,18 @@ static QString queryWinInfo(QueryInfo info) case PRODUCT_ENTERPRISE_SERVER_V: szVersion += "Server Enterprise without Hyper-V (full installation)"; break; - case PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT: - szVersion += "Essential Server Solution Management"; - break; case PRODUCT_ESSENTIALBUSINESS_SERVER_ADDL: szVersion += "Essential Server Solution Additional"; break; - case PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC: - szVersion += "Essential Server Solution Management SVC"; - break; case PRODUCT_ESSENTIALBUSINESS_SERVER_ADDLSVC: szVersion += "Essential Server Solution Additional SVC"; break; + case PRODUCT_ESSENTIALBUSINESS_SERVER_MGMT: + szVersion += "Essential Server Solution Management"; + break; + case PRODUCT_ESSENTIALBUSINESS_SERVER_MGMTSVC: + szVersion += "Essential Server Solution Management SVC"; + break; case PRODUCT_HOME_BASIC: szVersion += "Home Basic"; break; @@ -413,6 +447,12 @@ static QString queryWinInfo(QueryInfo info) case PRODUCT_HYPERV: szVersion += "Hyper-V Server"; break; + case PRODUCT_IOTUAP: + szVersion += "IoT Core"; + break; + //case PRODUCT_IOTUAPCOMMERCIAL: + //szVersion += "IoT Core Commercial"; + //break; case PRODUCT_MEDIUMBUSINESS_SERVER_MANAGEMENT: szVersion += "Essential Business Server Management Server"; break; @@ -422,24 +462,39 @@ static QString queryWinInfo(QueryInfo info) case PRODUCT_MEDIUMBUSINESS_SERVER_SECURITY: szVersion += "Essential Business Server Security Server"; break; + //case PRODUCT_MOBILE_CORE: + //szVersion += "Mobile"; + //break; + //case PRODUCT_MOBILE_ENTERPRISE: + //szVersion += "Mobile Enterprise"; + //break; + case PRODUCT_MULTIPOINT_PREMIUM_SERVER: + szVersion += "MultiPoint Server Premium (full installation)"; + break; case PRODUCT_MULTIPOINT_STANDARD_SERVER: szVersion += "MultiPoint Server Standard (full installation)"; break; - case PRODUCT_MULTIPOINT_PREMIUM_SERVER: - szVersion += "MultiPoint Server Premium (full installation)"; + case PRODUCT_PRO_WORKSTATION: + szVersion += "Pro for Workstations"; + break; + case PRODUCT_PRO_WORKSTATION_N: + szVersion += "Pro for Workstations N"; break; case PRODUCT_PROFESSIONAL: - szVersion += "Professional"; + szVersion += "Pro"; break; case PRODUCT_PROFESSIONAL_E: //szVersion+="Not supported"; break; case PRODUCT_PROFESSIONAL_N: - szVersion += "Professional N"; + szVersion += "Pro N"; break; case PRODUCT_PROFESSIONAL_WMC: szVersion += "Professional with Media Center"; break; + case PRODUCT_SB_SOLUTION_SERVER: + szVersion += "Small Business Server 2011 Essentials"; + break; case PRODUCT_SB_SOLUTION_SERVER_EM: szVersion += "Server For SB Solutions EM"; break; @@ -458,9 +513,6 @@ static QString queryWinInfo(QueryInfo info) case PRODUCT_SERVER_FOUNDATION: szVersion += "Server Foundation"; break; - case PRODUCT_SB_SOLUTION_SERVER: - szVersion += "Small Business Server 2011 Essentials"; - break; case PRODUCT_SMALLBUSINESS_SERVER: szVersion += "Small Business Server"; break; @@ -533,13 +585,6 @@ static QString queryWinInfo(QueryInfo info) case PRODUCT_STORAGE_WORKGROUP_SERVER_CORE: szVersion += "Storage Server Workgroup (core installation)"; break; - case PRODUCT_UNDEFINED: - szVersion += "An unknown product"; - break; - // just use unknown here since we do not care. - case PRODUCT_UNLICENSED: - szVersion += "An unknown product"; - break; case PRODUCT_ULTIMATE: szVersion += "Ultimate"; break; @@ -549,6 +594,13 @@ static QString queryWinInfo(QueryInfo info) case PRODUCT_ULTIMATE_N: szVersion += "Ultimate N"; break; + case PRODUCT_UNDEFINED: + szVersion += "An unknown product"; + break; + // just use unknown here since we do not care. + case PRODUCT_UNLICENSED: + szVersion += "An unknown product"; + break; case PRODUCT_WEB_SERVER: szVersion += "Web Server (full installation)"; break; @@ -562,55 +614,6 @@ static QString queryWinInfo(QueryInfo info) szVersion += "(x64) "; } } - else - { - // Test for the workstation type, for XP 32 bit - if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1) - { - if(osvi.wProductType == VER_NT_WORKSTATION) - { - if(osvi.wSuiteMask & VER_SUITE_PERSONAL) - szVersion += "Home Edition "; - else - szVersion += "Professional "; - } - } - // Test for the server type. - else if(osvi.wProductType == VER_NT_SERVER || osvi.wProductType == VER_NT_DOMAIN_CONTROLLER) - { - if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2) - { - if(si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) - { - if(osvi.wSuiteMask & VER_SUITE_DATACENTER) - szVersion += "Datacenter Edition for Itanium-based Systems"; - else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE) - szVersion += "Enterprise Edition for Itanium-based Systems"; - } - - else if(si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) - { - if(osvi.wSuiteMask & VER_SUITE_DATACENTER) - szVersion += "Datacenter x64 Edition "; - else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE) - szVersion += "Enterprise x64 Edition "; - else - szVersion += "Standard x64 Edition "; - } - else - { - if(osvi.wSuiteMask & VER_SUITE_DATACENTER) - szVersion += "Datacenter Edition "; - else if(osvi.wSuiteMask & VER_SUITE_ENTERPRISE) - szVersion += "Enterprise Edition "; - else if(osvi.wSuiteMask == VER_SUITE_BLADE) - szVersion += "Web Edition "; - else - szVersion += "Standard Edition "; - } - } - } - } } // Display service pack (if any) and build number. szVersion += QString("%1 (Build %2)").arg(QString::fromWCharArray(osvi.szCSDVersion)).arg(osvi.dwBuildNumber & 0xFFFF); @@ -732,6 +735,9 @@ namespace KviRuntimeInfo QString qtTheme() { - return QString(qApp->style()->objectName()); + static QString theme{qApp->style()->objectName().isEmpty() ? + __tr2qs("Overridden with a stylesheet") : + qApp->style()->objectName()}; + return theme; } } diff --git a/src/kvilib/ext/KviStringConversion.cpp b/src/kvilib/ext/KviStringConversion.cpp index 5bb63f0f0..21e571fd6 100644 --- a/src/kvilib/ext/KviStringConversion.cpp +++ b/src/kvilib/ext/KviStringConversion.cpp @@ -34,7 +34,7 @@ #include <QRect> #include <QString> #include <QStringList> -#include <stdio.h> +#include <cstdio> QString g_szGlobalDir; QString g_szLocalDir; diff --git a/src/kvilib/file/KviFileUtils.cpp b/src/kvilib/file/KviFileUtils.cpp index 8a0d60519..283bdc501 100644 --- a/src/kvilib/file/KviFileUtils.cpp +++ b/src/kvilib/file/KviFileUtils.cpp @@ -200,7 +200,7 @@ namespace KviFileUtils QFileInfoList lFileInfo = d.entryInfoList(QDir::Files | QDir::Dirs | QDir::Hidden | QDir::System | QDir::NoDotAndDotDot); - foreach(QFileInfo inf, lFileInfo) + for(const auto & inf : lFileInfo) { // just to be sure check that we're not deleting .. if(KviQString::equalCS(inf.fileName(), "..") || KviQString::equalCS(inf.fileName(), ".")) @@ -247,8 +247,6 @@ namespace KviFileUtils if(!f.open(QFile::WriteOnly | (bAppend ? QFile::Append : QFile::Truncate))) return false; QByteArray szTmp = szData.toUtf8(); - if(!szTmp.data()) - return true; if(f.write(szTmp.data(), szTmp.length()) != ((unsigned int)(szTmp.length()))) return false; return true; @@ -266,8 +264,6 @@ namespace KviFileUtils if(!f.open(QFile::WriteOnly | (bAppend ? QFile::Append : QFile::Truncate))) return false; QByteArray szTmp = QTextCodec::codecForLocale()->fromUnicode(szData); - if(!szTmp.data()) - return true; if(f.write(szTmp.data(), szTmp.length()) != ((unsigned int)(szTmp.length()))) return false; return true; @@ -452,7 +448,7 @@ namespace KviFileUtils QFileInfoList fl = d.entryInfoList(QStringList(), QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name); - Q_FOREACH(QFileInfo inf, fl) + for(const auto & inf : fl) { QString szName = szPrefix.isEmpty() ? inf.fileName() : QString("%1" KVI_PATH_SEPARATOR "%2").arg(szPrefix).arg(inf.fileName()); if(inf.isDir()) diff --git a/src/kvilib/file/KviPackageIOEngine.h b/src/kvilib/file/KviPackageIOEngine.h index d45e6366a..83cc5f1a0 100644 --- a/src/kvilib/file/KviPackageIOEngine.h +++ b/src/kvilib/file/KviPackageIOEngine.h @@ -68,7 +68,7 @@ private: KviPointerHashTable<QString, QString> * m_pStringInfoFields; KviPointerHashTable<QString, QByteArray> * m_pBinaryInfoFields; QProgressDialog * m_pProgressDialog; - QLabel * m_pProgressDialogLabel; + QLabel * m_pProgressDialogLabel = nullptr; public: /** diff --git a/src/kvilib/irc/KviAvatar.h b/src/kvilib/irc/KviAvatar.h index 17d78ad57..26fc1fe3a 100644 --- a/src/kvilib/irc/KviAvatar.h +++ b/src/kvilib/irc/KviAvatar.h @@ -82,13 +82,13 @@ public: * \brief Returns true, if avatar is remote. * \return bool */ - inline bool isRemote() { return m_bRemote; } + bool isRemote() const { return m_bRemote; } /** * \brief Returns filepath * \return const QString & */ - inline const QString & localPath() { return m_szLocalPath; } + const QString & localPath() const { return m_szLocalPath; } /** * \brief Returns fiename. @@ -96,25 +96,25 @@ public: * For remote avatars, remote address will be returned. * \return const QString & */ - inline const QString & name() { return m_szName; } + const QString & name() const { return m_szName; } /** * \brief Returns true, if underlying pixmap contains more then one frame. * \return bool */ - inline bool isAnimated() { return (m_pPixmap->framesCount() > 1); } + bool isAnimated() const { return (m_pPixmap->framesCount() > 1); } /** * \brief Returns original pixmap's size * \return const QSize & */ - inline const QSize & size() { return m_pPixmap->size(); } + const QSize & size() const { return m_pPixmap->size(); } /** * \brief Returns unscaled original frame. * \return QPixmap * */ - inline QPixmap * pixmap() { return m_pPixmap->pixmap(); } + QPixmap * pixmap() const { return m_pPixmap->pixmap(); } /** * \brief Returns true if pixmap has at least one loaded frame. @@ -122,13 +122,13 @@ public: * Returns false otherwise. * \return bool */ - inline bool isValid() { return m_pPixmap->isValid(); } + bool isValid() const { return m_pPixmap->isValid(); } /** * \brief Returns original animated pixmap. * \return KviAnimatedPixmap * */ - inline KviAnimatedPixmap * animatedPixmap() { return m_pPixmap; } + KviAnimatedPixmap * animatedPixmap() const { return m_pPixmap; } /** * \brief Returns animated pixmap, scaled to the requisted size. @@ -161,7 +161,7 @@ public: * \param uHeight The height of the avatar * \return KviAnimatedPixmap * */ - inline KviAnimatedPixmap * forSize(unsigned int uWidth, unsigned int uHeight) { return forSize(QSize(uWidth, uHeight)); } + KviAnimatedPixmap * forSize(unsigned int uWidth, unsigned int uHeight) { return forSize(QSize(uWidth, uHeight)); } /** * \brief Returns the string that uniquely identifies this avatar. diff --git a/src/kvilib/irc/KviAvatarCache.h b/src/kvilib/irc/KviAvatarCache.h index 9bc17e792..276f9f027 100644 --- a/src/kvilib/irc/KviAvatarCache.h +++ b/src/kvilib/irc/KviAvatarCache.h @@ -43,11 +43,11 @@ class KviIrcMask; * \struct _KviAvatarCacheEntry * \brief Defines a struct for the avatar entry in the cache */ -typedef struct _KviAvatarCacheEntry +struct KviAvatarCacheEntry { QString szIdString; /**< The id of the avatar */ kvi_time_t tLastAccess; /**< The time the avatar was last accessed */ -} KviAvatarCacheEntry; +}; /** * \class KviAvatarCache diff --git a/src/kvilib/irc/KviControlCodes.cpp b/src/kvilib/irc/KviControlCodes.cpp index 3f49652b5..30d20963d 100644 --- a/src/kvilib/irc/KviControlCodes.cpp +++ b/src/kvilib/irc/KviControlCodes.cpp @@ -191,7 +191,7 @@ namespace KviControlCodes if((c >= '0') && (c <= '9')) { - (*pcByte1) = (((*pcByte1) * 10) + (c - '0')) % 16; + (*pcByte1) = (((*pcByte1) * 10) + (c - '0')); iChar++; if(iChar >= (unsigned int)szData.length()) { @@ -235,7 +235,7 @@ namespace KviControlCodes if((c >= '0') && (c <= '9')) { - (*pcByte2) = (((*pcByte2) * 10) + (c - '0')) % 16; + (*pcByte2) = (((*pcByte2) * 10) + (c - '0')); iChar++; } @@ -265,7 +265,7 @@ namespace KviControlCodes pcData++; } else { //A number - (*pcByte1)=((((*pcByte1)*10)+((*pcData)-'0'))%16); + (*pcByte1)=((((*pcByte1)*10)+((*pcData)-'0'))); pcData++; if(*pcData==',') { @@ -296,7 +296,7 @@ namespace KviControlCodes pcData++; if((*pcData >= '0') && (*pcData <='9')) { - (*pcByte2)=((((*pcByte2)*10)+((*pcData)-'0'))%16); + (*pcByte2)=((((*pcByte2)*10)+((*pcData)-'0'))); pcData++; } return pcData; @@ -306,4 +306,102 @@ namespace KviControlCodes } } #endif + + // Get extended (16-98) mIRC color. + // Unlike the 0-15 ones, these are not configurable. + // https://modern.ircdocs.horse/formatting.html#colors-16-98 + // Returns (kvi_u32_t)-1 if index is out of bounds. + kvi_u32_t getExtendedColor(int index) + { + const int minColor = KVI_MIRCCOLOR_MAX + 1; // 16 + const int maxColor = KVI_EXTCOLOR_MAX; + static const kvi_u32_t colors[maxColor - minColor + 1] = { + 0x470000, + 0x472100, + 0x474700, + 0x324700, + 0x004700, + 0x00472c, + 0x004747, + 0x002747, + 0x000047, + 0x2e0047, + 0x470047, + 0x47002a, + 0x740000, + 0x743a00, + 0x747400, + 0x517400, + 0x007400, + 0x007449, + 0x007474, + 0x004074, + 0x000074, + 0x4b0074, + 0x740074, + 0x740045, + 0xb50000, + 0xb56300, + 0xb5b500, + 0x7db500, + 0x00b500, + 0x00b571, + 0x00b5b5, + 0x0063b5, + 0x0000b5, + 0x7500b5, + 0xb500b5, + 0xb5006b, + 0xff0000, + 0xff8c00, + 0xffff00, + 0xb2ff00, + 0x00ff00, + 0x00ffa0, + 0x00ffff, + 0x008cff, + 0x0000ff, + 0xa500ff, + 0xff00ff, + 0xff0098, + 0xff5959, + 0xffb459, + 0xffff71, + 0xcfff60, + 0x6fff6f, + 0x65ffc9, + 0x6dffff, + 0x59b4ff, + 0x5959ff, + 0xc459ff, + 0xff66ff, + 0xff59bc, + 0xff9c9c, + 0xffd39c, + 0xffff9c, + 0xe2ff9c, + 0x9cff9c, + 0x9cffdb, + 0x9cffff, + 0x9cd3ff, + 0x9c9cff, + 0xdc9cff, + 0xff9cff, + 0xff94d3, + 0x000000, + 0x131313, + 0x282828, + 0x363636, + 0x4d4d4d, + 0x656565, + 0x818181, + 0x9f9f9f, + 0xbcbcbc, + 0xe2e2e2, + 0xffffff, + }; + if (index < minColor || index > maxColor) + return (kvi_u32_t)-1; + return colors[index - minColor]; + } } diff --git a/src/kvilib/irc/KviControlCodes.h b/src/kvilib/irc/KviControlCodes.h index 5fac61076..fa0305471 100644 --- a/src/kvilib/irc/KviControlCodes.h +++ b/src/kvilib/irc/KviControlCodes.h @@ -42,8 +42,8 @@ #include "kvi_settings.h" #include "KviCString.h" -#define KVI_MIRCCOLOR_MAX_FOREGROUND 15 -#define KVI_MIRCCOLOR_MAX_BACKGROUND 15 +#define KVI_MIRCCOLOR_MAX 15 +#define KVI_EXTCOLOR_MAX 98 // ASCII Stuff: the following defines are meant to be escape sequences // that can go through an IRC connection @@ -155,6 +155,7 @@ namespace KviControlCodes Escape = 0x04, /**< Escape, totally artificial and internal to KviIrcView */ UnEscape = 0x05, /**< Unescape, totally artificial and internal to KviIrcView */ UnIcon = 0x06, /**< Unicon, totally artificial and internal to KviIrcView */ + ArbitraryBreak = UnIcon, /**< Arbitrary block break, totally artificial and internal to KviIrcView */ Reset = 0x0f, /**< Reset */ Reverse = 0x16, /**< Reverse */ Icon = 0x1c, /**< Icon, KVIrc control code */ @@ -178,6 +179,8 @@ namespace KviControlCodes inline const QChar * getUnicodeColorBytes(const QChar * pData, unsigned char * pcByte1, unsigned char * pcByte2) { return (QChar *)getColorBytesW((const kvi_wchar_t *)pData,pcByte1,pcByte2); } #endif + + KVILIB_API kvi_u32_t getExtendedColor(int index); } #endif //_KVI_CONTROLCODES_H_ diff --git a/src/kvilib/irc/KviIrcMask.cpp b/src/kvilib/irc/KviIrcMask.cpp index ddc79c720..47af63d94 100644 --- a/src/kvilib/irc/KviIrcMask.cpp +++ b/src/kvilib/irc/KviIrcMask.cpp @@ -55,12 +55,12 @@ this is rather server specific protocol, but the prefixes are somewhat standardized and the common meanings of them are:[br] [pre] - noprefix: I line with Ident[br] - ^: I line with OTHER type Ident[br] - ~: I line, no Ident[br] - +: i line with Ident[br] - =: i line with OTHER type Ident[br] - -: i line, no Ident[br] + noprefix: I line with Ident + ^: I line with OTHER type Ident + ~: I line, no Ident + +: i line with Ident + =: i line with OTHER type Ident + -: i line, no Ident [/pre] So finally you can find <username> strings like [i]~pragma[/i] or [i]^pragma[/i], where [i]pragma[/i] is the system username of the irc-user and ~ and ^ are prefixes.[br] @@ -371,7 +371,7 @@ bool KviIrcMask::matchWildString(const QString & szExp, const QString & szStr) c QChar * pPtr = (QChar *)szExp.constData(); if(!pPtr) - return 0; + return false; while(pPtr->unicode()) { diff --git a/src/kvilib/irc/KviIrcNetwork.h b/src/kvilib/irc/KviIrcNetwork.h index 41af48e23..608f330c2 100644 --- a/src/kvilib/irc/KviIrcNetwork.h +++ b/src/kvilib/irc/KviIrcNetwork.h @@ -85,14 +85,14 @@ protected: bool m_bAutoConnect; /**< autoconnect */ QString m_szUserIdentityId; /**< The user identity to use for this server: if empty then use the global primary identity moved from KviIrcServerDataBaseRecord */ KviPointerList<KviIrcServer> * m_pServerList; - KviIrcServer * m_pCurrentServer; + KviIrcServer * m_pCurrentServer = nullptr; public: /** * \brief Returns the name of the network * \return const QString & */ - inline const QString & name() const { return m_szName; }; + const QString & name() const { return m_szName; } /** * \brief Returns the encoding of the network @@ -101,7 +101,7 @@ public: * communicating with the server * \return const QString & */ - inline const QString & encoding() const { return m_szEncoding; }; + const QString & encoding() const { return m_szEncoding; } /** * \brief Returns the text encoding of the network @@ -109,85 +109,85 @@ public: * This is the default encoding when talking on channels or queries * \return const QString & */ - inline const QString & textEncoding() const { return m_szTextEncoding; }; + const QString & textEncoding() const { return m_szTextEncoding; } /** * \brief Returns the description of the network * \return const QString & */ - inline const QString & description() const { return m_szDescription; }; + const QString & description() const { return m_szDescription; } /** * \brief Returns the nickname of the user associated to the network * \return const QString & */ - inline const QString & nickName() const { return m_szNickName; }; + const QString & nickName() const { return m_szNickName; } /** * \brief Returns the alternative nickname of the user associated to the network * \return const QString & */ - inline const QString & alternativeNickName() const { return m_szAlternativeNickName; }; + const QString & alternativeNickName() const { return m_szAlternativeNickName; } /** * \brief Returns the realname of the user associated to the network * \return const QString & */ - inline const QString & realName() const { return m_szRealName; }; + const QString & realName() const { return m_szRealName; } /** * \brief Returns the username of the user associated to the network * \return const QString & */ - inline const QString & userName() const { return m_szUserName; }; + const QString & userName() const { return m_szUserName; } /** * \brief Returns the password of the user associated to the network * \return const QString & */ - inline const QString & password() const { return m_szPass; }; + const QString & password() const { return m_szPass; } /** * \brief Returns the commands to run on network login * \return const QString & */ - inline const QString & onLoginCommand() const { return m_szOnLoginCommand; }; + const QString & onLoginCommand() const { return m_szOnLoginCommand; } /** * \brief Returns the commands to run on network connect * \return const QString & */ - inline const QString & onConnectCommand() const { return m_szOnConnectCommand; }; + const QString & onConnectCommand() const { return m_szOnConnectCommand; } /** * \brief Returns the user identity of the user associated to the network * \return const QString & */ - inline const QString & userIdentityId() const { return m_szUserIdentityId; }; + const QString & userIdentityId() const { return m_szUserIdentityId; } /** * \brief Returns true if the network has the autoconnect state on * \return bool */ - inline bool autoConnect() const { return m_bAutoConnect; }; + bool autoConnect() const { return m_bAutoConnect; } /** * \brief Returns the list of channels with autojoin flag * \return QStringList * */ - inline QStringList * autoJoinChannelList() { return m_pChannelList; }; + QStringList * autoJoinChannelList() { return m_pChannelList; } /** * \brief Returns the list of channels with autojoin flag as a string * \return const QString & */ - inline const QString autoJoinChannelListAsString() { return m_pChannelList ? m_pChannelList->join(",") : ""; }; + const QString autoJoinChannelListAsString() { return m_pChannelList ? m_pChannelList->join(",") : ""; } /** * \brief Returns a set of rules for the NickServ * \return KviNickServRuleSet * */ - inline KviNickServRuleSet * nickServRuleSet() { return m_pNickServRuleSet; }; + KviNickServRuleSet * nickServRuleSet() { return m_pNickServRuleSet; } /** * \brief Sets the rules for NickServ @@ -208,7 +208,7 @@ public: * \param szName The name of the network * \return void */ - inline void setName(const QString & szName) { m_szName = szName; }; + void setName(const QString & szName) { m_szName = szName; } /** * \brief Sets the encondig of the network @@ -218,7 +218,7 @@ public: * \param szEncoding The encoding of the network * \return void */ - inline void setEncoding(const QString & szEncoding) { m_szEncoding = szEncoding; }; + void setEncoding(const QString & szEncoding) { m_szEncoding = szEncoding; } /** * \brief Sets the text encondig of the network @@ -227,63 +227,63 @@ public: * \param szEncoding The text encoding of the network * \return void */ - inline void setTextEncoding(const QString & szEncoding) { m_szTextEncoding = szEncoding; }; + void setTextEncoding(const QString & szEncoding) { m_szTextEncoding = szEncoding; } /** * \brief Sets the description of the network * \param szDescription The description of the network * \return void */ - inline void setDescription(const QString & szDescription) { m_szDescription = szDescription; }; + void setDescription(const QString & szDescription) { m_szDescription = szDescription; } /** * \brief Sets the list of commands to run on network connection * \param szCmd The commands list to run * \return void */ - inline void setOnConnectCommand(const QString & szCmd) { m_szOnConnectCommand = szCmd; }; + void setOnConnectCommand(const QString & szCmd) { m_szOnConnectCommand = szCmd; } /** * \brief Sets the list of commands to run on network login * \param szCmd The commands list to run * \return void */ - inline void setOnLoginCommand(const QString & szCmd) { m_szOnLoginCommand = szCmd; }; + void setOnLoginCommand(const QString & szCmd) { m_szOnLoginCommand = szCmd; } /** * \brief Sets the nickname of the user associated to the network * \param szNick The nickname * \return void */ - inline void setNickName(const QString & szNick) { m_szNickName = szNick; }; + void setNickName(const QString & szNick) { m_szNickName = szNick; } /** * \brief Sets the alternative nickname of the user associated to the network * \param szNick The nickname * \return void */ - inline void setAlternativeNickName(const QString & szNick) { m_szAlternativeNickName = szNick; }; + void setAlternativeNickName(const QString & szNick) { m_szAlternativeNickName = szNick; } /** * \brief Sets the realname of the user associated to the network * \param szReal The realname * \return void */ - inline void setRealName(const QString & szReal) { m_szRealName = szReal; }; + void setRealName(const QString & szReal) { m_szRealName = szReal; } /** * \brief Sets the username of the user associated to the network * \param szUser The username * \return void */ - inline void setUserName(const QString & szUser) { m_szUserName = szUser; }; + void setUserName(const QString & szUser) { m_szUserName = szUser; } /** * \brief Sets the password of the user associated to the network * \param szPass The password * \return void */ - inline void setPassword(const QString & szPass) { m_szPass = szPass; }; + void setPassword(const QString & szPass) { m_szPass = szPass; } /** * \brief Sets the list of channels to mark for autojoin @@ -304,20 +304,20 @@ public: * \param bAutoConnect The state of the autoconnect flag * \return void */ - inline void setAutoConnect(bool bAutoConnect) { m_bAutoConnect = bAutoConnect; }; + void setAutoConnect(bool bAutoConnect) { m_bAutoConnect = bAutoConnect; } /** * \brief Sets the user identity id of the user associated to the network * \param szUserIdentityId The user identity * \return void */ - inline void setUserIdentityId(const QString & szUserIdentityId) { m_szUserIdentityId = szUserIdentityId; }; + void setUserIdentityId(const QString & szUserIdentityId) { m_szUserIdentityId = szUserIdentityId; } /** * \brief Returns a list of servers associated to the network * \return KviPointerList<KviIrcServer> * */ - inline KviPointerList<KviIrcServer> * serverList() { return m_pServerList; }; + KviPointerList<KviIrcServer> * serverList() const { return m_pServerList; } /** * \brief Returns the current server diff --git a/src/kvilib/irc/KviIrcServer.cpp b/src/kvilib/irc/KviIrcServer.cpp index 4eeeadf90..fa78bdd66 100644 --- a/src/kvilib/irc/KviIrcServer.cpp +++ b/src/kvilib/irc/KviIrcServer.cpp @@ -32,7 +32,7 @@ #include <memory> #include <vector> -#include <stdlib.h> +#include <cstdlib> // This is not allowed on windows unless we force the symbol to be undefined // It works on linux since gcc allows undefined symbols by default @@ -94,6 +94,7 @@ KviIrcServer::KviIrcServer(const KviIrcServer & serv) m_bAutoConnect = serv.m_bAutoConnect; m_szSaslNick = serv.m_szSaslNick; m_szSaslPass = serv.m_szSaslPass; + m_szSaslMethod = serv.m_szSaslMethod; if(serv.m_pAutoJoinChannelList) m_pAutoJoinChannelList = new QStringList(*(serv.m_pAutoJoinChannelList)); @@ -178,7 +179,7 @@ void KviIrcServer::clearReconnectInfo() void KviIrcServer::generateUniqueId() { struct timeval tv; - kvi_gettimeofday(&tv, nullptr); + kvi_gettimeofday(&tv); m_szId = QString("myserver%1%2%3").arg(tv.tv_usec).arg(rand() % 1000).arg(rand() % 1000); } @@ -244,6 +245,8 @@ bool KviIrcServer::load(KviConfigurationFile * pCfg, const QString & szPrefix) m_szSaslPass = pCfg->readEntry(szTmp); szTmp = QString("%1SaslNick").arg(szPrefix); m_szSaslNick = pCfg->readEntry(szTmp); + szTmp = QString("%1SaslMethod").arg(szPrefix); + m_szSaslMethod = pCfg->readEntry(szTmp, QStringLiteral("PLAIN")); szTmp = QString("%1RealName").arg(szPrefix); m_szRealName = pCfg->readEntry(szTmp); szTmp = QString("%1InitUmode").arg(szPrefix); @@ -340,6 +343,11 @@ void KviIrcServer::save(KviConfigurationFile * pCfg, const QString & szPrefix) szTmp = QString("%1SaslNick").arg(szPrefix); pCfg->writeEntry(szTmp, m_szSaslNick); } + if(!m_szSaslMethod.isEmpty() && enabledSASL()) + { + szTmp = QString("%1SaslMethod").arg(szPrefix); + pCfg->writeEntry(szTmp, m_szSaslMethod); + } if(!m_szRealName.isEmpty()) { szTmp = QString("%1RealName").arg(szPrefix); diff --git a/src/kvilib/irc/KviIrcServer.h b/src/kvilib/irc/KviIrcServer.h index fde14c35b..152120a72 100644 --- a/src/kvilib/irc/KviIrcServer.h +++ b/src/kvilib/irc/KviIrcServer.h @@ -111,6 +111,7 @@ private: int m_iProxy; /**< proxy server's id */ QString m_szSaslNick; /**< nickname for sasl auth */ QString m_szSaslPass; /**< password for sasl auth */ + QString m_szSaslMethod; /**< method name for sasl auth */ public: KviIrcServerReconnectInfo * reconnectInfo() @@ -126,7 +127,7 @@ public: * \brief Returns the proxy server's id * \return int */ - inline int proxy() { return m_iProxy; }; + int proxy() const { return m_iProxy; } /** * \brief Returns the proxy server @@ -139,91 +140,97 @@ public: * \brief Returns the port number * \return kvi_u32_t */ - inline kvi_u32_t port() const { return m_uPort; }; + kvi_u32_t port() const { return m_uPort; } /** * \brief Returns the password of the user associated to the server * \return const QString & */ - inline const QString & password() const { return m_szPass; }; + const QString & password() const { return m_szPass; } /** * \brief Returns the nickname used for sasl auth * \return const QString & */ - inline const QString & saslNick() const { return m_szSaslNick; }; + const QString & saslNick() const { return m_szSaslNick; } /** * \brief Returns the password used for sasl auth * \return const QString & */ - inline const QString & saslPass() const { return m_szSaslPass; }; + const QString & saslPass() const { return m_szSaslPass; } + + /** + * \brief Returns the sasl authentication method to be used + * \return const QString & + */ + const QString & saslMethod() const { return m_szSaslMethod; } /** * \brief Returns the nickname of the user associated to the server * \return const QString & */ - inline const QString & nickName() const { return m_szNick; }; + const QString & nickName() const { return m_szNick; } /** * \brief Returns the alternative nickname of the user associated to the server * \return const QString & */ - inline const QString & alternativeNickName() const { return m_szAlternativeNick; }; + const QString & alternativeNickName() const { return m_szAlternativeNick; } /** * \brief Returns the user modes of the user associated to the server * \return const QString & */ - inline const QString & initUMode() const { return m_szInitUMode; }; + const QString & initUMode() const { return m_szInitUMode; } /** * \brief Returns the hostname of the user associated to the server * \return const QString & */ - inline const QString & hostName() const { return m_szHostname; }; + const QString & hostName() const { return m_szHostname; } /** * \brief Returns the IP address of the server * \return const QString & */ - inline const QString & ip() const { return m_szIp; }; + const QString & ip() const { return m_szIp; } /** * \brief Returns the commands to run on server login * \return const QString & */ - inline const QString & onLoginCommand() const { return m_szOnLoginCommand; }; + const QString & onLoginCommand() const { return m_szOnLoginCommand; } /** * \brief Returns the commands to run on server connection * \return const QString & */ - inline const QString & onConnectCommand() const { return m_szOnConnectCommand; }; + const QString & onConnectCommand() const { return m_szOnConnectCommand; } /** * \brief Returns the username of the user associated to the server * \return const QString & */ - inline const QString & userName() const { return m_szUser; }; + const QString & userName() const { return m_szUser; } /** * \brief Returns the realname of the user associated to the server * \return const QString & */ - inline const QString & realName() const { return m_szRealName; }; + const QString & realName() const { return m_szRealName; } /** * \brief Returns the filter applied on the server * \return const QString & */ - inline const QString & linkFilter() const { return m_szLinkFilter; }; + const QString & linkFilter() const { return m_szLinkFilter; } /** * \brief Returns the description of the server * \return const QString & */ - inline const QString & description() const { return m_szDescription; }; + const QString & description() const { return m_szDescription; } /** * \brief Returns the encoding associated to the server @@ -231,80 +238,80 @@ public: * communicating with the server * \return const QString & */ - inline const QString & encoding() const { return m_szEncoding; }; + const QString & encoding() const { return m_szEncoding; } /** * \brief Returns the text encoding associated to the server * This is the default encoding when talking on channels or queries * \return const QString & */ - inline const QString & textEncoding() const { return m_szTextEncoding; }; + const QString & textEncoding() const { return m_szTextEncoding; } /** * \brief Returns the id of the server * \return const QString & */ - inline const QString & id() const { return m_szId; }; + const QString & id() const { return m_szId; } /** * \brief Returns the id of the user associated to the server * \return const QString & */ - inline const QString & userIdentityId() const { return m_szUserIdentityId; }; + const QString & userIdentityId() const { return m_szUserIdentityId; } /** * \brief Returns true if the server is in autoconnect mode * \return bool */ - inline bool autoConnect() const { return m_bAutoConnect; }; + bool autoConnect() const { return m_bAutoConnect; } /** * \brief Returns the list of the channels in the autojoin list * \return QStringList * */ - inline QStringList * autoJoinChannelList() { return m_pAutoJoinChannelList; }; + QStringList * autoJoinChannelList() { return m_pAutoJoinChannelList; } /** * \brief Returns the list of the channels in the autojoin list as a string * \return const QString & */ - inline const QString autoJoinChannelListAsString() { return m_pAutoJoinChannelList ? m_pAutoJoinChannelList->join(",") : ""; }; + const QString autoJoinChannelListAsString() { return m_pAutoJoinChannelList ? m_pAutoJoinChannelList->join(",") : ""; } /** * \brief Returns true if the server uses IPv6 * \return bool */ - inline bool isIPv6() const { return (m_uFlags & KviIrcServer::IPv6); }; + bool isIPv6() const { return (m_uFlags & KviIrcServer::IPv6); } /** * \brief Returns true if the server uses SSL * \return bool */ - inline bool useSSL() const { return (m_uFlags & KviIrcServer::SSL); }; + bool useSSL() const { return (m_uFlags & KviIrcServer::SSL); } /** * \brief Returns true if the CAP protocol is enabled for this server * \return bool */ - inline bool enabledCAP() const { return (m_uFlags & KviIrcServer::CAP); }; + bool enabledCAP() const { return (m_uFlags & KviIrcServer::CAP); } /** * \brief Returns true if the STARTTLS protocol is enabled for this server * \return bool */ - inline bool enabledSTARTTLS() const { return (m_uFlags & KviIrcServer::STARTTLS); }; + bool enabledSTARTTLS() const { return (m_uFlags & KviIrcServer::STARTTLS); } /** * \brief Returns true if the SASL protocol is enabled for this server * \return bool */ - inline bool enabledSASL() const { return (m_uFlags & KviIrcServer::SASL); }; + bool enabledSASL() const { return (m_uFlags & KviIrcServer::SASL); } /** * \brief Returns true if the server caches the IP * \return bool */ - inline bool cacheIp() const { return (m_uFlags & KviIrcServer::CacheIP); }; + bool cacheIp() const { return (m_uFlags & KviIrcServer::CacheIP); } /** * \brief Returns the irc URI for the server @@ -318,84 +325,91 @@ public: * \param iProxy The proxy to connect through * \return void */ - inline void setProxy(int iProxy) { m_iProxy = iProxy; }; + void setProxy(int iProxy) { m_iProxy = iProxy; } /** * \brief Sets the IP for the server * \param szIp The IP of the server * \return void */ - inline void setIp(const QString & szIp) { m_szIp = szIp; }; + void setIp(const QString & szIp) { m_szIp = szIp; } /** * \brief Sets the port for the server * \param uPort The port of the server * \return void */ - inline void setPort(kvi_u32_t uPort) { m_uPort = uPort; }; + void setPort(kvi_u32_t uPort) { m_uPort = uPort; } /** * \brief Sets the hostname for the server * \param szHost The host name of the user * \return void */ - inline void setHostName(const QString & szHost) { m_szHostname = szHost; }; + void setHostName(const QString & szHost) { m_szHostname = szHost; } /** * \brief Sets the description for the server * \param szDesc The description of the server * \return void */ - inline void setDescription(const QString & szDesc) { m_szDescription = szDesc; }; + void setDescription(const QString & szDesc) { m_szDescription = szDesc; } /** * \brief Sets the username of the user associated to the server * \param szUser The user name of the user * \return void */ - inline void setUserName(const QString & szUser) { m_szUser = szUser; }; + void setUserName(const QString & szUser) { m_szUser = szUser; } /** * \brief Sets the password of the user associated to the server * \param szPass The password of the user * \return void */ - inline void setPassword(const QString & szPass) { m_szPass = szPass; }; + void setPassword(const QString & szPass) { m_szPass = szPass; } /** * \brief Sets the nickname of the user associated to the server * \param szNick The nick name of the user * \return void */ - inline void setNickName(const QString & szNick) { m_szNick = szNick; }; + void setNickName(const QString & szNick) { m_szNick = szNick; } /** * \brief Sets the alternative nickname of the user associated to the server * \param szNick The nick name of the user * \return void */ - inline void setAlternativeNickName(const QString & szNick) { m_szAlternativeNick = szNick; }; + void setAlternativeNickName(const QString & szNick) { m_szAlternativeNick = szNick; } /** * \brief Sets the password used for sasl auth * \param szPass The password of the user * \return void */ - inline void setSaslPass(const QString & szPass) { m_szSaslPass = szPass; }; + void setSaslPass(const QString & szPass) { m_szSaslPass = szPass; } /** * \brief Sets the nickname used for sasl auth * \param szNick The nick name of the user * \return void */ - inline void setSaslNick(const QString & szNick) { m_szSaslNick = szNick; }; + void setSaslNick(const QString & szNick) { m_szSaslNick = szNick; } + + /** + * \brief Sets the sasl method to be used for auth + * \param szMethod The method name + * \return void + */ + void setSaslMethod(const QString & szMethod) { m_szSaslMethod = szMethod; } /** * \brief Sets the realname of the user associated to the server * \param szReal The real name of the user * \return void */ - inline void setRealName(const QString & szReal) { m_szRealName = szReal; }; + void setRealName(const QString & szReal) { m_szRealName = szReal; } /** * \brief Sets the encoding associated to the server @@ -405,7 +419,7 @@ public: * \param szEncoding The default encoding of the text * \return void */ - inline void setEncoding(const QString & szEncoding) { m_szEncoding = szEncoding; }; + void setEncoding(const QString & szEncoding) { m_szEncoding = szEncoding; } /** * \brief Sets the encoding associated to the server @@ -413,28 +427,28 @@ public: * \param szEncoding The default encoding of the text * \return void */ - inline void setTextEncoding(const QString & szEncoding) { m_szTextEncoding = szEncoding; }; + void setTextEncoding(const QString & szEncoding) { m_szTextEncoding = szEncoding; } /** * \brief Sets the user modes of the user associated to the server * \param szUMode The user modes of the user * \return void */ - inline void setInitUMode(const QString & szUMode) { m_szInitUMode = szUMode; }; + void setInitUMode(const QString & szUMode) { m_szInitUMode = szUMode; } /** * \brief Sets the commands to run on server connection * \param szCmd The comands to run on connection * \return void */ - inline void setOnConnectCommand(const QString & szCmd) { m_szOnConnectCommand = szCmd; }; + void setOnConnectCommand(const QString & szCmd) { m_szOnConnectCommand = szCmd; } /** * \brief Sets the commands to run on server login * \param szCmd The comands to run on login * \return void */ - inline void setOnLoginCommand(const QString & szCmd) { m_szOnLoginCommand = szCmd; }; + void setOnLoginCommand(const QString & szCmd) { m_szOnLoginCommand = szCmd; } /** * \brief Applies the filter to the server @@ -445,7 +459,7 @@ public: * \param szFilter * \return void */ - inline void setLinkFilter(const QString & szFilter) { m_szLinkFilter = szFilter; }; + void setLinkFilter(const QString & szFilter) { m_szLinkFilter = szFilter; } /** * \brief Sets the list of channels to autojoin after connection @@ -467,92 +481,92 @@ public: * \param bAutoConnect Whether to set the autoconnection * \return void */ - inline void setAutoConnect(bool bAutoConnect) { m_bAutoConnect = bAutoConnect; }; + void setAutoConnect(bool bAutoConnect) { m_bAutoConnect = bAutoConnect; } /** * \brief Sets the id of the user associated to the server * \param szUserIdentityId The user identity id to set * \return void */ - inline void setUserIdentityId(const QString & szUserIdentityId) { m_szUserIdentityId = szUserIdentityId; }; + void setUserIdentityId(const QString & szUserIdentityId) { m_szUserIdentityId = szUserIdentityId; } /** * \brief Sets if the server uses IPv6 * \param bSet Whether to set the support for IPv6 * \return void */ - inline void setIPv6(bool bSet) + void setIPv6(bool bSet) { if(bSet) m_uFlags |= KviIrcServer::IPv6; else m_uFlags &= static_cast<unsigned short>(~KviIrcServer::IPv6); - }; + } /** * \brief Sets if the server uses SSL * \param bSet Whether to set the support for SSL * \return void */ - inline void setUseSSL(bool bSet) + void setUseSSL(bool bSet) { if(bSet) m_uFlags |= KviIrcServer::SSL; else m_uFlags &= static_cast<unsigned short>(~KviIrcServer::SSL); - }; + } /** * \brief Sets if STARTTLS support is enabled/disabled for this server * \param bSet Whether to enable the support for STARTTLS * \return void */ - inline void setEnabledSTARTTLS(bool bSet) + void setEnabledSTARTTLS(bool bSet) { if(bSet) m_uFlags |= KviIrcServer::STARTTLS; else m_uFlags &= static_cast<unsigned short>(~KviIrcServer::STARTTLS); - }; + } /** * \brief Sets if CAP support is enabled/disabled for this server * \param bSet Whether to enable the support for CAP * \return void */ - inline void setEnabledCAP(bool bSet) + void setEnabledCAP(bool bSet) { if(bSet) m_uFlags |= KviIrcServer::CAP; else m_uFlags &= static_cast<unsigned short>(~KviIrcServer::CAP); - }; + } /** * \brief Sets if SASL support is enabled/disabled for this server * \param bSet Whether to enable the support for SASL * \return void */ - inline void setEnabledSASL(bool bSet) + void setEnabledSASL(bool bSet) { if(bSet) m_uFlags |= KviIrcServer::SASL; else m_uFlags &= static_cast<unsigned short>(~KviIrcServer::SASL); - }; + } /** * \brief Sets if the server caches the IP * \param bSet Whether to set the cache for the IP * \return void */ - inline void setCacheIp(bool bSet) + void setCacheIp(bool bSet) { if(bSet) m_uFlags |= KviIrcServer::CacheIP; else m_uFlags &= static_cast<unsigned short>(~KviIrcServer::CacheIP); - }; + } /** * \brief Generates an unique id for the server and sets it @@ -565,12 +579,12 @@ public: * \param szId The id of the server * \return void */ - inline void setId(const QString & szId) + void setId(const QString & szId) { m_szId = szId; if(m_szId.isEmpty()) generateUniqueId(); - }; + } /** * \brief Loads the information from the configuration file @@ -600,19 +614,19 @@ public: * \param bSet whether the server is a favorite or not * \return void */ - inline void setFavorite(bool bSet) + void setFavorite(bool bSet) { if(bSet) m_uFlags |= KviIrcServer::FAVORITE; else m_uFlags &= static_cast<unsigned short>(~KviIrcServer::FAVORITE); - }; + } /** * \brief Returns if the server is a favorite * \return bool */ - inline bool favorite() const { return (m_uFlags & KviIrcServer::FAVORITE); }; + bool favorite() const { return (m_uFlags & KviIrcServer::FAVORITE); } }; #endif //_KVI_IRCSERVER_H_ diff --git a/src/kvilib/irc/KviIrcServerDataBase.h b/src/kvilib/irc/KviIrcServerDataBase.h index 18639ba1a..bdd3bbedf 100644 --- a/src/kvilib/irc/KviIrcServerDataBase.h +++ b/src/kvilib/irc/KviIrcServerDataBase.h @@ -44,7 +44,7 @@ class KviIrcServer; * \struct _KviIrcServerDefinition * \brief Server definition */ -typedef struct _KviIrcServerDefinition +struct KviIrcServerDefinition { QString szServer; kvi_u32_t uPort; @@ -57,7 +57,7 @@ typedef struct _KviIrcServerDefinition QString szNick; QString szInitUMode; QString szId; -} KviIrcServerDefinition; +}; /** * \class KviIrcServerDataBase @@ -94,7 +94,7 @@ public: * \brief Returns the record dictionary of the database * \return KviPointerHashTable<QString,KviIrcNetwork> * */ - inline KviPointerHashTable<QString, KviIrcNetwork> * recordDict() { return m_pRecords; }; + KviPointerHashTable<QString, KviIrcNetwork> * recordDict() const { return m_pRecords; } /** * \brief Returns a list of servers to connect on startup @@ -106,7 +106,7 @@ public: * later. * \return KviPointerList<KviIrcServer> * */ - inline KviPointerList<KviIrcServer> * autoConnectOnStartupServers() { return m_pAutoConnectOnStartupServers; }; + KviPointerList<KviIrcServer> * autoConnectOnStartupServers() const { return m_pAutoConnectOnStartupServers; } /** * \brief Returns a list of networks to connect on startup @@ -118,7 +118,7 @@ public: * updated later. * \return KviPointerList<KviIrcNetwork> * */ - inline KviPointerList<KviIrcNetwork> * autoConnectOnStartupNetworks() { return m_pAutoConnectOnStartupNetworks; }; + KviPointerList<KviIrcNetwork> * autoConnectOnStartupNetworks() const { return m_pAutoConnectOnStartupNetworks; } /** * \brief Deletes the list of autoconnect servers @@ -137,13 +137,13 @@ public: * \param szNetName The name of the network * \return void */ - inline void setCurrentNetwork(const QString & szNetName) { m_szCurrentNetwork = szNetName; }; + void setCurrentNetwork(const QString & szNetName) { m_szCurrentNetwork = szNetName; } /** * \brief Returns the current network name * \return const QString & */ - inline const QString & currentNetworkName() { return m_szCurrentNetwork; }; + const QString & currentNetworkName() const { return m_szCurrentNetwork; } /** * \brief Returns the current network diff --git a/src/kvilib/locale/KviLocale.h b/src/kvilib/locale/KviLocale.h index b44edd2ae..ae37dd326 100644 --- a/src/kvilib/locale/KviLocale.h +++ b/src/kvilib/locale/KviLocale.h @@ -64,14 +64,14 @@ public: * \struct _EncodingDescription * \brief Holds the encoding data */ - typedef struct _EncodingDescription + struct EncodingDescription { const char * pcName; /**< name of the encoding */ char bSmart; /**< is it a smart codec? */ char bSendUtf8; /**< does it send utf8 or the local charset? */ uint uGroup; /**< group */ const char * pcDescription; /**< description of the encoding */ - } EncodingDescription; + }; protected: /** diff --git a/src/kvilib/locale/KviMessageCatalogue.cpp b/src/kvilib/locale/KviMessageCatalogue.cpp index b1b2618e9..abc9094e8 100644 --- a/src/kvilib/locale/KviMessageCatalogue.cpp +++ b/src/kvilib/locale/KviMessageCatalogue.cpp @@ -61,7 +61,7 @@ #include <QString> #include <QTextCodec> -#include <stdio.h> +#include <cstdio> // The magic number of the GNU message catalog format. #define KVI_LOCALE_MAGIC 0x950412de diff --git a/src/kvilib/locale/KviTranslator.cpp b/src/kvilib/locale/KviTranslator.cpp index f4bff95df..db1137dd3 100644 --- a/src/kvilib/locale/KviTranslator.cpp +++ b/src/kvilib/locale/KviTranslator.cpp @@ -35,7 +35,7 @@ KviTranslator::KviTranslator(QObject * pParent) KviTranslator::~KviTranslator() = default; -QString KviTranslator::translate(const char *, const char * pcMessage, const char *) const +QString KviTranslator::translate(const char *, const char * pcMessage, const char *, int n) const { // We currently ignore contexts and comments for qt translations // FIXME: Could use the context and lookup in the context catalogue first, then in the main one. diff --git a/src/kvilib/locale/KviTranslator.h b/src/kvilib/locale/KviTranslator.h index 1103ab85d..e69e9eb23 100644 --- a/src/kvilib/locale/KviTranslator.h +++ b/src/kvilib/locale/KviTranslator.h @@ -68,7 +68,7 @@ public: * \param pcComment Comment of Qt translation. Unused by us * \return QString */ - virtual QString translate(const char * pcContext, const char * pcMessage, const char * pcComment) const; + QString translate(const char * pcContext, const char * pcMessage, const char * pcComment, int n = -1) const override; }; #endif //_KVITRANSLATOR_H_ diff --git a/src/kvilib/net/KviDnsResolver.cpp b/src/kvilib/net/KviDnsResolver.cpp index 530f139ef..116504e20 100644 --- a/src/kvilib/net/KviDnsResolver.cpp +++ b/src/kvilib/net/KviDnsResolver.cpp @@ -29,7 +29,7 @@ #include <QApplication> -#include <errno.h> +#include <cerrno> #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) #include <winsock2.h> @@ -180,7 +180,7 @@ void KviDnsResolverThread::run() // gethostbyaddr and gethostbyname are thread-safe on Windoze struct in_addr inAddr; - struct hostent * pHostEntry = 0; + struct hostent * pHostEntry = nullptr; // DIE DIE!....I hope that this stuff will disappear sooner or later :) diff --git a/src/kvilib/net/KviDnsResolver.h b/src/kvilib/net/KviDnsResolver.h index c1458b967..603a53315 100644 --- a/src/kvilib/net/KviDnsResolver.h +++ b/src/kvilib/net/KviDnsResolver.h @@ -92,7 +92,7 @@ class KVILIB_API KviDnsResolver : public QObject, public KviHeapObject Q_PROPERTY(bool blockingDelete READ isRunning) public: KviDnsResolver(); - virtual ~KviDnsResolver(); + ~KviDnsResolver(); public: enum QueryType @@ -138,7 +138,7 @@ public: bool isRunning() const; protected: - virtual bool event(QEvent * e); + bool event(QEvent * e) override; private: KviDnsResolverResult * result(); @@ -167,7 +167,7 @@ public: KVI_ASSERT(pResult); } - virtual ~KviDnsResolverThreadEvent() + ~KviDnsResolverThreadEvent() { delete m_pResult; } @@ -187,11 +187,11 @@ class KviDnsResolverThread : public QThread protected: KviDnsResolverThread(KviDnsResolver * pDns); - virtual ~KviDnsResolverThread(); + ~KviDnsResolverThread(); protected: QString m_szQuery; - KviDnsResolver::QueryType m_queryType; + KviDnsResolver::QueryType m_queryType = KviDnsResolver::Any; KviDnsResolver * m_pParentDns; public: @@ -202,7 +202,7 @@ public: }; protected: - virtual void run(); + void run() override; KviError::Code translateDnsError(int iErr); void postDnsError(KviDnsResolverResult * pDns, KviError::Code error); }; diff --git a/src/kvilib/net/KviDnsResolverNew.h b/src/kvilib/net/KviDnsResolverNew.h index 067397ef7..ca4a663d9 100644 --- a/src/kvilib/net/KviDnsResolverNew.h +++ b/src/kvilib/net/KviDnsResolverNew.h @@ -64,7 +64,7 @@ public: /// Destroys the instance of KviDnsResolver /// and frees all the relevant resources /// - virtual ~KviDnsResolver(); + ~KviDnsResolver(); public: enum QueryType diff --git a/src/kvilib/net/KviHttpRequest.cpp b/src/kvilib/net/KviHttpRequest.cpp index ae1804921..390b686b5 100644 --- a/src/kvilib/net/KviHttpRequest.cpp +++ b/src/kvilib/net/KviHttpRequest.cpp @@ -717,9 +717,9 @@ bool KviHttpRequest::processHeader(KviCString & szHeader) return false; } - KviCString * location = hdr.find("Location"); + KviCString * headerLocation = hdr.find("Location"); - if(!location) + if(!headerLocation || headerLocation->isEmpty()) { resetInternalStatus(); m_szLastError = __tr2qs("Bad redirect"); @@ -727,7 +727,18 @@ bool KviHttpRequest::processHeader(KviCString & szHeader) return false; } - KviUrl url(location->ptr()); + KviUrl url; + QString location(headerLocation->ptr()); + + if(location.startsWith('/')) + { + // relative redirect, use the old url and only update the path + url = m_connectionUrl; + url.setPath(location); + } else { + // absolute redirect + url.setUrl(location); + } if( (url.url() == m_connectionUrl.url()) || (url.url() == m_url.url())) @@ -1044,7 +1055,7 @@ void KviHttpRequest::dnsLookupDone(KviDnsResolver *d) { m_szIp = d->firstIpAddress(); delete m_pDns; - m_pDns = 0; + m_pDns = nullptr; QString tmp; tmp = QString(__tr2qs("Host %1 resolved to %2")).arg(m_connectionUrl.host(),m_szIp); emit status(tmp); diff --git a/src/kvilib/net/KviHttpRequest.h b/src/kvilib/net/KviHttpRequest.h index 6d165d011..2accde92f 100644 --- a/src/kvilib/net/KviHttpRequest.h +++ b/src/kvilib/net/KviHttpRequest.h @@ -78,7 +78,7 @@ public: public: KviHttpRequest(); - virtual ~KviHttpRequest(); + ~KviHttpRequest(); protected: // data diff --git a/src/kvilib/net/KviNetUtils.cpp b/src/kvilib/net/KviNetUtils.cpp index 82b5804d9..d3aefae72 100644 --- a/src/kvilib/net/KviNetUtils.cpp +++ b/src/kvilib/net/KviNetUtils.cpp @@ -241,7 +241,7 @@ bool kvi_binaryIpToStringIp_V6(struct in6_addr in, QString & szBuffer) #endif -#include <errno.h> +#include <cerrno> bool kvi_select(int fd, bool * bCanRead, bool * bCanWrite, int iUSecs) { @@ -610,7 +610,7 @@ kvi_u32_t KviSockaddr::port() bool KviSockaddr::getStringAddress(QString & szBuffer) { if(!m_pData) - return 0; + return false; #ifdef COMPILE_IPV6_SUPPORT switch(((struct addrinfo *)m_pData)->ai_family) { diff --git a/src/kvilib/net/KviNetworkAccessManager.h b/src/kvilib/net/KviNetworkAccessManager.h index f52c6a753..8226778dd 100644 --- a/src/kvilib/net/KviNetworkAccessManager.h +++ b/src/kvilib/net/KviNetworkAccessManager.h @@ -40,7 +40,7 @@ private: public: static QNetworkAccessManager * getInstance() { - static QNetworkAccessManager * pInstance = NULL; + static QNetworkAccessManager * pInstance = nullptr; if(!pInstance) pInstance = new QNetworkAccessManager(); return pInstance; diff --git a/src/kvilib/net/KviSASL.cpp b/src/kvilib/net/KviSASL.cpp index 9ea64ffe4..b6b88eeb4 100644 --- a/src/kvilib/net/KviSASL.cpp +++ b/src/kvilib/net/KviSASL.cpp @@ -28,11 +28,19 @@ #include "KviMemory.h" #include <QByteArray> +#include <QStringList> namespace KviSASL { + QStringList supportedMethods() + { + return { + QStringLiteral("PLAIN"), + QStringLiteral("EXTERNAL") + }; + } - bool plainMethod(KviCString & szIn, KviCString & szOut, QByteArray & baNick, QByteArray & baPass) + bool plainMethod(const KviCString & szIn, KviCString & szOut, const QByteArray & baNick, const QByteArray & baPass) { if(szIn == "+") { @@ -59,4 +67,15 @@ namespace KviSASL } return false; } + + bool externalMethod(const KviCString & szIn, KviCString & szOut) + { + if(szIn == "+") + { + szOut = szIn; + + return true; + } + return false; + } } diff --git a/src/kvilib/net/KviSASL.h b/src/kvilib/net/KviSASL.h index 8c177329d..861cbac26 100644 --- a/src/kvilib/net/KviSASL.h +++ b/src/kvilib/net/KviSASL.h @@ -28,17 +28,24 @@ class KviCString; class QByteArray; +class QStringList; /** * \namespace KviSASL * \brief This namespace implement some SASL authentication methods. * -* Currently implementhed methods are PLAIN and DH-BLOWFISH +* Currently implementhed methods are PLAIN and EXTERNAL */ namespace KviSASL { /** + * \brief Returns a list of the supported SASL methods + * \return QStringList + */ + extern KVILIB_API QStringList supportedMethods(); + + /** * \brief Create the auth message for PLAIN authentication * \param szIn The server-provided token * \param szOut A KviCString that will be filled with the authentication message @@ -46,7 +53,15 @@ namespace KviSASL * \param baPass The password * \return bool */ - extern KVILIB_API bool plainMethod(KviCString & szIn, KviCString & szOut, QByteArray & baNick, QByteArray & baPass); + extern KVILIB_API bool plainMethod(const KviCString & szIn, KviCString & szOut, const QByteArray & baNick, const QByteArray & baPass); + + /** + * \brief Create the auth message for EXTERNAL authentication + * \param szIn The server-provided token + * \param szOut A KviCString that will be filled with the authentication message + * \return bool + */ + extern KVILIB_API bool externalMethod(const KviCString & szIn, KviCString & szOut); }; #endif //_KVI_SASL_H_ diff --git a/src/kvilib/net/KviSSL.cpp b/src/kvilib/net/KviSSL.cpp index c063f53ea..8662b2f98 100644 --- a/src/kvilib/net/KviSSL.cpp +++ b/src/kvilib/net/KviSSL.cpp @@ -36,11 +36,11 @@ #include <openssl/err.h> #include <openssl/dh.h> -#include <stdio.h> +#include <cstdio> #if !(defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)) // linux, mac -#include <signal.h> +#include <csignal> #endif static bool g_bSSLInitialized = false; @@ -168,6 +168,7 @@ static DH * my_get_dh(int keylength) unsigned char * g = nullptr; int sp = 0; int sg = 0; + BIGNUM *bp, *bg; switch(keylength) { case 512: @@ -209,13 +210,21 @@ static DH * my_get_dh(int keylength) dh = DH_new(); if(!dh) return nullptr; - dh->p = BN_bin2bn(p, sp, nullptr); - dh->g = BN_bin2bn(g, sg, nullptr); - if((dh->p == nullptr) || (dh->g == nullptr)) + bp = BN_bin2bn(p, sp, nullptr); + bg = BN_bin2bn(g, sg, nullptr); + if((p == nullptr) || (g == nullptr)) { + BN_free(bp); + BN_free(bg); DH_free(dh); return nullptr; } +#if OPENSSL_VERSION_NUMBER >= 0x10100005L + DH_set0_pqg(dh, bp, nullptr, bg); +#else + dh->p = bp; + dh->g = bg; +#endif return dh; } @@ -313,8 +322,8 @@ void KviSSL::shutdown() { if(m_pSSL) { -//avoid to die on a SIGPIPE if the connection has close (SSL_shutdown can call send()) -//see bug #440 + //avoid to die on a SIGPIPE if the connection has close (SSL_shutdown can call send()) + //see bug #440 #if !(defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW)) // ignore SIGPIPE @@ -695,11 +704,17 @@ int KviSSLCertificate::fingerprintDigestId() if(!m_pX509) return -1; - int NID = OBJ_obj2nid(m_pX509->sig_alg->algorithm); + const X509_ALGOR * alg; +#if OPENSSL_VERSION_NUMBER >= 0x10100005L + X509_get0_signature(nullptr, &alg, m_pX509); +#else + alg = m_pX509->sig_alg; +#endif + + int NID = OBJ_obj2nid(alg->algorithm); if(NID == NID_undef) { return 0; // unknown digest function: it means the signature can't be verified: the certificate can't be trusted - } const EVP_MD * mdType = nullptr; @@ -710,7 +725,7 @@ int KviSSLCertificate::fingerprintDigestId() return 0; // Unknown digest } - return mdType->type; + return EVP_MD_type(mdType); } const char * KviSSLCertificate::fingerprintDigestStr() @@ -828,8 +843,14 @@ void KviSSLCertificate::extractPubKeyInfo() EVP_PKEY * p = X509_get_pubkey(m_pX509); if(p) { + int type; +#if OPENSSL_VERSION_NUMBER >= 0x10100005L + type = EVP_PKEY_base_id(p); +#else + type = EVP_PKEY_type(p->type); +#endif m_iPubKeyBits = EVP_PKEY_bits(p); - m_szPubKeyType = (p->type == NID_undef) ? __tr("Unknown") : OBJ_nid2ln(p->type); + m_szPubKeyType = (type == NID_undef) ? __tr("Unknown") : OBJ_nid2ln(type); // getPKeyType(p->type,m_szPubKeyType); } else @@ -841,28 +862,48 @@ void KviSSLCertificate::extractPubKeyInfo() void KviSSLCertificate::extractSerialNumber() { + m_szSerialNumber.clear(); ASN1_INTEGER * i = X509_get_serialNumber(m_pX509); if(i) - m_iSerialNumber = ASN1_INTEGER_get(i); - else - m_iSerialNumber = -1; + { + BIGNUM * bn = ASN1_INTEGER_to_BN(i, nullptr); + if(bn) + { + char * str = BN_bn2dec(bn); + if(str) + { + m_szSerialNumber = KviCString(str); + OPENSSL_free(str); + } + BN_free(bn); + } + } } void KviSSLCertificate::extractSignature() { static char hexdigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - int i = OBJ_obj2nid(m_pX509->sig_alg->algorithm); + const ASN1_BIT_STRING * sig; + const X509_ALGOR * alg; +#if OPENSSL_VERSION_NUMBER >= 0x10100005L + X509_get0_signature(&sig, &alg, m_pX509); +#else + sig = m_pX509->signature; + alg = m_pX509->sig_alg; +#endif + + int i = OBJ_obj2nid(alg->algorithm); m_szSignatureType = (i == NID_undef) ? __tr("Unknown") : OBJ_nid2ln(i); m_szSignatureContents = ""; - for(i = 0; i < m_pX509->signature->length; i++) + for(i = 0; i < sig->length; i++) { if(m_szSignatureContents.hasData()) m_szSignatureContents.append(":"); - m_szSignatureContents.append(hexdigits[(m_pX509->signature->data[i] & 0xf0) >> 4]); - m_szSignatureContents.append(hexdigits[(m_pX509->signature->data[i] & 0x0f)]); + m_szSignatureContents.append(hexdigits[(sig->data[i] & 0xf0) >> 4]); + m_szSignatureContents.append(hexdigits[(sig->data[i] & 0x0f)]); } } diff --git a/src/kvilib/net/KviSSL.h b/src/kvilib/net/KviSSL.h index 6c7798d29..849fb83f3 100644 --- a/src/kvilib/net/KviSSL.h +++ b/src/kvilib/net/KviSSL.h @@ -53,7 +53,7 @@ protected: KviPointerHashTable<const char *, KviCString> * m_pIssuer; int m_iPubKeyBits; KviCString m_szPubKeyType; - int m_iSerialNumber; + KviCString m_szSerialNumber; int m_iVersion; KviCString m_szSignatureType; KviCString m_szSignatureContents; @@ -92,7 +92,7 @@ public: int publicKeyBits() { return m_iPubKeyBits; }; const char * publicKeyType() { return m_szPubKeyType.ptr(); }; - int serialNumber() { return m_iSerialNumber; }; + const char * serialNumber() { return m_szSerialNumber.len() ? m_szSerialNumber.ptr() : nullptr; }; int version() { return m_iVersion; }; diff --git a/src/kvilib/net/KviUrl.cpp b/src/kvilib/net/KviUrl.cpp index 5de804a80..22207312a 100644 --- a/src/kvilib/net/KviUrl.cpp +++ b/src/kvilib/net/KviUrl.cpp @@ -27,13 +27,7 @@ #include <QUrl> KviUrl::KviUrl() -{ -} - -KviUrl::KviUrl(const KviUrl & u) -{ - *this = u; -} + = default; KviUrl::KviUrl(const char * szUrl) { @@ -47,6 +41,9 @@ KviUrl::KviUrl(const QString & szUrl) parse(); } +KviUrl::KviUrl(const KviUrl &) + = default; + KviUrl::~KviUrl() = default; @@ -69,6 +66,18 @@ void KviUrl::parse() m_uPort = url.port(0); } +void KviUrl::build() +{ + QUrl url; + url.setScheme(m_szProtocol); + url.setHost(m_szHost); + url.setPath(m_szPath); + url.setUserName(m_szUser); + url.setPassword(m_szPass); + url.setPort(m_uPort); + m_szUrl = url.toString(); +} + KviUrl & KviUrl::operator=(const QString & szUrl) { m_szUrl = szUrl; @@ -76,14 +85,49 @@ KviUrl & KviUrl::operator=(const QString & szUrl) return *this; } -KviUrl & KviUrl::operator=(const KviUrl & u) +KviUrl & KviUrl::operator=(const KviUrl &) + = default; + +void KviUrl::setUrl(QString & szUrl) { - m_szUrl = u.m_szUrl; - m_szProtocol = u.m_szProtocol; - m_szHost = u.m_szHost; - m_szPath = u.m_szPath; - m_szUser = u.m_szUser; - m_szPass = u.m_szPass; - m_uPort = u.m_uPort; - return *this; + m_szUrl = szUrl; + parse(); +} + +void KviUrl::setProtocol(QString & szProtocol) +{ + m_szProtocol = szProtocol; + build(); +} + +void KviUrl::setHost(QString & szHost) +{ + m_szHost = szHost; + build(); +} + +void KviUrl::setPath(QString & szPath) +{ + m_szPath = szPath; + if(m_szPath.isEmpty()) + m_szPath = QString("/"); + build(); +} + +void KviUrl::setUser(QString & szUser) +{ + m_szUser = szUser; + build(); +} + +void KviUrl::setPass(QString & szPass) +{ + m_szPass = szPass; + build(); +} + +void KviUrl::setPort(kvi_u32_t uPort) +{ + m_uPort = uPort; + build(); } diff --git a/src/kvilib/net/KviUrl.h b/src/kvilib/net/KviUrl.h index 0c98c7989..b2640c3ec 100644 --- a/src/kvilib/net/KviUrl.h +++ b/src/kvilib/net/KviUrl.h @@ -35,7 +35,7 @@ public: KviUrl(); KviUrl(const char * szUrl); KviUrl(const QString & szUrl); - KviUrl(const KviUrl & u); + KviUrl(const KviUrl &); ~KviUrl(); protected: @@ -50,6 +50,7 @@ protected: protected: void parse(); + void build(); public: const QString & url() const { return m_szUrl; }; @@ -60,8 +61,16 @@ public: const QString & pass() const { return m_szPass; }; kvi_u32_t port() const { return m_uPort; }; + void setUrl(QString & szUrl); + void setProtocol(QString & szProtocol); + void setHost(QString & szHost); + void setPath(QString & szPath); + void setUser(QString & szUser); + void setPass(QString & szPass); + void setPort(kvi_u32_t uPort); + KviUrl & operator=(const QString & szUrl); - KviUrl & operator=(const KviUrl & u); + KviUrl & operator=(const KviUrl &); }; #endif //_KVI_URL_H_ diff --git a/src/kvilib/system/KviEnvironment.h b/src/kvilib/system/KviEnvironment.h index 196bc39e5..49b978739 100644 --- a/src/kvilib/system/KviEnvironment.h +++ b/src/kvilib/system/KviEnvironment.h @@ -63,7 +63,7 @@ namespace KviEnvironment inline void unsetVariable(const QString & szName) { - SetEnvironmentVariable(szName.toStdWString().c_str(), NULL); + SetEnvironmentVariable(szName.toStdWString().c_str(), nullptr); } #else /** diff --git a/src/kvilib/system/KviSignalHandler.cpp b/src/kvilib/system/KviSignalHandler.cpp index 8ab525dc0..02f4b6aa1 100644 --- a/src/kvilib/system/KviSignalHandler.cpp +++ b/src/kvilib/system/KviSignalHandler.cpp @@ -32,7 +32,7 @@ #include "KviSignalHandler.h" -#include <signal.h> +#include <csignal> #include <sys/signal.h> #include <sys/socket.h> #include <unistd.h> @@ -67,14 +67,13 @@ bool kvi_signalHandlerSetup() new KviSignalHandler(); struct sigaction sa; + ::memset(&sa,0,sizeof(sa)); sa.sa_handler = KviSignalHandler::unixSignalHandler; sigemptyset(&sa.sa_mask); sa.sa_flags |= SA_RESTART; - return - sigaction(SIGTERM, &sa, 0) == 0 && - sigaction(SIGINT , &sa, 0) == 0; + return sigaction(SIGTERM, &sa, nullptr) == 0 && sigaction(SIGINT, &sa, nullptr) == 0; } // In your Unix signal handlers, you write a byte to the write end of diff --git a/src/kvilib/system/KviSignalHandler.h b/src/kvilib/system/KviSignalHandler.h index b5be82547..a0cb7d721 100644 --- a/src/kvilib/system/KviSignalHandler.h +++ b/src/kvilib/system/KviSignalHandler.h @@ -39,7 +39,7 @@ class KviSignalHandler : public QObject Q_OBJECT public: - KviSignalHandler(QObject *parent = 0); + KviSignalHandler(QObject *parent = nullptr); static void unixSignalHandler(int unused); diff --git a/src/kvilib/system/KviThread.cpp b/src/kvilib/system/KviThread.cpp index 3ed70ce60..fbe0888fc 100644 --- a/src/kvilib/system/KviThread.cpp +++ b/src/kvilib/system/KviThread.cpp @@ -32,11 +32,11 @@ #include <io.h> // for _pipe() #else #include <unistd.h> //for pipe() and other tricks -#include <signal.h> // on Windows it is useless +#include <csignal> // on Windows it is useless #include <fcntl.h> #endif -#include <errno.h> +#include <cerrno> #include "kvi_settings.h" #include "KviError.h" diff --git a/src/kvilib/system/KviThread.h b/src/kvilib/system/KviThread.h index 732fa9e65..fd0ae971c 100644 --- a/src/kvilib/system/KviThread.h +++ b/src/kvilib/system/KviThread.h @@ -226,7 +226,7 @@ protected: void exit(); // The tricky part: threadsafe event dispatching // Slave thread -> main thread objects - void postEvent(QObject * o, QEvent * e); + virtual void postEvent(QObject * o, QEvent * e); private: void setRunning(bool bRunning); @@ -280,9 +280,9 @@ protected: KviThread * m_pSender; public: - KviThreadEvent(int evId, KviThread * sender = 0) + KviThreadEvent(int evId, KviThread * sender = nullptr) : QEvent((QEvent::Type)KVI_THREAD_EVENT), m_eventId(evId), m_pSender(sender){}; - virtual ~KviThreadEvent(){}; + ~KviThreadEvent(){}; public: // This is the sender of the event @@ -298,9 +298,9 @@ protected: TData * m_pData; public: - KviThreadDataEvent(int evId, TData * pData = 0, KviThread * sender = 0) + KviThreadDataEvent(int evId, TData * pData = nullptr, KviThread * sender = nullptr) : KviThreadEvent(evId, sender) { m_pData = pData; }; - virtual ~KviThreadDataEvent() + ~KviThreadDataEvent() { if(m_pData) delete m_pData; @@ -316,7 +316,7 @@ public: TData * getData() { TData * aux = m_pData; - m_pData = 0; + m_pData = nullptr; return aux; }; TData * data() { return m_pData; }; @@ -360,11 +360,11 @@ protected: // This is private stuff...only KviThread and KviApplication may use it // and may call only specific functions...don't touch. -typedef struct _KviThreadPendingEvent +struct KviThreadPendingEvent { QObject * o; QEvent * e; -} KviThreadPendingEvent; +}; class KVILIB_API KviThreadManager : public QObject { diff --git a/src/kvilib/system/KviTimeUtils.cpp b/src/kvilib/system/KviTimeUtils.cpp index 3eca41ee0..57d41f86e 100644 --- a/src/kvilib/system/KviTimeUtils.cpp +++ b/src/kvilib/system/KviTimeUtils.cpp @@ -43,7 +43,7 @@ // buah buah buahhhh lol ghgh :DDDDDDDDD -void kvi_gettimeofday(struct timeval * tmv, struct timezone *) +void kvi_gettimeofday(struct timeval * tmv) { SYSTEMTIME st; GetSystemTime(&st); @@ -67,7 +67,7 @@ KviMSecTimeInterval::KviMSecTimeInterval() unsigned long KviMSecTimeInterval::mark() { struct timeval tmv; - kvi_gettimeofday(&tmv, nullptr); + kvi_gettimeofday(&tmv); unsigned long uDiff = ((((unsigned long)(tmv.tv_sec)) - m_uReferenceSecs) * 1000); if(((unsigned long)(tmv.tv_usec)) > m_uReferenceUSecs) uDiff += (((unsigned long)(tmv.tv_usec) - m_uReferenceUSecs) / 1000); @@ -83,7 +83,7 @@ namespace KviTimeUtils long long getCurrentTimeMills() { struct timeval tmv; - kvi_gettimeofday(&tmv, nullptr); + kvi_gettimeofday(&tmv); long long result = tmv.tv_sec * 1000 + tmv.tv_usec / 1000; return result; } diff --git a/src/kvilib/system/KviTimeUtils.h b/src/kvilib/system/KviTimeUtils.h index 104e35d99..6dea4d42b 100644 --- a/src/kvilib/system/KviTimeUtils.h +++ b/src/kvilib/system/KviTimeUtils.h @@ -51,7 +51,7 @@ class QString; * \param tmz The timezone * \return void */ -extern KVILIB_API void kvi_gettimeofday(struct timeval * tmv, struct timezone * tmz); +extern KVILIB_API void kvi_gettimeofday(struct timeval * tmv); #else #include <sys/time.h> // gettimeofday(), struct timeval @@ -61,9 +61,9 @@ extern KVILIB_API void kvi_gettimeofday(struct timeval * tmv, struct timezone * * \param tmz The timezone * \return void */ -inline void kvi_gettimeofday(struct timeval * tmv, struct timezone * tmz) +inline void kvi_gettimeofday(struct timeval * tmv) { - gettimeofday(tmv, tmz); + gettimeofday(tmv, nullptr); } #endif diff --git a/src/kvilib/tal/KviTalFileDialog.h b/src/kvilib/tal/KviTalFileDialog.h index 0c91ea03d..a99fcafa4 100644 --- a/src/kvilib/tal/KviTalFileDialog.h +++ b/src/kvilib/tal/KviTalFileDialog.h @@ -66,7 +66,7 @@ public: * \param bModal Whether the dialog is modal * \return KviTalFileDialog */ - KviTalFileDialog(const QString & szDirName, const QString & szFilter = QString(), QWidget * pParent = 0, const char * pcName = 0, bool bModal = false); + KviTalFileDialog(const QString & szDirName, const QString & szFilter = QString(), QWidget * pParent = nullptr, const char * pcName = nullptr, bool bModal = false); /** * \brief Destroys the filedialog object diff --git a/src/kvilib/tal/KviTalGroupBox.h b/src/kvilib/tal/KviTalGroupBox.h index e98e3f44f..8ad1f22b5 100644 --- a/src/kvilib/tal/KviTalGroupBox.h +++ b/src/kvilib/tal/KviTalGroupBox.h @@ -51,14 +51,14 @@ public: * \param pcName the name of the groupbox * \return KviTalGroupBox */ - KviTalGroupBox(QWidget * pParent, char * pcName = 0); + KviTalGroupBox(QWidget * pParent, char * pcName = nullptr); /** * \brief Constructs the groupbox object * \param pParent The parent object * \return KviTalGroupBox */ - KviTalGroupBox(QWidget * pParent = 0); + KviTalGroupBox(QWidget * pParent = nullptr); /** * \brief Constructs the groupbox object @@ -66,7 +66,7 @@ public: * \param pParent The parent object * \return KviTalGroupBox */ - KviTalGroupBox(const QString & szTitle, QWidget * pParent = 0); + KviTalGroupBox(const QString & szTitle, QWidget * pParent = nullptr); /** * \brief Constructs the groupbox object @@ -74,7 +74,7 @@ public: * \param pParent The parent object * \return KviTalGroupBox */ - KviTalGroupBox(Qt::Orientation orientation, QWidget * pParent = 0); + KviTalGroupBox(Qt::Orientation orientation, QWidget * pParent = nullptr); /** * \brief Constructs the groupbox object @@ -83,7 +83,7 @@ public: * \param pParent The parent object * \return KviTalGroupBox */ - KviTalGroupBox(Qt::Orientation orientation, const QString & szTitle, QWidget * pParent = 0); + KviTalGroupBox(Qt::Orientation orientation, const QString & szTitle, QWidget * pParent = nullptr); /** * \brief Destroys the groupbox object @@ -161,7 +161,7 @@ public: void setLayout(QLayout * newLayout); protected: - virtual void childEvent(QChildEvent * e); + void childEvent(QChildEvent * e) override; }; #endif // _KVI_TAL_GROUPBOX_H_ diff --git a/src/kvilib/tal/KviTalHBox.h b/src/kvilib/tal/KviTalHBox.h index c2c37b880..2d837454b 100644 --- a/src/kvilib/tal/KviTalHBox.h +++ b/src/kvilib/tal/KviTalHBox.h @@ -50,7 +50,7 @@ public: * \param pcName The name of the box * \return KviTalHBox */ - KviTalHBox(QWidget * pParent, char * pcName = 0); + KviTalHBox(QWidget * pParent, char * pcName = nullptr); /** * \brief Destroys an horizontal box object @@ -113,7 +113,7 @@ public: void addSpacing(int iSpace); protected: - virtual void childEvent(QChildEvent * e); + void childEvent(QChildEvent * e) override; }; #endif // _KVI_TAL_HBOX_H_ diff --git a/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.cpp b/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.cpp index c2b25cb70..e7f3ba758 100644 --- a/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.cpp +++ b/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.cpp @@ -121,5 +121,5 @@ QSize KviTalIconAndRichTextItemDelegate::sizeHint(const QStyleOptionViewItem & o if(h < m_oMinimumSize.height()) h = m_oMinimumSize.height(); - return QSize(w, h); + return { w, h }; } diff --git a/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.h b/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.h index 60581a315..cde4f1300 100644 --- a/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.h +++ b/src/kvilib/tal/KviTalIconAndRichTextItemDelegate.h @@ -58,7 +58,7 @@ public: * \param pWidget The item which we have to delegate for the paint * \return KviTalIconAndRichTextItemDelegate */ - KviTalIconAndRichTextItemDelegate(QAbstractItemView * pWidget = 0); + KviTalIconAndRichTextItemDelegate(QAbstractItemView * pWidget = nullptr); /** * \brief Destroys the icon and rich text item delegate object @@ -95,7 +95,7 @@ public: * \param index The model index for the item * \return QSize */ - QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const; + QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const override; /** * \brief Paints the view @@ -104,7 +104,7 @@ public: * \param index The model index for the item * \return void */ - void paint(QPainter * pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const; + void paint(QPainter * pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; /** * \brief Sets the default icon diff --git a/src/kvilib/tal/KviTalListWidget.h b/src/kvilib/tal/KviTalListWidget.h index 6a6de7050..5e30f2563 100644 --- a/src/kvilib/tal/KviTalListWidget.h +++ b/src/kvilib/tal/KviTalListWidget.h @@ -38,11 +38,11 @@ public: KviTalListWidget(QWidget * pParent, QString name, Qt::WindowType f = Qt::Widget); KviTalListWidget(QWidget * pParent) : QListWidget(pParent){}; - virtual ~KviTalListWidget(){}; + ~KviTalListWidget() = default; protected: - virtual bool event(QEvent * e); - virtual bool eventFilter(QObject * o, QEvent * e); + bool event(QEvent * e) override; + bool eventFilter(QObject * o, QEvent * e) override; signals: void tipRequest(QListWidgetItem *, const QPoint &); }; @@ -57,7 +57,7 @@ public: KviTalListWidgetItem(KviTalListWidget * pParent, QString & label) : QListWidgetItem(label, pParent){}; KviTalListWidget * listWidget() { return (KviTalListWidget *)QListWidgetItem::listWidget(); }; - virtual ~KviTalListWidgetItem(){}; + ~KviTalListWidgetItem() = default; }; class KVILIB_API KviTalListWidgetText : public KviTalListWidgetItem @@ -65,6 +65,7 @@ class KVILIB_API KviTalListWidgetText : public KviTalListWidgetItem public: KviTalListWidgetText(KviTalListWidget * listbox, const QString & text = QString()); KviTalListWidgetText(const QString & text = QString()); + KviTalListWidgetText(const KviTalListWidgetText &) = delete; ~KviTalListWidgetText(); int height(const KviTalListWidget *) const; @@ -78,9 +79,6 @@ public: protected: virtual void paint(QPainter *); - -private: - Q_DISABLE_COPY(KviTalListWidgetText) }; class KVILIB_API KviTalListWidgetPixmap : public KviTalListWidgetItem @@ -90,6 +88,7 @@ public: KviTalListWidgetPixmap(const QPixmap &); KviTalListWidgetPixmap(KviTalListWidget * listbox, const QPixmap &, const QString &); KviTalListWidgetPixmap(const QPixmap &, const QString &); + KviTalListWidgetPixmap(const KviTalListWidgetPixmap &) = delete; ~KviTalListWidgetPixmap(); const QPixmap * pixmap() const { return ± } @@ -107,7 +106,6 @@ protected: virtual void paint(QPainter *); private: - Q_DISABLE_COPY(KviTalListWidgetPixmap) QPixmap pm; }; diff --git a/src/kvilib/tal/KviTalTabDialog.h b/src/kvilib/tal/KviTalTabDialog.h index 349403234..c85959b7f 100644 --- a/src/kvilib/tal/KviTalTabDialog.h +++ b/src/kvilib/tal/KviTalTabDialog.h @@ -36,7 +36,7 @@ class KVILIB_API KviTalTabDialog : public QDialog { Q_OBJECT public: - KviTalTabDialog(QWidget * pParent = 0, const char * name = 0, bool bModal = false); + KviTalTabDialog(QWidget * pParent = nullptr, const char * name = nullptr, bool bModal = false); ~KviTalTabDialog(); protected: diff --git a/src/kvilib/tal/KviTalToolTip.h b/src/kvilib/tal/KviTalToolTip.h index 41f8dc54f..a7662b2c5 100644 --- a/src/kvilib/tal/KviTalToolTip.h +++ b/src/kvilib/tal/KviTalToolTip.h @@ -45,7 +45,7 @@ protected: KviTalToolTip * m_pToolTip; protected: - virtual bool eventFilter(QObject * pObject, QEvent * pEvent); + bool eventFilter(QObject * pObject, QEvent * pEvent) override; void toolTipDying(); }; diff --git a/src/kvilib/tal/KviTalVBox.h b/src/kvilib/tal/KviTalVBox.h index 1a33517e9..296bd40d7 100644 --- a/src/kvilib/tal/KviTalVBox.h +++ b/src/kvilib/tal/KviTalVBox.h @@ -50,7 +50,7 @@ public: * \param pcName The name of the box * \return KviTalVBox */ - KviTalVBox(QWidget * pParent, char * pcName = 0); + KviTalVBox(QWidget * pParent, char * pcName = nullptr); /** * \brief Destroys a vertical box object @@ -106,7 +106,7 @@ public: void addStretch(int iStretch); protected: - virtual void childEvent(QChildEvent * e); + void childEvent(QChildEvent * e) override; }; #endif // _KVI_TAL_VBOX_H_ diff --git a/src/kvilib/tal/KviTalWizard.h b/src/kvilib/tal/KviTalWizard.h index 13fd7bac2..8b50155cc 100644 --- a/src/kvilib/tal/KviTalWizard.h +++ b/src/kvilib/tal/KviTalWizard.h @@ -149,12 +149,12 @@ protected: /// /// Displays the first page if no other page is shown yet. /// - virtual void showEvent(QShowEvent * e); + void showEvent(QShowEvent * e) override; /// /// Handles redirects the close button to the "cancel" operation. /// - virtual void closeEvent(QCloseEvent * e); + void closeEvent(QCloseEvent * e) override; protected: void setCurrentPage(KviTalWizardPageData * pData); diff --git a/src/kvirc/CMakeLists.txt b/src/kvirc/CMakeLists.txt index 461229c3e..1c19f4add 100644 --- a/src/kvirc/CMakeLists.txt +++ b/src/kvirc/CMakeLists.txt @@ -270,12 +270,12 @@ endif() target_link_libraries(${KVIRC_BINARYNAME} ${KVILIB_BINARYNAME} ${LIBS}) -# Enable C++11 -set_property(TARGET ${KVIRC_BINARYNAME} PROPERTY CXX_STANDARD 11) +# Enable C++17 +set_property(TARGET ${KVIRC_BINARYNAME} PROPERTY CXX_STANDARD 17) set_property(TARGET ${KVIRC_BINARYNAME} PROPERTY CXX_STANDARD_REQUIRED ON) if(Qt5Widgets_FOUND) - qt5_use_modules(${KVIRC_BINARYNAME} ${qt5_kvirc_modules}) + target_link_libraries(${KVIRC_BINARYNAME} ${qt5_kvirc_modules}) endif() if(MINGW) @@ -300,8 +300,11 @@ if(WIN32) endif() if(WANT_STRIP) - get_target_property(KVIRC_LOCATION ${KVIRC_BINARYNAME} LOCATION) - install(CODE "exec_program(${STRIP_EXECUTABLE} ARGS -s \"${KVIRC_LOCATION}\")") + add_custom_command( + TARGET ${KVIRC_BINARYNAME} + POST_BUILD + COMMAND ${STRIP_EXECUTABLE} $<TARGET_FILE:${KVIRC_BINARYNAME}> + ) endif() # Installation directives @@ -315,13 +318,22 @@ if(APPLE) set(qtconf_dest_dir ${CMAKE_INSTALL_PREFIX}/Contents/Resources) #fixme dirty hack set(QT_PLUGINS_DIR "${Qt5Widgets_DIR}/../../../plugins") + set(QT_LIBRARY_DIR "${Qt5Widgets_DIR}/../../") + get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH) + get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/.." ABSOLUTE) - # qt4: codecs, iconengines, imageformats, phonon_backend, sqldrivers # qt5: audio, iconengines, imageformats, mediaservice, platforms, sqldrivers - install(DIRECTORY "${QT_PLUGINS_DIR}/" DESTINATION ${plugin_dest_dir} COMPONENT Runtime - FILES_MATCHING REGEX "(audio|codecs|iconengines|imageformats|mediaservice|phonon_backend|platforms|sqldrivers)/.*\\.dylib" - REGEX ".*_debug\\.dylib" EXCLUDE) + FILES_MATCHING + PATTERN "*.dSYM" EXCLUDE + PATTERN "*_debug.dylib" EXCLUDE + PATTERN "audio/*.dylib" + PATTERN "iconengines/*.dylib" + PATTERN "imageformats/*.dylib" + PATTERN "mediaservice/*.dylib" + PATTERN "platforms/*.dylib" + PATTERN "sqldrivers/*.dylib" + ) install(CODE " file(WRITE \"${qtconf_dest_dir}/qt.conf\" \"[Paths] diff --git a/src/kvirc/kernel/KviAction.cpp b/src/kvirc/kernel/KviAction.cpp index eaabeaa18..9265bcaf1 100644 --- a/src/kvirc/kernel/KviAction.cpp +++ b/src/kvirc/kernel/KviAction.cpp @@ -23,14 +23,14 @@ //============================================================================= #include "KviAction.h" -#include "KviCustomToolBar.h" -#include "KviMainWindow.h" -#include "KviIrcContext.h" #include "KviApplication.h" -#include "KviWindow.h" #include "KviChannelWindow.h" -#include "KviQueryWindow.h" +#include "KviCustomToolBar.h" +#include "KviIrcContext.h" +#include "KviMainWindow.h" #include "KviOptions.h" +#include "KviQueryWindow.h" +#include "KviWindow.h" #include <QAction> #include <QMenu> diff --git a/src/kvirc/kernel/KviAction.h b/src/kvirc/kernel/KviAction.h index 67507acc6..a371d14e6 100644 --- a/src/kvirc/kernel/KviAction.h +++ b/src/kvirc/kernel/KviAction.h @@ -82,19 +82,19 @@ public: * \brief Returns the name of the category * \return const QString & */ - const QString & name() const { return m_szName; }; + const QString & name() const { return m_szName; } /** * \brief Returns the visible name of the category * \return const QString & */ - const QString & visibleName() const { return m_szVisibleName; }; + const QString & visibleName() const { return m_szVisibleName; } /** * \brief Returns the description of the category * \return const QString & */ - const QString & description() const { return m_szDescription; }; + const QString & description() const { return m_szDescription; } }; /** @@ -200,7 +200,7 @@ protected: QString m_szName; QString m_szVisibleName; QString m_szDescription; - KviActionCategory * m_pCategory; + KviActionCategory * m_pCategory = nullptr; QString m_szBigIconId; QString m_szSmallIconId; // this is alternative to m_eSmallIcon KviIconManager::SmallIcon m_eSmallIcon; @@ -222,7 +222,7 @@ public: * \brief Returns the name of the action * \return const QString & */ - const QString & name() const { return m_szName; }; + const QString & name() const { return m_szName; } /** * \brief Returns the visible name of the action @@ -240,37 +240,37 @@ public: * \brief Returns the shortcut of the action * \return const QString & */ - const QString & keySequence() const { return m_szKeySequence; }; + const QString & keySequence() const { return m_szKeySequence; } /** * \brief Returns the id of the big icon associated to the action * \return const QString & */ - const QString & bigIconId() const { return m_szBigIconId; }; + const QString & bigIconId() const { return m_szBigIconId; } /** * \brief Returns the id of the small icon associated to the action * \return const QString & */ - const QString & smallIconId() const { return m_szSmallIconId; }; + const QString & smallIconId() const { return m_szSmallIconId; } /** * \brief Returns the category of the action * \return const QString & */ - KviActionCategory * category() const { return m_pCategory; }; + KviActionCategory * category() const { return m_pCategory; } /** * \brief Returns true if the action is enabled * \return bool */ - bool isEnabled() const { return (m_uInternalFlags & KviAction::Enabled); }; + bool isEnabled() const { return (m_uInternalFlags & KviAction::Enabled); } /** * \brief Returns the flag associated to the action * \return unsigned int */ - unsigned int flags() { return m_uFlags; }; + unsigned int flags() const { return m_uFlags; } /** * \brief Returns true if the action is user-defined @@ -316,14 +316,14 @@ public: * \brief Destroys itself. Maybe the best function in the whole APIs :) * \return void */ - void suicide() { delete this; }; + void suicide() { delete this; } protected: /** * \brief Returns true if the setup is finished * \note Called once before the FIRST button or menu item is created * \return bool */ - bool setupDone() const { return (m_uInternalFlags & KviAction::SetupDone); }; + bool setupDone() const { return (m_uInternalFlags & KviAction::SetupDone); } /** * \brief Enables or disables the action upon starting KVIrc @@ -335,7 +335,7 @@ protected: * \brief Returns the list of actions associated to the action * \return std::unordered_set<QAction *> */ - std::unordered_set<QAction *> const & actionList() const { return m_pActionList; }; + std::unordered_set<QAction *> const & actionList() const { return m_pActionList; } /** * \brief Registers the action shortcut in the application diff --git a/src/kvirc/kernel/KviActionManager.cpp b/src/kvirc/kernel/KviActionManager.cpp index 82fda3e37..8e9bb1bf9 100644 --- a/src/kvirc/kernel/KviActionManager.cpp +++ b/src/kvirc/kernel/KviActionManager.cpp @@ -68,8 +68,6 @@ KviActionManager::KviActionManager() CATEGORY(m_pCategoryTools, "tools", __tr2qs("Tools"), __tr2qs("Actions that will appear in the \"Tools\" menu")); m_bCustomizingToolBars = false; - m_pCurrentToolBar = nullptr; - m_bCoreActionsRegistered = false; } KviActionManager::~KviActionManager() diff --git a/src/kvirc/kernel/KviActionManager.h b/src/kvirc/kernel/KviActionManager.h index 8b6781ba5..a3eacdeb9 100644 --- a/src/kvirc/kernel/KviActionManager.h +++ b/src/kvirc/kernel/KviActionManager.h @@ -46,8 +46,8 @@ public: protected: static KviActionManager * m_pInstance; - KviPointerHashTable<QString, KviAction> * m_pActions; - KviPointerHashTable<QString, KviActionCategory> * m_pCategories; + KviPointerHashTable<QString, KviAction> * m_pActions = nullptr; + KviPointerHashTable<QString, KviActionCategory> * m_pCategories = nullptr; static bool m_bCustomizingToolBars; // action categories @@ -60,29 +60,29 @@ protected: static KviActionCategory * m_pCategoryTools; // internal, current toolbar to be edited (only when customizing) static KviCustomToolBar * m_pCurrentToolBar; - bool m_bCoreActionsRegistered; + bool m_bCoreActionsRegistered = false; public: static void init(); static void done(); - static KviActionManager * instance() { return m_pInstance; }; + static KviActionManager * instance() { return m_pInstance; } static void loadAllAvailableActions(); - static bool customizingToolBars() { return m_bCustomizingToolBars; }; - static KviActionCategory * categoryIrc() { return m_pCategoryIrc; }; - static KviActionCategory * categoryGeneric() { return m_pCategoryGeneric; }; - static KviActionCategory * categorySettings() { return m_pCategorySettings; }; - static KviActionCategory * categoryScripting() { return m_pCategoryScripting; }; - static KviActionCategory * categoryGUI() { return m_pCategoryGUI; }; - static KviActionCategory * categoryChannel() { return m_pCategoryChannel; }; - static KviActionCategory * categoryTools() { return m_pCategoryTools; }; + static bool customizingToolBars() { return m_bCustomizingToolBars; } + static KviActionCategory * categoryIrc() { return m_pCategoryIrc; } + static KviActionCategory * categoryGeneric() { return m_pCategoryGeneric; } + static KviActionCategory * categorySettings() { return m_pCategorySettings; } + static KviActionCategory * categoryScripting() { return m_pCategoryScripting; } + static KviActionCategory * categoryGUI() { return m_pCategoryGUI; } + static KviActionCategory * categoryChannel() { return m_pCategoryChannel; } + static KviActionCategory * categoryTools() { return m_pCategoryTools; } - KviPointerHashTable<QString, KviAction> * actions() { return m_pActions; }; + KviPointerHashTable<QString, KviAction> * actions() { return m_pActions; } KviActionCategory * category(const QString & szName); - KviPointerHashTable<QString, KviActionCategory> * categories() { return m_pCategories; }; + KviPointerHashTable<QString, KviActionCategory> * categories() { return m_pCategories; } void killAllKvsUserActions(); - static KviCustomToolBar * currentToolBar() { return m_pCurrentToolBar; }; + static KviCustomToolBar * currentToolBar() { return m_pCurrentToolBar; } KviAction * getAction(const QString & szName); void listActionsByCategory(const QString & szCatName, KviPointerList<KviAction> * pBuffer); QString nameForAutomaticAction(const QString & szTemplate); @@ -98,7 +98,7 @@ public: protected: void setCurrentToolBar(KviCustomToolBar * t); - KviAction * findAction(const QString & szName) { return m_pActions->find(szName); }; + KviAction * findAction(const QString & szName) { return m_pActions->find(szName); } void customizeToolBarsDialogCreated(); void customizeToolBarsDialogDestroyed(); void tryFindCurrentToolBar(); diff --git a/src/kvirc/kernel/KviApplication.cpp b/src/kvirc/kernel/KviApplication.cpp index d85c1f752..e3c582d50 100644 --- a/src/kvirc/kernel/KviApplication.cpp +++ b/src/kvirc/kernel/KviApplication.cpp @@ -87,8 +87,10 @@ #include "KviSignalHandler.h" #include "KviPtrListIterator.h" #include "KviIrcNetwork.h" +#include "KviRuntimeInfo.h" #include <QMenu> +#include <QPainter> #include <algorithm> #ifndef COMPILE_NO_IPC @@ -148,8 +150,8 @@ DO NOT REMOVE THEM EVEN IF THEY ARE DEFINED ALSO IN KviApplication.h #include <QDir> -#include <stdlib.h> // rand & srand -#include <time.h> // time() in srand() +#include <cstdlib> // rand & srand +#include <ctime> // time() in srand() #include <map> // std::map<> // Global application pointer @@ -448,16 +450,8 @@ void KviApplication::setup() // Script object controller //g_pScriptObjectController = new KviScriptObjectController(); gone - QString szStylesheetFile; - getGlobalKvircDirectory(szStylesheetFile, Config, "style.css"); - if(KviFileUtils::fileExists(szStylesheetFile)) - { - QString szStyleData; - KviFileUtils::readFile(szStylesheetFile, szStyleData); - szStyleData.replace("global://", m_szGlobalKvircDir); - szStyleData.replace("local://", m_szLocalKvircDir); - setStyleSheet(szStyleData); - } + // Cache the QStyle theme before it's overriden + (void)KviRuntimeInfo::qtTheme(); // create the frame window, we're almost up and running... createFrame(); @@ -1077,6 +1071,14 @@ void KviApplication::ipcMessage(char * pcMessage) szCmd.cutRight(szCmd.len() - (iIdx + 1)); pConsole->output(KVI_OUT_SYSTEMMESSAGE, __tr2qs("Remote command received (%s ...)"), szCmd.ptr()); } + if (kvi_strEqualCIN(pcMessage, "openurl ", 8)) + { + // there actually is no reliable way of raising the main window, but we try our best! +#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + SetForegroundWindow((HWND)g_pMainWindow->winId()); +#endif + g_pMainWindow->activateWindow(); + } KviKvsScript::run(pcMessage, pConsole); } #endif // COMPILE_NO_IPC diff --git a/src/kvirc/kernel/KviApplication.h b/src/kvirc/kernel/KviApplication.h index 24c16db42..a9f90d48c 100644 --- a/src/kvirc/kernel/KviApplication.h +++ b/src/kvirc/kernel/KviApplication.h @@ -68,32 +68,32 @@ class QTextCodec; class QDomElement; class QStringList; -typedef struct _KviPendingAvatarChange +struct KviPendingAvatarChange { KviConsoleWindow * pConsole; QString szRemoteUrl; QString szNick; QString szUser; QString szHost; -} KviPendingAvatarChange; +}; /** * \typedef KviNotifierMessageParam * \struct _KviNotifierMessageParam * \brief Defines a struct which holds information about the notifier message */ -typedef struct _KviNotifierMessageParam +struct KviNotifierMessageParam { KviWindow * pWindow; /**< The window where the notifier was triggered */ QString szIcon; /**< The id of the icon (channel, query, ...) */ QString szMessage; /**< The message which triggered the notifier */ unsigned int uMessageLifetime; /**< The timeout of the notifier; 0 means no hide */ -} KviNotifierMessageParam; +}; -typedef struct _KviDBusNotifierMessageQueue +struct KviDBusNotifierMessageQueue { QStringList lMessages; -} KviDBusNotifierMessageQueue; +}; #ifdef Unsorted #undef Unsorted @@ -158,18 +158,18 @@ protected: QString m_szGlobalKvircDir; QString m_szLocalKvircDir; int m_iHeartbeatTimerId; - bool m_bFirstTimeRun; + bool m_bFirstTimeRun = false; bool m_bClosingDown; #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) bool m_bPortable; #endif - KviWindow * m_pActiveWindow; + KviWindow * m_pActiveWindow = nullptr; bool m_bUpdateGuiPending; std::unordered_map<KviPendingAvatarChange *, std::unique_ptr<KviPendingAvatarChange>> m_PendingAvatarChanges; bool m_bSetupDone; KviPointerHashTable<QString, QStringList> * m_pRecentChannelDict; #ifdef COMPILE_PSEUDO_TRANSPARENCY - bool m_bUpdatePseudoTransparencyPending; + bool m_bUpdatePseudoTransparencyPending = false; #endif #ifndef COMPILE_NO_IPC KviIpcSentinel * m_pIpcSentinel; @@ -180,11 +180,8 @@ public: void setup(); // THIS SHOULD BE PRIVATE! (but is accessed from KviMain.cpp) #ifdef COMPILE_KDE_SUPPORT - void setAboutData(KAboutData * pAboutData) - { - m_pAboutData = pAboutData; - }; - KAboutData * aboutData() { return m_pAboutData; }; + void setAboutData(KAboutData * pAboutData) { m_pAboutData = pAboutData; } + KAboutData * aboutData() const { return m_pAboutData; } #endif #ifndef COMPILE_NO_IPC @@ -193,9 +190,9 @@ public: static int getGloballyUniqueId(); // returns an unique integer identifier across the application - bool firstTimeRun() const { return m_bFirstTimeRun; }; - bool kviClosingDown() const { return m_bClosingDown; }; - void setKviClosingDown() { m_bClosingDown = true; }; + bool firstTimeRun() const { return m_bFirstTimeRun; } + bool kviClosingDown() const { return m_bClosingDown; } + void setKviClosingDown() { m_bClosingDown = true; } bool supportsCompositing(); @@ -204,7 +201,7 @@ public: /* Unused - inline void emitRecentUrlsChanged() { emit(recentUrlsChanged()); }; + void emitRecentUrlsChanged() { emit(recentUrlsChanged()); } */ // KviApplication.cpp (Saving options) @@ -345,7 +342,7 @@ protected: void unregisterWindow(KviWindow * wnd); void frameDestructorCallback(); void heartbeat(kvi_time_t tNow); - virtual void timerEvent(QTimerEvent * e); + void timerEvent(QTimerEvent * e) override; private: // KviApplication_setup.cpp : Setup stuff @@ -381,7 +378,7 @@ private: #endif //COMPILE_PSEUDO_TRANSPARENCY public slots: // KviApplication.cpp : Slots - void saveConfiguration(); + void saveConfiguration() override; void updateGui(); void updatePseudoTransparency(); void restoreDefaultScript(); diff --git a/src/kvirc/kernel/KviApplication_filesystem.cpp b/src/kvirc/kernel/KviApplication_filesystem.cpp index c3fff6e62..f10f42024 100644 --- a/src/kvirc/kernel/KviApplication_filesystem.cpp +++ b/src/kvirc/kernel/KviApplication_filesystem.cpp @@ -313,7 +313,7 @@ void KviApplication::getTmpFileName(QString & szBuffer, const QString & szEnding KviQString::ensureLastCharIs(tmp, KVI_PATH_SEPARATOR_CHAR); struct timeval tmv; - kvi_gettimeofday(&tmv, nullptr); + kvi_gettimeofday(&tmv); QString szFileName = szEndingFileName.isNull() ? QString("file.tmp") : szEndingFileName; do @@ -443,7 +443,7 @@ bool KviApplication::mapImageFile(QString & szRetPath, const QString & filename) QString szBestMatch; - while(szRetPath.indexOf(KVI_PATH_SEPARATOR) != -1) + while(szRetPath.contains(KVI_PATH_SEPARATOR)) { KviQString::cutToFirst(szRetPath, KVI_PATH_SEPARATOR); diff --git a/src/kvirc/kernel/KviApplication_setup.cpp b/src/kvirc/kernel/KviApplication_setup.cpp index b3121d6be..0c030c2b0 100644 --- a/src/kvirc/kernel/KviApplication_setup.cpp +++ b/src/kvirc/kernel/KviApplication_setup.cpp @@ -37,7 +37,7 @@ #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) #include <shlwapi.h> #else -#include <stdlib.h> // for getenv() +#include <cstdlib> // for getenv() #include <unistd.h> // for symlink() <-- unused? #ifdef COMPILE_KDE_SUPPORT @@ -115,22 +115,22 @@ void KviApplication::setupUriAssociations(const QString & szProto) tmp = QString("Software\\Classes\\" + szProto).toStdWString(); SHDeleteKey(HKEY_CURRENT_USER, (LPCWSTR)tmp.c_str()); - RegCreateKeyEx(HKEY_CURRENT_USER, (LPCWSTR)tmp.c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL); + RegCreateKeyEx(HKEY_CURRENT_USER, (LPCWSTR)tmp.c_str(), 0, nullptr, 0, KEY_WRITE, nullptr, &hKey, nullptr); RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)TEXT("URL:IRC Protocol"), 16 * 2 + 1); RegSetValueEx(hKey, TEXT("URL Protocol"), 0, REG_SZ, (LPBYTE)"", 0); tmp = QString("Software\\Classes\\" + szProto + "\\DefaultIcon").toStdWString(); - RegCreateKeyEx(HKEY_CURRENT_USER, (LPCWSTR)tmp.c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL); + RegCreateKeyEx(HKEY_CURRENT_USER, (LPCWSTR)tmp.c_str(), 0, nullptr, 0, KEY_WRITE, nullptr, &hKey, nullptr); tmp = QString(szAppPath + ",0").toStdWString(); RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.c_str(), tmp.length() * 2 + 1); tmp = QString("Software\\Classes\\" + szProto + "\\Shell\\open").toStdWString(); - RegCreateKeyEx(HKEY_CURRENT_USER, (LPCWSTR)tmp.c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL); + RegCreateKeyEx(HKEY_CURRENT_USER, (LPCWSTR)tmp.c_str(), 0, nullptr, 0, KEY_WRITE, nullptr, &hKey, nullptr); tmp = __tr2qs("Open with KVIrc").toStdWString(); RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.c_str(), tmp.length() * 2 + 1); tmp = QString("Software\\Classes\\" + szProto + "\\Shell\\open\\command").toStdWString(); - RegCreateKeyEx(HKEY_CURRENT_USER, (LPCWSTR)tmp.c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL); + RegCreateKeyEx(HKEY_CURRENT_USER, (LPCWSTR)tmp.c_str(), 0, nullptr, 0, KEY_WRITE, nullptr, &hKey, nullptr); tmp = QString(szAppPath + " --external \"%1\"").toStdWString(); RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.c_str(), tmp.length() * 2 + 1); @@ -150,7 +150,7 @@ void KviApplication::setFileAssociation(const QString & szExtension, const QStri tmp = QString("Software\\Classes\\." + szExtension).toStdWString(); SHDeleteKey(HKEY_CURRENT_USER, (LPCWSTR)tmp.c_str()); - RegCreateKeyEx(HKEY_CURRENT_USER, (LPCWSTR)tmp.c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL); + RegCreateKeyEx(HKEY_CURRENT_USER, (LPCWSTR)tmp.c_str(), 0, nullptr, 0, KEY_WRITE, nullptr, &hKey, nullptr); tmp = szClassName.toStdWString(); RegSetValueEx(hKey, 0, 0, REG_SZ, (LPBYTE)tmp.c_str(), tmp.length() * 2 + 1); diff --git a/src/kvirc/kernel/KviAsynchronousConnectionData.cpp b/src/kvirc/kernel/KviAsynchronousConnectionData.cpp index 21697370a..e70cef9db 100644 --- a/src/kvirc/kernel/KviAsynchronousConnectionData.cpp +++ b/src/kvirc/kernel/KviAsynchronousConnectionData.cpp @@ -28,8 +28,6 @@ KviAsynchronousConnectionData::KviAsynchronousConnectionData() : KviHeapObject() { - m_pReconnectInfo = nullptr; - bUseLastServerInContext = false; } KviAsynchronousConnectionData::~KviAsynchronousConnectionData() diff --git a/src/kvirc/kernel/KviAsynchronousConnectionData.h b/src/kvirc/kernel/KviAsynchronousConnectionData.h index 747999b28..0c165ba99 100644 --- a/src/kvirc/kernel/KviAsynchronousConnectionData.h +++ b/src/kvirc/kernel/KviAsynchronousConnectionData.h @@ -37,7 +37,7 @@ public: public: QString szServer; - bool bUseLastServerInContext; // this is checked ONLY if szServer is empty + bool bUseLastServerInContext = false; // this is checked ONLY if szServer is empty kvi_u32_t uPort; bool bPortIsOk; bool bUseIPv6; @@ -50,7 +50,7 @@ public: QString szNick; QString szInitUMode; QString szServerId; - KviIrcServerReconnectInfo * m_pReconnectInfo; + KviIrcServerReconnectInfo * m_pReconnectInfo = nullptr; }; #endif //!_KVI_ASYNCHRONOUSCONNECTIONDATA_H_ diff --git a/src/kvirc/kernel/KviCoreActionNames.h b/src/kvirc/kernel/KviCoreActionNames.h index 75325f4ef..481cf2a1e 100644 --- a/src/kvirc/kernel/KviCoreActionNames.h +++ b/src/kvirc/kernel/KviCoreActionNames.h @@ -55,7 +55,6 @@ #define KVI_COREACTION_IRCTOOLS (KVI_COREACTION_NAME_PREFIX "irctools") #define KVI_COREACTION_IRCACTIONS (KVI_COREACTION_NAME_PREFIX "ircactions") #define KVI_COREACTION_HELPINDEX (KVI_COREACTION_NAME_PREFIX "helpindex") -#define KVI_COREACTION_KVIRCMAILINGLIST (KVI_COREACTION_NAME_PREFIX "kvircmailinglist") #define KVI_COREACTION_KVIRCHOMEPAGE (KVI_COREACTION_NAME_PREFIX "kvirchomepage") #define KVI_COREACTION_KVIRCRUHOMEPAGE (KVI_COREACTION_NAME_PREFIX "kvircruhomepage") #define KVI_COREACTION_EDITREGUSERS (KVI_COREACTION_NAME_PREFIX "editregusers") diff --git a/src/kvirc/kernel/KviCoreActions.cpp b/src/kvirc/kernel/KviCoreActions.cpp index ad445b79a..f970e5cb2 100644 --- a/src/kvirc/kernel/KviCoreActions.cpp +++ b/src/kvirc/kernel/KviCoreActions.cpp @@ -89,7 +89,7 @@ void register_core_actions(KviActionManager * m) SCRIPT_ACTION( KVI_COREACTION_SERVEROPTIONS, - "options.edit OptionsWidget_servers", + "options.edit -n OptionsWidget_servers", __tr2qs("Configure Servers..."), __tr2qs("Allows you to configure the servers and eventually to connect to them"), KviActionManager::categorySettings(), @@ -319,17 +319,6 @@ void register_core_actions(KviActionManager * m) KVI_SHORTCUTS_HELP); SCRIPT_ACTION( - KVI_COREACTION_KVIRCMAILINGLIST, - "openurl http://www.kvirc.net/?id=mailinglist", - __tr2qs("Subscribe to the Mailing List"), - __tr2qs("Allows subscribing to the KVIrc mailing list"), - KviActionManager::categoryGeneric(), - "kvi_bigicon_mailinglist.png", - KviIconManager::Message, - 0, - QString()); - - SCRIPT_ACTION( KVI_COREACTION_KVIRCHOMEPAGE, "openurl http://www.kvirc.net", __tr2qs("KVIrc WWW"), @@ -852,7 +841,7 @@ KviChangeNickAction::KviChangeNickAction(QObject * pParent) : KviSubmenuAction( pParent, QString(KVI_COREACTION_NICKNAMEMENU), - QString("dialog.textinput(\"" + __tr2qs("Change Nickname") + "\",\"" + __tr2qs("Please enter the new nickname") + "\",\"" + __tr2qs("OK") + "\",\"" + __tr2qs("Cancel") + "\"){ if($0 == 0 && $1 != \"\")nick $1; }"), + QString("dialog.textinput(\"" + __tr2qs("Change Nickname") + "\",\"" + __tr2qs("Please enter the new nickname") + "\",\"" + __tr2qs("OK") + "\",\"" + __tr2qs("Cancel") + R"("){ if($0 == 0 && $1 != "")nick $1; })"), __tr2qs("Change Nickname"), __tr2qs("Shows a popup menu that allows quickly changing the nickname"), KviActionManager::categoryIrc(), @@ -908,7 +897,7 @@ KviConnectToServerAction::KviConnectToServerAction(QObject * pParent) : KviSubmenuAction( pParent, QString(KVI_COREACTION_SERVERMENU), - QString("options.edit OptionsWidget_servers"), + QString("options.edit -n OptionsWidget_servers"), __tr2qs("Connect to"), __tr2qs("Shows a popup menu that allows quickly connecting to a server"), KviActionManager::categoryIrc(), diff --git a/src/kvirc/kernel/KviCoreActions.h b/src/kvirc/kernel/KviCoreActions.h index 2b1990c1b..ab3deef57 100644 --- a/src/kvirc/kernel/KviCoreActions.h +++ b/src/kvirc/kernel/KviCoreActions.h @@ -40,15 +40,15 @@ protected: QString m_szDisconnectString; public: - virtual bool addToPopupMenu(QMenu * pMenu); - virtual QAction * addToCustomToolBar(KviCustomToolBar * pTool); + bool addToPopupMenu(QMenu * pMenu) override; + QAction * addToCustomToolBar(KviCustomToolBar * pTool) override; protected: - virtual void setup(); - virtual void reloadImages(); - virtual void activate(); - virtual void activeContextChanged(); - virtual void activeContextStateChanged(); + void setup() override; + void reloadImages() override; + void activate() override; + void activeContextChanged() override; + void activeContextStateChanged() override; }; class KviSeparatorAction : public KviAction @@ -58,8 +58,8 @@ public: KviSeparatorAction(QObject * pParent); public: - virtual bool addToPopupMenu(QMenu * pMenu); - virtual QAction * addToCustomToolBar(KviCustomToolBar * pTool); + bool addToPopupMenu(QMenu * pMenu) override; + QAction * addToCustomToolBar(KviCustomToolBar * pTool) override; }; class QMenu; @@ -74,7 +74,7 @@ public: const QString & szScriptCode, const QString & szVisibleName, const QString & szDescription, - KviActionCategory * pCategory = NULL, + KviActionCategory * pCategory = nullptr, const QString & szBigIconId = QString(), KviIconManager::SmallIcon eSmallIcon = KviIconManager::None, unsigned int uFlags = 0); @@ -84,11 +84,11 @@ protected: QMenu * m_pPopup; protected: - virtual void setup(); + void setup() override; public: - virtual bool addToPopupMenu(QMenu * pMenu); - virtual QAction * addToCustomToolBar(KviCustomToolBar * pTool); + bool addToPopupMenu(QMenu * pMenu) override; + QAction * addToCustomToolBar(KviCustomToolBar * pTool) override; protected slots: virtual void popupAboutToShow(); virtual void popupActivated(QAction * pAction); @@ -110,8 +110,8 @@ class KviChangeNickAction : public KviSubmenuAction public: KviChangeNickAction(QObject * pParent); protected slots: - void popupAboutToShow(); - void popupActivated(QAction * pAction); + virtual void popupAboutToShow(); + virtual void popupActivated(QAction * pAction); }; class KviConnectToServerAction : public KviSubmenuAction @@ -120,8 +120,8 @@ class KviConnectToServerAction : public KviSubmenuAction public: KviConnectToServerAction(QObject * pParent); protected slots: - void popupAboutToShow(); - void popupActivated(QAction * pAction); + virtual void popupAboutToShow(); + virtual void popupActivated(QAction * pAction); }; class KviChangeUserModeAction : public KviSubmenuAction @@ -130,8 +130,8 @@ class KviChangeUserModeAction : public KviSubmenuAction public: KviChangeUserModeAction(QObject * pParent); protected slots: - void popupAboutToShow(); - void popupActivated(QAction * pAction); + virtual void popupAboutToShow(); + virtual void popupActivated(QAction * pAction); }; class KviIrcToolsAction : public KviSubmenuAction @@ -140,8 +140,8 @@ class KviIrcToolsAction : public KviSubmenuAction public: KviIrcToolsAction(QObject * pParent); protected slots: - void popupAboutToShow(); - void popupActivated(QAction * pAction); + virtual void popupAboutToShow(); + virtual void popupActivated(QAction * pAction); }; class KviIrcOperationsAction : public KviSubmenuAction @@ -150,8 +150,8 @@ class KviIrcOperationsAction : public KviSubmenuAction public: KviIrcOperationsAction(QObject * pParent); protected slots: - void popupAboutToShow(); - void popupActivated(QAction * pAction); + virtual void popupAboutToShow(); + virtual void popupActivated(QAction * pAction); }; #include "KviIrcToolBar.h" @@ -163,12 +163,12 @@ public: KviIrcContextDisplayAction(QObject * pParent); public: - virtual bool addToPopupMenu(QMenu * pMenu); - virtual QAction * addToCustomToolBar(KviCustomToolBar * pTool); - virtual void activeContextStateChanged(); - virtual void activeContextChanged(); - virtual void setEnabled(bool); - virtual void setup(); + bool addToPopupMenu(QMenu * pMenu) override; + QAction * addToCustomToolBar(KviCustomToolBar * pTool) override; + void activeContextStateChanged() override; + void activeContextChanged() override; + void setEnabled(bool) override; + void setup() override; }; class KviGoAwayAction : public KviKvsAction @@ -182,14 +182,14 @@ protected: QString m_szBackString; public: - virtual bool addToPopupMenu(QMenu * pMenu); - virtual QAction * addToCustomToolBar(KviCustomToolBar * pTool); + bool addToPopupMenu(QMenu * pMenu) override; + QAction * addToCustomToolBar(KviCustomToolBar * pTool) override; protected: - virtual void setup(); - virtual void reloadImages(); - virtual void activeContextChanged(); - virtual void activeContextStateChanged(); + void setup() override; + void reloadImages() override; + void activeContextChanged() override; + void activeContextStateChanged() override; }; #endif //_KVI_COREACTIONS_H_ diff --git a/src/kvirc/kernel/KviCustomToolBarDescriptor.cpp b/src/kvirc/kernel/KviCustomToolBarDescriptor.cpp index 7ff3192a6..b5c8a8ec2 100644 --- a/src/kvirc/kernel/KviCustomToolBarDescriptor.cpp +++ b/src/kvirc/kernel/KviCustomToolBarDescriptor.cpp @@ -23,6 +23,8 @@ //============================================================================= #include "KviCustomToolBarDescriptor.h" + +#include <utility> #include "KviCustomToolBar.h" #include "KviConfigurationFile.h" #include "KviAction.h" @@ -32,14 +34,12 @@ #include "KviKvsScript.h" #include "KviWindow.h" -KviCustomToolBarDescriptor::KviCustomToolBarDescriptor(const QString & szId, const QString & szLabelCode) +KviCustomToolBarDescriptor::KviCustomToolBarDescriptor(QString szId, const QString & szLabelCode) + : m_szId(std::move(szId)) { m_iInternalId = g_pApp->getGloballyUniqueId(); - m_szId = szId; m_pActions = new KviPointerList<QString>; m_pActions->setAutoDelete(true); - m_pToolBar = nullptr; - m_bVisibleAtStartup = false; createLabelScript(szLabelCode); } @@ -66,7 +66,7 @@ const QString & KviCustomToolBarDescriptor::label() return m_szParsedLabel; } -const QString & KviCustomToolBarDescriptor::labelCode() +const QString & KviCustomToolBarDescriptor::labelCode() const { return m_pLabelScript->code(); } @@ -205,13 +205,9 @@ bool KviCustomToolBarDescriptor::load(KviConfigurationFile * cfg) tmp.setNum(i); QString * p = new QString(cfg->readEntry(tmp)); if(p->isEmpty()) - { delete p; - } else - { m_pActions->append(p); - } } return true; } diff --git a/src/kvirc/kernel/KviCustomToolBarDescriptor.h b/src/kvirc/kernel/KviCustomToolBarDescriptor.h index 8df6a505c..7b68cce1d 100644 --- a/src/kvirc/kernel/KviCustomToolBarDescriptor.h +++ b/src/kvirc/kernel/KviCustomToolBarDescriptor.h @@ -25,11 +25,11 @@ //============================================================================= #include "kvi_settings.h" -#include "KviQString.h" #include "KviPointerList.h" +#include "KviQString.h" -class KviCustomToolBar; class KviConfigurationFile; +class KviCustomToolBar; class KviKvsScript; class KVIRC_API KviCustomToolBarDescriptor @@ -38,7 +38,7 @@ class KVIRC_API KviCustomToolBarDescriptor friend class KviCustomToolBarManager; protected: - KviCustomToolBarDescriptor(const QString & szId, const QString & szLabelCode); + KviCustomToolBarDescriptor(QString szId, const QString & szLabelCode); public: ~KviCustomToolBarDescriptor(); @@ -48,26 +48,26 @@ protected: QString m_szIconId; QString m_szParsedLabel; KviPointerList<QString> * m_pActions; - KviCustomToolBar * m_pToolBar; + KviCustomToolBar * m_pToolBar = nullptr; int m_iInternalId; - bool m_bVisibleAtStartup; - KviKvsScript * m_pLabelScript; + bool m_bVisibleAtStartup = false; + KviKvsScript * m_pLabelScript = nullptr; public: - const QString & iconId() { return m_szIconId; }; + const QString & iconId() const { return m_szIconId; } const QString & label(); - const QString & labelCode(); - const QString & id() { return m_szId; }; - int internalId() { return m_iInternalId; }; // useful only for KviMainWindow - KviCustomToolBar * toolBar() { return m_pToolBar; }; + const QString & labelCode() const; + const QString & id() const { return m_szId; } + int internalId() const { return m_iInternalId; } // useful only for KviMainWindow + KviCustomToolBar * toolBar() const { return m_pToolBar; } KviCustomToolBar * createToolBar(); - void setIconId(const QString & szIconId) { m_szIconId = szIconId; }; + void setIconId(const QString & szIconId) { m_szIconId = szIconId; } bool addAction(const QString & szAction); bool removeAction(const QString & szAction); bool removeAction(unsigned int iAction); void clear(); void rename(const QString & szNewName); - KviPointerList<QString> * actions() { return m_pActions; }; + KviPointerList<QString> * actions() const { return m_pActions; } void updateToolBar(); protected: diff --git a/src/kvirc/kernel/KviCustomToolBarManager.cpp b/src/kvirc/kernel/KviCustomToolBarManager.cpp index 9b5c68808..8918985fe 100644 --- a/src/kvirc/kernel/KviCustomToolBarManager.cpp +++ b/src/kvirc/kernel/KviCustomToolBarManager.cpp @@ -71,24 +71,18 @@ QString KviCustomToolBarManager::idForNewToolBar(const QString & szTemplate) { QString s; QString szTT = szTemplate.toLower(); - szTT.remove(" "); + szTT.remove(' '); szTT.remove("$tr"); - szTT.remove("("); - szTT.remove(")"); - szTT.remove("\""); - int idx = 0; - for(;;) + szTT.remove('('); + szTT.remove(')'); + szTT.remove('"'); + for(int idx = 0;; idx++) { s = szTT; if(idx > 0) - { - QString tmp; - tmp.setNum(idx); - s += tmp; - } + s += QString::number(idx); if(!m_pDescriptors->find(s)) return s; - idx++; } return s; } @@ -160,7 +154,7 @@ int KviCustomToolBarManager::visibleToolBarCount() KviPointerHashTableIterator<QString, KviCustomToolBarDescriptor> it(*m_pDescriptors); while(KviCustomToolBarDescriptor * d = it.current()) { - if(d->toolBar() != nullptr) + if(d->toolBar()) cnt++; ++it; } diff --git a/src/kvirc/kernel/KviCustomToolBarManager.h b/src/kvirc/kernel/KviCustomToolBarManager.h index d60ce2bb3..ad19e8265 100644 --- a/src/kvirc/kernel/KviCustomToolBarManager.h +++ b/src/kvirc/kernel/KviCustomToolBarManager.h @@ -43,20 +43,20 @@ protected: protected: static KviCustomToolBarManager * m_pInstance; - KviPointerHashTable<QString, KviCustomToolBarDescriptor> * m_pDescriptors; + KviPointerHashTable<QString, KviCustomToolBarDescriptor> * m_pDescriptors = nullptr; public: - static KviCustomToolBarManager * instance() { return m_pInstance; }; + static KviCustomToolBarManager * instance() { return m_pInstance; } static void init(); static void done(); void clear(); - int descriptorCount() { return m_pDescriptors->count(); }; + int descriptorCount() const { return m_pDescriptors->count(); } int visibleToolBarCount(); QString idForNewToolBar(const QString & szTemplate); - KviPointerHashTable<QString, KviCustomToolBarDescriptor> * descriptors() { return m_pDescriptors; }; + KviPointerHashTable<QString, KviCustomToolBarDescriptor> * descriptors() const { return m_pDescriptors; } KviCustomToolBar * firstExistingToolBar(); KviCustomToolBarDescriptor * create(const QString & szId, const QString & szLabelCode); - KviCustomToolBarDescriptor * find(const QString & szId) { return m_pDescriptors->find(szId); }; + KviCustomToolBarDescriptor * find(const QString & szId) { return m_pDescriptors->find(szId); } KviCustomToolBarDescriptor * findDescriptorByInternalId(int id); void updateVisibleToolBars(); void createToolBarsVisibleAtStartup(); diff --git a/src/kvirc/kernel/KviDefaultScript.cpp b/src/kvirc/kernel/KviDefaultScript.cpp index abe08a8d7..c4c010319 100644 --- a/src/kvirc/kernel/KviDefaultScript.cpp +++ b/src/kvirc/kernel/KviDefaultScript.cpp @@ -46,8 +46,6 @@ unsigned int KviDefaultScriptManager::m_uCount = 0; KviDefaultScriptManager::KviDefaultScriptManager() : QObject() { - m_bNoNeedToRestore = false; - // Check if versions' file exists in personal settings QString szLocal; g_pApp->getLocalKvircDirectory(szLocal, KviApplication::Config, "default.kvc"); @@ -60,8 +58,6 @@ KviDefaultScriptManager::KviDefaultScriptManager() QString szGlobal; g_pApp->getGlobalKvircDirectory(szGlobal, KviApplication::DefScript, "default.kvc"); QFile::copy(szGlobal, szLocal); - - m_bConfigFileMissing = false; } else { @@ -69,10 +65,6 @@ KviDefaultScriptManager::KviDefaultScriptManager() m_bConfigFileMissing = true; } } - else - { - m_bConfigFileMissing = false; - } } KviDefaultScriptManager::~KviDefaultScriptManager() @@ -141,7 +133,7 @@ void KviDefaultScriptManager::restore() void KviDefaultScriptManager::restoreInternal() { - QString szConfig, szTmp; + QString szConfig; g_pApp->getGlobalKvircDirectory(szConfig, KviApplication::DefScript, "default.kvc"); KviConfigurationFile oConfig(szConfig, KviConfigurationFile::Read); @@ -223,15 +215,13 @@ void KviDefaultScriptManager::restoreInternal() bool KviDefaultScriptManager::compareVersions(QString & szConfig, QString * pszError) { - QString szTmp, szTmp2; - if(pszError) *pszError = ""; KviConfigurationFile oConfig(szConfig, KviConfigurationFile::Read); - szTmp = "Date"; - szTmp2 = oConfig.readEntry(szTmp); + QString szTmp = "Date"; + QString szTmp2 = oConfig.readEntry(szTmp); QDate cfgDate = QDate::fromString(szTmp2, "yyyy-MM-dd"); QDate userDate = QDate::fromString(m_szDate, "yyyy-MM-dd"); @@ -365,9 +355,7 @@ void KviDefaultScriptManager::save(const QString & szConfigFile) void KviDefaultScriptManager::saveInternal(KviConfigurationFile * pCfg) { - QString szTmp; - - szTmp = "Version"; + QString szTmp = "Version"; pCfg->writeEntry(szTmp, m_szVersion); szTmp = "Date"; diff --git a/src/kvirc/kernel/KviDefaultScript.h b/src/kvirc/kernel/KviDefaultScript.h index a5d8c064d..3fc658e9f 100644 --- a/src/kvirc/kernel/KviDefaultScript.h +++ b/src/kvirc/kernel/KviDefaultScript.h @@ -32,11 +32,11 @@ #include "kvi_settings.h" -#include <QObject> #include <QDialog> +#include <QObject> -class QGroupBox; class QCheckBox; +class QGroupBox; class KviConfigurationFile; class KviDefaultScriptDialog; @@ -62,9 +62,9 @@ public: private: static KviDefaultScriptManager * m_pSelf; static unsigned int m_uCount; - bool m_bNoNeedToRestore; - bool m_bConfigFileMissing; - KviDefaultScriptDialog * m_pDialog; + bool m_bNoNeedToRestore = false; + bool m_bConfigFileMissing = false; + KviDefaultScriptDialog * m_pDialog = nullptr; QString m_szVersion; QString m_szDate; QString m_szAction; @@ -99,7 +99,7 @@ public: * \brief Returns the number of instances of the class * \return unsigned int */ - unsigned int count() { return m_uCount; }; + unsigned int count() const { return m_uCount; } /** * \brief Checks if the local defscript is up to date @@ -238,7 +238,7 @@ protected slots: * Called when the user clicks on 'Ok' * \return void */ - virtual void accept(); + void accept() override; /** * \brief Rejects the dialog @@ -247,7 +247,7 @@ protected slots: * decoration or pressing ESC * \return void */ - virtual void reject(); + void reject() override; }; #endif // _KVI_DEFAULTSCRIPT_H_ diff --git a/src/kvirc/kernel/KviFileTransfer.cpp b/src/kvirc/kernel/KviFileTransfer.cpp index 6dcbc1235..1605538c1 100644 --- a/src/kvirc/kernel/KviFileTransfer.cpp +++ b/src/kvirc/kernel/KviFileTransfer.cpp @@ -38,7 +38,6 @@ static KviFileTransferManager * g_pFileTransferManager = nullptr; KviFileTransferManager::KviFileTransferManager() : QObject() { - m_pTransferWindow = nullptr; } KviFileTransferManager::~KviFileTransferManager() @@ -49,9 +48,7 @@ KviFileTransferManager::~KviFileTransferManager() KviFileTransferManager * KviFileTransferManager::instance() { if(!g_pFileTransferManager) - { g_pFileTransferManager = new KviFileTransferManager(); - } return g_pFileTransferManager; } @@ -123,7 +120,6 @@ void KviFileTransferManager::unregisterTransfer(KviFileTransfer * t) KviFileTransfer::KviFileTransfer() : QObject() { - m_pDisplayItem = nullptr; m_iId = g_pApp->getGloballyUniqueId(); manager()->registerTransfer(this); } @@ -148,12 +144,12 @@ void KviFileTransfer::invokeTransferWindow(bool bCreateMinimized, bool bNoRaise) QString KviFileTransfer::localFileName() { - return QString(); + return {}; } QString KviFileTransfer::retryCommand() { - return QString(); + return {}; } bool KviFileTransfer::terminated() @@ -163,7 +159,7 @@ bool KviFileTransfer::terminated() QString KviFileTransfer::tipText() { - return QString(); + return {}; } int KviFileTransfer::displayHeight(int iLineSpacing) diff --git a/src/kvirc/kernel/KviFileTransfer.h b/src/kvirc/kernel/KviFileTransfer.h index 7fa0a1012..d764468fb 100644 --- a/src/kvirc/kernel/KviFileTransfer.h +++ b/src/kvirc/kernel/KviFileTransfer.h @@ -50,18 +50,18 @@ public: protected: std::vector<KviFileTransfer *> m_pTransferList; - KviWindow * m_pTransferWindow; + KviWindow * m_pTransferWindow = nullptr; protected: static void cleanup(); void registerTransfer(KviFileTransfer * t); void unregisterTransfer(KviFileTransfer * t); - void setTransferWindow(KviWindow * wnd) { m_pTransferWindow = wnd; }; + void setTransferWindow(KviWindow * wnd) { m_pTransferWindow = wnd; } public: // might be zero! - KviWindow * transferWindow() { return m_pTransferWindow; }; + KviWindow * transferWindow() const { return m_pTransferWindow; } static KviFileTransferManager * instance(); - std::vector<KviFileTransfer *> transferList() { return m_pTransferList; }; + std::vector<KviFileTransfer *> transferList() const { return m_pTransferList; } void invokeTransferWindow(bool bCreateMinimized = false, bool bNoRaise = false); void killAllTransfers(); void killTerminatedTransfers(); @@ -83,19 +83,19 @@ public: protected: int m_iId; - KviTalTableWidgetItemEx * m_pDisplayItem; + KviTalTableWidgetItemEx * m_pDisplayItem = nullptr; public: // This is called by KviFileTransferItem at any time - void setDisplayItem(KviTalTableWidgetItemEx * i) { m_pDisplayItem = i; }; - int id() { return m_iId; }; + void setDisplayItem(KviTalTableWidgetItemEx * i) { m_pDisplayItem = i; } + int id() const { return m_iId; } // this is just a convenience function : it's equivalent to !active() bool terminated(); // This may be used to invoke the transfer window void invokeTransferWindow(bool bCreateMinimized = false, bool bNoRaise = false); - KviFileTransferManager * manager() { return KviFileTransferManager::instance(); }; + KviFileTransferManager * manager() const { return KviFileTransferManager::instance(); } // this returns the pointer to the transfer window : may be 0! - KviWindow * transferWindow() { return manager()->transferWindow(); }; + KviWindow * transferWindow() const { return manager()->transferWindow(); } // this returns transferWindow() if not 0, otherwise the application's active window KviWindow * outputWindow(); diff --git a/src/kvirc/kernel/KviHtmlGenerator.cpp b/src/kvirc/kernel/KviHtmlGenerator.cpp index d43bdcd5d..0dd94895a 100644 --- a/src/kvirc/kernel/KviHtmlGenerator.cpp +++ b/src/kvirc/kernel/KviHtmlGenerator.cpp @@ -95,7 +95,10 @@ namespace KviHtmlGenerator if(uCurFore != Foreground) { szResult.append("<span style=\"color:"); - szResult.append(KVI_OPTION_MIRCCOLOR(uCurFore).name()); + if(uCurFore == Background) // this is the result of reverse + szResult.append(getMircColor(KviControlCodes::White).name()); + else + szResult.append(getMircColor(uCurFore).name()); bOpened = true; } @@ -110,7 +113,10 @@ namespace KviHtmlGenerator { szResult.append(";background-color:"); } - szResult.append(KVI_OPTION_MIRCCOLOR(uCurBack).name()); + if(uCurBack == Foreground) // this is the result of reverse + szResult.append(getMircColor(KviControlCodes::Black).name()); + else + szResult.append(getMircColor(uCurBack).name()); } if(bCurUnderline) @@ -183,9 +189,7 @@ namespace KviHtmlGenerator } case KviControlCodes::Reverse: { - char cAuxBack = uCurBack; - uCurBack = uCurFore; - uCurFore = cAuxBack; + std::swap(uCurFore, uCurBack); ++uIdx; break; } @@ -289,7 +293,7 @@ namespace KviHtmlGenerator if(uCurBack != Background) { szResult.append("\" style=\"background-color:"); - szResult.append(KVI_OPTION_MIRCCOLOR(uCurBack).name()); + szResult.append(getMircColor(uCurBack).name()); } szResult.append("\" />"); } @@ -331,7 +335,7 @@ namespace KviHtmlGenerator if(uCurBack != Background) { szResult.append("\" style=\"background-color:"); - szResult.append(KVI_OPTION_MIRCCOLOR(uCurBack).name()); + szResult.append(getMircColor(uCurBack).name()); } szResult.append("\" />"); } diff --git a/src/kvirc/kernel/KviIconManager.cpp b/src/kvirc/kernel/KviIconManager.cpp index 7a4a65afd..da2489418 100644 --- a/src/kvirc/kernel/KviIconManager.cpp +++ b/src/kvirc/kernel/KviIconManager.cpp @@ -32,14 +32,14 @@ #include "KviFileUtils.h" #include "KviOptions.h" -#include <QLayout> -#include <QLabel> -#include <QCursor> -#include <QEvent> #include <QCloseEvent> -#include <QIcon> +#include <QCursor> #include <QDir> #include <QDrag> +#include <QEvent> +#include <QIcon> +#include <QLabel> +#include <QLayout> #include <QMimeData> /* @@ -420,16 +420,11 @@ static const char * g_szIconNames[KviIconManager::IconCount] = { "newproxy", // 336 "actioncrypted", // 337 "topiccrypted", // 338 - "ctcpcrypted" // 339 + "ctcpcrypted", // 339 + "ownaction", // 340 + "ownactioncrypted" // 341 }; -KviIconWidget::KviIconWidget() - : QWidget(nullptr) -{ - setObjectName("global_icon_widget"); - init(); -} - KviIconWidget::KviIconWidget(QWidget * pPar) : QWidget(pPar) { @@ -447,20 +442,19 @@ void KviIconWidget::init() iRows++; QGridLayout * pLayout = new QGridLayout(this); - int i; - for(i = 0; i < 20; i++) + for(int i = 0; i < 20; i++) { KviCString szTmp(KviCString::Format, "%d", i); QLabel * pLabel = new QLabel(szTmp.ptr(), this); pLayout->addWidget(pLabel, 0, i + 1); } - for(i = 0; i < iRows; i++) + for(int i = 0; i < iRows; i++) { KviCString szTmp(KviCString::Format, "%d", i * 20); QLabel * pLabel = new QLabel(szTmp.ptr(), this); pLayout->addWidget(pLabel, i + 1, 0); } - for(i = 0; i < KviIconManager::IconCount; i++) + for(int i = 0; i < KviIconManager::IconCount; i++) { KviCString szTmp(KviCString::Format, "%d", i); QLabel * pLabel = new QLabel(this); @@ -541,19 +535,11 @@ void KviCachedPixmap::updateLastAccessTime() KviIconManager::KviIconManager() { - for(int i = 0; i < IconCount; i++) - m_smallIcons[i] = nullptr; - initQResourceBackend(); m_pCachedImages = new KviPointerHashTable<QString, KviCachedPixmap>(21, true); m_pCachedImages->setAutoDelete(true); - m_uCacheTotalSize = 0; - m_uCacheMaxSize = 1024 * 1024; // 1 MB - - m_pIconWidget = nullptr; - QString szBuffer; // Load the userchanstate image @@ -562,8 +548,6 @@ KviIconManager::KviIconManager() g_pApp->findImage(szBuffer, KVI_ACTIVITYMETER_IMAGE_NAME); g_pActivityMeterPixmap = new QPixmap(szBuffer); - - m_pIconNames = nullptr; } KviIconManager::~KviIconManager() @@ -1630,6 +1614,12 @@ KviIconManager::SmallIcon KviIconManager::iconName(int iIcon) case 339: return KviIconManager::CtcpCrypted; break; + case 340: + return KviIconManager::OwnAction; + break; + case 341: + return KviIconManager::OwnActionCrypted; + break; case 0: case KviIconManager::IconCount: default: @@ -1976,7 +1966,7 @@ QPixmap * KviIconManager::loadSmallIcon(int iIdx) } #ifdef __GNUC__ -#warning IMPLEMENT CLEANUP +//#warning IMPLEMENT CLEANUP #endif /* void KviIconManager::cacheCleanup() diff --git a/src/kvirc/kernel/KviIconManager.h b/src/kvirc/kernel/KviIconManager.h index 9d2b28ad3..de81a7a36 100644 --- a/src/kvirc/kernel/KviIconManager.h +++ b/src/kvirc/kernel/KviIconManager.h @@ -32,15 +32,17 @@ */ #include "kvi_settings.h" -#include "KviCString.h" #include "KviAvatar.h" -#include "KviTimeUtils.h" +#include "KviCString.h" #include "KviPointerHashTable.h" +#include "KviTimeUtils.h" -#include <QPixmap> #include <QObject> +#include <QPixmap> #include <QWidget> +#include <array> + #define KVI_BIGICON_DISCONNECTED "kvi_bigicon_disconnected.png" #define KVI_BIGICON_CONNECTING "kvi_bigicon_connecting.png" #define KVI_BIGICON_CONNECTED "kvi_bigicon_connected.png" @@ -106,7 +108,7 @@ public: private: QString m_szPath; kvi_time_t m_tLastAccess; - QPixmap * m_pPixmap; + QPixmap * m_pPixmap = nullptr; unsigned int m_uSize; public: @@ -114,25 +116,25 @@ public: * \brief Returns the image * \return QPixmap * */ - QPixmap * pixmap() { return m_pPixmap; }; + QPixmap * pixmap() const { return m_pPixmap; } /** * \brief Returns the path of the image * \return const QString & */ - const QString & path() { return m_szPath; }; + const QString & path() const { return m_szPath; } /** * \brief Returns the size of the image * \return unsigned int */ - unsigned int size() { return m_uSize; }; + unsigned int size() const { return m_uSize; } /** * \brief Returns the time the image was last accessed * \return kvi_time_t */ - kvi_time_t lastAccessTime() { return m_tLastAccess; }; + kvi_time_t lastAccessTime() const { return m_tLastAccess; } /** * \brief Updates the time the image was last accessed @@ -506,7 +508,9 @@ public: ActionCrypted = 337, TopicCrypted = 338, CtcpCrypted = 339, - IconCount = 340 + OwnAction = 340, + OwnActionCrypted = 341, + IconCount = 342 }; /** @@ -521,12 +525,12 @@ public: ~KviIconManager(); private: - QPixmap * m_smallIcons[IconCount]; - KviIconWidget * m_pIconWidget; - KviPointerHashTable<QString, KviCachedPixmap> * m_pCachedImages; - KviPointerHashTable<QString, int> * m_pIconNames; - unsigned int m_uCacheTotalSize; - unsigned int m_uCacheMaxSize; + std::array<QPixmap *,IconCount> m_smallIcons = { { nullptr } }; + KviIconWidget * m_pIconWidget = nullptr; + KviPointerHashTable<QString, KviCachedPixmap> * m_pCachedImages = nullptr; + KviPointerHashTable<QString, int> * m_pIconNames = nullptr; + unsigned int m_uCacheTotalSize = 0; + unsigned int m_uCacheMaxSize = 1024 * 1024; // 1 MiB public: /** @@ -541,7 +545,7 @@ public: * * \return QPixmap * */ - QPixmap * getImage(const QString & szId, bool bCanBeNumber = true, QString * pRetPath = 0); + QPixmap * getImage(const QString & szId, bool bCanBeNumber = true, QString * pRetPath = nullptr); /** * \brief Returns the cached pixmap of the image @@ -573,8 +577,8 @@ public: QPixmap * getPixmap(const QString & szName) { KviCachedPixmap * pPix = getPixmapWithCache(szName); - return pPix ? pPix->pixmap() : 0; - }; + return pPix ? pPix->pixmap() : nullptr; + } /** * \brief Returns the big icon @@ -592,7 +596,7 @@ public: * is returned * \return QPixmap * */ - QPixmap * getSmallIcon(SmallIcon eIcon) { return eIcon < IconCount ? (m_smallIcons[eIcon] ? m_smallIcons[eIcon] : loadSmallIcon(eIcon)) : 0; }; + QPixmap * getSmallIcon(SmallIcon eIcon) { return eIcon < IconCount ? (m_smallIcons[eIcon] ? m_smallIcons[eIcon] : loadSmallIcon(eIcon)) : nullptr; } /** * \brief Returns the small icon @@ -601,7 +605,7 @@ public: * is returned. This is provided for convenience * \return QPixmap * */ - QPixmap * getSmallIcon(int iIcon) { return iIcon < IconCount ? (m_smallIcons[iIcon] ? m_smallIcons[iIcon] : loadSmallIcon(iIcon)) : 0; }; + QPixmap * getSmallIcon(int iIcon) { return iIcon < IconCount ? (m_smallIcons[iIcon] ? m_smallIcons[iIcon] : loadSmallIcon(iIcon)) : nullptr; } /** * \brief Returns the name of the small icon @@ -709,16 +713,10 @@ class KVIRC_API KviIconWidget : public QWidget public: /** * \brief Constructs the icon table widget - * \return KviIconWidget - */ - KviIconWidget(); - - /** - * \brief Constructs the icon table widget * \param pPar The parent object * \return KviIconWidget */ - KviIconWidget(QWidget * pPar); + KviIconWidget(QWidget * pPar = nullptr); /** * \brief Destroys the icon table widget @@ -732,8 +730,8 @@ protected: */ void init(); - virtual void closeEvent(QCloseEvent * pEvent); - virtual bool eventFilter(QObject * pObject, QEvent * pEvent); + void closeEvent(QCloseEvent * pEvent) override; + bool eventFilter(QObject * pObject, QEvent * pEvent) override; signals: /** * \brief Emitted when we close the table widget diff --git a/src/kvirc/kernel/KviInternalCommand.cpp b/src/kvirc/kernel/KviInternalCommand.cpp index 577ffc75d..99fe63623 100644 --- a/src/kvirc/kernel/KviInternalCommand.cpp +++ b/src/kvirc/kernel/KviInternalCommand.cpp @@ -71,10 +71,9 @@ static const char * internalCommandTable[KVI_NUM_INTERNAL_COMMANDS] = { "openurl http://www.kvirc.net", "list.open", "channelsjoin.open", - "options.edit OptionsWidget_servers", + "options.edit -n OptionsWidget_servers", "url.list", "openurl http://www.kvirc.net/?id=themes", - "openurl http://www.kvirc.net/?id=mailinglist", "openurl https://github.com/kvirc/KVIrc/issues", "raweditor.open", "popupeditor.open", @@ -88,8 +87,6 @@ static const char * internalCommandTable[KVI_NUM_INTERNAL_COMMANDS] = { const char * kvi_getInternalCommandBuffer(int idx) { if(idx > 0 && idx < KVI_NUM_INTERNAL_COMMANDS) - { return internalCommandTable[idx]; - } return internalCommandTable[0]; } diff --git a/src/kvirc/kernel/KviInternalCommand.h b/src/kvirc/kernel/KviInternalCommand.h index b124c462a..f253a8118 100644 --- a/src/kvirc/kernel/KviInternalCommand.h +++ b/src/kvirc/kernel/KviInternalCommand.h @@ -50,17 +50,16 @@ #define KVI_INTERNALCOMMAND_SERVERSJOIN_OPEN 19 #define KVI_INTERNALCOMMAND_URL_OPEN 20 // Unused #define KVI_INTERNALCOMMAND_OPENURL_KVIRC_THEMES 21 -#define KVI_INTERNALCOMMAND_OPENURL_KVIRC_MAILINGLIST 22 -#define KVI_INTERNALCOMMAND_OPENURL_KVIRC_BUGTRACK 23 -#define KVI_INTERNALCOMMAND_RAWEDITOR_OPEN 24 // Unused -#define KVI_INTERNALCOMMAND_POPUPEDITOR_OPEN 25 // Unused -#define KVI_INTERNALCOMMAND_EXECUTE_SCRIPT_FROM_DISK 26 // Unused -#define KVI_INTERNALCOMMAND_ACTIONEDITOR_OPEN 27 // Unused -#define KVI_INTERNALCOMMAND_QUIT 28 -#define KVI_INTERNALCOMMAND_KVIRC_HOMEPAGE_RU 29 -#define KVI_INTERNALCOMMAND_JOIN_KVIRC_ON_FREENODE 30 +#define KVI_INTERNALCOMMAND_OPENURL_KVIRC_BUGTRACK 22 +#define KVI_INTERNALCOMMAND_RAWEDITOR_OPEN 23 // Unused +#define KVI_INTERNALCOMMAND_POPUPEDITOR_OPEN 24 // Unused +#define KVI_INTERNALCOMMAND_EXECUTE_SCRIPT_FROM_DISK 25 // Unused +#define KVI_INTERNALCOMMAND_ACTIONEDITOR_OPEN 26 // Unused +#define KVI_INTERNALCOMMAND_QUIT 27 +#define KVI_INTERNALCOMMAND_KVIRC_HOMEPAGE_RU 28 +#define KVI_INTERNALCOMMAND_JOIN_KVIRC_ON_FREENODE 29 -#define KVI_NUM_INTERNAL_COMMANDS 31 +#define KVI_NUM_INTERNAL_COMMANDS 30 extern KVIRC_API const char * kvi_getInternalCommandBuffer(int idx); diff --git a/src/kvirc/kernel/KviIpcSentinel.cpp b/src/kvirc/kernel/KviIpcSentinel.cpp index 44b66cd7f..7853f8731 100644 --- a/src/kvirc/kernel/KviIpcSentinel.cpp +++ b/src/kvirc/kernel/KviIpcSentinel.cpp @@ -41,8 +41,8 @@ #include <unistd.h> // for getuid, getpid #include <sys/types.h> // for getuid, getpid -#include <string.h> // for memcpy -#include <stdlib.h> // for malloc +#include <cstring> // for memcpy +#include <cstdlib> // for malloc #include <QX11Info> @@ -123,7 +123,7 @@ static Window kvi_x11_findIpcSentinel(Window win) Window found = 0; - for(int i = nChildren - 1; (!found) && (i >= 0); i--) + for(size_t i = 0; !found && i < nChildren; ++i) found = kvi_x11_findIpcSentinel(children[i]); if(children) @@ -287,16 +287,16 @@ bool KviIpcSentinel::x11Event(XEvent * e) extern "C" { -typedef struct +struct fake_xcb_generic_event_t { kvi_u8_t response_type; kvi_u8_t pad0; kvi_u16_t sequence; kvi_u32_t pad[7]; kvi_u32_t full_sequence; -} fake_xcb_generic_event_t; +}; -typedef struct xcb_property_notify_event_t +struct fake_xcb_property_notify_event_t { kvi_u8_t response_type; kvi_u8_t pad0; @@ -304,7 +304,7 @@ typedef struct xcb_property_notify_event_t kvi_u32_t window; kvi_u32_t atom; // .. other stuff follows, but we don't care -} fake_xcb_property_notify_event_t; +}; #define FAKE_XCB_PROPERTY_NOTIFY 28 } diff --git a/src/kvirc/kernel/KviIpcSentinel.h b/src/kvirc/kernel/KviIpcSentinel.h index 0c3cf6c83..273ffa6b9 100644 --- a/src/kvirc/kernel/KviIpcSentinel.h +++ b/src/kvirc/kernel/KviIpcSentinel.h @@ -55,7 +55,7 @@ protected: // protected members bool x11GetRemoteMessage(); #endif //!COMPILE_X11_SUPPORT -virtual bool nativeEvent(const QByteArray & id, void * msg, long * res); + bool nativeEvent(const QByteArray & id, void * msg, long * res) override; }; #endif //!COMPILE_NO_IPC diff --git a/src/kvirc/kernel/KviIrcConnection.cpp b/src/kvirc/kernel/KviIrcConnection.cpp index d847f10ae..391544d6a 100644 --- a/src/kvirc/kernel/KviIrcConnection.cpp +++ b/src/kvirc/kernel/KviIrcConnection.cpp @@ -72,18 +72,15 @@ #include <QtGlobal> #include <algorithm> +#include <memory> extern KVIRC_API KviIrcServerDataBase * g_pServerDataBase; extern KVIRC_API KviProxyDataBase * g_pProxyDataBase; KviIrcConnection::KviIrcConnection(KviIrcContext * pContext, KviIrcConnectionTarget * pTarget, KviUserIdentity * pIdentity) - : QObject() + : QObject(), m_pContext(pContext), m_pTarget(pTarget), m_pUserIdentity(pIdentity) { - m_bIdentdAttached = false; - m_pContext = pContext; m_pConsole = pContext->console(); - m_pTarget = pTarget; - m_pUserIdentity = pIdentity; m_pLink = new KviIrcLink(this); m_pUserDataBase = new KviIrcUserDataBase(); m_pUserInfo = new KviIrcConnectionUserInfo(); @@ -92,12 +89,7 @@ KviIrcConnection::KviIrcConnection(KviIrcContext * pContext, KviIrcConnectionTar m_pAntiCtcpFloodData = new KviIrcConnectionAntiCtcpFloodData(); m_pNetsplitDetectorData = new KviIrcConnectionNetsplitDetectorData(); m_pAsyncWhoisData = new KviIrcConnectionAsyncWhoisData(); - m_pStatistics = new KviIrcConnectionStatistics(); - m_pNotifyListTimer = nullptr; - m_pNotifyListManager = nullptr; - m_pLocalhostDns = nullptr; - m_pLagMeter = nullptr; - m_eState = Idle; + m_pStatistics = std::make_unique<KviIrcConnectionStatistics>(); m_pRequestQueue = new KviIrcConnectionRequestQueue(); setupSrvCodec(); setupTextCodec(); @@ -136,7 +128,6 @@ KviIrcConnection::~KviIrcConnection() delete m_pAntiCtcpFloodData; delete m_pNetsplitDetectorData; delete m_pAsyncWhoisData; - delete m_pStatistics; delete m_pUserIdentity; m_pRequestQueue->deleteLater(); } @@ -269,7 +260,7 @@ void KviIrcConnection::serverInfoReceived(const QString & szServerName, const QS g_pMainWindow->childConnectionServerInfoChange(this); } -const QString & KviIrcConnection::currentNetworkName() +const QString & KviIrcConnection::currentNetworkName() const { return m_pServerInfo->networkName(); } @@ -347,8 +338,7 @@ void KviIrcConnection::linkEstablished() if(!link() || !link()->socket()) return; - if( - (!link()->socket()->usingSSL()) && target()->server()->enabledSTARTTLS()) + if((!link()->socket()->usingSSL()) && target()->server()->enabledSTARTTLS()) { #ifdef COMPILE_SSL_SUPPORT // STARTTLS without CAP (forced request) @@ -421,8 +411,7 @@ void KviIrcConnection::handleInitialCapLs() // STARTTLS support: this has to be checked first because it could imply // a full cap renegotiation #ifdef COMPILE_SSL_SUPPORT - if( - (!link()->socket()->usingSSL()) && target()->server()->enabledSTARTTLS() && serverInfo()->supportedCaps().contains("tls", Qt::CaseInsensitive)) + if((!link()->socket()->usingSSL()) && target()->server()->enabledSTARTTLS() && serverInfo()->supportedCaps().contains("tls", Qt::CaseInsensitive)) { if(trySTARTTLS(false)) return; // STARTTLS negotiation in progress @@ -473,16 +462,30 @@ void KviIrcConnection::handleInitialCapAck() bool bUsed = false; //SASL - if( - target()->server()->enabledSASL() && m_pStateData->enabledCaps().contains("sasl", Qt::CaseInsensitive)) + if(target()->server()->enabledSASL() && m_pStateData->enabledCaps().contains("sasl", Qt::CaseInsensitive)) { - m_pStateData->setInsideAuthenticate(true); - bUsed = true; + if(target()->server()->saslMethod() == QStringLiteral("EXTERNAL")) + { + if(KVI_OPTION_BOOL(KviOption_boolUseSSLCertificate) && link()->socket()->usingSSL()) + { + bUsed = true; + sendFmtData("AUTHENTICATE EXTERNAL"); + m_pStateData->setSentSaslMethod(QStringLiteral("EXTERNAL")); + } + } - sendFmtData("AUTHENTICATE PLAIN"); + // Assume PLAIN if all other SASL methods are not chosen or we're attempting a fallback + if(!bUsed && !target()->server()->saslNick().isEmpty() && !target()->server()->saslPass().isEmpty()) + { + bUsed = true; + sendFmtData("AUTHENTICATE PLAIN"); + m_pStateData->setSentSaslMethod(QStringLiteral("PLAIN")); + } } - if(!bUsed) + if(bUsed) + m_pStateData->setInsideAuthenticate(true); + else endInitialCapNegotiation(); } @@ -495,9 +498,14 @@ void KviIrcConnection::handleAuthenticate(KviCString & szAuth) QByteArray szNick = encodeText(target()->server()->saslNick()); QByteArray szPass = encodeText(target()->server()->saslPass()); - //PLAIN KviCString szOut; - if(KviSASL::plainMethod(szAuth, szOut, szNick, szPass)) + bool bSendString = false; + if(m_pStateData->sentSaslMethod() == QStringLiteral("EXTERNAL")) + bSendString = KviSASL::externalMethod(szAuth, szOut); + else // Assume PLAIN + bSendString = KviSASL::plainMethod(szAuth, szOut, szNick, szPass); + + if(bSendString) sendFmtData("AUTHENTICATE %s", szOut.ptr()); else sendFmtData("AUTHENTICATE *"); @@ -1519,11 +1527,6 @@ void KviIrcConnection::loginToIrcServer() QByteArray szReal = encodeText(m_pUserInfo->realName()); // may be empty QByteArray szPass = encodeText(m_pUserInfo->password()); // may be empty - if(!szReal.data()) - szReal = ""; - if(!szPass.data()) - szPass = ""; - if(!_OUTPUT_MUTE) m_pConsole->output(KVI_OUT_SYSTEMMESSAGE, __tr2qs("Logging in as %Q!%Q :%Q"), &(m_pUserInfo->nickName()), &(m_pUserInfo->userName()), &(m_pUserInfo->realName())); @@ -1673,7 +1676,7 @@ bool KviIrcConnection::changeUserMode(char cMode, bool bSet) void KviIrcConnection::gatherChannelAndPasswordPairs(std::vector<std::pair<QString, QString>> & lChannelsAndPasses) { - for(auto & c : m_pChannelList) + for(const auto & c : m_pChannelList) lChannelsAndPasses.emplace_back( c->windowName(), c->hasChannelMode('k') ? c->channelModeParam('k') : QString()); @@ -1681,7 +1684,7 @@ void KviIrcConnection::gatherChannelAndPasswordPairs(std::vector<std::pair<QStri void KviIrcConnection::gatherQueryNames(QStringList & lQueryNames) { - for(auto & q : m_pQueryList) + for(const auto & q : m_pQueryList) lQueryNames.append(q->target()); } @@ -1702,7 +1705,6 @@ void KviIrcConnection::joinChannels(const std::vector<std::pair<QString, QString // We send the channel list in chunks to avoid overflowing the 510 character limit on the message. QString szChans, szPasses; - QString szCommand; for(auto & oChanAndPass : lSorted) { @@ -1721,22 +1723,22 @@ void KviIrcConnection::joinChannels(const std::vector<std::pair<QString, QString // empirical limit if((szChans.length() + szPasses.length()) > 450) { - szCommand = szChans; + QString szCommand = szChans; if(!szPasses.isEmpty()) { - szCommand.append(" "); + szCommand.append(' '); szCommand.append(szPasses); } sendFmtData("JOIN %s", encodeText(szCommand).data()); - szChans = QString(); - szPasses = QString(); + szChans.clear(); + szPasses.clear(); } } - szCommand = szChans; + QString szCommand = szChans; if(!szPasses.isEmpty()) { - szCommand.append(" "); + szCommand.append(' '); szCommand.append(szPasses); } sendFmtData("JOIN %s", encodeText(szCommand).data()); @@ -1771,10 +1773,7 @@ void KviIrcConnection::loginComplete(const QString & szNickName) g_pApp->addRecentNickname(szNickName); - bool bHaltOutput = false; - bHaltOutput = KVS_TRIGGER_EVENT_0_HALTED(KviEvent_OnIRC, m_pConsole); - - if(!bHaltOutput) + if(!KVS_TRIGGER_EVENT_0_HALTED(KviEvent_OnIRC, m_pConsole)) m_pConsole->outputNoFmt(KVI_OUT_IRC, __tr2qs("Login operations complete, happy ircing!")); resurrectDeadQueries(); @@ -2012,17 +2011,17 @@ void KviIrcConnection::heartbeat(kvi_time_t tNow) } } -const QString & KviIrcConnection::currentServerName() +const QString & KviIrcConnection::currentServerName() const { return serverInfo()->name(); } -const QString & KviIrcConnection::currentNickName() +const QString & KviIrcConnection::currentNickName() const { return userInfo()->nickName(); } -const QString & KviIrcConnection::currentUserName() +const QString & KviIrcConnection::currentUserName() const { return userInfo()->userName(); } diff --git a/src/kvirc/kernel/KviIrcConnection.h b/src/kvirc/kernel/KviIrcConnection.h index 0e33484c1..dc1bb6fde 100644 --- a/src/kvirc/kernel/KviIrcConnection.h +++ b/src/kvirc/kernel/KviIrcConnection.h @@ -34,10 +34,11 @@ #include "KviQString.h" #include "KviTimeUtils.h" -#include <QObject> #include <QByteArray> +#include <QObject> #include <QStringList> +#include <memory> #include <utility> #include <vector> @@ -105,14 +106,14 @@ protected: * * This is actually used only by KviConsoleWindow. * - * pContext must not be NULL and is kept as shallow pointer (that is, it's + * pContext must not be nullptr and is kept as shallow pointer (that is, it's * not owned and must persists for the entire life of KviIrcConnection: * caller is responsable for that). * - * pTarget must not be NULL and must be allocated with new as this class + * pTarget must not be nullptr and must be allocated with new as this class * takes the ownership. * - * pIdentity must not be NULL and must be allocated with new as this class + * pIdentity must not be nullptr and must be allocated with new as this class * takes the ownership. * \param pContext The KviIrcContext we're attacched to * \param pTarget The server data @@ -142,8 +143,8 @@ private: KviConsoleWindow * m_pConsole; // shallow, never null KviIrcContext * m_pContext; // shallow, never null - State m_eState; - bool m_bIdentdAttached; + State m_eState = Idle; + bool m_bIdentdAttached = false; KviIrcConnectionTarget * m_pTarget; // owned, never null @@ -165,18 +166,18 @@ private: KviIrcUserDataBase * m_pUserDataBase; // owned, never null - KviNotifyListManager * m_pNotifyListManager; // owned, see restartNotifyList() - QTimer * m_pNotifyListTimer; // delayed startup timer for the notify lists + KviNotifyListManager * m_pNotifyListManager = nullptr; // owned, see restartNotifyList() + QTimer * m_pNotifyListTimer = nullptr; // delayed startup timer for the notify lists - KviLagMeter * m_pLagMeter; // owned, may be null (when not running) + KviLagMeter * m_pLagMeter = nullptr; // owned, may be null (when not running) KviIrcConnectionAntiCtcpFloodData * m_pAntiCtcpFloodData; // owned, never null KviIrcConnectionNetsplitDetectorData * m_pNetsplitDetectorData; // owned, never null KviIrcConnectionAsyncWhoisData * m_pAsyncWhoisData; // owned, never null - KviIrcConnectionStatistics * m_pStatistics; // owned, never null + std::unique_ptr<KviIrcConnectionStatistics> m_pStatistics; // owned, never null - KviDnsResolver * m_pLocalhostDns; // FIXME: this should go to an aux structure + KviDnsResolver * m_pLocalhostDns = nullptr; // FIXME: this should go to an aux structure QTextCodec * m_pSrvCodec; // connection codec: never null QTextCodec * m_pTextCodec; // connection codec: never null @@ -185,51 +186,51 @@ public: /** * \brief Returns a pointer to the owning console * - * The pointer is never NULL + * The pointer is never nullptr * \return KviConsoleWindow * */ - KviConsoleWindow * console() { return m_pConsole; }; + KviConsoleWindow * console() const { return m_pConsole; } /** * \brief Returns a pointer to the owning KviIrcContext. * - * The returned value is never NULL + * The returned value is never nullptr * \return KviIrcContext * */ - KviIrcContext * context() { return m_pContext; }; + KviIrcContext * context() const { return m_pContext; } /** * \brief Returns the target of this connection. * * Please note that the target doesn't necessairly contain up-to-date data. * You might want to look at serverInfo() instead. - * The returned pointer is never NULL. + * The returned pointer is never nullptr. * \return KviIrcConnectionTarget * */ - KviIrcConnectionTarget * target() { return m_pTarget; }; + KviIrcConnectionTarget * target() const { return m_pTarget; } /** * \brief Returns the underlying KviIrcLink object * - * The returned pointer is never NULL. + * The returned pointer is never nullptr. * \return KviIrcLink * */ - KviIrcLink * link() { return m_pLink; }; + KviIrcLink * link() const { return m_pLink; } /** * \brief Returns the current state of the connection * \return State */ - State state() { return m_eState; }; + State state() const { return m_eState; } /** * \brief Returns a pointer to the big connection user database. * * The database contains ALL the users KVIrc can "see" in this connection. - * The returned pointer is never NULL. + * The returned pointer is never nullptr. * \return KviIrcUserDataBase * */ - KviIrcUserDataBase * userDataBase() { return m_pUserDataBase; }; + KviIrcUserDataBase * userDataBase() const { return m_pUserDataBase; } /** * \brief Returns a pointer to the KviIrcConnectionUserInfo object @@ -237,12 +238,12 @@ public: * It contains runtime information about the user. This includes the * current nickname, username, flags and other stuff that KviUserIdentity * actually doesn't contain (or has only "default" values for). - * The returned pointer is never NULL. + * The returned pointer is never nullptr. * Include "KviIrcConnectionUserInfo.h" as the class is only * forwarded here. * \return KviIrcConnectionUserInfo * */ - KviIrcConnectionUserInfo * userInfo() { return m_pUserInfo; }; + KviIrcConnectionUserInfo * userInfo() const { return m_pUserInfo; } /** * \brief Returns a pointer to the KviIrcConnectionServerInfo object @@ -251,12 +252,12 @@ public: * the current servername, the server capabilities and other stuff that * KviConnectionTarget actually doesn't contain (or has only "default" * values for). - * The returned pointer is never NULL. + * The returned pointer is never nullptr. * Include "KviIrcConnectionServerInfo.h" as the class is only * forwarded here. * \return KviIrcConnectionServerInfo * */ - KviIrcConnectionServerInfo * serverInfo() { return m_pServerInfo; }; + KviIrcConnectionServerInfo * serverInfo() const { return m_pServerInfo; } /** * \brief Returns a pointer to the KviIrcConnectionStateData object @@ -265,96 +266,96 @@ public: * nickname index at login time, flags that signal "micro-states" etc... * This data *could* be part of KviIrcConnection itself but we prefer to * keep it in a separate class in order to cleanup the implementation. - * The returned pointer is never NULL. + * The returned pointer is never nullptr. * Include "KviIrcConnectionStateData.h" as the class is only * forwarded here. * \return KviIrcConnectionStateData * */ - KviIrcConnectionStateData * stateData() { return m_pStateData; }; + KviIrcConnectionStateData * stateData() const { return m_pStateData; } /** * \brief Returns a pointer to the KviIrcConnectionAntiCtcpFloodData object * * It contains data private to the Anti CTCP Flood engine. Very similar * to KviIrcConnectionStateData but dedicated to Ctcp flood. - * The returned pointer is never NULL. + * The returned pointer is never nullptr. * Include "KviIrcConnectionAntiCtcpFloodData.h" as the class is * only forwarded here. * \return KviIrcConnectionAntiCtcpFloodData * */ - KviIrcConnectionAntiCtcpFloodData * antiCtcpFloodData() + KviIrcConnectionAntiCtcpFloodData * antiCtcpFloodData() const { return m_pAntiCtcpFloodData; - }; + } /** * \brief Returns a pointer to the KviIrcConnectionNetsplitDetectorData object * * It contains data private to the netsplit detector engine. Very similar * to KviIrcConnectionStateData but dedicated to netsplit detection. - * The returned pointer is never NULL. + * The returned pointer is never nullptr. * Include "KviIrcConnectionNetsplitDetectorData.h" as the class is * only forwarded here. * \return KviIrcConnectionNetsplitDetectorData * */ - KviIrcConnectionNetsplitDetectorData * netsplitDetectorData() + KviIrcConnectionNetsplitDetectorData * netsplitDetectorData() const { return m_pNetsplitDetectorData; - }; + } /** * \brief Returns a pointer to the KviIrcConnectionAsyncWhoisData object * * It contains data private to the async whois engine. Very similar to * KviIrcConnectionStateData but dedicated to async whois. - * The returned pointer is never NULL. + * The returned pointer is never nullptr. * Include "KviIrcConnectionAsyncWhoisData.h" as the class is only * forwarded here. * \return KviIrcConnectionAsyncWhoisData * */ - KviIrcConnectionAsyncWhoisData * asyncWhoisData() + KviIrcConnectionAsyncWhoisData * asyncWhoisData() const { return m_pAsyncWhoisData; - }; + } /** * \brief Returns a pointer to the KviIrcConnectionStatistics object * * It contains runtime statistics about the connection. Very similar to * KviIrcConnectionStateData but dedicated to statistics. - * The returned pointer is never NULL. + * The returned pointer is never nullptr. * Include "KviIrcConnectionStatistics.h" as the class is only * forwarded here. * \return KviIrcConnectionStatistics * */ - KviIrcConnectionStatistics * statistics() { return m_pStatistics; }; + KviIrcConnectionStatistics * statistics() const { return m_pStatistics.get(); } /** * \brief Returns a pointer to the current KviNotifyListManager. * - * The returned pointer is NULL if notify list management is disabled for + * The returned pointer is nullptr if notify list management is disabled for * the current connection. * \return KviNotifyListManager * */ - KviNotifyListManager * notifyListManager() + KviNotifyListManager * notifyListManager() const { return m_pNotifyListManager; - }; + } /** * \brief Returns a pointer to the current KviLagMeter. * - * The returned pointer is NULL if lag measurement is disabled for the + * The returned pointer is nullptr if lag measurement is disabled for the * current connection. * \return KviLagMeter * */ - KviLagMeter * lagMeter() { return m_pLagMeter; }; + KviLagMeter * lagMeter() const { return m_pLagMeter; } /** * \brief Returns a pointer to the current KviIrcConnectionRequestQueue. * \return KviIrcConnectionRequestQueue * */ - KviIrcConnectionRequestQueue * requestQueue() { return m_pRequestQueue; }; + KviIrcConnectionRequestQueue * requestQueue() const { return m_pRequestQueue; } /** * \brief Returns the list of the channels bound to the current connection. @@ -362,31 +363,31 @@ public: * The pointer itself is never null (though the list may be empty). * \return & std::vector<KviChannelWindow *> */ - std::vector<KviChannelWindow *> & channelList() { return m_pChannelList; }; + std::vector<KviChannelWindow *> & channelList() { return m_pChannelList; } /** * \brief Helper that provides a shortcut for really common access to serverInfo()->networkName() * \return const QString & */ - const QString & currentNetworkName(); + const QString & currentNetworkName() const; /** * \brief Helper that provides a shortcut for really common access to userInfo()->nickName() * \return const QString & */ - const QString & currentNickName(); + const QString & currentNickName() const; /** * \brief Helper that provides a shortcut for really common access to userInfo()->userName() * \return const QString & */ - const QString & currentUserName(); + const QString & currentUserName() const; /** * \brief Helper that provides a shortcut for really common access to serverInfo()->name() * \return const QString & */ - const QString & currentServerName(); + const QString & currentServerName() const; // // Channel management @@ -397,7 +398,7 @@ public: /** * \brief Finds the channel with the specified unicode name. * - * Returns the pointer to the channel found or NULL if there is no such + * Returns the pointer to the channel found or nullptr if there is no such * channel. * \param szName The name of the channel * \return KviChannelWindow * @@ -427,7 +428,7 @@ public: * This should be called in response to a JOIN message. * This function _assumes_ that such a channel doesn't exist yet (or if it * exists then it's actually in DEAD state). You can assume that channel - * creation never fails: if the returned pointer is NULL then we're screwed + * creation never fails: if the returned pointer is nullptr then we're screwed * anyway as virtual memory is exausted. * \param szName The name of the channel * \return KviChannelWindow * @@ -480,7 +481,7 @@ public: /** * \brief Finds the query with the specified nick. * - * Returns the pointer to the query found or NULL if there is no such + * Returns the pointer to the query found or nullptr if there is no such * query. * \param szNick The nickname of the user * \return KviQueryWindow * @@ -490,10 +491,10 @@ public: /** * \brief Returns the list of the currently open queries. * - * The returned pointer is never NULL (the list may be empty though). + * The returned pointer is never nullptr (the list may be empty though). * \return std::vector<KviQueryWindow *> & */ - std::vector<KviQueryWindow *> & queryList() { return m_pQueryList; }; + std::vector<KviQueryWindow *> & queryList() { return m_pQueryList; } /// /// Visibility mode for createQuery() @@ -666,7 +667,7 @@ public: * windows. The returned pointer may be null if things really went wrong. * \return QTextCodec * */ - QTextCodec * textCodec() { return m_pTextCodec; }; + QTextCodec * textCodec() const { return m_pTextCodec; } /** * \brief Returns a pointer to the current global codec for inbound data. @@ -675,7 +676,7 @@ public: * windows. The returned pointer may be null if things really went wrong. * \return QTextCodec * */ - QTextCodec * serverCodec() { return m_pSrvCodec; }; + QTextCodec * serverCodec() const { return m_pSrvCodec; } /** * \brief Sets the global encoding for this connection. diff --git a/src/kvirc/kernel/KviIrcConnectionAntiCtcpFloodData.cpp b/src/kvirc/kernel/KviIrcConnectionAntiCtcpFloodData.cpp index 9ed3b769e..9da54ef7b 100644 --- a/src/kvirc/kernel/KviIrcConnectionAntiCtcpFloodData.cpp +++ b/src/kvirc/kernel/KviIrcConnectionAntiCtcpFloodData.cpp @@ -25,10 +25,7 @@ #include "KviIrcConnectionAntiCtcpFloodData.h" KviIrcConnectionAntiCtcpFloodData::KviIrcConnectionAntiCtcpFloodData() -{ - m_tLastCtcp = 0; - m_uCtcpCount = 0; -} + = default; KviIrcConnectionAntiCtcpFloodData::~KviIrcConnectionAntiCtcpFloodData() = default; diff --git a/src/kvirc/kernel/KviIrcConnectionAntiCtcpFloodData.h b/src/kvirc/kernel/KviIrcConnectionAntiCtcpFloodData.h index 685df2273..18ec24c6d 100644 --- a/src/kvirc/kernel/KviIrcConnectionAntiCtcpFloodData.h +++ b/src/kvirc/kernel/KviIrcConnectionAntiCtcpFloodData.h @@ -35,14 +35,14 @@ public: protected: // ctcp antiflood mechanism - kvi_time_t m_tLastCtcp; // the time we have received the last "may flood" ctcp request - unsigned int m_uCtcpCount; // the ctcp counter for the antiflooder + kvi_time_t m_tLastCtcp = 0; // the time we have received the last "may flood" ctcp request + unsigned int m_uCtcpCount = 0; // the ctcp counter for the antiflooder public: - kvi_time_t lastCtcpTime() { return m_tLastCtcp; }; - unsigned int ctcpCount() { return m_uCtcpCount; }; - void setLastCtcpTime(kvi_time_t tLastCtcp) { m_tLastCtcp = tLastCtcp; }; - void increaseCtcpCount() { m_uCtcpCount++; }; - void setCtcpCount(unsigned int uCtcpCount) { m_uCtcpCount = uCtcpCount; }; + kvi_time_t lastCtcpTime() const { return m_tLastCtcp; } + unsigned int ctcpCount() const { return m_uCtcpCount; } + void setLastCtcpTime(kvi_time_t tLastCtcp) { m_tLastCtcp = tLastCtcp; } + void increaseCtcpCount() { m_uCtcpCount++; } + void setCtcpCount(unsigned int uCtcpCount) { m_uCtcpCount = uCtcpCount; } }; #endif //!_KVI_IRCCONNECTIONANTICTCPFLOODDATA_H_ diff --git a/src/kvirc/kernel/KviIrcConnectionAsyncData.h b/src/kvirc/kernel/KviIrcConnectionAsyncData.h index 89acde382..827385a53 100644 --- a/src/kvirc/kernel/KviIrcConnectionAsyncData.h +++ b/src/kvirc/kernel/KviIrcConnectionAsyncData.h @@ -29,6 +29,8 @@ // KviIrcConnectionAsyncWhowasData for creating an awhowas command // It is now also used by KviIrcConnectionAsyncWhoisData +#include "KviQString.h" + #include <unordered_set> #ifndef __GNUC__ @@ -45,14 +47,9 @@ public: T * lookup(const QString & nick) { - if(m_pInfoList.empty()) - return nullptr; - for(auto & i : m_pInfoList) - { if(KviQString::equalCI(nick, i->szNick)) return i; - } return nullptr; } diff --git a/src/kvirc/kernel/KviIrcConnectionAsyncWhoisData.cpp b/src/kvirc/kernel/KviIrcConnectionAsyncWhoisData.cpp index ac236eeb4..fa6509ee8 100644 --- a/src/kvirc/kernel/KviIrcConnectionAsyncWhoisData.cpp +++ b/src/kvirc/kernel/KviIrcConnectionAsyncWhoisData.cpp @@ -26,10 +26,7 @@ #include "KviKvsScript.h" KviAsyncWhoisInfo::KviAsyncWhoisInfo() -{ - pCallback = nullptr; - pMagic = nullptr; -} + = default; KviAsyncWhoisInfo::~KviAsyncWhoisInfo() { diff --git a/src/kvirc/kernel/KviIrcConnectionAsyncWhoisData.h b/src/kvirc/kernel/KviIrcConnectionAsyncWhoisData.h index e6d8c513c..b5935271f 100644 --- a/src/kvirc/kernel/KviIrcConnectionAsyncWhoisData.h +++ b/src/kvirc/kernel/KviIrcConnectionAsyncWhoisData.h @@ -25,17 +25,21 @@ //============================================================================= #include "kvi_settings.h" -#include "KviQString.h" -#include "KviPointerList.h" #include "KviIrcConnectionAsyncData.h" -class KviWindow; +#include <QString> + class KviKvsScript; class KviKvsVariant; +class KviWindow; class KVIRC_API KviAsyncWhoisInfo { public: + KviAsyncWhoisInfo(); + ~KviAsyncWhoisInfo(); + +public: QString szNick; QString szUser; QString szHost; @@ -44,16 +48,12 @@ public: QString szIdle; QString szSignon; QString szChannels; - QString szAway; // The szSpecial member is renamed szAway as its sole purpose is to tell whether the user is away or not + QString szAway; QString szAuth; QString szAdditional; - KviKvsScript * pCallback; - KviKvsVariant * pMagic; - KviWindow * pWindow; - -public: - KviAsyncWhoisInfo(); - ~KviAsyncWhoisInfo(); + KviKvsScript * pCallback = nullptr; + KviKvsVariant * pMagic = nullptr; + KviWindow * pWindow = nullptr; }; // KviIrcConnectionAsyncWhoisData is now recreated using a template diff --git a/src/kvirc/kernel/KviIrcConnectionNetsplitDetectorData.cpp b/src/kvirc/kernel/KviIrcConnectionNetsplitDetectorData.cpp index a5868bca0..66346ea2d 100644 --- a/src/kvirc/kernel/KviIrcConnectionNetsplitDetectorData.cpp +++ b/src/kvirc/kernel/KviIrcConnectionNetsplitDetectorData.cpp @@ -25,9 +25,7 @@ #include "KviIrcConnectionNetsplitDetectorData.h" KviIrcConnectionNetsplitDetectorData::KviIrcConnectionNetsplitDetectorData() -{ - m_tLastNetsplitOnQuit = 0; -} + = default; KviIrcConnectionNetsplitDetectorData::~KviIrcConnectionNetsplitDetectorData() = default; diff --git a/src/kvirc/kernel/KviIrcConnectionNetsplitDetectorData.h b/src/kvirc/kernel/KviIrcConnectionNetsplitDetectorData.h index c88d9b80a..2f530f02e 100644 --- a/src/kvirc/kernel/KviIrcConnectionNetsplitDetectorData.h +++ b/src/kvirc/kernel/KviIrcConnectionNetsplitDetectorData.h @@ -25,9 +25,10 @@ //============================================================================= #include "kvi_settings.h" -#include "KviQString.h" #include "KviTimeUtils.h" +#include <QString> + class KVIRC_API KviIrcConnectionNetsplitDetectorData { public: @@ -36,13 +37,13 @@ public: protected: QString m_szLastNetsplitOnQuitReason; - kvi_time_t m_tLastNetsplitOnQuit; + kvi_time_t m_tLastNetsplitOnQuit = 0; public: - const QString & lastNetsplitOnQuitReason() { return m_szLastNetsplitOnQuitReason; }; - void setLastNetsplitOnQuitReason(const QString & szReason) { m_szLastNetsplitOnQuitReason = szReason; }; - kvi_time_t lastNetsplitOnQuitTime() { return m_tLastNetsplitOnQuit; }; - void setLastNetsplitOnQuitTime(kvi_time_t t) { m_tLastNetsplitOnQuit = t; }; + const QString & lastNetsplitOnQuitReason() const { return m_szLastNetsplitOnQuitReason; } + void setLastNetsplitOnQuitReason(const QString & szReason) { m_szLastNetsplitOnQuitReason = szReason; } + kvi_time_t lastNetsplitOnQuitTime() const { return m_tLastNetsplitOnQuit; } + void setLastNetsplitOnQuitTime(kvi_time_t t) { m_tLastNetsplitOnQuit = t; } }; #endif //!_KVI_IRCCONNECTIONNETSPLITDETECTORDATA_H_ diff --git a/src/kvirc/kernel/KviIrcConnectionRequestQueue.cpp b/src/kvirc/kernel/KviIrcConnectionRequestQueue.cpp index 06c817bfc..8c3dd78ca 100644 --- a/src/kvirc/kernel/KviIrcConnectionRequestQueue.cpp +++ b/src/kvirc/kernel/KviIrcConnectionRequestQueue.cpp @@ -34,7 +34,6 @@ KviIrcConnectionRequestQueue::KviIrcConnectionRequestQueue() { - m_curType = Mode; connect(&m_timer, SIGNAL(timeout()), this, SLOT(timerSlot())); } @@ -49,9 +48,7 @@ void KviIrcConnectionRequestQueue::enqueueChannel(KviChannelWindow * pChan) { m_channels.enqueue(pChan); if(!m_timer.isActive()) - { m_timer.start(KVI_OPTION_UINT(KviOption_uintOnJoinRequestsDelay) * 1000); - } } } diff --git a/src/kvirc/kernel/KviIrcConnectionRequestQueue.h b/src/kvirc/kernel/KviIrcConnectionRequestQueue.h index 77f63494c..a2f94fc38 100644 --- a/src/kvirc/kernel/KviIrcConnectionRequestQueue.h +++ b/src/kvirc/kernel/KviIrcConnectionRequestQueue.h @@ -57,7 +57,7 @@ public: /** * \brief Destroys the request queue objects */ - virtual ~KviIrcConnectionRequestQueue(); + ~KviIrcConnectionRequestQueue(); protected: /** @@ -78,7 +78,7 @@ protected: QQueue<KviChannelWindow *> m_channels; QTimer m_timer; - RequestTypes m_curType; + RequestTypes m_curType = Mode; public: /** @@ -100,7 +100,7 @@ public: * \param pChan The channel to check * \return bool */ - bool isQueued(KviChannelWindow * pChan) { return m_channels.contains(pChan); }; + bool isQueued(KviChannelWindow * pChan) const { return m_channels.contains(pChan); } /** * \brief Clears the queue stack diff --git a/src/kvirc/kernel/KviIrcConnectionServerInfo.cpp b/src/kvirc/kernel/KviIrcConnectionServerInfo.cpp index bf5a2d79e..1d03ee478 100644 --- a/src/kvirc/kernel/KviIrcConnectionServerInfo.cpp +++ b/src/kvirc/kernel/KviIrcConnectionServerInfo.cpp @@ -23,6 +23,8 @@ //============================================================================= #include "KviIrcConnectionServerInfo.h" + +#include <utility> #include "KviLocale.h" #include "KviMemory.h" #include "KviIrcUserDataBase.h" @@ -30,22 +32,7 @@ KviIrcConnectionServerInfo::KviIrcConnectionServerInfo() { // default assumptions - m_szSupportedChannelTypes = "#&!+"; - m_szSupportedModePrefixes = "@+"; - m_szSupportedModeFlags = "ov"; - m_pModePrefixTable = nullptr; buildModePrefixTable(); - m_bSupportsWatchList = false; - m_bSupportsCodePages = false; - m_bSupportsCap = false; - m_iMaxTopicLen = -1; - m_iMaxModeChanges = 3; - m_szListModes = "b"; - m_szParameterModes = "k"; - m_szParameterWhenSetModes = "l"; - m_szPlainModes = "pstnmi"; - m_szSupportedChannelModes = "pstnmiklb"; - m_bSupportsWhox = false; m_pServInfo = new KviBasicIrcServerInfo(this); } @@ -57,7 +44,7 @@ KviIrcConnectionServerInfo::~KviIrcConnectionServerInfo() KviMemory::free(m_pModePrefixTable); } -bool KviIrcConnectionServerInfo::isSupportedChannelType(QChar c) +bool KviIrcConnectionServerInfo::isSupportedChannelType(QChar c) const { return m_szSupportedChannelTypes.contains(c); } @@ -173,7 +160,7 @@ void KviIrcConnectionServerInfo::buildModePrefixTable() } } -bool KviIrcConnectionServerInfo::isSupportedModePrefix(QChar c) +bool KviIrcConnectionServerInfo::isSupportedModePrefix(QChar c) const { if(!m_pModePrefixTable) return false; @@ -185,7 +172,7 @@ bool KviIrcConnectionServerInfo::isSupportedModePrefix(QChar c) return false; } -bool KviIrcConnectionServerInfo::isSupportedModeFlag(QChar c) +bool KviIrcConnectionServerInfo::isSupportedModeFlag(QChar c) const { if(!m_pModePrefixTable) return false; @@ -197,10 +184,10 @@ bool KviIrcConnectionServerInfo::isSupportedModeFlag(QChar c) return false; } -QChar KviIrcConnectionServerInfo::modePrefixChar(kvi_u32_t flag) +QChar KviIrcConnectionServerInfo::modePrefixChar(kvi_u32_t flag) const { if(!m_pModePrefixTable) - return QChar(0); + return { 0 }; for(unsigned int i = 0; i < m_uPrefixes; i++) { if(m_pModePrefixTable[i * 3 + 2] & flag) @@ -209,10 +196,10 @@ QChar KviIrcConnectionServerInfo::modePrefixChar(kvi_u32_t flag) return QChar(0); } -QChar KviIrcConnectionServerInfo::modeFlagChar(kvi_u32_t flag) +QChar KviIrcConnectionServerInfo::modeFlagChar(kvi_u32_t flag) const { if(!m_pModePrefixTable) - return QChar(0); + return { 0 }; for(unsigned int i = 0; i < m_uPrefixes; i++) { if(m_pModePrefixTable[i * 3 + 2] & flag) @@ -221,7 +208,7 @@ QChar KviIrcConnectionServerInfo::modeFlagChar(kvi_u32_t flag) return QChar(0); } -kvi_u32_t KviIrcConnectionServerInfo::modeFlagFromPrefixChar(QChar c) +kvi_u32_t KviIrcConnectionServerInfo::modeFlagFromPrefixChar(QChar c) const { if(!m_pModePrefixTable) return 0; @@ -233,7 +220,7 @@ kvi_u32_t KviIrcConnectionServerInfo::modeFlagFromPrefixChar(QChar c) return 0; } -kvi_u32_t KviIrcConnectionServerInfo::modeFlagFromModeChar(QChar c) +kvi_u32_t KviIrcConnectionServerInfo::modeFlagFromModeChar(QChar c) const { if(!m_pModePrefixTable) return 0; @@ -289,10 +276,9 @@ void KviIrcConnectionServerInfo::setServerVersion(const QString & version) m_pServInfo = new KviBasicIrcServerInfo(this, version); } -KviBasicIrcServerInfo::KviBasicIrcServerInfo(KviIrcConnectionServerInfo * pParent, const QString & version) +KviBasicIrcServerInfo::KviBasicIrcServerInfo(KviIrcConnectionServerInfo * pParent, QString version) + : m_szServerVersion(std::move(version)), m_pParent(pParent) { - m_szServerVersion = version; - m_pParent = pParent; } KviBasicIrcServerInfo::~KviBasicIrcServerInfo() @@ -302,7 +288,7 @@ KviBasicIrcServerInfo::~KviBasicIrcServerInfo() // User modes // -const QString & KviBasicIrcServerInfo::getUserModeDescription(QChar mode) +const QString & KviBasicIrcServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -352,7 +338,7 @@ const QString & KviBasicIrcServerInfo::getUserModeDescription(QChar mode) return KviQString::Empty; } -const QString & KviHybridServerInfo::getUserModeDescription(QChar mode) +const QString & KviHybridServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -420,7 +406,7 @@ const QString & KviHybridServerInfo::getUserModeDescription(QChar mode) return KviBasicIrcServerInfo::getUserModeDescription(mode); } -const QString & KviIrcdRatboxIrcServerInfo::getUserModeDescription(QChar mode) +const QString & KviIrcdRatboxIrcServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -464,7 +450,7 @@ const QString & KviIrcdRatboxIrcServerInfo::getUserModeDescription(QChar mode) return KviHybridServerInfo::getUserModeDescription(mode); } -const QString & KviCharybdisServerInfo::getUserModeDescription(QChar mode) +const QString & KviCharybdisServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -493,7 +479,7 @@ const QString & KviCharybdisServerInfo::getUserModeDescription(QChar mode) return KviIrcdRatboxIrcServerInfo::getUserModeDescription(mode); } -const QString & KviIrcdSevenIrcServerInfo::getUserModeDescription(QChar mode) +const QString & KviIrcdSevenIrcServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -507,7 +493,7 @@ const QString & KviIrcdSevenIrcServerInfo::getUserModeDescription(QChar mode) return KviCharybdisServerInfo::getUserModeDescription(mode); } -const QString & KviPlexusIrcServerInfo::getUserModeDescription(QChar mode) +const QString & KviPlexusIrcServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -542,7 +528,7 @@ const QString & KviPlexusIrcServerInfo::getUserModeDescription(QChar mode) return KviHybridServerInfo::getUserModeDescription(mode); } -const QString & KviOftcIrcServerInfo::getUserModeDescription(QChar mode) +const QString & KviOftcIrcServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -562,7 +548,7 @@ const QString & KviOftcIrcServerInfo::getUserModeDescription(QChar mode) return KviHybridServerInfo::getUserModeDescription(mode); } -const QString & KviIrcuIrcServerInfo::getUserModeDescription(QChar mode) +const QString & KviIrcuIrcServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -591,7 +577,7 @@ const QString & KviIrcuIrcServerInfo::getUserModeDescription(QChar mode) return KviBasicIrcServerInfo::getUserModeDescription(mode); } -const QString & KviSnircdIrcServerInfo::getUserModeDescription(QChar mode) +const QString & KviSnircdIrcServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -611,7 +597,7 @@ const QString & KviSnircdIrcServerInfo::getUserModeDescription(QChar mode) return KviIrcuIrcServerInfo::getUserModeDescription(mode); } -const QString & KviDarenetIrcServerInfo::getUserModeDescription(QChar mode) +const QString & KviDarenetIrcServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -640,7 +626,7 @@ const QString & KviDarenetIrcServerInfo::getUserModeDescription(QChar mode) return KviIrcuIrcServerInfo::getUserModeDescription(mode); } -const QString & KviUnreal32IrcServerInfo::getUserModeDescription(QChar mode) +const QString & KviUnreal32IrcServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -720,7 +706,21 @@ const QString & KviUnreal32IrcServerInfo::getUserModeDescription(QChar mode) return KviBasicIrcServerInfo::getUserModeDescription(mode); } -const QString & KviCritenIrcServerInfo::getUserModeDescription(QChar mode) +const QString & KviUnreal40IrcServerInfo::getUserModeDescription(QChar mode) const +{ + switch(mode.unicode()) + { + case 'D': + return __tr2qs("D: Only receive private messages from opers, servers, or services"); + break; + case 'Z': + return __tr2qs("Z: Only receive private messages from users with SSL"); + break; + } + return KviUnreal32IrcServerInfo::getUserModeDescription(mode); +} + +const QString & KviCritenIrcServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -779,7 +779,7 @@ const QString & KviCritenIrcServerInfo::getUserModeDescription(QChar mode) return KviBasicIrcServerInfo::getUserModeDescription(mode); } -const QString & KviBahamutIrcServerInfo::getUserModeDescription(QChar mode) +const QString & KviBahamutIrcServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -850,7 +850,7 @@ const QString & KviBahamutIrcServerInfo::getUserModeDescription(QChar mode) return KviBasicIrcServerInfo::getUserModeDescription(mode); } -const QString & KviHyperionIrcServerInfo::getUserModeDescription(QChar mode) +const QString & KviHyperionIrcServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -1004,7 +1004,7 @@ const QString & KviHyperionIrcServerInfo::getUserModeDescription(QChar mode) return KviBasicIrcServerInfo::getUserModeDescription(mode); } -const QString & KviInspIRCdIrcServerInfo::getUserModeDescription(QChar mode) +const QString & KviInspIRCdIrcServerInfo::getUserModeDescription(QChar mode) const { switch(mode.unicode()) { @@ -1083,7 +1083,7 @@ const QString & KviInspIRCdIrcServerInfo::getUserModeDescription(QChar mode) // by the user. // // Cases returning QChar::Null are free to set by the user without restrictions. -QChar KviBasicIrcServerInfo::getUserModeRequirement(QChar mode) +QChar KviBasicIrcServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1112,7 +1112,7 @@ QChar KviBasicIrcServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviHybridServerInfo::getUserModeRequirement(QChar mode) +QChar KviHybridServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1144,7 +1144,7 @@ QChar KviHybridServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviIrcdRatboxIrcServerInfo::getUserModeRequirement(QChar mode) +QChar KviIrcdRatboxIrcServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1170,7 +1170,7 @@ QChar KviIrcdRatboxIrcServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviCharybdisServerInfo::getUserModeRequirement(QChar mode) +QChar KviCharybdisServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1191,7 +1191,7 @@ QChar KviCharybdisServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviIrcdSevenIrcServerInfo::getUserModeRequirement(QChar mode) +QChar KviIrcdSevenIrcServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1214,7 +1214,7 @@ QChar KviIrcdSevenIrcServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviPlexusIrcServerInfo::getUserModeRequirement(QChar mode) +QChar KviPlexusIrcServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1250,7 +1250,7 @@ QChar KviPlexusIrcServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviOftcIrcServerInfo::getUserModeRequirement(QChar mode) +QChar KviOftcIrcServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1280,7 +1280,7 @@ QChar KviOftcIrcServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviIrcuIrcServerInfo::getUserModeRequirement(QChar mode) +QChar KviIrcuIrcServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1301,7 +1301,7 @@ QChar KviIrcuIrcServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviSnircdIrcServerInfo::getUserModeRequirement(QChar mode) +QChar KviSnircdIrcServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1324,7 +1324,7 @@ QChar KviSnircdIrcServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviDarenetIrcServerInfo::getUserModeRequirement(QChar mode) +QChar KviDarenetIrcServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1353,7 +1353,7 @@ QChar KviDarenetIrcServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviUnreal32IrcServerInfo::getUserModeRequirement(QChar mode) +QChar KviUnreal32IrcServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1401,7 +1401,7 @@ QChar KviUnreal32IrcServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviCritenIrcServerInfo::getUserModeRequirement(QChar mode) +QChar KviCritenIrcServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1435,7 +1435,7 @@ QChar KviCritenIrcServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviBahamutIrcServerInfo::getUserModeRequirement(QChar mode) +QChar KviBahamutIrcServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1474,13 +1474,12 @@ QChar KviBahamutIrcServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviHyperionIrcServerInfo::getUserModeRequirement(QChar mode) +QChar KviHyperionIrcServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { case 'e': return '!'; - case 'A': case 'B': case 'D': @@ -1534,7 +1533,7 @@ QChar KviHyperionIrcServerInfo::getUserModeRequirement(QChar mode) return QChar::Null; } -QChar KviInspIRCdIrcServerInfo::getUserModeRequirement(QChar mode) +QChar KviInspIRCdIrcServerInfo::getUserModeRequirement(QChar mode) const { switch(mode.unicode()) { @@ -1557,7 +1556,7 @@ QChar KviInspIRCdIrcServerInfo::getUserModeRequirement(QChar mode) // Channel modes // -const QString & KviBasicIrcServerInfo::getChannelModeDescription(char mode) +const QString & KviBasicIrcServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -1604,7 +1603,7 @@ const QString & KviBasicIrcServerInfo::getChannelModeDescription(char mode) return KviQString::Empty; } -const QString & KviHybridServerInfo::getChannelModeDescription(char mode) +const QString & KviHybridServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -1639,7 +1638,7 @@ const QString & KviHybridServerInfo::getChannelModeDescription(char mode) return KviBasicIrcServerInfo::getChannelModeDescription(mode); } -const QString & KviIrcdRatboxIrcServerInfo::getChannelModeDescription(char mode) +const QString & KviIrcdRatboxIrcServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -1651,7 +1650,7 @@ const QString & KviIrcdRatboxIrcServerInfo::getChannelModeDescription(char mode) return KviHybridServerInfo::getChannelModeDescription(mode); } -const QString & KviCharybdisServerInfo::getChannelModeDescription(char mode) +const QString & KviCharybdisServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -1710,7 +1709,7 @@ const QString & KviCharybdisServerInfo::getChannelModeDescription(char mode) return KviIrcdRatboxIrcServerInfo::getChannelModeDescription(mode); } -const QString & KviPlexusIrcServerInfo::getChannelModeDescription(char mode) +const QString & KviPlexusIrcServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -1736,7 +1735,7 @@ const QString & KviPlexusIrcServerInfo::getChannelModeDescription(char mode) return KviHybridServerInfo::getChannelModeDescription(mode); } -const QString & KviOftcIrcServerInfo::getChannelModeDescription(char mode) +const QString & KviOftcIrcServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -1750,7 +1749,7 @@ const QString & KviOftcIrcServerInfo::getChannelModeDescription(char mode) return KviHybridServerInfo::getChannelModeDescription(mode); } -const QString & KviIrcuIrcServerInfo::getChannelModeDescription(char mode) +const QString & KviIrcuIrcServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -1785,7 +1784,7 @@ const QString & KviIrcuIrcServerInfo::getChannelModeDescription(char mode) return KviBasicIrcServerInfo::getChannelModeDescription(mode); } -const QString & KviSnircdIrcServerInfo::getChannelModeDescription(char mode) +const QString & KviSnircdIrcServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -1805,7 +1804,7 @@ const QString & KviSnircdIrcServerInfo::getChannelModeDescription(char mode) return KviIrcuIrcServerInfo::getChannelModeDescription(mode); } -const QString & KviDarenetIrcServerInfo::getChannelModeDescription(char mode) +const QString & KviDarenetIrcServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -1837,7 +1836,7 @@ const QString & KviDarenetIrcServerInfo::getChannelModeDescription(char mode) return KviIrcuIrcServerInfo::getChannelModeDescription(mode); } -const QString & KviUnrealIrcServerInfo::getChannelModeDescription(char mode) +const QString & KviUnrealIrcServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -1902,7 +1901,7 @@ const QString & KviUnrealIrcServerInfo::getChannelModeDescription(char mode) return KviBasicIrcServerInfo::getChannelModeDescription(mode); } -const QString & KviUnreal32IrcServerInfo::getChannelModeDescription(char mode) +const QString & KviUnreal32IrcServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -1937,7 +1936,7 @@ const QString & KviUnreal32IrcServerInfo::getChannelModeDescription(char mode) return KviUnrealIrcServerInfo::getChannelModeDescription(mode); } -const QString & KviUnreal40IrcServerInfo::getChannelModeDescription(char mode) +const QString & KviUnreal40IrcServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -1954,7 +1953,7 @@ const QString & KviUnreal40IrcServerInfo::getChannelModeDescription(char mode) return KviUnreal32IrcServerInfo::getChannelModeDescription(mode); } -const QString & KviCritenIrcServerInfo::getChannelModeDescription(char mode) +const QString & KviCritenIrcServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -1992,7 +1991,7 @@ const QString & KviCritenIrcServerInfo::getChannelModeDescription(char mode) return KviBasicIrcServerInfo::getChannelModeDescription(mode); } -const QString & KviBahamutIrcServerInfo::getChannelModeDescription(char mode) +const QString & KviBahamutIrcServerInfo::getChannelModeDescription(char mode) const { switch(mode) { @@ -2047,7 +2046,7 @@ const QString & KviBahamutIrcServerInfo::getChannelModeDescription(char mode) return KviBasicIrcServerInfo::getChannelModeDescription(mode); } -const QString & KviInspIRCdIrcServerInfo::getChannelModeDescription(char mode) +const QString & KviInspIRCdIrcServerInfo::getChannelModeDescription(char mode) const { switch(mode) { diff --git a/src/kvirc/kernel/KviIrcConnectionServerInfo.h b/src/kvirc/kernel/KviIrcConnectionServerInfo.h index a418c3928..e90dee11f 100644 --- a/src/kvirc/kernel/KviIrcConnectionServerInfo.h +++ b/src/kvirc/kernel/KviIrcConnectionServerInfo.h @@ -40,17 +40,17 @@ protected: KviIrcConnectionServerInfo * m_pParent; public: - KviBasicIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty); + KviBasicIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, QString version = KviQString::Empty); virtual ~KviBasicIrcServerInfo(); public: - virtual const QString & getChannelModeDescription(char mode); - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual char getRegisterModeChar() { return 0; }; - virtual const char * getSoftware() { return "Ircd"; }; - virtual bool getNeedsOpToListModeseI() { return false; }; - virtual bool getNeedsOperToSetS() { return false; }; + virtual const QString & getChannelModeDescription(char mode) const; + virtual const QString & getUserModeDescription(QChar mode) const; + virtual QChar getUserModeRequirement(QChar mode) const; + virtual char getRegisterModeChar() const { return 0; } + virtual const char * getSoftware() const { return "Ircd"; } + virtual bool getNeedsOpToListModeseI() const { return false; } + virtual bool getNeedsOperToSetS() const { return false; } }; // @@ -61,78 +61,76 @@ class KVIRC_API KviHybridServerInfo : public KviBasicIrcServerInfo { // This is a major IRCd that most modern forks are based off of public: - KviHybridServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviBasicIrcServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual char getRegisterModeChar() { return 'r'; }; - virtual const char * getSoftware() { return "Hybrid"; }; + KviHybridServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviBasicIrcServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + char getRegisterModeChar() const override { return 'r'; } + const char * getSoftware() const override { return "Hybrid"; } }; class KVIRC_API KviIrcdRatboxIrcServerInfo : public KviHybridServerInfo { // efnet public: - KviIrcdRatboxIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviHybridServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual char getRegisterModeChar() { return 0; }; - virtual const char * getSoftware() { return "Ircd-ratbox"; }; - virtual bool getNeedsOpToListModeseI() { return true; }; + KviIrcdRatboxIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviHybridServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + const char * getSoftware() const override { return "Ircd-ratbox"; } + bool getNeedsOpToListModeseI() const override { return true; } }; class KVIRC_API KviCharybdisServerInfo : public KviIrcdRatboxIrcServerInfo { public: - KviCharybdisServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviIrcdRatboxIrcServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual const char * getSoftware() { return "Charybdis"; }; - virtual bool getNeedsOperToSetS() { return true; }; + KviCharybdisServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviIrcdRatboxIrcServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + const char * getSoftware() const override { return "Charybdis"; } + bool getNeedsOperToSetS() const override { return true; } }; class KVIRC_API KviIrcdSevenIrcServerInfo : public KviCharybdisServerInfo { // freenode public: - KviIrcdSevenIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviCharybdisServerInfo(pParent, version) { ; }; - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual char getRegisterModeChar() { return 0; }; - virtual const char * getSoftware() { return "Ircd-seven"; }; + KviIrcdSevenIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviCharybdisServerInfo(pParent, version) {} + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + const char * getSoftware() const override { return "Ircd-seven"; } }; class KVIRC_API KviPlexusIrcServerInfo : public KviHybridServerInfo { // rizon; note: plexus is an extension to hybrid public: - KviPlexusIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviHybridServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual const char * getSoftware() { return "Plexus"; }; - virtual bool getNeedsOpToListModeseI() { return true; }; + KviPlexusIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviHybridServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + const char * getSoftware() const override { return "Plexus"; } + bool getNeedsOpToListModeseI() const override { return true; } }; class KVIRC_API KviOftcIrcServerInfo : public KviHybridServerInfo { // oftc; note: hybrid+oftc is an extension to hybrid public: - KviOftcIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviHybridServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual char getRegisterModeChar() { return 'R'; }; - virtual const char * getSoftware() { return "Hybrid+Oftc"; }; - virtual bool getNeedsOpToListModeseI() { return true; }; + KviOftcIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviHybridServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + char getRegisterModeChar() const override { return 'R'; } + const char * getSoftware() const override { return "Hybrid+Oftc"; } + bool getNeedsOpToListModeseI() const override { return true; } }; // @@ -143,42 +141,40 @@ class KVIRC_API KviIrcuIrcServerInfo : public KviBasicIrcServerInfo { // undernet public: - KviIrcuIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviBasicIrcServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual char getRegisterModeChar() { return 0; }; - virtual const char * getSoftware() { return "Ircu"; }; - virtual bool getNeedsOpToListModeseI() { return true; }; - virtual bool getNeedsOperToSetS() { return true; }; + KviIrcuIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviBasicIrcServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + const char * getSoftware() const override { return "Ircu"; } + bool getNeedsOpToListModeseI() const override { return true; } + bool getNeedsOperToSetS() const override { return true; } }; class KVIRC_API KviSnircdIrcServerInfo : public KviIrcuIrcServerInfo { // quakenet; note: snird is an extension to ircu public: - KviSnircdIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviIrcuIrcServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual const char * getSoftware() { return "Snircd"; }; - virtual bool getNeedsOperToSetS() { return true; }; + KviSnircdIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviIrcuIrcServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + const char * getSoftware() const override { return "Snircd"; } + bool getNeedsOperToSetS() const override { return true; } }; class KVIRC_API KviDarenetIrcServerInfo : public KviIrcuIrcServerInfo { // darenet; note: u2+ircd-darenet is an extension to ircu public: - KviDarenetIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviIrcuIrcServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual char getRegisterModeChar() { return 'r'; }; - virtual const char * getSoftware() { return "Ircu+Darenet"; }; - virtual bool getNeedsOpToListModeseI() { return false; }; + KviDarenetIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviIrcuIrcServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + char getRegisterModeChar() const override { return 'r'; } + const char * getSoftware() const override { return "Ircu+Darenet"; } }; // @@ -188,13 +184,12 @@ public: class KVIRC_API KviUnrealIrcServerInfo : public KviBasicIrcServerInfo { public: - KviUnrealIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviBasicIrcServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual char getRegisterModeChar() { return 'r'; }; - virtual const char * getSoftware() { return "Unreal"; }; - virtual bool getNeedsOpToListModeseI() { return false; }; - virtual bool getNeedsOperToSetS() { return true; }; + KviUnrealIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviBasicIrcServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + char getRegisterModeChar() const override { return 'r'; } + const char * getSoftware() const override { return "Unreal"; } + bool getNeedsOperToSetS() const override { return true; } }; class KVIRC_API KviUnreal32IrcServerInfo : public KviUnrealIrcServerInfo @@ -202,95 +197,94 @@ class KVIRC_API KviUnreal32IrcServerInfo : public KviUnrealIrcServerInfo // This is a continuation on to Unreal, so use its predecessor // as a base class. public: - KviUnreal32IrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviUnrealIrcServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual const char * getSoftware() { return "Unreal32"; }; + KviUnreal32IrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviUnrealIrcServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + const char * getSoftware() const override { return "Unreal32"; } }; class KVIRC_API KviUnreal40IrcServerInfo : public KviUnreal32IrcServerInfo { public: - KviUnreal40IrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviUnreal32IrcServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual const char * getSoftware() { return "Unreal40"; }; + KviUnreal40IrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviUnreal32IrcServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + const QString & getUserModeDescription(QChar mode) const override; + const char * getSoftware() const override { return "Unreal40"; } }; class KVIRC_API KviCritenIrcServerInfo : public KviBasicIrcServerInfo { // abjects public: - KviCritenIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviBasicIrcServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual char getRegisterModeChar() { return 'r'; }; - virtual const char * getSoftware() { return "Criten"; }; - virtual bool getNeedsOpToListModeseI() { return true; }; + KviCritenIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviBasicIrcServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + char getRegisterModeChar() const override { return 'r'; } + const char * getSoftware() const override { return "Criten"; } + bool getNeedsOpToListModeseI() const override { return true; } }; class KVIRC_API KviNemesisIrcServerInfo : public KviCritenIrcServerInfo { // criten public: - KviNemesisIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviCritenIrcServerInfo(pParent, version) { ; }; - virtual const char * getSoftware() { return "Nemesis"; }; + KviNemesisIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviCritenIrcServerInfo(pParent, version) {} + const char * getSoftware() const override { return "Nemesis"; } }; class KVIRC_API KviNemesis20IrcServerInfo : public KviUnreal32IrcServerInfo { public: - KviNemesis20IrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviUnreal32IrcServerInfo(pParent, version) { ; }; - virtual const char * getSoftware() { return "Nemesis2.0"; }; - virtual bool getNeedsOperToSetS() { return false; }; + KviNemesis20IrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviUnreal32IrcServerInfo(pParent, version) {} + const char * getSoftware() const override { return "Nemesis2.0"; } }; class KVIRC_API KviBahamutIrcServerInfo : public KviBasicIrcServerInfo { // dalnet, azzurranet public: - KviBahamutIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviBasicIrcServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual char getRegisterModeChar() { return 'r'; }; - virtual const char * getSoftware() { return "Bahamut"; }; - virtual bool getNeedsOpToListModeseI() { return false; }; + KviBahamutIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviBasicIrcServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + char getRegisterModeChar() const override { return 'r'; } + const char * getSoftware() const override { return "Bahamut"; } }; class KVIRC_API KviHyperionIrcServerInfo : public KviBasicIrcServerInfo { // legacy freenode : no longer maintained public: - KviHyperionIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviBasicIrcServerInfo(pParent, version) { ; }; - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual char getRegisterModeChar() { return 'e'; }; - virtual const char * getSoftware() { return "Hyperion"; }; - virtual bool getNeedsOpToListModeseI() { return true; }; + KviHyperionIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviBasicIrcServerInfo(pParent, version) {} + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + char getRegisterModeChar() const override { return 'e'; } + const char * getSoftware() const override { return "Hyperion"; } + bool getNeedsOpToListModeseI() const override { return true; } }; class KVIRC_API KviInspIRCdIrcServerInfo : public KviBasicIrcServerInfo { // chatspike public: - KviInspIRCdIrcServerInfo(KviIrcConnectionServerInfo * pParent = 0, const QString & version = KviQString::Empty) - : KviBasicIrcServerInfo(pParent, version) { ; }; - virtual const QString & getChannelModeDescription(char mode); - virtual const QString & getUserModeDescription(QChar mode); - virtual QChar getUserModeRequirement(QChar mode); - virtual char getRegisterModeChar() { return 'r'; }; - virtual const char * getSoftware() { return "InspIRCd"; }; - virtual bool getNeedsOpToListModeseI() { return true; }; - virtual bool getNeedsOperToSetS() { return true; }; + KviInspIRCdIrcServerInfo(KviIrcConnectionServerInfo * pParent = nullptr, const QString & version = KviQString::Empty) + : KviBasicIrcServerInfo(pParent, version) {} + const QString & getChannelModeDescription(char mode) const override; + const QString & getUserModeDescription(QChar mode) const override; + QChar getUserModeRequirement(QChar mode) const override; + char getRegisterModeChar() const override { return 'r'; } + const char * getSoftware() const override { return "InspIRCd"; } + bool getNeedsOpToListModeseI() const override { return true; } + bool getNeedsOperToSetS() const override { return true; } }; class KVIRC_API KviIrcConnectionServerInfo @@ -308,82 +302,85 @@ private: QString m_szNetworkName; // the most actual network name (may be the one we specify or the one that the server reports) QString m_szName; // the most actual server name (may be the one we specify or the one that the server wants to be known as) QString m_szSupportedUserModes; // the supported user modes - QString m_szSupportedChannelModes; // the supported channel modes (all of them) - QString m_szSupportedModePrefixes; // the actually used mode prefixes @+ - kvi_u32_t * m_pModePrefixTable; // the mode prefixes above in a table + QString m_szSupportedChannelModes = "pstnmiklb"; // the supported channel modes (all of them) + QString m_szSupportedModePrefixes = "@+"; // the actually used mode prefixes @+ + QString m_szSupportedStatusMsgPrefixes; // mode prefixes that can be used to target messages (from the STATUSMSG ISUPPORT token) + kvi_u32_t * m_pModePrefixTable = nullptr; // the mode prefixes above in a table unsigned int m_uPrefixes; - QString m_szSupportedModeFlags; // the actually used mode flags ov - QString m_szSupportedChannelTypes; // the supported channel types - bool m_bSupportsWatchList; // supports the watch list ? - bool m_bSupportsCodePages; // supports the /CODEPAGE command ? - int m_iMaxTopicLen; - int m_iMaxModeChanges; + QString m_szSupportedModeFlags = "ov"; // the actually used mode flags ov + QString m_szSupportedChannelTypes = "#&!+"; // the supported channel types + bool m_bSupportsWatchList = false; // supports the watch list ? + bool m_bSupportsCodePages = false; // supports the /CODEPAGE command ? + int m_iMaxTopicLen = -1; + int m_iMaxModeChanges = 3; // Mode that adds or removes a nick or address to a list. Always has a parameter (eg: "b" as ban) - QString m_szListModes; + QString m_szListModes = "b"; // Mode that changes a setting and always has a parameter (eg: "k" as channel key) - QString m_szParameterModes; + QString m_szParameterModes = "k"; // Mode that changes a setting and only has a parameter when set (eg: "l" as channel limit) - QString m_szParameterWhenSetModes; + QString m_szParameterWhenSetModes = "l"; // Mode that changes a setting and never has a parameter (eg: "m" as channel moderated) - QString m_szPlainModes; - bool m_bSupportsCap; + QString m_szPlainModes = "pstnmi"; + bool m_bSupportsCap = false; QStringList m_lSupportedCaps; - bool m_bSupportsWhox; // supports WHOX + bool m_bSupportsWhox = false; // supports WHOX public: - char registerModeChar() { return m_pServInfo ? m_pServInfo->getRegisterModeChar() : 0; }; - const char * software() { return m_pServInfo ? m_pServInfo->getSoftware() : 0; }; - bool getNeedsOpToListModeseI() { return m_pServInfo ? m_pServInfo->getNeedsOpToListModeseI() : false; }; - bool getNeedsOperToSetS() { return m_pServInfo ? m_pServInfo->getNeedsOperToSetS() : false; }; - const QString & name() { return m_szName; }; - const QString & networkName() { return m_szNetworkName; }; - const QString & supportedUserModes() { return m_szSupportedUserModes; }; - const QString & supportedChannelModes() { return m_szSupportedChannelModes; }; - const QString & supportedChannelTypes() { return m_szSupportedChannelTypes; }; - const QString & supportedModePrefixes() { return m_szSupportedModePrefixes; }; - const QString & supportedModeFlags() { return m_szSupportedModeFlags; }; - const QString & supportedListModes() { return m_szListModes; }; - const QString & supportedParameterModes() { return m_szParameterModes; }; - const QString & supportedParameterWhenSetModes() { return m_szParameterWhenSetModes; }; - const QString & supportedPlainModes() { return m_szPlainModes; }; - bool supportsCap() { return m_bSupportsCap; }; - const QStringList & supportedCaps() { return m_lSupportedCaps; }; - bool supportsWatchList() { return m_bSupportsWatchList; }; - bool supportsCodePages() { return m_bSupportsCodePages; }; - bool supportsWhox() { return m_bSupportsWhox; }; + char registerModeChar() const { return m_pServInfo ? m_pServInfo->getRegisterModeChar() : 0; } + const char * software() const { return m_pServInfo ? m_pServInfo->getSoftware() : 0; } + bool getNeedsOpToListModeseI() const { return m_pServInfo ? m_pServInfo->getNeedsOpToListModeseI() : false; } + bool getNeedsOperToSetS() const { return m_pServInfo ? m_pServInfo->getNeedsOperToSetS() : false; } + const QString & name() const { return m_szName; } + const QString & networkName() const { return m_szNetworkName; } + const QString & supportedUserModes() const { return m_szSupportedUserModes; } + const QString & supportedChannelModes() const { return m_szSupportedChannelModes; } + const QString & supportedChannelTypes() const { return m_szSupportedChannelTypes; } + const QString & supportedModePrefixes() const { return m_szSupportedModePrefixes; } + const QString & supportedStatusMsgPrefixes() const { return m_szSupportedStatusMsgPrefixes; } + const QString & supportedModeFlags() const { return m_szSupportedModeFlags; } + const QString & supportedListModes() const { return m_szListModes; } + const QString & supportedParameterModes() const { return m_szParameterModes; } + const QString & supportedParameterWhenSetModes() const { return m_szParameterWhenSetModes; } + const QString & supportedPlainModes() const { return m_szPlainModes; } + bool supportsCap() const { return m_bSupportsCap; } + const QStringList & supportedCaps() const { return m_lSupportedCaps; } + bool supportsWatchList() const { return m_bSupportsWatchList; } + bool supportsCodePages() const { return m_bSupportsCodePages; } + bool supportsWhox() const { return m_bSupportsWhox; } - int maxTopicLen() { return m_iMaxTopicLen; }; - int maxModeChanges() { return m_iMaxModeChanges; }; + int maxTopicLen() const { return m_iMaxTopicLen; } + int maxModeChanges() const { return m_iMaxModeChanges; } void setServerVersion(const QString & version); - const QString & getChannelModeDescription(char mode) { return m_pServInfo->getChannelModeDescription(mode); }; - const QString & getUserModeDescription(QChar mode) { return m_pServInfo->getUserModeDescription(mode); }; + const QString & getChannelModeDescription(char mode) const { return m_pServInfo->getChannelModeDescription(mode); } + const QString & getUserModeDescription(QChar mode) const { return m_pServInfo->getUserModeDescription(mode); } // Returning ! means the mode can never be set by the user. Returning QChar::Null means the mode is free to set. // Returning a QChar means the mode has another mode dependency (the QChar we're returning) - QChar getUserModeRequirement(QChar mode) { return m_pServInfo ? m_pServInfo->getUserModeRequirement(mode) : QChar::Null; }; + QChar getUserModeRequirement(QChar mode) const { return m_pServInfo ? m_pServInfo->getUserModeRequirement(mode) : QChar::Null; } - bool isSupportedChannelType(QChar c); - bool isSupportedModePrefix(QChar c); - bool isSupportedModeFlag(QChar c); - QChar modePrefixChar(kvi_u32_t flag); - QChar modeFlagChar(kvi_u32_t flag); - kvi_u32_t modeFlagFromPrefixChar(QChar c); - kvi_u32_t modeFlagFromModeChar(QChar c); + bool isSupportedChannelType(QChar c) const; + bool isSupportedModePrefix(QChar c) const; + bool isSupportedModeFlag(QChar c) const; + QChar modePrefixChar(kvi_u32_t flag) const; + QChar modeFlagChar(kvi_u32_t flag) const; + kvi_u32_t modeFlagFromPrefixChar(QChar c) const; + kvi_u32_t modeFlagFromModeChar(QChar c) const; protected: - void setNetworkName(const QString & szName) { m_szNetworkName = szName; }; - void setName(const QString & szName) { m_szName = szName; }; - void setSupportedUserModes(const QString & szSupportedUserModes) { m_szSupportedUserModes = szSupportedUserModes; }; + void setNetworkName(const QString & szName) { m_szNetworkName = szName; } + void setName(const QString & szName) { m_szName = szName; } + void setSupportedUserModes(const QString & szSupportedUserModes) { m_szSupportedUserModes = szSupportedUserModes; } void setSupportedChannelModes(const QString & szSupportedChannelModes); void setSupportedModePrefixes(const QString & szSupportedModePrefixes, const QString & szSupportedModeFlags); - void setSupportedChannelTypes(const QString & szSupportedChannelTypes) { m_szSupportedChannelTypes = szSupportedChannelTypes; }; - void setSupportsWatchList(bool bSupportsWatchList) { m_bSupportsWatchList = bSupportsWatchList; }; - void setSupportsCodePages(bool bSupportsCodePages) { m_bSupportsCodePages = bSupportsCodePages; }; + void setSupportedStatusMsgPrefixes(const QString & szSupportedStatusMsgPrefixes) { m_szSupportedStatusMsgPrefixes = szSupportedStatusMsgPrefixes; } + void setSupportedChannelTypes(const QString & szSupportedChannelTypes) { m_szSupportedChannelTypes = szSupportedChannelTypes; } + void setSupportsWatchList(bool bSupportsWatchList) { m_bSupportsWatchList = bSupportsWatchList; } + void setSupportsCodePages(bool bSupportsCodePages) { m_bSupportsCodePages = bSupportsCodePages; } void addSupportedCaps(const QString & szCapList); - void setMaxTopicLen(int iTopLen) { m_iMaxTopicLen = iTopLen; }; - void setMaxModeChanges(int iModes) { m_iMaxModeChanges = iModes; }; - void setSupportsWhox(bool bSupportsWhox) { m_bSupportsWhox = bSupportsWhox; }; + void setMaxTopicLen(int iTopLen) { m_iMaxTopicLen = iTopLen; } + void setMaxModeChanges(int iModes) { m_iMaxModeChanges = iModes; } + void setSupportsWhox(bool bSupportsWhox) { m_bSupportsWhox = bSupportsWhox; } private: void buildModePrefixTable(); }; diff --git a/src/kvirc/kernel/KviIrcConnectionStateData.cpp b/src/kvirc/kernel/KviIrcConnectionStateData.cpp index 19753bd27..4712371d6 100644 --- a/src/kvirc/kernel/KviIrcConnectionStateData.cpp +++ b/src/kvirc/kernel/KviIrcConnectionStateData.cpp @@ -26,18 +26,8 @@ KviIrcConnectionStateData::KviIrcConnectionStateData() { - m_bSentStartTls = false; - m_bSentQuit = false; - m_bInsideInitialCapLs = false; - m_bInsideInitialCapReq = false; - m_bInsideInitialStartTls = false; - m_bIgnoreOneYouHaveNotRegisteredError = false; - m_eLoginNickNameState = UsedConnectionSpecificNickName; - m_bSimulateUnexpectedDisconnect = false; m_tLastReceivedChannelWhoReply = kvi_unixTime(); m_tLastSentChannelWhoRequest = m_tLastReceivedChannelWhoReply; - m_tLastReceivedWhoisReply = 0; - m_bIdentifyMsgCapabilityEnabled = false; } KviIrcConnectionStateData::~KviIrcConnectionStateData() @@ -45,17 +35,13 @@ KviIrcConnectionStateData::~KviIrcConnectionStateData() void KviIrcConnectionStateData::changeEnabledCapList(const QString & szCapList) { - QStringList lTmp = szCapList.split(' ', QString::SkipEmptyParts); - foreach(QString szCap, lTmp) + for(auto szCap : szCapList.split(' ', QString::SkipEmptyParts)) { // cap modifiers are: // '-' : disable a capability (should not be present in a LS message...) // '=' : sticky (can't be disabled once enabled) // '~' : needs ack for modification - if(szCap.length() < 1) - continue; // shouldn't happen - bool bRemove = false; switch(szCap[0].unicode()) @@ -78,13 +64,8 @@ void KviIrcConnectionStateData::changeEnabledCapList(const QString & szCapList) m_bIdentifyMsgCapabilityEnabled = !bRemove; if(bRemove) - { m_lEnabledCaps.removeAll(szCap); - } - else - { - if(!m_lEnabledCaps.contains(szCap)) - m_lEnabledCaps.append(szCap); - } + else if(!m_lEnabledCaps.contains(szCap)) + m_lEnabledCaps.append(szCap); } } diff --git a/src/kvirc/kernel/KviIrcConnectionStateData.h b/src/kvirc/kernel/KviIrcConnectionStateData.h index 1750b4c95..21c902b09 100644 --- a/src/kvirc/kernel/KviIrcConnectionStateData.h +++ b/src/kvirc/kernel/KviIrcConnectionStateData.h @@ -25,8 +25,8 @@ //============================================================================= #include "kvi_settings.h" -#include "KviTimeUtils.h" #include "KviQString.h" +#include "KviTimeUtils.h" #include <QStringList> @@ -74,9 +74,9 @@ protected: /// /// the current login nickname state /// - LoginNickNameState m_eLoginNickNameState; + LoginNickNameState m_eLoginNickNameState = UsedConnectionSpecificNickName; - bool m_bInsideInitialCapLs; // true if there's a CAP LS request pending + bool m_bInsideInitialCapLs = false; // true if there's a CAP LS request pending /// /// This is set to true if a forced STARTTLS request has been sent /// to the server followed by a PING. We use this flag to gracefully @@ -85,19 +85,20 @@ protected: /// Note that in this case the STARTTLS support wasn't detected by a previous CAP LS /// (which wasn't sent at all). /// - bool m_bInsideInitialStartTls; - bool m_bIgnoreOneYouHaveNotRegisteredError; // true if we have sent a CAP LS request followed by a PING which will generate an error (and we need to ignore it) - bool m_bInsideInitialCapReq; // true if there's a CAP REQ request pending - bool m_bInsideAuthenticate; // true if there's a AUTHENTICATE request pending - bool m_bSentStartTls; // the state of STARTTLS protocol - bool m_bSentQuit; // have we sent the quit message for this connection ? + bool m_bInsideInitialStartTls = false; + bool m_bIgnoreOneYouHaveNotRegisteredError = false; // true if we have sent a CAP LS request followed by a PING which will generate an error (and we need to ignore it) + bool m_bInsideInitialCapReq = false; // true if there's a CAP REQ request pending + bool m_bInsideAuthenticate = false; // true if there's a AUTHENTICATE request pending + bool m_bSentStartTls = false; // the state of STARTTLS protocol + bool m_bSentQuit = false; // have we sent the quit message for this connection ? QString m_szCommandToExecAfterConnect; // yes.. this is a special command to execute after connection - bool m_bSimulateUnexpectedDisconnect; // this is set to true if we have to simulate an unexpected disconnect even if we have sent a normal quit message + bool m_bSimulateUnexpectedDisconnect = false; // this is set to true if we have to simulate an unexpected disconnect even if we have sent a normal quit message kvi_time_t m_tLastReceivedChannelWhoReply; // the time that we have received our last channel who reply kvi_time_t m_tLastSentChannelWhoRequest; // the time that we have sent our last channel who request - kvi_time_t m_tLastReceivedWhoisReply; // the time that we have received the last whois reply, reset to 0 when we receive an /END OF WHOIS + kvi_time_t m_tLastReceivedWhoisReply = 0; // the time that we have received the last whois reply, reset to 0 when we receive an /END OF WHOIS QStringList m_lEnabledCaps; // the CAPs currently enabled - bool m_bIdentifyMsgCapabilityEnabled; // do we have the msg-identity CAP enabled ? + bool m_bIdentifyMsgCapabilityEnabled = false; // do we have the msg-identity CAP enabled ? + QString m_szSentSaslMethod; public: /// /// Sets the current login nickname state @@ -115,55 +116,58 @@ public: return m_eLoginNickNameState; } - const QStringList & enabledCaps() { return m_lEnabledCaps; }; + const QStringList & enabledCaps() const { return m_lEnabledCaps; } void changeEnabledCapList(const QString & szCapList); bool identifyMsgCapabilityEnabled() const { return m_bIdentifyMsgCapabilityEnabled; - }; + } + + const QString & sentSaslMethod() const { return m_szSentSaslMethod; } + void setSentSaslMethod(const QString& szMethod) { m_szSentSaslMethod = szMethod; } - bool sentStartTls() { return m_bSentStartTls; }; - void setSentStartTls() { m_bSentStartTls = true; }; + bool sentStartTls() const { return m_bSentStartTls; } + void setSentStartTls() { m_bSentStartTls = true; } - bool isInsideAuthenticate() { return m_bInsideAuthenticate; }; - void setInsideAuthenticate(bool bInside) { m_bInsideAuthenticate = bInside; }; + bool isInsideAuthenticate() const { return m_bInsideAuthenticate; } + void setInsideAuthenticate(bool bInside) { m_bInsideAuthenticate = bInside; } - bool isInsideInitialCapLs() { return m_bInsideInitialCapLs; }; - void setInsideInitialCapLs(bool bInside) { m_bInsideInitialCapLs = bInside; }; + bool isInsideInitialCapLs() const { return m_bInsideInitialCapLs; } + void setInsideInitialCapLs(bool bInside) { m_bInsideInitialCapLs = bInside; } - bool isInsideInitialStartTls() { return m_bInsideInitialStartTls; }; - void setInsideInitialStartTls(bool bInside) { m_bInsideInitialStartTls = bInside; }; + bool isInsideInitialStartTls() const { return m_bInsideInitialStartTls; } + void setInsideInitialStartTls(bool bInside) { m_bInsideInitialStartTls = bInside; } void setIgnoreOneYouHaveNotRegisteredError(bool bIgnore) { m_bIgnoreOneYouHaveNotRegisteredError = bIgnore; - }; + } bool ignoreOneYouHaveNotRegisteredError() const { return m_bIgnoreOneYouHaveNotRegisteredError; - }; + } - bool isInsideInitialCapReq() { return m_bInsideInitialCapReq; }; - void setInsideInitialCapReq(bool bInside) { m_bInsideInitialCapReq = bInside; }; + bool isInsideInitialCapReq() const { return m_bInsideInitialCapReq; } + void setInsideInitialCapReq(bool bInside) { m_bInsideInitialCapReq = bInside; } - bool sentQuit() { return m_bSentQuit; }; - void setSentQuit() { m_bSentQuit = true; }; + bool sentQuit() const { return m_bSentQuit; } + void setSentQuit() { m_bSentQuit = true; } - kvi_time_t lastReceivedChannelWhoReply() { return m_tLastReceivedChannelWhoReply; }; - void setLastReceivedChannelWhoReply(kvi_time_t tTime) { m_tLastReceivedChannelWhoReply = tTime; }; + kvi_time_t lastReceivedChannelWhoReply() const { return m_tLastReceivedChannelWhoReply; } + void setLastReceivedChannelWhoReply(kvi_time_t tTime) { m_tLastReceivedChannelWhoReply = tTime; } - kvi_time_t lastSentChannelWhoRequest() { return m_tLastSentChannelWhoRequest; }; - void setLastSentChannelWhoRequest(kvi_time_t tTime) { m_tLastSentChannelWhoRequest = tTime; }; + kvi_time_t lastSentChannelWhoRequest() const { return m_tLastSentChannelWhoRequest; } + void setLastSentChannelWhoRequest(kvi_time_t tTime) { m_tLastSentChannelWhoRequest = tTime; } - kvi_time_t lastReceivedWhoisReply() { return m_tLastReceivedWhoisReply; }; - void setLastReceivedWhoisReply(kvi_time_t tTime) { m_tLastReceivedWhoisReply = tTime; }; + kvi_time_t lastReceivedWhoisReply() const { return m_tLastReceivedWhoisReply; } + void setLastReceivedWhoisReply(kvi_time_t tTime) { m_tLastReceivedWhoisReply = tTime; } - bool simulateUnexpectedDisconnect() { return m_bSimulateUnexpectedDisconnect; }; - void setSimulateUnexpectedDisconnect(bool bSimulate) { m_bSimulateUnexpectedDisconnect = bSimulate; }; + bool simulateUnexpectedDisconnect() const { return m_bSimulateUnexpectedDisconnect; } + void setSimulateUnexpectedDisconnect(bool bSimulate) { m_bSimulateUnexpectedDisconnect = bSimulate; } - const QString & commandToExecAfterConnect() { return m_szCommandToExecAfterConnect; }; - void setCommandToExecAfterConnect(const QString & szCmd) { m_szCommandToExecAfterConnect = szCmd; }; + const QString & commandToExecAfterConnect() const { return m_szCommandToExecAfterConnect; } + void setCommandToExecAfterConnect(const QString & szCmd) { m_szCommandToExecAfterConnect = szCmd; } }; #endif //!_KVI_IRCCONNECTIONSTATEDATA_H_ diff --git a/src/kvirc/kernel/KviIrcConnectionStatistics.cpp b/src/kvirc/kernel/KviIrcConnectionStatistics.cpp index edf6c7d57..af7a2b6f7 100644 --- a/src/kvirc/kernel/KviIrcConnectionStatistics.cpp +++ b/src/kvirc/kernel/KviIrcConnectionStatistics.cpp @@ -25,10 +25,7 @@ #include "KviIrcConnectionStatistics.h" KviIrcConnectionStatistics::KviIrcConnectionStatistics() -{ - m_tConnectionStart = 0; - m_tLastMessage = 0; -} + = default; KviIrcConnectionStatistics::~KviIrcConnectionStatistics() = default; diff --git a/src/kvirc/kernel/KviIrcConnectionStatistics.h b/src/kvirc/kernel/KviIrcConnectionStatistics.h index 8fcfb9053..89a36a482 100644 --- a/src/kvirc/kernel/KviIrcConnectionStatistics.h +++ b/src/kvirc/kernel/KviIrcConnectionStatistics.h @@ -30,7 +30,6 @@ class KVIRC_API KviIrcConnectionStatistics { - friend class KviConsoleWindow; // to be removed friend class KviIrcConnection; public: @@ -38,14 +37,14 @@ public: ~KviIrcConnectionStatistics(); protected: - kvi_time_t m_tConnectionStart; // (valid only when Connected or LoggingIn) - kvi_time_t m_tLastMessage; // last message received from server + kvi_time_t m_tConnectionStart = 0; // (valid only when Connected or LoggingIn) + kvi_time_t m_tLastMessage = 0; // last message received from server public: - kvi_time_t connectionStartTime() { return m_tConnectionStart; }; - kvi_time_t lastMessageTime() { return m_tLastMessage; }; + kvi_time_t connectionStartTime() const { return m_tConnectionStart; } + kvi_time_t lastMessageTime() const { return m_tLastMessage; } protected: - void setLastMessageTime(kvi_time_t t) { m_tLastMessage = t; }; - void setConnectionStartTime(kvi_time_t t) { m_tConnectionStart = t; }; + void setLastMessageTime(kvi_time_t t) { m_tLastMessage = t; } + void setConnectionStartTime(kvi_time_t t) { m_tConnectionStart = t; } }; #endif //!_KVI_IRCCONNECTIONSTATISTICS_H_ diff --git a/src/kvirc/kernel/KviIrcConnectionTarget.cpp b/src/kvirc/kernel/KviIrcConnectionTarget.cpp index 5580e5b02..c6b2d44bc 100644 --- a/src/kvirc/kernel/KviIrcConnectionTarget.cpp +++ b/src/kvirc/kernel/KviIrcConnectionTarget.cpp @@ -36,7 +36,8 @@ KviIrcConnectionTarget::KviIrcConnectionTarget( { m_pNetwork = new KviIrcNetwork(*pNetwork); m_pServer = new KviIrcServer(*pServer); - m_pProxy = pProxy ? new KviProxy(*pProxy) : nullptr; + if(pProxy) + m_pProxy = new KviProxy(*pProxy); m_szBindAddress = szBindAddress; } diff --git a/src/kvirc/kernel/KviIrcConnectionTarget.h b/src/kvirc/kernel/KviIrcConnectionTarget.h index 4b2bde89b..3735c34e8 100644 --- a/src/kvirc/kernel/KviIrcConnectionTarget.h +++ b/src/kvirc/kernel/KviIrcConnectionTarget.h @@ -42,49 +42,27 @@ public: KviIrcConnectionTarget( const KviIrcNetwork * pNetwork, const KviIrcServer * pServer, - const KviProxy * pProxy = 0, - const QString & szBindAddress = QString()); + const KviProxy * pProxy = nullptr, + const QString & szBindAddress = {}); ~KviIrcConnectionTarget(); private: - KviIrcNetwork * m_pNetwork; // owned, never null, it's a COPY of the entry in the db - KviIrcServer * m_pServer; // owned, never null, it's a COPY of the entry in the db - KviProxy * m_pProxy; // owned, may be null, it's a COPY of the entry in the db - QString m_szBindAddress; // forced bind address + KviIrcNetwork * m_pNetwork; // owned, never null, it's a COPY of the entry in the db + KviIrcServer * m_pServer; // owned, never null, it's a COPY of the entry in the db + KviProxy * m_pProxy = nullptr; // owned, may be null, it's a COPY of the entry in the db + QString m_szBindAddress; // forced bind address public: - KviIrcServer * server() - { - return m_pServer; - } - - KviIrcNetwork * network() - { - return m_pNetwork; - } - - KviProxy * proxy() - { - return m_pProxy; - } - - const QString & bindAddress() - { - return m_szBindAddress; - } - - bool hasBindAddress() - { - return (!m_szBindAddress.isEmpty()); - } + KviIrcServer * server() const { return m_pServer; } + KviIrcNetwork * network() const { return m_pNetwork; } + KviProxy * proxy() const { return m_pProxy; } + const QString & bindAddress() const { return m_szBindAddress; } + bool hasBindAddress() const { return !m_szBindAddress.isEmpty(); } protected: // this is for KviIrcConnectionTargetResolver only void clearProxy(); - void setBindAddress(const QString & szBindAddress) - { - m_szBindAddress = szBindAddress; - } + void setBindAddress(const QString & szBindAddress) { m_szBindAddress = szBindAddress; } }; #endif //!_KVI_IRCCONNECTIONTARGET_H_ diff --git a/src/kvirc/kernel/KviIrcConnectionTargetResolver.cpp b/src/kvirc/kernel/KviIrcConnectionTargetResolver.cpp index 1bd1c890e..118f31a49 100644 --- a/src/kvirc/kernel/KviIrcConnectionTargetResolver.cpp +++ b/src/kvirc/kernel/KviIrcConnectionTargetResolver.cpp @@ -28,7 +28,6 @@ #include "KviIrcServerDataBase.h" #include "KviProxy.h" #include "KviProxyDataBase.h" -#include "KviError.h" #include "kvi_out.h" #include "KviOptions.h" #include "KviIrcSocket.h" @@ -43,28 +42,17 @@ #include "KviIrcConnectionTarget.h" #include "KviIrcNetwork.h" -#include <stdlib.h> - #include <QTimer> +#include <cstdlib> + extern KVIRC_API KviIrcServerDataBase * g_pServerDataBase; extern KVIRC_API KviProxyDataBase * g_pProxyDataBase; KviIrcConnectionTargetResolver::KviIrcConnectionTargetResolver(KviIrcConnection * pConnection) - : QObject() + : QObject(), m_pConnection(pConnection) { - m_pConnection = pConnection; - m_pTarget = nullptr; m_pConsole = m_pConnection->console(); - - m_pStartTimer = nullptr; - m_pProxyDns = nullptr; - m_pServerDns = nullptr; - - m_eState = Idle; - m_eStatus = Success; - - m_iLastError = KviError::Success; } KviIrcConnectionTargetResolver::~KviIrcConnectionTargetResolver() @@ -179,16 +167,10 @@ void KviIrcConnectionTargetResolver::lookupProxyHostname() bool bValidIp; #ifdef COMPILE_IPV6_SUPPORT if(m_pTarget->proxy()->isIPv6()) - { bValidIp = KviNetUtils::isValidStringIPv6(m_pTarget->proxy()->ip()); - } else - { #endif bValidIp = KviNetUtils::isValidStringIp(m_pTarget->proxy()->ip()); -#ifdef COMPILE_IPV6_SUPPORT - } -#endif if(bValidIp) { @@ -206,27 +188,18 @@ void KviIrcConnectionTargetResolver::lookupProxyHostname() { #ifdef COMPILE_IPV6_SUPPORT if(m_pTarget->proxy()->isIPv6()) - { bValidIp = KviNetUtils::isValidStringIPv6(m_pTarget->proxy()->hostname()); - } else - { #endif bValidIp = KviNetUtils::isValidStringIp(m_pTarget->proxy()->hostname()); -#ifdef COMPILE_IPV6_SUPPORT - } -#endif + if(bValidIp) { m_pTarget->proxy()->setIp(m_pTarget->proxy()->hostname()); if(m_pTarget->proxy()->protocol() != KviProxy::Http && m_pTarget->proxy()->protocol() != KviProxy::Socks5) - { lookupServerHostname(); - } else - { terminate(Success, KviError::Success); - } } else { @@ -309,16 +282,10 @@ void KviIrcConnectionTargetResolver::lookupServerHostname() #ifdef COMPILE_IPV6_SUPPORT if(m_pTarget->server()->isIPv6()) - { bValidIp = KviNetUtils::isValidStringIPv6(m_pTarget->server()->ip()); - } else - { #endif bValidIp = KviNetUtils::isValidStringIp(m_pTarget->server()->ip()); -#ifdef COMPILE_IPV6_SUPPORT - } -#endif if(bValidIp && m_pTarget->server()->cacheIp()) { @@ -332,16 +299,11 @@ void KviIrcConnectionTargetResolver::lookupServerHostname() { #ifdef COMPILE_IPV6_SUPPORT if(m_pTarget->server()->isIPv6()) - { bValidIp = KviNetUtils::isValidStringIPv6(m_pTarget->server()->hostName()); - } else - { #endif bValidIp = KviNetUtils::isValidStringIp(m_pTarget->server()->hostName()); -#ifdef COMPILE_IPV6_SUPPORT - } -#endif + if(bValidIp) { m_pTarget->server()->setIp(m_pTarget->server()->hostName()); @@ -489,8 +451,8 @@ void KviIrcConnectionTargetResolver::haveServerIp() { if(!validateLocalAddress(m_pTarget->bindAddress(), bindAddress)) { - QString szBindAddress = m_pTarget->bindAddress(); - if((szBindAddress.indexOf('.') != -1) || (szBindAddress.indexOf(':') != -1)) + const QString & szBindAddress = m_pTarget->bindAddress(); + if(szBindAddress.contains('.') || szBindAddress.contains(':')) { if(!_OUTPUT_MUTE) m_pConsole->output(KVI_OUT_SYSTEMWARNING, @@ -502,7 +464,7 @@ void KviIrcConnectionTargetResolver::haveServerIp() if(!_OUTPUT_MUTE) m_pConsole->output(KVI_OUT_SYSTEMWARNING, __tr2qs("The specified bind address (%Q) is not valid (the interface it refers to might be down)"), - &(szBindAddress)); + &szBindAddress); } } } @@ -519,7 +481,7 @@ void KviIrcConnectionTargetResolver::haveServerIp() if(!validateLocalAddress(KVI_OPTION_STRING(KviOption_stringIPv6ConnectionBindAddress), bindAddress)) { // if it is not an interface name, kill it for now and let the user correct the address - if(KVI_OPTION_STRING(KviOption_stringIPv6ConnectionBindAddress).indexOf(':') != -1) + if(KVI_OPTION_STRING(KviOption_stringIPv6ConnectionBindAddress).contains(':')) { if(!_OUTPUT_MUTE) m_pConsole->output(KVI_OUT_SYSTEMWARNING, @@ -554,7 +516,7 @@ void KviIrcConnectionTargetResolver::haveServerIp() if(!validateLocalAddress(KVI_OPTION_STRING(KviOption_stringIPv4ConnectionBindAddress), bindAddress)) { // if it is not an interface name, kill it for now and let the user correct the address - if(KVI_OPTION_STRING(KviOption_stringIPv4ConnectionBindAddress).indexOf(':') != -1) + if(KVI_OPTION_STRING(KviOption_stringIPv4ConnectionBindAddress).contains(':')) { if(!_OUTPUT_MUTE) m_pConsole->output(KVI_OUT_SYSTEMWARNING, diff --git a/src/kvirc/kernel/KviIrcConnectionTargetResolver.h b/src/kvirc/kernel/KviIrcConnectionTargetResolver.h index 2c42f5e81..5c6a1ce71 100644 --- a/src/kvirc/kernel/KviIrcConnectionTargetResolver.h +++ b/src/kvirc/kernel/KviIrcConnectionTargetResolver.h @@ -25,6 +25,7 @@ //============================================================================= #include "kvi_settings.h" +#include "KviError.h" #include "KviQString.h" #include <QObject> @@ -70,28 +71,24 @@ public: }; private: - KviIrcConnection * m_pConnection; // shallow, never null - KviIrcConnectionTarget * m_pTarget; // shallow, never null - KviConsoleWindow * m_pConsole; // shallow, never null - Status m_eStatus; - State m_eState; + KviIrcConnection * m_pConnection; // shallow, never null + KviIrcConnectionTarget * m_pTarget = nullptr; // shallow, never null + KviConsoleWindow * m_pConsole; // shallow, never null + Status m_eStatus = Success; + State m_eState = Idle; // Auxiliary stuff - QTimer * m_pStartTimer; // timer used to start the connection - KviDnsResolver * m_pProxyDns; // the dns object for the proxy hostnames - KviDnsResolver * m_pServerDns; // the dns object for the server hostnames + QTimer * m_pStartTimer = nullptr; // timer used to start the connection + KviDnsResolver * m_pProxyDns = nullptr; // the dns object for the proxy hostnames + KviDnsResolver * m_pServerDns = nullptr; // the dns object for the server hostnames - char * m_pReadBuffer; - unsigned int m_uReadBufferLen; - unsigned int m_uReadPackets; - - int m_iLastError; + int m_iLastError = KviError::Success; public: void start(KviIrcConnectionTarget * t); // valid only after the terminated() signal - Status status() { return m_eStatus; }; - int lastError() { return m_iLastError; }; + Status status() const { return m_eStatus; } + int lastError() const { return m_iLastError; } // causes the resolver to terminate with iLastError == KviError_operationAborted // the terminated() signal is emitted. void abort(); diff --git a/src/kvirc/kernel/KviIrcConnectionUserInfo.cpp b/src/kvirc/kernel/KviIrcConnectionUserInfo.cpp index 5959e7b9b..75d596a65 100644 --- a/src/kvirc/kernel/KviIrcConnectionUserInfo.cpp +++ b/src/kvirc/kernel/KviIrcConnectionUserInfo.cpp @@ -25,9 +25,7 @@ #include "KviIrcConnectionUserInfo.h" KviIrcConnectionUserInfo::KviIrcConnectionUserInfo() -{ - m_bAway = false; -} + = default; bool KviIrcConnectionUserInfo::hasUserMode(const QChar & m) { @@ -44,8 +42,7 @@ bool KviIrcConnectionUserInfo::addUserMode(const QChar & m) bool KviIrcConnectionUserInfo::removeUserMode(const QChar & m) { - int idx = m_szUserMode.indexOf(m, 0); - if(idx == -1) + if(!hasUserMode(m)) return false; m_szUserMode.replace(m, QString("")); return true; diff --git a/src/kvirc/kernel/KviIrcConnectionUserInfo.h b/src/kvirc/kernel/KviIrcConnectionUserInfo.h index 625b31f15..2292d658c 100644 --- a/src/kvirc/kernel/KviIrcConnectionUserInfo.h +++ b/src/kvirc/kernel/KviIrcConnectionUserInfo.h @@ -25,9 +25,10 @@ //============================================================================= #include "kvi_settings.h" -#include "KviQString.h" #include "KviTimeUtils.h" +#include <QString> + class KVIRC_API KviIrcConnectionUserInfo { friend class KviIrcConnection; @@ -36,7 +37,7 @@ class KVIRC_API KviIrcConnectionUserInfo protected: KviIrcConnectionUserInfo(); - ~KviIrcConnectionUserInfo(){}; + ~KviIrcConnectionUserInfo() = default; private: QString m_szRealName; // the actual real name sent from the server @@ -48,7 +49,7 @@ private: QString m_szHostName; // the local host name that the server reports QString m_szHostIp; // the host name above resolved, if possible QString m_szAwayReason; - bool m_bAway; // is the user away ? + bool m_bAway = false; // is the user away ? kvi_time_t m_tAway; // time at that the user went away QString m_szNickBeforeAway; // the nickname that the user had just before going away // From bugtrack: @@ -60,33 +61,33 @@ private: QString m_szUnmaskedHostName; public: - const QString & realName() { return m_szRealName; }; - const QString & nickName() { return m_szNickName; }; - const QString & userMode() { return m_szUserMode; }; - const QString & userName() { return m_szUserName; }; - const QString & password() { return m_szPassword; }; - const QString & localHostIp() { return m_szLocalHostIp; }; - const QString & hostName() { return m_szHostName; }; - const QString & unmaskedHostName() { return m_szUnmaskedHostName; }; - const QString & hostIp() { return m_szHostIp; }; - const QString & awayReason() { return m_szAwayReason; }; + const QString & realName() const { return m_szRealName; } + const QString & nickName() const { return m_szNickName; } + const QString & userMode() const { return m_szUserMode; } + const QString & userName() const { return m_szUserName; } + const QString & password() const { return m_szPassword; } + const QString & localHostIp() const { return m_szLocalHostIp; } + const QString & hostName() const { return m_szHostName; } + const QString & unmaskedHostName() const { return m_szUnmaskedHostName; } + const QString & hostIp() const { return m_szHostIp; } + const QString & awayReason() const { return m_szAwayReason; } bool hasUserMode(const QChar & m); - bool isAway() { return m_bAway; }; - time_t awayTime() { return m_tAway; }; - const QString & nickNameBeforeAway() { return m_szNickBeforeAway; }; + bool isAway() const { return m_bAway; } + kvi_time_t awayTime() const { return m_tAway; } + const QString & nickNameBeforeAway() const { return m_szNickBeforeAway; } protected: - void setRealName(const QString & szRealName) { m_szRealName = szRealName; }; - void setNickName(const QString & szNickName) { m_szNickName = szNickName; }; - void setUserMode(const QString & szUserMode) { m_szUserMode = szUserMode; }; - void setUserName(const QString & szUserName) { m_szUserName = szUserName; }; - void setPassword(const QString & szPassword) { m_szPassword = szPassword; }; - void setHostName(const QString & szHostName) { m_szHostName = szHostName; }; - void setUnmaskedHostName(const QString & szHostName) { m_szUnmaskedHostName = szHostName; }; - void setHostIp(const QString & szHostIp) { m_szHostIp = szHostIp; }; - void setLocalHostIp(const QString & szLocalHostIp) { m_szLocalHostIp = szLocalHostIp; }; + void setRealName(const QString & szRealName) { m_szRealName = szRealName; } + void setNickName(const QString & szNickName) { m_szNickName = szNickName; } + void setUserMode(const QString & szUserMode) { m_szUserMode = szUserMode; } + void setUserName(const QString & szUserName) { m_szUserName = szUserName; } + void setPassword(const QString & szPassword) { m_szPassword = szPassword; } + void setHostName(const QString & szHostName) { m_szHostName = szHostName; } + void setUnmaskedHostName(const QString & szHostName) { m_szUnmaskedHostName = szHostName; } + void setHostIp(const QString & szHostIp) { m_szHostIp = szHostIp; } + void setLocalHostIp(const QString & szLocalHostIp) { m_szLocalHostIp = szLocalHostIp; } bool addUserMode(const QChar & m); // returns false if the mode was already there bool removeUserMode(const QChar & m); // returns fales if the mode was not there - void setAwayReason(const QString & szReazon) { m_szAwayReason = szReazon; }; + void setAwayReason(const QString & szReazon) { m_szAwayReason = szReazon; } void setAway(); void setBack(); }; diff --git a/src/kvirc/kernel/KviIrcContext.cpp b/src/kvirc/kernel/KviIrcContext.cpp index d3ff543f1..92592831d 100644 --- a/src/kvirc/kernel/KviIrcContext.cpp +++ b/src/kvirc/kernel/KviIrcContext.cpp @@ -69,27 +69,11 @@ extern KVIRC_API KviIrcServerDataBase * g_pServerDataBase; extern KVIRC_API KviProxyDataBase * g_pProxyDataBase; KviIrcContext::KviIrcContext(KviConsoleWindow * pConsole) - : QObject(nullptr) + : QObject(), m_pConsole(pConsole) { m_uId = g_uNextIrcContextId; g_uNextIrcContextId++; - m_pConsole = pConsole; - - m_pConnection = nullptr; - - m_pLinksWindow = nullptr; - m_pListWindow = nullptr; - - m_eState = Idle; - - m_pAsynchronousConnectionData = nullptr; - m_pSavedAsynchronousConnectionData = nullptr; - m_uConnectAttemptCount = 0; - m_pReconnectTimer = nullptr; - - m_uConnectAttemptCount = 1; - m_iHeartbeatTimerId = startTimer(5000); } @@ -179,6 +163,7 @@ KviQueryWindow * KviIrcContext::findDeadQuery(const QString & name) if(KviQString::equalCI(name, q->windowName())) return q; } + return nullptr; } @@ -219,11 +204,11 @@ bool KviIrcContext::unregisterDeadChannel(KviChannelWindow * c) if(m_DeadChannels.empty()) return false; - int pos = std::find(m_DeadChannels.begin(), m_DeadChannels.end(), c) - m_DeadChannels.begin(); + auto result = std::find(m_DeadChannels.begin(), m_DeadChannels.end(), c); - if(pos < m_DeadChannels.size()) + if(result != m_DeadChannels.end()) { - m_DeadChannels.erase(m_DeadChannels.begin() + pos); + m_DeadChannels.erase(result); return true; } @@ -235,11 +220,11 @@ bool KviIrcContext::unregisterContextWindow(KviWindow * pWnd) if(m_ContextWindows.empty()) return false; - int pos = std::find(m_ContextWindows.begin(), m_ContextWindows.end(), pWnd) - m_ContextWindows.begin(); + auto result = std::find(m_ContextWindows.begin(), m_ContextWindows.end(), pWnd); - if(pos < m_ContextWindows.size()) + if(result != m_ContextWindows.end()) { - m_ContextWindows.erase(m_ContextWindows.begin() + pos); + m_ContextWindows.erase(result); return true; } @@ -251,11 +236,11 @@ bool KviIrcContext::unregisterDeadQuery(KviQueryWindow * q) if(m_DeadQueries.empty()) return false; - int pos = std::find(m_DeadQueries.begin(), m_DeadQueries.end(), q) - m_DeadQueries.begin(); + auto result = std::find(m_DeadQueries.begin(), m_DeadQueries.end(), q); - if(pos < m_DeadQueries.size()) + if(result != m_DeadQueries.end()) { - m_DeadQueries.erase(m_DeadQueries.begin() + pos); + m_DeadQueries.erase(result); return true; } @@ -290,7 +275,7 @@ void KviIrcContext::destroyConnection() m_pConsole->connectionDetached(); - // make sure that m_pConnection is already 0 in any + // make sure that m_pConnection is already nullptr in any // event triggered by KviIrcConnection destructor KviIrcConnection * pTmp = m_pConnection; m_pConnection = nullptr; @@ -388,8 +373,7 @@ void KviIrcContext::connectToCurrentServer() if(m_pAsynchronousConnectionData->szServer.isEmpty()) { // an empty server might mean "reuse the last server in context" - if( - m_pAsynchronousConnectionData->bUseLastServerInContext && m_pSavedAsynchronousConnectionData) + if(m_pAsynchronousConnectionData->bUseLastServerInContext && m_pSavedAsynchronousConnectionData) { // reuse the saved connection data // the server for sure @@ -456,27 +440,17 @@ void KviIrcContext::connectToCurrentServer() KviIrcNetwork * net = g_pServerDataBase->currentNetwork(); KviIrcServer * srv = net ? net->currentServer() : nullptr; - KviProxy * prx = nullptr; - if(!srv) { if(g_pServerDataBase->networkCount()) - KviKvsScript::run("options.edit OptionsWidget_servers", m_pConsole); + KviKvsScript::run("options.edit -n OptionsWidget_servers", m_pConsole); else m_pConsole->outputNoFmt(KVI_OUT_SYSTEMERROR, __tr2qs("No servers available. Check the options dialog or use the /SERVER command")); destroyAsynchronousConnectionData(); return; } - if(!net) - { - // BUG - m_pConsole->outputNoFmt(KVI_OUT_SYSTEMERROR, __tr2qs("Oops! You've hit a bug in the servers database... I have found a server but not a network...")); - destroyAsynchronousConnectionData(); - return; - } - - prx = srv->proxyServer(g_pProxyDataBase); + KviProxy * prx = srv->proxyServer(g_pProxyDataBase); if(!prx && (srv->proxy() != -1) && KVI_OPTION_BOOL(KviOption_boolUseProxyHost)) { @@ -652,11 +626,9 @@ void KviIrcContext::connectionEstablished() // m_uConnectAttemptCount = 1; - bool bStopOutput = false; - setState(LoggingIn); // this must be set in order for $server and other functions to return the correct values - bStopOutput = KVS_TRIGGER_EVENT_0_HALTED(KviEvent_OnIRCConnectionEstablished, m_pConsole); + bool bStopOutput = KVS_TRIGGER_EVENT_0_HALTED(KviEvent_OnIRCConnectionEstablished, m_pConsole); if(!bStopOutput) { diff --git a/src/kvirc/kernel/KviIrcContext.h b/src/kvirc/kernel/KviIrcContext.h index 8c6a0a903..bbf6efe6e 100644 --- a/src/kvirc/kernel/KviIrcContext.h +++ b/src/kvirc/kernel/KviIrcContext.h @@ -83,21 +83,21 @@ public: protected: KviConsoleWindow * m_pConsole; // shallow, never null - KviIrcConnection * m_pConnection; + KviIrcConnection * m_pConnection = nullptr; unsigned int m_uId; // this irc context id - State m_eState; // this context state + State m_eState = Idle; // this context state // permanent links and list window - KviExternalServerDataParser * m_pLinksWindow; - KviExternalServerDataParser * m_pListWindow; + KviExternalServerDataParser * m_pLinksWindow = nullptr; + KviExternalServerDataParser * m_pListWindow = nullptr; - KviAsynchronousConnectionData * m_pAsynchronousConnectionData; // owned, may be null - KviAsynchronousConnectionData * m_pSavedAsynchronousConnectionData; // owned, may be null, this is used to reconnect to the last server in this context + KviAsynchronousConnectionData * m_pAsynchronousConnectionData = nullptr; // owned, may be null + KviAsynchronousConnectionData * m_pSavedAsynchronousConnectionData = nullptr; // owned, may be null, this is used to reconnect to the last server in this context - unsigned int m_uConnectAttemptCount; - QTimer * m_pReconnectTimer; + unsigned int m_uConnectAttemptCount = 1; + QTimer * m_pReconnectTimer = nullptr; std::vector<KviIrcDataStreamMonitor *> m_pMonitorList; // owned, may be empty @@ -110,15 +110,15 @@ protected: int m_iHeartbeatTimerId; public: - inline unsigned int id() { return m_uId; }; + unsigned int id() const { return m_uId; } // never null and always the same! - inline KviConsoleWindow * console() { return m_pConsole; }; + KviConsoleWindow * console() const { return m_pConsole; } // may be null and may change! - inline KviIrcConnection * connection() { return m_pConnection; }; + KviIrcConnection * connection() const { return m_pConnection; } // state - inline State state() { return m_eState; }; - inline bool isConnected() { return m_eState == Connected; }; - inline bool isLoggingIn() { return m_eState == LoggingIn; }; + State state() const { return m_eState; } + bool isConnected() const { return m_eState == Connected; } + bool isLoggingIn() const { return m_eState == LoggingIn; } // dead channels and queries bool unregisterDeadChannel(KviChannelWindow * c); bool unregisterDeadQuery(KviQueryWindow * q); @@ -133,20 +133,20 @@ public: void registerContextWindow(KviWindow * pWnd); bool unregisterContextWindow(KviWindow * pWnd); - inline std::vector<KviIrcDataStreamMonitor *> & monitorList() { return m_pMonitorList; }; + std::vector<KviIrcDataStreamMonitor *> & monitorList() { return m_pMonitorList; } // links window void createLinksWindow(); - inline void setLinksWindowPointer(KviExternalServerDataParser * l) { m_pLinksWindow = l; }; - inline KviExternalServerDataParser * linksWindow() { return m_pLinksWindow; }; + void setLinksWindowPointer(KviExternalServerDataParser * l) { m_pLinksWindow = l; } + KviExternalServerDataParser * linksWindow() const { return m_pLinksWindow; } // list window void createListWindow(); - inline void setListWindowPointer(KviExternalServerDataParser * l) { m_pListWindow = l; }; - inline KviExternalServerDataParser * listWindow() { return m_pListWindow; }; + void setListWindowPointer(KviExternalServerDataParser * l) { m_pListWindow = l; } + KviExternalServerDataParser * listWindow() const { return m_pListWindow; } void setAsynchronousConnectionData(KviAsynchronousConnectionData * d); - inline KviAsynchronousConnectionData * asynchronousConnectionData() { return m_pAsynchronousConnectionData; }; + KviAsynchronousConnectionData * asynchronousConnectionData() const { return m_pAsynchronousConnectionData; } void destroyAsynchronousConnectionData(); // used by KviConsoleWindow (for now) and KviUserParser void connectToCurrentServer(); @@ -171,10 +171,10 @@ protected: // called by KviIrcConnection void loginComplete(); // our heartbeat timer event - virtual void timerEvent(QTimerEvent * e); + void timerEvent(QTimerEvent * e) override; public: - void connectOrDisconnect() { connectButtonClicked(); }; + void connectOrDisconnect() { connectButtonClicked(); } protected: // // KviIrcConnection interface diff --git a/src/kvirc/kernel/KviIrcDataStreamMonitor.cpp b/src/kvirc/kernel/KviIrcDataStreamMonitor.cpp index 688a639ef..67e99464c 100644 --- a/src/kvirc/kernel/KviIrcDataStreamMonitor.cpp +++ b/src/kvirc/kernel/KviIrcDataStreamMonitor.cpp @@ -26,9 +26,8 @@ #include "KviIrcContext.h" KviIrcDataStreamMonitor::KviIrcDataStreamMonitor(KviIrcContext * pContext) - : KviHeapObject() + : KviHeapObject(), m_pMyContext(pContext) { - m_pMyContext = pContext; m_pMyContext->registerDataStreamMonitor(this); } diff --git a/src/kvirc/kernel/KviIrcDataStreamMonitor.h b/src/kvirc/kernel/KviIrcDataStreamMonitor.h index fc8660632..bbf940bf9 100644 --- a/src/kvirc/kernel/KviIrcDataStreamMonitor.h +++ b/src/kvirc/kernel/KviIrcDataStreamMonitor.h @@ -42,9 +42,9 @@ public: virtual bool incomingMessage(const char *) = 0; // For proxy connections it might spit out binary data! virtual bool outgoingMessage(const char *) = 0; - virtual void connectionInitiated(){}; - virtual void connectionTerminated(){}; - virtual void die() { delete this; }; + virtual void connectionInitiated(){} + virtual void connectionTerminated(){} + virtual void die() { delete this; } }; #endif //!_KVI_IRCDATASTREAMMONITOR_H_ diff --git a/src/kvirc/kernel/KviIrcLink.cpp b/src/kvirc/kernel/KviIrcLink.cpp index 0ac7894e6..30b83b0e0 100644 --- a/src/kvirc/kernel/KviIrcLink.cpp +++ b/src/kvirc/kernel/KviIrcLink.cpp @@ -50,21 +50,10 @@ extern KVIRC_API KviIrcServerDataBase * g_pServerDataBase; extern KVIRC_API KviProxyDataBase * g_pProxyDataBase; KviIrcLink::KviIrcLink(KviIrcConnection * pConnection) - : QObject() + : QObject(), m_pConnection(pConnection) { - m_pConnection = pConnection; m_pTarget = pConnection->target(); m_pConsole = m_pConnection->console(); - - m_pSocket = nullptr; - m_pLinkFilter = nullptr; - m_pResolver = nullptr; - - m_pReadBuffer = nullptr; // incoming data buffer - m_uReadBufferLen = 0; // incoming data buffer length - m_uReadPackets = 0; // total packets read per session - - m_eState = Idle; } KviIrcLink::~KviIrcLink() @@ -262,7 +251,7 @@ void KviIrcLink::processData(char * buffer, int iLen) if(*cMessageBuffer != 0) m_pConnection->incomingMessage(cMessageBuffer); - if(m_pSocket->state() != KviIrcSocket::Connected) + if(!m_pSocket || (m_pSocket->state() != KviIrcSocket::Connected)) { // Disconnected in KviConsoleWindow::incomingMessage() call. // This may happen for several reasons (local event loop diff --git a/src/kvirc/kernel/KviIrcLink.h b/src/kvirc/kernel/KviIrcLink.h index 97d23eeef..635c9fdc4 100644 --- a/src/kvirc/kernel/KviIrcLink.h +++ b/src/kvirc/kernel/KviIrcLink.h @@ -92,16 +92,16 @@ private: KviIrcConnection * m_pConnection; // shallow, never null KviIrcConnectionTarget * m_pTarget; // shallow, never null KviConsoleWindow * m_pConsole; // shallow, never null - KviIrcSocket * m_pSocket; // owned, may be null! - KviMexLinkFilter * m_pLinkFilter; // owned, may be null! + KviIrcSocket * m_pSocket = nullptr; // owned, may be null! + KviMexLinkFilter * m_pLinkFilter = nullptr; // owned, may be null! - State m_eState; + State m_eState = Idle; - char * m_pReadBuffer; - unsigned int m_uReadBufferLen; - unsigned int m_uReadPackets; + char * m_pReadBuffer = nullptr; // incoming data buffer + unsigned int m_uReadBufferLen = 0; // incoming data buffer length + unsigned int m_uReadPackets = 0; // total packets read per session - KviIrcConnectionTargetResolver * m_pResolver; // owned + KviIrcConnectionTargetResolver * m_pResolver = nullptr; // owned public: /** * \brief Returns the socket @@ -109,7 +109,7 @@ public: * May be null! * \return KviIrcSocket * */ - KviIrcSocket * socket() { return m_pSocket; }; + KviIrcSocket * socket() const { return m_pSocket; } /** * \brief Returns the connection object @@ -117,7 +117,7 @@ public: * Never null * \return KviIrcConnection * */ - KviIrcConnection * connection() { return m_pConnection; }; + KviIrcConnection * connection() const { return m_pConnection; } /** * \brief Returns the console @@ -125,13 +125,13 @@ public: * Never null * \return KviConsoleWindow * */ - KviConsoleWindow * console() { return m_pConsole; }; + KviConsoleWindow * console() const { return m_pConsole; } /** * \brief Returns the state of the socket * \return State */ - State state() { return m_eState; }; + State state() const { return m_eState; } protected: /** * \brief Sends a data packet diff --git a/src/kvirc/kernel/KviIrcSocket.cpp b/src/kvirc/kernel/KviIrcSocket.cpp index 700898df7..00b317145 100644 --- a/src/kvirc/kernel/KviIrcSocket.cpp +++ b/src/kvirc/kernel/KviIrcSocket.cpp @@ -33,7 +33,6 @@ #include "kvi_debug.h" #include "KviCString.h" #include "KviOptions.h" -#include "kvi_socket.h" #include "KviConsoleWindow.h" #include "kvi_out.h" #include "KviIrcLink.h" @@ -46,6 +45,7 @@ #include <QTimer> #include <QSocketNotifier> +#include <memory> #if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW) #include <unistd.h> //for gettimeofday() @@ -58,47 +58,20 @@ unsigned int g_uNextIrcLinkId = 1; KviIrcSocket::KviIrcSocket(KviIrcLink * pLink) - : QObject() + : QObject(), m_pLink(pLink) { m_uId = g_uNextIrcLinkId; g_uNextIrcLinkId++; - m_pLink = pLink; m_pConsole = m_pLink->console(); - m_state = Idle; // current socket state - - m_pRsn = nullptr; // read socket notifier - m_pWsn = nullptr; // write socket notifier - m_sock = KVI_INVALID_SOCKET; // socket - - m_pIrcServer = nullptr; // current server data - m_pProxy = nullptr; // current proxy data - - m_pTimeoutTimer = nullptr; // timeout for connect() - - m_uReadBytes = 0; // total read bytes per session - m_uSentBytes = 0; // total sent bytes per session - m_uSentPackets = 0; // total packets sent per session - - m_pSendQueueHead = nullptr; // data queue - m_pSendQueueTail = nullptr; // - - m_eLastError = KviError::Success; - -#ifdef COMPILE_SSL_SUPPORT - m_pSSL = nullptr; -#endif - m_tAntiFloodLastMessageTime.tv_sec = 0; m_tAntiFloodLastMessageTime.tv_usec = 0; if(KVI_OPTION_UINT(KviOption_uintSocketQueueFlushTimeout) < 100) KVI_OPTION_UINT(KviOption_uintSocketQueueFlushTimeout) = 100; // this is our minimum, we don't want to lag the app - m_bInProcessData = false; - - m_pFlushTimer.reset(new QTimer()); // queue flush timer + m_pFlushTimer = std::make_unique<QTimer>(); // queue flush timer connect(m_pFlushTimer.get(), SIGNAL(timeout()), this, SLOT(flushSendQueue())); } @@ -208,9 +181,7 @@ void KviIrcSocket::outputSSLError(const QString & szMsg) void KviIrcSocket::outputProxyMessage(const QString & szMsg) { - QStringList list = szMsg.isEmpty() ? QStringList() : szMsg.split("\n", QString::SkipEmptyParts); - - for(const auto & it : list) + for(const auto & it : szMsg.split('\n', QString::SkipEmptyParts)) { QString szTemporary = it.trimmed(); m_pConsole->output(KVI_OUT_SOCKETMESSAGE, __tr2qs("[PROXY]: %Q"), &szTemporary); @@ -219,9 +190,7 @@ void KviIrcSocket::outputProxyMessage(const QString & szMsg) void KviIrcSocket::outputProxyError(const QString & szMsg) { - QStringList list = szMsg.isEmpty() ? QStringList() : szMsg.split("\n", QString::SkipEmptyParts); - - for(const auto & it : list) + for(const auto & it : szMsg.split('\n', QString::SkipEmptyParts)) { QString szTemporary = it.trimmed(); m_pConsole->output(KVI_OUT_SOCKETERROR, __tr2qs("[PROXY ERROR]: %Q"), &szTemporary); @@ -273,12 +242,12 @@ KviError::Code KviIrcSocket::startConnection(KviIrcServer * pServer, KviProxy * // Coherent state, thnx. reset(); +#ifndef COMPILE_SSL_SUPPORT if(pServer->useSSL()) { -#ifndef COMPILE_SSL_SUPPORT return KviError::NoSSLSupport; -#endif //COMPILE_SSL_SUPPORT } +#endif //COMPILE_SSL_SUPPORT // Copy the server m_pIrcServer = new KviIrcServer(*pServer); @@ -777,7 +746,7 @@ void KviIrcSocket::proxyLoginV4() KviMemory::move((void *)(pcBufToSend + 4), (void *)&host, 4); KviMemory::move((void *)(pcBufToSend + 8), (void *)(szUserAndPass.ptr()), szUserAndPass.len()); - pcBufToSend[iLen - 1] = 0; //NULL + pcBufToSend[iLen - 1] = '\0'; // send it into hyperspace... setState(ProxyFinalV4); @@ -1714,7 +1683,7 @@ void KviIrcSocket::flushSendQueue() { if(KVI_OPTION_BOOL(KviOption_boolLimitOutgoingTraffic)) { - kvi_gettimeofday(&curTime, nullptr); + kvi_gettimeofday(&curTime); int iTimeDiff = curTime.tv_usec - m_tAntiFloodLastMessageTime.tv_usec; iTimeDiff += (curTime.tv_sec - m_tAntiFloodLastMessageTime.tv_sec) * 1000000; diff --git a/src/kvirc/kernel/KviIrcSocket.h b/src/kvirc/kernel/KviIrcSocket.h index caa47345f..27947b924 100644 --- a/src/kvirc/kernel/KviIrcSocket.h +++ b/src/kvirc/kernel/KviIrcSocket.h @@ -31,36 +31,38 @@ */ #include "kvi_settings.h" -#include "KviCString.h" +#include "kvi_socket.h" #include "kvi_sockettype.h" -#include "KviTimeUtils.h" -#include "KviPointerList.h" +#include "KviCString.h" #include "KviError.h" +#include "KviPointerList.h" +#include "KviTimeUtils.h" -#include <memory> #include <QObject> -class QTimer; -class QSocketNotifier; -class KviIrcServer; -class KviProxy; +#include <memory> + +class KviConsoleWindow; +class KviDataBuffer; class KviIrcConnection; class KviIrcConnectionTarget; class KviIrcLink; +class KviIrcServer; +class KviProxy; class KviSSL; -class KviConsoleWindow; -class KviDataBuffer; +class QSocketNotifier; +class QTimer; /** * \typedef KviIrcSocketMsgEntry * \struct _KviIrcSocketMsgEntry * \brief Holds the messages entries */ -typedef struct _KviIrcSocketMsgEntry +struct KviIrcSocketMsgEntry { KviDataBuffer * pData; - struct _KviIrcSocketMsgEntry * next_ptr; -} KviIrcSocketMsgEntry; + KviIrcSocketMsgEntry * next_ptr; +}; /** * \class KviIrcSocket @@ -108,103 +110,100 @@ protected: unsigned int m_uId; KviIrcLink * m_pLink; KviConsoleWindow * m_pConsole; - kvi_socket_t m_sock; - SocketState m_state; - QSocketNotifier * m_pWsn; - QSocketNotifier * m_pRsn; - KviIrcServer * m_pIrcServer; - KviProxy * m_pProxy; - QTimer * m_pTimeoutTimer; - unsigned int m_uReadBytes; - unsigned int m_uSentBytes; - KviError::Code m_eLastError; - unsigned int m_uSentPackets; - KviIrcSocketMsgEntry * m_pSendQueueHead; - KviIrcSocketMsgEntry * m_pSendQueueTail; + kvi_socket_t m_sock = KVI_INVALID_SOCKET; // socket + SocketState m_state = Idle; // current socket state + QSocketNotifier * m_pWsn = nullptr; // read socket notifier + QSocketNotifier * m_pRsn = nullptr; // write socket notifier + KviIrcServer * m_pIrcServer = nullptr; // current server data + KviProxy * m_pProxy = nullptr; // current proxy data + QTimer * m_pTimeoutTimer = nullptr; // timeout for connect() + unsigned int m_uReadBytes = 0; // total read bytes per session + unsigned int m_uSentBytes = 0; // total sent bytes per session + unsigned int m_uSentPackets = 0; // total packets sent per session + KviError::Code m_eLastError = KviError::Success; + KviIrcSocketMsgEntry * m_pSendQueueHead = nullptr; // data queue + KviIrcSocketMsgEntry * m_pSendQueueTail = nullptr; std::unique_ptr<QTimer> m_pFlushTimer; struct timeval m_tAntiFloodLastMessageTime; - bool m_bInProcessData; + bool m_bInProcessData = false; #ifdef COMPILE_SSL_SUPPORT - KviSSL * m_pSSL; + KviSSL * m_pSSL = nullptr; #endif public: /** * \brief Returns the console * \return KviConsoleWindow * */ - KviConsoleWindow * console() { return m_pConsole; }; + KviConsoleWindow * console() const { return m_pConsole; } /** * \brief Returns the link * \return KviIrcLink * */ - KviIrcLink * link() { return m_pLink; }; + KviIrcLink * link() const { return m_pLink; } /** * \brief Returns the state of the socket * \return SocketState */ - SocketState state() { return m_state; }; + SocketState state() const { return m_state; } /** * \brief Returns the last error * \return int */ - int lastError() { return m_eLastError; }; + int lastError() const { return m_eLastError; } /** * \brief Returns the id of the socket * \return unsigned int */ - unsigned int id() { return m_uId; }; + unsigned int id() const { return m_uId; } /** * \brief Returns true if the socket is a Secure Socket Layer (SSL) * \return bool */ -#ifdef COMPILE_SSL_SUPPORT - bool usingSSL() + bool usingSSL() const { +#ifdef COMPILE_SSL_SUPPORT return m_pSSL; - }; #else - bool usingSSL() - { return false; - }; #endif + } #ifdef COMPILE_SSL_SUPPORT /** * \brief Returns the current SSL object for this socket * \return bool */ - KviSSL * getSSL() { return m_pSSL; }; + KviSSL * getSSL() const { return m_pSSL; } #endif /** * \brief Returns the number of bytes read * \return unsigned int */ - unsigned int readBytes() { return m_uReadBytes; }; + unsigned int readBytes() const { return m_uReadBytes; } /** * \brief Returns the number of bytes sent * \return unsigned int */ - unsigned int sentBytes() { return m_uSentBytes; }; + unsigned int sentBytes() const { return m_uSentBytes; } /** * \brief Returns the number of packets sent * \return unsigned int */ - unsigned int sentPackets() { return m_uSentPackets; }; - //unsigned int readPackets(){ return m_uReadPackets; }; + unsigned int sentPackets() const { return m_uSentPackets; } + //unsigned int readPackets() const { return m_uReadPackets; } /** * \brief Returns true if the socket is connected * \return bool */ - bool isConnected() { return m_state == Connected; }; + bool isConnected() const { return m_state == Connected; } /** * \brief Starts the connection @@ -213,7 +212,7 @@ public: * \param pcBindAddress The address to bind the connection to * \return int */ - KviError::Code startConnection(KviIrcServer * pServer, KviProxy * pProxy = 0, const char * pcBindAddress = 0); + KviError::Code startConnection(KviIrcServer * pServer, KviProxy * pProxy = nullptr, const char * pcBindAddress = nullptr); #ifdef COMPILE_SSL_SUPPORT /** diff --git a/src/kvirc/kernel/KviIrcUrl.cpp b/src/kvirc/kernel/KviIrcUrl.cpp index a33ad9d8e..33614192a 100644 --- a/src/kvirc/kernel/KviIrcUrl.cpp +++ b/src/kvirc/kernel/KviIrcUrl.cpp @@ -71,23 +71,22 @@ bool KviIrcUrl::parse(const char * url, KviCString & cmdBuffer, int contextSpec) cmdBuffer.append(" -s "); QString channels, passwords; - QStringList splitted; if(urlParts.chanList.size()) { for(int i = 0; i < urlParts.chanList.size(); ++i) { - splitted = urlParts.chanList[i].split("?"); + QStringList splitted = urlParts.chanList[i].split("?"); if(i) - channels.append(","); - if(!(splitted[0].startsWith("#") || splitted[0].startsWith("!") || splitted[0].startsWith("&"))) - channels.append("#"); + channels.append(','); + if(!(splitted[0].startsWith('#') || splitted[0].startsWith('!') || splitted[0].startsWith('&'))) + channels.append('#'); channels.append(splitted[0]); if(splitted.size() > 1) { if(i) - passwords.append(","); + passwords.append(','); passwords.append(splitted[1]); } } @@ -103,7 +102,7 @@ bool KviIrcUrl::parse(const char * url, KviCString & cmdBuffer, int contextSpec) return true; } -void KviIrcUrl::split(QString url, KviIrcUrlParts & result) +void KviIrcUrl::split(const QString & url, KviIrcUrlParts & result) { // irc[s][6]://<server>[:<port>][/<channel>[?<pass>]][[,<channel>[?<pass>]] @@ -113,7 +112,7 @@ void KviIrcUrl::split(QString url, KviIrcUrlParts & result) result.iPort = 6667; result.iError = 0; - QRegExp rx("^(irc(s)?(6)?://)?\\[?([\\w\\d\\.-]*|[\\d:a-f]*)\\]?(:(\\d*))?(/(.*))?$"); + QRegExp rx(R"(^(irc(s)?(6)?://)?\[?([\w\d\.-]*|[\d:a-f]*)\]?(:(\d*))?(/(.*))?$)"); if(rx.indexIn(url) < 0) { @@ -153,26 +152,26 @@ void KviIrcUrl::join(QString & uri, KviIrcServer * server) uri = "irc"; if(server->useSSL()) - uri.append("s"); + uri.append('s'); if(server->isIPv6()) - uri.append("6"); + uri.append('6'); uri.append("://"); if(server->isIPv6() && server->hostName().contains(':')) - uri.append("["); + uri.append('['); uri.append(server->hostName()); if(server->isIPv6() && server->hostName().contains(':')) - uri.append("]"); + uri.append(']'); if(server->port() != 6667) uri.append(QString(":%1").arg(server->port())); - uri.append("/"); + uri.append('/'); } } void KviIrcUrl::makeJoinCmd(const QStringList & chans, QString & szJoinCommand) { QString szChannels, szProtectedChannels, szPasswords, szCurPass, szCurChan; - if(chans.count() != 0) + if(!chans.isEmpty()) { for(const auto & chan : chans) @@ -182,7 +181,7 @@ void KviIrcUrl::makeJoinCmd(const QStringList & chans, QString & szJoinCommand) if(szCurPass.isEmpty()) { if(!szChannels.isEmpty()) - szChannels.append(","); + szChannels.append(','); szCurChan = chan.section('?', 0, 0); if(!(szCurChan[0] == '#' || szCurChan[0] == '&' || szCurChan[0] == '!')) szCurChan.prepend('#'); @@ -191,7 +190,7 @@ void KviIrcUrl::makeJoinCmd(const QStringList & chans, QString & szJoinCommand) else { if(!szProtectedChannels.isEmpty()) - szProtectedChannels.append(","); + szProtectedChannels.append(','); szCurChan = chan.section('?', 0, 0); if(!(szCurChan[0] == '#' || szCurChan[0] == '&' || szCurChan[0] == '!')) szCurChan.prepend('#'); diff --git a/src/kvirc/kernel/KviIrcUrl.h b/src/kvirc/kernel/KviIrcUrl.h index 5becaa3a3..ebefd74aa 100644 --- a/src/kvirc/kernel/KviIrcUrl.h +++ b/src/kvirc/kernel/KviIrcUrl.h @@ -40,7 +40,7 @@ class KviConsoleWindow; // Create /server <server> commands (this irc context) #define KVI_IRCURL_CONTEXT_THIS 2 -typedef struct _KviIrcUrlParts +struct KviIrcUrlParts { QString szHost; kvi_u32_t iPort; @@ -48,7 +48,7 @@ typedef struct _KviIrcUrlParts bool bSsl; QStringList chanList; int iError; -} KviIrcUrlParts; +}; namespace KviIrcUrl { @@ -74,9 +74,9 @@ namespace KviIrcUrl extern KVIRC_API bool parse(const char * url, KviCString & cmdBuffer, int contextSpec = KVI_IRCURL_CONTEXT_FIRSTFREE); - extern KVIRC_API int run(const QString & url, int contextSpec = FirstFreeContext, KviConsoleWindow * pConsole = 0); + extern KVIRC_API int run(const QString & url, int contextSpec = FirstFreeContext, KviConsoleWindow * pConsole = nullptr); - extern KVIRC_API void split(QString url, KviIrcUrlParts & parts); + extern KVIRC_API void split(const QString & url, KviIrcUrlParts & parts); extern KVIRC_API void join(QString & url, KviIrcServer * server); extern KVIRC_API void makeJoinCmd(const QStringList & chans, QString & szJoinCommand); } diff --git a/src/kvirc/kernel/KviLagMeter.cpp b/src/kvirc/kernel/KviLagMeter.cpp index 40f426458..a114b99aa 100644 --- a/src/kvirc/kernel/KviLagMeter.cpp +++ b/src/kvirc/kernel/KviLagMeter.cpp @@ -1,10 +1,10 @@ //============================================================================= // // File : KviLagMeter.cpp -// Creation date : Fri Oct 18 13:31:36 CEST 1999 by Juanjo lvarez +// Creation date : Fri Oct 18 13:31:36 CEST 1999 by Juanjo Álvarez // // This file is part of the KVIrc IRC client distribution -// Copyright (C) 1999 Juanjo lvarez +// Copyright (C) 1999 Juanjo Álvarez // Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net) // // This program is FREE software. You can redistribute it and/or @@ -39,18 +39,8 @@ #include <algorithm> KviLagMeter::KviLagMeter(KviIrcConnection * c) - : QObject() + : QObject(), m_pConnection(c) { - m_pConnection = c; - m_uLag = 0; - m_uLastEmittedLag = 0; - m_uLastReliability = 0; - m_tLastCompleted = 0; - m_tLastOwnCheck = 0; - m_tFirstOwnCheck = 0; - m_bOnAlarm = false; - m_pDeletionSignal = nullptr; - // FIXME: We could use the KviIrcConnection::heartbeat() here! if(KVI_OPTION_UINT(KviOption_uintLagMeterHeartbeat) < 2000) KVI_OPTION_UINT(KviOption_uintLagMeterHeartbeat) = 2000; // kinda absurd @@ -65,12 +55,14 @@ KviLagMeter::~KviLagMeter() { if(m_pDeletionSignal) *m_pDeletionSignal = true; + + qDeleteAll(m_lCheckList); } unsigned int KviLagMeter::secondsSinceLastCompleted() { struct timeval tv; - kvi_gettimeofday(&tv, nullptr); + kvi_gettimeofday(&tv); return tv.tv_sec - m_tLastCompleted; } @@ -117,7 +109,7 @@ void KviLagMeter::timerEvent(QTimerEvent *) // get current time struct timeval tv; - kvi_gettimeofday(&tv, nullptr); + kvi_gettimeofday(&tv); unsigned int uDiff = tv.tv_sec - m_tLastCompleted; unsigned int uHeartbeat = KVI_OPTION_UINT(KviOption_uintLagMeterHeartbeat) / 1000; if(uHeartbeat < 2) @@ -131,11 +123,11 @@ void KviLagMeter::timerEvent(QTimerEvent *) // the last completed check has been completed a lot of time ago // do we have some checks on the queue ? - if(m_CheckList.size() > 0) + if(m_lCheckList.count() > 0) { // if the first registered check is not too outdated // we wait a little more for it to return - KviLagCheck * c = m_CheckList.front(); + KviLagCheck * c = m_lCheckList.first(); if(c) { if((tv.tv_sec - c->lSecs) <= 10) @@ -195,20 +187,20 @@ void KviLagMeter::lagCheckRegister(const char * key, unsigned int uReliability) if(_OUTPUT_PARANOIC) m_pConnection->console()->output(KVI_OUT_VERBOSE, __tr2qs("Registered lag check with reliability %u (%s)"), uReliability, key); - KviLagCheck * c = new KviLagCheck; + KviLagCheck * c = new KviLagCheck(); c->szKey = key; struct timeval tv; - kvi_gettimeofday(&tv, nullptr); + kvi_gettimeofday(&tv); c->lSecs = tv.tv_sec; c->lUSecs = tv.tv_usec; c->uReliability = uReliability <= 100 ? uReliability : 100; - m_CheckList.push_back(c); - while(m_CheckList.size() > 30) + m_lCheckList.append(c); + while(m_lCheckList.size() > 30) { // we're fried :/ // either our ping mechanism is not working // or the server is stoned... - m_CheckList.erase(m_CheckList.begin()); + delete m_lCheckList.takeFirst(); } } @@ -216,7 +208,7 @@ bool KviLagMeter::lagCheckComplete(const char * key) { // find this lag check KviLagCheck * c = nullptr; - for(auto cc : m_CheckList) + for(auto cc : m_lCheckList) { if(kvi_strEqualCS(cc->szKey.ptr(), key)) { @@ -226,15 +218,16 @@ bool KviLagMeter::lagCheckComplete(const char * key) } if(!c) return false; // not found + // kill any earlier lag checks (IRC is a sequential proto) - while(m_CheckList.front() != c) - m_CheckList.erase(m_CheckList.begin()); + while(m_lCheckList.first() != c) + delete m_lCheckList.takeFirst(); if(_OUTPUT_PARANOIC) m_pConnection->console()->output(KVI_OUT_VERBOSE, __tr2qs("Lag check completed (%s)"), key); struct timeval tv; - kvi_gettimeofday(&tv, nullptr); + kvi_gettimeofday(&tv); unsigned int uLag = ((tv.tv_sec - c->lSecs) * 1000); if(tv.tv_usec < c->lUSecs) @@ -262,7 +255,7 @@ bool KviLagMeter::lagCheckComplete(const char * key) m_tFirstOwnCheck = 0; m_uLastReliability = c->uReliability; - m_CheckList.erase(m_CheckList.begin()); + delete m_lCheckList.takeFirst(); return true; } @@ -272,7 +265,13 @@ void KviLagMeter::lagCheckAbort(const char * key) if(_OUTPUT_PARANOIC) m_pConnection->console()->output(KVI_OUT_VERBOSE, __tr2qs("Lag check aborted (%s)"), key); - for(auto c : m_CheckList) + QList<KviLagCheck *> lAborted; + + for(auto c : m_lCheckList) + { if(kvi_strEqualCS(c->szKey.ptr(), key)) - m_CheckList.erase(std::remove(m_CheckList.begin(), m_CheckList.end(), c), m_CheckList.end()); + lAborted.append(c); + } + + qDeleteAll(lAborted); } diff --git a/src/kvirc/kernel/KviLagMeter.h b/src/kvirc/kernel/KviLagMeter.h index 751a4f48b..03dfbc6ec 100644 --- a/src/kvirc/kernel/KviLagMeter.h +++ b/src/kvirc/kernel/KviLagMeter.h @@ -3,10 +3,10 @@ //============================================================================= // // File : KviLagMeter.h -// Creation date : Fri Oct 18 13:30:26 CEST 1999 by Juanjo lvarez +// Creation date : Fri Oct 18 13:30:26 CEST 1999 by Juanjo Álvarez // // This file is part of the KVIrc IRC client distribution -// Copyright (C) 1999 Juanjo lvarez +// Copyright (C) 1999 Juanjo Álvarez // Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net) // // This program is FREE software. You can redistribute it and/or @@ -29,14 +29,12 @@ #include "KviCString.h" #include <QObject> - -#include <vector> +#include <QList> class KviIrcConnection; -class KviLagCheck +struct KviLagCheck { -public: KviCString szKey; long lSecs; // since epoch long lUSecs; @@ -45,35 +43,35 @@ public: class KVIRC_API KviLagMeter : public QObject { - Q_OBJECT friend class KviIrcConnection; + Q_OBJECT protected: KviLagMeter(KviIrcConnection * c); ~KviLagMeter(); protected: - KviIrcConnection * m_pConnection; - unsigned int m_uLag; // last computed lag - unsigned int m_uLastEmittedLag; // last emitted lag - long m_tLastCompleted; // time when the last lag was completed (gettimeofday!) - unsigned int m_uLastReliability; // how much reliable was the last completed check ? - std::vector<KviLagCheck *> m_CheckList; - long m_tFirstOwnCheck; // time when the first ping after a completed check was sent - long m_tLastOwnCheck; // time when the last ping was sent - bool m_bOnAlarm; - bool * m_pDeletionSignal; // we use this to signal our own delete + KviIrcConnection * m_pConnection = nullptr; + unsigned int m_uLag = 0; // last computed lag + unsigned int m_uLastEmittedLag = 0; // last emitted lag + long m_tLastCompleted = 0; // time when the last lag was completed (gettimeofday!) + unsigned int m_uLastReliability = 0; // how much reliable was the last completed check ? + QList<KviLagCheck *> m_lCheckList; + long m_tFirstOwnCheck = 0; // time when the first ping after a completed check was sent + long m_tLastOwnCheck = 0; // time when the last ping was sent + bool m_bOnAlarm = false; + bool * m_pDeletionSignal = nullptr; // we use this to signal our own delete public: // lag checks should be done only against the user's server // please make SURE that the key is unique! void lagCheckRegister(const char * key, unsigned int uReliability = 50); bool lagCheckComplete(const char * key); void lagCheckAbort(const char * key); - unsigned int lag() { return m_uLag; }; + unsigned int lag() const { return m_uLag; } unsigned int secondsSinceLastCompleted(); protected: - virtual void timerEvent(QTimerEvent * e); + void timerEvent(QTimerEvent * e) override; }; #endif // _KVI_LAGMETER_H_ diff --git a/src/kvirc/kernel/KviMain.cpp b/src/kvirc/kernel/KviMain.cpp index 0434b68e6..1a67bacf0 100644 --- a/src/kvirc/kernel/KviMain.cpp +++ b/src/kvirc/kernel/KviMain.cpp @@ -55,7 +55,7 @@ extern bool kvi_sendIpcMessage(const char * message); // KviIpcSentinel.cpp #define KVI_ARGS_RETCODE_ERROR 1 #define KVI_ARGS_RETCODE_STOP 2 -typedef struct _ParseArgs +struct ParseArgs { int argc; char ** argv; @@ -66,7 +66,7 @@ typedef struct _ParseArgs bool bExecuteCommandAndClose; QString szExecCommand; QString szExecRemoteCommand; -} ParseArgs; +}; int parseArgs(ParseArgs * a) { diff --git a/src/kvirc/kernel/KviNotifyList.cpp b/src/kvirc/kernel/KviNotifyList.cpp index 266e6f413..a6a65bb9a 100644 --- a/src/kvirc/kernel/KviNotifyList.cpp +++ b/src/kvirc/kernel/KviNotifyList.cpp @@ -43,10 +43,11 @@ #include "KviKvsEventTriggers.h" #include "KviIrcMessage.h" -#include <QStringList> #include <QByteArray> +#include <QStringList> #include <algorithm> +#include <memory> #include <set> #include <vector> @@ -118,7 +119,7 @@ // Basic NotifyListManager: this does completely nothing KviNotifyListManager::KviNotifyListManager(KviIrcConnection * pConnection) - : QObject(nullptr) + : QObject() { setObjectName("notify_list_manager"); m_pConnection = pConnection; @@ -174,17 +175,14 @@ void KviNotifyListManager::notifyOnLine(const QString & szNick, const QString & while(KviRegisteredUser * pUser = it.current()) { QString szProp = pUser->getProperty("notify"); - if(!szProp.isEmpty()) + if(!szProp.isEmpty() && szProp.split(',', QString::SkipEmptyParts).contains(szNick)) { - if(szProp.split(",", QString::SkipEmptyParts).indexOf(szNick) != -1) - { - QString szComment = pUser->getProperty("comment"); - if(!szComment.isEmpty()) - szMsg = QString("%1 (%2), Group \"%3\" is on IRC as (%4)").arg(pUser->name(), szComment, pUser->group(), szWho); - else - szMsg = QString("%1, Group \"%2\" is on IRC as (%3)").arg(pUser->name(), pUser->group(), szWho); - break; - } + QString szComment = pUser->getProperty("comment"); + if(!szComment.isEmpty()) + szMsg = QString("%1 (%2), Group \"%3\" is on IRC as (%4)").arg(pUser->name(), szComment, pUser->group(), szWho); + else + szMsg = QString("%1, Group \"%2\" is on IRC as (%3)").arg(pUser->name(), pUser->group(), szWho); + break; } ++it; } @@ -196,9 +194,9 @@ void KviNotifyListManager::notifyOnLine(const QString & szNick, const QString & if((!szReason.isEmpty()) && (_OUTPUT_VERBOSE)) { - szMsg += "("; + szMsg += '('; szMsg += szReason; - szMsg += ")"; + szMsg += ')'; } pOut->outputNoFmt(KVI_OUT_NOTIFYONLINE, szMsg); @@ -238,17 +236,14 @@ void KviNotifyListManager::notifyOffLine(const QString & szNick, const QString & while(KviRegisteredUser * pUser = it.current()) { QString szProp = pUser->getProperty("notify"); - if(!szProp.isEmpty()) + if(!szProp.isEmpty() && szProp.split(',', QString::SkipEmptyParts).contains(szNick)) { - if(szProp.split(",", QString::SkipEmptyParts).indexOf(szNick) != -1) - { - QString szComment = pUser->getProperty("comment"); - if(!szComment.isEmpty()) - szMsg = QString("%1 (%2), Group \"%3\" has left IRC as (%4)").arg(pUser->name(), szComment, pUser->group(), szWho); - else - szMsg = QString("%1, Group \"%2\" has left IRC as (%3)").arg(pUser->name(), pUser->group(), szWho); - break; - } + QString szComment = pUser->getProperty("comment"); + if(!szComment.isEmpty()) + szMsg = QString("%1 (%2), Group \"%3\" has left IRC as (%4)").arg(pUser->name(), szComment, pUser->group(), szWho); + else + szMsg = QString("%1, Group \"%2\" has left IRC as (%3)").arg(pUser->name(), pUser->group(), szWho); + break; } ++it; } @@ -258,9 +253,9 @@ void KviNotifyListManager::notifyOffLine(const QString & szNick, const QString & if((!szReason.isEmpty()) && (_OUTPUT_VERBOSE)) { - szMsg += "("; + szMsg += '('; szMsg += szReason; - szMsg += ")"; + szMsg += ')'; } pOut->outputNoFmt(KVI_OUT_NOTIFYOFFLINE, szMsg); @@ -328,8 +323,6 @@ KviIsOnNotifyListManager::KviIsOnNotifyListManager(KviIrcConnection * pConnectio connect(&m_pDelayedNotifyTimer, SIGNAL(timeout()), this, SLOT(newNotifySession())); connect(&m_pDelayedIsOnTimer, SIGNAL(timeout()), this, SLOT(newIsOnSession())); connect(&m_pDelayedUserhostTimer, SIGNAL(timeout()), this, SLOT(newUserhostSession())); - - m_bRunning = false; } KviIsOnNotifyListManager::~KviIsOnNotifyListManager() @@ -370,22 +363,8 @@ void KviIsOnNotifyListManager::buildRegUserDict() QString notify; if(u->getProperty("notify", notify)) { - notify = notify.trimmed(); - while(!notify.isEmpty()) - { - int idx = notify.indexOf(' '); - if(idx > 0) - { - QString single = notify.left(idx); - m_pRegUserDict.emplace(single, u->name()); - notify.remove(0, idx + 1); - } - else - { - m_pRegUserDict.emplace(notify, u->name()); - notify = ""; - } - } + for(const auto & single : notify.trimmed().split(' ', QString::SkipEmptyParts)) + m_pRegUserDict.emplace(single, u->name()); } ++it; } @@ -837,7 +816,7 @@ bool KviIsOnNotifyListManager::handleUserhost(KviIrcMessage * msg) { if(KviQString::equalCI(s, szNick)) { - tmplist.emplace(i, std::unique_ptr<KviIrcMask>(new KviIrcMask(szNick, szUser, szHost))); + tmplist.emplace(i, std::make_unique<KviIrcMask>(szNick, szUser, szHost)); bGotIt = true; break; } @@ -1128,7 +1107,7 @@ void KviWatchNotifyListManager::start() for(auto & it : m_pRegUserDict) { const QString & nk = it.first; - if(nk.indexOf('*') == -1) + if(!nk.contains('*')) { if((watchStr.length() + nk.length() + 2) > 501) { @@ -1239,11 +1218,11 @@ bool KviWatchNotifyListManager::handleWatchReply(KviIrcMessage * msg) { // 600: RPL_LOGON // :prefix 600 <target> <nick> <user> <host> <logintime> :logged online - // 601: RPL_LOGON + // 601: RPL_LOGOFF // :prefix 601 <target> <nick> <user> <host> <logintime> :logged offline - // 604: PRL_NOWON + // 604: RPL_NOWON // :prefix 604 <target> <nick> <user> <host> <logintime> :is online - // 605: PRL_NOWOFF + // 605: RPL_NOWOFF // :prefix 605 <target> <nick> <user> <host> 0 :is offline // FIXME: #warning "Use the logintime in some way ?" diff --git a/src/kvirc/kernel/KviNotifyList.h b/src/kvirc/kernel/KviNotifyList.h index c451f6e38..c379e45c5 100644 --- a/src/kvirc/kernel/KviNotifyList.h +++ b/src/kvirc/kernel/KviNotifyList.h @@ -35,9 +35,9 @@ #include <vector> class KviConsoleWindow; -class KviIrcMessage; -class KviIrcMask; class KviIrcConnection; +class KviIrcMask; +class KviIrcMessage; class KVIRC_API KviNotifyListManager : public QObject { @@ -64,7 +64,7 @@ protected: void notifyOffLine(const QString & nick, const QString & user = QString(), const QString & host = QString(), const QString & szReason = QString()); public: - KviConsoleWindow * console() { return m_pConsole; }; + KviConsoleWindow * console() const { return m_pConsole; } }; class KVIRC_API KviIsOnNotifyListManager : public KviNotifyListManager @@ -79,24 +79,24 @@ protected: private: std::map<QString, QString> m_pRegUserDict; // dict notifystring->reguser name - std::vector<QString> m_NotifyList; // list of notifystring (total) - std::vector<QString> m_IsOnList; // list of notifystring (one session) - QString m_szIsOnString; // m_pIsOnList in form of a string + std::vector<QString> m_NotifyList; // list of notifystring (total) + std::vector<QString> m_IsOnList; // list of notifystring (one session) + QString m_szIsOnString; // m_pIsOnList in form of a string std::vector<QString> m_OnlineList; std::vector<QString> m_UserhostList; QString m_szUserhostString; - bool m_bExpectingIsOn; - bool m_bExpectingUserhost; QTimer m_pDelayedIsOnTimer; QTimer m_pDelayedNotifyTimer; QTimer m_pDelayedUserhostTimer; - bool m_bRunning; + bool m_bExpectingIsOn; + bool m_bExpectingUserhost; + bool m_bRunning = false; protected: - virtual void start(); - virtual void stop(); - virtual bool handleUserhost(KviIrcMessage * msg); - virtual bool handleIsOn(KviIrcMessage * msg); + void start() override; + void stop() override; + bool handleUserhost(KviIrcMessage * msg) override; + bool handleIsOn(KviIrcMessage * msg) override; private: void delayedNotifySession(); @@ -133,12 +133,12 @@ protected: int m_iRestartTimer; protected: - virtual void start(); - virtual void stop(); - virtual bool handleIsOn(KviIrcMessage * msg); + void start() override; + void stop() override; + bool handleIsOn(KviIrcMessage * msg) override; protected: - virtual void timerEvent(QTimerEvent * e); + void timerEvent(QTimerEvent * e) override; private: void buildNickList(); @@ -158,9 +158,9 @@ protected: std::map<QString, QString> m_pRegUserDict; // dict notifystring->reguser name protected: void buildRegUserDict(); - virtual void start(); - virtual void stop(); - virtual bool handleWatchReply(KviIrcMessage * msg); + void start() override; + void stop() override; + bool handleWatchReply(KviIrcMessage * msg) override; bool doMatchUser(KviIrcMessage * msg, const QString & notifyString, const KviIrcMask & mask); }; diff --git a/src/kvirc/kernel/KviOptions.cpp b/src/kvirc/kernel/KviOptions.cpp index 31df83585..f7e531dd1 100644 --- a/src/kvirc/kernel/KviOptions.cpp +++ b/src/kvirc/kernel/KviOptions.cpp @@ -26,24 +26,24 @@ #define _KVI_OPTIONS_CPP_ #include "KviOptions.h" +#include "kvi_confignames.h" #include "kvi_defaults.h" -#include "KviConfigurationFile.h" +#include "kvi_out.h" +#include "kvi_settings.h" #include "KviApplication.h" -#include "KviIconManager.h" +#include "KviConfigurationFile.h" #include "KviControlCodes.h" +#include "KviFileUtils.h" +#include "KviIconManager.h" +#include "KviInternalCommand.h" #include "KviLocale.h" -#include "kvi_confignames.h" -#include "KviWindow.h" -#include "kvi_out.h" -#include "KviStringConversion.h" -#include "kvi_settings.h" #include "KviMainWindow.h" -#include "KviInternalCommand.h" +#include "KviStringConversion.h" #include "KviTheme.h" -#include "KviFileUtils.h" +#include "KviWindow.h" -#include <QMessageBox> #include <QDir> +#include <QMessageBox> #include <QStringList> // KviApplication.cpp @@ -90,7 +90,7 @@ KviBoolOption g_boolOptionsTable[KVI_NUM_BOOL_OPTIONS] = { BOOL_OPTION("IgnoreCtcpFinger", true, KviOption_sectFlagCtcp), BOOL_OPTION("IgnoreCtcpSource", false, KviOption_sectFlagCtcp), BOOL_OPTION("IgnoreCtcpTime", false, KviOption_sectFlagCtcp), - BOOL_OPTION("RequestMissingAvatars", true, KviOption_sectFlagAvatar), + BOOL_OPTION("RequestMissingAvatars", false, KviOption_sectFlagAvatar), BOOL_OPTION("ShowCompactModeChanges", true, KviOption_sectFlagConnection), BOOL_OPTION("IgnoreCtcpDcc", false, KviOption_sectFlagDcc), BOOL_OPTION("AutoAcceptDccChat", false, KviOption_sectFlagDcc), @@ -120,13 +120,13 @@ KviBoolOption g_boolOptionsTable[KVI_NUM_BOOL_OPTIONS] = { BOOL_OPTION("NotifyDccSendSuccessInConsole", false, KviOption_sectFlagDcc), BOOL_OPTION("CreateMinimizedDccSend", false, KviOption_sectFlagDcc), BOOL_OPTION("CreateMinimizedDccChat", false, KviOption_sectFlagDcc), - BOOL_OPTION("AutoAcceptIncomingAvatars", true, KviOption_sectFlagDcc), + BOOL_OPTION("AutoAcceptIncomingAvatars", false, KviOption_sectFlagDcc), BOOL_OPTION("UseNickCompletionPostfixForFirstWordOnly", true, KviOption_sectFlagInput), BOOL_OPTION("UseWindowListIcons", true, KviOption_sectFlagWindowList | KviOption_resetUpdateGui | KviOption_groupTheme), BOOL_OPTION("CreateMinimizedDccSendWhenAutoAccepted", true, KviOption_sectFlagDcc), BOOL_OPTION("CreateMinimizedDccChatWhenAutoAccepted", true, KviOption_sectFlagDcc), BOOL_OPTION("DccGuessIpFromServerWhenLocalIsUnroutable", true, KviOption_sectFlagDcc), - BOOL_OPTION("ShowRegisteredUsersDialogAsToplevel", true, KviOption_sectFlagFrame), //UNUSED + BOOL_OPTION("ColorNicksWithBackground", false, KviOption_sectFlagIrcView | KviOption_groupTheme), BOOL_OPTION("AutoLogQueries", true, KviOption_sectFlagLogging), /* this options enabled by default in mIRC,XChat and irssi. People are confused while they want to see logs, but see empty dir*/ BOOL_OPTION("AutoLogChannels", true, KviOption_sectFlagLogging), BOOL_OPTION("AutoLogDccChat", false, KviOption_sectFlagLogging), @@ -188,7 +188,7 @@ KviBoolOption g_boolOptionsTable[KVI_NUM_BOOL_OPTIONS] = { BOOL_OPTION("DccSendFakeAddressByDefault", false, KviOption_sectFlagDcc), BOOL_OPTION("UseWindowListActivityMeter", false, KviOption_sectFlagWindowList | KviOption_resetUpdateGui | KviOption_groupTheme), BOOL_OPTION("CloseServerWidgetAfterConnect", false, KviOption_sectFlagFrame), - BOOL_OPTION("ShowIdentityDialogAsToplevel", true, KviOption_sectFlagFrame), //UNUSED + BOOL_OPTION("PrioritizeLastActionTime", false, KviOption_sectFlagInput), BOOL_OPTION("ShowUserChannelIcons", true, KviOption_sectFlagUserListView | KviOption_resetUpdateGui | KviOption_groupTheme), BOOL_OPTION("ShowUserChannelState", false, KviOption_sectFlagUserListView | KviOption_resetUpdateGui | KviOption_groupTheme), BOOL_OPTION("EnableIgnoreOnPrivMsg", true, KviOption_sectFlagConnection), @@ -332,7 +332,8 @@ KviBoolOption g_boolOptionsTable[KVI_NUM_BOOL_OPTIONS] = { BOOL_OPTION("ShowTreeWindowListHandle", true, KviOption_sectFlagWindowList | KviOption_resetUpdateGui | KviOption_groupTheme), BOOL_OPTION("MenuBarVisible", true, KviOption_sectFlagFrame | KviOption_resetUpdateGui), BOOL_OPTION("WarnAboutHidingMenuBar", true, KviOption_sectFlagFrame), - BOOL_OPTION("WhoRepliesToActiveWindow", false, KviOption_sectFlagConnection) + BOOL_OPTION("WhoRepliesToActiveWindow", false, KviOption_sectFlagConnection), + BOOL_OPTION("DropConnectionOnSaslFailure", false, KviOption_sectFlagConnection) }; // NOTICE: REUSE EQUIVALENT UNUSED KviOption_bool in KviOptions.h ENTRIES BEFORE ADDING NEW ENTRIES ABOVE @@ -604,7 +605,7 @@ KviUIntOption g_uintOptionsTable[KVI_NUM_UINT_OPTIONS] = { UINT_OPTION("TimeStampBackground", KviControlCodes::Transparent, KviOption_sectFlagIrcView | KviOption_resetUpdateGui | KviOption_groupTheme), UINT_OPTION("UserExperienceLevel", 1, KviOption_sectFlagUser), UINT_OPTION("ClassicWindowListMaximumButtonWidth", 100, KviOption_sectFlagGeometry | KviOption_resetUpdateGui | KviOption_groupTheme), - UINT_OPTION("DefaultBanType", 7, KviOption_sectFlagIrcSocket), + UINT_OPTION("DefaultBanType", 9, KviOption_sectFlagIrcSocket), UINT_OPTION("IrcViewPixmapAlign", 0, KviOption_sectFlagIrcView | KviOption_groupTheme), UINT_OPTION("UserListPixmapAlign", 0, KviOption_sectFlagFrame | KviOption_groupTheme), UINT_OPTION("ToolBarAppletPixmapAlign", 0, KviOption_sectFlagFrame | KviOption_groupTheme), @@ -838,7 +839,10 @@ KviMessageTypeSettingsOption g_msgtypeOptionsTable[KVI_NUM_MSGTYPE_OPTIONS] = { MSGTYPE_OPTION("ChanURL", __tr_no_lookup("Channel URL"), KviIconManager::Url, KVI_MSGTYPE_LEVEL_3), MSGTYPE_OPTION("MemoServ", __tr_no_lookup("MemoServ message"), KviIconManager::MemoServ, KVI_MSGTYPE_LEVEL_1), MSGTYPE_OPTION("Log", __tr_no_lookup("Log message"), KviIconManager::Log, KVI_MSGTYPE_LEVEL_1), - MSGTYPE_OPTION("ActionCrypted", __tr_no_lookup("Encrypted user action"), KviIconManager::ActionCrypted, KVI_MSGTYPE_LEVEL_3) + MSGTYPE_OPTION("ActionCrypted", __tr_no_lookup("Encrypted user action"), KviIconManager::ActionCrypted, KVI_MSGTYPE_LEVEL_3), + MSGTYPE_OPTION("OwnAction", __tr_no_lookup("Own action"), KviIconManager::OwnAction, KVI_MSGTYPE_LEVEL_1), + MSGTYPE_OPTION("OwnActionCrypted", __tr_no_lookup("Own encrypted action"), KviIconManager::OwnActionCrypted, KVI_MSGTYPE_LEVEL_1), + MSGTYPE_OPTION("TopicCrypted", __tr_no_lookup("Encrypted topic message"), KviIconManager::TopicCrypted, KVI_MSGTYPE_LEVEL_3), }; static const char * options_section_table[KVI_NUM_OPTION_SECT_FLAGS] = { @@ -855,9 +859,7 @@ static void config_set_section(int flag, KviConfigurationFile * cfg) { int index = flag & KviOption_sectMask; if((index < KVI_NUM_OPTION_SECT_FLAGS) && (index >= 0)) - { cfg->setGroup(options_section_table[index]); - } else cfg->setGroup(""); // Default group } @@ -913,15 +915,9 @@ void KviApplication::saveOptions() saveRecentChannels(); getLocalKvircDirectory(buffer, Config, KVI_CONFIGFILE_MAIN); + KviConfigurationFile cfg(buffer, KviConfigurationFile::Write); - if(!cfg.ensureWritable()) - { - QMessageBox::warning(nullptr, __tr2qs("Warning While Writing Configuration - KVIrc"), - __tr2qs("I can't write to the main configuration file:\n\t%1\nPlease ensure the directory exists and that you have the proper permissions before continuing, " - "or else any custom configuration will be lost.") - .arg(buffer)); - } int i; #define WRITE_OPTIONS(_num, _table) \ @@ -969,6 +965,14 @@ void KviApplication::saveOptions() WRITE_OPTIONS(KVI_NUM_MIRCCOLOR_OPTIONS, g_mirccolorOptionsTable) WRITE_OPTIONS(KVI_NUM_ICCOLOR_OPTIONS, g_iccolorOptionsTable) + if(!cfg.saveIfDirty()) + { + QMessageBox::warning(nullptr, __tr2qs("Warning While Writing Configuration - KVIrc"), + __tr2qs("I can't write to the main configuration file:\n\t%1\nPlease ensure the directory exists and that you have the proper permissions before continuing, " + "or else any custom configuration will be lost.") + .arg(buffer)); + } + #undef WRITE_OPTIONS } @@ -1005,9 +1009,7 @@ namespace KviTheme } if(!options.save(szThemeDirPath + KVI_THEMEINFO_FILE_NAME)) - { return false; - } KviConfigurationFile cfg(szThemeDirPath + KVI_THEMEDATA_FILE_NAME, KviConfigurationFile::Write); @@ -1206,13 +1208,9 @@ namespace KviTheme QString szVal = cfg.readEntry(g_pixmapOptionsTable[i].name, "").trimmed(); QString szBuffer; if(!szVal.isEmpty()) - { g_pApp->findImage(szBuffer, szVal); - } else - { szBuffer = szVal; - } KviStringConversion::fromString(szBuffer, g_pixmapOptionsTable[i].option); @@ -1295,15 +1293,11 @@ void KviApplication::optionResetUpdate(int flags) } if(flags & KviOption_resetUpdateAppFont) - { updateApplicationFont(); - } #ifdef COMPILE_PSEUDO_TRANSPARENCY if(flags & KviOption_resetUpdatePseudoTransparency) - { triggerUpdatePseudoTransparency(); - } #endif if(flags & KviOption_resetRestartIdentd) @@ -1316,34 +1310,22 @@ void KviApplication::optionResetUpdate(int flags) } if(flags & KviOption_resetUpdateGui) - { triggerUpdateGui(); - } if(flags & KviOption_resetUpdateWindowList) - { g_pMainWindow->recreateWindowList(); - } if(flags & KviOption_resetRestartNotifyList) - { g_pApp->restartNotifyLists(); - } if(flags & KviOption_resetRestartLagMeter) - { g_pApp->restartLagMeters(); - } if(flags & KviOption_resetRecentChannels) - { g_pApp->buildRecentChannels(); - } if(flags & KviOption_resetUpdateNotifier) - { emit updateNotifier(); - } } bool KviApplication::setOptionValue(const QString & optName, const QString & value) @@ -1364,13 +1346,9 @@ bool KviApplication::setOptionValue(const QString & optName, const QString & val QString szVal = value.trimmed(); QString szBuffer; if(!szVal.isEmpty()) - { findImage(szBuffer, szVal); - } else - { szBuffer = szVal; - } for(auto & i : g_pixmapOptionsTable) { diff --git a/src/kvirc/kernel/KviOptions.h b/src/kvirc/kernel/KviOptions.h index 0c53a5f9a..3b4bac15b 100644 --- a/src/kvirc/kernel/KviOptions.h +++ b/src/kvirc/kernel/KviOptions.h @@ -29,6 +29,7 @@ #include "KviCString.h" #include "KviPixmap.h" #include "KviMessageTypeSettings.h" +#include "KviControlCodes.h" #include <QRect> #include <QPixmap> @@ -47,8 +48,8 @@ \ public: \ _cname(const QString & n, _type o, int f) \ - : name(n), option(o), flags(f){}; \ - ~_cname(){}; \ + : name(n), option(o), flags(f){} \ + ~_cname() = default; \ }; DECLARE_OPTION_STRUCT(KviBoolOption, bool) @@ -62,13 +63,13 @@ DECLARE_OPTION_STRUCT(KviUIntOption, unsigned int) DECLARE_OPTION_STRUCT(KviMessageTypeSettingsOption, KviMessageTypeSettings) DECLARE_OPTION_STRUCT(KviStringListOption, QStringList) -#define KVI_COLOR_EXT_USER_OP 50 -#define KVI_COLOR_EXT_USER_HALFOP 51 -#define KVI_COLOR_EXT_USER_ADMIN 52 -#define KVI_COLOR_EXT_USER_OWNER 53 -#define KVI_COLOR_EXT_USER_VOICE 54 -#define KVI_COLOR_EXT_USER_USEROP 55 -#define KVI_COLOR_EXT_USER_NORMAL 56 +#define KVI_COLOR_EXT_USER_OP 150 +#define KVI_COLOR_EXT_USER_HALFOP 151 +#define KVI_COLOR_EXT_USER_ADMIN 152 +#define KVI_COLOR_EXT_USER_OWNER 153 +#define KVI_COLOR_EXT_USER_VOICE 154 +#define KVI_COLOR_EXT_USER_USEROP 155 +#define KVI_COLOR_EXT_USER_NORMAL 156 #define KVI_COLOR_CUSTOM 255 #define KVI_COLOR_OWN 254 @@ -154,7 +155,7 @@ DECLARE_OPTION_STRUCT(KviStringListOption, QStringList) #define KviOption_boolCreateMinimizedDccSendWhenAutoAccepted 62 /* dcc::send */ #define KviOption_boolCreateMinimizedDccChatWhenAutoAccepted 63 /* dcc::chat */ #define KviOption_boolDccGuessIpFromServerWhenLocalIsUnroutable 64 /* dcc */ -//#define KviOption_boolShowRegisteredUsersDialogAsToplevel 65 /* interface::features::global */ //UNUSED +#define KviOption_boolColorNicksWithBackground 65 /* interface::features::components::ircview */ #define KviOption_boolAutoLogQueries 66 /* ircengine::logging */ #define KviOption_boolAutoLogChannels 67 /* ircendine::logging */ #define KviOption_boolAutoLogDccChat 68 /* ircengine::logging */ @@ -212,7 +213,7 @@ DECLARE_OPTION_STRUCT(KviStringListOption, QStringList) #define KviOption_boolDccSendFakeAddressByDefault 120 /* dcc::general */ #define KviOption_boolUseWindowListActivityMeter 121 /* irc::output */ #define KviOption_boolCloseServerWidgetAfterConnect 122 /* IMPLEMENTATION NEEDED !!! */ -//#define KviOption_boolShowIdentityDialogAsToplevel 123 /* ??? */ //UNUSED +#define KviOption_boolPrioritizeLastActionTime 123 #define KviOption_boolShowUserChannelIcons 124 /* look & feel::interface features::userlist */ #define KviOption_boolShowUserChannelState 125 /* look & feel::interface features::userlist */ #define KviOption_boolEnableIgnoreOnPrivMsg 126 /* irc::ignore */ @@ -353,10 +354,11 @@ DECLARE_OPTION_STRUCT(KviStringListOption, QStringList) #define KviOption_boolMenuBarVisible 261 #define KviOption_boolWarnAboutHidingMenuBar 262 #define KviOption_boolWhoRepliesToActiveWindow 263 /* irc::output */ +#define KviOption_boolDropConnectionOnSaslFailure 264 /* connection::advanced */ // NOTICE: REUSE EQUIVALENT UNUSED BOOL_OPTION in KviOptions.cpp ENTRIES BEFORE ADDING NEW ENTRIES ABOVE -#define KVI_NUM_BOOL_OPTIONS 264 +#define KVI_NUM_BOOL_OPTIONS 265 #define KVI_STRING_OPTIONS_PREFIX "string" #define KVI_STRING_OPTIONS_PREFIX_LEN 6 @@ -632,12 +634,12 @@ namespace KviIdentdOutputMode #define KVI_MSGTYPE_OPTIONS_PREFIX "msgtype" #define KVI_MSGTYPE_OPTIONS_PREFIX_LEN 7 -#define KVI_NUM_MSGTYPE_OPTIONS 146 +#define KVI_NUM_MSGTYPE_OPTIONS 149 #define KVI_MIRCCOLOR_OPTIONS_PREFIX "mirccolor" #define KVI_MIRCCOLOR_OPTIONS_PREFIX_LEN 9 -#define KVI_NUM_MIRCCOLOR_OPTIONS 16 +#define KVI_NUM_MIRCCOLOR_OPTIONS (KVI_MIRCCOLOR_MAX+1) // external declaration of the tables extern KVIRC_API KviBoolOption g_boolOptionsTable[KVI_NUM_BOOL_OPTIONS]; @@ -666,6 +668,16 @@ extern KVIRC_API KviStringListOption g_stringlistOptionsTable[KVI_NUM_STRINGLIST #define KVI_OPTION_STRINGLIST(_idx) g_stringlistOptionsTable[_idx].option #define KVI_OPTION_ICCOLOR(_idx) g_iccolorOptionsTable[_idx].option +inline QColor getMircColor(unsigned int index) +{ + // Use inline function (instead of macro) to avoid evaluating index more than once. + if (index <= KVI_MIRCCOLOR_MAX) + return KVI_OPTION_MIRCCOLOR(index); + if (index <= KVI_EXTCOLOR_MAX) + return KviControlCodes::getExtendedColor(index); + return QColor(); // invalid color (isValid returns false) +} + // Verbosity constants #define KVI_VERBOSITY_LEVEL_MUTE 0 #define KVI_VERBOSITY_LEVEL_QUIET 1 diff --git a/src/kvirc/kernel/KviSSLMaster.cpp b/src/kvirc/kernel/KviSSLMaster.cpp index 721e308c5..3a26bd1ca 100644 --- a/src/kvirc/kernel/KviSSLMaster.cpp +++ b/src/kvirc/kernel/KviSSLMaster.cpp @@ -64,7 +64,7 @@ namespace KviSSLMaster { wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]: %c%s"), KviControlCodes::Bold, description); wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]: Version: %c%d"), KviControlCodes::Bold, c->version()); - wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]: Serial number: %c%d"), KviControlCodes::Bold, c->serialNumber()); + wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]: Serial number: %c%s"), KviControlCodes::Bold, c->serialNumber()); wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]: Subject:")); wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]: Common name: %c%s"), KviControlCodes::Bold, c->subjectCommonName()); wnd->output(KVI_OUT_SSL, __tr2qs("[SSL]: Organization: %c%s"), KviControlCodes::Bold, c->subjectOrganization()); @@ -280,7 +280,7 @@ namespace KviSSLMaster } if(szQuery.compare("serialNumber") == 0) { - pRetBuffer->setInteger(pCert->serialNumber()); + pRetBuffer->setString(pCert->serialNumber()); return true; } if(szQuery.compare("pemBase64") == 0) diff --git a/src/kvirc/kernel/KviSSLMaster.h b/src/kvirc/kernel/KviSSLMaster.h index afed0cd8c..7c451c790 100644 --- a/src/kvirc/kernel/KviSSLMaster.h +++ b/src/kvirc/kernel/KviSSLMaster.h @@ -41,7 +41,7 @@ namespace KviSSLMaster extern KVIRC_API void printSSLConnectionInfo(KviWindow * wnd, KviSSL * s); - extern KVIRC_API KviSSL * allocSSL(KviWindow * wnd, kvi_socket_t sock, KviSSL::Method m, const char * contextString = 0); + extern KVIRC_API KviSSL * allocSSL(KviWindow * wnd, kvi_socket_t sock, KviSSL::Method m, const char * contextString = nullptr); extern KVIRC_API void freeSSL(KviSSL * s); extern KVIRC_API bool getSSLCertInfo(KviSSLCertificate * pCert, QString szQuery, QString szOptionalParam, KviKvsVariant * pRetBuffer); diff --git a/src/kvirc/kernel/KviTextIconManager.cpp b/src/kvirc/kernel/KviTextIconManager.cpp index 6997e2b5a..e174e19dc 100644 --- a/src/kvirc/kernel/KviTextIconManager.cpp +++ b/src/kvirc/kernel/KviTextIconManager.cpp @@ -25,16 +25,16 @@ #define _KVI_TEXTICONMANAGER_CPP_ #include "KviTextIconManager.h" -#include "KviFileUtils.h" -#include "KviCString.h" -#include "KviConfigurationFile.h" -#include "KviApplication.h" #include "kvi_confignames.h" #include "KviAnimatedPixmap.h" +#include "KviApplication.h" +#include "KviConfigurationFile.h" +#include "KviCString.h" +#include "KviFileUtils.h" #include "KviOptions.h" -#include <QPixmap> #include <QFile> +#include <QPixmap> #include <vector> static KviTextIconAssocEntry default_associations[] = { @@ -58,11 +58,11 @@ static KviTextIconAssocEntry default_associations[] = { KVIRC_API KviTextIconManager * g_pTextIconManager = nullptr; KviTextIcon::KviTextIcon(KviIconManager::SmallIcon eIcon) - : m_eIcon(eIcon), m_pAnimatedPixmap(nullptr) + : m_eIcon(eIcon) { } -KviTextIcon::KviTextIcon(QString szFile) +KviTextIcon::KviTextIcon(const QString & szFile) : m_eIcon(KviIconManager::None), m_szFileName(szFile) { QString szRetPath; @@ -75,10 +75,6 @@ KviTextIcon::KviTextIcon(QString szFile) else m_pAnimatedPixmap->stop(); } - else - { - m_pAnimatedPixmap = nullptr; - } } KviTextIcon::KviTextIcon(KviTextIcon * pIcon) @@ -87,8 +83,6 @@ KviTextIcon::KviTextIcon(KviTextIcon * pIcon) m_szFileName = pIcon->m_szFileName; if(pIcon->m_pAnimatedPixmap) m_pAnimatedPixmap = new KviAnimatedPixmap(*(pIcon->m_pAnimatedPixmap)); - else - m_pAnimatedPixmap = nullptr; } KviTextIcon::~KviTextIcon() @@ -100,16 +94,16 @@ KviTextIcon::~KviTextIcon() void KviTextIcon::setId(KviIconManager::SmallIcon eIcon) { m_eIcon = eIcon; - m_szFileName = QString(); + m_szFileName.clear(); } void KviTextIcon::setId(int iIcon) { m_eIcon = g_pIconManager->iconName(iIcon); - m_szFileName = QString(); + m_szFileName.clear(); } -void KviTextIcon::setFilename(QString szFileName) +void KviTextIcon::setFilename(const QString & szFileName) { m_eIcon = KviIconManager::None; QString szRetPath; @@ -187,7 +181,6 @@ void KviTextIconManager::load() { QString szTmp; int iUpd = 0; - QString szPath; if(g_pApp->getReadOnlyConfigPath(szTmp, KVI_CONFIGFILE_TEXTICONS)) iUpd = load(szTmp, false); diff --git a/src/kvirc/kernel/KviTextIconManager.h b/src/kvirc/kernel/KviTextIconManager.h index 933eda307..718056d9e 100644 --- a/src/kvirc/kernel/KviTextIconManager.h +++ b/src/kvirc/kernel/KviTextIconManager.h @@ -33,9 +33,9 @@ */ #include "kvi_settings.h" -#include "KviPointerHashTable.h" #include "KviAnimatedPixmap.h" #include "KviIconManager.h" +#include "KviPointerHashTable.h" #include <QPixmap> @@ -46,11 +46,11 @@ * \struct _KviTextIconAssocEntry * \brief A struct that contains the icon association entries */ -typedef struct _KviTextIconAssocEntry +struct KviTextIconAssocEntry { const char * name; /**< the name of the icon */ int iVal; /**< the id of the icon */ -} KviTextIconAssocEntry; +}; /** * \class KviTextIcon @@ -61,7 +61,7 @@ class KVIRC_API KviTextIcon protected: KviIconManager::SmallIcon m_eIcon; QString m_szFileName; - KviAnimatedPixmap * m_pAnimatedPixmap; + KviAnimatedPixmap * m_pAnimatedPixmap = nullptr; public: /** @@ -76,7 +76,7 @@ public: * \param szFile The filename the icon * \return KviTextIcon */ - KviTextIcon(QString szFile); + KviTextIcon(const QString & szFile); /** * \brief Constructs the icon object @@ -95,7 +95,7 @@ public: * \brief Returns the id of the icon * \return KviIconManager::SmallIcon */ - inline KviIconManager::SmallIcon id() { return m_eIcon; }; + KviIconManager::SmallIcon id() const { return m_eIcon; } /** * \brief Sets the id of the icon @@ -117,13 +117,13 @@ public: * \param szFileName The filename of the icon * \return void */ - void setFilename(QString szFileName); + void setFilename(const QString & szFileName); /** * \brief Returns the filename of the icon * \return QString */ - inline QString filename() { return m_szFileName; }; + const QString & filename() const { return m_szFileName; } /** * \brief Returns the pixmap associated to the icon @@ -137,7 +137,7 @@ public: * \brief Returns the animated pixmap associated to the icon * \return KviAnimatedPixmap * */ - inline KviAnimatedPixmap * animatedPixmap() { return m_pAnimatedPixmap; }; + KviAnimatedPixmap * animatedPixmap() const { return m_pAnimatedPixmap; } }; /** @@ -169,7 +169,7 @@ public: * \brief Returns the dictionary of the icons * \return KviPointerHashTable<QString,KviTextIcon> * */ - inline KviPointerHashTable<QString, KviTextIcon> * textIconDict() { return m_pTextIconDict; }; + KviPointerHashTable<QString, KviTextIcon> * textIconDict() const { return m_pTextIconDict; } /** * \brief Checks and updates the default associations @@ -204,7 +204,7 @@ public: * \param szName The name of the icon * \return KviTextIcon * */ - inline KviTextIcon * lookupTextIcon(const QString & szName) { return m_pTextIconDict->find(szName); }; + KviTextIcon * lookupTextIcon(const QString & szName) { return m_pTextIconDict->find(szName); } /** * \brief Loads the dictionary diff --git a/src/kvirc/kernel/kvi_out.h b/src/kvirc/kernel/kvi_out.h index 0d66d83e0..c027663b5 100644 --- a/src/kvirc/kernel/kvi_out.h +++ b/src/kvirc/kernel/kvi_out.h @@ -170,7 +170,10 @@ #define KVI_OUT_MEMOSERV 143 #define KVI_OUT_LOG 144 #define KVI_OUT_ACTIONCRYPTED 145 -//#define KVI_NUM_MSGTYPE_OPTIONS 146 +#define KVI_OUT_OWNACTION 146 +#define KVI_OUT_OWNACTIONCRYPTED 147 +#define KVI_OUT_TOPICCRYPTED 148 +//#define KVI_NUM_MSGTYPE_OPTIONS 149 // UPDATE THE TOTAL COUNT IN KviOptions.h !!!! #endif //_KVI_OPTIONS_H_ diff --git a/src/kvirc/kvs/KviKvsAction.h b/src/kvirc/kvs/KviKvsAction.h index 3db570e82..f10ef1569 100644 --- a/src/kvirc/kvs/KviKvsAction.h +++ b/src/kvirc/kvs/KviKvsAction.h @@ -67,7 +67,7 @@ public: const QString & szScriptCode, const QString & szVisibleName, const QString & szDescription, - KviActionCategory * pCategory = NULL, + KviActionCategory * pCategory = nullptr, const QString & szBigIconId = QString(), const QString & szSmallIconId = QString(), unsigned int uFlags = 0, @@ -93,7 +93,7 @@ public: const QString & szScriptCode, const QString & szVisibleName, const QString & szDescription, - KviActionCategory * pCategory = NULL, + KviActionCategory * pCategory = nullptr, const QString & szBigIconId = QString(), KviIconManager::SmallIcon eSmallIcon = KviIconManager::None, unsigned int uFlags = 0, diff --git a/src/kvirc/kvs/KviKvsAliasManager.cpp b/src/kvirc/kvs/KviKvsAliasManager.cpp index 87f9c60f4..ed53b4605 100644 --- a/src/kvirc/kvs/KviKvsAliasManager.cpp +++ b/src/kvirc/kvs/KviKvsAliasManager.cpp @@ -74,7 +74,7 @@ bool KviKvsAliasManager::removeNamespace(const QString & szName) if(lKill.isEmpty()) return false; - Q_FOREACH(QString szKill, lKill) + for(auto & szKill : lKill) remove(szKill); return true; diff --git a/src/kvirc/kvs/KviKvsArray.cpp b/src/kvirc/kvs/KviKvsArray.cpp index a70c0b415..e59aa488e 100644 --- a/src/kvirc/kvs/KviKvsArray.cpp +++ b/src/kvirc/kvs/KviKvsArray.cpp @@ -25,7 +25,7 @@ #include "KviKvsArray.h" #include "KviMemory.h" -#include <stdlib.h> +#include <cstdlib> #define KVI_KVS_ARRAY_ALLOC_CHUNK 8 diff --git a/src/kvirc/kvs/KviKvsArrayCast.h b/src/kvirc/kvs/KviKvsArrayCast.h index 233b2cdc9..4182be81b 100644 --- a/src/kvirc/kvs/KviKvsArrayCast.h +++ b/src/kvirc/kvs/KviKvsArrayCast.h @@ -30,12 +30,11 @@ class KVIRC_API KviKvsArrayCast { protected: - KviKvsArray * m_pArray; - bool m_bOwned; + KviKvsArray * m_pArray = nullptr; + bool m_bOwned = false; public: - KviKvsArrayCast() - : m_pArray(0){}; + KviKvsArrayCast() = default; ~KviKvsArrayCast(); public: diff --git a/src/kvirc/kvs/KviKvsAsyncDnsOperation.h b/src/kvirc/kvs/KviKvsAsyncDnsOperation.h index fcebd4111..068a3c9ef 100644 --- a/src/kvirc/kvs/KviKvsAsyncDnsOperation.h +++ b/src/kvirc/kvs/KviKvsAsyncDnsOperation.h @@ -37,7 +37,7 @@ class KVIRC_API KviKvsAsyncDnsOperation : public KviKvsAsyncOperation { Q_OBJECT public: - KviKvsAsyncDnsOperation(KviWindow * pWnd, QString & szQuery, KviDnsResolver::QueryType eType, KviKvsScript * pCallback = 0, KviKvsVariant * pMagic = 0); + KviKvsAsyncDnsOperation(KviWindow * pWnd, QString & szQuery, KviDnsResolver::QueryType eType, KviKvsScript * pCallback = nullptr, KviKvsVariant * pMagic = nullptr); virtual ~KviKvsAsyncDnsOperation(); protected: diff --git a/src/kvirc/kvs/KviKvsCallbackObject.h b/src/kvirc/kvs/KviKvsCallbackObject.h index 5092a1a24..38bd9d7d3 100644 --- a/src/kvirc/kvs/KviKvsCallbackObject.h +++ b/src/kvirc/kvs/KviKvsCallbackObject.h @@ -80,7 +80,7 @@ protected: protected: // the parameter list is always shallow! - CallbackStatus execute(KviKvsVariantList * pParams = 0, KviKvsVariant * pRetVal = 0); + CallbackStatus execute(KviKvsVariantList * pParams = nullptr, KviKvsVariant * pRetVal = nullptr); }; #endif //!_KVI_KVS_CALLBACKOBJECT_H_ diff --git a/src/kvirc/kvs/KviKvsCoreCallbackCommands.cpp b/src/kvirc/kvs/KviKvsCoreCallbackCommands.cpp index 17e317520..e880c9d7c 100644 --- a/src/kvirc/kvs/KviKvsCoreCallbackCommands.cpp +++ b/src/kvirc/kvs/KviKvsCoreCallbackCommands.cpp @@ -530,6 +530,10 @@ namespace KviKvsCoreCallbackCommands list instead of being added.[br] The <event_name> may be one of the KVIrc builtin event names or a numeric code (from 0 to 999) of a RAW server message.[br] + <handler_name> can only contain alphanumeric characters. If the + provided handler name contains invalid characters, they are + silently removed. If the provided handler name does not contain + a single valid character, the handler will be named "unnamed".[br] If the -q switch is specified then the command runs in quiet mode. @seealso: [cmd]eventctl[/cmd] [fnc]$iseventenabled[/fnc] @@ -558,6 +562,7 @@ namespace KviKvsCoreCallbackCommands } else { + KviKvsEventManager::instance()->cleanHandlerName(szHandlerName); iNumber = KviKvsEventManager::instance()->findAppEventIndexByName(szEventName); if(!KviKvsEventManager::instance()->isValidAppEvent(iNumber)) { @@ -1030,8 +1035,6 @@ namespace KviKvsCoreCallbackCommands KVSCCC(privateimpl) { - Q_UNUSED(__pSwitches); - kvs_hobject_t hObject; QString szFunctionName; KVSCCC_PARAMETERS_BEGIN diff --git a/src/kvirc/kvs/KviKvsCoreCallbackCommands.h b/src/kvirc/kvs/KviKvsCoreCallbackCommands.h index 6062e21df..c3e001477 100644 --- a/src/kvirc/kvs/KviKvsCoreCallbackCommands.h +++ b/src/kvirc/kvs/KviKvsCoreCallbackCommands.h @@ -31,7 +31,7 @@ #include "KviKvsScript.h" #include "KviKvsParameterProcessor.h" -#define KVSCCC(_name) bool _name(KviKvsRunTimeContext * __pContext, KviKvsVariantList * __pParams, KviKvsSwitchList * __pSwitches, const KviKvsScript * __pCallback) +#define KVSCCC(_name) bool _name([[maybe_unused]] KviKvsRunTimeContext * __pContext, [[maybe_unused]] KviKvsVariantList * __pParams, [[maybe_unused]] KviKvsSwitchList * __pSwitches, const KviKvsScript * __pCallback) #define KVSCCC_pContext __pContext #define KVSCCC_pParams __pParams diff --git a/src/kvirc/kvs/KviKvsCoreFunctions.cpp b/src/kvirc/kvs/KviKvsCoreFunctions.cpp index 3e805c0f1..7d90034ab 100644 --- a/src/kvirc/kvs/KviKvsCoreFunctions.cpp +++ b/src/kvirc/kvs/KviKvsCoreFunctions.cpp @@ -147,17 +147,12 @@ namespace KviKvsCoreFunctions KVSCF(strayAt) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setString(g_szStaticStrayConstantAt); return true; } KVSCF(mightBeStrayAtOrThis) { - Q_UNUSED(__pParams); - KviKvsObject * o = KVSCF_pContext->thisObject(); if(o) { diff --git a/src/kvirc/kvs/KviKvsCoreFunctions.h b/src/kvirc/kvs/KviKvsCoreFunctions.h index d8f5e29b5..d3be8c750 100644 --- a/src/kvirc/kvs/KviKvsCoreFunctions.h +++ b/src/kvirc/kvs/KviKvsCoreFunctions.h @@ -30,7 +30,7 @@ #include "KviKvsVariant.h" #include "KviKvsParameterProcessor.h" -#define KVSCF(_name) bool _name(KviKvsRunTimeContext * __pContext, KviKvsVariantList * __pParams, KviKvsVariant * __pRetBuffer) +#define KVSCF(_name) bool _name([[maybe_unused]] KviKvsRunTimeContext * __pContext, [[maybe_unused]] KviKvsVariantList * __pParams, [[maybe_unused]] KviKvsVariant * __pRetBuffer) #define KVSCF_pContext __pContext #define KVSCF_pParams __pParams diff --git a/src/kvirc/kvs/KviKvsCoreFunctions_af.cpp b/src/kvirc/kvs/KviKvsCoreFunctions_af.cpp index c83148cc1..dd416556b 100644 --- a/src/kvirc/kvs/KviKvsCoreFunctions_af.cpp +++ b/src/kvirc/kvs/KviKvsCoreFunctions_af.cpp @@ -270,8 +270,6 @@ namespace KviKvsCoreFunctions KVSCF(array) { - Q_UNUSED(__pContext); - KviKvsArray * a = new KviKvsArray(); for(KviKvsVariant * v = KVSCF_pParams->first(); v; v = KVSCF_pParams->next()) @@ -351,9 +349,6 @@ namespace KviKvsCoreFunctions KVSCF(b) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setString(QString(QChar(KviControlCodes::Bold))); return true; } @@ -793,9 +788,6 @@ namespace KviKvsCoreFunctions KVSCF(countStatusBarItems) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - if(g_pMainWindow->mainStatusBar()) { QList<QWidget *> widgets = g_pMainWindow->mainStatusBar()->findChildren<QWidget *>(); @@ -824,9 +816,6 @@ namespace KviKvsCoreFunctions KVSCF(cr) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setString(QString(QChar('\r'))); return true; } @@ -1172,9 +1161,6 @@ namespace KviKvsCoreFunctions KVSCF(falseCKEYWORDWORKAROUND) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setBoolean(false); return true; } @@ -1203,8 +1189,8 @@ namespace KviKvsCoreFunctions %i = %myfeats[]# [cmd]while[/cmd](%i > 0) { - [cmd]echo[/cmd] "Supporting feature %myfeats[%i]" %i--; + [cmd]echo[/cmd] "Supporting feature %myfeats[%i]" } [/example] Nearly the same loop, just really shorter: @@ -1263,9 +1249,6 @@ namespace KviKvsCoreFunctions KVSCF(firstConnectedConsole) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KviConsoleWindow * c = g_pApp->topmostConnectedConsole(); KVSCF_pRetBuffer->setInteger(c ? c->numericId() : 0); return true; @@ -1296,8 +1279,6 @@ namespace KviKvsCoreFunctions KVSCF(flatten) { - Q_UNUSED(__pContext); - KviKvsArray * a = new KviKvsArray(); KVSCF_pRetBuffer->setArray(a); unsigned int uIdx = 0; diff --git a/src/kvirc/kvs/KviKvsCoreFunctions_gl.cpp b/src/kvirc/kvs/KviKvsCoreFunctions_gl.cpp index 4713f6209..bdf7714b6 100644 --- a/src/kvirc/kvs/KviKvsCoreFunctions_gl.cpp +++ b/src/kvirc/kvs/KviKvsCoreFunctions_gl.cpp @@ -134,9 +134,6 @@ namespace KviKvsCoreFunctions KVSCF(globals) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setHash(new KviKvsHash(*(KviKvsKernel::instance()->globalVariables()))); return true; } @@ -174,8 +171,6 @@ namespace KviKvsCoreFunctions KVSCF(hash) { - Q_UNUSED(__pContext); - KviKvsHash * a = new KviKvsHash(); for(KviKvsVariant * key = KVSCF_pParams->first(); key; key = KVSCF_pParams->next()) @@ -299,8 +294,6 @@ namespace KviKvsCoreFunctions KVSCF(lag) { - Q_UNUSED(__pParams); - if(!KVSCF_pContext->window()->console()) return KVSCF_pContext->errorNoIrcContext(); if(!KVSCF_pContext->window()->console()->connection()) @@ -344,11 +337,8 @@ namespace KviKvsCoreFunctions KVSCF(hptimestamp) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - struct timeval tv; - kvi_gettimeofday(&tv, nullptr); + kvi_gettimeofday(&tv); kvs_real_t dTimestamp = (kvs_real_t)(tv.tv_sec); dTimestamp += (((kvs_real_t)(tv.tv_usec)) / 1000000.0); KVSCF_pRetBuffer->setReal(dTimestamp); @@ -373,9 +363,6 @@ namespace KviKvsCoreFunctions KVSCF(i) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setString(QString(QChar(KviControlCodes::Italic))); return true; } @@ -443,7 +430,7 @@ namespace KviKvsCoreFunctions [cmd]echo[/cmd] $iconname([fnc]$icon[/fnc](linux)) [/example] @seealso: - [fnc]$iconName[/fnc] + [fnc]$icon[/fnc] */ KVSCF(iconName) @@ -482,8 +469,6 @@ namespace KviKvsCoreFunctions KVSCF(insideAlias) { - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setBoolean(KVSCF_pContext->aliasSwitchList()); return true; } @@ -621,9 +606,6 @@ namespace KviKvsCoreFunctions KVSCF(isMainWindowActive) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setBoolean(g_pMainWindow->isActiveWindow()); return true; } @@ -644,9 +626,6 @@ namespace KviKvsCoreFunctions KVSCF(isMainWindowMinimized) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setBoolean(g_pMainWindow->isMinimized()); return true; } @@ -1044,9 +1023,6 @@ namespace KviKvsCoreFunctions KVSCF(lf) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setString(QString(QChar('\n'))); return true; } diff --git a/src/kvirc/kvs/KviKvsCoreFunctions_mr.cpp b/src/kvirc/kvs/KviKvsCoreFunctions_mr.cpp index 4f83c5679..1cf80c156 100644 --- a/src/kvirc/kvs/KviKvsCoreFunctions_mr.cpp +++ b/src/kvirc/kvs/KviKvsCoreFunctions_mr.cpp @@ -37,7 +37,7 @@ #include "KviApplication.h" #include "KviQueryWindow.h" -#include <stdlib.h> // rand & srand +#include <cstdlib> // rand & srand namespace KviKvsCoreFunctions { @@ -331,9 +331,6 @@ namespace KviKvsCoreFunctions KVSCF(nothing) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setNothing(); return true; } @@ -359,9 +356,6 @@ namespace KviKvsCoreFunctions KVSCF(nullCKEYWORDWORKAROUND) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setHObject(nullptr); return true; } @@ -384,9 +378,6 @@ namespace KviKvsCoreFunctions KVSCF(o) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setString(QString(QChar(KviControlCodes::Reset))); return true; } @@ -513,9 +504,6 @@ namespace KviKvsCoreFunctions KVSCF(r) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setString(QString(QChar(KviControlCodes::Reverse))); return true; } @@ -678,9 +666,6 @@ namespace KviKvsCoreFunctions KVSCF(receivedBytes) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setInteger(g_uIncomingTraffic); return true; } diff --git a/src/kvirc/kvs/KviKvsCoreFunctions_sz.cpp b/src/kvirc/kvs/KviKvsCoreFunctions_sz.cpp index d16bc3c01..fb3b8fcea 100644 --- a/src/kvirc/kvs/KviKvsCoreFunctions_sz.cpp +++ b/src/kvirc/kvs/KviKvsCoreFunctions_sz.cpp @@ -85,7 +85,6 @@ namespace KviKvsCoreFunctions KVSCF(scriptContextName) { - Q_UNUSED(__pParams); KVSCF_pRetBuffer->setString(KVSCF_pContext->script()->name()); return true; } @@ -132,9 +131,6 @@ namespace KviKvsCoreFunctions KVSCF(sentBytes) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setInteger(g_uOutgoingTraffic); return true; } @@ -480,8 +476,6 @@ namespace KviKvsCoreFunctions KVSCF(thisCKEYWORDWORKAROUND) { - Q_UNUSED(__pParams); - // prologue: parameter handling KviKvsObject * o = KVSCF_pContext->thisObject(); KVSCF_pRetBuffer->setHObject(o ? o->handle() : ((kvs_hobject_t) nullptr)); @@ -717,9 +711,6 @@ namespace KviKvsCoreFunctions KVSCF(trueCKEYWORDWORKAROUND) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setBoolean(true); return true; } @@ -781,9 +772,6 @@ namespace KviKvsCoreFunctions KVSCF(u) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setString(QString(QChar(KviControlCodes::Underline))); return true; } @@ -904,9 +892,6 @@ namespace KviKvsCoreFunctions KVSCF(unixtime) { - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - KVSCF_pRetBuffer->setInteger((kvs_int_t)(time(nullptr))); return true; } diff --git a/src/kvirc/kvs/KviKvsCoreSimpleCommands.cpp b/src/kvirc/kvs/KviKvsCoreSimpleCommands.cpp index f250701f9..b595382e3 100644 --- a/src/kvirc/kvs/KviKvsCoreSimpleCommands.cpp +++ b/src/kvirc/kvs/KviKvsCoreSimpleCommands.cpp @@ -151,8 +151,6 @@ namespace KviKvsCoreSimpleCommands bool multipleModeCommand(KviKvsRunTimeContext * __pContext, KviKvsVariantList * __pParams, KviKvsSwitchList * __pSwitches, char plusminus, char flag) { - Q_UNUSED(__pSwitches); - QString szTokens; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("tokens", KVS_PT_STRING, KVS_PF_APPENDREMAINING, szTokens) @@ -263,8 +261,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(rfc2812wrapper) { - Q_UNUSED(__pSwitches); - QString szText; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("text", KVS_PT_STRING, KVS_PF_OPTIONAL | KVS_PF_APPENDREMAINING, szText) diff --git a/src/kvirc/kvs/KviKvsCoreSimpleCommands.h b/src/kvirc/kvs/KviKvsCoreSimpleCommands.h index 82ddb50b2..37f467f3d 100644 --- a/src/kvirc/kvs/KviKvsCoreSimpleCommands.h +++ b/src/kvirc/kvs/KviKvsCoreSimpleCommands.h @@ -32,7 +32,7 @@ #include "KviKvsSwitchList.h" #include "KviKvsParameterProcessor.h" -#define KVSCSC(_name) bool _name(KviKvsRunTimeContext * __pContext, KviKvsVariantList * __pParams, KviKvsSwitchList * __pSwitches) +#define KVSCSC(_name) bool _name([[maybe_unused]] KviKvsRunTimeContext * __pContext, [[maybe_unused]] KviKvsVariantList * __pParams, [[maybe_unused]] KviKvsSwitchList * __pSwitches) #define KVSCSC_pContext __pContext #define KVSCSC_pParams __pParams diff --git a/src/kvirc/kvs/KviKvsCoreSimpleCommands_af.cpp b/src/kvirc/kvs/KviKvsCoreSimpleCommands_af.cpp index a5a11bd13..921e77e2a 100644 --- a/src/kvirc/kvs/KviKvsCoreSimpleCommands_af.cpp +++ b/src/kvirc/kvs/KviKvsCoreSimpleCommands_af.cpp @@ -121,8 +121,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC_PARAMETER("reason", KVS_PT_STRING, KVS_PF_OPTIONAL | KVS_PF_APPENDREMAINING, szReason) KVSCSC_PARAMETERS_END - KVSCSC_REQUIRE_CONNECTION - if(szReason.isEmpty()) { if(KVI_OPTION_BOOL(KviOption_boolUseAwayMessage) || KVSCSC_pSwitches->find('d', "default-message")) @@ -173,6 +171,8 @@ namespace KviKvsCoreSimpleCommands } else { + KVSCSC_REQUIRE_CONNECTION + QByteArray szR = KVSCSC_pConnection->encodeText(szReason); if(!(KVSCSC_pConnection->sendFmtData("AWAY :%s", szR.data()))) return KVSCSC_pContext->warningNoIrcConnection(); @@ -208,8 +208,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(back) { - Q_UNUSED(__pParams); - if(KVSCSC_pSwitches->find('a', "all-networks")) { for(auto & wnd : g_pGlobalWindowDict) @@ -523,8 +521,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(cap) { - Q_UNUSED(__pSwitches); - QString szCommand, szParams; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("command", KVS_PT_NONEMPTYSTRING, 0, szCommand) @@ -671,7 +667,7 @@ namespace KviKvsCoreSimpleCommands if(szCtcpCmd.compare("PING", Qt::CaseInsensitive) == 0 && szCtcpData.isEmpty()) { struct timeval tv; - kvi_gettimeofday(&tv, nullptr); + kvi_gettimeofday(&tv); KviQString::appendFormatted(szCtcpData, "%d.%d", tv.tv_sec, tv.tv_usec); } else if (szCtcpCmd.compare("ACTION", Qt::CaseInsensitive) == 0 && !KVSCSC_pSwitches->find('n', "notice")) @@ -726,8 +722,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(debugCKEYWORDWORKAROUND) { - Q_UNUSED(__pContext); - QString szAll; KVSCSC_pParams->allAsString(szAll); if(KVSCSC_pSwitches->find('c', "scriptcontext-name")) @@ -845,9 +839,6 @@ namespace KviKvsCoreSimpleCommands @switches: !sw: -q | --quiet Causes the command to run quietly - !sw: -i | --immediate - Causes the object to be destroyed immediately - instead of simply scheduling its later deletion. @description: Schedules for destruction the object designed by <objectHandle>. This command is internally aliased to [cmd]destroy[/cmd]. @@ -861,13 +852,6 @@ namespace KviKvsCoreSimpleCommands the signals may be still emitted after the delete call. You have to disconnect the signals explicitly if you don't want it to happen.[br] - Alternatively you can use the -i switch: it causes the object - to be destructed immediately but is intrinsicly unsafe: - in complex script scenarios it may lead to a SIGSEGV; - usually when called from one of the deleted object function - handlers, or from a slot connected to one of the deleted object - signals. Well, it actually does not SIGSEGV, but I can't guarantee it; - so, if use the -i switch, test your script 10 times before releasing it. The -q switch causes the command to run a bit more silently: it still complains if the parameter passed is not an object reference, but it fails silently if the reference just points to an inexistent object (or is null). @@ -883,7 +867,7 @@ namespace KviKvsCoreSimpleCommands @title: destroy @syntax: - destroy [-q] [-i] <objectHandle> + destroy [-q] <objectHandle> @short: Destroys an object @description: @@ -911,10 +895,14 @@ namespace KviKvsCoreSimpleCommands } else { - if(KVSCSC_pSwitches->find('i', "immediate")) - o->dieNow(); - else - o->die(); + // -i | --immediate was too annoying. People were writing self-destructive scripts + // and then were complaining about -i causing their KVIrc to crash. + // + //if(KVSCSC_pSwitches->find('i', "immediate")) + // o->dieNow(); + //else + + o->die(); } } return true; @@ -1342,8 +1330,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(error) { - Q_UNUSED(__pSwitches); - QString szAll; KVSCSC_pParams->allAsString(szAll); KVSCSC_pContext->error("%Q", &szAll); @@ -1498,6 +1484,7 @@ namespace KviKvsCoreSimpleCommands } else { + KviKvsEventManager::instance()->cleanHandlerName(szHandlerName); iNumber = KviKvsEventManager::instance()->findAppEventIndexByName(szEventName); if(!KviKvsEventManager::instance()->isValidAppEvent(iNumber)) { @@ -1588,10 +1575,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(exit) { - Q_UNUSED(__pSwitches); - Q_UNUSED(__pContext); - Q_UNUSED(__pParams); - g_pApp->quit(); return true; } diff --git a/src/kvirc/kvs/KviKvsCoreSimpleCommands_gl.cpp b/src/kvirc/kvs/KviKvsCoreSimpleCommands_gl.cpp index b4ac02e9a..cb20d05e3 100644 --- a/src/kvirc/kvs/KviKvsCoreSimpleCommands_gl.cpp +++ b/src/kvirc/kvs/KviKvsCoreSimpleCommands_gl.cpp @@ -86,9 +86,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(halt) { - Q_UNUSED(__pSwitches); - Q_UNUSED(__pParams); - KVSCSC_pContext->setHaltCalled(); return false; } @@ -277,8 +274,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(inject) { - Q_UNUSED(__pSwitches); - QString szText; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("text", KVS_PT_NONEMPTYSTRING, KVS_PF_APPENDREMAINING, szText) @@ -377,8 +372,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(join) { - Q_UNUSED(__pSwitches); - QString szChans, szKeys; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("chans", KVS_PT_NONEMPTYSTRING, 0, szChans) @@ -448,8 +441,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(kick) { - Q_UNUSED(__pSwitches); - QString szUser; QString szReason; KVSCSC_PARAMETERS_BEGIN @@ -611,9 +602,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(listtimers) { - Q_UNUSED(__pSwitches); - Q_UNUSED(__pParams); - KviPointerHashTable<QString, KviKvsTimer> * pTimerDict = KviKvsTimerManager::instance()->timerDict(); if(!pTimerDict) diff --git a/src/kvirc/kvs/KviKvsCoreSimpleCommands_mr.cpp b/src/kvirc/kvs/KviKvsCoreSimpleCommands_mr.cpp index bc170ff6c..bbeca3d90 100644 --- a/src/kvirc/kvs/KviKvsCoreSimpleCommands_mr.cpp +++ b/src/kvirc/kvs/KviKvsCoreSimpleCommands_mr.cpp @@ -96,8 +96,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(me) { - Q_UNUSED(__pSwitches); - QString szText; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("text", KVS_PT_STRING, KVS_PF_OPTIONAL | KVS_PF_APPENDREMAINING, szText) @@ -143,8 +141,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(mode) { - Q_UNUSED(__pSwitches); - QString szText; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("text", KVS_PT_STRING, KVS_PF_APPENDREMAINING, szText) @@ -226,8 +222,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(nick) { - Q_UNUSED(__pSwitches); - QString szNick; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("nickname", KVS_PT_NONEMPTYSTRING, 0, szNick) @@ -236,8 +230,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC_REQUIRE_CONNECTION QByteArray szData = KVSCSC_pConnection->encodeText(szNick); - if(!szData.data()) - szData = ""; if(!KVSCSC_pConnection->sendFmtData("NICK %s", szData.data())) return KVSCSC_pContext->warningNoIrcConnection(); @@ -288,16 +280,12 @@ namespace KviKvsCoreSimpleCommands QByteArray szT = KVSCSC_pConnection->encodeText(szTarget); QByteArray szD = w ? w->encodeText(szText) : KVSCSC_pConnection->encodeText(szText); - if(!szT.data()) - szT = ""; // encoding problems ? - if(!szD.data()) - szD = ""; // encoding problems ? if(!(KVSCSC_pConnection->sendFmtData("NOTICE %s :%s", szT.data(), szD.data()))) return KVSCSC_pContext->warningNoIrcConnection(); if(!KVSCSC_pSwitches->find('q', "quiet")) - KVSCSC_pWindow->output(KVI_OUT_OWNPRIVMSG, "[NOTICE >>> %Q\r]: %Q", &szTarget, &szText); + KVSCSC_pWindow->output(KVI_OUT_OWNPRIVMSG, "[NOTICE >>> \r!nc\r%Q\r]: %Q", &szTarget, &szText); return true; } @@ -369,8 +357,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(openurl) { - Q_UNUSED(__pSwitches); - QString szUrl; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("url", KVS_PT_NONEMPTYSTRING, KVS_PF_APPENDREMAINING, szUrl) @@ -390,7 +376,8 @@ namespace KviKvsCoreSimpleCommands { szCommand = KVI_OPTION_STRING(KviOption_stringUrlHttpsCommand); } - else if(KviQString::equalCIN(szUrl, "ftp", 3)) + else if(KviQString::equalCIN(szUrl, "ftp", 3) || KviQString::equalCIN(szUrl, "sftp", 4) || + KviQString::equalCIN(szUrl, "ftps", 4) || KviQString::equalCIN(szUrl, "ftpes", 4)) { szCommand = KVI_OPTION_STRING(KviOption_stringUrlFtpCommand); if(KviQString::equalCIN(szUrl, "ftp.", 4)) @@ -415,7 +402,7 @@ namespace KviKvsCoreSimpleCommands #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) if(KVI_OPTION_BOOL(KviOption_boolUseSystemUrlHandlers)) { - intptr_t iRet = (intptr_t)::ShellExecute(NULL, TEXT("open"), szUrl.toStdWString().c_str(), NULL, NULL, SW_SHOWNORMAL); + intptr_t iRet = (intptr_t)::ShellExecute(nullptr, TEXT("open"), szUrl.toStdWString().c_str(), nullptr, nullptr, SW_SHOWNORMAL); if(iRet <= 32) { /* @@ -515,8 +502,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(operwall) { - Q_UNUSED(__pSwitches); - QString szMessage; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("message", KVS_PT_NONEMPTYSTRING, KVS_PF_APPENDREMAINING, szMessage) @@ -591,8 +576,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(option) { - Q_UNUSED(__pSwitches); - QString szName; QString szValue; KVSCSC_PARAMETERS_BEGIN @@ -1019,17 +1002,13 @@ namespace KviKvsCoreSimpleCommands else { QByteArray szT = KVSCSC_pConnection->encodeText(szTarget); - QByteArray szD = w ? w->encodeText(szText) : KVSCSC_pConnection->encodeText(szText); - if(!szT.data()) - szT = ""; // encoding problems ? - if(!szD.data()) - szD = ""; // encoding problems ? + QByteArray szD = KVSCSC_pConnection->encodeText(szText); if(!(KVSCSC_pConnection->sendFmtData("PRIVMSG %s :%s", szT.data(), szD.data()))) return KVSCSC_pContext->warningNoIrcConnection(); if(!KVSCSC_pSwitches->find('q', "quiet")) - KVSCSC_pWindow->output(KVI_OUT_OWNPRIVMSG, "[PRIVMSG >>> %Q\r]: %Q", &szTarget, &szText); + KVSCSC_pWindow->output(KVI_OUT_OWNPRIVMSG, "[PRIVMSG >>> \r!nc\r%Q\r]: %Q", &szTarget, &szText); } return true; @@ -1076,8 +1055,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(query) { - Q_UNUSED(__pSwitches); - QString szTargets, szText; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("targets", KVS_PT_NONEMPTYSTRING, 0, szTargets) @@ -1219,10 +1196,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(raise) { - Q_UNUSED(__pSwitches); - Q_UNUSED(__pParams); - Q_UNUSED(__pContext); - if(!g_pMainWindow->isVisible()) g_pMainWindow->show(); g_pMainWindow->raise(); @@ -1269,8 +1242,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC_REQUIRE_CONNECTION QByteArray szData = KVSCSC_pConnection->encodeText(szRawCommand); - if(!szData.data()) - szData = ""; if(!KVSCSC_pConnection->sendData(szData.data())) return KVSCSC_pContext->warningNoIrcConnection(); @@ -1364,8 +1335,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(returnCKEYWORDWORKAROUND) { - Q_UNUSED(__pSwitches); - if(KVSCSC_pParams->count() == 0) { KVSCSC_pContext->returnValue()->setNothing(); @@ -1411,8 +1380,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(run) { - Q_UNUSED(__pSwitches); - QString szCommand; QStringList l; KVSCSC_PARAMETERS_BEGIN diff --git a/src/kvirc/kvs/KviKvsCoreSimpleCommands_sz.cpp b/src/kvirc/kvs/KviKvsCoreSimpleCommands_sz.cpp index c49e341d0..f91970ccb 100644 --- a/src/kvirc/kvs/KviKvsCoreSimpleCommands_sz.cpp +++ b/src/kvirc/kvs/KviKvsCoreSimpleCommands_sz.cpp @@ -152,6 +152,7 @@ namespace KviKvsCoreSimpleCommands entry too). !sw: -s | --ssl Activates the SSL support for this connection (if OpenSSL support has been compiled in). + If SSL is enabled and no port is specified, the connection will be made to port 6697. !sw: -u | --unused-context Forces the connection to be attempted in the first IRC context that has no connection in progress. If all the IRC contexts have connections in progress @@ -288,6 +289,8 @@ namespace KviKvsCoreSimpleCommands d->bUseSSL = (KVSCSC_pSwitches->find('s', "ssl") != nullptr); d->bSTARTTLS = false; d->szServer = szServer; + // if the user wants to connect using ssl but didn't specify a port, default to 6697 + if (d->bUseSSL && !(uPort > 0))uPort = 6697; d->uPort = (kvi_u32_t)uPort; d->szLinkFilter = szSocketFilter; d->bPortIsOk = (uPort > 0); @@ -440,8 +443,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(setreturn) { - Q_UNUSED(__pSwitches); - if(KVSCSC_pParams->count() == 0) { KVSCSC_pContext->returnValue()->setNothing(); @@ -518,11 +519,7 @@ namespace KviKvsCoreSimpleCommands else { QByteArray szT = KVSCSC_pConnection->encodeText(szTarget); - QByteArray szD = w ? w->encodeText(szText) : KVSCSC_pConnection->encodeText(szText); - if(!szT.data()) - szT = ""; // encoding problems ? - if(!szD.data()) - szD = ""; // encoding problems ? + QByteArray szD = KVSCSC_pConnection->encodeText(szText); if(!(KVSCSC_pConnection->sendFmtData("SQUERY %s :%s", szT.data(), szD.data()))) return KVSCSC_pContext->warningNoIrcConnection(); @@ -572,7 +569,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(srand) { - Q_UNUSED(__pSwitches); QString tmp; for(int i = 0; i < 10; i++) @@ -645,8 +641,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(topic) { - Q_UNUSED(__pSwitches); - QString szChannel; QString szTopic; KVSCSC_PARAMETERS_BEGIN @@ -937,8 +931,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(warning) { - Q_UNUSED(__pSwitches); - QString szAll; KVSCSC_pParams->allAsString(szAll); KVSCSC_pContext->warning("%Q", &szAll); @@ -965,8 +957,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(wallops) { - Q_UNUSED(__pSwitches); - QString szMessage; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("message", KVS_PT_NONEMPTYSTRING, KVS_PF_APPENDREMAINING, szMessage) @@ -1019,8 +1009,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(who) { - Q_UNUSED(__pSwitches); - QString szData; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("filter", KVS_PT_NONEMPTYSTRING, KVS_PF_OPTIONAL | KVS_PF_APPENDREMAINING, szData) @@ -1080,8 +1068,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(whois) { - Q_UNUSED(__pSwitches); - QString szNick; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("nickname", KVS_PT_NONEMPTYSTRING, KVS_PF_APPENDREMAINING, szNick) @@ -1122,8 +1108,6 @@ namespace KviKvsCoreSimpleCommands KVSCSC(whowas) { - Q_UNUSED(__pSwitches); - QString szNick; KVSCSC_PARAMETERS_BEGIN KVSCSC_PARAMETER("nickname", KVS_PT_NONEMPTYSTRING, KVS_PF_APPENDREMAINING, szNick) diff --git a/src/kvirc/kvs/KviKvsDnsManager.h b/src/kvirc/kvs/KviKvsDnsManager.h index 341fe0bf0..1154ecd5d 100644 --- a/src/kvirc/kvs/KviKvsDnsManager.h +++ b/src/kvirc/kvs/KviKvsDnsManager.h @@ -42,8 +42,8 @@ public: KviWindow * pWnd, const QString & szQuery, bool bRebindOnWindowClose = true, - KviKvsScript * pCallback = 0, - KviKvsVariantList * pParameterList = 0); + KviKvsScript * pCallback = nullptr, + KviKvsVariantList * pParameterList = nullptr); ~KviKvsDnsObject(); protected: diff --git a/src/kvirc/kvs/KviKvsKernel.h b/src/kvirc/kvs/KviKvsKernel.h index 5dcaf8de4..945ca7e76 100644 --- a/src/kvirc/kvs/KviKvsKernel.h +++ b/src/kvirc/kvs/KviKvsKernel.h @@ -44,28 +44,28 @@ class KviKvsScript; class KviKvsHash; typedef KviKvsTreeNodeCommand * (KviKvsParser::*specialCommandParsingRoutine)(); -typedef struct _KviKvsSpecialCommandParsingRoutine +struct KviKvsSpecialCommandParsingRoutine { specialCommandParsingRoutine proc; -} KviKvsSpecialCommandParsingRoutine; +}; typedef bool (*coreSimpleCommandExecRoutine)(KviKvsRunTimeContext * c, KviKvsVariantList * pParams, KviKvsSwitchList * pSwitches); -typedef struct _KviKvsCoreSimpleCommandExecRoutine +struct KviKvsCoreSimpleCommandExecRoutine { coreSimpleCommandExecRoutine proc; -} KviKvsCoreSimpleCommandExecRoutine; +}; typedef bool (*coreFunctionExecRoutine)(KviKvsRunTimeContext * c, KviKvsVariantList * pParams, KviKvsVariant * pRetBuffer); -typedef struct _KviKvsCoreFunctionExecRoutine +struct KviKvsCoreFunctionExecRoutine { coreFunctionExecRoutine proc; -} KviKvsCoreFunctionExecRoutine; +}; typedef bool (*coreCallbackCommandExecRoutine)(KviKvsRunTimeContext * c, KviKvsVariantList * pParams, KviKvsSwitchList * pSwitches, const KviKvsScript * pCallback); -typedef struct _KviKvsCoreCallbackCommandExecRoutine +struct KviKvsCoreCallbackCommandExecRoutine { coreCallbackCommandExecRoutine proc; -} KviKvsCoreCallbackCommandExecRoutine; +}; class KVIRC_API KviKvsKernel { diff --git a/src/kvirc/kvs/KviKvsModuleInterface.h b/src/kvirc/kvs/KviKvsModuleInterface.h index 0d04b195e..45e2a940b 100644 --- a/src/kvirc/kvs/KviKvsModuleInterface.h +++ b/src/kvirc/kvs/KviKvsModuleInterface.h @@ -103,7 +103,7 @@ public: ~KviKvsModuleCallbackCommandCall(){}; public: - // Never NULL, but may have empty code + // Never nullptr, but may have empty code const KviKvsScript * callback() { return m_pCallback; }; virtual bool getParameterCode(unsigned int uParamIdx, QString & szParamBuffer); }; diff --git a/src/kvirc/kvs/KviKvsParameterProcessor.h b/src/kvirc/kvs/KviKvsParameterProcessor.h index 4ab74d7d0..551a01c77 100644 --- a/src/kvirc/kvs/KviKvsParameterProcessor.h +++ b/src/kvirc/kvs/KviKvsParameterProcessor.h @@ -211,11 +211,11 @@ namespace KviKvsParameterProcessor // KVS_PT_IGNORE ParameterFormat(const char * name) - : szName(name), uType(KVS_PT_IGNORE), uFlags(0), pContainer(NULL) {} + : szName(name), uType(KVS_PT_IGNORE), uFlags(0), pContainer(nullptr) {} // terminator ParameterFormat() - : szName(NULL), uType(KVS_PT_IGNORE), uFlags(0), pContainer(NULL){}; + : szName(nullptr), uType(KVS_PT_IGNORE), uFlags(0), pContainer(nullptr){}; //ParameterFormat(const char * n,unsigned char t,unsigned char f,void * p) //: szName(n), uType(t), uFlags(f), pContainer(p) {}; @@ -227,9 +227,9 @@ namespace KviKvsParameterProcessor #define KVS_PARAMETERS_BEGIN(__name) \ KviKvsParameterProcessor::ParameterFormat __name[] = { -#define KVS_PARAMETERS_END \ - KviKvsParameterProcessor::ParameterFormat(0) \ - } \ +#define KVS_PARAMETERS_END \ + KviKvsParameterProcessor::ParameterFormat(nullptr) \ + } \ ; //#define KVS_PARAMETER(__name,__type,__flags,__void) diff --git a/src/kvirc/kvs/KviKvsPopupMenu.cpp b/src/kvirc/kvs/KviKvsPopupMenu.cpp index 2cf8b1e64..1be8489c0 100644 --- a/src/kvirc/kvs/KviKvsPopupMenu.cpp +++ b/src/kvirc/kvs/KviKvsPopupMenu.cpp @@ -34,6 +34,7 @@ #include "KviOptions.h" #include <QWidgetAction> +#include <utility> // popup names // rootname : the root popup @@ -44,35 +45,21 @@ // rootname.labelX : child labels KviKvsPopupMenuItem::KviKvsPopupMenuItem(Type t, const QString & szItemName, const QString & szCondition) + : m_szItemName{szItemName}, m_eType{t} { - m_szItemName = szItemName; - m_eType = t; - if(szCondition.isEmpty()) + if(!szCondition.isEmpty()) { - // true by default - m_pKvsCondition = nullptr; - } - else - { - QString szName = "condition callback for "; - szName += szItemName; + QString szName = QStringLiteral("condition callback for ") + szItemName; m_pKvsCondition = new KviKvsScript(szName, szCondition, KviKvsScript::Expression); } } -KviKvsPopupMenuItem::KviKvsPopupMenuItem(Type t, const QString & szItemName, const KviKvsScript * pCondition) +KviKvsPopupMenuItem::KviKvsPopupMenuItem(Type t, QString szItemName, const KviKvsScript * pCondition) + : m_szItemName{ std::move(szItemName) } + , m_eType{ t } { - m_szItemName = szItemName; - m_eType = t; - if(!pCondition) - { - // true by default - m_pKvsCondition = nullptr; - } - else - { + if(pCondition) m_pKvsCondition = new KviKvsScript(*pCondition); - } } KviKvsPopupMenuItem::~KviKvsPopupMenuItem() @@ -85,17 +72,17 @@ void KviKvsPopupMenuItem::clear() { } -KviKvsScript * KviKvsPopupMenuItem::kvsIcon() +KviKvsScript * KviKvsPopupMenuItem::kvsIcon() const { return nullptr; } -KviKvsScript * KviKvsPopupMenuItem::kvsText() +KviKvsScript * KviKvsPopupMenuItem::kvsText() const { return nullptr; } -KviKvsScript * KviKvsPopupMenuItem::kvsCode() +KviKvsScript * KviKvsPopupMenuItem::kvsCode() const { return nullptr; } @@ -136,7 +123,7 @@ void KviKvsPopupMenuItemSeparator::fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenu { if(!evaluateCondition(pData)) return; - ((QMenu *)pMenu)->addSeparator(); + static_cast<QMenu *>(pMenu)->addSeparator(); } KviKvsPopupMenuItem * KviKvsPopupMenuItemSeparator::clone() const @@ -147,18 +134,12 @@ KviKvsPopupMenuItem * KviKvsPopupMenuItemSeparator::clone() const KviKvsPopupMenuItemWithTextAndIcon::KviKvsPopupMenuItemWithTextAndIcon(KviKvsPopupMenuItem::Type t, const QString & szItemName, const QString & szText, const QString & szIcon, const QString & szCondition) : KviKvsPopupMenuItem(t, szItemName, szCondition) { - QString szName = "text callback for "; - szName += szItemName; + QString szName = QStringLiteral("text callback for ") + szItemName; m_pKvsText = new KviKvsScript(szName, szText, KviKvsScript::Parameter); - if(szIcon.isEmpty()) + if(!szIcon.isEmpty()) { - m_pKvsIcon = nullptr; - } - else - { - szName = "icon callback for "; - szName += szItemName; + szName = QStringLiteral("icon callback for ") + szItemName; m_pKvsIcon = new KviKvsScript(szName, szIcon, KviKvsScript::Parameter); } } @@ -167,25 +148,16 @@ KviKvsPopupMenuItemWithTextAndIcon::KviKvsPopupMenuItemWithTextAndIcon(KviKvsPop : KviKvsPopupMenuItem(t, szItemName, pCondition) { if(pText) - { m_pKvsText = new KviKvsScript(*pText); - } else { // hum.. this should never happen anyway - QString szName = "text callback for "; - szName += szItemName; + QString szName = QStringLiteral("text callback for ") + szItemName; m_pKvsText = new KviKvsScript(szName, "", KviKvsScript::Parameter); } - if(!pIcon) - { - m_pKvsIcon = nullptr; - } - else - { + if(pIcon) m_pKvsIcon = new KviKvsScript(*pIcon); - } } KviKvsPopupMenuItemWithTextAndIcon::~KviKvsPopupMenuItemWithTextAndIcon() @@ -195,12 +167,12 @@ KviKvsPopupMenuItemWithTextAndIcon::~KviKvsPopupMenuItemWithTextAndIcon() delete m_pKvsIcon; } -KviKvsScript * KviKvsPopupMenuItemWithTextAndIcon::kvsIcon() +KviKvsScript * KviKvsPopupMenuItemWithTextAndIcon::kvsIcon() const { return m_pKvsIcon; } -KviKvsScript * KviKvsPopupMenuItemWithTextAndIcon::kvsText() +KviKvsScript * KviKvsPopupMenuItemWithTextAndIcon::kvsText() const { return m_pKvsText; } @@ -235,9 +207,8 @@ QPixmap * KviKvsPopupMenuItemWithTextAndIcon::evaluateIcon(KviKvsPopupMenuTopLev QString KviKvsPopupMenuItemWithTextAndIcon::evaluateText(KviKvsPopupMenuTopLevelData * pData) { - QString szRet; if(!m_pKvsText) - return szRet; + return {}; KviKvsVariant vRet; if(!m_pKvsText->run(pData->window(), pData->parameters(), @@ -247,16 +218,16 @@ QString KviKvsPopupMenuItemWithTextAndIcon::evaluateText(KviKvsPopupMenuTopLevel { // broken text pData->window()->output(KVI_OUT_PARSERWARNING, __tr2qs_ctx("Broken text parameter: assuming empty string", "kvs")); - return szRet; + return {}; } + QString szRet; vRet.asString(szRet); return szRet; } KviKvsPopupMenuItemLabelHelper::KviKvsPopupMenuItemLabelHelper(KviKvsPopupMenuItemLabel * pItem) - : QObject() + : QObject(), m_pItem{pItem} { - m_pItem = pItem; } KviKvsPopupMenuItemLabelHelper::~KviKvsPopupMenuItemLabelHelper() @@ -270,14 +241,12 @@ void KviKvsPopupMenuItemLabelHelper::labelDestroyed() KviKvsPopupMenuItemLabel::KviKvsPopupMenuItemLabel(const QString & szItemName, const QString & szText, const QString & szIcon, const QString & szCondition) : KviKvsPopupMenuItemWithTextAndIcon(KviKvsPopupMenuItem::Label, szItemName, szText, szIcon, szCondition) { - m_pLabel = nullptr; m_pSignalRelay = new KviKvsPopupMenuItemLabelHelper(this); } KviKvsPopupMenuItemLabel::KviKvsPopupMenuItemLabel(const QString & szItemName, const KviKvsScript * pText, const KviKvsScript * pIcon, const KviKvsScript * pCondition) : KviKvsPopupMenuItemWithTextAndIcon(KviKvsPopupMenuItem::Label, szItemName, pText, pIcon, pCondition) { - m_pLabel = nullptr; m_pSignalRelay = new KviKvsPopupMenuItemLabelHelper(this); } @@ -325,9 +294,6 @@ void KviKvsPopupMenuItemLabel::fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopL m_pLabel = new QLabel(szText, pMenu); QObject::connect(m_pLabel, SIGNAL(destroyed()), m_pSignalRelay, SLOT(labelDestroyed())); -//QPalette p; -//m_pLabel->setStyleSheet("background-color: " + p.color(QPalette::Normal, QPalette::Mid).name()); - #ifdef COMPILE_ON_MAC m_pLabel->setIndent(16); m_pLabel->setMargin(2); @@ -346,8 +312,7 @@ void KviKvsPopupMenuItemLabel::fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopL KviKvsPopupMenuItemItem::KviKvsPopupMenuItemItem(const QString & szItemName, const QString & szCode, const QString & szText, const QString & szIcon, const QString & szCondition) : KviKvsPopupMenuItemWithTextAndIcon(KviKvsPopupMenuItem::Item, szItemName, szText, szIcon, szCondition) { - QString szName = "click callback for "; - szName += szItemName; + QString szName = QStringLiteral("click callback for ") + szItemName; m_pKvsCode = new KviKvsScript(szName, szCode); } @@ -381,21 +346,19 @@ KviKvsPopupMenuItem * KviKvsPopupMenuItemItem::clone() const return new KviKvsPopupMenuItemItem(m_szItemName, m_pKvsCode, m_pKvsText, m_pKvsIcon, m_pKvsCondition); } -KviKvsScript * KviKvsPopupMenuItemItem::kvsCode() +KviKvsScript * KviKvsPopupMenuItemItem::kvsCode() const { return m_pKvsCode; } KviKvsPopupMenuItemMenu::KviKvsPopupMenuItemMenu(const QString & szItemName, KviKvsPopupMenu * pMenu, const QString & szText, const QString & szIcon, const QString & szCondition) - : KviKvsPopupMenuItemWithTextAndIcon(KviKvsPopupMenuItem::Menu, szItemName, szText, szIcon, szCondition) + : KviKvsPopupMenuItemWithTextAndIcon(KviKvsPopupMenuItem::Menu, szItemName, szText, szIcon, szCondition), m_pMenu{pMenu} { - m_pMenu = pMenu; } KviKvsPopupMenuItemMenu::KviKvsPopupMenuItemMenu(const QString & szItemName, KviKvsPopupMenu * pMenu, const KviKvsScript * pText, const KviKvsScript * pIcon, const KviKvsScript * pCondition) - : KviKvsPopupMenuItemWithTextAndIcon(KviKvsPopupMenuItem::Menu, szItemName, pText, pIcon, pCondition) + : KviKvsPopupMenuItemWithTextAndIcon(KviKvsPopupMenuItem::Menu, szItemName, pText, pIcon, pCondition), m_pMenu{pMenu} { - m_pMenu = pMenu; } KviKvsPopupMenuItemMenu::~KviKvsPopupMenuItemMenu() @@ -416,8 +379,8 @@ void KviKvsPopupMenuItemMenu::fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopLe return; QString szText = evaluateText(pData); QPixmap * pPix = evaluateIcon(pData); - QAction * pAction; m_pMenu->setParentPopup(pMenu); + QAction * pAction; if(pPix) pAction = pMenu->addAction(*pPix, szText); else @@ -431,34 +394,31 @@ void KviKvsPopupMenuItemMenu::clear() m_pMenu->clearMenuContents(); } -KviKvsPopupMenuItemExtMenu::KviKvsPopupMenuItemExtMenu(const QString & szItemName, const QString & szMenuName, const QString & szText, const QString & szIcon, const QString & szCondition) +KviKvsPopupMenuItemExtMenu::KviKvsPopupMenuItemExtMenu(const QString & szItemName, QString szMenuName, const QString & szText, const QString & szIcon, const QString & szCondition) : KviKvsPopupMenuItemWithTextAndIcon(KviKvsPopupMenuItem::ExtMenu, szItemName, szText, szIcon, szCondition) + , m_szMenuName{ std::move(szMenuName) } { - m_szMenuName = szMenuName; - if(m_szMenuName[0] == '"' && m_szMenuName[(int)(m_szMenuName.length() - 1)] == '"') + if(m_szMenuName[0] == '"' && m_szMenuName[m_szMenuName.length() - 1] == '"') { m_szMenuName.remove(0, 1); m_szMenuName.remove(m_szMenuName.length() - 1, 1); } - m_pMenu = nullptr; } -KviKvsPopupMenuItemExtMenu::KviKvsPopupMenuItemExtMenu(const QString & szItemName, const QString & szMenuName, const KviKvsScript * pText, const KviKvsScript * pIcon, const KviKvsScript * pCondition) +KviKvsPopupMenuItemExtMenu::KviKvsPopupMenuItemExtMenu(const QString & szItemName, QString szMenuName, const KviKvsScript * pText, const KviKvsScript * pIcon, const KviKvsScript * pCondition) : KviKvsPopupMenuItemWithTextAndIcon(KviKvsPopupMenuItem::ExtMenu, szItemName, pText, pIcon, pCondition) + , m_szMenuName{ std::move(szMenuName) } { - m_szMenuName = szMenuName; - if(m_szMenuName[0] == '"' && m_szMenuName[(int)(m_szMenuName.length() - 1)] == '"') + if(m_szMenuName[0] == '"' && m_szMenuName[m_szMenuName.length() - 1] == '"') { m_szMenuName.remove(0, 1); m_szMenuName.remove(m_szMenuName.length() - 1, 1); } - m_pMenu = nullptr; } KviKvsPopupMenuItemExtMenu::~KviKvsPopupMenuItemExtMenu() { - if(m_pMenu) - delete m_pMenu; + clear(); } void KviKvsPopupMenuItemExtMenu::clear() @@ -491,8 +451,7 @@ void KviKvsPopupMenuItemExtMenu::fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTo return; } QString tmp = QString("%1.%2").arg(pMenu->popupName(), m_szMenuName); - if(m_pMenu) - delete m_pMenu; + clear(); m_pMenu = new KviKvsPopupMenu(tmp); m_pMenu->copyFrom(source); m_pMenu->setParentPopup(pMenu); @@ -506,18 +465,13 @@ void KviKvsPopupMenuItemExtMenu::fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTo pAction->setData(iIdx); } else - { pData->window()->output(KVI_OUT_PARSERWARNING, __tr2qs_ctx("Can't find the external popup '%Q': ignoring", "kvs"), &m_szMenuName); - } } KviKvsPopupMenuTopLevelData::KviKvsPopupMenuTopLevelData(KviKvsVariantList * pParameters, KviWindow * pWindow) + : m_pParameters{pParameters}, m_pWindow{pWindow} { m_pExtendedRunTimeData = new KviKvsExtendedRunTimeData(new KviKvsHash(), true); - m_pParameters = pParameters; - m_pWindow = pWindow; - m_bTestMode = false; - m_eLocked = Unlocked; } KviKvsPopupMenuTopLevelData::~KviKvsPopupMenuTopLevelData() @@ -527,19 +481,14 @@ KviKvsPopupMenuTopLevelData::~KviKvsPopupMenuTopLevelData() } KviKvsPopupMenu::KviKvsPopupMenu(const QString & szName) - : QMenu(szName, nullptr) + : QMenu(szName, nullptr), m_szName{szName} { - m_szName = szName; m_pItemList = new KviPointerList<KviKvsPopupMenuItem>; m_pItemList->setAutoDelete(true); m_pPrologues = new KviPointerList<KviKvsScript>; m_pPrologues->setAutoDelete(true); m_pEpilogues = new KviPointerList<KviKvsScript>; m_pEpilogues->setAutoDelete(true); - m_pParentPopup = nullptr; - m_pTopLevelData = nullptr; - m_pTempTopLevelData = nullptr; - m_bSetupDone = false; connect(this, SIGNAL(triggered(QAction *)), this, SLOT(itemClicked(QAction *))); connect(this, SIGNAL(aboutToShow()), this, SLOT(setupMenuContents())); } @@ -561,19 +510,13 @@ void KviKvsPopupMenu::copyFrom(const KviKvsPopupMenu * src) doClear(); for(KviKvsScript * se = src->m_pEpilogues->first(); se; se = src->m_pEpilogues->next()) - { m_pEpilogues->append(new KviKvsScript(*se)); - } for(KviKvsScript * sp = src->m_pPrologues->first(); sp; sp = src->m_pPrologues->next()) - { m_pPrologues->append(new KviKvsScript(*sp)); - } for(const KviKvsPopupMenuItem * it = src->m_pItemList->first(); it; it = src->m_pItemList->next()) - { addItemInternal(it->clone()); - } } void KviKvsPopupMenu::addPrologue(const QString & szItemName, const QString & szCode) @@ -619,49 +562,36 @@ KviKvsPopupMenu * KviKvsPopupMenu::findChildPopupByName(const QString & szItemNa bool KviKvsPopupMenu::removeItemByName(const QString & szItemName, bool bRecursive) { - KviKvsScript * se; - - for(se = m_pEpilogues->first(); se; se = m_pEpilogues->next()) - { + for(auto se = m_pEpilogues->first(); se; se = m_pEpilogues->next()) if(KviQString::equalCI(szItemName, se->name())) { m_pEpilogues->removeRef(se); return true; } - } - for(se = m_pPrologues->first(); se; se = m_pPrologues->next()) - { + for(auto se = m_pPrologues->first(); se; se = m_pPrologues->next()) if(KviQString::equalCI(szItemName, se->name())) { m_pPrologues->removeRef(se); return true; } - } - for(KviKvsPopupMenuItem * it = m_pItemList->first(); it; it = m_pItemList->next()) - { + for(auto * it = m_pItemList->first(); it; it = m_pItemList->next()) if(KviQString::equalCI(szItemName, it->name())) { m_pItemList->removeRef(it); // bye :) return true; } - } if(bRecursive) { - for(KviKvsPopupMenuItem * ii = m_pItemList->first(); ii; ii = m_pItemList->next()) - { - if(ii->isMenu()) + for(auto * ii = m_pItemList->first(); ii; ii = m_pItemList->next()) + if(ii->isMenu() && static_cast<KviKvsPopupMenuItemMenu *>(ii)->menu()) { - if(((KviKvsPopupMenuItemMenu *)ii)->menu()) - { - bool bRet = ((KviKvsPopupMenuItemMenu *)ii)->menu()->removeItemByName(szItemName, true); - if(bRet) - return true; - } + bool bRet = static_cast<KviKvsPopupMenuItemMenu *>(ii)->menu()->removeItemByName(szItemName, true); + if(bRet) + return true; } - } } return false; @@ -757,9 +687,7 @@ void KviKvsPopupMenu::clearMenuContents() clear(); for(KviKvsPopupMenuItem * it = m_pItemList->first(); it; it = m_pItemList->next()) - { it->clear(); - } if(m_pTopLevelData) { @@ -795,7 +723,7 @@ void KviKvsPopupMenu::doClear() void KviKvsPopupMenu::lock(KviKvsPopupMenuTopLevelData::LockStatus eLock) { - KviKvsPopupMenuTopLevelData * d = topLevelData(); + auto * d = topLevelData(); if(!d) return; d->setLocked(eLock); @@ -804,9 +732,9 @@ void KviKvsPopupMenu::lock(KviKvsPopupMenuTopLevelData::LockStatus eLock) void KviKvsPopupMenu::setupMenuContents() { // This might be a compat problem later :(((( - if(parentPopup() == nullptr) + if(!parentPopup()) { - if(m_pTempTopLevelData == nullptr) + if(!m_pTempTopLevelData) { // We have been called by a KviMenuBar! // m_bSetupDone is not valid here @@ -946,17 +874,13 @@ void KviKvsPopupMenu::load(const QString & prefix, KviConfigurationFile * cfg) { doClear(); - int cnt; - int idx; + QString tmp = prefix + QStringLiteral("_PrologueCount"); - QString tmp = prefix; - tmp.append("_PrologueCount"); - - cnt = cfg->readIntEntry(tmp, 0); + int cnt = cfg->readIntEntry(tmp, 0); if(cnt > 0) { - for(idx = 0; idx < cnt; idx++) + for(int idx = 0; idx < cnt; idx++) { tmp = QString("%1_Prologue%2").arg(prefix).arg(idx); QString pr = cfg->readEntry(tmp, ""); @@ -980,7 +904,7 @@ void KviKvsPopupMenu::load(const QString & prefix, KviConfigurationFile * cfg) if(cnt > 0) { - for(idx = 0; idx < cnt; idx++) + for(int idx = 0; idx < cnt; idx++) { tmp = QString("%1_Epilogue%2").arg(prefix).arg(idx); QString ep = cfg->readEntry(tmp, ""); @@ -1003,7 +927,7 @@ void KviKvsPopupMenu::load(const QString & prefix, KviConfigurationFile * cfg) cnt = cfg->readIntEntry(tmp, 0); - for(idx = 0; idx < cnt; idx++) + for(int idx = 0; idx < cnt; idx++) { QString pre = QString("%1_%2").arg(prefix).arg(idx); @@ -1085,16 +1009,11 @@ void KviKvsPopupMenu::load(const QString & prefix, KviConfigurationFile * cfg) void KviKvsPopupMenu::save(const QString & prefix, KviConfigurationFile * cfg) { - int idx; - - KviKvsScript * s; - QString tmp; - - tmp = QString("%1_PrologueCount").arg(prefix); + QString tmp = QString("%1_PrologueCount").arg(prefix); cfg->writeEntry(tmp, m_pPrologues->count()); - idx = 0; - for(s = m_pPrologues->first(); s; s = m_pPrologues->next()) + int idx = 0; + for(auto s = m_pPrologues->first(); s; s = m_pPrologues->next()) { tmp = QString("%1_Prologue%2").arg(prefix).arg(idx); cfg->writeEntry(tmp, s->code()); @@ -1107,7 +1026,7 @@ void KviKvsPopupMenu::save(const QString & prefix, KviConfigurationFile * cfg) cfg->writeEntry(tmp, m_pEpilogues->count()); idx = 0; - for(s = m_pEpilogues->first(); s; s = m_pEpilogues->next()) + for(auto s = m_pEpilogues->first(); s; s = m_pEpilogues->next()) { tmp = QString("%1_Epilogue%2").arg(prefix).arg(idx); cfg->writeEntry(tmp, s->code()); @@ -1149,7 +1068,7 @@ void KviKvsPopupMenu::save(const QString & prefix, KviConfigurationFile * cfg) tmp = QString("%1_Id").arg(pre); cfg->writeEntry(tmp, it->name()); - s = it->kvsCondition(); + auto s = it->kvsCondition(); if(s) { tmp = QString("%1_Expr").arg(pre); @@ -1200,7 +1119,7 @@ void KviKvsPopupMenu::generateDefPopupCore(QString & buffer) KviKvsScript * s; - for(s = m_pPrologues->first(); s; s = m_pPrologues->next()) + for(auto s = m_pPrologues->first(); s; s = m_pPrologues->next()) { buffer.append("prologue\n"); tmp = s->code().trimmed(); @@ -1215,7 +1134,11 @@ void KviKvsPopupMenu::generateDefPopupCore(QString & buffer) { case KviKvsPopupMenuItem::Item: if(it->kvsIcon()) - KviQString::appendFormatted(buffer, "item(%Q,%Q)", &(it->kvsText()->code()), &(it->kvsIcon()->code())); + { + QString szIcon = it->kvsIcon()->code(); + KviQString::escapeKvs(&szIcon, KviQString::EscapeSpace | KviQString::EscapeParenthesis); + KviQString::appendFormatted(buffer, "item(%Q,%Q)", &(it->kvsText()->code()), &szIcon); + } else KviQString::appendFormatted(buffer, "item(%Q)", &(it->kvsText()->code())); if(it->kvsCondition()) @@ -1228,7 +1151,11 @@ void KviKvsPopupMenu::generateDefPopupCore(QString & buffer) break; case KviKvsPopupMenuItem::Menu: if(it->kvsIcon()) - KviQString::appendFormatted(buffer, "popup(%Q,%Q)", &(it->kvsText()->code()), &(it->kvsIcon()->code())); + { + QString szIcon = it->kvsIcon()->code(); + KviQString::escapeKvs(&szIcon, KviQString::EscapeSpace | KviQString::EscapeParenthesis); + KviQString::appendFormatted(buffer, "popup(%Q,%Q)", &(it->kvsText()->code()), &szIcon); + } else KviQString::appendFormatted(buffer, "popup(%Q)", &(it->kvsText()->code())); if(it->kvsCondition()) @@ -1247,7 +1174,11 @@ void KviKvsPopupMenu::generateDefPopupCore(QString & buffer) break; case KviKvsPopupMenuItem::Label: if(it->kvsIcon()) - KviQString::appendFormatted(buffer, "label(%Q,%Q)", &(it->kvsText()->code()), &(it->kvsIcon()->code())); + { + QString szIcon = it->kvsIcon()->code(); + KviQString::escapeKvs(&szIcon, KviQString::EscapeSpace | KviQString::EscapeParenthesis); + KviQString::appendFormatted(buffer, "label(%Q,%Q)", &(it->kvsText()->code()), &szIcon); + } else KviQString::appendFormatted(buffer, "label(%Q)", &(it->kvsText()->code())); if(it->kvsCondition()) @@ -1256,7 +1187,11 @@ void KviKvsPopupMenu::generateDefPopupCore(QString & buffer) break; case KviKvsPopupMenuItem::ExtMenu: if(it->kvsIcon()) - KviQString::appendFormatted(buffer, "extpopup(%Q,%Q,%Q)", &(it->kvsText()->code()), &(((KviKvsPopupMenuItemExtMenu *)it)->extName()), &(it->kvsIcon()->code())); + { + QString szIcon = it->kvsIcon()->code(); + KviQString::escapeKvs(&szIcon, KviQString::EscapeSpace | KviQString::EscapeParenthesis); + KviQString::appendFormatted(buffer, "extpopup(%Q,%Q,%Q)", &(it->kvsText()->code()), &(((KviKvsPopupMenuItemExtMenu *)it)->extName()), &szIcon); + } else KviQString::appendFormatted(buffer, "extpopup(%Q)", &(it->kvsText()->code())); if(it->kvsCondition()) diff --git a/src/kvirc/kvs/KviKvsPopupMenu.h b/src/kvirc/kvs/KviKvsPopupMenu.h index f9c4d8261..0ad36e19f 100644 --- a/src/kvirc/kvs/KviKvsPopupMenu.h +++ b/src/kvirc/kvs/KviKvsPopupMenu.h @@ -53,23 +53,22 @@ public: }; protected: - KviKvsExtendedRunTimeData * m_pExtendedRunTimeData; - KviKvsVariantList * m_pParameters; - KviWindow * m_pWindow; - LockStatus m_eLocked; - bool m_bTestMode; + KviKvsExtendedRunTimeData * m_pExtendedRunTimeData = nullptr; + KviKvsVariantList * m_pParameters = nullptr; + KviWindow * m_pWindow = nullptr; + LockStatus m_eLocked = Unlocked; + bool m_bTestMode = false; public: - KviKvsExtendedRunTimeData * extendedRunTimeData() { return m_pExtendedRunTimeData; }; - //KviKvsHash * extScopeVariables(){ return m_pExtScopeVariables; }; - KviKvsVariantList * parameters() { return m_pParameters; }; - bool isSoftLocked() { return m_eLocked != Unlocked; }; - bool isHardLocked() { return m_eLocked == HardLocked; }; - void setLocked(LockStatus eLocked) { m_eLocked = eLocked; }; - KviWindow * window() { return m_pWindow; }; - void setWindow(KviWindow * pWindow) { m_pWindow = pWindow; }; - bool testMode() { return m_bTestMode; }; - void setTestMode(bool bTestMode) { m_bTestMode = bTestMode; }; + KviKvsExtendedRunTimeData * extendedRunTimeData() const { return m_pExtendedRunTimeData; } + KviKvsVariantList * parameters() const { return m_pParameters; } + bool isSoftLocked() const { return m_eLocked != Unlocked; } + bool isHardLocked() const { return m_eLocked == HardLocked; } + void setLocked(LockStatus eLocked) { m_eLocked = eLocked; } + KviWindow * window() const { return m_pWindow; } + void setWindow(KviWindow * pWindow) { m_pWindow = pWindow; } + bool testMode() const { return m_bTestMode; } + void setTestMode(bool bTestMode) { m_bTestMode = bTestMode; } }; class KVIRC_API KviKvsPopupMenuItem @@ -88,7 +87,7 @@ public: protected: KviKvsPopupMenuItem(Type t, const QString & szItemName, const QString & szCondition); - KviKvsPopupMenuItem(Type t, const QString & szItemName, const KviKvsScript * pCondition); + KviKvsPopupMenuItem(Type t, QString szItemName, const KviKvsScript * pCondition); public: virtual ~KviKvsPopupMenuItem(); @@ -96,26 +95,26 @@ public: protected: QString m_szItemName; Type m_eType; - KviKvsScript * m_pKvsCondition; + KviKvsScript * m_pKvsCondition = nullptr; public: // this doesn't trigger errors, only warnings bool evaluateCondition(KviKvsPopupMenuTopLevelData * pData); - KviKvsPopupMenuItem::Type type() { return m_eType; }; + KviKvsPopupMenuItem::Type type() const { return m_eType; } - const QString & name() { return m_szItemName; }; + const QString & name() const { return m_szItemName; } - bool isItem() { return m_eType == Item; }; - bool isSeparator() { return m_eType == Separator; }; - bool isLabel() { return m_eType == Label; }; - bool isExtMenu() { return m_eType == ExtMenu; }; - bool isMenu() { return m_eType == Menu; }; + bool isItem() const { return m_eType == Item; } + bool isSeparator() const { return m_eType == Separator; } + bool isLabel() const { return m_eType == Label; } + bool isExtMenu() const { return m_eType == ExtMenu; } + bool isMenu() const { return m_eType == Menu; } - KviKvsScript * kvsCondition() { return m_pKvsCondition; }; - virtual KviKvsScript * kvsIcon(); - virtual KviKvsScript * kvsText(); - virtual KviKvsScript * kvsCode(); + KviKvsScript * kvsCondition() const { return m_pKvsCondition; } + virtual KviKvsScript * kvsIcon() const; + virtual KviKvsScript * kvsText() const; + virtual KviKvsScript * kvsCode() const; virtual void fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopLevelData * pData, int iIdx) = 0; virtual void clear(); @@ -131,11 +130,11 @@ protected: KviKvsPopupMenuItemSeparator(const QString & szItemName, const KviKvsScript * pCondition); public: - virtual ~KviKvsPopupMenuItemSeparator(); + ~KviKvsPopupMenuItemSeparator(); public: - virtual void fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopLevelData * pData, int iIdx); - virtual KviKvsPopupMenuItem * clone() const; + void fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopLevelData * pData, int iIdx) override; + KviKvsPopupMenuItem * clone() const override; }; class KVIRC_API KviKvsPopupMenuItemWithTextAndIcon : public KviKvsPopupMenuItem @@ -145,15 +144,15 @@ protected: KviKvsPopupMenuItemWithTextAndIcon(KviKvsPopupMenuItem::Type t, const QString & szItemName, const KviKvsScript * pText, const KviKvsScript * pIcon, const KviKvsScript * pCondition); public: - virtual ~KviKvsPopupMenuItemWithTextAndIcon(); + ~KviKvsPopupMenuItemWithTextAndIcon(); protected: - KviKvsScript * m_pKvsText; - KviKvsScript * m_pKvsIcon; + KviKvsScript * m_pKvsText = nullptr; + KviKvsScript * m_pKvsIcon = nullptr; public: - virtual KviKvsScript * kvsIcon(); - virtual KviKvsScript * kvsText(); + KviKvsScript * kvsIcon() const override; + KviKvsScript * kvsText() const override; // this just returns a string, eventually empty QString evaluateText(KviKvsPopupMenuTopLevelData * pData); // this just returns the icon, eventually @@ -173,7 +172,7 @@ protected: ~KviKvsPopupMenuItemLabelHelper(); protected: - KviKvsPopupMenuItemLabel * m_pItem; + KviKvsPopupMenuItemLabel * m_pItem = nullptr; protected slots: void labelDestroyed(); }; @@ -188,16 +187,16 @@ protected: KviKvsPopupMenuItemLabel(const QString & szItemName, const KviKvsScript * pText, const KviKvsScript * pIcon, const KviKvsScript * pCondition); public: - virtual ~KviKvsPopupMenuItemLabel(); + ~KviKvsPopupMenuItemLabel(); protected: - QLabel * m_pLabel; - KviKvsPopupMenuItemLabelHelper * m_pSignalRelay; + QLabel * m_pLabel = nullptr; + KviKvsPopupMenuItemLabelHelper * m_pSignalRelay = nullptr; public: - virtual void fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopLevelData * pData, int iIdx); - virtual KviKvsPopupMenuItem * clone() const; - virtual void clear(); + void fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopLevelData * pData, int iIdx) override; + KviKvsPopupMenuItem * clone() const override; + void clear() override; protected: void labelDestroyed(); @@ -212,17 +211,17 @@ protected: KviKvsPopupMenuItemItem(const QString & szItemName, const KviKvsScript * pCode, const KviKvsScript * pText, const KviKvsScript * pIcon, const KviKvsScript * pCondition); public: - virtual ~KviKvsPopupMenuItemItem(); + ~KviKvsPopupMenuItemItem(); protected: - KviKvsScript * m_pKvsCode; + KviKvsScript * m_pKvsCode = nullptr; protected: - virtual KviKvsScript * kvsCode(); + KviKvsScript * kvsCode() const override; public: - virtual void fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopLevelData * pData, int iIdx); - virtual KviKvsPopupMenuItem * clone() const; + void fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopLevelData * pData, int iIdx) override; + KviKvsPopupMenuItem * clone() const override; }; class KVIRC_API KviKvsPopupMenuItemMenu : public KviKvsPopupMenuItemWithTextAndIcon @@ -234,16 +233,16 @@ protected: KviKvsPopupMenuItemMenu(const QString & szItemName, KviKvsPopupMenu * pMenu, const KviKvsScript * pText, const KviKvsScript * pIcon, const KviKvsScript * pCondition); public: - virtual ~KviKvsPopupMenuItemMenu(); + ~KviKvsPopupMenuItemMenu(); protected: - KviKvsPopupMenu * m_pMenu; + KviKvsPopupMenu * m_pMenu = nullptr; public: - KviKvsPopupMenu * menu() { return m_pMenu; }; - virtual void fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopLevelData * pData, int iIdx); - virtual void clear(); - virtual KviKvsPopupMenuItem * clone() const; + KviKvsPopupMenu * menu() const { return m_pMenu; } + void fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopLevelData * pData, int iIdx) override; + void clear() override; + KviKvsPopupMenuItem * clone() const override; }; class KVIRC_API KviKvsPopupMenuItemExtMenu : public KviKvsPopupMenuItemWithTextAndIcon @@ -251,52 +250,53 @@ class KVIRC_API KviKvsPopupMenuItemExtMenu : public KviKvsPopupMenuItemWithTextA friend class KviKvsPopupMenu; protected: - KviKvsPopupMenuItemExtMenu(const QString & szItemName, const QString & szMenuName, const QString & szText, const QString & szIcon, const QString & szCondition); - KviKvsPopupMenuItemExtMenu(const QString & szItemName, const QString & szMenuName, const KviKvsScript * pText, const KviKvsScript * pIcon, const KviKvsScript * pCondition); + KviKvsPopupMenuItemExtMenu(const QString & szItemName, QString szMenuName, const QString & szText, const QString & szIcon, const QString & szCondition); + KviKvsPopupMenuItemExtMenu(const QString & szItemName, QString szMenuName, const KviKvsScript * pText, const KviKvsScript * pIcon, const KviKvsScript * pCondition); public: - virtual ~KviKvsPopupMenuItemExtMenu(); + ~KviKvsPopupMenuItemExtMenu(); protected: QString m_szMenuName; - KviKvsPopupMenu * m_pMenu; // owned! + KviKvsPopupMenu * m_pMenu = nullptr; // owned! public: - const QString & extName() { return m_szMenuName; }; - virtual void fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopLevelData * pData, int iIdx); - virtual void clear(); - virtual KviKvsPopupMenuItem * clone() const; + const QString & extName() const { return m_szMenuName; } + void fill(KviKvsPopupMenu * pMenu, KviKvsPopupMenuTopLevelData * pData, int iIdx) override; + void clear() override; + KviKvsPopupMenuItem * clone() const override; }; class KVIRC_API KviKvsPopupMenu : public QMenu { + Q_OBJECT friend class KviKvsPopupMenuItemMenu; friend class KviKvsPopupManager; friend class KviSinglePopupEditor; - Q_OBJECT + public: KviKvsPopupMenu(const QString & szName); ~KviKvsPopupMenu(); protected: - KviPointerList<KviKvsPopupMenuItem> * m_pItemList; + KviPointerList<KviKvsPopupMenuItem> * m_pItemList = nullptr; private: QString m_szName; - KviKvsPopupMenu * m_pParentPopup; - KviPointerList<KviKvsScript> * m_pPrologues; - KviPointerList<KviKvsScript> * m_pEpilogues; - KviKvsPopupMenuTopLevelData * m_pTopLevelData; + KviKvsPopupMenu * m_pParentPopup = nullptr; + KviPointerList<KviKvsScript> * m_pPrologues = nullptr; + KviPointerList<KviKvsScript> * m_pEpilogues = nullptr; + KviKvsPopupMenuTopLevelData * m_pTopLevelData = nullptr; // this is a temporary used to hack-in the activation from KviMenuBar - KviKvsPopupMenuTopLevelData * m_pTempTopLevelData; - bool m_bSetupDone; + KviKvsPopupMenuTopLevelData * m_pTempTopLevelData = nullptr; + bool m_bSetupDone = false; public: - const QString & popupName() { return m_szName; }; - void setPopupName(const QString & szName) { m_szName = szName; }; + const QString & popupName() const { return m_szName; } + void setPopupName(const QString & szName) { m_szName = szName; } void copyFrom(const KviKvsPopupMenu * src); KviKvsPopupMenuTopLevelData * topLevelData(); KviKvsPopupMenu * topLevelPopup(); - KviPointerList<KviKvsPopupMenuItem> * itemList() { return m_pItemList; }; + KviPointerList<KviKvsPopupMenuItem> * itemList() const { return m_pItemList; } bool isSoftLocked(); bool isHardLocked(); void lock(KviKvsPopupMenuTopLevelData::LockStatus eLock); @@ -306,17 +306,17 @@ public: void addItem(const QString & szItemName, const QString & szCode, const QString & szText, const QString & szIcon, const QString & szCondition); void addExtPopup(const QString & szItemName, const QString & szPopupName, const QString & szText, const QString & szIcon, const QString & szCondition); void doPopup(const QPoint & pnt, KviWindow * wnd, KviKvsVariantList * pParams, bool bTestMode = false); - bool isEmpty() { return m_pItemList->isEmpty() && m_pPrologues->isEmpty() && m_pEpilogues->isEmpty(); }; + bool isEmpty() const { return m_pItemList->isEmpty() && m_pPrologues->isEmpty() && m_pEpilogues->isEmpty(); } void doClear(); void addPrologue(const QString & szItemName, const QString & szCode); void addEpilogue(const QString & szItemName, const QString & szCode); bool removeItemByName(const QString & szItemName, bool bRecursive); KviKvsPopupMenu * findChildPopupByName(const QString & szItemName); - KviPointerList<KviKvsScript> * epilogues() { return m_pEpilogues; }; - KviPointerList<KviKvsScript> * prologues() { return m_pPrologues; }; - KviKvsPopupMenu * parentPopup() { return m_pParentPopup; }; + KviPointerList<KviKvsScript> * epilogues() const { return m_pEpilogues; } + KviPointerList<KviKvsScript> * prologues() const { return m_pPrologues; } + KviKvsPopupMenu * parentPopup() const { return m_pParentPopup; } void generateDefPopup(QString & buffer); - void setParentPopup(KviKvsPopupMenu * par) { m_pParentPopup = par; }; + void setParentPopup(KviKvsPopupMenu * par) { m_pParentPopup = par; } void generateDefPopupCore(QString & buffer); protected: diff --git a/src/kvirc/kvs/KviKvsProcessManager.cpp b/src/kvirc/kvs/KviKvsProcessManager.cpp index 48e51e8b2..dcaad4ec6 100644 --- a/src/kvirc/kvs/KviKvsProcessManager.cpp +++ b/src/kvirc/kvs/KviKvsProcessManager.cpp @@ -385,7 +385,7 @@ void KviKvsProcessManager::done() { if(!m_pInstance)return; delete m_pInstance; - m_pInstance = 0; + m_pInstance = nullptr; } bool KviKvsProcessManager::execute(KviKvsProcessAsyncOperationData * d) diff --git a/src/kvirc/kvs/KviKvsProcessManager.h b/src/kvirc/kvs/KviKvsProcessManager.h index 3a881c7bf..a7ad759d3 100644 --- a/src/kvirc/kvs/KviKvsProcessManager.h +++ b/src/kvirc/kvs/KviKvsProcessManager.h @@ -53,7 +53,7 @@ class KviWindow; class KviKvsScript; class KviKvsVariant; -typedef struct _KviKvsProcessDescriptorData +struct KviKvsProcessDescriptorData { QString szShell; QString szCommandline; @@ -63,7 +63,7 @@ typedef struct _KviKvsProcessDescriptorData int iFlags; int iMaxRunTime; // 0 for no timeout int iPingTimeout; // 0 for no ping timeout -} KviKvsProcessDescriptorData; +}; class KviKvsProcessManager; diff --git a/src/kvirc/kvs/KviKvsReport.cpp b/src/kvirc/kvs/KviKvsReport.cpp index 7bd515293..2161e232b 100644 --- a/src/kvirc/kvs/KviKvsReport.cpp +++ b/src/kvirc/kvs/KviKvsReport.cpp @@ -23,6 +23,8 @@ //============================================================================= #include "KviKvsReport.h" + +#include <utility> #include "KviControlCodes.h" #include "KviWindow.h" #include "kvi_out.h" @@ -31,8 +33,12 @@ #include "KviDebugWindow.h" #include "KviOptions.h" -KviKvsReport::KviKvsReport(Type t, const QString & szContext, const QString & szMessage, const QString & szLocation, KviWindow * pWindow) - : m_eType(t), m_szContext(szContext), m_szMessage(szMessage), m_szLocation(szLocation), m_pWindow(pWindow) +KviKvsReport::KviKvsReport(Type t, QString szContext, QString szMessage, QString szLocation, KviWindow * pWindow) + : m_eType(t) + , m_szContext(std::move(szContext)) + , m_szMessage(std::move(szMessage)) + , m_szLocation(std::move(szLocation)) + , m_pWindow(pWindow) { m_pCallStack = nullptr; m_pCodeListing = nullptr; diff --git a/src/kvirc/kvs/KviKvsReport.h b/src/kvirc/kvs/KviKvsReport.h index f3f0b9ffa..4e969bf17 100644 --- a/src/kvirc/kvs/KviKvsReport.h +++ b/src/kvirc/kvs/KviKvsReport.h @@ -42,7 +42,7 @@ public: }; public: - KviKvsReport(Type t, const QString & szContext, const QString & szMessage, const QString & szLocation, KviWindow * pWindow); + KviKvsReport(Type t, QString szContext, QString szMessage, QString szLocation, KviWindow * pWindow); ~KviKvsReport(); protected: diff --git a/src/kvirc/kvs/KviKvsRunTimeContext.h b/src/kvirc/kvs/KviKvsRunTimeContext.h index 09c8c89a7..f2c20494e 100644 --- a/src/kvirc/kvs/KviKvsRunTimeContext.h +++ b/src/kvirc/kvs/KviKvsRunTimeContext.h @@ -113,7 +113,7 @@ protected: KviWindow * pWnd, KviKvsVariantList * pParams, KviKvsVariant * pRetVal, - KviKvsExtendedRunTimeData * pExtData = 0); + KviKvsExtendedRunTimeData * pExtData = nullptr); public: ~KviKvsRunTimeContext(); diff --git a/src/kvirc/kvs/KviKvsScript.h b/src/kvirc/kvs/KviKvsScript.h index 8e68ce309..f8639a0ab 100644 --- a/src/kvirc/kvs/KviKvsScript.h +++ b/src/kvirc/kvs/KviKvsScript.h @@ -181,7 +181,7 @@ public: * \param pExtData Extended data (usually 0) * \return int */ - int run(KviWindow * pWnd, KviKvsVariantList * pParams = 0, KviKvsVariant * pRetVal = 0, int iRunFlags = 0, KviKvsExtendedRunTimeData * pExtData = 0); + int run(KviWindow * pWnd, KviKvsVariantList * pParams = nullptr, KviKvsVariant * pRetVal = nullptr, int iRunFlags = 0, KviKvsExtendedRunTimeData * pExtData = nullptr); /** * \brief Runs the script @@ -199,7 +199,7 @@ public: * \param pExtData Extended data (usually 0) * \return int */ - int run(KviWindow * pWnd, KviKvsVariantList * pParams, QString & szRetVal, int iRunFlags = 0, KviKvsExtendedRunTimeData * pExtData = 0); + int run(KviWindow * pWnd, KviKvsVariantList * pParams, QString & szRetVal, int iRunFlags = 0, KviKvsExtendedRunTimeData * pExtData = nullptr); /** * \brief Runs the script @@ -225,7 +225,7 @@ public: * \param pRetVal Return value buffer (0 if you ignore it) * \return int */ - static int run(const QString & szCode, KviWindow * pWindow, KviKvsVariantList * pParams = 0, KviKvsVariant * pRetVal = 0); + static int run(const QString & szCode, KviWindow * pWindow, KviKvsVariantList * pParams = nullptr, KviKvsVariant * pRetVal = nullptr); /** * \brief Static helper for quick evaluating parameters @@ -271,7 +271,7 @@ protected: * \param iRunFlags A combination of run flags (usually default) * \return bool */ - bool parse(KviWindow * pOutput = 0, int iRunFlags = 0); + bool parse(KviWindow * pOutput = nullptr, int iRunFlags = 0); /** * \brief Runs the script @@ -285,7 +285,7 @@ protected: * \param pExtData Extended data (usually 0) * \return int */ - int execute(KviWindow * pWnd, KviKvsVariantList * pParams = 0, KviKvsVariant * pRetVal = 0, int iRunFlags = 0, KviKvsExtendedRunTimeData * pExtData = 0); + int execute(KviWindow * pWnd, KviKvsVariantList * pParams = nullptr, KviKvsVariant * pRetVal = nullptr, int iRunFlags = 0, KviKvsExtendedRunTimeData * pExtData = nullptr); /** * \brief Runs the script diff --git a/src/kvirc/kvs/KviKvsScriptAddonManager.cpp b/src/kvirc/kvs/KviKvsScriptAddonManager.cpp index 9ad223469..f980f23a7 100644 --- a/src/kvirc/kvs/KviKvsScriptAddonManager.cpp +++ b/src/kvirc/kvs/KviKvsScriptAddonManager.cpp @@ -31,16 +31,21 @@ #include "KviApplication.h" #include <QFileInfo> +#include <utility> KviKvsScriptAddonManager * KviKvsScriptAddonManager::m_pInstance = nullptr; KviKvsScriptAddon::KviKvsScriptAddon( - const QString & szName, - const QString & szVersion, + QString szName, + QString szVersion, const QString & szVisibleNameCode, const QString & szDescriptionCode, const QString & szUninstallCallbackCode, - const QString & szIconId) : KviHeapObject(), m_szName(szName), m_szVersion(szVersion), m_szIconId(szIconId) + QString szIconId) + : KviHeapObject() + , m_szName(std::move(szName)) + , m_szVersion(std::move(szVersion)) + , m_szIconId(std::move(szIconId)) { allocateScripts(szVisibleNameCode, szDescriptionCode, szUninstallCallbackCode); m_pConfigureCallback = nullptr; diff --git a/src/kvirc/kvs/KviKvsScriptAddonManager.h b/src/kvirc/kvs/KviKvsScriptAddonManager.h index a53c4da80..58536c75d 100644 --- a/src/kvirc/kvs/KviKvsScriptAddonManager.h +++ b/src/kvirc/kvs/KviKvsScriptAddonManager.h @@ -43,12 +43,12 @@ class KVIRC_API KviKvsScriptAddon : public KviHeapObject protected: KviKvsScriptAddon(); KviKvsScriptAddon( - const QString & szName, - const QString & szVersion, + QString szName, + QString szVersion, const QString & szVisibleNameCode, const QString & szDescriptionCode, const QString & szUninstallCallbackCode, - const QString & szIconId); + QString szIconId); public: KviKvsScriptAddon(const KviKvsScriptAddon & a); diff --git a/src/kvirc/kvs/KviKvsTimerManager.h b/src/kvirc/kvs/KviKvsTimerManager.h index 5dcacbe71..2fa33cc5a 100644 --- a/src/kvirc/kvs/KviKvsTimerManager.h +++ b/src/kvirc/kvs/KviKvsTimerManager.h @@ -127,7 +127,7 @@ public: protected: void scheduleKill(KviKvsTimer * t); - virtual void timerEvent(QTimerEvent * e); + void timerEvent(QTimerEvent * e) override; }; #endif //!_KVI_KVS_TIMERMANAGER_H_ diff --git a/src/kvirc/kvs/KviKvsVariant.cpp b/src/kvirc/kvs/KviKvsVariant.cpp index 38ae42cb6..b7547beef 100644 --- a/src/kvirc/kvs/KviKvsVariant.cpp +++ b/src/kvirc/kvs/KviKvsVariant.cpp @@ -27,7 +27,7 @@ #include "KviKvsHash.h" #include "KviKvsArray.h" -#include <math.h> +#include <cmath> #include <cinttypes> int KviKvsVariantComparison::compareIntString(const KviKvsVariant * pV1, const KviKvsVariant * pV2) @@ -1671,7 +1671,7 @@ KviKvsVariant * KviKvsVariant::unserializeHash(const QChar ** ppAux) //skip leading '{' (*ppAux)++; int i = 0; - while(1) + while(true) { //skip leading space while((*ppAux)->isSpace()) @@ -1744,7 +1744,7 @@ KviKvsVariant * KviKvsVariant::unserializeArray(const QChar ** ppAux) KviKvsVariant * pElement = nullptr; (*ppAux)++; int i = 0; - while(1) + while(true) { pElement = unserialize(ppAux); if(pElement) diff --git a/src/kvirc/kvs/event/KviKvsEventHandler.cpp b/src/kvirc/kvs/event/KviKvsEventHandler.cpp index 37f14aca3..4392623c4 100644 --- a/src/kvirc/kvs/event/KviKvsEventHandler.cpp +++ b/src/kvirc/kvs/event/KviKvsEventHandler.cpp @@ -24,6 +24,8 @@ #include "KviKvsEventHandler.h" +#include <utility> + KviKvsEventHandler::KviKvsEventHandler(Type t) : KviHeapObject(), m_type(t) { @@ -32,8 +34,10 @@ KviKvsEventHandler::KviKvsEventHandler(Type t) KviKvsEventHandler::~KviKvsEventHandler() = default; -KviKvsScriptEventHandler::KviKvsScriptEventHandler(const QString & szHandlerName, const QString & szContextName, const QString & szCode, bool bEnabled) - : KviKvsEventHandler(KviKvsEventHandler::Script), m_szName(szHandlerName), m_bEnabled(bEnabled) +KviKvsScriptEventHandler::KviKvsScriptEventHandler(QString szHandlerName, const QString & szContextName, const QString & szCode, bool bEnabled) + : KviKvsEventHandler(KviKvsEventHandler::Script) + , m_szName(std::move(szHandlerName)) + , m_bEnabled(bEnabled) { m_pScript = new KviKvsScript(szContextName, szCode); } diff --git a/src/kvirc/kvs/event/KviKvsEventHandler.h b/src/kvirc/kvs/event/KviKvsEventHandler.h index c03ed7a4b..804e8750d 100644 --- a/src/kvirc/kvs/event/KviKvsEventHandler.h +++ b/src/kvirc/kvs/event/KviKvsEventHandler.h @@ -54,7 +54,7 @@ class KVIRC_API KviKvsScriptEventHandler : public KviKvsEventHandler { public: // the event handler becomes the owned of pszCode! - KviKvsScriptEventHandler(const QString & szHandlerName, const QString & szContextName, const QString & szCode, bool bEnabled = true); + KviKvsScriptEventHandler(QString szHandlerName, const QString & szContextName, const QString & szCode, bool bEnabled = true); virtual ~KviKvsScriptEventHandler(); protected: diff --git a/src/kvirc/kvs/event/KviKvsEventManager.cpp b/src/kvirc/kvs/event/KviKvsEventManager.cpp index 15ca56f3c..74a82419a 100644 --- a/src/kvirc/kvs/event/KviKvsEventManager.cpp +++ b/src/kvirc/kvs/event/KviKvsEventManager.cpp @@ -33,6 +33,8 @@ #include "KviWindow.h" #include "KviKvsVariantList.h" +#include <QRegExp> + /* @doc: events @type: @@ -636,3 +638,11 @@ void KviKvsEventManager::saveAppEvents(const QString & szFileName) } } } + +void KviKvsEventManager::cleanHandlerName(QString & szHandlerName) +{ + static QRegExp re(KVI_KVS_EVENT_HANDLER_NAME_INVALID_CHARS_REG_EXP); + szHandlerName.replace(re, ""); + if (szHandlerName.isEmpty()) + szHandlerName = "unnamed"; +} diff --git a/src/kvirc/kvs/event/KviKvsEventManager.h b/src/kvirc/kvs/event/KviKvsEventManager.h index 2f2f4eb98..a151ec638 100644 --- a/src/kvirc/kvs/event/KviKvsEventManager.h +++ b/src/kvirc/kvs/event/KviKvsEventManager.h @@ -36,6 +36,9 @@ class KviKvsVariantList; #define KVI_KVS_NUM_RAW_EVENTS 1000 +#define KVI_KVS_EVENT_HANDLER_NAME_REG_EXP "^[A-Za-z0-9_]*$" +#define KVI_KVS_EVENT_HANDLER_NAME_INVALID_CHARS_REG_EXP "[^A-Za-z0-9_]" + class KVIRC_API KviKvsEventManager : public QObject { Q_OBJECT @@ -127,6 +130,8 @@ public: void saveAppEvents(const QString & szFileName); void loadRawEvents(const QString & szFileName); void saveRawEvents(const QString & szFileName); + + void cleanHandlerName(QString & szHandlerName); signals: void eventHandlerDisabled(const QString &); }; diff --git a/src/kvirc/kvs/object/KviKvsObject.cpp b/src/kvirc/kvs/object/KviKvsObject.cpp index 2dcd7e47d..aca8163aa 100644 --- a/src/kvirc/kvs/object/KviKvsObject.cpp +++ b/src/kvirc/kvs/object/KviKvsObject.cpp @@ -45,9 +45,9 @@ #include <QIcon> #include <QPointer> -#include <time.h> +#include <ctime> - /* +/* @doc: objects @title: Object scripting @@ -524,7 +524,7 @@ by all the modern kernels and used in inter-process communication).[br] */ - /* +/* @doc: object @keyterms: object class, object, class @@ -634,7 +634,7 @@ static char * g_hNextObjectHandle = (char *)nullptr; KviKvsObject::KviKvsObject(KviKvsObjectClass * pClass, KviKvsObject * pParent, const QString & szName) - : QObject(pParent) + : QObject(pParent), m_szName{szName}, m_pClass{pClass} { setObjectName(szName); @@ -643,27 +643,11 @@ KviKvsObject::KviKvsObject(KviKvsObjectClass * pClass, KviKvsObject * pParent, c m_hObject = (kvs_hobject_t)g_hNextObjectHandle; g_hNextObjectHandle++; - m_pObject = nullptr; - m_bObjectOwner = true; // true by default - - m_szName = szName; - - m_pClass = pClass; - m_pChildList = new KviPointerList<KviKvsObject>; m_pChildList->setAutoDelete(false); m_pDataContainer = new KviKvsHash(); - m_pFunctionHandlers = nullptr; // no local function handlers yet! - - m_bInDelayedDeath = false; - m_bDestructorCalled = false; - m_bAboutToDie = false; - - m_pSignalDict = nullptr; // no signals connected to remote slots - m_pConnectionList = nullptr; // no local slots connected to remote signals - if(pParent) pParent->registerChild(this); @@ -1200,7 +1184,7 @@ bool KviKvsObject::function_setProperty(KviKvsObjectFunctionCall * c) QMetaProperty prop = m_pObject->metaObject()->property(idx); const QMetaProperty * p = ∝ - if(!p) + if(!p->isValid()) { c->warning(__tr2qs_ctx("Can't find property named '%Q' for object named '%Q' of class '%Q': the property is indexed but it doesn't really exist", "kvs"), &szName, &m_szName, &(m_pClass->name())); return true; @@ -1460,7 +1444,7 @@ bool KviKvsObject::function_property(KviKvsObjectFunctionCall * c) } QMetaProperty prop = m_pObject->metaObject()->property(idx); const QMetaProperty * p = ∝ - if(!p) + if(!p->isValid()) { c->returnValue()->setNothing(); c->warning(__tr2qs_ctx("Can't find property named '%Q' for object named '%Q' of class '%Q': the property is indexed but it doesn't really exist", "kvs"), &szName, &m_szName, &(m_pClass->name())); diff --git a/src/kvirc/kvs/object/KviKvsObject.h b/src/kvirc/kvs/object/KviKvsObject.h index 12c701f5c..4b52a76de 100644 --- a/src/kvirc/kvs/object/KviKvsObject.h +++ b/src/kvirc/kvs/object/KviKvsObject.h @@ -36,13 +36,13 @@ class KviKvsObjectFunctionCall; -typedef struct _KviKvsObjectConnection +struct KviKvsObjectConnection { - KviKvsObject * pSourceObject; // source object (owner of the struct) - KviKvsObject * pTargetObject; // target object - QString szSignal; // source signal name - QString szSlot; // target slot function -} KviKvsObjectConnection; + KviKvsObject * pSourceObject = nullptr; // source object (owner of the struct) + KviKvsObject * pTargetObject = nullptr; // target object + QString szSignal; // source signal name + QString szSlot; // target slot function +}; typedef KviPointerList<KviKvsObjectConnection> KviKvsObjectConnectionList; typedef KviPointerListIterator<KviKvsObjectConnection> KviKvsObjectConnectionListIterator; @@ -54,49 +54,49 @@ class KVIRC_API KviKvsObject : public QObject Q_OBJECT public: KviKvsObject(KviKvsObjectClass * pClass, KviKvsObject * pParent, const QString & szName); - virtual ~KviKvsObject(); + ~KviKvsObject(); protected: // main data - QString m_szName; // object name - kvs_hobject_t m_hObject; // global object handle - KviKvsObjectClass * m_pClass; // the class definition + QString m_szName; // object name + kvs_hobject_t m_hObject; // global object handle + KviKvsObjectClass * m_pClass = nullptr; // the class definition - KviKvsHash * m_pDataContainer; // member variables + KviKvsHash * m_pDataContainer = nullptr; // member variables - KviPointerList<KviKvsObject> * m_pChildList; + KviPointerList<KviKvsObject> * m_pChildList = nullptr; - KviPointerHashTable<QString, KviKvsObjectFunctionHandler> * m_pFunctionHandlers; // our function handlers + KviPointerHashTable<QString, KviKvsObjectFunctionHandler> * m_pFunctionHandlers = nullptr; // our function handlers - KviPointerHashTable<QString, KviKvsObjectConnectionList> * m_pSignalDict; // our signals connected to other object functions + KviPointerHashTable<QString, KviKvsObjectConnectionList> * m_pSignalDict = nullptr; // our signals connected to other object functions - KviKvsObjectConnectionList * m_pConnectionList; // signals connected to this object functions + KviKvsObjectConnectionList * m_pConnectionList = nullptr; // signals connected to this object functions // this is valid when processing one of our slots kvs_hobject_t m_hSignalSender; QString m_szSignalName; // if this object wraps a qt one, it is here - QObject * m_pObject; - bool m_bObjectOwner; // do we have to destroy it ? + QObject * m_pObject = nullptr; + bool m_bObjectOwner = true; // do we have to destroy it ? // We're going to die soon after the control is given back to the event loop - bool m_bInDelayedDeath; + bool m_bInDelayedDeath = false; // We're going to die BEFORE the control is given back to the event loop - bool m_bAboutToDie; + bool m_bAboutToDie = false; // Did we already call the destructor ? - bool m_bDestructorCalled; + bool m_bDestructorCalled = false; public: - kvs_hobject_t handle() { return m_hObject; }; + kvs_hobject_t handle() { return m_hObject; } // the wrapped Qt object (may be 0!) - QObject * object() const { return m_pObject; }; + QObject * object() const { return m_pObject; } void setObject(QObject * o, bool bIsOwned = true); - const QString & getName() { return m_szName; }; + const QString & getName() const { return m_szName; } - KviKvsObject * parentObject() { return (KviKvsObject *)parent(); }; + KviKvsObject * parentObject() { return (KviKvsObject *)parent(); } QWidget * parentScriptWidget(); bool connectSignal(const QString & sigName, KviKvsObject * target, const QString & slotName); @@ -109,20 +109,20 @@ public: // this is intended to be called from other function calls (the parameters are copied from pOuterCall) // since we should NEVER emit totally spontaneous signals: all of them // should be generated inside object functions (either from scripting or by core calls) - int emitSignal(const QString & sigName, KviKvsObjectFunctionCall * pOuterCall, KviKvsVariantList * pParams = 0); + int emitSignal(const QString & sigName, KviKvsObjectFunctionCall * pOuterCall, KviKvsVariantList * pParams = nullptr); - void setSignalSender(kvs_hobject_t hObject) { m_hSignalSender = hObject; }; - kvs_hobject_t signalSender() { return m_hSignalSender; }; - void setSignalName(const QString & szSigName) { m_szSignalName = szSigName; }; + void setSignalSender(kvs_hobject_t hObject) { m_hSignalSender = hObject; } + kvs_hobject_t signalSender() { return m_hSignalSender; } + void setSignalName(const QString & szSigName) { m_szSignalName = szSigName; } - KviPointerHashTable<QString, KviKvsObjectFunctionHandler> * functionHandlers() { return m_pFunctionHandlers; }; + KviPointerHashTable<QString, KviKvsObjectFunctionHandler> * functionHandlers() { return m_pFunctionHandlers; } - KviKvsHash * dataContainer() { return m_pDataContainer; }; + KviKvsHash * dataContainer() { return m_pDataContainer; } bool die(); bool dieNow(); - KviKvsObjectClass * getExactClass() { return m_pClass; }; + KviKvsObjectClass * getExactClass() { return m_pClass; } KviKvsObjectClass * getClass(const QString & classOverride = QString()); bool inheritsClass(KviKvsObjectClass * pClass); bool inheritsClass(const QString & szClass); @@ -144,9 +144,9 @@ public: KviKvsVariant * pRetVal, // the return value KviKvsVariantList * pParams); // the parameters for the call // a nice and simple wrapper: it accepts a parameter list only (eventually 0) - bool callFunction(KviKvsObject * pCaller, const QString & fncName, KviKvsVariantList * pParams = 0); + bool callFunction(KviKvsObject * pCaller, const QString & fncName, KviKvsVariantList * pParams = nullptr); // this one gets a non null ret val too - bool callFunction(KviKvsObject * pCaller, const QString & fncName, KviKvsVariant * pRetVal, KviKvsVariantList * pParams = 0); + bool callFunction(KviKvsObject * pCaller, const QString & fncName, KviKvsVariant * pRetVal, KviKvsVariantList * pParams = nullptr); KviKvsObject * findChild(const QString & szClass, const QString & szName); void killAllChildrenWithClass(KviKvsObjectClass * cl); @@ -160,8 +160,8 @@ protected: void registerChild(KviKvsObject * c); void unregisterChild(KviKvsObject * c); - virtual bool eventFilter(QObject * o, QEvent * e); //necessary ? - virtual void timerEvent(QTimerEvent * e); + bool eventFilter(QObject * o, QEvent * e) override; //necessary ? + void timerEvent(QTimerEvent * e) override; protected: bool function_name(KviKvsObjectFunctionCall * c); diff --git a/src/kvirc/kvs/object/KviKvsObjectClass.cpp b/src/kvirc/kvs/object/KviKvsObjectClass.cpp index fae3d0733..b900689b6 100644 --- a/src/kvirc/kvs/object/KviKvsObjectClass.cpp +++ b/src/kvirc/kvs/object/KviKvsObjectClass.cpp @@ -193,15 +193,12 @@ bool KviKvsObjectClass::save(const QString & szFileName) { if(h->isScriptHandler() && !h->isClone()) { - QString reminder = h->reminder(); - KviQString::escapeKvs(&reminder); - szBuffer += " "; if(h->flags() & KviKvsObjectFunctionHandler::Internal) szBuffer += "internal "; szBuffer += "function "; szBuffer += it.currentKey(); - szBuffer += "(\"" + reminder + "\")\n"; + szBuffer += "(" + h->reminder() + ")\n"; QString szCode = h->scriptHandlerCode(); KviCommandFormatter::blockFromBuffer(szCode); KviCommandFormatter::indent(szCode); diff --git a/src/kvirc/kvs/object/KviKvsObjectController.h b/src/kvirc/kvs/object/KviKvsObjectController.h index d5de27f55..84e86f496 100644 --- a/src/kvirc/kvs/object/KviKvsObjectController.h +++ b/src/kvirc/kvs/object/KviKvsObjectController.h @@ -47,7 +47,7 @@ protected: KviPointerList<KviKvsObject> * m_pTopLevelObjectList; KviPointerHashTable<void *, KviKvsObject> * m_pObjectDict; KviPointerHashTable<QString, KviKvsObjectClass> * m_pClassDict; - KviKvsObjectClass * m_pObjectClass; //base class + KviKvsObjectClass * m_pObjectClass = nullptr; //base class protected: // the classes and the objects register themselves with the controller void registerObject(KviKvsObject * pObject); diff --git a/src/kvirc/kvs/parser/KviKvsParser.cpp b/src/kvirc/kvs/parser/KviKvsParser.cpp index 15d242273..556a510f7 100644 --- a/src/kvirc/kvs/parser/KviKvsParser.cpp +++ b/src/kvirc/kvs/parser/KviKvsParser.cpp @@ -35,9 +35,6 @@ KviKvsParser::KviKvsParser(KviKvsScript * pScript, KviWindow * pOutputWindow) { - // no need to initialize m_pBuffer - // no need to initialize m_ptr - // no need to initialize m_bError m_pGlobals = nullptr; m_pScript = pScript; m_pWindow = pOutputWindow; @@ -2919,10 +2916,10 @@ KviKvsTreeNodeDataList * KviKvsParser::parseCommaSeparatedParameterList() { \ QString szValue; \ \ - const QChar * pStart = KVSP_curCharPointer; \ + [[maybe_unused]] const QChar * pStart = KVSP_curCharPointer; \ const QChar * pBegin = KVSP_curCharPointer; \ int iLen = 0; \ - int iNestedTerminators = 0; \ + [[maybe_unused]] int iNestedTerminators = 0; \ \ for(;;) \ { \ @@ -3016,12 +3013,10 @@ KviKvsTreeNodeDataList * KviKvsParser::parseCommaSeparatedParameterList() } \ } \ KVSP_ASSERT(false); \ - return 0; \ + return nullptr; \ } LITERAL_PARAM_PARSING_FUNCTION_BEGIN(parseCommandLiteralParameter) -Q_UNUSED(pStart); -Q_UNUSED(iNestedTerminators); case 0: case '$': @@ -3036,8 +3031,6 @@ case '\t': LITERAL_PARAM_PARSING_FUNCTION_GENERIC_END LITERAL_PARAM_PARSING_FUNCTION_BEGIN(parseStringLiteralParameter) - Q_UNUSED(pStart); - Q_UNUSED(iNestedTerminators); case 0: case '$': @@ -3057,7 +3050,6 @@ LITERAL_PARAM_PARSING_FUNCTION_END */ LITERAL_PARAM_PARSING_FUNCTION_BEGIN(parseHashKeyLiteralParameter) - Q_UNUSED(pStart); case '{': LITERAL_PARAM_PARSING_FUNCTION_WARN_NESTED_TERMINATOR @@ -3075,7 +3067,6 @@ case ' ': LITERAL_PARAM_PARSING_FUNCTION_GENERIC_END LITERAL_PARAM_PARSING_FUNCTION_BEGIN(parseCommaSeparatedLiteralParameter) - Q_UNUSED(pStart); case '(': LITERAL_PARAM_PARSING_FUNCTION_WARN_NESTED_TERMINATOR @@ -3094,7 +3085,6 @@ case '\t': LITERAL_PARAM_PARSING_FUNCTION_GENERIC_END LITERAL_PARAM_PARSING_FUNCTION_BEGIN(parseSingleLiteralParameterInParenthesis) - Q_UNUSED(pStart); case '(': LITERAL_PARAM_PARSING_FUNCTION_WARN_NESTED_TERMINATOR @@ -3112,8 +3102,6 @@ case '\t': LITERAL_PARAM_PARSING_FUNCTION_GENERIC_END LITERAL_PARAM_PARSING_FUNCTION_BEGIN(parseBindingOperationLiteralParameter) - Q_UNUSED(pStart); - Q_UNUSED(iNestedTerminators); case 0: case '$': @@ -3143,13 +3131,13 @@ KviKvsTreeNodeData * KviKvsParser::parseArrayIndex() delete l; warning(pBegin,__tr2qs_ctx("Unterminated array index","kvs")); error(KVSP_curCharPointer,__tr2qs_ctx("Unexpected end of script in array index (missing ']' character?)","kvs")); - return 0; + return nullptr; break; case '\n': delete l; warning(pBegin,__tr2qs_ctx("Unterminated array index","kvs")); error(KVSP_curCharPointer,__tr2qs_ctx("Unexpected end of line in array index (missing ']' character or unescaped newline)","kvs")); - return 0; + return nullptr; break; case ' ': case '\t': @@ -3170,7 +3158,7 @@ KviKvsTreeNodeData * KviKvsParser::parseArrayIndex() error(KVSP_curCharPointer,__tr2qs_ctx("Unexpected character '%q' (Unicode %x) in array index: it should be already terminated","kvs"),KVSP_curCharPointer,KVSP_curCharUnicode); break; } - return 0; + return nullptr; } goto end_of_the_array_index; break; @@ -3183,7 +3171,7 @@ KviKvsTreeNodeData * KviKvsParser::parseArrayIndex() { // this is an error delete l; - return 0; + return nullptr; } l->append(p); } @@ -3202,7 +3190,7 @@ KviKvsTreeNodeData * KviKvsParser::parseArrayIndex() { // error delete l; - return 0; + return nullptr; } l->append(p); } diff --git a/src/kvirc/kvs/parser/KviKvsParser.h b/src/kvirc/kvs/parser/KviKvsParser.h index 4a0f162d1..e379d6af7 100644 --- a/src/kvirc/kvs/parser/KviKvsParser.h +++ b/src/kvirc/kvs/parser/KviKvsParser.h @@ -60,12 +60,12 @@ public: ~KviKvsParser(); private: - const QChar * m_pBuffer; // the local pointer to the beginning of the buffer - const QChar * m_ptr; // the parsing pointer + const QChar * m_pBuffer = nullptr; // the local pointer to the beginning of the buffer + const QChar * m_ptr = nullptr; // the parsing pointer // parsing state KviPointerHashTable<QString, QString> * m_pGlobals; // the dict of the vars declared with global in this script - int m_iFlags; // the current parsing flags - bool m_bError; // error(..) was called ? + int m_iFlags = 0; // the current parsing flags + bool m_bError = false; // error(..) was called ? // this stuff is used only for reporting errors and warnings KviKvsScript * m_pScript; // parent script KviWindow * m_pWindow; // output window @@ -103,31 +103,31 @@ protected: static void init(); private: - // returns 0 only in case of error + // returns nullptr only in case of error // starts on the first char of a buffer // stops at the first null char encountered KviKvsTreeNodeInstruction * parseInstructionList(); - // may return 0 (empty instruction), check error() for error conditions + // may return nullptr (empty instruction), check error() for error conditions // starts on the first character of an instruction - // if the first char is ';' '\n' or null it just returns 0 without error + // if the first char is ';' '\n' or null it just returns nullptr without error // stops after the ending char of the instruction KviKvsTreeNodeInstruction * parseInstruction(); - // may return 0 (empty block), check error() for error conditions + // may return nullptr (empty block), check error() for error conditions // starts at the leading '{' of the block // stops after the trailing '}' of the block KviKvsTreeNodeInstruction * parseInstructionBlock(); - // returns 0 only in case of error + // returns nullptr only in case of error // starts on the first character of the parameters // ends after the end of the command KviKvsTreeNodeDataList * parseCommandParameterList(); - // returns 0 only in case of error + // returns nullptr only in case of error // starts on the leading '(' or a ',' in the middle of the list // ends after the trailing ')' // if started in the middle of the list returns only the remaining // parameters. KviKvsTreeNodeDataList * parseCommaSeparatedParameterList(); KviPointerList<QString> * parseCommaSeparatedParameterListNoTree(); - // returns 0 in case of error or if it starts on a terminating character (null parameter) + // returns nullptr in case of error or if it starts on a terminating character (null parameter) // check error() to see if there was an error condition (unless you already know that // there was a valid first character) // start on the first character of the parameter @@ -136,105 +136,105 @@ private: // is extracted an attempt to convert it to a numeric format is made. // This optimizes assignments, self-sums etc... KviKvsTreeNodeData * parseCommandParameter(bool bPreferNumeric = false); - // returns 0 only in case of error + // returns nullptr only in case of error // start on the first character of the parameter // ends after the first character not included in the param (')','\n','\0',',') KviKvsTreeNodeData * parseCommaSeparatedParameter(); - // returns 0 only in case of error + // returns nullptr only in case of error // start on the first character of the parameter // ends after the first character not included in the param (')','\n','\0') KviKvsTreeNodeData * parseSingleParameterInParenthesis(); - // never returns 0 + // never returns nullptr KviKvsTreeNodeConstantData * parseCommandLiteralParameter(); - // never returns 0 + // never returns nullptr KviKvsTreeNodeConstantData * parseCommaSeparatedLiteralParameter(); - // never returns 0 + // never returns nullptr KviKvsTreeNodeConstantData * parseSingleLiteralParameterInParenthesis(); - // returns 0 only in case of error + // returns nullptr only in case of error // starts at the leading '"' // ends after the trailing '"' KviKvsTreeNodeData * parseStringParameter(); - // never returns 0 + // never returns nullptr KviKvsTreeNodeConstantData * parseStringLiteralParameter(); - // returns 0 in case of error or of an empty switch list (check the error code!) + // returns nullptr in case of error or of an empty switch list (check the error code!) // starts at the leading '-' of the first switch // ends after the last switch KviKvsTreeNodeSwitchList * parseCommandSwitchList(); - // returns 0 only in case of error + // returns nullptr only in case of error // starts at '%' or '$' // and ends after the end of the data reference // or just after the '%' or '$' if this was only a ConstandData (not a var or func) KviKvsTreeNodeData * parseParameterPercentOrDollar(); - // returns 0 only in case of error + // returns nullptr only in case of error // starts at '%' or '$' // ends after the end of the complete data reference (including scope operators!) KviKvsTreeNodeData * parsePercentOrDollar(bool bInObjScope = false); - // returns 0 only in case of error + // returns nullptr only in case of error // starts at '%' // ends after the end of the structured data KviKvsTreeNodeVariable * parsePercent(bool bInObjectScope = false); - // returns 0 only in case of error + // returns nullptr only in case of error KviKvsTreeNodeData * parseHashKey(); - // never returns 0 + // never returns nullptr KviKvsTreeNodeConstantData * parseHashKeyLiteralParameter(); // // KviKvsParser_specialCommands.cpp // - // return 0 only in case of error + // return nullptr only in case of error // starts at the leading '(' of the if command (after the switches) // and stops after the end of the else block // if the first character is not '(' then this function fails with an error KviKvsTreeNodeCommand * parseSpecialCommandIf(); - // always returns 0 + // always returns nullptr // check error() for error conditions // starts after the switches of the "global" keyword // and stops at the end of the command // if the first character is not '%' of a variable then this function fails with an error KviKvsTreeNodeCommand * parseSpecialCommandGlobal(); - // returns 0 only in case of error + // returns nullptr only in case of error // starts at the leading '(' of the while command (after the switches) // and stops after the end of the command block // if the first character is not '(' then this function fails with an error KviKvsTreeNodeCommand * parseSpecialCommandWhile(); - // returns 0 only in case of error + // returns nullptr only in case of error // starts at the leading '(' of the while command (after the switches) // and stops after the end of the command block // if the first character is not '(' then this function fails with an error KviKvsTreeNodeCommand * parseSpecialCommandDo(); - // returns 0 only in case of error + // returns nullptr only in case of error // and stops after the end of the break command KviKvsTreeNodeCommand * parseSpecialCommandBreak(); - // returns 0 only in case of error + // returns nullptr only in case of error // and jumps to the next iteration after the end of the continue command KviKvsTreeNodeCommand * parseSpecialCommandContinue(); - // returns 0 only in case of error + // returns nullptr only in case of error // and stops after the end of the for command block KviKvsTreeNodeCommand * parseSpecialCommandFor(); - // returns 0 only in case of error + // returns nullptr only in case of error // and stops after the end of the foreach command block KviKvsTreeNodeCommand * parseSpecialCommandForeach(); - // returns 0 only in case of error + // returns nullptr only in case of error // and stops after the end of the switch command block KviKvsTreeNodeCommand * parseSpecialCommandSwitch(); - // returns 0 only in case of error + // returns nullptr only in case of error // and stops after the end of the defpopup command block KviKvsTreeNodeCommand * parseSpecialCommandUnset(); - // returns 0 only in case of error + // returns nullptr only in case of error // and stops after the end of the defpopup command block KviKvsTreeNodeCommand * parseSpecialCommandDefpopup(); KviKvsTreeNodeSpecialCommandDefpopupLabelPopup * parseSpecialCommandDefpopupLabelPopup(); - // returns 0 only in case of error + // returns nullptr only in case of error // stops after the class command block KviKvsTreeNodeCommand * parseSpecialCommandClass(); - // returns 0 only in case of error + // returns nullptr only in case of error // stops after the perl.end statement KviKvsTreeNodeCommand * parseSpecialCommandPerlBegin(); - // returns 0 only in case of error + // returns nullptr only in case of error // stops after the perl.end statement KviKvsTreeNodeCommand * parseSpecialCommandPythonBegin(); - // returns 0 only in case of error + // returns nullptr only in case of error // and stops after the end of the help command KviKvsTreeNodeCommand * parseSpecialCommandHelp(); @@ -242,7 +242,7 @@ private: // KviKvsParser_command.cpp // - // may return 0 (empty command), check error() for error conditions + // may return nullptr (empty command), check error() for error conditions // starts at the beginning of a command (can be non valid) // ends after the ending char of the command KviKvsTreeNodeCommand * parseCommand(); @@ -251,7 +251,7 @@ private: // KviKvsParser_comment.cpp // - // always returns 0, and it CAN be an error! + // always returns nullptr, and it CAN be an error! // starts at the beginning of a comment (must be '#' or '/') // ends after the ending char of the comment KviKvsTreeNode * parseComment(); @@ -260,12 +260,12 @@ private: // KviKvsParser_dollar.cpp // - // returns 0 only in case of error + // returns nullptr only in case of error // starts at '$' // ends after the end of the function call KviKvsTreeNodeData * parseDollar(bool bInObjScope = false); - // returns 0 only in case of error + // returns nullptr only in case of error // starts at '@' // ends after the end of the function call KviKvsTreeNodeData * parseAt(bool bInObjScope = false); @@ -274,17 +274,17 @@ private: // KviKvsParser_lside.cpp // - // returns 0 only in case of error + // returns nullptr only in case of error // returns after the command terminator KviKvsTreeNodeInstruction * parseVoidFunctionCallOrOperation(); - // returns 0 only in case of error + // returns nullptr only in case of error // returns after the command terminator KviKvsTreeNodeOperation * parseOperation(); - // returns 0 only in case of error + // returns nullptr only in case of error // returns after the command terminator // If bPreferNumeric is propagated to parseCommandParameter() function KviKvsTreeNodeData * parseOperationRightSide(bool bPreferNumeric = false); - // return 0 only in case of error + // return nullptr only in case of error // returns after the command terminator KviKvsTreeNodeOperation * parseBindingOperation(); KviKvsTreeNodeConstantData * parseBindingOperationLiteralParameter(); @@ -294,7 +294,7 @@ private: // KviKvsParser_expression.cpp // - // returns 0 only in case of error + // returns nullptr only in case of error // starts AFTER the leading char of the expression // ends after the first terminator found KviKvsTreeNodeExpression * parseExpression(char terminator); diff --git a/src/kvirc/kvs/parser/KviKvsParser_command.cpp b/src/kvirc/kvs/parser/KviKvsParser_command.cpp index 34668ce21..74dc761a6 100644 --- a/src/kvirc/kvs/parser/KviKvsParser_command.cpp +++ b/src/kvirc/kvs/parser/KviKvsParser_command.cpp @@ -177,7 +177,7 @@ KviKvsTreeNodeCommand * KviKvsParser::parseCommand() // might be an error, but might be not... // it is an error only if error() returns true // but since the caller will take care of it - // we just return 0 + // we just return nullptr if(sw) delete sw; if(pRebindData) @@ -218,7 +218,7 @@ KviKvsTreeNodeCommand * KviKvsParser::parseCommand() // might be an error, but might be not... // it is an error only if error() returns true // but since the caller will take care of it - // we just return 0 + // we just return nullptr if(sw) delete sw; if(pRebindData) diff --git a/src/kvirc/kvs/parser/KviKvsParser_lside.cpp b/src/kvirc/kvs/parser/KviKvsParser_lside.cpp index fbff809b3..78459f170 100644 --- a/src/kvirc/kvs/parser/KviKvsParser_lside.cpp +++ b/src/kvirc/kvs/parser/KviKvsParser_lside.cpp @@ -627,6 +627,7 @@ KviKvsTreeNodeOperation * KviKvsParser::parseBindingOperation() { error(KVSP_curCharPointer, __tr2qs_ctx("Unexpected end of command in binding operation, at least one slash is missing", "kvs")); delete pFirst; + delete pSecond; return nullptr; } @@ -634,6 +635,7 @@ KviKvsTreeNodeOperation * KviKvsParser::parseBindingOperation() { error(KVSP_curCharPointer, __tr2qs_ctx("Found character '%q' (Unicode %x) where a slash '/' was expected", "kvs"), KVSP_curCharPointer, KVSP_curCharUnicode); delete pFirst; + delete pSecond; return nullptr; } @@ -897,11 +899,11 @@ KviKvsTreeNodeOperation * KviKvsParser::parseOperation() if(KVSP_curCharIsEndOfCommand) \ { \ error(KVSP_curCharPointer, __tr2qs_ctx("Missing right operand for operator '" __opstr "='", "kvs")); \ - return 0; \ + return nullptr; \ } \ KviKvsTreeNodeData * d = parseOperationRightSide(true); \ if(!d) \ - return 0; \ + return nullptr; \ return new __class(pBegin, d); \ break; \ } \ diff --git a/src/kvirc/kvs/parser/KviKvsParser_specialCommands.cpp b/src/kvirc/kvs/parser/KviKvsParser_specialCommands.cpp index 71f8bf98e..609ac1b11 100644 --- a/src/kvirc/kvs/parser/KviKvsParser_specialCommands.cpp +++ b/src/kvirc/kvs/parser/KviKvsParser_specialCommands.cpp @@ -54,7 +54,7 @@ python.begin <python code> python.end { \ dl = parseCommaSeparatedParameterList(); \ if(!dl) \ - return 0; \ + return nullptr; \ } \ else \ { \ @@ -67,7 +67,7 @@ python.begin <python code> python.end if(!skipSpacesAndNewlines()) \ { \ delete dl; \ - return 0; \ + return nullptr; \ } \ \ /* allow a ';' after [interpreter].begin */ \ @@ -77,7 +77,7 @@ python.begin <python code> python.end if(!skipSpacesAndNewlines()) \ { \ delete dl; \ - return 0; \ + return nullptr; \ } \ } \ \ @@ -102,7 +102,7 @@ python.begin <python code> python.end szErr += " statement"; \ \ error(KVSP_curCharPointer, __tr2qs_ctx(szErr.toUtf8().data(), "kvs")); \ - return 0; \ + return nullptr; \ } \ pInterpreterEnd = KVSP_curCharPointer; \ \ @@ -1812,7 +1812,7 @@ KviKvsTreeNodeSpecialCommandDefpopupLabelPopup * KviKvsParser::parseSpecialComma EXTRACT_POPUP_LABEL_CONDITION if(KVSP_curCharUnicode == ';') KVSP_skipChar; - QString * pItemName = pParameters ? pParameters->first() : nullptr; + QString * pItemName = pParameters->first(); pPopup->addLabel(new KviKvsTreeNodeSpecialCommandDefpopupLabelSeparator(pLabelBegin, szCondition, pItemName ? *pItemName : QString())); delete pParameters; } diff --git a/src/kvirc/kvs/tree/KviKvsTreeNodeAliasSimpleCommand.cpp b/src/kvirc/kvs/tree/KviKvsTreeNodeAliasSimpleCommand.cpp index a67932cba..af589c1fd 100644 --- a/src/kvirc/kvs/tree/KviKvsTreeNodeAliasSimpleCommand.cpp +++ b/src/kvirc/kvs/tree/KviKvsTreeNodeAliasSimpleCommand.cpp @@ -88,8 +88,6 @@ bool KviKvsTreeNodeAliasSimpleCommand::execute(KviKvsRunTimeContext * c) goto no_way_to_send_as_raw; szData = c->window()->connection()->encodeText(szAll); - if(!szData.data()) - szData = ""; if(!c->window()->connection()->sendData(szData.data())) goto no_way_to_send_as_raw; diff --git a/src/kvirc/kvs/tree/KviKvsTreeNodeExpression.cpp b/src/kvirc/kvs/tree/KviKvsTreeNodeExpression.cpp index ee541da7d..bd87977d2 100644 --- a/src/kvirc/kvs/tree/KviKvsTreeNodeExpression.cpp +++ b/src/kvirc/kvs/tree/KviKvsTreeNodeExpression.cpp @@ -25,7 +25,7 @@ #include "KviKvsTreeNodeExpression.h" #include "KviLocale.h" -#include <math.h> +#include <cmath> KviKvsTreeNodeExpression::KviKvsTreeNodeExpression(const QChar * pLocation) : KviKvsTreeNodeData(pLocation) diff --git a/src/kvirc/kvs/tree/KviKvsTreeNodeOperation.cpp b/src/kvirc/kvs/tree/KviKvsTreeNodeOperation.cpp index c9b383d68..c8191ca01 100644 --- a/src/kvirc/kvs/tree/KviKvsTreeNodeOperation.cpp +++ b/src/kvirc/kvs/tree/KviKvsTreeNodeOperation.cpp @@ -29,12 +29,11 @@ #include <QRegExp> -#include <math.h> +#include <cmath> KviKvsTreeNodeOperation::KviKvsTreeNodeOperation(const QChar * pLocation) : KviKvsTreeNodeInstruction(pLocation) { - //m_pTargetData = 0; no need to set it } KviKvsTreeNodeOperation::~KviKvsTreeNodeOperation() diff --git a/src/kvirc/kvs/tree/KviKvsTreeNodeOperation.h b/src/kvirc/kvs/tree/KviKvsTreeNodeOperation.h index 93c40d5b2..bbcc97ac1 100644 --- a/src/kvirc/kvs/tree/KviKvsTreeNodeOperation.h +++ b/src/kvirc/kvs/tree/KviKvsTreeNodeOperation.h @@ -38,7 +38,7 @@ public: ~KviKvsTreeNodeOperation(); protected: - KviKvsTreeNodeData * m_pTargetData; // can't be null + KviKvsTreeNodeData * m_pTargetData = nullptr; // can't be null public: void setTargetVariableReference(KviKvsTreeNodeData * r); virtual void contextDescription(QString & szBuffer); diff --git a/src/kvirc/kvs/tree/KviKvsTreeNodeSpecialCommandDefpopup.cpp b/src/kvirc/kvs/tree/KviKvsTreeNodeSpecialCommandDefpopup.cpp index 45468925f..f9b829855 100644 --- a/src/kvirc/kvs/tree/KviKvsTreeNodeSpecialCommandDefpopup.cpp +++ b/src/kvirc/kvs/tree/KviKvsTreeNodeSpecialCommandDefpopup.cpp @@ -33,7 +33,7 @@ void KviKvsTreeNodeSpecialCommandDefpopupLabelExtpopup::contextDescription(QString & szBuffer) { - szBuffer = "Label \"extpopup\" for Special Command \"defpopup\""; + szBuffer = R"(Label "extpopup" for Special Command "defpopup")"; } void KviKvsTreeNodeSpecialCommandDefpopupLabelExtpopup::dump(const char * prefix) @@ -67,7 +67,7 @@ bool KviKvsTreeNodeSpecialCommandDefpopupLabelExtpopup::execute(KviKvsRunTimeCon void KviKvsTreeNodeSpecialCommandDefpopupLabelItem::contextDescription(QString & szBuffer) { - szBuffer = "Label \"item\" for Special Command \"defpopup\""; + szBuffer = R"(Label "item" for Special Command "defpopup")"; } void KviKvsTreeNodeSpecialCommandDefpopupLabelItem::dump(const char * prefix) @@ -101,7 +101,7 @@ bool KviKvsTreeNodeSpecialCommandDefpopupLabelItem::execute(KviKvsRunTimeContext void KviKvsTreeNodeSpecialCommandDefpopupLabelLabel::contextDescription(QString & szBuffer) { - szBuffer = "Label \"label\" for Special Command \"defpopup\""; + szBuffer = R"(Label "label" for Special Command "defpopup")"; } void KviKvsTreeNodeSpecialCommandDefpopupLabelLabel::dump(const char * prefix) @@ -131,7 +131,7 @@ bool KviKvsTreeNodeSpecialCommandDefpopupLabelLabel::execute(KviKvsRunTimeContex void KviKvsTreeNodeSpecialCommandDefpopupLabelSeparator::contextDescription(QString & szBuffer) { - szBuffer = "Label \"separator\" for Special Command \"defpopup\""; + szBuffer = R"(Label "separator" for Special Command "defpopup")"; } void KviKvsTreeNodeSpecialCommandDefpopupLabelSeparator::dump(const char * prefix) @@ -151,7 +151,7 @@ bool KviKvsTreeNodeSpecialCommandDefpopupLabelSeparator::execute(KviKvsRunTimeCo void KviKvsTreeNodeSpecialCommandDefpopupLabelEpilogue::contextDescription(QString & szBuffer) { - szBuffer = "Label \"epilogue\" for Special Command \"defpopup\""; + szBuffer = R"(Label "epilogue" for Special Command "defpopup")"; } void KviKvsTreeNodeSpecialCommandDefpopupLabelEpilogue::dump(const char * prefix) @@ -171,7 +171,7 @@ bool KviKvsTreeNodeSpecialCommandDefpopupLabelEpilogue::execute(KviKvsRunTimeCon void KviKvsTreeNodeSpecialCommandDefpopupLabelPrologue::contextDescription(QString & szBuffer) { - szBuffer = "Label \"prologue\" for Special Command \"defpopup\""; + szBuffer = R"(Label "prologue" for Special Command "defpopup")"; } void KviKvsTreeNodeSpecialCommandDefpopupLabelPrologue::dump(const char * prefix) @@ -203,7 +203,7 @@ KviKvsTreeNodeSpecialCommandDefpopupLabelPopup::~KviKvsTreeNodeSpecialCommandDef void KviKvsTreeNodeSpecialCommandDefpopupLabelPopup::contextDescription(QString & szBuffer) { - szBuffer = "Label \"popup\" for Special Command \"defpopup\""; + szBuffer = R"(Label "popup" for Special Command "defpopup")"; } void KviKvsTreeNodeSpecialCommandDefpopupLabelPopup::dump(const char * prefix) diff --git a/src/kvirc/kvs/tree/KviKvsTreeNodeSpecialCommandSwitch.cpp b/src/kvirc/kvs/tree/KviKvsTreeNodeSpecialCommandSwitch.cpp index c8946414a..f9afc3c64 100644 --- a/src/kvirc/kvs/tree/KviKvsTreeNodeSpecialCommandSwitch.cpp +++ b/src/kvirc/kvs/tree/KviKvsTreeNodeSpecialCommandSwitch.cpp @@ -74,7 +74,7 @@ KviKvsTreeNodeSpecialCommandSwitchLabelCase::~KviKvsTreeNodeSpecialCommandSwitch void KviKvsTreeNodeSpecialCommandSwitchLabelCase::contextDescription(QString & szBuffer) { - szBuffer = "Label \"case\" for Special Command \"switch\""; + szBuffer = R"(Label "case" for Special Command "switch")"; } void KviKvsTreeNodeSpecialCommandSwitchLabelCase::dump(const char * prefix) @@ -168,7 +168,7 @@ KviKvsTreeNodeSpecialCommandSwitchLabelMatch::~KviKvsTreeNodeSpecialCommandSwitc void KviKvsTreeNodeSpecialCommandSwitchLabelMatch::contextDescription(QString & szBuffer) { - szBuffer = "Label \"match\" for Special Command \"switch\""; + szBuffer = R"(Label "match" for Special Command "switch")"; } void KviKvsTreeNodeSpecialCommandSwitchLabelMatch::dump(const char * prefix) @@ -227,7 +227,7 @@ KviKvsTreeNodeSpecialCommandSwitchLabelRegexp::~KviKvsTreeNodeSpecialCommandSwit void KviKvsTreeNodeSpecialCommandSwitchLabelRegexp::contextDescription(QString & szBuffer) { - szBuffer = "Label \"regexp\" for Special Command \"switch\""; + szBuffer = R"(Label "regexp" for Special Command "switch")"; } void KviKvsTreeNodeSpecialCommandSwitchLabelRegexp::dump(const char * prefix) @@ -286,7 +286,7 @@ KviKvsTreeNodeSpecialCommandSwitchLabelDefault::~KviKvsTreeNodeSpecialCommandSwi void KviKvsTreeNodeSpecialCommandSwitchLabelDefault::contextDescription(QString & szBuffer) { - szBuffer = "Label \"default\" for Special Command \"switch\""; + szBuffer = R"(Label "default" for Special Command "switch")"; } void KviKvsTreeNodeSpecialCommandSwitchLabelDefault::dump(const char * prefix) diff --git a/src/kvirc/kvs/tree/KviKvsTreeNodeThisObjectFunctionCall.cpp b/src/kvirc/kvs/tree/KviKvsTreeNodeThisObjectFunctionCall.cpp index 1cac36ac8..3ef2e56f6 100644 --- a/src/kvirc/kvs/tree/KviKvsTreeNodeThisObjectFunctionCall.cpp +++ b/src/kvirc/kvs/tree/KviKvsTreeNodeThisObjectFunctionCall.cpp @@ -35,7 +35,7 @@ KviKvsTreeNodeThisObjectFunctionCall::~KviKvsTreeNodeThisObjectFunctionCall() void KviKvsTreeNodeThisObjectFunctionCall::contextDescription(QString & szBuffer) { - szBuffer = "\"This\" Object Function Call \""; + szBuffer = R"("This" Object Function Call ")"; szBuffer += m_szFunctionName; szBuffer += "\""; } diff --git a/src/kvirc/module/KviModule.cpp b/src/kvirc/module/KviModule.cpp index de2e7e46e..8d381cde8 100644 --- a/src/kvirc/module/KviModule.cpp +++ b/src/kvirc/module/KviModule.cpp @@ -33,7 +33,7 @@ #include <QLibrary> -#include <time.h> +#include <ctime> #ifdef COMPILE_CRYPT_SUPPORT #include "KviCryptEngine.h" diff --git a/src/kvirc/module/KviModule.h b/src/kvirc/module/KviModule.h index e624fa4c3..245c5c96f 100644 --- a/src/kvirc/module/KviModule.h +++ b/src/kvirc/module/KviModule.h @@ -59,7 +59,7 @@ class QLibrary; typedef bool (*KviModuleSystemRoutine)(KviModule *); typedef bool (*KviModuleCtrlRoutine)(KviModule *, const char *, void *); -typedef struct _KviModuleInfo +struct KviModuleInfo { const char * szKVIrcVersion; // must match KVI_VERSION if module version checking is in force const char * szModuleName; // module name @@ -99,7 +99,7 @@ typedef struct _KviModuleInfo * so better cleanup everything here :) */ KviModuleSystemRoutine cleanup_routine; // WARNING : g_pApp may be in the destructor and may have no frames open! -} KviModuleInfo; +}; // NOTE: The init and cleanup routines should NEVER rely on g_pApp existing! // so only "initialization and cleanup INTERNAL to the module" goes there! diff --git a/src/kvirc/module/KviModuleExtension.h b/src/kvirc/module/KviModuleExtension.h index 1eef5533b..026e7da47 100644 --- a/src/kvirc/module/KviModuleExtension.h +++ b/src/kvirc/module/KviModuleExtension.h @@ -38,13 +38,13 @@ class KviModuleExtensionDescriptor; class KviWindow; class QPixmap; -typedef struct _KviModuleExtensionAllocStructTag +struct KviModuleExtensionAllocStruct { KviModuleExtensionDescriptor * pDescriptor; // module extension that this alloc routine refers to KviWindow * pWindow; // may be 0! KviPointerHashTable<QString, QVariant> * pParams; // parameter dict (may be 0!) void * pSpecial; // special parameter passed to the alloc routine, may be 0 -} KviModuleExtensionAllocStruct; +}; typedef KviModuleExtension * (*KviModuleExtensionAllocRoutine)(KviModuleExtensionAllocStruct *); @@ -73,7 +73,7 @@ private: KviModule * m_pModule; // module pointer public: // pParams ownership is NOT taken - KviModuleExtension * allocate(KviWindow * pWnd = 0, KviPointerHashTable<QString, QVariant> * pParams = 0, void * pSpecial = 0); + KviModuleExtension * allocate(KviWindow * pWnd = nullptr, KviPointerHashTable<QString, QVariant> * pParams = nullptr, void * pSpecial = nullptr); int id() { return m_iId; }; KviModule * module() { return m_pModule; }; @@ -122,8 +122,8 @@ public: KviModuleExtensionDescriptor * findExtensionDescriptor(const KviCString & szType, const KviCString & szName); static KviModuleExtensionManager * instance() { return g_pModuleExtensionManager; }; KviModuleExtensionDescriptorList * getExtensionList(const KviCString & szType); - KviModuleExtension * allocateExtension(const KviCString & szType, const KviCString & szName, KviWindow * pWnd = 0, KviPointerHashTable<QString, QVariant> * pParams = 0, void * pSpecial = 0, const QString & preloadModule = QString()); - KviModuleExtension * allocateExtension(const KviCString & szType, int id, KviWindow * pWnd = 0, KviPointerHashTable<QString, QVariant> * pParams = 0, void * pSpecial = 0, const QString & preloadModule = QString()); + KviModuleExtension * allocateExtension(const KviCString & szType, const KviCString & szName, KviWindow * pWnd = nullptr, KviPointerHashTable<QString, QVariant> * pParams = nullptr, void * pSpecial = nullptr, const QString & preloadModule = QString()); + KviModuleExtension * allocateExtension(const KviCString & szType, int id, KviWindow * pWnd = nullptr, KviPointerHashTable<QString, QVariant> * pParams = nullptr, void * pSpecial = nullptr, const QString & preloadModule = QString()); private: KviModuleExtensionDescriptorList * allocateExtensionGetDescriptorList(const KviCString & szType, const QString & preloadModule); diff --git a/src/kvirc/module/KviModuleManager.cpp b/src/kvirc/module/KviModuleManager.cpp index bf984685f..37cee0b83 100644 --- a/src/kvirc/module/KviModuleManager.cpp +++ b/src/kvirc/module/KviModuleManager.cpp @@ -265,7 +265,7 @@ bool KviModuleManager::loadModule(const QString & modName) if(g_pMainWindow) { KviConsoleWindow * pWnd = g_pMainWindow->firstConsole(); - if(pWnd) // this may be NULL when the app is starting up + if(pWnd) // this may be nullptr when the app is starting up pWnd->output( KVI_OUT_VERBOSE, __tr2qs("Loaded module '%s' (%s)"), diff --git a/src/kvirc/sparser/KviAntiSpam.cpp b/src/kvirc/sparser/KviAntiSpam.cpp index 3877b2f0f..abf9f7e82 100644 --- a/src/kvirc/sparser/KviAntiSpam.cpp +++ b/src/kvirc/sparser/KviAntiSpam.cpp @@ -71,8 +71,9 @@ bool kvi_mayBeSpam(KviCString msg, KviCString & spamWord) for(auto & it : KVI_OPTION_STRINGLIST(KviOption_stringlistSpamWords)) { // FIXME : This is SLOOOOOOOOW (QString -> ascii translation!!) - const char * aux = it.toLatin1(); - if(aux) + QByteArray szLatin1 = it.toLatin1(); + const char * aux = szLatin1.data(); + if(*aux) { if(msg.findFirstIdx(aux, false) != -1) { diff --git a/src/kvirc/sparser/KviIrcMessage.cpp b/src/kvirc/sparser/KviIrcMessage.cpp index e5d8eea9a..49102ee78 100644 --- a/src/kvirc/sparser/KviIrcMessage.cpp +++ b/src/kvirc/sparser/KviIrcMessage.cpp @@ -72,7 +72,7 @@ KviIrcMessage::KviIrcMessage(const char * message, KviIrcConnection * pConnectio if(*m_ptr == ':') { ++m_ptr; - m_pParams.push_back(KviCString(m_ptr)); + m_pParams.emplace_back(m_ptr); break; // this was the last } else @@ -80,7 +80,7 @@ KviIrcMessage::KviIrcMessage(const char * message, KviIrcConnection * pConnectio aux = m_ptr; while(*m_ptr && (*m_ptr != ' ')) ++m_ptr; - m_pParams.push_back(KviCString(aux, m_ptr)); + m_pParams.emplace_back(aux, m_ptr); while(*m_ptr == ' ') ++m_ptr; } @@ -122,8 +122,7 @@ KviIrcMessage::KviIrcMessage(const char * message, KviIrcConnection * pConnectio } KviIrcMessage::~KviIrcMessage() -{ -} + = default; void KviIrcMessage::decodeAndSplitMask(char * b, QString & szNick, QString & szUser, QString & szHost) { diff --git a/src/kvirc/sparser/KviIrcNumericCodes.h b/src/kvirc/sparser/KviIrcNumericCodes.h index e88b428fc..2641ebb1d 100644 --- a/src/kvirc/sparser/KviIrcNumericCodes.h +++ b/src/kvirc/sparser/KviIrcNumericCodes.h @@ -389,7 +389,7 @@ #define RPL_SPAMFILTERLIST 941 // <nick> <channel> <spamfilter> ///* 303 */ RPL_ISON, ":", -///* 304 */ RPL_TEXT, (char *)NULL, +///* 304 */ RPL_TEXT, (char *)nullptr, ///* 305 */ RPL_UNAWAY, ":You are no longer marked as being away", ///* 306 */ RPL_NOWAWAY, ":You have been marked as being away", @@ -398,11 +398,11 @@ ///* 323 */ RPL_LISTEND, ":End of /LIST", ///* 324 */ RPL_CHANNELMODEIS, "%???" -///* 334 */ 0, (char *)NULL, +///* 334 */ 0, (char *)nullptr, ///* 341 */ RPL_INVITING, "%s %s", ///* 342 */ RPL_SUMMONING, "%s :User summoned to irc", ///* 352 */ RPL_WHOREPLY, , -///* 361 */ RPL_KILLDONE, (char *)NULL, +///* 361 */ RPL_KILLDONE, (char *)nullptr, ///* 362 */ RPL_CLOSING, "%s :Closed. Status = %d", ///* 363 */ RPL_CLOSEEND, "%d: Connections Closed", ///* 364 */ RPL_LINKS, "%s %s :%d %s", @@ -413,9 +413,9 @@ ///* 369 */ RPL_ENDOFWHOWAS, "%s :End of WHOWAS", ///* 381 */ RPL_YOUREOPER, ":You have entered... the Twilight Zone!.", ///* 382 */ RPL_REHASHING, "%s :Rehashing", -///* 383 */ 0, (char *)NULL, +///* 383 */ 0, (char *)nullptr, ///* 384 */ RPL_MYPORTIS, "%d :Port to local server is\r\n", -///* 385 */ RPL_NOTOPERANYMORE, (char *)NULL, +///* 385 */ RPL_NOTOPERANYMORE, (char *)nullptr, ///* 391 */ RPL_TIME, "%s :%s", ///* 392 */ RPL_USERSSTART, ":UserID Terminal Host", ///* 393 */ RPL_USERS, ":%-8s %-9s %-8s", @@ -431,11 +431,11 @@ ///* 223 */ RPL_STATSELINE, "%c %s * %s %d %d", ///* 224 */ RPL_STATSFLINE, "%c %s * %s %d %d", ///* 225 */ RPL_STATSDLINE, "%c %s %s", -///* 231 */ 0, (char *)NULL, -///* 232 */ 0, (char *)NULL, -///* 233 */ 0, (char *)NULL, -///* 234 */ RPL_SERVLIST, (char *)NULL, -///* 235 */ RPL_SERVLISTEND, (char *)NULL, +///* 231 */ 0, (char *)nullptr, +///* 232 */ 0, (char *)nullptr, +///* 233 */ 0, (char *)nullptr, +///* 234 */ RPL_SERVLIST, (char *)nullptr, +///* 235 */ RPL_SERVLISTEND, (char *)nullptr, ///* 241 */ RPL_STATSLLINE, "%c %s * %s %d %d", ///* 242 */ RPL_STATSUPTIME, ":Server Up %d days, %d:%02d:%02d", ///* 243 */ RPL_STATSOLINE, "%c %s * %s %d %d", diff --git a/src/kvirc/sparser/KviIrcServerParser.h b/src/kvirc/sparser/KviIrcServerParser.h index f07e5eca6..42b436b29 100644 --- a/src/kvirc/sparser/KviIrcServerParser.h +++ b/src/kvirc/sparser/KviIrcServerParser.h @@ -48,15 +48,15 @@ class QByteArray; typedef void (KviIrcServerParser::*messageParseProc)(KviIrcMessage *); -typedef struct _KviLiteralMessageParseStruct +struct KviLiteralMessageParseStruct { const char * msgName; messageParseProc proc; -} KviLiteralMessageParseStruct; +}; class KviIrcMask; -typedef struct _KviCtcpMessage +struct KviCtcpMessage { KviIrcMessage * msg; const char * pData; @@ -67,9 +67,9 @@ typedef struct _KviCtcpMessage bool bUnknown; QString szTag; -} KviCtcpMessage; +}; -typedef struct _KviDccRequest +struct KviDccRequest { KviCString szType; KviCString szParam1; @@ -80,19 +80,19 @@ typedef struct _KviDccRequest bool bIPv6; KviCtcpMessage * ctcpMsg; KviConsoleWindow * pConsole; -} KviDccRequest; +}; typedef void (KviIrcServerParser::*ctcpParseProc)(KviCtcpMessage *); #define KVI_CTCP_MESSAGE_PARSE_TRIGGERNOEVENT 1 -typedef struct _KviCtcpMessageParseStruct +struct KviCtcpMessageParseStruct { const char * msgName; ctcpParseProc req; ctcpParseProc rpl; int iFlags; -} KviCtcpMessageParseStruct; +}; #define EXTERNAL_SERVER_DATA_PARSER_CONTROL_RESET 0 #define EXTERNAL_SERVER_DATA_PARSER_CONTROL_STARTOFDATA 1 diff --git a/src/kvirc/sparser/KviIrcServerParser_ctcp.cpp b/src/kvirc/sparser/KviIrcServerParser_ctcp.cpp index 180182752..eb8c0fd75 100644 --- a/src/kvirc/sparser/KviIrcServerParser_ctcp.cpp +++ b/src/kvirc/sparser/KviIrcServerParser_ctcp.cpp @@ -62,7 +62,7 @@ #include "KviCryptController.h" #endif //COMPILE_CRYPT_SUPPORT -#include <stdlib.h> +#include <cstdlib> #include <QDateTime> #include <QLocale> @@ -363,14 +363,14 @@ extern KVIRC_API KviCtcpPageDialog * g_pCtcpPageDialog; The DCC tag is used to initiate a Direct Client Connection. The known DCC types are:[br] [pre] - CHAT[br] - SEND[br] - SSEND[br] - TSEND[br] - GET[br] - TGET[br] - ACCEPT[br] - RESUME[br] + CHAT + SEND + SSEND + TSEND + GET + TGET + ACCEPT + RESUME [/pre] */ @@ -1112,7 +1112,7 @@ void KviIrcServerParser::parseCtcpReplyPing(KviCtcpMessage * msg) KviCString szTime; struct timeval tv; - kvi_gettimeofday(&tv, nullptr); + kvi_gettimeofday(&tv); msg->pData = extractCtcpParameter(msg->pData, szTime, true); @@ -1872,7 +1872,7 @@ void KviIrcServerParser::parseCtcpReplyAvatar(KviCtcpMessage * msg) msg->msg->haltOutput() ? QString() : textLine); } -typedef void (*dccModuleCtcpDccParseRoutine)(KviDccRequest * par); +using dccModuleCtcpDccParseRoutine = void (*)(KviDccRequest *); void KviIrcServerParser::parseCtcpRequestDcc(KviCtcpMessage * msg) { diff --git a/src/kvirc/sparser/KviIrcServerParser_literalHandlers.cpp b/src/kvirc/sparser/KviIrcServerParser_literalHandlers.cpp index ddad13d3a..aa1363f53 100644 --- a/src/kvirc/sparser/KviIrcServerParser_literalHandlers.cpp +++ b/src/kvirc/sparser/KviIrcServerParser_literalHandlers.cpp @@ -852,6 +852,15 @@ void KviIrcServerParser::parseLiteralPrivmsg(KviIrcMessage * msg) QString szSourceNick, szSourceUser, szSourceHost; msg->decodeAndSplitPrefix(szSourceNick, szSourceUser, szSourceHost); + // update the user entry in the database right away + KviIrcUserDataBase * db = msg->connection()->userDataBase(); + KviIrcUserEntry * e = db->find(szSourceNick); + if (e) + { + e->setUser(szSourceUser); + e->setHost(szSourceHost); + } + QString szTarget = msg->connection()->decodeText(msg->safeParam(0)); QString szMsg = msg->connection()->decodeText(msg->safeTrailing()); @@ -909,9 +918,21 @@ void KviIrcServerParser::parseLiteralPrivmsg(KviIrcMessage * msg) } } - // Normal PRIVMSG + QString szOriginalTarget = szTarget; + QString szPrefixes; + + // check if the channel has some leading mode prefixes + while((szTarget.length() > 0) && console->connection()->serverInfo()->supportedStatusMsgPrefixes().contains(szTarget[0])) + { + szPrefixes += szTarget[0]; + szTarget.remove(0, 1); + } + + // Query PRIVMSG if(msg->connection()->serverInfo()->supportedChannelTypes().indexOf(szTarget[0]) == -1) { + szTarget = szOriginalTarget; + //Ignore it? if(uSource) { @@ -1143,9 +1164,6 @@ void KviIrcServerParser::parseLiteralPrivmsg(KviIrcMessage * msg) // Channel PRIVMSG KviChannelWindow * chan = msg->connection()->findChannel(szTarget); - QString szOriginalTarget = szTarget; - QString szPrefixes; - //Ignore it? if(uSource) { @@ -1164,17 +1182,6 @@ void KviIrcServerParser::parseLiteralPrivmsg(KviIrcMessage * msg) if(!chan) { - // check if the channel has some leading mode prefixes - while((szTarget.length() > 0) && console->connection()->serverInfo()->isSupportedModePrefix(szTarget[0].unicode())) - { - szPrefixes += szTarget[0]; - szTarget.remove(0, 1); - } - chan = msg->connection()->findChannel(szTarget); - } - - if(!chan) - { if(!msg->haltOutput()) { QString szMsgText = msg->connection()->decodeText(msg->safeTrailing()); @@ -1236,6 +1243,15 @@ void KviIrcServerParser::parseLiteralNotice(KviIrcMessage * msg) if(szHost == "*" && szUser == "*" && szNick.indexOf('.') != -1) bIsServerNotice = true; + // update the user entry in the database right away + KviIrcUserDataBase * db = msg->connection()->userDataBase(); + KviIrcUserEntry * e = db->find(szNick); + if (e) + { + e->setUser(szUser); + e->setHost(szHost); + } + // FIXME: "DEDICATED CTCP WINDOW ?" KviCString pTrailing = msg->trailingString(); @@ -1572,7 +1588,7 @@ void KviIrcServerParser::parseLiteralNotice(KviIrcMessage * msg) if(!chan) { // check if the channel has some leading mode prefixes - while((szTarget.length() > 0) && console->connection()->serverInfo()->isSupportedModePrefix(szTarget[0].unicode())) + while((szTarget.length() > 0) && console->connection()->serverInfo()->supportedStatusMsgPrefixes().contains(szTarget[0])) { szPrefixes += szTarget[0]; szTarget.remove(0, 1); @@ -1690,7 +1706,7 @@ void KviIrcServerParser::parseLiteralTopic(KviIrcMessage * msg) const char * txtptr; int msgtype; - DECRYPT_IF_NEEDED(chan, msg->safeTrailing(), KVI_OUT_QUERYPRIVMSG, KVI_OUT_QUERYPRIVMSGCRYPTED, szBuffer, txtptr, msgtype) + DECRYPT_IF_NEEDED(chan, msg->safeTrailing(), KVI_OUT_TOPIC, KVI_OUT_TOPICCRYPTED, szBuffer, txtptr, msgtype) QString szTopic = chan->decodeText(txtptr); @@ -1722,7 +1738,7 @@ void KviIrcServerParser::parseLiteralTopic(KviIrcMessage * msg) if(!msg->haltOutput()) { - chan->output(KVI_OUT_TOPIC, + chan->output(msgtype, __tr2qs("\r!n\r%Q\r [%Q@\r!h\r%Q\r] has changed topic to \"%Q%c\""), &szNick, &szUser, &szHost, &szTopic, KviControlCodes::Reset); } @@ -1857,6 +1873,15 @@ void KviIrcServerParser::parseLiteralInvite(KviIrcMessage * msg) QString szNick, szUser, szHost; msg->decodeAndSplitPrefix(szNick, szUser, szHost); + // update the user entry in the database right away + KviIrcUserDataBase * db = msg->connection()->userDataBase(); + KviIrcUserEntry * e = db->find(szNick); + if (e) + { + e->setUser(szUser); + e->setHost(szHost); + } + QString szTarget = msg->connection()->decodeText(msg->safeParam(0)); QString szChannel = msg->connection()->decodeText(msg->safeParam(1)); @@ -1997,7 +2022,6 @@ void KviIrcServerParser::parseChannelMode(const QString & szNick, const QString { bool bSet = true; - bool bIsMultiMode = false; bool bIsMultiSingleMode = false; bool bShowAsCompact = false; @@ -2061,7 +2085,6 @@ void KviIrcServerParser::parseChannelMode(const QString & szNick, const QString if(iTotModes > 1) { - bIsMultiMode = true; bShowAsCompact = KVI_OPTION_BOOL(KviOption_boolShowCompactModeChanges); if(iSingleModes == 1) diff --git a/src/kvirc/sparser/KviIrcServerParser_numericHandlers.cpp b/src/kvirc/sparser/KviIrcServerParser_numericHandlers.cpp index a53e4df67..968ab5704 100644 --- a/src/kvirc/sparser/KviIrcServerParser_numericHandlers.cpp +++ b/src/kvirc/sparser/KviIrcServerParser_numericHandlers.cpp @@ -246,7 +246,6 @@ void KviIrcServerParser::parseNumeric005(KviIrcMessage * msg) * MAXLIST -> Maximum number entries in the list per mode (e.g. MAXLIST=beI:30) * WALLCHOPS -> The server supports messaging channel operators (deprecated by STATUSMSG, e.g. usage: NOTICE @#channel) * WALLVOICES -> The server supports messaging channel voiced users (deprecated by STATUSMSG, e.g. usage: NOTICE +#channel) - * STATUSMSG -> The server supports messaging a particular class of channel users (e.g. STATUSMSG=+@) * CASEMAPPING -> Case mapping used for nick- and channel name comparing (e.g. CASEMAPPING=rfc1459) * ELIST -> search extensions to list modes, like mask search, topic search, creation time search (e.g. ELIST=MNUCT) * KICKLEN -> Maximum kick comment length (e.g. KICKLEN=80) @@ -284,6 +283,13 @@ void KviIrcServerParser::parseNumeric005(KviIrcMessage * msg) if(szModePrefixes.hasData() && (szModePrefixes.len() == szModeFlags.len())) msg->connection()->serverInfo()->setSupportedModePrefixes(szModePrefixes.ptr(), szModeFlags.ptr()); } + else if(kvi_strEqualCIN("STATUSMSG=", p, 10)) + { + p += 10; + KviCString tmp = p; + if(tmp.hasData()) + msg->connection()->serverInfo()->setSupportedStatusMsgPrefixes(tmp.ptr()); + } else if(kvi_strEqualCIN("CHANTYPES=", p, 10)) { p += 10; @@ -529,7 +535,6 @@ void KviIrcServerParser::parseNumericNames(KviIrcMessage * msg) mask.hasUser() ? mask.user() : QString(), mask.hasHost() ? mask.host() : QString(), iFlags); - *aux = ' '; *aux = save; // run to the next nick (or the end) while((*aux) && (*aux == ' ')) @@ -607,14 +612,14 @@ void KviIrcServerParser::parseNumericTopic(KviIrcMessage * msg) const char * txtptr; int msgtype; - DECRYPT_IF_NEEDED(chan, msg->safeTrailing(), KVI_OUT_QUERYPRIVMSG, KVI_OUT_QUERYPRIVMSGCRYPTED, szBuffer, txtptr, msgtype) + DECRYPT_IF_NEEDED(chan, msg->safeTrailing(), KVI_OUT_TOPIC, KVI_OUT_TOPICCRYPTED, szBuffer, txtptr, msgtype) QString szTopic = chan->decodeText(txtptr); chan->topicWidget()->setTopic(szTopic); chan->topicWidget()->setTopicSetBy(__tr2qs("(unknown)")); if(KVI_OPTION_BOOL(KviOption_boolEchoNumericTopic) && !msg->haltOutput()) - chan->output(KVI_OUT_TOPIC, __tr2qs("Channel topic is: %Q"), &szTopic); + chan->output(msgtype, __tr2qs("Channel topic is: %Q"), &szTopic); } else { @@ -2289,7 +2294,7 @@ void KviIrcServerParser::parseNumericBackFromAway(KviIrcMessage * msg) if(bWasAway) { - int uTimeDiff = bWasAway ? (kvi_unixTime() - msg->connection()->userInfo()->awayTime()) : 0; + int uTimeDiff = kvi_unixTime() - msg->connection()->userInfo()->awayTime(); pOut->output(KVI_OUT_AWAY, __tr2qs("[Leaving away status after %ud %uh %um %us]: %Q"), uTimeDiff / 86400, (uTimeDiff % 86400) / 3600, (uTimeDiff % 3600) / 60, uTimeDiff % 60, &szWText); @@ -2399,7 +2404,7 @@ void KviIrcServerParser::parseNumericStats(KviIrcMessage * msg) if(msg->paramCount() > 2) { KviCString szParms; - for(std::size_t i = 1; i < msg->paramCount(); ++i) + for(int i = 1; i < msg->paramCount(); ++i) { if(szParms.hasData()) szParms.append(' '); @@ -3034,6 +3039,32 @@ void KviIrcServerParser::parseNumericSaslFail(KviIrcMessage * msg) pOut->output(KVI_OUT_SERVERINFO, __tr2qs("SASL authentication error: %Q"), &szParam); } + // Handle fallback if possible for SASL auth failure or dump if user mandates SASL + // and no fallback is available + if(msg->numeric() == 904) + { + if(msg->connection()->stateData()->sentSaslMethod() == QStringLiteral("EXTERNAL")) + { + if(!msg->connection()->target()->server()->saslNick().isEmpty() && !msg->connection()->target()->server()->saslPass().isEmpty()) + { + KviWindow * pOut = static_cast<KviWindow *>(msg->console()); + pOut->output(KVI_OUT_SERVERINFO, __tr2qs("Attempting fallback due to SASL failure.")); + msg->connection()->sendFmtData("AUTHENTICATE PLAIN"); + msg->connection()->stateData()->setSentSaslMethod(QStringLiteral("PLAIN")); + return; + } + } + + if(KVI_OPTION_BOOL(KviOption_boolDropConnectionOnSaslFailure)) + { + KviWindow * pOut = static_cast<KviWindow *>(msg->console()); + pOut->output(KVI_OUT_SERVERINFO, __tr2qs("SASL auth failed. Dropping the connection.")); + msg->connection()->sendFmtData("QUIT"); + msg->connection()->abort(); + return; + } + } + if(msg->connection()->stateData()->isInsideAuthenticate()) msg->connection()->endInitialCapNegotiation(); } diff --git a/src/kvirc/ui/KviChannelWindow.cpp b/src/kvirc/ui/KviChannelWindow.cpp index c2a229f15..74c8f5441 100644 --- a/src/kvirc/ui/KviChannelWindow.cpp +++ b/src/kvirc/ui/KviChannelWindow.cpp @@ -59,7 +59,7 @@ #endif //COMPILE_CRYPT_SUPPORT #include <set> -#include <time.h> +#include <ctime> #include <QDate> #include <QByteArray> @@ -103,9 +103,9 @@ KviChannelWindow::KviChannelWindow(KviConsoleWindow * lpConsole, const QString & connect(m_pTopicWidget, SIGNAL(topicSelected(const QString &)), this, SLOT(topicSelected(const QString &))); // mode label follows the topic widget - m_pModeWidget = new KviModeWidget(m_pTopSplitter, this, "mode_"); + m_pModeWidget = new KviModeWidget(m_pTopSplitter, *this, "mode_"); KviTalToolTip::add(m_pModeWidget, __tr2qs("Channel modes")); - connect(m_pModeWidget, SIGNAL(setMode(QString &)), this, SLOT(setMode(QString &))); + connect(m_pModeWidget, SIGNAL(setMode(const QString &)), this, SLOT(setMode(const QString &))); createTextEncodingButton(m_pButtonContainer); @@ -271,6 +271,8 @@ KviChannelWindow::~KviChannelWindow() for(auto i : m_ModeLists) for(auto ii : i.second) delete ii; + + qDeleteAll(m_lActionHistory); } void KviChannelWindow::toggleToolButtons() @@ -396,7 +398,7 @@ void KviChannelWindow::loadProperties(KviConfigurationFile * pCfg) KviWindow::loadProperties(pCfg); if(m_pUserListView) { - bool bHidden = pCfg->readBoolEntry("UserListHidden", 0); + bool bHidden = pCfg->readBoolEntry("UserListHidden", false); m_pUserListView->setHidden(bHidden); m_pListViewButton->setChecked(!bHidden); if(!bHidden) @@ -501,7 +503,7 @@ void KviChannelWindow::toggleModeEditor() else { m_pModeEditor = new KviModeEditor(m_pSplitter, m_pModeEditorButton, "mode_editor", this); - connect(m_pModeEditor, SIGNAL(setMode(QString &)), this, SLOT(setMode(QString &))); + connect(m_pModeEditor, SIGNAL(setMode(const QString &)), this, SLOT(setMode(const QString &))); connect(m_pModeEditor, SIGNAL(done()), this, SLOT(modeSelectorDone())); m_pModeEditor->show(); //setFocusHandlerNoClass(m_pInput,m_pModeEditor,"QLineEdit"); @@ -516,7 +518,7 @@ void KviChannelWindow::modeSelectorDone() toggleModeEditor(); } -void KviChannelWindow::setMode(QString & szMode) +void KviChannelWindow::setMode(const QString & szMode) { if(!connection()) return; @@ -690,7 +692,7 @@ void KviChannelWindow::setChannelModeWithParam(char cMode, QString & szParam) if(szParam.isEmpty()) m_szChannelParameterModes.erase(cMode); else - m_szChannelParameterModes.emplace(cMode, szParam); + m_szChannelParameterModes[cMode] = szParam; updateModeLabel(); updateCaption(); } @@ -717,13 +719,15 @@ void KviChannelWindow::getChannelModeString(QString & szBuffer) szBuffer.append(QChar(iter.first)); } -void KviChannelWindow::getChannelModeStringWithEmbeddedParams(QString & szBuffer) +QString KviChannelWindow::getChannelModeStringWithEmbeddedParams() { - szBuffer = m_szChannelMode; + QString szBuffer = m_szChannelMode; //add modes that use a parameter for(auto iter : m_szChannelParameterModes) szBuffer.append(QString(" %1:%2").arg(QChar(iter.first)).arg(iter.second)); + + return szBuffer; } bool KviChannelWindow::setOp(const QString & szNick, bool bOp, bool bIsMe) @@ -757,7 +761,8 @@ void KviChannelWindow::setDeadChan() m_pTopicWidget->reset(); - m_ActionHistory.clear(); + qDeleteAll(m_lActionHistory); + m_lActionHistory.clear(); m_uActionHistoryHotActionCount = 0; m_szChannelMode = ""; @@ -1043,12 +1048,12 @@ void KviChannelWindow::getWindowListTipText(QString & szBuffer) { if((cas.lTalkingUsers.count() < 3) && (cas.lWereTalkingUsers.count() > 0)) { - szBuffer += "<tr><td bgcolor=\"#E0E0E0\"><font color=\"#000000\">"; + szBuffer += R"(<tr><td bgcolor="#E0E0E0"><font color="#000000">)"; getTalkingUsersStats(szBuffer, cas.lWereTalkingUsers, true); szBuffer += "</font>"; szBuffer += szRowEnd; } - szBuffer += "<tr><td bgcolor=\"#E0E0E0\"><font color=\"#000000\">"; + szBuffer += R"(<tr><td bgcolor="#E0E0E0"><font color="#000000">)"; getTalkingUsersStats(szBuffer, cas.lTalkingUsers, false); szBuffer += "</font>"; szBuffer += szRowEnd; @@ -1057,14 +1062,14 @@ void KviChannelWindow::getWindowListTipText(QString & szBuffer) { if(cas.lWereTalkingUsers.count() > 0) { - szBuffer += "<tr><td bgcolor=\"#E0E0E0\"><font color=\"#000000\">"; + szBuffer += R"(<tr><td bgcolor="#E0E0E0"><font color="#000000">)"; getTalkingUsersStats(szBuffer, cas.lWereTalkingUsers, true); szBuffer += "</font>"; szBuffer += szRowEnd; } } - szBuffer += "<tr><td bgcolor=\"#E0E0E0\"><b><font color=\"#000000\">"; + szBuffer += R"(<tr><td bgcolor="#E0E0E0"><b><font color="#000000">)"; if(cas.dActionsPerMinute < 0.1) szBuffer += __tr2qs("No activity"); @@ -1249,7 +1254,7 @@ void KviChannelWindow::ownMessage(const QString & szBuffer, bool bUserFeedback) // first part (optimization): quickly find an high index that is _surely_lesser_ // than the correct one - while(1) + while(true) { iC++; szTmp = pEncoder->fromUnicode(szTmpBuffer.left(iPos)); @@ -1265,7 +1270,7 @@ void KviChannelWindow::ownMessage(const QString & szBuffer, bool bUserFeedback) // now, do it the simple way: increment our index until we perfectly fit into the // available space - while(1) + while(true) { iC++; @@ -1369,7 +1374,11 @@ void KviChannelWindow::ownAction(const QString & szBuffer) if(!connection()->sendFmtData("PRIVMSG %s :%cACTION %s%c", name.data(), 0x01, szEncrypted.ptr(), 0x01)) return; - output(KVI_OUT_ACTIONCRYPTED, "\r!nc\r%Q\r %Q", &szMyName, &szTmpBuffer); + QString szBuf = "\r!nc\r"; + szBuf += szMyName; + szBuf += "\r "; + szBuf += szTmpBuffer; + outputMessage(KVI_OUT_OWNACTIONCRYPTED, szBuf); } break; case KviCryptEngine::Encoded: @@ -1380,7 +1389,11 @@ void KviChannelWindow::ownAction(const QString & szBuffer) // ugly, but we must redecode here QString szRedecoded = decodeText(szEncrypted.ptr()); - output(KVI_OUT_ACTIONCRYPTED, "\r!nc\r%Q\r %Q", &szMyName, &szRedecoded); + QString szBuf = "\r!nc\r"; + szBuf += szMyName; + szBuf += "\r "; + szBuf += szRedecoded; + outputMessage(KVI_OUT_OWNACTIONCRYPTED, szBuf); } break; default: @@ -1425,7 +1438,7 @@ void KviChannelWindow::ownAction(const QString & szBuffer) // first part (optimization): quickly find an high index that is _surely_lesser_ // than the correct one - while(1) + while(true) { iC++; szTmp = pEncoder->fromUnicode(szTmpBuffer.left(iPos)); @@ -1440,7 +1453,7 @@ void KviChannelWindow::ownAction(const QString & szBuffer) //printf("Multi message: %d optimization cyles", iC); // now, do it the simple way: increment our index until we perfectly fit into the // available space - while(1) + while(true) { iC++; @@ -1474,7 +1487,7 @@ void KviChannelWindow::ownAction(const QString & szBuffer) szBuf += connection()->currentNickName(); szBuf += "\r "; szBuf += szTmp.data(); - outputMessage(KVI_OUT_ACTION, szBuf); + outputMessage(KVI_OUT_OWNACTION, szBuf); userAction(connection()->currentNickName(), KVI_USERACTION_ACTION); } else @@ -1497,7 +1510,7 @@ void KviChannelWindow::ownAction(const QString & szBuffer) szBuf += connection()->currentNickName(); szBuf += "\r "; szBuf += szTmpBuffer; - outputMessage(KVI_OUT_ACTION, szBuf); + outputMessage(KVI_OUT_OWNACTION, szBuf); userAction(connection()->currentNickName(), KVI_USERACTION_ACTION); } } @@ -1539,7 +1552,7 @@ bool KviChannelWindow::activityMeter(unsigned int * puActivityValue, unsigned in unsigned int uHotActionPercent; double dActionsPerMinute; - if(m_ActionHistory.size() < 1) + if(m_lActionHistory.count() < 1) { // nothing is happening uHotActionPercent = 0; @@ -1549,11 +1562,11 @@ bool KviChannelWindow::activityMeter(unsigned int * puActivityValue, unsigned in { kvi_time_t tNow = kvi_unixTime(); - KviChannelAction * pAction = m_ActionHistory.back(); + KviChannelAction * pAction = m_lActionHistory.last(); double dSpan = (double)(tNow - pAction->tTime); - if(m_ActionHistory.size() < KVI_CHANNEL_ACTION_HISTORY_MAX_COUNT) + if(m_lActionHistory.count() < KVI_CHANNEL_ACTION_HISTORY_MAX_COUNT) { if(m_joinTime.secsTo(QDateTime::currentDateTime()) < KVI_CHANNEL_ACTION_HISTORY_MAX_TIMESPAN) { @@ -1569,11 +1582,11 @@ bool KviChannelWindow::activityMeter(unsigned int * puActivityValue, unsigned in } // else the actions have been pushed out of the history because they were too much if(dSpan > 0.0) - dActionsPerMinute = (((double)(m_ActionHistory.size())) / (dSpan)) * 60.0; + dActionsPerMinute = (((double)(m_lActionHistory.count())) / (dSpan)) * 60.0; else - dActionsPerMinute = (double)(m_ActionHistory.size()); // ??? + dActionsPerMinute = (double)(m_lActionHistory.count()); // ??? - uHotActionPercent = (m_uActionHistoryHotActionCount * 100) / (m_ActionHistory.size()); + uHotActionPercent = (m_uActionHistoryHotActionCount * 100) / (m_lActionHistory.count()); } if(dActionsPerMinute < 0.3) @@ -1618,28 +1631,28 @@ void KviChannelWindow::channelAction(const QString & szNick, unsigned int uActio if(iTemperature > 0) m_uActionHistoryHotActionCount++; - m_ActionHistory.push_back(pAction); + m_lActionHistory.append(pAction); fixActionHistory(); } void KviChannelWindow::fixActionHistory() { - while(m_ActionHistory.size() > KVI_CHANNEL_ACTION_HISTORY_MAX_COUNT) - m_ActionHistory.erase(m_ActionHistory.begin(), m_ActionHistory.begin() + 1); + while(m_lActionHistory.count() > KVI_CHANNEL_ACTION_HISTORY_MAX_COUNT) + delete m_lActionHistory.takeFirst(); - if(m_ActionHistory.empty()) + if(m_lActionHistory.isEmpty()) return; - KviChannelAction * pAction = m_ActionHistory.back(); + KviChannelAction * pAction = m_lActionHistory.last(); kvi_time_t tMinimum = pAction->tTime - KVI_CHANNEL_ACTION_HISTORY_MAX_TIMESPAN; - KviChannelAction * pAct = m_ActionHistory.front(); + KviChannelAction * pAct = m_lActionHistory.first(); while(pAct && (pAct->tTime < tMinimum)) { if(pAct->iTemperature > 0) m_uActionHistoryHotActionCount--; - m_ActionHistory.erase(m_ActionHistory.begin(), m_ActionHistory.begin() + 1); - pAct = m_ActionHistory.front(); + delete m_lActionHistory.takeFirst(); + pAct = m_lActionHistory.first(); } } @@ -1656,7 +1669,7 @@ void KviChannelWindow::getChannelActivityStats(KviChannelActivityStats * pStats) { fixActionHistory(); - pStats->uActionCount = m_ActionHistory.size(); + pStats->uActionCount = m_lActionHistory.count(); pStats->iAverageActionTemperature = 0; pStats->uActionsInTheLastMinute = 0; pStats->uHotActionCount = 0; @@ -1675,10 +1688,10 @@ void KviChannelWindow::getChannelActivityStats(KviChannelActivityStats * pStats) kvi_time_t tNow = kvi_unixTime(); - KviChannelAction * pAction = m_ActionHistory.back(); + KviChannelAction * pAction = m_lActionHistory.last(); pStats->uLastActionTimeSpan = tNow - pAction->tTime; - pAction = m_ActionHistory.front(); + pAction = m_lActionHistory.first(); pStats->uFirstActionTimeSpan = tNow - pAction->tTime; double dSpan = (double)pStats->uFirstActionTimeSpan; @@ -1713,9 +1726,9 @@ void KviChannelWindow::getChannelActivityStats(KviChannelActivityStats * pStats) pStats->lTalkingUsers.clear(); pStats->lWereTalkingUsers.clear(); - for(unsigned i = m_ActionHistory.size(); i-- > 0; ) + for(unsigned i = m_lActionHistory.count(); i-- > 0; ) { - pAction = m_ActionHistory[i]; + pAction = m_lActionHistory[i]; if(pAction->tTime >= tNow) pStats->uActionsInTheLastMinute++; diff --git a/src/kvirc/ui/KviChannelWindow.h b/src/kvirc/ui/KviChannelWindow.h index a10d818dd..af53ee2f0 100644 --- a/src/kvirc/ui/KviChannelWindow.h +++ b/src/kvirc/ui/KviChannelWindow.h @@ -60,7 +60,7 @@ class KviTopicWidget; // windows compiler wants this instead of the forward decl #include "KviMaskEditor.h" #else -typedef struct _KviMaskEntry KviMaskEntry; // KviMaskEditor.h +struct KviMaskEntry; // KviMaskEditor.h #endif /** @@ -76,24 +76,22 @@ typedef struct _KviMaskEntry KviMaskEntry; // KviMaskEditor.h #endif /** -* \typedef KviChannelAction * \struct _KviChannelAction * \brief A struct which holds the channel actions */ -typedef struct _KviChannelAction +struct KviChannelAction { QString szNick; // action source nick unsigned int uActionType; // type of the action kvi_time_t tTime; // time of the action int iTemperature; // temperature of the action -} KviChannelAction; +}; /** -* \typedef KviChannelActivityStats * \struct _KviChannelActivityStats * \brief A struct which holds the activity stats */ -typedef struct _KviChannelActivityStats +struct KviChannelActivityStats { unsigned int uActionCount; // number of actions in the history bool bStatsInaccurate; // the stats are inaccurate because we have just joined the chan @@ -106,7 +104,7 @@ typedef struct _KviChannelActivityStats unsigned int uHotActionPercent; QStringList lTalkingUsers; // users that seem to be talking NOW QStringList lWereTalkingUsers; -} KviChannelActivityStats; +}; /** * \class KviChannelWindow @@ -182,7 +180,7 @@ protected: QString m_szNameWithUserFlag; QStringList * m_pTmpHighLighted; unsigned int m_uActionHistoryHotActionCount; - std::vector<KviChannelAction *> m_ActionHistory; + QList<KviChannelAction *> m_lActionHistory; kvi_time_t m_tLastReceivedWhoReply; QList<int> m_VertSplitterSizesList; QList<int> m_SplitterSizesList; @@ -211,7 +209,7 @@ public: * \brief Returns the button container object * \return QFrame * */ - QFrame * buttonContainer() { return (QFrame *)m_pButtonContainer; }; + QFrame * buttonContainer() override { return (QFrame *)m_pButtonContainer; } /** * \brief Returns a list of masks for a specific mode @@ -242,7 +240,7 @@ public: * \brief Returns the name of the channel * \return const QString & */ - virtual const QString & target() { return windowName(); }; + const QString & target() override { return windowName(); } /** * \brief Returns the name of the channel with user flags @@ -307,9 +305,9 @@ public: /** * \brief Returns the number of masks is a channel mode list - * \return unsigned int + * \return size_t */ - unsigned int maskCount(char cMode) const { return this->modeMasks(cMode).size(); }; + size_t maskCount(char cMode) const { return this->modeMasks(cMode).size(); }; /** * \brief Called when someone sets a channel mode that is stored in a list; these modes require a parameter that is tipically a mask @@ -471,7 +469,7 @@ public: * \param puActivityTemperature The temperature of the activity * \return bool */ - virtual bool activityMeter(unsigned int * puActivityValue, unsigned int * puActivityTemperature); + bool activityMeter(unsigned int * puActivityValue, unsigned int * puActivityTemperature) override; /** * \brief Sets the channel as dead @@ -510,7 +508,7 @@ public: * \brief Returns the size of the channel * \return QSize */ - virtual QSize sizeHint() const; + QSize sizeHint() const override; /** * \brief Enables or disable the userlist updates @@ -772,14 +770,14 @@ public: * \param bUserFeedback Whether to display the echo feedback to the user * \return void */ - void ownMessage(const QString & szBuffer, bool bUserFeedback = true); + void ownMessage(const QString & szBuffer, bool bUserFeedback = true) override; /** * \brief Called when we perform an action * \param szBuffer The buffer :) * \return void */ - void ownAction(const QString & szBuffer); + void ownAction(const QString & szBuffer) override; /** * \brief Sets a plain (parameter-less) channel mode, (eg: +m) @@ -807,7 +805,7 @@ public: * \param szBuffer The buffer :) * \return void */ - void getChannelModeStringWithEmbeddedParams(QString & szBuffer); + QString getChannelModeStringWithEmbeddedParams(); /** * \brief Sets a channel mode with a parameter; an empty parameter unsets the mode (eg: +k password) @@ -862,14 +860,14 @@ public: * \brief Called when the channel losts the focus by the user * \return void */ - virtual void lostUserFocus(); + void lostUserFocus() override; /** * \brief Creates the tooltip over the channel treeview * \param szBuffer The buffer where to store the data * \return void */ - virtual void getWindowListTipText(QString & szBuffer); + void getWindowListTipText(QString & szBuffer) override; /** * \brief Unhighlights the windowlist item @@ -896,7 +894,7 @@ public: * See also: view() * \return KviIrcView * */ - virtual KviIrcView * lastClickedView() const; + KviIrcView * lastClickedView() const override; protected: /** @@ -905,59 +903,59 @@ protected: * \param pEvent The event * \return bool */ - bool eventFilter(QObject * pObject, QEvent * pEvent); + bool eventFilter(QObject * pObject, QEvent * pEvent) override; /** * \brief Returns the correct icon for the channel * \return QPixmap * */ - virtual QPixmap * myIconPtr(); + QPixmap * myIconPtr() override; /** * \brief Fills in the caption buffers * \return void */ - virtual void fillCaptionBuffers(); + void fillCaptionBuffers() override; /** * \brief Gets the group name * \param szBuffer The buffer where to save the data * \return void */ - virtual void getConfigGroupName(QString & szBuffer); + void getConfigGroupName(QString & szBuffer) override; /** * \brief Saves the properties to file * \param pCfg The config file * \return void */ - virtual void saveProperties(KviConfigurationFile * pCfg); + void saveProperties(KviConfigurationFile * pCfg) override; /** * \brief Loads the properties from file * \param pCfg The config file * \return void */ - virtual void loadProperties(KviConfigurationFile * pCfg); + void loadProperties(KviConfigurationFile * pCfg) override; /** * \brief Applies the options * \return void */ - virtual void applyOptions(); + void applyOptions() override; /** * \brief Gets the base name for log file * \param szBuffer The buffer where to save data * \return void */ - virtual void getBaseLogFileName(QString & szBuffer); + void getBaseLogFileName(QString & szBuffer) override; /** * \brief Trigger the OnChannelWindowCreated event * \return void */ - virtual void triggerCreationEvents(); + void triggerCreationEvents() override; /** * \brief Called when someone sets a mask in the channel's lists @@ -1003,10 +1001,10 @@ protected: * \param szMessage The message :) * \return void */ - virtual void preprocessMessage(QString & szMessage); + void preprocessMessage(QString & szMessage) override; - virtual void resizeEvent(QResizeEvent *); - virtual void closeEvent(QCloseEvent * pEvent); + void resizeEvent(QResizeEvent *) override; + void closeEvent(QCloseEvent * pEvent) override; public slots: /** * \brief Toggles the double view mode @@ -1050,7 +1048,7 @@ private slots: * \param szMode The modes selected, including any plus/minus sign and parameters * \return void */ - void setMode(QString & szMode); + void setMode(const QString & szMode); /** * \brief Called when we right-click the irc view. diff --git a/src/kvirc/ui/KviColorSelectionWindow.h b/src/kvirc/ui/KviColorSelectionWindow.h index adb67d09e..913691663 100644 --- a/src/kvirc/ui/KviColorSelectionWindow.h +++ b/src/kvirc/ui/KviColorSelectionWindow.h @@ -67,10 +67,10 @@ public: private: virtual void show(); - virtual void paintEvent(QPaintEvent * e); - virtual void keyPressEvent(QKeyEvent * e); - virtual void mousePressEvent(QMouseEvent * e); - virtual void timerEvent(QTimerEvent * e); + void paintEvent(QPaintEvent * e) override; + void keyPressEvent(QKeyEvent * e) override; + void mousePressEvent(QMouseEvent * e) override; + void timerEvent(QTimerEvent * e) override; }; #endif //_KVI_COLORWIN_H_ diff --git a/src/kvirc/ui/KviConsoleWindow.cpp b/src/kvirc/ui/KviConsoleWindow.cpp index 4f8efcacc..f400ef14d 100644 --- a/src/kvirc/ui/KviConsoleWindow.cpp +++ b/src/kvirc/ui/KviConsoleWindow.cpp @@ -280,7 +280,7 @@ void KviConsoleWindow::getUserTipText(const QString & nick, KviIrcUserEntry * e, if(e->avatar()) { - buffer += QString(nrs + "<center><img src=\"%1\" width=\"%2\"></center>" + enr).arg(e->avatar()->localPath()).arg(e->avatar()->size().width()); + buffer += QString(nrs + R"(<center><img src="%1" width="%2"></center>)" + enr).arg(e->avatar()->localPath()).arg(e->avatar()->size().width()); } if(e->hasRealName()) @@ -340,7 +340,7 @@ void KviConsoleWindow::getUserTipText(const QString & nick, KviIrcUserEntry * e, if(e->hasHops()) { - buffer += "<tr><td bgcolor=\"#E0E0E0\"><font color=\"#000000\">"; + buffer += R"(<tr><td bgcolor="#E0E0E0"><font color="#000000">)"; buffer += __tr2qs("Hops: <b>%1</b>").arg(e->hops()); buffer += "</font>" + enr; } @@ -353,14 +353,14 @@ void KviConsoleWindow::getUserTipText(const QString & nick, KviIrcUserEntry * e, if(e->hasAccountName()) { - buffer += "<tr><td bgcolor=\"#E0E0E0\"><font color=\"#000000\">"; + buffer += R"(<tr><td bgcolor="#E0E0E0"><font color="#000000">)"; buffer += __tr2qs("Identified to account: <b>%1</b>").arg(e->accountName()); buffer += "</font>" + enr; } if(e->isAway()) { - buffer += "<tr><td width=\"100%\" bgcolor=\"#E0E0E0\"><font color=\"#000000\">"; + buffer += R"(<tr><td width="100%" bgcolor="#E0E0E0"><font color="#000000">)"; buffer += __tr2qs("Probably away"); buffer += "</font>" + enr; } @@ -799,13 +799,13 @@ void KviConsoleWindow::outputPrivmsg(KviWindow * wnd, if(KVI_OPTION_BOOL(KviOption_boolUseSpecifiedSmartColorForOwnNick)) { //avoid the use of the color specifier for own nickname - if(m_szOwnSmartColor == KviNickColors::getSmartColor(sum)) + if(m_szOwnSmartColor == KviNickColors::getSmartColor(sum, KVI_OPTION_BOOL(KviOption_boolColorNicksWithBackground))) sum++; } pUserEntry->setSmartNickColor(sum); } - szNick.prepend(KviNickColors::getSmartColor(sum)); + szNick.prepend(KviNickColors::getSmartColor(sum, KVI_OPTION_BOOL(KviOption_boolColorNicksWithBackground))); } else { @@ -819,10 +819,10 @@ void KviConsoleWindow::outputPrivmsg(KviWindow * wnd, if(KVI_OPTION_BOOL(KviOption_boolUseSpecifiedSmartColorForOwnNick)) { //avoid the use of the color specifier for own nickname - if(m_szOwnSmartColor == KviNickColors::getSmartColor(sum)) + if(m_szOwnSmartColor == KviNickColors::getSmartColor(sum, KVI_OPTION_BOOL(KviOption_boolColorNicksWithBackground))) sum++; } - szNick.prepend(KviNickColors::getSmartColor(sum)); + szNick.prepend(KviNickColors::getSmartColor(sum, KVI_OPTION_BOOL(KviOption_boolColorNicksWithBackground))); } } szNick.prepend(KviControlCodes::Color); @@ -1306,7 +1306,7 @@ void KviConsoleWindow::getWindowListTipText(QString & buffer) buffer += tspan; buffer += html_eofbold; - buffer += enr + "<tr><td bgcolor=\"#E0E0E0\"><font color=\"#000000\">"; + buffer += enr + R"(<tr><td bgcolor="#E0E0E0"><font color="#000000">)"; tspan = KviTimeUtils::formatTimeInterval((unsigned int)(kvi_secondsSince(connection()->statistics()->lastMessageTime())), KviTimeUtils::NoLeadingEmptyIntervals | KviTimeUtils::NoLeadingZeroes); diff --git a/src/kvirc/ui/KviConsoleWindow.h b/src/kvirc/ui/KviConsoleWindow.h index 2396abd05..7f1b5c4fb 100644 --- a/src/kvirc/ui/KviConsoleWindow.h +++ b/src/kvirc/ui/KviConsoleWindow.h @@ -98,22 +98,22 @@ protected: protected: // UI - virtual QPixmap * myIconPtr(); - virtual void fillCaptionBuffers(); - virtual void resizeEvent(QResizeEvent * e); - virtual void closeEvent(QCloseEvent * e); - virtual void getBaseLogFileName(QString & buffer); - virtual void getWindowListTipText(QString & buffer); - virtual QSize sizeHint() const; - virtual void applyOptions(); - virtual void triggerCreationEvents(); + QPixmap * myIconPtr() override; + void fillCaptionBuffers() override; + void resizeEvent(QResizeEvent * e) override; + void closeEvent(QCloseEvent * e) override; + void getBaseLogFileName(QString & buffer) override; + void getWindowListTipText(QString & buffer) override; + QSize sizeHint() const override; + void applyOptions() override; + void triggerCreationEvents() override; void fillStatusString(); //void socketError(int iError); //void socketStateChange(); //void registerLinkMonitor(KviIrcSocketMonitor * m); //void unregisterLinkMonitor(KviIrcSocketMonitor * m); - virtual void loadProperties(KviConfigurationFile * cfg); - virtual void saveProperties(KviConfigurationFile * cfg); + void loadProperties(KviConfigurationFile * cfg) override; + void saveProperties(KviConfigurationFile * cfg) override; void destroyConnection(); // internal helper for applyHighlighting @@ -126,23 +126,23 @@ public: KviIrcContext * context() { return m_pContext; }; // UI - inline KviUserListView * notifyListView() { return m_pNotifyListView; }; - inline int selectedCount(); + KviUserListView * notifyListView() const { return m_pNotifyListView; } + int selectedCount(); // // State // - inline KviIrcContext::State state() { return context()->state(); }; + KviIrcContext::State state() { return context()->state(); } // these should disappear! - inline bool isConnected() { return context()->isConnected(); }; - inline bool isIPv6Connection(); - inline bool isNotConnected(); + bool isConnected() { return context()->isConnected(); } + bool isIPv6Connection(); + bool isNotConnected(); bool connectionInProgress(); // // This connection info // - inline QString currentNetworkName(); + QString currentNetworkName(); KviAvatar * currentAvatar(); // // IRC Context wide helpers (connection related) @@ -179,10 +179,10 @@ public: // when no longer needed. KviAvatar * defaultAvatarFromOptions(); - void terminateConnectionRequest(bool bForce = false, const char * quitMsg = 0); + void terminateConnectionRequest(bool bForce = false, const char * quitMsg = nullptr); // Status string (usermode + nick) (connection related too) - inline const QString & statusString() { return m_szStatusString; }; + const QString & statusString() const { return m_szStatusString; } KviWindow * activeWindow(); // User db, connection related diff --git a/src/kvirc/ui/KviCtcpPageDialog.h b/src/kvirc/ui/KviCtcpPageDialog.h index c76d463c2..c37fafd5a 100644 --- a/src/kvirc/ui/KviCtcpPageDialog.h +++ b/src/kvirc/ui/KviCtcpPageDialog.h @@ -52,8 +52,8 @@ protected: void center(); protected: - virtual void showEvent(QShowEvent * e); - virtual void closeEvent(QCloseEvent * e); + void showEvent(QShowEvent * e) override; + void closeEvent(QCloseEvent * e) override; protected slots: void die(); }; diff --git a/src/kvirc/ui/KviCustomToolBar.cpp b/src/kvirc/ui/KviCustomToolBar.cpp index 0e8081bb3..5fe6dafb6 100644 --- a/src/kvirc/ui/KviCustomToolBar.cpp +++ b/src/kvirc/ui/KviCustomToolBar.cpp @@ -358,7 +358,7 @@ QSize KviCustomToolBarSeparator::sizeHint() const int iExtent = style()->pixelMetric(QStyle::PM_ToolBarSeparatorExtent, &opt, this); if(m_pToolBar->orientation() == Qt::Horizontal) - return QSize(iExtent, 0); + return { iExtent, 0 }; else return QSize(0, iExtent); } diff --git a/src/kvirc/ui/KviCustomToolBar.h b/src/kvirc/ui/KviCustomToolBar.h index 6eaf8b15d..e6987478e 100644 --- a/src/kvirc/ui/KviCustomToolBar.h +++ b/src/kvirc/ui/KviCustomToolBar.h @@ -51,17 +51,17 @@ protected: public: KviCustomToolBarDescriptor * descriptor() { return m_pDescriptor; }; protected: - virtual void dragEnterEvent(QDragEnterEvent * e); - virtual void dragMoveEvent(QDragMoveEvent * e); - virtual void dragLeaveEvent(QDragLeaveEvent * e); - virtual void dropEvent(QDropEvent * e); - virtual void childEvent(QChildEvent * e); - virtual bool eventFilter(QObject * o, QEvent * e); + void dragEnterEvent(QDragEnterEvent * e) override; + void dragMoveEvent(QDragMoveEvent * e) override; + void dragLeaveEvent(QDragLeaveEvent * e) override; + void dropEvent(QDropEvent * e) override; + void childEvent(QChildEvent * e) override; + bool eventFilter(QObject * o, QEvent * e) override; QAction * actionForWidget(QWidget * pWidget); void drag(QWidget * pChild, const QPoint & pnt); void filterChild(QObject * o); void unfilterChild(QObject * o); - virtual void paintEvent(QPaintEvent * e); + void paintEvent(QPaintEvent * e) override; void syncDescriptor(); protected slots: void beginCustomize(); @@ -79,10 +79,10 @@ protected: KviCustomToolBar * m_pToolBar; public: - QSize sizeHint() const; + QSize sizeHint() const override; protected: - void paintEvent(QPaintEvent * e); + void paintEvent(QPaintEvent * e) override; }; #endif //_KVI_CUSTOMTOOLBAR_H_ diff --git a/src/kvirc/ui/KviDebugWindow.h b/src/kvirc/ui/KviDebugWindow.h index ee7ea2d44..3f2424f8c 100644 --- a/src/kvirc/ui/KviDebugWindow.h +++ b/src/kvirc/ui/KviDebugWindow.h @@ -45,13 +45,13 @@ public: static KviDebugWindow * getInstance(); protected: - virtual QPixmap * myIconPtr(); - virtual void fillCaptionBuffers(); - virtual void resizeEvent(QResizeEvent * e); - virtual void loadProperties(KviConfigurationFile * cfg); - virtual void saveProperties(KviConfigurationFile * cfg); - virtual void getBaseLogFileName(QString & buffer); - virtual QSize sizeHint() const; + QPixmap * myIconPtr() override; + void fillCaptionBuffers() override; + void resizeEvent(QResizeEvent * e) override; + void loadProperties(KviConfigurationFile * cfg) override; + void saveProperties(KviConfigurationFile * cfg) override; + void getBaseLogFileName(QString & buffer) override; + QSize sizeHint() const override; }; #endif //_KVI_DEBUGWINDOW_H_ diff --git a/src/kvirc/ui/KviDynamicToolTip.h b/src/kvirc/ui/KviDynamicToolTip.h index 9c0bd1748..2d39419d7 100644 --- a/src/kvirc/ui/KviDynamicToolTip.h +++ b/src/kvirc/ui/KviDynamicToolTip.h @@ -51,7 +51,7 @@ class KVIRC_API KviDynamicToolTip : public QObject friend class KviDynamicToolTipHelper; Q_OBJECT public: - KviDynamicToolTip(QWidget * parent, const char * name = 0); + KviDynamicToolTip(QWidget * parent, const char * name = nullptr); virtual ~KviDynamicToolTip(); protected: diff --git a/src/kvirc/ui/KviFileDialog.h b/src/kvirc/ui/KviFileDialog.h index ad22bce18..ad01e2f6a 100644 --- a/src/kvirc/ui/KviFileDialog.h +++ b/src/kvirc/ui/KviFileDialog.h @@ -57,7 +57,7 @@ public: * \param bModal Whether to have a modal behaviour * \return KviFileDialog */ - KviFileDialog(const QString & szDirName, const QString & szFilter = QString(), QWidget * pParent = 0, const char * name = 0, bool bModal = false); + KviFileDialog(const QString & szDirName, const QString & szFilter = QString(), QWidget * pParent = nullptr, const char * name = nullptr, bool bModal = false); /** * \brief Destroys the file dialog object @@ -75,7 +75,7 @@ public: * \param pParent The parent widget * \return bool */ - static bool askForOpenFileName(QString & szBuffer, const QString & szCaption, const QString & szInitial = QString(), const QString & szFilter = QString(), bool bShowHidden = false, bool bShowNative = true, QWidget * pParent = 0); + static bool askForOpenFileName(QString & szBuffer, const QString & szCaption, const QString & szInitial = QString(), const QString & szFilter = QString(), bool bShowHidden = false, bool bShowNative = true, QWidget * pParent = nullptr); /** * \param szBuffer The buffer where to store the data @@ -88,7 +88,7 @@ public: * \param pParent The parent widget * \return bool */ - static bool askForSaveFileName(QString & szBuffer, const QString & szCaption, const QString & szInitial = QString(), const QString & szFilter = QString(), bool bShowHidden = false, bool bConfirmOverwrite = false, bool bShowNative = true, QWidget * pParent = 0); + static bool askForSaveFileName(QString & szBuffer, const QString & szCaption, const QString & szInitial = QString(), const QString & szFilter = QString(), bool bShowHidden = false, bool bConfirmOverwrite = false, bool bShowNative = true, QWidget * pParent = nullptr); /** * \param szBuffer The buffer where to store the data @@ -100,7 +100,7 @@ public: * \param pParent The parent widget * \return bool */ - static bool askForDirectoryName(QString & szBuffer, const QString & szCaption, const QString & szInitial, const QString & szFilter = QString(), bool bShowHidden = false, bool bShowNative = true, QWidget * pParent = 0); + static bool askForDirectoryName(QString & szBuffer, const QString & szCaption, const QString & szInitial, const QString & szFilter = QString(), bool bShowHidden = false, bool bShowNative = true, QWidget * pParent = nullptr); /** * \param szBuffer The buffer where to store the data @@ -112,7 +112,7 @@ public: * \param pParent The parent widget * \return bool */ - static bool askForOpenFileNames(QStringList & szBuffer, const QString & szCaption, const QString & szInitial, const QString & szFilter = QString(), bool bShowHidden = false, bool bShowNative = true, QWidget * pParent = 0); + static bool askForOpenFileNames(QStringList & szBuffer, const QString & szCaption, const QString & szInitial, const QString & szFilter = QString(), bool bShowHidden = false, bool bShowNative = true, QWidget * pParent = nullptr); }; #endif //_KVI_FILEDIALOG_H_ diff --git a/src/kvirc/ui/KviHistoryWindow.cpp b/src/kvirc/ui/KviHistoryWindow.cpp index 85b309f29..adfd141ae 100644 --- a/src/kvirc/ui/KviHistoryWindow.cpp +++ b/src/kvirc/ui/KviHistoryWindow.cpp @@ -34,7 +34,7 @@ #include <QListWidget> #include <QMouseEvent> -#include <ctype.h> +#include <cctype> KviHistoryWindow::KviHistoryWindow(QWidget * pParent) : QListWidget(pParent) diff --git a/src/kvirc/ui/KviHistoryWindow.h b/src/kvirc/ui/KviHistoryWindow.h index 297aeb277..7270c8519 100644 --- a/src/kvirc/ui/KviHistoryWindow.h +++ b/src/kvirc/ui/KviHistoryWindow.h @@ -95,10 +95,10 @@ private: void fill(); //bool findTypedSeq(); // returns true if it is a complete word - virtual void keyPressEvent(QKeyEvent * e); - virtual void mousePressEvent(QMouseEvent * e); - virtual void timerEvent(QTimerEvent * e); - virtual void hideEvent(QHideEvent * e); + void keyPressEvent(QKeyEvent * e) override; + void mousePressEvent(QMouseEvent * e) override; + void timerEvent(QTimerEvent * e) override; + void hideEvent(QHideEvent * e) override; public slots: /** * \brief Called when the owner is dead diff --git a/src/kvirc/ui/KviImageDialog.h b/src/kvirc/ui/KviImageDialog.h index af05dba36..42773bea7 100644 --- a/src/kvirc/ui/KviImageDialog.h +++ b/src/kvirc/ui/KviImageDialog.h @@ -52,7 +52,7 @@ public: const QString & tipText() { return m_szTipText; }; virtual int height(const KviTalListWidget *) const; virtual int width(const KviTalListWidget *) const; - virtual void paint(QPainter * p); + void paint(QPainter * p) override; }; #define KID_TYPE_BUILTIN_IMAGES_SMALL 1 @@ -70,7 +70,7 @@ public: int initialType = 0, const QString & szInitialDir = QString(), int maxPreviewFileSize = 256000, bool modal = false); - virtual ~KviImageDialog(); + ~KviImageDialog(); protected: QComboBox * m_pTypeComboBox; @@ -97,7 +97,7 @@ public: protected: void startJob(int type, const QString & szInitialPath = QString()); void jobTerminated(); - virtual void closeEvent(QCloseEvent * e); + void closeEvent(QCloseEvent * e) override; protected slots: void okClicked(); void cancelClicked(); diff --git a/src/kvirc/ui/KviInput.cpp b/src/kvirc/ui/KviInput.cpp index 1175ee73c..b84910d7d 100644 --- a/src/kvirc/ui/KviInput.cpp +++ b/src/kvirc/ui/KviInput.cpp @@ -58,9 +58,10 @@ #include <QHBoxLayout> #include <QMenu> #include <QPushButton> +#include <QFontMetrics> -#include <ctype.h> -#include <stdlib.h> +#include <cctype> +#include <cstdlib> //This comes from KviApplication.cpp extern KviColorWindow * g_pColorWindow; @@ -381,7 +382,7 @@ void KviInput::focusInEvent(QFocusEvent *) int KviInput::heightHint() const { - return m_pMultiLineEditor ? 120 : m_pInputEditor->heightHint(); + return m_pMultiLineEditor ? (m_pInputEditor->heightHint() * 6) : m_pInputEditor->heightHint(); } void KviInput::setText(const QString & szText) diff --git a/src/kvirc/ui/KviInput.h b/src/kvirc/ui/KviInput.h index 97e72a3aa..3c4061642 100644 --- a/src/kvirc/ui/KviInput.h +++ b/src/kvirc/ui/KviInput.h @@ -61,7 +61,7 @@ public: * \param pView The userlist * \return KviInput */ - KviInput(KviWindow * pPar, KviUserListView * pView = 0); + KviInput(KviWindow * pPar, KviUserListView * pView = nullptr); /** * \brief Destroys the input object @@ -165,18 +165,18 @@ public: * \brief Return the instance of the input editor * \return KviInputEditor * */ - inline KviInputEditor * editor() { return m_pInputEditor; }; + KviInputEditor * editor() const { return m_pInputEditor; } /** * \brief Return the instance of the input history * \return KviInputHistory * */ - inline KviInputHistory * history() { return KviInputHistory::instance(); }; + KviInputHistory * history() { return KviInputHistory::instance(); } protected: void installShortcuts(); - virtual void focusInEvent(QFocusEvent * e); - virtual void setFocusProxy(QWidget * w); - virtual void keyPressEvent(QKeyEvent * e); + void focusInEvent(QFocusEvent * e) override; + void setFocusProxy(QWidget * w); + void keyPressEvent(QKeyEvent * e) override; public slots: /** * \brief Toggles the multiline editor diff --git a/src/kvirc/ui/KviInputEditor.cpp b/src/kvirc/ui/KviInputEditor.cpp index 4f9a38c7e..482d81ec0 100644 --- a/src/kvirc/ui/KviInputEditor.cpp +++ b/src/kvirc/ui/KviInputEditor.cpp @@ -73,6 +73,7 @@ #include <algorithm> #include <functional> +#include <utility> #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) #include <windows.h> @@ -121,8 +122,8 @@ public: { } - KviInputEditorTextBlock(const QString & text) - : szText(text) + KviInputEditorTextBlock(QString text) + : szText(std::move(text)) { } }; @@ -896,17 +897,17 @@ void KviInputEditor::drawContents(QPainter * p) { if(pBlock->uForeground == KVI_INPUT_DEF_FORE) p->setPen(bIsSelected ? KVI_OPTION_COLOR(KviOption_colorInputSelectionForeground) : KVI_OPTION_COLOR(KviOption_colorInputForeground)); - else if(pBlock->uForeground >= 16) + else if(pBlock->uForeground > KVI_EXTCOLOR_MAX) p->setPen(KVI_OPTION_COLOR(KviOption_colorInputBackground)); else - p->setPen(KVI_OPTION_MIRCCOLOR(pBlock->uForeground)); + p->setPen(getMircColor(pBlock->uForeground)); if(pBlock->uBackground != KVI_INPUT_DEF_BACK) { - if(pBlock->uBackground >= 16) + if(pBlock->uBackground > KVI_EXTCOLOR_MAX) p->fillRect(QRectF(fCurX, iTop, pBlock->fWidth, iBottom - iTop), KVI_OPTION_COLOR(KviOption_colorInputForeground)); else - p->fillRect(QRectF(fCurX, iTop, pBlock->fWidth, iBottom - iTop), KVI_OPTION_MIRCCOLOR(pBlock->uBackground)); + p->fillRect(QRectF(fCurX, iTop, pBlock->fWidth, iBottom - iTop), getMircColor(pBlock->uBackground)); } @@ -986,7 +987,7 @@ QChar KviInputEditor::getSubstituteChar(unsigned short uControlCode) return QChar('E'); break; default: - return QChar(uControlCode); + return { uControlCode }; break; } } @@ -1672,7 +1673,7 @@ void KviInputEditor::handleDragSelection() QPoint pnt = mapFromGlobal(QCursor::pos()); - m_iCursorPosition = charIndexFromXPosition(pnt.x()); + m_iCursorPosition = std::min(charIndexFromXPosition(pnt.x()), m_szTextBuffer.length()); if(m_iCursorPosition == m_iSelectionAnchorChar) clearSelection(); @@ -2001,7 +2002,7 @@ void KviInputEditor::keyPressEvent(QKeyEvent * e) return; } - m_bLastCompletionFinished = 1; + m_bLastCompletionFinished = true; } switch(e->key()) @@ -2373,7 +2374,7 @@ void KviInputEditor::standardNickCompletion(bool bAddMask, QString & szWord, boo m_iLastCompletionCursorPosition = m_iCursorPosition; m_szLastCompletedNick = szBuffer; standardNickCompletionInsertCompletedText(szWord, szBuffer, bFirstWordInLine, bInCommand); - m_bLastCompletionFinished = 0; + m_bLastCompletionFinished = false; // REPAINT CALLED FROM OUTSIDE! } // else no match at all @@ -2399,12 +2400,12 @@ void KviInputEditor::standardNickCompletion(bool bAddMask, QString & szWord, boo // completed m_szLastCompletedNick = szBuffer; standardNickCompletionInsertCompletedText(szWord, szBuffer, bFirstWordInLine, bInCommand); - m_bLastCompletionFinished = 0; + m_bLastCompletionFinished = false; // REPAINT CALLED FROM OUTSIDE! } else { - m_bLastCompletionFinished = 1; + m_bLastCompletionFinished = true; m_szLastCompletedNick = ""; } @@ -2424,12 +2425,12 @@ void KviInputEditor::standardNickCompletion(bool bAddMask, QString & szWord, boo m_iLastCompletionCursorPosition = m_iCursorPosition; m_szLastCompletedNick = szBuffer; standardNickCompletionInsertCompletedText(szWord, szBuffer, bFirstWordInLine, bInCommand); - m_bLastCompletionFinished = 0; + m_bLastCompletionFinished = false; // REPAINT CALLED FROM OUTSIDE! } else { - m_bLastCompletionFinished = 1; + m_bLastCompletionFinished = true; m_szLastCompletedNick = ""; } } @@ -3186,11 +3187,11 @@ void KviInputEditor::clearSelection() void KviInputEditor::homeInternal() { + clearSelection(); + if(m_iCursorPosition <= 0) return; - clearSelection(); - home(); } diff --git a/src/kvirc/ui/KviInputEditor.h b/src/kvirc/ui/KviInputEditor.h index 41412d0e7..cab113307 100644 --- a/src/kvirc/ui/KviInputEditor.h +++ b/src/kvirc/ui/KviInputEditor.h @@ -503,13 +503,13 @@ private: * \brief Returns true is there are some action in the undo stack * \return bool */ - inline bool isUndoAvailable() const { return !m_bReadOnly && !m_UndoStack.empty(); } + bool isUndoAvailable() const { return !m_bReadOnly && !m_UndoStack.empty(); } /** * \brief Returns true is there are some action in the redo stack * \return bool */ - inline bool isRedoAvailable() const { return !m_bReadOnly && !m_RedoStack.empty(); } + bool isRedoAvailable() const { return !m_bReadOnly && !m_RedoStack.empty(); } /** * \brief Inserts one action in the undo stack diff --git a/src/kvirc/ui/KviIpEditor.h b/src/kvirc/ui/KviIpEditor.h index 56e0e8a07..77133ea2c 100644 --- a/src/kvirc/ui/KviIpEditor.h +++ b/src/kvirc/ui/KviIpEditor.h @@ -47,7 +47,7 @@ public: bool setAddress(const QString & ipAddr); QString address() const; void setAddressType(AddressType addrType); - inline AddressType addressType() const { return m_addrType; } + AddressType addressType() const { return m_addrType; } bool isValid() const; }; diff --git a/src/kvirc/ui/KviIrcToolBar.cpp b/src/kvirc/ui/KviIrcToolBar.cpp index 35b0f0bd7..4ebc90a3e 100644 --- a/src/kvirc/ui/KviIrcToolBar.cpp +++ b/src/kvirc/ui/KviIrcToolBar.cpp @@ -309,7 +309,7 @@ void KviIrcContextDisplay::tipRequest(KviDynamicToolTip * tip, const QPoint &) txt += nbspc + __tr2qs("Lag: <b>?.?\?</b>"); //escaped a ? due to compiler trigraphs warning } - txt += "<tr><td bgcolor=\"#E0E0E0\"><font color=\"#000000\">"; + txt += R"(<tr><td bgcolor="#E0E0E0"><font color="#000000">)"; txt += szIrcContext; txt += "</font>" + enr; } @@ -339,7 +339,6 @@ void KviIrcContextDisplay::drawContents(QPainter * p) if(c) { QString serv, nick; - QString tmp; if(!c->connection()) { serv = __tr2qs("Not connected"); @@ -358,21 +357,12 @@ void KviIrcContextDisplay::drawContents(QPainter * p) else if(ic->userInfo()->userMode().isEmpty()) nick += ic->currentNickName(); - if(ic->userInfo()->isAway()) - { - nick += space + sprtr + space; - nick += __tr2qs("is away"); - } - - else + if(ic->userInfo()->isAway()) { - if(ic->userInfo()->isAway()) - { - nick += space; - nick += __tr2qs("is away"); - nick += space + sprtr; - } + nick += space + sprtr + space; + nick += __tr2qs("is away"); } + serv = __tr2qs("Using server"); serv += cln + space; serv += ic->currentServerName(); diff --git a/src/kvirc/ui/KviIrcToolBar.h b/src/kvirc/ui/KviIrcToolBar.h index 81d62b6e2..fdbd742c9 100644 --- a/src/kvirc/ui/KviIrcToolBar.h +++ b/src/kvirc/ui/KviIrcToolBar.h @@ -48,21 +48,21 @@ class KVIRC_API KviToolBarGraphicalApplet : public QWidget { Q_OBJECT public: - KviToolBarGraphicalApplet(QWidget * par, const char * name = 0); + KviToolBarGraphicalApplet(QWidget * par, const char * name = nullptr); ~KviToolBarGraphicalApplet(); private: bool m_bResizeMode; public: - virtual QSize sizeHint() const; + QSize sizeHint() const override; protected: - virtual void mouseMoveEvent(QMouseEvent * e); - virtual void mousePressEvent(QMouseEvent * e); - virtual void mouseReleaseEvent(QMouseEvent * e); + void mouseMoveEvent(QMouseEvent * e) override; + void mousePressEvent(QMouseEvent * e) override; + void mouseReleaseEvent(QMouseEvent * e) override; - virtual void paintEvent(QPaintEvent * e); + void paintEvent(QPaintEvent * e) override; virtual void drawContents(QPainter * p); }; @@ -72,7 +72,7 @@ class KVIRC_API KviIrcContextDisplay : public KviToolBarGraphicalApplet { Q_OBJECT public: - KviIrcContextDisplay(QWidget * par, const char * name = 0); + KviIrcContextDisplay(QWidget * par, const char * name = nullptr); ~KviIrcContextDisplay(); protected: diff --git a/src/kvirc/ui/KviIrcView.cpp b/src/kvirc/ui/KviIrcView.cpp index 0d8aefcd6..7b52722a9 100644 --- a/src/kvirc/ui/KviIrcView.cpp +++ b/src/kvirc/ui/KviIrcView.cpp @@ -105,8 +105,9 @@ #include <QFontDialog> #include <QByteArray> #include <QMenu> +#include <QWindow> -#include <time.h> +#include <ctime> #ifdef COMPILE_ON_WINDOWS #pragma warning(disable : 4102) @@ -370,6 +371,23 @@ KviIrcView::~KviIrcView() delete m_pWrappedBlockSelectionInfo; } +void KviIrcView::showEvent(QShowEvent * e) +{ + QWindow * pWin = topLevelWidget()->windowHandle(); + if(!pWin) + return; // huh ? + + QObject::disconnect(pWin,SIGNAL(screenChanged(QScreen *)),this,SLOT(screenChanged(QScreen *))); + QObject::connect(pWin,SIGNAL(screenChanged(QScreen *)),this,SLOT(screenChanged(QScreen *))); +} + +void KviIrcView::screenChanged(QScreen *) +{ + // Changing screen can change DPI. Reset font so metrics are recomputed. + setFont(font()); +} + + // // The IrcView : options // @@ -758,6 +776,8 @@ bool KviIrcView::messageShouldGoToMessageView(int iMsgType) case KVI_OUT_CHANNELNOTICECRYPTED: case KVI_OUT_ACTION: case KVI_OUT_ACTIONCRYPTED: + case KVI_OUT_OWNACTION: + case KVI_OUT_OWNACTIONCRYPTED: case KVI_OUT_OWNPRIVMSG: case KVI_OUT_OWNPRIVMSGCRYPTED: case KVI_OUT_HIGHLIGHT: @@ -1265,8 +1285,8 @@ void KviIrcView::paintEvent(QPaintEvent * p) } bacWasTransp = (aux == KviControlCodes::Transparent); break; - //case KviControlCodes::Icon: - //case KviControlCodes::UnIcon: + //case KviControlCodes::Icon: + //case KviControlCodes::UnIcon: // does nothing //qDebug("Have a block with ICON/UNICON attr"); //break; @@ -1291,9 +1311,9 @@ void KviIrcView::paintEvent(QPaintEvent * p) // #define SET_PEN(_color, _custom) \ - if(((unsigned char)_color) < 16) \ + if(((unsigned char)_color) <= KVI_EXTCOLOR_MAX) \ { \ - pa.setPen(KVI_OPTION_MIRCCOLOR((unsigned char)_color)); \ + pa.setPen(getMircColor((unsigned char)_color)); \ } \ else \ { \ @@ -1338,7 +1358,7 @@ void KviIrcView::paintEvent(QPaintEvent * p) int theWdth = _text_width; \ if(theWdth < 0) \ theWdth = width() - (curLeftCoord + KVI_IRCVIEW_HORIZONTAL_BORDER + scrollbarWidth); \ - pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_SELECT).back())); \ + pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing, getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_SELECT).back())); \ } \ pPenFont.setStyle(curItalic ^ (normalFontStyle != QFont::StyleNormal) ? QFont::StyleItalic : QFont::StyleNormal); \ if (m_bUseRealBold) \ @@ -1356,7 +1376,7 @@ void KviIrcView::paintEvent(QPaintEvent * p) int theWdth = _text_width; \ if(theWdth < 0) \ theWdth = width() - (curLeftCoord + KVI_IRCVIEW_HORIZONTAL_BORDER + scrollbarWidth); \ - pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing, KVI_OPTION_MIRCCOLOR((unsigned char)curBack)); \ + pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing, getMircColor((unsigned char)curBack)); \ } \ pPenFont.setStyle(curItalic ^ (normalFontStyle != QFont::StyleNormal) ? QFont::StyleItalic : QFont::StyleNormal); \ if (m_bUseRealBold) \ @@ -1427,7 +1447,8 @@ void KviIrcView::paintEvent(QPaintEvent * p) int theWdth = block->block_width; if(theWdth < 0) theWdth = width() - (curLeftCoord + KVI_IRCVIEW_HORIZONTAL_BORDER + scrollbarWidth); - pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_SELECT).back())); + pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, theWdth, m_iFontLineSpacing, + getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_SELECT).back())); goto no_selection_paint; } break; @@ -1464,9 +1485,9 @@ void KviIrcView::paintEvent(QPaintEvent * p) wdth = widgetWidth - (curLeftCoord + KVI_IRCVIEW_HORIZONTAL_BORDER); int imageYPos = curBottomCoord - m_iRelativePixmapY; // Set the mask if needed - if(curBack != KviControlCodes::Transparent && curBack < 16) + if(curBack != KviControlCodes::Transparent && curBack <= KVI_EXTCOLOR_MAX) { - pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, wdth, m_iFontLineSpacing, KVI_OPTION_MIRCCOLOR((unsigned char)curBack)); + pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, wdth, m_iFontLineSpacing, getMircColor((unsigned char)curBack)); } QString tmpQ; tmpQ.setUtf16(block->pChunk->szSmileId, kvi_wstrlen(block->pChunk->szSmileId)); @@ -1501,9 +1522,9 @@ void KviIrcView::paintEvent(QPaintEvent * p) SET_PEN(curFore, block->pChunk ? block->pChunk->customFore : QColor()); - if(curBack != KviControlCodes::Transparent && curBack < 16) + if(curBack != KviControlCodes::Transparent && curBack <= KVI_EXTCOLOR_MAX) { - pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, wdth, m_iFontLineSpacing, KVI_OPTION_MIRCCOLOR((unsigned char)curBack)); + pa.fillRect(curLeftCoord, curBottomCoord - m_iFontLineSpacing + m_iFontDescent, wdth, m_iFontLineSpacing, getMircColor((unsigned char)curBack)); } bool bBold = curBold || curLink; @@ -2843,7 +2864,7 @@ KviIrcViewWrappedBlock * KviIrcView::getLinkUnderMouse(int xPos, int yPos, QRect else { uLineWraps++; - bHadWordWraps = 1; + bHadWordWraps = true; } } if(pRect) @@ -2864,7 +2885,7 @@ KviIrcViewWrappedBlock * KviIrcView::getLinkUnderMouse(int xPos, int yPos, QRect { QString szLink; int iEndOfLInk = iLastEscapeBlock; - while(1) + while(true) { if(l->pBlocks[iEndOfLInk].pChunk) { diff --git a/src/kvirc/ui/KviIrcView.h b/src/kvirc/ui/KviIrcView.h index dc28df5db..5c85453ef 100644 --- a/src/kvirc/ui/KviIrcView.h +++ b/src/kvirc/ui/KviIrcView.h @@ -40,6 +40,7 @@ class QLineEdit; class QFile; class QFontMetrics; class QMenu; +class QScreen; class KviWindow; class KviMainWindow; @@ -48,10 +49,10 @@ class KviIrcViewToolWidget; class KviIrcViewToolTip; class KviAnimatedPixmap; -typedef struct _KviIrcViewLineChunk KviIrcViewLineChunk; -typedef struct _KviIrcViewWrappedBlock KviIrcViewWrappedBlock; -typedef struct _KviIrcViewLine KviIrcViewLine; -typedef struct _KviIrcViewWrappedBlockSelectionInfoTag KviIrcViewWrappedBlockSelectionInfo; +struct KviIrcViewLineChunk; +struct KviIrcViewWrappedBlock; +struct KviIrcViewLine; +struct KviIrcViewWrappedBlockSelectionInfo; #define KVI_IRCVIEW_INVALID_LINE_MARK_INDEX 0xffffffff @@ -177,13 +178,13 @@ public: // A null pixmap passed here unsets the private backgrdound. void setPrivateBackgroundPixmap(const QPixmap & pixmap, bool bRepaint = true); QPixmap * getPrivateBackgroundPixmap() const { return m_pPrivateBackgroundPixmap; }; - bool hasPrivateBackgroundPixmap() { return (m_pPrivateBackgroundPixmap != 0); }; + bool hasPrivateBackgroundPixmap() { return (m_pPrivateBackgroundPixmap != nullptr); }; // Logging // Stops previous logging session too... bool startLogging(const QString & fname = QString(), bool bPrependCurBuffer = false); void stopLogging(); - bool isLogging() { return (m_pLogFile != 0); }; + bool isLogging() { return (m_pLogFile != nullptr); }; void getLogFileName(QString & buffer); void add2Log(const QString & szBuffer, const QDateTime & date, int iMsgType, bool bPrependDate); @@ -204,27 +205,28 @@ public: void prevPage(); void scrollTop(); void scrollBottom(); - virtual QSize sizeHint() const; + QSize sizeHint() const override; const QString & lastLineOfText(); const QString & lastMessageText(); - virtual void setFont(const QFont & f); + void setFont(const QFont & f); void scrollToMarker(); protected: - virtual void paintEvent(QPaintEvent *); - virtual void resizeEvent(QResizeEvent *); - virtual void mousePressEvent(QMouseEvent * e); - virtual void mouseReleaseEvent(QMouseEvent *); - virtual void mouseDoubleClickEvent(QMouseEvent * e); - virtual void mouseMoveEvent(QMouseEvent * e); - virtual void timerEvent(QTimerEvent * e); - virtual void dragEnterEvent(QDragEnterEvent * e); - virtual void dropEvent(QDropEvent * e); - virtual bool event(QEvent * e); - virtual void wheelEvent(QWheelEvent * e); - virtual void keyPressEvent(QKeyEvent * e); + void paintEvent(QPaintEvent *) override; + void resizeEvent(QResizeEvent *) override; + void mousePressEvent(QMouseEvent * e) override; + void mouseReleaseEvent(QMouseEvent *) override; + void mouseDoubleClickEvent(QMouseEvent * e) override; + void mouseMoveEvent(QMouseEvent * e) override; + void timerEvent(QTimerEvent * e) override; + void dragEnterEvent(QDragEnterEvent * e) override; + void dropEvent(QDropEvent * e) override; + void showEvent(QShowEvent * e) override; + bool event(QEvent * e) override; + void wheelEvent(QWheelEvent * e) override; + void keyPressEvent(QKeyEvent * e) override; void maybeTip(const QPoint & pnt); - virtual void leaveEvent(QEvent *); + void leaveEvent(QEvent *) override; private: void triggerMouseRelatedKvsEvents(QMouseEvent * e); @@ -240,7 +242,7 @@ private: void calculateLineWraps(KviIrcViewLine * ptr, int maxWidth); void recalcFontVariables(const QFont & font, const QFontInfo & fi); bool checkSelectionBlock(KviIrcViewLine * line, int bufIndex); - KviIrcViewWrappedBlock * getLinkUnderMouse(int xPos, int yPos, QRect * pRect = 0, QString * linkCmd = 0, QString * linkText = 0); + KviIrcViewWrappedBlock * getLinkUnderMouse(int xPos, int yPos, QRect * pRect = nullptr, QString * linkCmd = nullptr, QString * linkText = nullptr); void doLinkToolTip(const QRect & rct, QString & linkCmd, QString & linkText); void doMarkerToolTip(); bool checkMarkerArea(const QPoint & mousePos); @@ -259,6 +261,7 @@ public slots: void resetBackground(); protected slots: virtual void scrollBarPositionChanged(int newValue); + void screenChanged(QScreen *); void masterDead(); void animatedIconChange(); signals: diff --git a/src/kvirc/ui/KviIrcView_events.cpp b/src/kvirc/ui/KviIrcView_events.cpp index 456341124..69374aaf3 100644 --- a/src/kvirc/ui/KviIrcView_events.cpp +++ b/src/kvirc/ui/KviIrcView_events.cpp @@ -536,10 +536,9 @@ void KviIrcView::mouseReleaseEvent(QMouseEvent * e) if(m_bShiftPressed) { bool bStarted = false; - KviIrcViewLineChunk * pC; for(unsigned int i = 0; i < tempLine->uChunkCount; i++) { - pC = &tempLine->pChunks[i]; + KviIrcViewLineChunk * pC = &tempLine->pChunks[i]; if(bStarted) { if(endChar >= (pC->iTextStart + pC->iTextLen)) @@ -562,7 +561,7 @@ void KviIrcView::mouseReleaseEvent(QMouseEvent * e) { //starts in this chunk addControlCharacter(pC, szSelectionText); - if((endChar - initChar) > pC->iTextLen) + if(endChar >= (pC->iTextLen + pC->iTextLen)) { //don't end in this chunk szSelectionText.append(tempLine->szText.mid(initChar, pC->iTextLen - (initChar - pC->iTextStart))); @@ -861,7 +860,7 @@ void KviIrcView::doMarkerToolTip() QString tip; tip += "<table>"; - tip += "<tr><td style=\"white-space: pre; padding-left: 2px; padding-right: 2px; valign=\"middle\">"; + tip += R"(<tr><td style="white-space: pre; padding-left: 2px; padding-right: 2px; valign="middle">)"; tip += __tr2qs("Scroll up to read from the last read line"); tip += "</td></tr></table>"; diff --git a/src/kvirc/ui/KviIrcView_getTextLine.cpp b/src/kvirc/ui/KviIrcView_getTextLine.cpp index 6c370aaec..d45640522 100644 --- a/src/kvirc/ui/KviIrcView_getTextLine.cpp +++ b/src/kvirc/ui/KviIrcView_getTextLine.cpp @@ -159,11 +159,12 @@ static inline bool url_compare_helper(const kvi_wchar_t * pData1, const kvi_wcha } const kvi_wchar_t * KviIrcView::getTextLine( - int iMsgType, - const kvi_wchar_t * data_ptr, - KviIrcViewLine * line_ptr, - bool bEnableTimeStamp, - const QDateTime & datetime_param) + int iMsgType, + const kvi_wchar_t * data_ptr, + KviIrcViewLine * line_ptr, + bool bEnableTimeStamp, + const QDateTime & datetime_param + ) { const kvi_wchar_t * pUnEscapeAt = nullptr; @@ -186,7 +187,7 @@ const kvi_wchar_t * KviIrcView::getTextLine( line_ptr->pChunks[0].iTextStart = 0; line_ptr->pChunks[0].colors.back = KVI_OPTION_MSGTYPE(iMsgType).back(); line_ptr->pChunks[0].colors.fore = KVI_OPTION_MSGTYPE(iMsgType).fore(); - line_ptr->pChunks[0].customFore = QColor(); + //line_ptr->pChunks[0].customFore = QColor(); // print a nice timestamp at the begin of the first line if(bEnableTimeStamp && KVI_OPTION_BOOL(KviOption_boolIrcViewTimestamp)) @@ -221,7 +222,7 @@ const kvi_wchar_t * KviIrcView::getTextLine( line_ptr->pChunks[2].iTextLen = 1; line_ptr->pChunks[2].colors.back = KVI_OPTION_MSGTYPE(iMsgType).back(); line_ptr->pChunks[2].colors.fore = KVI_OPTION_MSGTYPE(iMsgType).fore(); - line_ptr->pChunks[2].customFore = QColor(); + //line_ptr->pChunks[2].customFore = QColor(); iCurChunk += 2; } else @@ -251,67 +252,68 @@ const kvi_wchar_t * KviIrcView::getTextLine( line_ptr->pChunks[0].iTextLen = 0; } -// -// Ok... a couple of macros that occur really frequently -// in the following code... -// these could work well as functions too...but the macros are a lot faster :) -// - -/* - * Profane description: this adds a block of text of known length to a already created chunk inside this line. - */ -#define APPEND_LAST_TEXT_BLOCK(__data_ptr, __data_len) \ - blockLen = (__data_len); \ - line_ptr->pChunks[iCurChunk].iTextLen += blockLen; \ - kvi_appendWCharToQStringWithLength(&(line_ptr->szText), __data_ptr, __data_len); \ - iTextIdx += blockLen; - -/* - * Profane description: this adds a block of text of known length to a already created chunk inside this line. - * text is hidden (e.g. we want to display an emoticon instead of the ":)" text, so we insert it hidden) - */ - -#define APPEND_LAST_TEXT_BLOCK_HIDDEN_FROM_NOW(__data_ptr, __data_len) \ - blockLen = (__data_len); \ - kvi_appendWCharToQStringWithLength(&(line_ptr->szText), __data_ptr, __data_len); \ - iTextIdx += blockLen; - -/* - * Profane description: this is dummy - */ - -#define APPEND_ZERO_LENGTH_BLOCK(__data_ptr) /* does nothing */ - -/* - * Profane description: this adds a new chunk to the current line of the specified type. A chunk is a block of text - * with similar style properties (mainly with the same color) - */ - -#define NEW_LINE_CHUNK(_chunk_type) \ - line_ptr->uChunkCount++; \ - line_ptr->pChunks = (KviIrcViewLineChunk *)KviMemory::reallocate((void *)line_ptr->pChunks, \ - line_ptr->uChunkCount * sizeof(KviIrcViewLineChunk)); \ - iCurChunk++; \ - line_ptr->pChunks[iCurChunk].type = _chunk_type; \ - line_ptr->pChunks[iCurChunk].iTextStart = iTextIdx; \ - line_ptr->pChunks[iCurChunk].iTextLen = 0; \ - line_ptr->pChunks[iCurChunk].customFore = iCurChunk ? line_ptr->pChunks[iCurChunk - 1].customFore : QColor(); - - // EOF Macros + // + // Ok... a couple of macros that occur really frequently + // in the following code... + // these could work well as functions too...but the macros are a lot faster :) + // + + /* + * Profane description: this adds a block of text of known length to a already created chunk inside this line. + */ + #define APPEND_LAST_TEXT_BLOCK(__data_ptr, __data_len) \ + blockLen = (__data_len); \ + line_ptr->pChunks[iCurChunk].iTextLen += blockLen; \ + kvi_appendWCharToQStringWithLength(&(line_ptr->szText), __data_ptr, __data_len); \ + iTextIdx += blockLen; + + /* + * Profane description: this adds a block of text of known length to a already created chunk inside this line. + * text is hidden (e.g. we want to display an emoticon instead of the ":)" text, so we insert it hidden) + */ + + #define APPEND_LAST_TEXT_BLOCK_HIDDEN_FROM_NOW(__data_ptr, __data_len) \ + blockLen = (__data_len); \ + kvi_appendWCharToQStringWithLength(&(line_ptr->szText), __data_ptr, __data_len); \ + iTextIdx += blockLen; + + /* + * Profane description: this is dummy + */ + + #define APPEND_ZERO_LENGTH_BLOCK(__data_ptr) /* does nothing */ + + /* + * Profane description: this adds a new chunk to the current line of the specified type. A chunk is a block of text + * with similar style properties (mainly with the same color) + */ + + #define NEW_LINE_CHUNK(_chunk_type) \ + line_ptr->uChunkCount++; \ + line_ptr->pChunks = (KviIrcViewLineChunk *)KviMemory::reallocate((void *)line_ptr->pChunks, \ + line_ptr->uChunkCount * sizeof(KviIrcViewLineChunk)); \ + iCurChunk++; \ + line_ptr->pChunks[iCurChunk].type = _chunk_type; \ + line_ptr->pChunks[iCurChunk].iTextStart = iTextIdx; \ + line_ptr->pChunks[iCurChunk].iTextLen = 0; \ + if(iCurChunk > 0) \ + line_ptr->pChunks[iCurChunk].customFore = line_ptr->pChunks[iCurChunk - 1].customFore; + // EOF Macros + int partLen; - -/* - * Some additional description for the profanes: we want a fast way to check the presence of "active objects we have to process" in lines of text; - * such objects can be: EOF, URLs, mIRC control characters, emoticons, and so on. We implemented a jump table to accomplish this task very fast. - * This jump table is an array[256] containing label addresses (imagine them as functions). So something like "goto array[4];" is valid construct - * in C, that is equivalent to a function call to a function that starts on that label's line of code. - * Imagine to parse the input line one character at once and match it (as a switch can do) against this big array. Every 1-byte character corresponds - * to an ASCII integer between 0 and 255. If the array value for that integer key is defined and !=0, we jump to the corresponding label address. - * Example, if we find a "H" (72) we'll "goto char_to_check_jump_table[72]", aka "goto check_http_url". - * There exists two different versions of this tricky code, we switch them depending on the compiler abilities to accept our bad code :) - */ - + + /* + * Some additional description for the profanes: we want a fast way to check the presence of "active objects we have to process" in lines of text; + * such objects can be: EOF, URLs, mIRC control characters, emoticons, and so on. We implemented a jump table to accomplish this task very fast. + * This jump table is an array[256] containing label addresses (imagine them as functions). So something like "goto array[4];" is valid construct + * in C, that is equivalent to a function call to a function that starts on that label's line of code. + * Imagine to parse the input line one character at once and match it (as a switch can do) against this big array. Every 1-byte character corresponds + * to an ASCII integer between 0 and 255. If the array value for that integer key is defined and !=0, we jump to the corresponding label address. + * Example, if we find a "H" (72) we'll "goto char_to_check_jump_table[72]", aka "goto check_http_url". + * There exists two different versions of this tricky code, we switch them depending on the compiler abilities to accept our bad code :) + */ + #ifdef COMPILE_USE_DYNAMIC_LABELS // Heresy :) @@ -359,7 +361,7 @@ const kvi_wchar_t * KviIrcView::getTextLine( // clang-format off &&found_end_of_buffer ,nullptr ,&&found_mirc_escape ,&&found_color_escape , nullptr ,nullptr ,nullptr ,nullptr , - nullptr ,nullptr ,&&found_end_of_line ,nullptr , + nullptr ,&&found_tab ,&&found_end_of_line ,nullptr , nullptr ,&&found_command_escape ,nullptr ,&&found_mirc_escape , nullptr ,nullptr ,nullptr ,nullptr , nullptr ,nullptr ,&&found_mirc_escape ,nullptr , @@ -377,7 +379,7 @@ const kvi_wchar_t * KviIrcView::getTextLine( nullptr ,&&check_e2k_url ,&&check_file_or_ftp_url ,nullptr , &&check_http_url ,&&check_irc_url ,nullptr ,nullptr , nullptr ,&&check_mailto_or_magnet_url ,nullptr ,nullptr , // 064-079 // 070==F 072==H 073==I 077==M - nullptr ,nullptr ,nullptr ,&&check_spotify_url , + nullptr ,nullptr ,nullptr ,&&check_spotify_or_sftp_url , nullptr ,nullptr ,nullptr ,&&check_www_url , nullptr ,nullptr ,nullptr ,nullptr , nullptr ,nullptr ,nullptr ,nullptr , // 080-095 // 083==S 087==W @@ -385,7 +387,7 @@ const kvi_wchar_t * KviIrcView::getTextLine( nullptr ,&&check_e2k_url ,&&check_file_or_ftp_url ,nullptr , &&check_http_url ,&&check_irc_url ,nullptr ,nullptr , nullptr ,&&check_mailto_or_magnet_url ,nullptr ,nullptr , // 096-111 // 101=e 102=f 104=h 105=i 109==m - nullptr ,nullptr ,nullptr ,&&check_spotify_url , + nullptr ,nullptr ,nullptr ,&&check_spotify_or_sftp_url , nullptr ,nullptr ,nullptr ,&&check_www_url , nullptr ,nullptr ,nullptr ,nullptr , nullptr ,nullptr ,nullptr ,nullptr , // 112-127 // 115==s 119==w @@ -512,7 +514,7 @@ check_char_loop: goto check_e2k_url; break; case 9: - goto check_spotify_url; + goto check_spotify_or_sftp_url; break; } } @@ -540,7 +542,7 @@ check_escape_switch: { case '\0': #ifdef COMPILE_USE_DYNAMIC_LABELS - found_end_of_buffer: +found_end_of_buffer: #endif //COMPILE_USE_DYNAMIC_LABELS APPEND_LAST_TEXT_BLOCK(data_ptr, p - data_ptr) if(pUnEscapeAt) @@ -553,7 +555,7 @@ check_escape_switch: break; case '\n': #ifdef COMPILE_USE_DYNAMIC_LABELS - found_end_of_line: +found_end_of_line: #endif //COMPILE_USE_DYNAMIC_LABELS // Found the end of a line APPEND_LAST_TEXT_BLOCK(data_ptr, p - data_ptr); @@ -569,9 +571,24 @@ check_escape_switch: p++; return p; break; + case '\t': +#ifdef COMPILE_USE_DYNAMIC_LABELS +found_tab: +#endif //COMPILE_USE_DYNAMIC_LABELS + // Found tab. Artificial end of block. + APPEND_LAST_TEXT_BLOCK(data_ptr, p - data_ptr); + // Artificial block with a single tab + NEW_LINE_CHUNK(KviControlCodes::ArbitraryBreak); + data_ptr = p; + p++; + APPEND_LAST_TEXT_BLOCK(data_ptr, p - data_ptr); + NEW_LINE_CHUNK(KviControlCodes::ArbitraryBreak); + data_ptr = p; + p++; + break; case '\r': #ifdef COMPILE_USE_DYNAMIC_LABELS - found_command_escape: +found_command_escape: #endif //COMPILE_USE_DYNAMIC_LABELS if(p == pUnEscapeAt) @@ -672,7 +689,7 @@ check_escape_switch: break; case KviControlCodes::Color: #ifdef COMPILE_USE_DYNAMIC_LABELS - found_color_escape: +found_color_escape: #endif //COMPILE_USE_DYNAMIC_LABELS //Color control code...need a new attribute struct APPEND_LAST_TEXT_BLOCK(data_ptr, p - data_ptr) @@ -683,7 +700,7 @@ check_escape_switch: break; case KviControlCodes::Icon: #ifdef COMPILE_USE_DYNAMIC_LABELS - found_icon_escape: +found_icon_escape: #endif //COMPILE_USE_DYNAMIC_LABELS p++; if(KVI_OPTION_BOOL(KviOption_boolDrawEmoticons)) @@ -736,7 +753,7 @@ check_escape_switch: case KviControlCodes::Reverse: case KviControlCodes::Reset: #ifdef COMPILE_USE_DYNAMIC_LABELS - found_mirc_escape: +found_mirc_escape: #endif //COMPILE_USE_DYNAMIC_LABELS APPEND_LAST_TEXT_BLOCK(data_ptr, p - data_ptr) NEW_LINE_CHUNK(*p) @@ -837,6 +854,22 @@ check_file_or_ftp_url: goto got_url; } + static kvi_wchar_t aFtpsUrl[] = { 'f', 't', 'p', 's', ':', '/', '/' }; + + if(url_compare_helper(p, aFtpsUrl, 7)) + { + partLen = 7; + goto got_url; + } + + static kvi_wchar_t aFtpesUrl[] = { 'f', 't', 'p', 'e', 's', ':', '/', '/' }; + + if(url_compare_helper(p, aFtpesUrl, 8)) + { + partLen = 8; + goto got_url; + } + static kvi_wchar_t aFtp2Url[] = { 'f', 't', 'p', '.' }; if(url_compare_helper(p, aFtp2Url, 4)) @@ -981,11 +1014,24 @@ check_mailto_or_magnet_url: goto check_char_loop; #endif // !COMPILE_USE_DYNAMIC_LABELS -check_spotify_url: +check_spotify_or_sftp_url: p++; if(KVI_OPTION_BOOL(KviOption_boolIrcViewUrlHighlighting)) { - if((*p == 'p') || (*p == 'P')) + if((*p == 'f') || (*p == 'F')) + { + p--; + + static kvi_wchar_t aSftpUrl[] = { 's', 'f', 't', 'p', ':', '/', '/' }; + + if(url_compare_helper(p, aSftpUrl, 7)) + { + partLen = 7; + goto got_url; + } + p++; + } + else if((*p == 'p') || (*p == 'P')) { p--; @@ -1076,6 +1122,8 @@ check_emoticon_char: case KVI_OUT_CHANPRIVMSG: case KVI_OUT_ACTION: case KVI_OUT_ACTIONCRYPTED: + case KVI_OUT_OWNACTION: + case KVI_OUT_OWNACTIONCRYPTED: case KVI_OUT_OWNPRIVMSG: case KVI_OUT_QUERYPRIVMSG: case KVI_OUT_QUERYPRIVMSGCRYPTED: diff --git a/src/kvirc/ui/KviIrcView_loghandling.cpp b/src/kvirc/ui/KviIrcView_loghandling.cpp index 209873ce8..08dd79644 100644 --- a/src/kvirc/ui/KviIrcView_loghandling.cpp +++ b/src/kvirc/ui/KviIrcView_loghandling.cpp @@ -150,6 +150,8 @@ const QString & KviIrcView::lastMessageText() case KVI_OUT_CHANNELNOTICECRYPTED: case KVI_OUT_ACTION: case KVI_OUT_ACTIONCRYPTED: + case KVI_OUT_OWNACTION: + case KVI_OUT_OWNACTIONCRYPTED: case KVI_OUT_OWNPRIVMSG: case KVI_OUT_OWNPRIVMSGCRYPTED: case KVI_OUT_HIGHLIGHT: diff --git a/src/kvirc/ui/KviIrcView_private.h b/src/kvirc/ui/KviIrcView_private.h index 85312dd45..8be1842d4 100644 --- a/src/kvirc/ui/KviIrcView_private.h +++ b/src/kvirc/ui/KviIrcView_private.h @@ -77,7 +77,7 @@ // resets the color, bold and underline flags // -typedef struct _KviIrcViewLineChunk +struct KviIrcViewLineChunk { unsigned char type; // chunk type int iTextStart; // index in the szText string of the beginning of the block @@ -91,21 +91,21 @@ typedef struct _KviIrcViewLineChunk } _KVI_PACKED colors; // anonymous // QColor customBack; QColor customFore; -} /*_KVI_PACKED*/ KviIrcViewLineChunk; +}; // // The wrapped paintable data block // -typedef struct _KviIrcViewWrappedBlock +struct KviIrcViewWrappedBlock { KviIrcViewLineChunk * pChunk; // pointer to real line chunk or 0 for word wraps int block_start; // this is generally different than pAttribute->block_idx! int block_len; // length if the block in characters int block_width; // width of the block in pixels -} _KVI_PACKED KviIrcViewWrappedBlock; +} _KVI_PACKED; -typedef struct _KviIrcViewLine +struct KviIrcViewLine { // this is a text line in the IrcView's memory unsigned int uIndex; // index of the text line (needed for find and splitting) @@ -127,11 +127,11 @@ typedef struct _KviIrcViewLine KviIrcViewWrappedBlock * pBlocks; // pointer to the re-split paintable blocks // next and previous line - struct _KviIrcViewLine * pPrev; - struct _KviIrcViewLine * pNext; -} KviIrcViewLine; + KviIrcViewLine * pPrev; + KviIrcViewLine * pNext; +}; -typedef struct _KviIrcViewWrappedBlockSelectionInfoTag +struct KviIrcViewWrappedBlockSelectionInfo { int selection_type; int part_1_length; @@ -140,7 +140,7 @@ typedef struct _KviIrcViewWrappedBlockSelectionInfoTag int part_2_width; int part_3_length; int part_3_width; -} KviIrcViewWrappedBlockSelectionInfo; +}; #ifdef COMPILE_ON_WINDOWS #pragma pack(pop, old_packing) diff --git a/src/kvirc/ui/KviIrcView_tools.h b/src/kvirc/ui/KviIrcView_tools.h index 1aa34f91d..efbf40fa5 100644 --- a/src/kvirc/ui/KviIrcView_tools.h +++ b/src/kvirc/ui/KviIrcView_tools.h @@ -68,7 +68,6 @@ public: ~KviIrcMessageCheckListItem(); private: - QCheckBox * m_pCbox; int m_iId; KviIrcViewToolWidget * m_pToolWidget; @@ -123,7 +122,7 @@ public: }; void setFindResult(const QString & text); void focusStringToFind(); - inline bool messageEnabled(int msg_type) { return m_pFilterItems[msg_type]->isOn(); }; + bool messageEnabled(int msg_type) { return m_pFilterItems[msg_type]->isOn(); } void forceRepaint(); protected slots: void findPrev(); diff --git a/src/kvirc/ui/KviMainWindow.cpp b/src/kvirc/ui/KviMainWindow.cpp index 35248b064..016db92e6 100644 --- a/src/kvirc/ui/KviMainWindow.cpp +++ b/src/kvirc/ui/KviMainWindow.cpp @@ -59,24 +59,24 @@ #define _WANT_OPTION_FLAGS_ #include "KviOptions.h" -#include <QSplitter> -#include <QVariant> -#include <QLineEdit> -#include <QMessageBox> -#include <QTimer> -#include <QLayout> +#include <QCheckBox> +#include <QCloseEvent> #include <QDesktopWidget> #include <QEvent> -#include <QCloseEvent> -#include <QShortcut> #include <QFile> +#include <QLayout> +#include <QLineEdit> #include <QMenu> -#include <QWindowStateChangeEvent> -#include <QCheckBox> +#include <QMessageBox> +#include <QShortcut> +#include <QSplitter> #include <QString> +#include <QTimer> +#include <QVariant> +#include <QWindowStateChangeEvent> -#include <time.h> #include <algorithm> +#include <ctime> #ifdef COMPILE_PSEUDO_TRANSPARENCY #include <QPixmap> @@ -108,10 +108,6 @@ KviMainWindow::KviMainWindow(QWidget * pParent) setWindowTitle(KVI_DEFAULT_FRAME_CAPTION); - m_pActiveContext = nullptr; - - m_pTrayIcon = nullptr; - m_pSplitter = new QSplitter(Qt::Horizontal, this); m_pSplitter->setObjectName("main_frame_splitter"); m_pSplitter->setChildrenCollapsible(false); @@ -141,12 +137,6 @@ KviMainWindow::KviMainWindow(QWidget * pParent) // the init function) m_pStatusBar->load(); } - else - { - m_pStatusBar = nullptr; - } - - m_pWindowList = nullptr; createWindowList(); @@ -213,26 +203,13 @@ KviMainWindow::~KviMainWindow() delete m_pStatusBar; m_pStatusBar = nullptr; - std::vector<KviWindow *> l_winListCopy(m_WinList.begin(), m_WinList.end()); - std::vector<KviWindow *>::size_type iCount = 0; - - // close all not console windows - while(iCount < l_winListCopy.size()) - { - KviWindow * lkWindow = l_winListCopy[iCount]; - if(lkWindow->type() != KviWindow::Console) - { - closeWindow(lkWindow); - l_winListCopy.erase(l_winListCopy.begin() + iCount); - } - else - { - ++iCount; - } - } + std::vector<KviWindow *> lWinListCopy(m_WinList.begin(), m_WinList.end()); + // Sort the console windows to the end so they are closed last + std::sort(begin(lWinListCopy), end(lWinListCopy), [](KviWindow * a, KviWindow * b){ + return !a->isConsole() && b->isConsole(); + }); - // close all the remaining windows (consoles) - for(auto & i : l_winListCopy) + for(auto & i : lWinListCopy) closeWindow(i); g_pMainWindow = nullptr; @@ -269,11 +246,9 @@ void KviMainWindow::saveModuleExtensionToolBars() for(auto & t : m_pModuleExtensionToolBarList) { QString s = t->descriptor()->module()->name(); - s += ":"; + s += ':'; s += t->descriptor()->name().ptr(); - //qDebug("FOUND TOOLBAR %s",t.descriptor()->name().ptr()); - KVI_OPTION_STRINGLIST(KviOption_stringlistModuleExtensionToolbars).append(s); } } @@ -281,10 +256,9 @@ void KviMainWindow::saveModuleExtensionToolBars() KviMexToolBar * KviMainWindow::moduleExtensionToolBar(int extensionId) { for(auto & t : m_pModuleExtensionToolBarList) - { if(extensionId == t->descriptor()->id()) return t; - } + return nullptr; } @@ -340,7 +314,7 @@ void KviMainWindow::installAccelerators() m_pAccellerators.push_back(KviShortcut::create(key, this, SLOT(accelActivated()), SLOT(accelActivated()), Qt::ApplicationShortcut)); } -void KviMainWindow::freeAccelleratorKeySequence(QString & key) +void KviMainWindow::freeAccelleratorKeySequence(const QString & key) { QKeySequence kS(key); for(auto & pS : m_pAccellerators) @@ -358,7 +332,7 @@ void KviMainWindow::freeAccelleratorKeySequence(QString & key) void KviMainWindow::accelActivated() { - KVS_TRIGGER_EVENT_1(KviEvent_OnAccelKeyPressed, g_pActiveWindow, (((QShortcut *)sender())->key()).toString()); + KVS_TRIGGER_EVENT_1(KviEvent_OnAccelKeyPressed, g_pActiveWindow, ((qobject_cast<QShortcut *>(sender()))->key()).toString()); } void KviMainWindow::executeInternalCommand(int index) @@ -437,19 +411,16 @@ void KviMainWindow::closeActiveWindow() void KviMainWindow::closeWindow(KviWindow * wnd) { - if(wnd->inherits("KviConsoleWindow")) + if(wnd->isConsole() && consoleCount() <= 1) { - if(consoleCount() <= 1) - { - KVS_TRIGGER_EVENT_0(KviEvent_OnFrameWindowDestroyed, wnd); - KVS_TRIGGER_EVENT_0(KviEvent_OnKVIrcShutdown, wnd); - } + KVS_TRIGGER_EVENT_0(KviEvent_OnFrameWindowDestroyed, wnd); + KVS_TRIGGER_EVENT_0(KviEvent_OnKVIrcShutdown, wnd); } // notify the destruction wnd->triggerDestructionEvents(); // save it's properties - if(KVI_OPTION_BOOL(KviOption_boolWindowsRememberProperties)) // && (wnd->type() == KviWindow::Channel)) + if(KVI_OPTION_BOOL(KviOption_boolWindowsRememberProperties)) { QString group; wnd->getConfigGroupName(group); @@ -463,14 +434,6 @@ void KviMainWindow::closeWindow(KviWindow * wnd) if (iter != m_WinList.end()) m_WinList.erase(iter); -#if 0 - // hide it - if(wnd->parentWidget()) - wnd->mdiParent()->hide(); - else - wnd->hide(); -#endif - if(wnd == g_pActiveWindow) { if(!g_pApp->kviClosingDown()) @@ -492,7 +455,6 @@ void KviMainWindow::closeWindow(KviWindow * wnd) if(!bGotIt) { - // :/ g_pActiveWindow = nullptr; m_pActiveContext = nullptr; } @@ -531,7 +493,7 @@ void KviMainWindow::addWindow(KviWindow * wnd, bool bShow) { g_pWinPropertiesConfig->setGroup(group); } - else if(wnd->type() == KviWindow::Channel && g_pWinPropertiesConfig->hasGroup(group = wnd->windowName())) + else if(wnd->isChannel() && g_pWinPropertiesConfig->hasGroup(group = wnd->windowName())) { // try to load pre-4.2 channel settings g_pWinPropertiesConfig->setGroup(group); @@ -659,25 +621,16 @@ KviConsoleWindow * KviMainWindow::createNewConsole(bool bFirstInFrame, bool bSho return c; } -unsigned int KviMainWindow::consoleCount() +int KviMainWindow::consoleCount() { - unsigned int count = 0; - for(auto & wnd : m_WinList) - { - if(wnd) - if(wnd->type() == KviWindow::Console) - count++; - } - return count; + return std::count_if(begin(m_WinList), end(m_WinList), [](KviWindow * w){ return w->isConsole(); }); } KviConsoleWindow * KviMainWindow::firstConsole() { for(auto & wnd : m_WinList) - { - if(wnd->type() == KviWindow::Console) - return (KviConsoleWindow *)wnd; - } + if(wnd->isConsole()) + return qobject_cast<KviConsoleWindow *>(wnd); // We end up here when we have not console windows. // This may happen at early startup or late before shutdown. @@ -690,8 +643,8 @@ KviConsoleWindow * KviMainWindow::firstNotConnectedConsole() { if(wnd->type() == KviWindow::Console) { - if(!((KviConsoleWindow *)wnd)->connectionInProgress()) - return (KviConsoleWindow *)wnd; + if(!qobject_cast<KviConsoleWindow *>(wnd)->connectionInProgress()) + return qobject_cast<KviConsoleWindow *>(wnd); } } return nullptr; @@ -704,7 +657,6 @@ void KviMainWindow::childWindowCloseRequest(KviWindow * wnd) void KviMainWindow::setActiveWindow(KviWindow * wnd) { - // ASSERT(m_WinList.findRef(wnd)) m_pWindowStack->showAndActivate(wnd); } @@ -772,7 +724,6 @@ void KviMainWindow::windowActivated(KviWindow * wnd, bool bForce) if(!wnd) return; // this can happen? - // ASSERT(m_WinList.findRef(wnd)) // unless we want to bForce the active window to be re-activated if(g_pActiveWindow == wnd && !bForce) return; @@ -805,8 +756,7 @@ void KviMainWindow::changeEvent(QEvent * e) { #ifndef COMPILE_ON_MAC // For Qt5 this should be used to minimize to tray - if( - (e->type() == QEvent::WindowStateChange) && (windowState() & Qt::WindowMinimized) && KVI_OPTION_BOOL(KviOption_boolMinimizeInTray) && e->spontaneous()) + if((e->type() == QEvent::WindowStateChange) && (windowState() & Qt::WindowMinimized) && KVI_OPTION_BOOL(KviOption_boolMinimizeInTray) && e->spontaneous()) { if(!trayIcon()) @@ -815,9 +765,9 @@ void KviMainWindow::changeEvent(QEvent * e) } if(trayIcon()) { - QWindowStateChangeEvent * ev = (QWindowStateChangeEvent *)e; + QWindowStateChangeEvent * ev = static_cast<QWindowStateChangeEvent *>(e); KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized) = ev->oldState() & Qt::WindowMaximized; - QTimer::singleShot(0, this, SLOT(hide())); + QTimer::singleShot(0, this, &KviMainWindow::hide); } return; } @@ -831,14 +781,11 @@ void KviMainWindow::changeEvent(QEvent * e) // and hopefully make the dock widget work correctly // in this case. // This will also trigger the OnWindowActivated event :) - if(isActiveWindow()) + if(g_pActiveWindow) { - if(g_pActiveWindow) + if(isActiveWindow()) windowActivated(g_pActiveWindow, true); - } - else - { - if(g_pActiveWindow) + else g_pActiveWindow->lostUserFocus(); } } @@ -859,7 +806,7 @@ void KviMainWindow::closeEvent(QCloseEvent * e) { e->ignore(); KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized) = isMaximized(); - QTimer::singleShot(0, this, SLOT(hide())); + QTimer::singleShot(0, this, &KviMainWindow::hide); } return; } @@ -870,20 +817,16 @@ void KviMainWindow::closeEvent(QCloseEvent * e) bool bGotRunningConnection = false; for(auto & w : m_WinList) { - if(w->type() == KviWindow::Console) + if(w->isConsole() && qobject_cast<KviConsoleWindow *>(w)->connectionInProgress()) { - if(((KviConsoleWindow *)w)->connectionInProgress()) - { - bGotRunningConnection = true; - break; - } + bGotRunningConnection = true; + break; } } if(bGotRunningConnection) { - QString txt; - txt += __tr2qs("There are active connections, are you sure you wish to quit KVIrc?"); + QString txt = __tr2qs("There are active connections, are you sure you wish to quit KVIrc?"); switch(QMessageBox::warning(this, __tr2qs("Confirm Close - KVIrc"), txt, __tr2qs("&Yes"), __tr2qs("&Always"), __tr2qs("&No"), 2, 2)) { @@ -924,7 +867,7 @@ void KviMainWindow::hideEvent(QHideEvent * e) if(trayIcon()) { KVI_OPTION_BOOL(KviOption_boolFrameIsMaximized) = isMaximized(); - QTimer::singleShot(0, this, SLOT(hide())); + QTimer::singleShot(0, this, &KviMainWindow::hide); } return; } @@ -947,7 +890,7 @@ void KviMainWindow::updatePseudoTransparency() { #ifdef COMPILE_PSEUDO_TRANSPARENCY uint uOpacity = KVI_OPTION_UINT(KviOption_uintGlobalWindowOpacityPercent) < 50 ? 50 : KVI_OPTION_UINT(KviOption_uintGlobalWindowOpacityPercent); - setWindowOpacity((float)uOpacity / 100); + setWindowOpacity(uOpacity / 100.f); #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) #ifndef Q_WS_EX_LAYERED #define Q_WS_EX_LAYERED WS_EX_LAYERED @@ -1066,10 +1009,9 @@ void KviMainWindow::fillToolBarsPopup(QMenu * p) { p->clear(); - disconnect(p, SIGNAL(triggered(QAction *)), this, SLOT(toolbarsPopupSelected(QAction *))); // just to be sure - connect(p, SIGNAL(triggered(QAction *)), this, SLOT(toolbarsPopupSelected(QAction *))); + disconnect(p, &QMenu::triggered, this, &KviMainWindow::toolbarsPopupSelected); // just to be sure + connect(p, &QMenu::triggered, this, &KviMainWindow::toolbarsPopupSelected); - QAction * pAction = nullptr; int cnt = 0; KviModuleExtensionDescriptorList * l = g_pModuleExtensionManager->getExtensionList("toolbar"); @@ -1078,6 +1020,7 @@ void KviMainWindow::fillToolBarsPopup(QMenu * p) for(KviModuleExtensionDescriptor * d = l->first(); d; d = l->next()) { QString label = __tr2qs("Show %1").arg(d->visibleName()); + QAction * pAction; if(d->icon()) pAction = p->addAction(*(d->icon()), label); else @@ -1100,17 +1043,14 @@ void KviMainWindow::fillToolBarsPopup(QMenu * p) { QString label = __tr2qs("Show %1").arg(d->label()); QString ico = d->iconId(); + QAction * pAction; if(!ico.isEmpty()) { QPixmap * pix = g_pIconManager->getImage(d->iconId()); if(pix) - { pAction = p->addAction(*pix, label); - } else - { pAction = p->addAction(label); - } } else { @@ -1141,7 +1081,7 @@ void KviMainWindow::customizeToolBars() void KviMainWindow::toolbarsPopupSelected(QAction * pAction) { - bool bOk = false; + bool bOk; int idext = pAction->data().toInt(&bOk); if(!bOk) return; @@ -1156,13 +1096,9 @@ void KviMainWindow::toolbarsPopupSelected(QAction * pAction) } if(KviMexToolBar * t = moduleExtensionToolBar(idext)) - { t->die(); - } else - { g_pModuleExtensionManager->allocateExtension("toolbar", idext, firstConsole()); - } } void KviMainWindow::iconSizePopupSelected(QAction * pAction) @@ -1170,7 +1106,7 @@ void KviMainWindow::iconSizePopupSelected(QAction * pAction) if(!pAction) return; - bool bOk = false; + bool bOk; uint uSize = pAction->data().toUInt(&bOk); if(!bOk) return; @@ -1184,7 +1120,7 @@ void KviMainWindow::buttonStylePopupSelected(QAction * pAction) if(!pAction) return; - bool bOk = false; + bool bOk; uint uStyle = pAction->data().toUInt(&bOk); if(!bOk) return; @@ -1194,8 +1130,7 @@ void KviMainWindow::buttonStylePopupSelected(QAction * pAction) bool KviMainWindow::focusNextPrevChild(bool next) { - QWidget * w = focusWidget(); - if(w) + if(QWidget * w = focusWidget(); w) { if(w->focusPolicy() == Qt::StrongFocus) return false; @@ -1229,9 +1164,7 @@ void KviMainWindow::saveToolBarPositions() QFile f(szTemp); if(f.open(QIODevice::WriteOnly | QIODevice::Truncate)) - { f.write(saveState(1)); - } } void KviMainWindow::restoreToolBarPositions() @@ -1301,32 +1234,32 @@ void KviMainWindow::recreateWindowList() // Some accelerators // -void KviMainWindow::switchToPrevWindow(void) +void KviMainWindow::switchToPrevWindow() { m_pWindowList->switchWindow(false, false); } -void KviMainWindow::switchToNextWindow(void) +void KviMainWindow::switchToNextWindow() { m_pWindowList->switchWindow(true, false); } -void KviMainWindow::switchToPrevHighlightedWindow(void) +void KviMainWindow::switchToPrevHighlightedWindow() { m_pWindowList->switchWindow(false, false, true); } -void KviMainWindow::switchToNextHighlightedWindow(void) +void KviMainWindow::switchToNextHighlightedWindow() { m_pWindowList->switchWindow(true, false, true); } -void KviMainWindow::switchToPrevWindowInContext(void) +void KviMainWindow::switchToPrevWindowInContext() { m_pWindowList->switchWindow(false, true); } -void KviMainWindow::switchToNextWindowInContext(void) +void KviMainWindow::switchToNextWindowInContext() { m_pWindowList->switchWindow(true, true); } diff --git a/src/kvirc/ui/KviMainWindow.h b/src/kvirc/ui/KviMainWindow.h index c8b1b06cf..1984ec4a1 100644 --- a/src/kvirc/ui/KviMainWindow.h +++ b/src/kvirc/ui/KviMainWindow.h @@ -38,35 +38,36 @@ #include <unordered_set> #include <vector> -class KviMenuBar; -class KviWindowStack; -class KviWindow; -class KviConsoleWindow; -class KviWindowListBase; -class QSplitter; class KviConfigurationFile; -class KviMexToolBar; -class KviIrcContext; +class KviConsoleWindow; class KviIrcConnection; +class KviIrcContext; +class KviMenuBar; +class KviMexToolBar; class KviStatusBar; -class QMenu; class KviTrayIcon; +class KviWindow; +class KviWindowListBase; +class KviWindowStack; +class QMenu; +class QSplitter; class QShortcut; class QString; -class KVIRC_API KviMainWindow : public KviTalMainWindow //, public KviIrcContextManager +class KVIRC_API KviMainWindow : public KviTalMainWindow { - friend class KviWindow; - friend class KviConsoleWindow; friend class KviApplication; - friend class KviIrcServerParser; - friend class KviMexToolBar; - friend class KviWindowStack; - friend class KviIrcContext; + friend class KviConsoleWindow; friend class KviIrcConnection; + friend class KviIrcContext; + friend class KviIrcServerParser; friend class KviLagMeter; + friend class KviMexToolBar; + friend class KviToolBar; friend class KviUserListView; friend class KviUserListViewArea; + friend class KviWindow; + friend class KviWindowStack; Q_OBJECT public: KviMainWindow(QWidget * pParent); @@ -78,31 +79,31 @@ protected: KviMenuBar * m_pMenuBar; // the main menu bar KviWindowStack * m_pWindowStack; // the mdi manager widget (child of the splitter) std::unordered_set<KviMexToolBar *> m_pModuleExtensionToolBarList; // the module extension toolbars - KviWindowListBase * m_pWindowList; // the WindowList - KviStatusBar * m_pStatusBar; + KviWindowListBase * m_pWindowList = nullptr; // the WindowList + KviStatusBar * m_pStatusBar = nullptr; // the mdi workspace child windows std::list<KviWindow *> m_WinList; // the main list of windows - KviIrcContext * m_pActiveContext; // the context of the m_pActiveWindow + KviIrcContext * m_pActiveContext = nullptr; // the context of the m_pActiveWindow // other - KviTrayIcon * m_pTrayIcon; // the frame's dock extension: this should be prolly moved ? + KviTrayIcon * m_pTrayIcon = nullptr; // the frame's dock extension: this should be prolly moved ? std::vector<QShortcut *> m_pAccellerators; // global application accellerators public: // the mdi manager: handles mdi children - KviWindowStack * windowStack() { return m_pWindowStack; }; + KviWindowStack * windowStack() const { return m_pWindowStack; } // the splitter is the central widget for this frame - QSplitter * splitter() { return m_pSplitter; }; + QSplitter * splitter() const { return m_pSplitter; } // KviWindowListBase is the base class for KviTreeWindowList and the KviClassicWindowList - KviWindowListBase * windowListWidget() { return m_pWindowList; }; + KviWindowListBase * windowListWidget() const { return m_pWindowList; } // well.. the menu bar :D - KviMenuBar * mainMenuBar() { return m_pMenuBar; }; - KviStatusBar * mainStatusBar() { return m_pStatusBar; }; - // this function may return 0 if the active window has no irc context - KviIrcContext * activeContext() { return m_pActiveContext; }; + KviMenuBar * mainMenuBar() const { return m_pMenuBar; } + KviStatusBar * mainStatusBar() const { return m_pStatusBar; } + // this function may return nullptr if the active window has no irc context + KviIrcContext * activeContext() const { return m_pActiveContext; } // shortcut to a = activeContext(); return a ? a->connection() : 0 KviIrcConnection * activeConnection(); // The list of the windows belonging to this frame // Note that the windows may be also undocked, but they are still owned by the frame - std::list<KviWindow *> & windowList() { return m_WinList; }; + std::list<KviWindow *> & windowList() { return m_WinList; } // Sets the specified window to be the active one // Raises it and focuses it void setActiveWindow(KviWindow * wnd); @@ -116,9 +117,9 @@ public: // window list. This is useful for asynchronous functions // that keep a window pointer and need to ensure that it is still // valid after an uncontrolled delay. (Think of a /timer implementation) - bool windowExists(KviWindow * wnd) { return (std::find(m_WinList.begin(), m_WinList.end(), wnd) != m_WinList.end()); }; + bool windowExists(KviWindow * wnd) const { return (std::find(m_WinList.begin(), m_WinList.end(), wnd) != m_WinList.end()); } // The number of consoles in this frame - unsigned int consoleCount(); + int consoleCount(); // Creates a new console window. DON'T use the KviConsoleWindow constructor directly. // (The script creation events are triggered from here) KviConsoleWindow * createNewConsole(bool bFirstInFrame = false, bool bShowIt = true); @@ -127,13 +128,13 @@ public: // Exceptions are the startup and the shutdown (see activeWindow()) KviConsoleWindow * firstConsole(); // Returns the first console that has no connection in progress - // This function CAN return 0 if all the consoles are connected + // This function CAN return nullptr if all the consoles are connected KviConsoleWindow * firstNotConnectedConsole(); // this is explicitly dedicated to the TrayIcon module - void setTrayIcon(KviTrayIcon * e) { m_pTrayIcon = e; }; + void setTrayIcon(KviTrayIcon * e) { m_pTrayIcon = e; } // returns the dockExtension applet. Useful for calling refresh() when // some particular event happens - KviTrayIcon * trayIcon() { return m_pTrayIcon; }; + KviTrayIcon * trayIcon() const { return m_pTrayIcon; } // helper for saving the window properties void saveWindowProperties(KviWindow * wnd, const QString & szSection); // finds the module extension toolbar with the specified identifier @@ -148,7 +149,7 @@ public: void setIconSize(unsigned int uSize); void setButtonStyle(unsigned int uStyle); // allows scripts and actions to override builtin accellerators, avoiding ambiguous events - void freeAccelleratorKeySequence(QString & key); + void freeAccelleratorKeySequence(const QString & key); // called by children windows when they have updated their titles. void updateWindowTitle(KviWindow * wnd); public slots: @@ -183,13 +184,13 @@ protected: void childConnectionServerInfoChange(KviIrcConnection * c); void childWindowSelectionStateChange(KviWindow * pWnd, bool bGotSelectionNow); - virtual void closeEvent(QCloseEvent * e); - virtual void hideEvent(QHideEvent * e); - virtual void resizeEvent(QResizeEvent * e); - virtual void moveEvent(QMoveEvent * e); - virtual bool focusNextPrevChild(bool next); - virtual void changeEvent(QEvent * event); - virtual void contextMenuEvent(QContextMenuEvent * event); + void closeEvent(QCloseEvent * e) override; + void hideEvent(QHideEvent * e) override; + void resizeEvent(QResizeEvent * e) override; + void moveEvent(QMoveEvent * e) override; + bool focusNextPrevChild(bool next) override; + void changeEvent(QEvent * event) override; + void contextMenuEvent(QContextMenuEvent * event) override; void updatePseudoTransparency(); void installAccelerators(); diff --git a/src/kvirc/ui/KviMaskEditor.cpp b/src/kvirc/ui/KviMaskEditor.cpp index c0b1d036c..b013ea719 100644 --- a/src/kvirc/ui/KviMaskEditor.cpp +++ b/src/kvirc/ui/KviMaskEditor.cpp @@ -71,7 +71,7 @@ KviMaskInputDialog::KviMaskInputDialog(const QString & szMask, KviMaskEditor * p { m_pChannel = pChannel; m_pEditor = pEditor; - setModal(1); + setModal(true); m_szOldMask = szMask; setWindowTitle(__tr2qs("Mask Editor - KVIrc")); diff --git a/src/kvirc/ui/KviMaskEditor.h b/src/kvirc/ui/KviMaskEditor.h index 4cfe2e0d9..65e57aa06 100644 --- a/src/kvirc/ui/KviMaskEditor.h +++ b/src/kvirc/ui/KviMaskEditor.h @@ -40,12 +40,12 @@ class KviMaskEditor; class QLineEdit; class QPushButton; -typedef struct _KviMaskEntry +struct KviMaskEntry { QString szMask; QString szSetBy; unsigned int uSetAt; -} KviMaskEntry; +}; class KviMaskItem : public QTreeWidgetItem { @@ -71,7 +71,7 @@ protected: return m_Mask.uSetAt < ((KviMaskItem *)&other)->mask()->uSetAt; break; } - return 0; //make compiler happy + return false; //make compiler happy } }; @@ -90,7 +90,7 @@ protected: KviChannelWindow * m_pChannel; KviMaskEditor * m_pEditor; protected slots: - virtual void accept(); + void accept() override; }; class KVIRC_API KviMaskEditor : public KviWindowToolWidget diff --git a/src/kvirc/ui/KviMenuBar.cpp b/src/kvirc/ui/KviMenuBar.cpp index 19a563164..58b566eb0 100644 --- a/src/kvirc/ui/KviMenuBar.cpp +++ b/src/kvirc/ui/KviMenuBar.cpp @@ -23,78 +23,74 @@ //============================================================================= #include "KviMenuBar.h" +#include "KviActionManager.h" #include "KviApplication.h" -#include "KviLocale.h" -#include "KviMainWindow.h" -#include "KviWindowStack.h" +#include "KviConsoleWindow.h" +#include "KviCoreActionNames.h" #include "KviIconManager.h" #include "KviInternalCommand.h" #include "KviIrcUrl.h" -#include "KviConsoleWindow.h" #include "KviKvsPopupMenu.h" +#include "KviKvsScript.h" +#include "KviLocale.h" +#include "KviMainWindow.h" #include "KviMemory.h" #include "KviModuleExtension.h" #include "KviOptions.h" -#include "KviActionManager.h" -#include "KviCoreActionNames.h" -#include "KviKvsScript.h" #include "KviShortcut.h" -#include "KviOptions.h" +#include "KviWindowStack.h" #include <QKeySequence> #include <QMenu> KviMenuBar::KviMenuBar(KviMainWindow * par, const char * name) - : KviTalMenuBar(par, name) + : KviTalMenuBar(par, name), m_pFrm{par} { setAutoFillBackground(false); - m_pFrm = par; - m_pRecentServersPopup = new QMenu("recentservers", this); - connect(m_pRecentServersPopup, SIGNAL(aboutToShow()), this, SLOT(updateRecentServersPopup())); - connect(m_pRecentServersPopup, SIGNAL(triggered(QAction *)), this, SLOT(newConnectionToServer(QAction *))); + m_pRecentServersPopup = new QMenu(QStringLiteral("recentservers"), this); + connect(m_pRecentServersPopup, &QMenu::aboutToShow, this, &KviMenuBar::updateRecentServersPopup); + connect(m_pRecentServersPopup, &QMenu::triggered, this, &KviMenuBar::newConnectionToServer); - m_pModulesToolsPopup = new QMenu("modulestools", this); - connect(m_pModulesToolsPopup, SIGNAL(aboutToShow()), this, SLOT(updateModulesToolsPopup())); - connect(m_pModulesToolsPopup, SIGNAL(triggered(QAction *)), this, SLOT(modulesToolsTriggered(QAction *))); + m_pModulesToolsPopup = new QMenu(QStringLiteral("modulestools"), this); + connect(m_pModulesToolsPopup, &QMenu::aboutToShow, this, &KviMenuBar::updateModulesToolsPopup); + connect(m_pModulesToolsPopup, &QMenu::triggered, this, &KviMenuBar::modulesToolsTriggered); - m_pActionsToolsPopup = new QMenu("actionstools", this); - connect(m_pActionsToolsPopup, SIGNAL(aboutToShow()), this, SLOT(updateActionsToolsPopup())); + m_pActionsToolsPopup = new QMenu(QStringLiteral("actionstools"), this); + connect(m_pActionsToolsPopup, &QMenu::aboutToShow, this, &KviMenuBar::updateActionsToolsPopup); - QMenu * pop = new QMenu("KVIrc", this); + QMenu * pop = new QMenu(QStringLiteral("KVIrc"), this); setupMainPopup(pop); - connect(pop, SIGNAL(aboutToShow()), this, SLOT(updateMainPopup())); + connect(pop, &QMenu::aboutToShow, this, &KviMenuBar::updateMainPopup); #ifndef COMPILE_ON_MAC - addDefaultItem("&KVIrc", pop); + addDefaultItem(QStringLiteral("&KVIrc"), pop); #else // Qt/Mac creates already a "KVirc" menu item on its own, and we don't like double entries ;-) - addDefaultItem("&IRC", pop); + addDefaultItem(QStringLiteral("&IRC"), pop); #endif //COMPILE_ON_MAC - m_pScriptItemList = nullptr; - - pop = new QMenu("scripting", this); + pop = new QMenu(QStringLiteral("scripting"), this); setupScriptingPopup(pop); addDefaultItem(__tr2qs("Scri&pting"), pop); - pop = new QMenu("tools", this); + pop = new QMenu(QStringLiteral("tools"), this); setupToolsPopup(pop); addDefaultItem(__tr2qs("&Tools"), pop); - connect(pop, SIGNAL(aboutToShow()), this, SLOT(updateToolsPopup())); + connect(pop, &QMenu::aboutToShow, this, &KviMenuBar::updateToolsPopup); - m_pToolbarsPopup = new QMenu("toolbars", this); - connect(m_pToolbarsPopup, SIGNAL(aboutToShow()), this, SLOT(updateToolbarsPopup())); + m_pToolbarsPopup = new QMenu(QStringLiteral("toolbars"), this); + connect(m_pToolbarsPopup, &QMenu::aboutToShow, this, &KviMenuBar::updateToolbarsPopup); - pop = new QMenu("settings", this); + pop = new QMenu(QStringLiteral("settings"), this); setupSettingsPopup(pop); - connect(pop, SIGNAL(aboutToShow()), this, SLOT(updateSettingsPopup())); + connect(pop, &QMenu::aboutToShow, this, &KviMenuBar::updateSettingsPopup); addDefaultItem(__tr2qs("&Settings"), pop); addDefaultItem(__tr2qs("&Window"), par->windowStack()->windowPopup()); - pop = new QMenu("help", this); + pop = new QMenu(QStringLiteral("help"), this); setupHelpPopup(pop); - connect(pop, SIGNAL(triggered(QAction *)), this, SLOT(actionTriggered(QAction *))); + connect(pop, &QMenu::triggered, this, &KviMenuBar::actionTriggered); addDefaultItem(__tr2qs("&Help"), pop); } @@ -112,7 +108,7 @@ void KviMenuBar::addDefaultItem(const QString & text, QMenu * pop) void KviMenuBar::setupHelpPopup(QMenu * pop) { - QMenu * help = pop ? pop : (QMenu *)sender(); + QMenu * help = pop ? pop : qobject_cast<QMenu *>(sender()); help->clear(); ACTION_POPUP_ITEM(KVI_COREACTION_HELPINDEX, help) @@ -128,14 +124,12 @@ void KviMenuBar::setupHelpPopup(QMenu * pop) help->addSeparator(); pAction = help->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::HomePage)), __tr2qs("KVIrc Home&page")); pAction->setData(KVI_INTERNALCOMMAND_KVIRC_HOMEPAGE); - if(QString::compare(KviLocale::instance()->localeName(), QString("ru"), Qt::CaseInsensitive) == 0) + if(QString::compare(KviLocale::instance()->localeName(), QLatin1String("ru"), Qt::CaseInsensitive) == 0) { pAction = help->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::HomePage)), __tr2qs("KVIrc Russian Home&page")); pAction->setData(KVI_INTERNALCOMMAND_KVIRC_HOMEPAGE_RU); } help->addSeparator(); - pAction = help->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Message)), __tr2qs("Subscribe to the Mailing List")); - pAction->setData(KVI_INTERNALCOMMAND_OPENURL_KVIRC_MAILINGLIST); pAction = help->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Bug)), __tr2qs("Report a Bug / Propose Improvements")); pAction->setData(KVI_INTERNALCOMMAND_OPENURL_KVIRC_BUGTRACK); help->addSeparator(); @@ -145,15 +139,15 @@ void KviMenuBar::setupHelpPopup(QMenu * pop) void KviMenuBar::actionTriggered(QAction * pAction) { - bool bOk = false; + bool bOk; int id = pAction->data().toInt(&bOk); if(bOk) m_pFrm->executeInternalCommand(id); } -void KviMenuBar::actionTriggered(bool) +void KviMenuBar::actionTriggeredBool(bool) { - QAction * pAction = (QAction *)sender(); + QAction * pAction = qobject_cast<QAction *>(sender()); if(!pAction) return; @@ -171,7 +165,7 @@ void KviMenuBar::updateSettingsPopup() void KviMenuBar::setupSettingsPopup(QMenu * pop) { - QMenu * opt = pop ? pop : (QMenu *)sender(); + QMenu * opt = pop ? pop : qobject_cast<QMenu *>(sender()); opt->clear(); QAction * pAction = opt->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Toolbar)), __tr2qs("Toolbars")); @@ -208,7 +202,7 @@ void KviMenuBar::setupSettingsPopup(QMenu * pop) void KviMenuBar::setupScriptingPopup(QMenu * pop) { - QMenu * script = pop ? pop : (QMenu *)sender(); + QMenu * script = pop ? pop : qobject_cast<QMenu *>(sender()); script->clear(); ACTION_POPUP_ITEM(KVI_COREACTION_ACTIONEDITOR, script) @@ -234,7 +228,7 @@ void KviMenuBar::updateMainPopup() void KviMenuBar::setupMainPopup(QMenu * pop) { - QMenu * main = pop ? pop : (QMenu *)sender(); + QMenu * main = pop ? pop : qobject_cast<QMenu *>(sender()); main->clear(); ACTION_POPUP_ITEM(KVI_COREACTION_NEWIRCCONTEXT, main) @@ -242,7 +236,7 @@ void KviMenuBar::setupMainPopup(QMenu * pop) QAction * pAction = main->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::World)), __tr2qs("New &Connection to")); pAction->setMenu(m_pRecentServersPopup); - m_pDisconnectAction = main->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Quit)), __tr2qs("Disconnect"), this, SLOT(actionTriggered(bool))); + m_pDisconnectAction = main->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Quit)), __tr2qs("Disconnect"), this, SLOT(actionTriggeredBool(bool))); m_pDisconnectAction->setData(KVI_INTERNALCOMMAND_QUIT); // FIXME: Add a "Dock to tray" icon if the tray is not visible (or show tray icon or whatever) @@ -257,7 +251,7 @@ void KviMenuBar::setupMainPopup(QMenu * pop) void KviMenuBar::updateRecentServersPopup() { - QMenu * m = (QMenu *)sender(); + QMenu * m = qobject_cast<QMenu *>(sender()); g_pApp->fillRecentServersPopup(m); m->addSeparator(); m->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Server)), __tr2qs("&Other...")); @@ -270,11 +264,11 @@ void KviMenuBar::newConnectionToServer(QAction * pAction) { if(text == __tr2qs("&Other...")) { - KviKvsScript::run("options.edit OptionsWidget_servers", m_pFrm->firstConsole()); + KviKvsScript::run("options.edit -n OptionsWidget_servers", m_pFrm->firstConsole()); } else { - text.replace(QString("&"), QString("")); + text.replace(QLatin1String("&"), QLatin1String("")); KviCString szCommand; if(KviIrcUrl::parse(text.toUtf8().data(), szCommand, KVI_IRCURL_CONTEXT_FIRSTFREE)) { @@ -298,20 +292,17 @@ void KviMenuBar::updateModulesToolsPopup() { m_pModulesToolsPopup->clear(); - QAction * pAction = nullptr; KviModuleExtensionDescriptorList * l = g_pModuleExtensionManager->getExtensionList("tool"); if(l) { for(KviModuleExtensionDescriptor * d = l->first(); d; d = l->next()) { + QAction * pAction = nullptr; if(d->icon()) - { pAction = m_pModulesToolsPopup->addAction(*(d->icon()), d->visibleName()); - } else - { pAction = m_pModulesToolsPopup->addAction(d->visibleName()); - } + pAction->setData(d->id()); } } @@ -333,7 +324,7 @@ void KviMenuBar::updateActionsToolsPopup() void KviMenuBar::setupToolsPopup(QMenu * pop) { - QMenu * m = pop ? pop : (QMenu *)sender(); + QMenu * m = pop ? pop : qobject_cast<QMenu *>(sender()); if(!m) return; @@ -361,8 +352,7 @@ void KviMenuBar::setupToolsPopup(QMenu * pop) // moved the old tools here m->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::IconManager)), __tr2qs("Show &Icon Table"), g_pIconManager, SLOT(showIconWidget())); #ifdef COMPILE_KDE4_SUPPORT - QAction * pAction = nullptr; - pAction = m->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Terminal)), __tr2qs("Open &Terminal"), this, SLOT(actionTriggered(bool))); + QAction * pAction = m->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Terminal)), __tr2qs("Open &Terminal"), this, SLOT(actionTriggeredBool(bool))); pAction->setData(KVI_INTERNALCOMMAND_TERM_OPEN); #endif @@ -377,7 +367,7 @@ void KviMenuBar::setupToolsPopup(QMenu * pop) void KviMenuBar::modulesToolsTriggered(QAction * pAction) { - bool bOk = false; + bool bOk; int idext = pAction->data().toInt(&bOk); if(bOk) g_pModuleExtensionManager->allocateExtension("tool", idext, m_pFrm->firstConsole()); @@ -394,12 +384,7 @@ void KviMenuBar::updateToolbarsPopup() int KviMenuBar::getDefaultItemRealIndex(int iDefaultIndex) { - if(iDefaultIndex < 0) - iDefaultIndex = 0; - if(iDefaultIndex > actions().count()) - iDefaultIndex = actions().count(); - - return iDefaultIndex; + return std::clamp(iDefaultIndex, 0, actions().count()); } KviScriptMenuBarItem * KviMenuBar::findMenu(const QString & text) @@ -407,10 +392,9 @@ KviScriptMenuBarItem * KviMenuBar::findMenu(const QString & text) if(!m_pScriptItemList) return nullptr; for(KviScriptMenuBarItem * i = m_pScriptItemList->first(); i; i = m_pScriptItemList->next()) - { if(KviQString::equalCI(text, i->szText)) return i; - } + return nullptr; } @@ -419,19 +403,17 @@ KviScriptMenuBarItem * KviMenuBar::findMenu(KviKvsPopupMenu * p) if(!m_pScriptItemList) return nullptr; for(KviScriptMenuBarItem * i = m_pScriptItemList->first(); i; i = m_pScriptItemList->next()) - { if(i->pPopup == p) return i; - } + return nullptr; } bool KviMenuBar::removeMenu(const QString & text) { - KviScriptMenuBarItem * i = findMenu(text); - if(i) + if(KviScriptMenuBarItem * i = findMenu(text); i) { - disconnect(i->pPopup, SIGNAL(destroyed()), this, SLOT(menuDestroyed())); + disconnect(i->pPopup, &KviKvsPopupMenu::destroyed, this, &KviMenuBar::menuDestroyed); removeAction(i->pPopup->menuAction()); m_pScriptItemList->removeRef(i); return true; @@ -441,8 +423,7 @@ bool KviMenuBar::removeMenu(const QString & text) void KviMenuBar::menuDestroyed() { - KviScriptMenuBarItem * i = findMenu(((KviKvsPopupMenu *)sender())); - if(i) + if(KviScriptMenuBarItem * i = findMenu(qobject_cast<KviKvsPopupMenu *>(sender())); i) { // No need to remove the associated action: qt already did it (ticket #931) m_pScriptItemList->removeRef(i); @@ -463,14 +444,10 @@ void KviMenuBar::addMenu(const QString & text, KviKvsPopupMenu * p, int index) it->pPopup = p; it->pPopup->menuAction()->setText(text); if(index == -1 || index >= actions().count()) - { addAction(it->pPopup->menuAction()); - } else - { insertAction(actions().value(index), it->pPopup->menuAction()); - } - connect(p, SIGNAL(destroyed()), this, SLOT(menuDestroyed())); + connect(p, &KviKvsPopupMenu::destroyed, this, &KviMenuBar::menuDestroyed); m_pScriptItemList->append(it); } diff --git a/src/kvirc/ui/KviMenuBar.h b/src/kvirc/ui/KviMenuBar.h index 1416a9e1e..4af981d0e 100644 --- a/src/kvirc/ui/KviMenuBar.h +++ b/src/kvirc/ui/KviMenuBar.h @@ -34,12 +34,12 @@ class KviMainWindow; class QAction; class QMenu; -typedef struct _KviScriptMenuBarItem +struct KviScriptMenuBarItem { KviCString szPopupName; KviKvsPopupMenu * pPopup; KviCString szText; -} KviScriptMenuBarItem; +}; class KVIRC_API KviMenuBar : public KviTalMenuBar { @@ -49,14 +49,16 @@ public: ~KviMenuBar(); protected: - QMenu * m_pToolbarsPopup; - QMenu * m_pRecentServersPopup; KviMainWindow * m_pFrm; + QMenu * m_pRecentServersPopup; QMenu * m_pModulesToolsPopup; QMenu * m_pActionsToolsPopup; - KviPointerList<KviScriptMenuBarItem> * m_pScriptItemList; + QMenu * m_pToolbarsPopup; + KviPointerList<KviScriptMenuBarItem> * m_pScriptItemList = nullptr; // Dynamic actions +#ifndef COMPILE_ON_MAC QAction * m_pMenuBarAction; +#endif QAction * m_pStatusBarAction; QAction * m_pWindowListAction; QAction * m_pDisconnectAction; @@ -92,7 +94,7 @@ protected slots: void newConnectionToServer(QAction * pAction); void modulesToolsTriggered(QAction * pAction); void actionTriggered(QAction * pAction); - void actionTriggered(bool); + void actionTriggeredBool(bool); }; #endif //_KVI_MENUBAR_H_ diff --git a/src/kvirc/ui/KviModeEditor.cpp b/src/kvirc/ui/KviModeEditor.cpp index 5a05289cd..daa4c1db2 100644 --- a/src/kvirc/ui/KviModeEditor.cpp +++ b/src/kvirc/ui/KviModeEditor.cpp @@ -437,7 +437,7 @@ void KviModeEditor::commit() emit done(); } -inline const QString * KviModeEditor::getModeDescription(char cMode) +const QString * KviModeEditor::getModeDescription(char cMode) { if(!m_pChannel) return nullptr; @@ -447,10 +447,10 @@ inline const QString * KviModeEditor::getModeDescription(char cMode) return nullptr; } -inline bool KviModeEditor::modeNeedsParameterOnlyWhenSet(char cMode) +bool KviModeEditor::modeNeedsParameterOnlyWhenSet(char cMode) { if(!m_pChannel) - return 0; + return false; KviIrcConnectionServerInfo * pServerInfo = m_pChannel->serverInfo(); if(pServerInfo) return pServerInfo->supportedParameterWhenSetModes().contains(cMode); diff --git a/src/kvirc/ui/KviModeEditor.h b/src/kvirc/ui/KviModeEditor.h index 7c23d6795..8fe020186 100644 --- a/src/kvirc/ui/KviModeEditor.h +++ b/src/kvirc/ui/KviModeEditor.h @@ -57,7 +57,7 @@ protected: const QString * getModeDescription(char cMode); bool modeNeedsParameterOnlyWhenSet(char cMode); signals: - void setMode(QString & szMode); + void setMode(const QString & szMode); void done(); protected slots: void checkBoxToggled(bool bChecked); diff --git a/src/kvirc/ui/KviModeWidget.cpp b/src/kvirc/ui/KviModeWidget.cpp index f95a75cfd..4e58784b0 100644 --- a/src/kvirc/ui/KviModeWidget.cpp +++ b/src/kvirc/ui/KviModeWidget.cpp @@ -22,20 +22,18 @@ // //============================================================================ +#include "KviModeWidget.h" #include "KviChannelWindow.h" -#include "KviOptions.h" #include "KviIrcConnectionServerInfo.h" #include "KviIrcConnectionUserInfo.h" +#include "KviOptions.h" #include "KviTalHBox.h" -#include <QEvent> -#include <QResizeEvent> -#include <QByteArray> +#include <QKeyEvent> -KviModeWidget::KviModeWidget(QWidget * par, KviChannelWindow * chan, const char * name) - : KviThemedLineEdit(par, chan, name) +KviModeWidget::KviModeWidget(QWidget * par, KviChannelWindow & chan, const char * name) + : KviThemedLineEdit(par, &chan, name), m_Channel(chan) { - m_pChannel = chan; reset(); } @@ -47,20 +45,18 @@ void KviModeWidget::reset() setReadOnly(true); refreshModes(); - if(m_pChannel->input()) - m_pChannel->setFocus(); + if(m_Channel.input()) + m_Channel.setFocus(); } void KviModeWidget::refreshModes() { - QString szMode; - m_pChannel->getChannelModeStringWithEmbeddedParams(szMode); - setText(szMode); + setText(m_Channel.getChannelModeStringWithEmbeddedParams()); } void KviModeWidget::mouseDoubleClickEvent(QMouseEvent *) { - if(m_pChannel->isMeHalfOp(true) || m_pChannel->connection()->userInfo()->hasUserMode('o') || m_pChannel->connection()->userInfo()->hasUserMode('O')) + if(m_Channel.isMeHalfOp(true) || m_Channel.connection()->userInfo()->hasUserMode('o') || m_Channel.connection()->userInfo()->hasUserMode('O')) { setReadOnly(false); } @@ -72,7 +68,7 @@ void KviModeWidget::keyReleaseEvent(QKeyEvent * e) { case Qt::Key_Return: case Qt::Key_Enter: - editorReturnPressed(); + processModeChanges(); break; case Qt::Key_Escape: reset(); @@ -83,200 +79,122 @@ void KviModeWidget::keyReleaseEvent(QKeyEvent * e) } } -void KviModeWidget::editorReturnPressed() +void KviModeWidget::processModeChanges() { - QMap<char, QString> szPlusModes; - QMap<char, QString> szMinusModes; + auto szOldModes = m_Channel.getChannelModeStringWithEmbeddedParams(); + auto newModesDict = parseChannelModeString(text()); + auto oldModesDict = parseChannelModeString(szOldModes); - QString szTmpMode; - m_pChannel->getChannelModeStringWithEmbeddedParams(szTmpMode); - QStringList szOldModes = szTmpMode.split(QChar(' '), QString::SkipEmptyParts); - QStringList szNewModes = text().split(QChar(' '), QString::SkipEmptyParts); + std::vector<std::pair<QChar, QString>> removeModes; + std::vector<std::pair<QChar, QString>> addModes; - //add new modes and modified ones - for(int i = 0; i < szNewModes.count(); ++i) + for(const auto & modeIter : oldModesDict) { - QString szSubstring = szNewModes.at(i); - if(i) - { - // not first part: mode with parameter - if(szSubstring.size() < 3) - continue; - if(szSubstring.at(1) != QChar(':')) - continue; - char cMode = szSubstring.at(0).unicode(); - szSubstring.remove(0, 2); - - if(!m_pChannel->hasChannelMode(cMode) || (szSubstring != m_pChannel->channelModeParam(cMode))) - { - // mode was not set before, or the parameter has changed - szPlusModes.insert(cMode, szSubstring); - } - } - else + const QChar & cMode = modeIter.first; + const QString & szParam = modeIter.second; + if(!newModesDict.count(cMode)) { - // first part: parameterless modes - QString szCurModes = szOldModes.count() ? szOldModes.at(0) : ""; - for(auto j : szSubstring) - { - char cMode = j.unicode(); - if(!szCurModes.contains(cMode)) - { - // was not set, has to be inserted - szPlusModes.insert(cMode, QString()); - } - } + if(!isParameterOnlyNeededWhenModeIsSet(cMode)) + removeModes.emplace_back(cMode, szParam); + else + removeModes.emplace_back(cMode, QString{}); } } - // check for any mode that has been unset - for(int i = 0; i < szOldModes.count(); ++i) + for(const auto & modeIter : newModesDict) { - QString szSubstring = szOldModes.at(i); - if(i) + const QChar & cMode = modeIter.first; + const QString & szParam = modeIter.second; + if(!oldModesDict.count(cMode)) + addModes.emplace_back(cMode, szParam); + else if(oldModesDict[cMode] != newModesDict[cMode]) { - // not first part: mode with parameter - if(szSubstring.size() < 3) - continue; - if(szSubstring.at(1) != QChar(':')) - continue; - char cMode = szSubstring.at(0).unicode(); - szSubstring.remove(0, 2); - - // we skip parameterless modes (j=0) - bool bStillSet = false; - for(int j = 1; j < szNewModes.length(); ++j) - { - if(szNewModes.at(j).at(0) == cMode) - bStillSet = true; - } - if(!bStillSet) - { - // checks if this specific mode does not need a parameter when set - if(modeNeedsParameterOnlyWhenSet(cMode)) - { - szMinusModes.insert(cMode, QString()); - } - else - { - szMinusModes.insert(cMode, szSubstring); - } - } - } - else - { - // first part: parameterless modes - QString szNewParameterLessModes = szNewModes.count() ? szNewModes.at(0) : ""; - for(auto j : szSubstring) - { - char cMode = j.unicode(); - if(!szNewParameterLessModes.contains(cMode)) - { - // was set, has to be unset - szMinusModes.insert(cMode, QString()); - } - } + if(!isParameterOnlyNeededWhenModeIsSet(cMode)) + removeModes.emplace_back(cMode, oldModesDict[cMode]); + addModes.emplace_back(cMode, szParam); } } - // now flush out mode changes - int iModesPerLine = 3; // a good default - KviIrcConnectionServerInfo * pServerInfo = nullptr; - if(m_pChannel) - pServerInfo = m_pChannel->serverInfo(); + int iModesPerLine = 3; + KviIrcConnectionServerInfo * pServerInfo = m_Channel.serverInfo(); if(pServerInfo) - { - iModesPerLine = pServerInfo->maxModeChanges(); - if(iModesPerLine < 1) - iModesPerLine = 1; - } + iModesPerLine = std::max(1, pServerInfo->maxModeChanges()); - QString szModes; - QStringList szParameters; int iModes = 0; - - QMap<char, QString>::const_iterator iter = szMinusModes.constBegin(); - while(iter != szMinusModes.constEnd()) + QString szModeChanges; + QStringList params; + for(const auto & modeChange : removeModes) { - if(iter == szMinusModes.constBegin()) - szModes.append("-"); - szModes.append(iter.key()); - szParameters.append(iter.value()); + if(szModeChanges.isEmpty()) + szModeChanges += QChar('-'); + szModeChanges += modeChange.first; + if(!modeChange.second.isEmpty()) + params << modeChange.second; ++iModes; - ++iter; - - //time to commit? if(iModes == iModesPerLine) { - QString szCommitModes = szModes; - if(iter == szMinusModes.constEnd()) - szModes.clear(); - else - szModes = "-"; - if(szParameters.count()) - { - szCommitModes.append(QChar(' ')); - szCommitModes.append(szParameters.join(QString(" "))); - szParameters.clear(); - } + sendModeChanges(std::move(szModeChanges), std::move(params)); iModes = 0; - - emit setMode(szCommitModes); } } - iter = szPlusModes.constBegin(); - while(iter != szPlusModes.constEnd()) + if(!addModes.empty()) + szModeChanges += QChar('+'); + + for(const auto & modeChange : addModes) { - if(iter == szPlusModes.constBegin()) - szModes.append("+"); - szModes.append(iter.key()); - szParameters.append(iter.value()); + if(szModeChanges.isEmpty()) + szModeChanges += QChar('+'); + szModeChanges += modeChange.first; + if(!modeChange.second.isEmpty()) + params << modeChange.second; ++iModes; - ++iter; - - //time to commit? this should be an ==, but includes the minus sign so "+aaa" = 4 chars if(iModes == iModesPerLine) { - QString szCommitModes = szModes; - if(iter == szPlusModes.constEnd()) - szModes.clear(); - else - szModes = "+"; - if(szParameters.count()) - { - szCommitModes.append(QChar(' ')); - szCommitModes.append(szParameters.join(QString(" "))); - szParameters.clear(); - } + sendModeChanges(std::move(szModeChanges), std::move(params)); iModes = 0; - - emit setMode(szCommitModes); } } - if(iModes) - { - QString szCommitModes = szModes; - szModes.clear(); - if(szParameters.count()) - { - szCommitModes.append(QChar(' ')); - szCommitModes.append(szParameters.join(QString(" "))); - szParameters.clear(); - } - emit setMode(szCommitModes); - } + if(iModes != 0) + sendModeChanges(std::move(szModeChanges), std::move(params)); reset(); } -inline bool KviModeWidget::modeNeedsParameterOnlyWhenSet(char cMode) +bool KviModeWidget::isParameterOnlyNeededWhenModeIsSet(const QChar & cMode) { - KviIrcConnectionServerInfo * pServerInfo = nullptr; - if(m_pChannel) - pServerInfo = m_pChannel->serverInfo(); + KviIrcConnectionServerInfo * pServerInfo = m_Channel.serverInfo(); if(pServerInfo) return pServerInfo->supportedParameterWhenSetModes().contains(cMode); return false; } + +std::map<QChar, QString> KviModeWidget::parseChannelModeString(const QString& szModes) +{ + std::map<QChar, QString> modeDict; + + for(const auto & szSubstring : szModes.split(QChar(' '), QString::SkipEmptyParts)) + { + if(szSubstring.size() >= 3 && szSubstring.at(1) == QChar(':')) + { + QChar cMode = szSubstring.at(0); + modeDict[cMode] = szSubstring.mid(2); + } + else + { + for(const auto & cMode : szSubstring) + modeDict[cMode] = QString{}; + } + } + + return modeDict; +} + +void KviModeWidget::sendModeChanges(const QString szModeString, const QStringList params) +{ + if(!params.isEmpty()) + emit setMode(szModeString + QChar(' ') + params.join(QChar(' '))); + else + emit setMode(szModeString); +} diff --git a/src/kvirc/ui/KviModeWidget.h b/src/kvirc/ui/KviModeWidget.h index 0aea5182f..017862108 100644 --- a/src/kvirc/ui/KviModeWidget.h +++ b/src/kvirc/ui/KviModeWidget.h @@ -1,5 +1,5 @@ -#ifndef _KVI_MODEW_H_ -#define _KVI_MODEW_H_ +#ifndef _KVI_MODEWIDGET_H_ +#define _KVI_MODEWIDGET_H_ //============================================================================ // // File : KviModeWidget.h @@ -26,30 +26,38 @@ #include "KviThemedLineEdit.h" +#include <map> + class KviChannelWindow; class KviIrcConnectionServerInfo; class KVIRC_API KviModeWidget : public KviThemedLineEdit { Q_OBJECT - public: - KviModeWidget(QWidget * par, KviChannelWindow * chan, const char * name = 0); + KviModeWidget(QWidget * par, KviChannelWindow & chan, const char * name = nullptr); ~KviModeWidget(); + void reset(); void refreshModes(); private: - KviChannelWindow * m_pChannel; + KviChannelWindow & m_Channel; + + std::map<QChar, QString> parseChannelModeString(const QString& szModes); + void sendModeChanges(const QString szModeString, const QStringList params); protected: - void mouseDoubleClickEvent(QMouseEvent * e); - void keyReleaseEvent(QKeyEvent * e); - bool modeNeedsParameterOnlyWhenSet(char cMode); + void mouseDoubleClickEvent(QMouseEvent * e) override; + void keyReleaseEvent(QKeyEvent * e) override; + + bool isParameterOnlyNeededWhenModeIsSet(const QChar & cMode); + public slots: - void editorReturnPressed(); + void processModeChanges(); + signals: - void setMode(QString & szMode); + void setMode(const QString & szMode); }; -#endif //_KVI_MODEW_H_ +#endif //_KVI_MODEWIDGET_H_ diff --git a/src/kvirc/ui/KviOptionsWidget.cpp b/src/kvirc/ui/KviOptionsWidget.cpp index 46794891a..2e8dbc62f 100644 --- a/src/kvirc/ui/KviOptionsWidget.cpp +++ b/src/kvirc/ui/KviOptionsWidget.cpp @@ -71,7 +71,7 @@ KviOptionsWidget::~KviOptionsWidget() void KviOptionsWidget::mergeTip(QWidget * w, const QString & tip) { - static QString begin = "<table width=\"100%\"><tr><td bgcolor=\"#fefef0\"><font color=\"#000000\">"; + static QString begin = R"(<table width="100%"><tr><td bgcolor="#fefef0"><font color="#000000">)"; static QString mid = "</font></td></tr><tr><td>"; static QString end = "</td></tr></table>"; diff --git a/src/kvirc/ui/KviOptionsWidget.h b/src/kvirc/ui/KviOptionsWidget.h index e28394d24..d0ff568df 100644 --- a/src/kvirc/ui/KviOptionsWidget.h +++ b/src/kvirc/ui/KviOptionsWidget.h @@ -40,7 +40,7 @@ class KVIRC_API KviOptionsWidget : public QFrame, public KviSelectorInterface { Q_OBJECT public: - KviOptionsWidget(QWidget * parent, const char * name = 0, bool bSunken = true); + KviOptionsWidget(QWidget * parent, const char * name = nullptr, bool bSunken = true); ~KviOptionsWidget(); private: @@ -149,10 +149,10 @@ public: void removeSelector(KviSelectorInterface * pInterface); - virtual void commit(); - virtual void childEvent(QChildEvent * e); + void commit() override; + void childEvent(QChildEvent * e) override; - virtual bool eventFilter(QObject * watched, QEvent * e); + bool eventFilter(QObject * watched, QEvent * e) override; protected slots: // this is internal to the options dialog (options module) diff --git a/src/kvirc/ui/KviQueryWindow.cpp b/src/kvirc/ui/KviQueryWindow.cpp index e45023604..fb0ab6555 100644 --- a/src/kvirc/ui/KviQueryWindow.cpp +++ b/src/kvirc/ui/KviQueryWindow.cpp @@ -200,7 +200,7 @@ QString KviQueryWindow::getInfoLabelText() szTmp += "\n"; - if(connection()->getCommonChannels(m_szName, szChans, 0)) + if(connection()->getCommonChannels(m_szName, szChans, false)) szTmp += __tr2qs("Common channels: %2").arg(szChans); else szTmp += __tr2qs("No common channels"); @@ -629,7 +629,7 @@ void KviQueryWindow::ownMessage(const QString & szBuffer, bool bUserFeedback) // first part (optimization): quickly find an high index that is _surely_lesser_ // than the correct one - while(1) + while(true) { iC++; szTmp = pEncoder->fromUnicode(szTmpBuffer.left(iPos)); @@ -647,7 +647,7 @@ void KviQueryWindow::ownMessage(const QString & szBuffer, bool bUserFeedback) // now, do it the simple way: increment our index until we perfectly fit into the // available space - while(1) + while(true) { iC++; @@ -752,7 +752,7 @@ void KviQueryWindow::ownAction(const QString & szBuffer) if(!connection()->sendFmtData("PRIVMSG %s :%cACTION %s%c", name.data(), 0x01, szEncrypted.ptr(), 0x01)) return; - output(KVI_OUT_ACTIONCRYPTED, "\r!nc\r%Q\r %Q", &szMyName, &szTmpBuffer); + output(KVI_OUT_OWNACTIONCRYPTED, "\r!nc\r%Q\r %Q", &szMyName, &szTmpBuffer); } break; case KviCryptEngine::Encoded: @@ -763,7 +763,7 @@ void KviQueryWindow::ownAction(const QString & szBuffer) // ugly, but we must redecode here QString szRedecoded = decodeText(szEncrypted.ptr()); - output(KVI_OUT_ACTIONCRYPTED, "\r!nc\r%Q\r %Q", &szMyName, &szRedecoded); + output(KVI_OUT_OWNACTIONCRYPTED, "\r!nc\r%Q\r %Q", &szMyName, &szRedecoded); } break; default: // also case KviCryptEngine::EncryptError @@ -789,6 +789,6 @@ void KviQueryWindow::ownAction(const QString & szBuffer) if(!connection()->sendFmtData("PRIVMSG %s :%cACTION %s%c", name.data(), 0x01, data.data(), 0x01)) return; - output(KVI_OUT_ACTION, "\r!nc\r%Q\r %Q", &szMyName, &szTmpBuffer); + output(KVI_OUT_OWNACTION, "\r!nc\r%Q\r %Q", &szMyName, &szTmpBuffer); m_pUserListView->userAction(szMyName, KVI_USERACTION_ACTION); } diff --git a/src/kvirc/ui/KviQueryWindow.h b/src/kvirc/ui/KviQueryWindow.h index c1dcc687d..20e8d91ff 100644 --- a/src/kvirc/ui/KviQueryWindow.h +++ b/src/kvirc/ui/KviQueryWindow.h @@ -109,13 +109,13 @@ public: * \brief Returns the size of the query object * \return QSize */ - virtual QSize sizeHint() const; + QSize sizeHint() const override; /** * \brief Returns the name of the query target * \return const QString & */ - virtual const QString & target() { return windowName(); }; + const QString & target() override { return windowName(); } /** * \brief Sets the target of the query @@ -130,13 +130,13 @@ public: * \brief Returns the button container * \return QFrame * */ - QFrame * buttonContainer() { return (QFrame *)m_pButtonGrid; }; + QFrame * buttonContainer() override { return (QFrame *)m_pButtonGrid; } /** * \brief Applies the options * \return void */ - virtual void applyOptions(); + void applyOptions() override; /** * \brief Called when a user performs an action @@ -178,14 +178,14 @@ public: * \param bUserFeedback Whether to display the echo feedback to the user * \return void */ - void ownMessage(const QString & szBuffer, bool bUserFeedback = true); + void ownMessage(const QString & szBuffer, bool bUserFeedback = true) override; /** * \brief Called when we perform an action * \param szBuffer The buffer :) * \return void */ - void ownAction(const QString & szBuffer); + void ownAction(const QString & szBuffer) override; /** * \brief Returns the number of selected users in the userlist @@ -255,48 +255,48 @@ protected: * \brief Gets the window list and info label tooltip text * \return QString */ - virtual void getWindowListTipText(QString & szBuffer); + void getWindowListTipText(QString & szBuffer) override; /** * \brief Returns the icon associated to the query * \return QPixmap * */ - virtual QPixmap * myIconPtr(); + QPixmap * myIconPtr() override; /** * \brief Fills in the caption buffers * \return void */ - virtual void fillCaptionBuffers(); + void fillCaptionBuffers() override; /** * \brief Loads the properties from file * \param pCfg The configuration file * \return void */ - virtual void loadProperties(KviConfigurationFile * pCfg); + void loadProperties(KviConfigurationFile * pCfg) override; /** * \brief Saves the properties to file * \param pCfg The configuration file * \return void */ - virtual void saveProperties(KviConfigurationFile * pCfg); + void saveProperties(KviConfigurationFile * pCfg) override; /** * \brief Gets the base of the log file name * \param szBuffer The buffer where to save the info * \return void */ - virtual void getBaseLogFileName(QString & szBuffer); + void getBaseLogFileName(QString & szBuffer) override; /** * \brief Trigger the OnQueryWindowCreated event * \return void */ - virtual void triggerCreationEvents(); + void triggerCreationEvents() override; - virtual void resizeEvent(QResizeEvent *); + void resizeEvent(QResizeEvent *) override; protected slots: /** * \brief Triggers the OnQueryPopupRequest event diff --git a/src/kvirc/ui/KviScriptEditor.h b/src/kvirc/ui/KviScriptEditor.h index da014f997..1235651df 100644 --- a/src/kvirc/ui/KviScriptEditor.h +++ b/src/kvirc/ui/KviScriptEditor.h @@ -47,9 +47,6 @@ class KVIRC_API KviScriptEditor : public QWidget protected: KviScriptEditor(QWidget * par) : QWidget(par){}; -protected: - QLineEdit * m_pFindLineedit; - public: virtual void setText(const char * txt) { setText(QByteArray(txt)); }; virtual void setText(const QByteArray & txt){}; diff --git a/src/kvirc/ui/KviSelectors.cpp b/src/kvirc/ui/KviSelectors.cpp index aab24c34f..d8fb5fb9d 100644 --- a/src/kvirc/ui/KviSelectors.cpp +++ b/src/kvirc/ui/KviSelectors.cpp @@ -706,7 +706,7 @@ KviMircTextColorSelector::KviMircTextColorSelector(QWidget * par, const QString m_pForePopup = new QMenu(this); connect(m_pForePopup, SIGNAL(triggered(QAction *)), this, SLOT(foreSelected(QAction *))); int iColor; - for(iColor = 0; iColor < KVI_MIRCCOLOR_MAX_FOREGROUND; iColor++) + for(iColor = 0; iColor < KVI_MIRCCOLOR_MAX; iColor++) { QPixmap tmp(120, 16); tmp.fill(KVI_OPTION_MIRCCOLOR(iColor)); @@ -721,7 +721,7 @@ KviMircTextColorSelector::KviMircTextColorSelector(QWidget * par, const QString connect(m_pBackPopup, SIGNAL(triggered(QAction *)), this, SLOT(backSelected(QAction *))); pAction = m_pBackPopup->addAction(__tr2qs("Transparent")); pAction->setData(KviControlCodes::Transparent); - for(iColor = 0; iColor < KVI_MIRCCOLOR_MAX_BACKGROUND; iColor++) + for(iColor = 0; iColor < KVI_MIRCCOLOR_MAX; iColor++) { QPixmap tmp(120, 16); tmp.fill(KVI_OPTION_MIRCCOLOR(iColor)); @@ -753,7 +753,7 @@ void KviMircTextColorSelector::setButtonPalette() { QPalette pal; - if(m_uBack > KVI_MIRCCOLOR_MAX_BACKGROUND) + if(m_uBack > KVI_MIRCCOLOR_MAX) { if(m_uBack != KviControlCodes::Transparent) m_uBack = KviControlCodes::Transparent; @@ -764,8 +764,8 @@ void KviMircTextColorSelector::setButtonPalette() pal = QPalette(KVI_OPTION_MIRCCOLOR(m_uBack)); } - if(m_uFore > KVI_MIRCCOLOR_MAX_FOREGROUND) - m_uFore = KVI_MIRCCOLOR_MAX_FOREGROUND; + if(m_uFore > KVI_MIRCCOLOR_MAX) + m_uFore = KVI_MIRCCOLOR_MAX; pal.setColor(QPalette::ButtonText, KVI_OPTION_MIRCCOLOR(m_uFore)); pal.setColor(QPalette::Text, KVI_OPTION_MIRCCOLOR(m_uFore)); diff --git a/src/kvirc/ui/KviSelectors.h b/src/kvirc/ui/KviSelectors.h index 961f5448e..00a7f8191 100644 --- a/src/kvirc/ui/KviSelectors.h +++ b/src/kvirc/ui/KviSelectors.h @@ -52,7 +52,7 @@ public: public: virtual void commit(){}; virtual QString textForSearch() { return QString(); }; - virtual QWidget * widgetToHighlight() { return 0; }; + virtual QWidget * widgetToHighlight() { return nullptr; }; }; class KVIRC_API KviBoolSelector : public QCheckBox, public KviSelectorInterface diff --git a/src/kvirc/ui/KviStatusBar.cpp b/src/kvirc/ui/KviStatusBar.cpp index 8aed13490..20f2308dd 100644 --- a/src/kvirc/ui/KviStatusBar.cpp +++ b/src/kvirc/ui/KviStatusBar.cpp @@ -312,7 +312,7 @@ void KviStatusBar::tipRequest(QHelpEvent * e) QString szTip; if(pApplet) { - szTip = "<table style=\"white-space: pre\"><tr><td bgcolor=\"#303030\" align=\"center\"><font color=\"#ffffff\"><b>" + pApplet->descriptor()->visibleName() + "</b></font></td></tr>"; + szTip = R"(<table style="white-space: pre"><tr><td bgcolor="#303030" align="center"><font color="#ffffff"><b>)" + pApplet->descriptor()->visibleName() + "</b></font></td></tr>"; QString szTipx = pApplet->tipText(pApplet->mapFromGlobal(mapToGlobal(e->pos()))); if(!szTipx.isEmpty()) @@ -322,7 +322,7 @@ void KviStatusBar::tipRequest(QHelpEvent * e) szTip += "</td></tr><tr><td align=\"center\"><hr></td></tr>"; } - szTip += "<tr><td><font color=\"#636363\" size=\"-1\">"; + szTip += R"(<tr><td><font color="#636363" size="-1">)"; szTip += __tr2qs("<b>Shift+Drag</b> or <b>Ctrl+Drag</b> to move the applet around"); szTip += "<br>"; szTip += __tr2qs("Right-click to see the other options"); diff --git a/src/kvirc/ui/KviStatusBar.h b/src/kvirc/ui/KviStatusBar.h index 1094b1f50..044f1f871 100644 --- a/src/kvirc/ui/KviStatusBar.h +++ b/src/kvirc/ui/KviStatusBar.h @@ -131,7 +131,6 @@ public: ~KviStatusBar(); protected: - KviTalHBox * m_pBox; KviMainWindow * m_pFrame; KviPointerList<KviStatusBarMessage> * m_pMessageQueue; QTimer * m_pMessageTimer; @@ -143,7 +142,6 @@ protected: KviStatusBarApplet * m_pClickedApplet; int m_iLastMinimumHeight; bool m_bStopLayoutOnAddRemove; - KviDynamicToolTip * m_pToolTip; public: /** @@ -313,12 +311,12 @@ protected slots: void setPermanentMessage(); protected: - virtual void mousePressEvent(QMouseEvent * e); - virtual void mouseDoubleClickEvent(QMouseEvent * e); - virtual bool event(QEvent * e); - void dropEvent(QDropEvent * de); - void dragMoveEvent(QDragMoveEvent * de); - void dragEnterEvent(QDragEnterEvent * event); + void mousePressEvent(QMouseEvent * e) override; + void mouseDoubleClickEvent(QMouseEvent * e) override; + bool event(QEvent * e) override; + void dropEvent(QDropEvent * de) override; + void dragMoveEvent(QDragMoveEvent * de) override; + void dragEnterEvent(QDragEnterEvent * event) override; }; #endif // _KVI_STATUSBAR_H_ diff --git a/src/kvirc/ui/KviStatusBarApplet.cpp b/src/kvirc/ui/KviStatusBarApplet.cpp index bb8660793..0394c31d0 100644 --- a/src/kvirc/ui/KviStatusBarApplet.cpp +++ b/src/kvirc/ui/KviStatusBarApplet.cpp @@ -286,13 +286,10 @@ QString KviStatusBarLagIndicator::tipText(const QPoint &) goto not_connected; if(c->lagMeter()) { - int lll; - if((lll = c->lagMeter()->lag()) > 0) + int lll = c->lagMeter()->lag(); + if(lll > 0) { - int llls = lll / 1000; - int llld = (lll % 1000) / 100; - int lllc = (lll % 100) / 10; - KviQString::appendFormatted(szRet, __tr2qs("Lag: <b>%d.%d%d secs"), llls, llld, lllc); + KviQString::appendFormatted(szRet, __tr2qs("Lag: <b>%d ms"), lll); szRet += "</b><br>"; int vss = c->lagMeter()->secondsSinceLastCompleted(); int vmm = vss / 60; @@ -331,13 +328,10 @@ void KviStatusBarLagIndicator::updateDisplay() KviIrcConnection * ic = c->connection(); if(ic->lagMeter()) { - int lll; - if((lll = ic->lagMeter()->lag()) > 0) + int lll = ic->lagMeter()->lag(); + if(lll > 0) { - int llls = lll / 1000; - int llld = (lll % 1000) / 100; - int lllc = (lll % 100) / 10; - QString szTmp = QString(__tr2qs("Lag: %1.%2%3 secs")).arg(llls).arg(llld).arg(lllc); + QString szTmp = QString(__tr2qs("Lag: %1 ms")).arg(lll); if(lll > 60000) { // one minute lag! @@ -351,7 +345,7 @@ void KviStatusBarLagIndicator::updateDisplay() } } // no lag available - setText(__tr2qs("Lag: ?.??")); + setText(__tr2qs("Lag: ???")); } KviStatusBarApplet * CreateStatusBarLagIndicator(KviStatusBar * pBar, KviStatusBarAppletDescriptor * pDescriptor) @@ -507,7 +501,7 @@ KviStatusBarConnectionTimer::KviStatusBarConnectionTimer(KviStatusBar * pParent, : KviStatusBarApplet(pParent, pDescriptor) { startTimer(1000); - m_bTotal = 0; + m_bTotal = false; QFontMetrics fm(font()); setFixedWidth(fm.width("000 d 00 h 00 m 00 s")); diff --git a/src/kvirc/ui/KviStatusBarApplet.h b/src/kvirc/ui/KviStatusBarApplet.h index 5df4129e4..14bcef6ba 100644 --- a/src/kvirc/ui/KviStatusBarApplet.h +++ b/src/kvirc/ui/KviStatusBarApplet.h @@ -94,14 +94,14 @@ protected: public: KviStatusBarApplet(KviStatusBar * pParent, KviStatusBarAppletDescriptor * pDescriptor); - virtual ~KviStatusBarApplet(); + ~KviStatusBarApplet(); public: KviStatusBar * statusBar() { return m_pStatusBar; }; KviMainWindow * frame() { return m_pStatusBar->frame(); }; KviStatusBarAppletDescriptor * descriptor() { return m_pDescriptor; }; - inline void setIndex(int i) { mIndex = i; }; - inline int index() const { return mIndex; }; + void setIndex(int i) { mIndex = i; } + int index() const { return mIndex; } protected: virtual void fillContextPopup(QMenu *){}; virtual void loadState(const char *, KviConfigurationFile *){}; @@ -120,7 +120,7 @@ class KviStatusBarClock : public KviStatusBarApplet Q_OBJECT public: KviStatusBarClock(KviStatusBar * pParent, KviStatusBarAppletDescriptor * pDescriptor); - virtual ~KviStatusBarClock(); + ~KviStatusBarClock(); enum Format { HMS, @@ -136,11 +136,11 @@ public: static void selfRegister(KviStatusBar * pBar); protected: - virtual void fillContextPopup(QMenu * p); - virtual void timerEvent(QTimerEvent * e); + void fillContextPopup(QMenu * p) override; + void timerEvent(QTimerEvent * e) override; - virtual void loadState(const char * pcPrefix, KviConfigurationFile * pCfg); - virtual void saveState(const char * pcPrefix, KviConfigurationFile * pCfg); + void loadState(const char * pcPrefix, KviConfigurationFile * pCfg) override; + void saveState(const char * pcPrefix, KviConfigurationFile * pCfg) override; void adjustMinWidth(); protected slots: void toggleUtc(); @@ -153,16 +153,16 @@ class KviStatusBarConnectionTimer : public KviStatusBarApplet Q_OBJECT public: KviStatusBarConnectionTimer(KviStatusBar * pParent, KviStatusBarAppletDescriptor * pDescriptor); - virtual ~KviStatusBarConnectionTimer(); + ~KviStatusBarConnectionTimer(); protected: bool m_bTotal; protected: - virtual void timerEvent(QTimerEvent * e); - virtual void fillContextPopup(QMenu * p); - virtual void loadState(const char * pcPrefix, KviConfigurationFile * pCfg); - virtual void saveState(const char * pcPrefix, KviConfigurationFile * pCfg); + void timerEvent(QTimerEvent * e) override; + void fillContextPopup(QMenu * p) override; + void loadState(const char * pcPrefix, KviConfigurationFile * pCfg) override; + void saveState(const char * pcPrefix, KviConfigurationFile * pCfg) override; public: static void selfRegister(KviStatusBar * pBar); @@ -175,7 +175,7 @@ class KviStatusBarSeparator : public KviStatusBarApplet Q_OBJECT public: KviStatusBarSeparator(KviStatusBar * pParent, KviStatusBarAppletDescriptor * pDescriptor); - virtual ~KviStatusBarSeparator(); + ~KviStatusBarSeparator(); public: static void selfRegister(KviStatusBar * pBar); @@ -186,7 +186,7 @@ class KviStatusBarAwayIndicator : public KviStatusBarApplet Q_OBJECT public: KviStatusBarAwayIndicator(KviStatusBar * pParent, KviStatusBarAppletDescriptor * pDescriptor); - virtual ~KviStatusBarAwayIndicator(); + ~KviStatusBarAwayIndicator(); public: static void selfRegister(KviStatusBar * pBar); @@ -195,11 +195,11 @@ protected: bool m_bAwayOnAllContexts; protected: - virtual void mouseDoubleClickEvent(QMouseEvent * e); - virtual QString tipText(const QPoint &); - virtual void fillContextPopup(QMenu * p); - virtual void loadState(const char * pcPrefix, KviConfigurationFile * pCfg); - virtual void saveState(const char * pcPrefix, KviConfigurationFile * pCfg); + void mouseDoubleClickEvent(QMouseEvent * e) override; + QString tipText(const QPoint &) override; + void fillContextPopup(QMenu * p) override; + void loadState(const char * pcPrefix, KviConfigurationFile * pCfg) override; + void saveState(const char * pcPrefix, KviConfigurationFile * pCfg) override; protected slots: void updateDisplay(); void toggleContext(); @@ -210,14 +210,14 @@ class KviStatusBarLagIndicator : public KviStatusBarApplet Q_OBJECT public: KviStatusBarLagIndicator(KviStatusBar * pParent, KviStatusBarAppletDescriptor * pDescriptor); - virtual ~KviStatusBarLagIndicator(){}; + ~KviStatusBarLagIndicator() = default; public: static void selfRegister(KviStatusBar * pBar); protected: - virtual void mouseDoubleClickEvent(QMouseEvent * e); - virtual QString tipText(const QPoint &); + void mouseDoubleClickEvent(QMouseEvent * e) override; + QString tipText(const QPoint &) override; protected slots: void updateDisplay(); }; @@ -227,15 +227,15 @@ class KviStatusBarUpdateIndicator : public KviStatusBarApplet Q_OBJECT public: KviStatusBarUpdateIndicator(KviStatusBar * pParent, KviStatusBarAppletDescriptor * pDescriptor); - virtual ~KviStatusBarUpdateIndicator(); + ~KviStatusBarUpdateIndicator(); static void selfRegister(KviStatusBar * pBar); protected: - virtual void mouseDoubleClickEvent(QMouseEvent * e); - virtual QString tipText(const QPoint &); - virtual void fillContextPopup(QMenu * p); - virtual void loadState(const char * pcPrefix, KviConfigurationFile * pCfg); - virtual void saveState(const char * pcPrefix, KviConfigurationFile * pCfg); + void mouseDoubleClickEvent(QMouseEvent * e) override; + QString tipText(const QPoint &) override; + void fillContextPopup(QMenu * p) override; + void loadState(const char * pcPrefix, KviConfigurationFile * pCfg) override; + void saveState(const char * pcPrefix, KviConfigurationFile * pCfg) override; void checkVersion(); void getNewVersion(); protected slots: diff --git a/src/kvirc/ui/KviTextIconWindow.cpp b/src/kvirc/ui/KviTextIconWindow.cpp index 1aa861507..b71443de8 100644 --- a/src/kvirc/ui/KviTextIconWindow.cpp +++ b/src/kvirc/ui/KviTextIconWindow.cpp @@ -23,29 +23,28 @@ //============================================================================= #include "KviTextIconWindow.h" -#include "KviTextIconManager.h" #include "KviApplication.h" -#include "KviOptions.h" -#include "KviInput.h" -#include "KviTopicWidget.h" +#include "KviCaster.h" #include "KviControlCodes.h" #include "KviIconManager.h" -#include "KviCaster.h" +#include "KviInput.h" +#include "KviInputEditor.h" +#include "KviOptions.h" +#include "KviTextIconManager.h" +#include "KviTopicWidget.h" -#include <QPainter> -#include <QLineEdit> #include <QEvent> -#include <QKeyEvent> #include <QHeaderView> -#include <QPalette> +#include <QKeyEvent> +#include <QLineEdit> +#include <QPainter> #include <QScrollBar> +#include <QTableWidget> +#include <limits> KviTextIconWindow::KviTextIconWindow() : QWidget(nullptr, Qt::Popup) { - m_pOwner = nullptr; - m_bAltMode = false; - setFixedSize(KVI_TEXTICON_WIN_WIDTH, KVI_TEXTICON_WIN_HEIGHT); m_pTable = new QTableWidget(this); @@ -61,8 +60,8 @@ KviTextIconWindow::KviTextIconWindow() m_pTable->installEventFilter(this); - connect(g_pTextIconManager, SIGNAL(changed()), this, SLOT(fill())); - connect(m_pTable, SIGNAL(cellClicked(int, int)), this, SLOT(cellSelected(int, int))); + connect(g_pTextIconManager, &KviTextIconManager::changed, this, &KviTextIconWindow::fill); + connect(m_pTable, &QTableWidget::cellClicked, this, &KviTextIconWindow::cellSelected); } KviTextIconWindow::~KviTextIconWindow() @@ -85,13 +84,12 @@ void KviTextIconWindow::fill() KviPointerHashTableIterator<QString, KviTextIcon> it(*pDict); int iCol = KVI_TEXTICON_COLUMNS; - QLabel * newItem; while(KviTextIcon * pIcon = it.current()) { QPixmap * pPix = pIcon->pixmap(); if(pPix) { - newItem = new QLabel(); + QLabel * newItem = new QLabel; newItem->setToolTip(it.currentKey()); newItem->setPixmap(*pPix); newItem->setAlignment(Qt::AlignCenter); @@ -115,10 +113,10 @@ void KviTextIconWindow::popup(QWidget * pOwner, bool bAltMode) m_bAltMode = bAltMode; if(m_pOwner) - disconnect(m_pOwner, SIGNAL(destroyed()), this, SLOT(ownerDead())); + disconnect(m_pOwner, &QWidget::destroyed, this, &KviTextIconWindow::ownerDead); m_pOwner = pOwner; - connect(m_pOwner, SIGNAL(destroyed()), this, SLOT(ownerDead())); + connect(m_pOwner, &QWidget::destroyed, this, &KviTextIconWindow::ownerDead); show(); @@ -161,12 +159,12 @@ bool KviTextIconWindow::eventFilter(QObject * o, QEvent * e) break; default: // redirect to owner - if(m_pOwner->inherits("KviInputEditor")) + if(KviInputEditor * pOwner = qobject_cast<KviInputEditor *>(m_pOwner); pOwner) { if(e->type() == QEvent::KeyPress) - ((KviInputEditor *)m_pOwner)->keyPressEvent(ev); + pOwner->keyPressEvent(ev); else - ((KviInputEditor *)m_pOwner)->keyReleaseEvent(ev); + pOwner->keyReleaseEvent(ev); autoSelectBestMatchBasedOnOwnerText(); return true; } @@ -179,10 +177,11 @@ bool KviTextIconWindow::eventFilter(QObject * o, QEvent * e) void KviTextIconWindow::autoSelectBestMatchBasedOnOwnerText() { - if(!m_pOwner->inherits("KviInputEditor")) + KviInputEditor * pOwner = qobject_cast<KviInputEditor *>(m_pOwner); + if(!pOwner) return; - QString szText = ((KviInputEditor *)m_pOwner)->textBeforeCursor(); + QString szText = pOwner->textBeforeCursor(); int idx = szText.lastIndexOf(QChar(KviControlCodes::Icon)); if(idx < 0) return; @@ -197,7 +196,7 @@ void KviTextIconWindow::autoSelectBestMatchBasedOnOwnerText() int iBestR = -1; int iBestC = -1; - int iBestLen = 999999; + int iBestLen = std::numeric_limits<int>::max(); for(int r = 0; r < iRows; r++) { @@ -211,7 +210,7 @@ void KviTextIconWindow::autoSelectBestMatchBasedOnOwnerText() continue; // good. - if((iBestR == -1) || (txt.length() < iBestLen)) + if(txt.length() < iBestLen) { iBestR = r; iBestC = c; @@ -243,22 +242,22 @@ void KviTextIconWindow::cellSelected(int row, int column) if(!m_pTable->cellWidget(row, column)) return; - QString szItem(m_pTable->cellWidget(row, column)->toolTip()); + QString szItem = m_pTable->cellWidget(row, column)->toolTip(); if(m_bAltMode) szItem.prepend(KviControlCodes::Icon); - if(m_pOwner->inherits("KviInputEditor")) - ((KviInputEditor *)m_pOwner)->insertIconCode(szItem); - else if(m_pOwner->inherits("KviInput")) - ((KviInput *)m_pOwner)->insertText(QString("%1 ").arg(szItem)); - else if(m_pOwner->inherits("QLineEdit")) + if(KviInputEditor * pOwner = qobject_cast<KviInputEditor *>(m_pOwner); pOwner) + pOwner->insertIconCode(szItem); + else if(KviInput * pOwner = qobject_cast<KviInput *>(m_pOwner); pOwner) + pOwner->insertText(QString("%1 ").arg(szItem)); + else if(QLineEdit * pOwner = qobject_cast<QLineEdit *>(m_pOwner); pOwner) { szItem.append(' '); - QString szTmp = ((QLineEdit *)m_pOwner)->text(); - szTmp.insert(((QLineEdit *)m_pOwner)->cursorPosition(), szItem); - ((QLineEdit *)m_pOwner)->setText(szTmp); - ((QLineEdit *)m_pOwner)->setCursorPosition(((QLineEdit *)m_pOwner)->cursorPosition() + szItem.length()); + QString szTmp = pOwner->text(); + szTmp.insert(pOwner->cursorPosition(), szItem); + pOwner->setText(szTmp); + pOwner->setCursorPosition(pOwner->cursorPosition() + szItem.length()); } doHide(); } diff --git a/src/kvirc/ui/KviTextIconWindow.h b/src/kvirc/ui/KviTextIconWindow.h index 63b528321..7ab8d7dda 100644 --- a/src/kvirc/ui/KviTextIconWindow.h +++ b/src/kvirc/ui/KviTextIconWindow.h @@ -24,25 +24,15 @@ // //============================================================================= -/** -* \file KviTextIconWindow.h -* \author Szymon Stefanek -* \brief Text icon window -* -* \def KVI_TEXTICON_WIN_WIDTH The width of the window -* \def KVI_TEXTICON_WIN_HEIGHT The height of the window -*/ - #include "kvi_settings.h" -#include "KviCString.h" #include "KviIconManager.h" -#include <QPainter> -#include <QTableWidget> +class QTableWidget; + +constexpr int KVI_TEXTICON_WIN_WIDTH = 230; +constexpr int KVI_TEXTICON_WIN_HEIGHT = 200; +constexpr int KVI_TEXTICON_COLUMNS = 6; -#define KVI_TEXTICON_WIN_WIDTH 230 -#define KVI_TEXTICON_WIN_HEIGHT 200 -#define KVI_TEXTICON_COLUMNS 6 /** * \class KviTextIconWindow * \brief Text icon window class @@ -51,21 +41,13 @@ class KVIRC_API KviTextIconWindow : public QWidget { Q_OBJECT public: - /** - * \brief Constructs the text icon window objet - * \return KviTextIconWindow - */ KviTextIconWindow(); - - /** - * \brief Destroys the text icon window objet - */ ~KviTextIconWindow(); private: - QWidget * m_pOwner; + QWidget * m_pOwner = nullptr; QTableWidget * m_pTable; - bool m_bAltMode; // in alt mode the inserted string will contains also the Alt+E escape code + bool m_bAltMode = false; // in alt mode the inserted string will contains also the Alt+E escape code public: /** * \brief Shows the popup @@ -83,7 +65,7 @@ private: void doHide(); private: - virtual bool eventFilter(QObject * o, QEvent * e); + bool eventFilter(QObject * o, QEvent * e) override; void autoSelectBestMatchBasedOnOwnerText(); public slots: diff --git a/src/kvirc/ui/KviThemedComboBox.cpp b/src/kvirc/ui/KviThemedComboBox.cpp index 61f1b5d19..de724e226 100644 --- a/src/kvirc/ui/KviThemedComboBox.cpp +++ b/src/kvirc/ui/KviThemedComboBox.cpp @@ -61,28 +61,35 @@ void KviThemedComboBox::applyOptions() bool bIsTrasparent = false; #endif + // As of 10.09.2017 setting a style sheet with 'background' or 'color' on the QComboBox makes + // Qt go nuts. The console window does not redraw properly and several BadMatch errors appear: + // QXcbConnection: XCB error: 8 (BadMatch), sequence: 1335, resource id: 81789032, major code: 130 (Unknown), minor code: 3 + +#if 0 if(style()->objectName() == "oxygen" || style()->objectName().startsWith("ia-ora-") || style()->objectName() == "breeze") { // workaround for broken oxygen in kde4.4: use palette() instead that stylesheet // ia-ora- are the mandriva default styles +#endif setFont(KVI_OPTION_FONT(KviOption_fontLabel)); QPalette pal = palette(); pal.setBrush(QPalette::Base, bIsTrasparent ? Qt::transparent : KVI_OPTION_COLOR(KviOption_colorLabelBackground)); //qcombobox forces QPalette::Text as its forecolor - pal.setBrush(QPalette::Text, bIsTrasparent ? KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()) : KVI_OPTION_COLOR(KviOption_colorLabelForeground)); + pal.setBrush(QPalette::Text, bIsTrasparent ? getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()) : KVI_OPTION_COLOR(KviOption_colorLabelForeground)); setPalette(pal); - } - else - { +#if 0 + } else { + //QString szStyle = QString("QComboBox { background: %1; color: %2; font-family: %3; font-size: %4pt; font-weight: %5; font-style: %6;}") QString szStyle = QString("QComboBox { background: %1; color: %2; font-family: %3; font-size: %4pt; font-weight: %5; font-style: %6;}") .arg(bIsTrasparent ? "transparent" : KVI_OPTION_COLOR(KviOption_colorLabelBackground).name()) - .arg(bIsTrasparent ? KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name()) + .arg(bIsTrasparent ? getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name()) .arg(KVI_OPTION_FONT(KviOption_fontLabel).family()) .arg(KVI_OPTION_FONT(KviOption_fontLabel).pointSize()) .arg(KVI_OPTION_FONT(KviOption_fontLabel).weight() == QFont::Bold ? "bold" : "normal") .arg(KVI_OPTION_FONT(KviOption_fontLabel).style() == QFont::StyleItalic ? "italic" : "normal"); setStyleSheet(szStyle); } +#endif update(); } diff --git a/src/kvirc/ui/KviThemedComboBox.h b/src/kvirc/ui/KviThemedComboBox.h index c2d6be781..a409decd3 100644 --- a/src/kvirc/ui/KviThemedComboBox.h +++ b/src/kvirc/ui/KviThemedComboBox.h @@ -42,8 +42,8 @@ private: KviWindow * m_pKviWindow; protected: - virtual void paintEvent(QPaintEvent * event); - virtual void keyPressEvent(QKeyEvent * e); + void paintEvent(QPaintEvent * event) override; + void keyPressEvent(QKeyEvent * e) override; public: int dummyRead() const { return 0; }; diff --git a/src/kvirc/ui/KviThemedLabel.cpp b/src/kvirc/ui/KviThemedLabel.cpp index ffded12f8..b8359536d 100644 --- a/src/kvirc/ui/KviThemedLabel.cpp +++ b/src/kvirc/ui/KviThemedLabel.cpp @@ -63,7 +63,7 @@ void KviThemedLabel::applyOptions() QString szStyle = QString("QLabel { background: %1; background-clip: content; color: %2; font-family: %3; font-size: %4pt; font-weight: %5; font-style: %6;}") .arg(bIsTrasparent ? "transparent" : KVI_OPTION_COLOR(KviOption_colorLabelBackground).name()) - .arg(bIsTrasparent ? KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name()) + .arg(bIsTrasparent ? getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name()) .arg(KVI_OPTION_FONT(KviOption_fontLabel).family()) .arg(KVI_OPTION_FONT(KviOption_fontLabel).pointSize()) .arg(KVI_OPTION_FONT(KviOption_fontLabel).weight() == QFont::Bold ? "bold" : "normal") diff --git a/src/kvirc/ui/KviThemedLabel.h b/src/kvirc/ui/KviThemedLabel.h index 90548952f..de54f8d32 100644 --- a/src/kvirc/ui/KviThemedLabel.h +++ b/src/kvirc/ui/KviThemedLabel.h @@ -42,8 +42,8 @@ private: KviWindow * m_pKviWindow; protected: - virtual void paintEvent(QPaintEvent * event); - virtual void mouseDoubleClickEvent(QMouseEvent * e); + void paintEvent(QPaintEvent * event) override; + void mouseDoubleClickEvent(QMouseEvent * e) override; public: int dummyRead() const { return 0; }; diff --git a/src/kvirc/ui/KviThemedLineEdit.cpp b/src/kvirc/ui/KviThemedLineEdit.cpp index 21bcad156..f41d4bf8b 100644 --- a/src/kvirc/ui/KviThemedLineEdit.cpp +++ b/src/kvirc/ui/KviThemedLineEdit.cpp @@ -73,7 +73,7 @@ void KviThemedLineEdit::applyOptions() #endif QString szStyle = QString("QLineEdit { background: %1; color: %2; font-family: %3; font-size: %4pt; font-weight: %5; font-style: %6; margin: 1px; }") .arg(bIsTrasparent ? "transparent" : KVI_OPTION_COLOR(KviOption_colorLabelBackground).name()) - .arg(bIsTrasparent ? KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name()) + .arg(bIsTrasparent ? getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name()) .arg(KVI_OPTION_FONT(KviOption_fontLabel).family()) .arg(KVI_OPTION_FONT(KviOption_fontLabel).pointSize()) .arg(KVI_OPTION_FONT(KviOption_fontLabel).weight() == QFont::Bold ? "bold" : "normal") diff --git a/src/kvirc/ui/KviThemedLineEdit.h b/src/kvirc/ui/KviThemedLineEdit.h index 5bf39578a..4e9e54758 100644 --- a/src/kvirc/ui/KviThemedLineEdit.h +++ b/src/kvirc/ui/KviThemedLineEdit.h @@ -42,7 +42,7 @@ private: KviWindow * m_pKviWindow; protected: - virtual void paintEvent(QPaintEvent * event); + void paintEvent(QPaintEvent * event) override; public: int dummyRead() const { return 0; }; diff --git a/src/kvirc/ui/KviThemedTreeWidget.cpp b/src/kvirc/ui/KviThemedTreeWidget.cpp index 29e850964..5677964d6 100644 --- a/src/kvirc/ui/KviThemedTreeWidget.cpp +++ b/src/kvirc/ui/KviThemedTreeWidget.cpp @@ -57,7 +57,7 @@ void KviThemedTreeWidget::applyOptions() QString szStyle = QString("QTreeWidget { background: %1; background-clip: content; color: %2; font-family: %3; font-size: %4pt; font-weight: %5; font-style: %6;}") .arg(bIsTrasparent ? "transparent" : KVI_OPTION_COLOR(KviOption_colorLabelBackground).name()) - .arg(bIsTrasparent ? KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name()) + .arg(bIsTrasparent ? getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore()).name() : KVI_OPTION_COLOR(KviOption_colorLabelForeground).name()) .arg(KVI_OPTION_FONT(KviOption_fontLabel).family()) .arg(KVI_OPTION_FONT(KviOption_fontLabel).pointSize()) .arg(KVI_OPTION_FONT(KviOption_fontLabel).weight() == QFont::Bold ? "bold" : "normal") diff --git a/src/kvirc/ui/KviToolBar.cpp b/src/kvirc/ui/KviToolBar.cpp index 3b13f57f0..e7f2a12dd 100644 --- a/src/kvirc/ui/KviToolBar.cpp +++ b/src/kvirc/ui/KviToolBar.cpp @@ -23,15 +23,16 @@ //============================================================================= #include "KviToolBar.h" -#include "KviMainWindow.h" -#include "KviLocale.h" #include "KviApplication.h" +#include "KviLocale.h" +#include "KviMainWindow.h" #include "KviOptions.h" +#include <array> #include <QCursor> #include <QEvent> -#include <QMouseEvent> #include <QMenu> +#include <QMouseEvent> static QMenu * g_pToolBarContextPopup = nullptr; static QMenu * g_pToolBarWindowsPopup = nullptr; @@ -75,20 +76,18 @@ KviToolBar::~KviToolBar() } } -#define VALID_ICONSIZES_NUM 2 -static KviToolBar::IconSizes valid_iconsizes[VALID_ICONSIZES_NUM] = { +static const std::array<KviToolBar::IconSize, 2> valid_iconsizes = {{ { 16, "Small (16x16)" }, { 32, "Large (32x32)" }, -}; +}}; -#define VALID_BUTTONSTYLES_NUM 5 -static KviToolBar::ButtonStyles valid_buttonstyles[VALID_BUTTONSTYLES_NUM] = { +static const std::array<KviToolBar::ButtonStyle, 5> valid_buttonstyles = {{ { Qt::ToolButtonIconOnly, "Icon Only" }, { Qt::ToolButtonTextOnly, "Text Only" }, { Qt::ToolButtonTextBesideIcon, "Text Beside Icon" }, { Qt::ToolButtonTextUnderIcon, "Text Under Icon" }, - { Qt::ToolButtonFollowStyle, "Use System Style" } -}; + { Qt::ToolButtonFollowStyle, "Use System Style" }, +}}; void KviToolBar::mousePressEvent(QMouseEvent * e) { @@ -118,38 +117,30 @@ void KviToolBar::mousePressEvent(QMouseEvent * e) // fill icon size menu QActionGroup * pIconSizeGroup = new QActionGroup(g_pToolBarIconSizesPopup); - QAction * pTmp = nullptr; - IconSizes iconSize; - for(auto & valid_iconsize : valid_iconsizes) + for(auto iconSize : valid_iconsizes) { - iconSize = valid_iconsize; - - pTmp = pIconSizeGroup->addAction(g_pToolBarIconSizesPopup->addAction(__tr2qs(iconSize.pcName))); - pTmp->setData((uint)iconSize.uSize); + QAction * pTmp = pIconSizeGroup->addAction(g_pToolBarIconSizesPopup->addAction(__tr2qs(iconSize.pcName))); + pTmp->setData(iconSize.uSize); pTmp->setCheckable(true); if(iconSize.uSize == KVI_OPTION_UINT(KviOption_uintToolBarIconSize)) pTmp->setChecked(true); } - connect(pIconSizeGroup, SIGNAL(triggered(QAction *)), g_pMainWindow, SLOT(iconSizePopupSelected(QAction *))); + connect(pIconSizeGroup, &QActionGroup::triggered, g_pMainWindow, &KviMainWindow::iconSizePopupSelected); // fill button style menu QActionGroup * pButtonStyleGroup = new QActionGroup(g_pToolBarButtonStylePopup); - pTmp = nullptr; - ButtonStyles buttonStyle; - for(auto & valid_buttonstyle : valid_buttonstyles) + for(auto buttonStyle : valid_buttonstyles) { - buttonStyle = valid_buttonstyle; - - pTmp = pButtonStyleGroup->addAction(g_pToolBarButtonStylePopup->addAction(__tr2qs(buttonStyle.pcName))); - pTmp->setData((uint)buttonStyle.uStyle); + QAction * pTmp = pButtonStyleGroup->addAction(g_pToolBarButtonStylePopup->addAction(__tr2qs(buttonStyle.pcName))); + pTmp->setData(buttonStyle.uStyle); pTmp->setCheckable(true); if(buttonStyle.uStyle == KVI_OPTION_UINT(KviOption_uintToolBarButtonStyle)) pTmp->setChecked(true); } - connect(pButtonStyleGroup, SIGNAL(triggered(QAction *)), g_pMainWindow, SLOT(buttonStylePopupSelected(QAction *))); + connect(pButtonStyleGroup, &QActionGroup::triggered, g_pMainWindow, &KviMainWindow::buttonStylePopupSelected); } g_pToolBarContextPopup->popup(QCursor::pos()); diff --git a/src/kvirc/ui/KviToolBar.h b/src/kvirc/ui/KviToolBar.h index dabd8b1d1..03c2297a5 100644 --- a/src/kvirc/ui/KviToolBar.h +++ b/src/kvirc/ui/KviToolBar.h @@ -40,25 +40,25 @@ public: * \struct _IconSizes * \brief Enumerates the valid icon sizes */ - typedef struct _IconSizes + struct IconSize { uint uSize; /**< icon size */ const char * pcName; /**< menu entry label */ - } IconSizes; + }; /** * \typedef ButtonStyles * \struct _ButtonStyles * \brief Enumerates the valid button styles */ - typedef struct _ButtonStyles + struct ButtonStyle { uint uStyle; /**< button style */ const char * pcName; /**< menu entry label */ - } ButtonStyles; + }; protected: - virtual void mousePressEvent(QMouseEvent * e); + void mousePressEvent(QMouseEvent * e) override; }; #endif //_KVI_TOOLBAR_H_ diff --git a/src/kvirc/ui/KviTopicWidget.cpp b/src/kvirc/ui/KviTopicWidget.cpp index ace4bee2e..de5b56373 100644 --- a/src/kvirc/ui/KviTopicWidget.cpp +++ b/src/kvirc/ui/KviTopicWidget.cpp @@ -229,15 +229,15 @@ void KviTopicWidget::paintColoredText(QPainter * p, QString text, const QPalette } else { - if(curFore > 16) + if(curFore > KVI_EXTCOLOR_MAX) p->setPen(cg.background().color()); else - p->setPen(KVI_OPTION_MIRCCOLOR(curFore)); + p->setPen(getMircColor(curFore)); } if(curBack != KVI_LABEL_DEF_BACK) { - if(curBack > 16) + if(curBack > KVI_EXTCOLOR_MAX) { p->fillRect(curX, rect.y() + 2, wdth, rect.height() - 4, cg.text()); @@ -245,7 +245,7 @@ void KviTopicWidget::paintColoredText(QPainter * p, QString text, const QPalette else { p->fillRect(curX, rect.y() + 2, wdth, rect.height() - 4, - KVI_OPTION_MIRCCOLOR(curBack)); + getMircColor(curBack)); } } @@ -405,13 +405,13 @@ void KviTopicWidget::updateToolTip() if(!m_szSetBy.isEmpty()) { - txt += "<tr><td style=\"white-space: pre\"; bgcolor=\"#E0E0E0\"><font color=\"#000000\">"; + txt += R"(<tr><td style="white-space: pre"; bgcolor="#E0E0E0"><font color="#000000">)"; txt += __tr2qs("Set by") + cln + space + bb + m_szSetBy + be; txt += "</font>" + enr; if(!m_szSetAt.isEmpty()) { - txt += "<tr><td bgcolor=\"#E0E0E0\"><font color=\"#000000\">"; + txt += R"(<tr><td bgcolor="#E0E0E0"><font color="#000000">)"; txt += __tr2qs("Set on") + cln + space + bb + m_szSetAt + be; txt += "</font>" + enr; } @@ -743,7 +743,7 @@ QChar KviTopicWidget::getSubstituteChar(unsigned short control_code) return QChar('E'); break; default: - return QChar(control_code); + return { control_code }; break; } } diff --git a/src/kvirc/ui/KviTopicWidget.h b/src/kvirc/ui/KviTopicWidget.h index 123567be3..178a878cf 100644 --- a/src/kvirc/ui/KviTopicWidget.h +++ b/src/kvirc/ui/KviTopicWidget.h @@ -44,7 +44,7 @@ class KVIRC_API KviTopicListBoxItemDelegate : public KviTalIconAndRichTextItemDe { Q_OBJECT public: - KviTopicListBoxItemDelegate(QAbstractItemView * pWidget = 0); + KviTopicListBoxItemDelegate(QAbstractItemView * pWidget = nullptr); ~KviTopicListBoxItemDelegate(); public: @@ -55,7 +55,7 @@ public: class KVIRC_API KviTopicListBoxItem : public KviTalListWidgetText { public: - KviTopicListBoxItem(KviTalListWidget * pListBox = 0, const QString & text = QString()); + KviTopicListBoxItem(KviTalListWidget * pListBox = nullptr, const QString & text = QString()); ~KviTopicListBoxItem(); public: @@ -97,10 +97,10 @@ protected: void updateToolTip(); void deactivate(); void iconButtonClicked(); - virtual bool eventFilter(QObject * o, QEvent * e); - virtual void mousePressEvent(QMouseEvent * e); - virtual void keyPressEvent(QKeyEvent * e); - virtual void resizeEvent(QResizeEvent * e); + bool eventFilter(QObject * o, QEvent * e) override; + void mousePressEvent(QMouseEvent * e) override; + void keyPressEvent(QKeyEvent * e) override; + void resizeEvent(QResizeEvent * e) override; public: void insertChar(QChar c); @@ -115,7 +115,7 @@ public: const QString & topic() { return m_szTopic; }; const QString & topicSetBy() { return m_szSetBy; }; const QString & topicSetAt() { return m_szSetAt; }; - virtual QSize sizeHint() const; + QSize sizeHint() const override; void applyOptions(); static void paintColoredText(QPainter * p, QString szText, const QPalette & palette, const QRect & rect); diff --git a/src/kvirc/ui/KviTreeWindowList.cpp b/src/kvirc/ui/KviTreeWindowList.cpp index a3ce2ae1f..29584ddd5 100644 --- a/src/kvirc/ui/KviTreeWindowList.cpp +++ b/src/kvirc/ui/KviTreeWindowList.cpp @@ -571,17 +571,21 @@ void KviTreeWindowListItemDelegate::paint(QPainter * p, const QStyleOptionViewIt if(treeWidget->currentItem() == item) { //selection colored background - if(treeWidget->style()->inherits("QWindowsXPStyle") || treeWidget->style()->inherits("QWindowsVistaStyle")) +#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + if(treeWidget->style()->inherits("QStyleSheetStyle") || treeWidget->style()->inherits("QWindowsVistaStyle")) { - // The QWindowsXP style does not honor our colors. It uses the system ones instead. + // The Windows style does not honor our colors. It uses the system ones instead. // We can't accept it. p->fillRect(opt.rect, KVI_OPTION_COLOR(KviOption_colorTreeWindowListActiveBackground)); } else { +#endif opt.palette.setColor(QPalette::Highlight, KVI_OPTION_COLOR(KviOption_colorTreeWindowListActiveBackground)); treeWidget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, p, treeWidget); +#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) } +#endif #ifndef COMPILE_ON_MAC } else @@ -592,17 +596,21 @@ void KviTreeWindowListItemDelegate::paint(QPainter * p, const QStyleOptionViewIt QColor col(KVI_OPTION_COLOR(KviOption_colorTreeWindowListActiveBackground)); col.setAlpha(127); - if(treeWidget->style()->inherits("QWindowsXPStyle") || treeWidget->style()->inherits("QWindowsVistaStyle")) + #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + if(treeWidget->style()->inherits("QStyleSheetStyle") || treeWidget->style()->inherits("QWindowsVistaStyle")) { - // The QWindowsXP style does not honor our colors. It uses the system ones instead. + // The Windows style does not honor our colors. It uses the system ones instead. // We can't accept it. p->fillRect(opt.rect, col); } else { + #endif opt.palette.setColor(QPalette::Highlight, col); treeWidget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, p, treeWidget); + #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) } + #endif } #endif } @@ -733,5 +741,5 @@ QSize KviTreeWindowListItemDelegate::sizeHint(const QStyleOptionViewItem &, cons if((KVI_OPTION_BOOL(KviOption_boolUseWindowListIrcContextIndicator) || KVI_OPTION_BOOL(KviOption_boolUseWindowListIcons) || KVI_OPTION_BOOL(KviOption_boolUseWindowListActivityMeter)) && iHeight < 20) iHeight = 20; - return QSize(treeWidget->viewport()->size().width(), iHeight); + return { treeWidget->viewport()->size().width(), iHeight }; } diff --git a/src/kvirc/ui/KviTreeWindowList.h b/src/kvirc/ui/KviTreeWindowList.h index 853ab21fa..e869b3949 100644 --- a/src/kvirc/ui/KviTreeWindowList.h +++ b/src/kvirc/ui/KviTreeWindowList.h @@ -45,10 +45,10 @@ public: public: virtual QString key() const; - virtual void captionChanged(); - virtual void highlight(int iLevel = 1); - virtual void unhighlight(); - virtual void setProgress(int progress); + void captionChanged() override; + void highlight(int iLevel = 1) override; + void unhighlight() override; + void setProgress(int progress) override; virtual void applyOptions(); protected: @@ -69,11 +69,11 @@ public: ~KviTreeWindowListTreeWidget(); bool isReverseSort() { return bReverseSort; }; protected: - virtual void mousePressEvent(QMouseEvent * e); - virtual void mouseMoveEvent(QMouseEvent * e); - virtual void wheelEvent(QWheelEvent * e); - virtual void mouseDoubleClickEvent(QMouseEvent * e); - virtual void paintEvent(QPaintEvent * event); + void mousePressEvent(QMouseEvent * e) override; + void mouseMoveEvent(QMouseEvent * e) override; + void wheelEvent(QWheelEvent * e) override; + void mouseDoubleClickEvent(QMouseEvent * e) override; + void paintEvent(QPaintEvent * event) override; private: KviWindowListItem * lastItem(); @@ -92,26 +92,26 @@ public: private: KviTreeWindowListTreeWidget * m_pTreeWidget; - KviTreeWindowListItem * m_pCurrentItem; + KviTreeWindowListItem * m_pCurrentItem = nullptr; KviDynamicToolTip * m_pToolTip; QStyledItemDelegate * m_pItemDelegate; public: - virtual KviWindowListItem * addItem(KviWindow *); - virtual bool removeItem(KviWindowListItem *); - virtual void setActiveItem(KviWindowListItem *); - virtual KviWindowListItem * firstItem(); - virtual KviWindowListItem * nextItem(void); - virtual KviWindowListItem * lastItem(); - virtual KviWindowListItem * prevItem(void); - virtual bool setIterationPointer(KviWindowListItem * it); - virtual void updatePseudoTransparency(); - virtual void updateActivityMeter(); + KviWindowListItem * addItem(KviWindow *) override; + bool removeItem(KviWindowListItem *) override; + void setActiveItem(KviWindowListItem *) override; + KviWindowListItem * firstItem() override; + KviWindowListItem * nextItem(void) override; + KviWindowListItem * lastItem() override; + KviWindowListItem * prevItem(void) override; + bool setIterationPointer(KviWindowListItem * it) override; + void updatePseudoTransparency() override; + void updateActivityMeter() override; - virtual void wheelEvent(QWheelEvent * e); + void wheelEvent(QWheelEvent * e) override; protected: - virtual void moveEvent(QMoveEvent *); + void moveEvent(QMoveEvent *) override; protected slots: void tipRequest(KviDynamicToolTip * tip, const QPoint & pnt); }; @@ -123,7 +123,7 @@ class KVIRC_API KviTreeWindowListItemDelegate : public QStyledItemDelegate { Q_OBJECT public: - KviTreeWindowListItemDelegate(QAbstractItemView * pWidget = 0) + KviTreeWindowListItemDelegate(QAbstractItemView * pWidget = nullptr) : QStyledItemDelegate(pWidget){}; ~KviTreeWindowListItemDelegate(){}; QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const; diff --git a/src/kvirc/ui/KviUserListView.cpp b/src/kvirc/ui/KviUserListView.cpp index 0fbcb2466..f3e235c3d 100644 --- a/src/kvirc/ui/KviUserListView.cpp +++ b/src/kvirc/ui/KviUserListView.cpp @@ -345,8 +345,8 @@ void KviUserListView::applyOptions() m_iFontHeight = fm.lineSpacing(); m_pViewArea->m_pScrollBar->setSingleStep(m_iFontHeight); - if(KVI_OPTION_UINT(KviOption_uintUserListMinimumWidth) < 100) - KVI_OPTION_UINT(KviOption_uintUserListMinimumWidth) = 100; + if(KVI_OPTION_UINT(KviOption_uintUserListMinimumWidth) < 50) + KVI_OPTION_UINT(KviOption_uintUserListMinimumWidth) = 50; setMinimumWidth(KVI_OPTION_UINT(KviOption_uintUserListMinimumWidth)); @@ -485,8 +485,81 @@ void KviUserListView::completeNickBashLike(const QString & szBegin, std::vector< } } +bool KviUserListView::completeNickLastAction(const QString & szBegin, const QString & szSkipAfter, QString & szBuffer, bool bAppendMask) +{ + KviUserListEntry * pLastMatch = findEntry(szSkipAfter); + KviUserListEntry * pBestMatch = nullptr; + + bool bUseNextEqual = false; + KviUserListEntry * pEntry = m_pHeadItem; + while(pEntry) + { + if(pLastMatch && pEntry == pLastMatch) + bUseNextEqual = true; + else if(pEntry->m_szNick.length() >= szBegin.length()) + { + bool bEqual = KviQString::equalCIN(szBegin, pEntry->m_szNick, szBegin.length()); + if(!bEqual && KVI_OPTION_BOOL(KviOption_boolIgnoreSpecialCharactersInNickCompletion)) + { + QString szTmp = pEntry->m_szNick; + szTmp.remove(QRegExp("[^a-zA-Z0-9]")); + bEqual = KviQString::equalCIN(szBegin, szTmp, szBegin.length()); + } + + if(bEqual) + { + if(!pLastMatch && !pBestMatch) + pBestMatch = pEntry; + else if(!pLastMatch && pBestMatch) + { + if(pEntry->m_lastActionTime > pBestMatch->m_lastActionTime) + pBestMatch = pEntry; + } + else if(!pBestMatch) + { + if(pLastMatch->m_lastActionTime > pEntry->m_lastActionTime) + pBestMatch = pEntry; + else if(bUseNextEqual && pLastMatch->m_lastActionTime == pEntry->m_lastActionTime) + { + pBestMatch = pEntry; + bUseNextEqual = false; + } + } + else + { + if((pLastMatch->m_lastActionTime > pEntry->m_lastActionTime) && (pEntry->m_lastActionTime > pBestMatch->m_lastActionTime)) + pBestMatch = pEntry; + else if(bUseNextEqual && pLastMatch->m_lastActionTime == pEntry->m_lastActionTime) + { + pBestMatch = pEntry; + bUseNextEqual = false; + } + } + } + } + pEntry = pEntry->m_pNext; + } + + if(pBestMatch) + { + szBuffer = pBestMatch->m_szNick; + if(bAppendMask) + { + szBuffer += "!"; + szBuffer += pBestMatch->m_pGlobalData->user(); + szBuffer += "@"; + szBuffer += pBestMatch->m_pGlobalData->host(); + } + return true; + } + return false; +} + bool KviUserListView::completeNickStandard(const QString & szBegin, const QString & szSkipAfter, QString & szBuffer, bool bAppendMask) { + if(KVI_OPTION_BOOL(KviOption_boolPrioritizeLastActionTime)) + return completeNickLastAction(szBegin, szSkipAfter, szBuffer, bAppendMask); + KviUserListEntry * pEntry = m_pHeadItem; if(!szSkipAfter.isEmpty()) @@ -1624,7 +1697,7 @@ void KviUserListView::maybeTip(KviUserListToolTip * pTip, const QPoint & pnt) break; } - szBuffer += "<tr><td bgcolor=\"#E0E0E0\"><font color=\"#000000\">"; + szBuffer += R"(<tr><td bgcolor="#E0E0E0"><font color="#000000">)"; szBuffer += __tr2qs("Joined on: <b>%1</b>").arg(szTmp); szBuffer += "</font></td></tr>"; } @@ -1636,19 +1709,19 @@ void KviUserListView::maybeTip(KviUserListToolTip * pTip, const QPoint & pnt) iSecs = iSecs % 60; int iHours = iMins / 60; iMins = iMins % 60; - szBuffer += "<tr><td bgcolor=\"#E0E0E0\"><font color=\"#000000\">"; + szBuffer += R"(<tr><td bgcolor="#E0E0E0"><font color="#000000">)"; szBuffer += __tr2qs("Quiet for: <b>%1h %2m %3s</b>").arg(iHours).arg(iMins).arg(iSecs); szBuffer += "</font></td></tr>"; } if(pEntry->m_pGlobalData->isIrcOp()) { - szBuffer += "<tr><td bgcolor=\"#E0E0E0\"><font color=\"#000000\">"; + szBuffer += R"(<tr><td bgcolor="#E0E0E0"><font color="#000000">)"; szBuffer += __tr2qs("%1 is an <b>IrcOp</b>").arg(pEntry->m_szNick); szBuffer += "</font></td></tr>"; } - pTip->doTip(itRect, szBuffer); + pTip->doTip(QRect(pnt, pnt), szBuffer); } } } diff --git a/src/kvirc/ui/KviUserListView.h b/src/kvirc/ui/KviUserListView.h index 121010269..219bdd72c 100644 --- a/src/kvirc/ui/KviUserListView.h +++ b/src/kvirc/ui/KviUserListView.h @@ -66,11 +66,10 @@ class KviWindow; #define KVI_USERLISTVIEW_GRIDTYPE_DEFAULT 0 /** -* \typedef KviUserListViewUserStats * \struct _KviUserListViewUserStats * \brief A struct to hold user statistics */ -typedef struct _KviUserListViewUserStats +struct KviUserListViewUserStats { unsigned int uTotal; /**< total users on the channel */ unsigned int uActive; /**< active users in the last 10 mins */ @@ -85,7 +84,7 @@ typedef struct _KviUserListViewUserStats unsigned int uVoiced; /**< total voiced users */ unsigned int uUserOp; /**< total userops (uops) */ int iAvgTemperature; /**< average user temperature */ -} KviUserListViewUserStats; +}; /** * \class KviUserListToolTip @@ -105,7 +104,7 @@ public: /** * \brief Destroys the userlist tooltip */ - virtual ~KviUserListToolTip(); + ~KviUserListToolTip(); private: KviUserListView * m_pListView; @@ -116,7 +115,7 @@ public: * \param pnt The point where to show to tooltip * \return void */ - virtual void maybeTip(const QPoint & pnt); + void maybeTip(const QPoint & pnt) override; /** * \brief Shows the tooltip @@ -321,7 +320,7 @@ public: * \param pRect The rectangle where to search * \return KviUserListEntry * */ - KviUserListEntry * itemAt(const QPoint & pnt, QRect * pRect = 0); + KviUserListEntry * itemAt(const QPoint & pnt, QRect * pRect = nullptr); /** * \brief Returns true if the item in the entry is visible @@ -715,6 +714,11 @@ public: void emitDoubleClick(); /** + * \brief Completes the nick prioritizing last active first + */ + bool completeNickLastAction(const QString & szBegin, const QString & szSkipAfter, QString & szBuffer, bool bAppendMask); + + /** * \brief Completes the nick in normal behaviour * * It looks for the letters typed, if it found at least a result, it @@ -801,7 +805,7 @@ protected: */ void updateScrollBarRange(); - virtual void resizeEvent(QResizeEvent * e); + void resizeEvent(QResizeEvent * e) override; public slots: /** @@ -850,14 +854,14 @@ protected: bool m_bIgnoreScrollBar; protected: - virtual void paintEvent(QPaintEvent * e); - virtual void resizeEvent(QResizeEvent * e); - virtual void mousePressEvent(QMouseEvent * e); - virtual void mouseMoveEvent(QMouseEvent * e); - virtual void mouseReleaseEvent(QMouseEvent * e); - virtual void mouseDoubleClickEvent(QMouseEvent * e); - virtual void wheelEvent(QWheelEvent * e); - virtual void keyPressEvent(QKeyEvent * e); + void paintEvent(QPaintEvent * e) override; + void resizeEvent(QResizeEvent * e) override; + void mousePressEvent(QMouseEvent * e) override; + void mouseMoveEvent(QMouseEvent * e) override; + void mouseReleaseEvent(QMouseEvent * e) override; + void mouseDoubleClickEvent(QMouseEvent * e) override; + void wheelEvent(QWheelEvent * e) override; + void keyPressEvent(QKeyEvent * e) override; protected slots: /** diff --git a/src/kvirc/ui/KviWebPackageManagementDialog.h b/src/kvirc/ui/KviWebPackageManagementDialog.h index 49235ccee..af2804daa 100644 --- a/src/kvirc/ui/KviWebPackageManagementDialog.h +++ b/src/kvirc/ui/KviWebPackageManagementDialog.h @@ -52,13 +52,13 @@ public: /// /// Creates an instance of KviWebPackageManagementDialog /// - KviWebPackageManagementDialog(QWidget * pParent = NULL); + KviWebPackageManagementDialog(QWidget * pParent = nullptr); /// /// Destroys the instance of KviWebPackageManagementDialog /// and frees all the relevant resources /// - virtual ~KviWebPackageManagementDialog(); + ~KviWebPackageManagementDialog(); private: QToolBar * m_pToolBar; @@ -71,7 +71,7 @@ private: protected: void setPackagePageUrl(const QString & szUrl); - virtual void showEvent(QShowEvent * e); + void showEvent(QShowEvent * e) override; virtual bool packageIsInstalled(const QString & szId, const QString & szVersion) = 0; virtual bool installPackage(const QString & szPath, QString & szError) = 0; diff --git a/src/kvirc/ui/KviWindow.cpp b/src/kvirc/ui/KviWindow.cpp index bc5d6d0cb..4ccdbf6b9 100644 --- a/src/kvirc/ui/KviWindow.cpp +++ b/src/kvirc/ui/KviWindow.cpp @@ -74,6 +74,7 @@ #include <QInputMethodEvent> #include <QFileInfo> +#include <array> #include <tuple> #include <vector> @@ -139,6 +140,8 @@ KviWindow::KviWindow(Type eType, const QString & szName, KviConsoleWindow * lpCo //setAutoFillBackground(false); setFocusPolicy(Qt::StrongFocus); connect(g_pApp, SIGNAL(reloadImages()), this, SLOT(reloadImages())); + + setAttribute(Qt::WA_InputMethodEnabled, true); } KviWindow::~KviWindow() @@ -208,7 +211,7 @@ bool KviWindow::hasAttention(AttentionLevel eLevel) void KviWindow::demandAttention() { - WId windowId = isDocked() ? g_pMainWindow->winId() : winId(); + [[maybe_unused]] WId windowId = isDocked() ? g_pMainWindow->winId() : winId(); #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) FLASHWINFO fwi; @@ -702,9 +705,9 @@ void KviWindow::createSystemTextEncodingPopup() pAction->setMenu(g_pMdiWindowSystemTextEncodingPopupSmartUtf8); // second level menus (encoding groups) - QMenu * pPopupStandard[KVI_NUM_ENCODING_GROUPS]; - QMenu * pPopupSmart[KVI_NUM_ENCODING_GROUPS]; - QMenu * pPopupSmartUtf8[KVI_NUM_ENCODING_GROUPS]; + std::array<QMenu *, KVI_NUM_ENCODING_GROUPS> pPopupStandard = {}; + std::array<QMenu *, KVI_NUM_ENCODING_GROUPS> pPopupSmart = {}; + std::array<QMenu *, KVI_NUM_ENCODING_GROUPS> pPopupSmartUtf8 = {}; uint u = 0; const char * pcEncodingGroup = KviLocale::instance()->encodingGroup(u); diff --git a/src/kvirc/ui/KviWindow.h b/src/kvirc/ui/KviWindow.h index 923391e15..b1cc107a2 100644 --- a/src/kvirc/ui/KviWindow.h +++ b/src/kvirc/ui/KviWindow.h @@ -171,7 +171,7 @@ public: /** * \brief Destroys the window object */ - virtual ~KviWindow(); + ~KviWindow(); protected: // almost private: don't touch :D QString m_szName; // the current window name (usually also the target) @@ -203,7 +203,7 @@ protected: // almost private: don't touch :D bool m_bProcessingInputEvent; public: - inline bool isDocked() { return m_bIsDocked; } + bool isDocked() const { return m_bIsDocked; } /** * \brief Returns the global ID of this window @@ -211,7 +211,7 @@ public: * This is unique in the application * \return QString */ - inline QString id() { return QString("%1").arg(m_uId); }; + QString id() const { return QString("%1").arg(m_uId); } /** * \brief Returns the global ID of this window @@ -219,13 +219,13 @@ public: * This is unique in the application * \return QString */ - inline unsigned long int numericId() { return m_uId; }; + unsigned long int numericId() const { return m_uId; } /** * \brief Returns the name of this window * \return const QString & */ - inline const QString & windowName() { return m_szName; }; + const QString & windowName() const { return m_szName; } /** * \brief Sets the name of the window @@ -247,22 +247,22 @@ public: * \brief Returns the type of the window * \return Type */ - inline Type type() const { return m_eType; }; + Type type() const { return m_eType; } /** * Returns true if the window is a channel */ - inline bool isChannel() const { return m_eType == Channel; }; + bool isChannel() const { return m_eType == Channel; } /** * Returns true if the window is a query */ - inline bool isQuery() const { return m_eType == Query; }; + bool isQuery() const { return m_eType == Query; } /** * Returns true if the window is a console */ - inline bool isConsole() const { return m_eType == Console; }; + bool isConsole() const { return m_eType == Console; } /** * \brief Returns a descriptive name of the window type @@ -270,16 +270,16 @@ public: */ virtual const char * typeString(); - inline QTextCodec * textCodec() { return m_pTextCodec ? m_pTextCodec : defaultTextCodec(); }; + QTextCodec * textCodec() { return m_pTextCodec ? m_pTextCodec : defaultTextCodec(); } void forceTextCodec(QTextCodec * pCodec); /** * \brief Returns the KviIrcView of this window * - * May be NULL if the window has no KviIrcView (and thus supports no direct output) + * May be nullptr if the window has no KviIrcView (and thus supports no direct output) * \return KviIrcView * */ - inline KviIrcView * view() const { return m_pIrcView; }; + KviIrcView * view() const { return m_pIrcView; } /** * \brief Returns the KviIrcView that was last clicked in this window @@ -296,7 +296,7 @@ public: * May be null for windows that aren't bound to irc contexts * \return KviConsoleWindow * */ - inline KviConsoleWindow * console() { return m_pConsole; }; + KviConsoleWindow * console() const { return m_pConsole; } KviIrcContext * context(); @@ -312,7 +312,7 @@ public: * It *shouldn't* be null... but... well... who knows ? :D ...better check it * \return KviTalSplitter * */ - inline KviTalSplitter * splitter() { return m_pSplitter; }; + KviTalSplitter * splitter() const { return m_pSplitter; } /** * \brief Returns the windowList item @@ -320,7 +320,7 @@ public: * The window has ALWAYS a WindowList item * \return KviWindowListItem * */ - inline KviWindowListItem * windowListItem() { return m_pWindowListItem; }; + KviWindowListItem * windowListItem() const { return m_pWindowListItem; } // The window *might* have a button container virtual QFrame * buttonContainer() { return (QFrame *)m_pButtonBox; }; @@ -330,7 +330,7 @@ public: virtual KviWindow * outputProxy(); // The window input widget - inline KviInput * input() { return m_pInput; }; + KviInput * input() const { return m_pInput; } // The target of this window: empty when it makes no sense :D virtual const QString & target() { return KviQString::Empty; }; @@ -354,20 +354,20 @@ public: void unhighlight(); - virtual inline void getWindowListTipText(QString & szBuffer) { szBuffer = m_szPlainTextCaption; }; + virtual void getWindowListTipText(QString & szBuffer) { szBuffer = m_szPlainTextCaption; } - // This is meaningful only if view() is non NULL + // This is meaningful only if view() is non nullptr const QString & lastLineOfText(); const QString & lastMessageText(); - inline const QString & textEncoding() { return m_szTextEncoding; }; + const QString & textEncoding() const { return m_szTextEncoding; } // returns true if the encoding could be successfully set bool setTextEncoding(const QString & szTextEncoding); // this must return a default text codec suitable for this window virtual QTextCodec * defaultTextCodec(); // encode the text from szSource by using m_uTextEncoding - inline QByteArray encodeText(const QString & szText); - inline QString decodeText(const char * pcText); + QByteArray encodeText(const QString & szText); + QString decodeText(const char * pcText); //return a text encoder QTextEncoder * makeEncoder(); @@ -434,7 +434,7 @@ public: // call this in the constructor if your caption is fixed: // it will set m_szPlainTextCaption to szCaption and it will // automatically use it without the need of overriding fillCaptionBuffers - inline void setFixedCaption(const QString & szCaption) { m_szPlainTextCaption = szCaption; }; + void setFixedCaption(const QString & szCaption) { m_szPlainTextCaption = szCaption; } void setWindowTitle(QString & szTitle); @@ -476,7 +476,7 @@ protected: // this by default calls fillSingleColorCaptionBuffer(plainTextCaption()); virtual void fillCaptionBuffers(); // protected helper - inline void fillSingleColorCaptionBuffers(const QString & szName) { m_szPlainTextCaption = szName; }; + void fillSingleColorCaptionBuffers(const QString & szName) { m_szPlainTextCaption = szName; } // Virtual events that signal dock state change virtual void youAreDocked(); virtual void youAreUndocked(); @@ -485,14 +485,14 @@ protected: // Sets the type of this window: be careful with this void setType(Type eType) { m_eType = eType; }; - bool eventFilter(QObject * pObject, QEvent * pEvent); + bool eventFilter(QObject * pObject, QEvent * pEvent) override; // Virtuals overridden to manage the internal layouts... - virtual void moveEvent(QMoveEvent * pEvent); - virtual void closeEvent(QCloseEvent * pEvent); - virtual void childEvent(QChildEvent * pEvent); - virtual void focusInEvent(QFocusEvent *); - virtual void inputMethodEvent(QInputMethodEvent * e); + void moveEvent(QMoveEvent * pEvent) override; + void closeEvent(QCloseEvent * pEvent) override; + void childEvent(QChildEvent * pEvent) override; + void focusInEvent(QFocusEvent *) override; + void inputMethodEvent(QInputMethodEvent * e) override; void childInserted(QWidget * pObject); void childRemoved(QWidget * pObject); @@ -506,7 +506,7 @@ protected: // This is called by KviInput: actually it links the widgetAdded virtual void childrenTreeChanged(QWidget * pAdded); - virtual bool focusNextPrevChild(bool bNext); + bool focusNextPrevChild(bool bNext) override; virtual void preprocessMessage(QString & szMessage); public slots: @@ -531,7 +531,7 @@ signals: // This is almost always non null // The exception is the startup (when there are no windows at all) // and the last phase of the destructor. -// You usually shouldn't care of checking this pointer for NULL unless +// You usually shouldn't care of checking this pointer for nullptr unless // you're running very early at startup or very late at shutdown extern KVIRC_API KviWindow * g_pActiveWindow; #endif diff --git a/src/kvirc/ui/KviWindowListBase.cpp b/src/kvirc/ui/KviWindowListBase.cpp index 73776be0d..76a39caa9 100644 --- a/src/kvirc/ui/KviWindowListBase.cpp +++ b/src/kvirc/ui/KviWindowListBase.cpp @@ -215,7 +215,7 @@ QSize KviWindowListTitleWidget::sizeHint() const { // if there is no handle there is nothing to paint. if(!KVI_OPTION_BOOL(KviOption_boolShowTreeWindowListHandle)) - return QSize(0, 0); + return { 0, 0 }; int h, w; if(m_pParent->features() & QDockWidget::DockWidgetVerticalTitleBar) @@ -840,7 +840,7 @@ KviWindowListItem * KviClassicWindowList::firstItem() return m_pButtonList->first(); } -KviWindowListItem * KviClassicWindowList::lastItem(void) +KviWindowListItem * KviClassicWindowList::lastItem() { return m_pButtonList->last(); } @@ -850,7 +850,7 @@ KviWindowListItem * KviClassicWindowList::nextItem() return m_pButtonList->next(); } -KviWindowListItem * KviClassicWindowList::prevItem(void) +KviWindowListItem * KviClassicWindowList::prevItem() { return m_pButtonList->prev(); } diff --git a/src/kvirc/ui/KviWindowListBase.h b/src/kvirc/ui/KviWindowListBase.h index dfa24b89f..ed0a19f63 100644 --- a/src/kvirc/ui/KviWindowListBase.h +++ b/src/kvirc/ui/KviWindowListBase.h @@ -79,7 +79,7 @@ class KVIRC_API KviWindowListBase : public QDockWidget Q_OBJECT public: KviWindowListBase(); - virtual ~KviWindowListBase(); + ~KviWindowListBase(); protected: KviMainWindow * m_pFrm; @@ -88,19 +88,19 @@ protected: Qt::DockWidgetArea currentArea; public: - virtual KviWindowListItem * addItem(KviWindow *) { return 0; }; + virtual KviWindowListItem * addItem(KviWindow *) { return nullptr; } virtual bool removeItem(KviWindowListItem *) { return false; }; virtual void setActiveItem(KviWindowListItem *){}; - virtual KviWindowListItem * firstItem() { return 0; }; - virtual KviWindowListItem * lastItem(void) { return 0; } - virtual KviWindowListItem * nextItem() { return 0; }; - virtual KviWindowListItem * prevItem(void) { return 0; } + virtual KviWindowListItem * firstItem() { return nullptr; } + virtual KviWindowListItem * lastItem(void) { return nullptr; } + virtual KviWindowListItem * nextItem() { return nullptr; } + virtual KviWindowListItem * prevItem(void) { return nullptr; } virtual KviWindowListItem * item(int number); virtual bool setIterationPointer(KviWindowListItem *) { return false; }; virtual void switchWindow(bool bNext, bool bInContextOnly, bool bHighlightedOnly = false); virtual void updatePseudoTransparency(){}; virtual void applyOptions(); - virtual void wheelEvent(QWheelEvent * e); + void wheelEvent(QWheelEvent * e) override; static void getTextForConsole(QString & szText, KviConsoleWindow * pConsole); Qt::DockWidgetArea currentDockArea() { return currentArea; }; protected slots: @@ -137,17 +137,17 @@ protected: KviDynamicToolTip * m_pTip; protected: - virtual void mousePressEvent(QMouseEvent * e); - virtual void contextMenuEvent(QContextMenuEvent * e); + void mousePressEvent(QMouseEvent * e) override; + void contextMenuEvent(QContextMenuEvent * e) override; virtual void drawButtonLabel(QPainter * p); - virtual void paintEvent(QPaintEvent * e); + void paintEvent(QPaintEvent * e) override; public: - virtual bool active() { return m_bActive; }; - virtual void highlight(int iLevel = 1); - virtual void unhighlight(); - virtual void setProgress(int progress); - virtual void captionChanged(); + bool active() override { return m_bActive; } + void highlight(int iLevel = 1) override; + void unhighlight() override; + void setProgress(int progress) override; + void captionChanged() override; protected: void setActive(bool bActive); @@ -171,10 +171,10 @@ public: ~KviClassicWindowListToolButton() {}; protected: - virtual void mousePressEvent(QMouseEvent *e); + void mousePressEvent(QMouseEvent *e) override; public: - virtual QSize sizeHint() const; + QSize sizeHint() const override; }; class KVIRC_API KviClassicWindowList : public KviWindowListBase @@ -194,19 +194,19 @@ protected: void insertButton(KviWindowListButton * b); public: - virtual void resizeEvent(QResizeEvent * e); + void resizeEvent(QResizeEvent * e) override; public: - virtual KviWindowListItem * addItem(KviWindow *); - virtual bool removeItem(KviWindowListItem *); - virtual void setActiveItem(KviWindowListItem *); - virtual KviWindowListItem * firstItem(); - virtual KviWindowListItem * lastItem(void); - virtual KviWindowListItem * nextItem(); - virtual KviWindowListItem * prevItem(void); - virtual bool setIterationPointer(KviWindowListItem * it); - virtual void updateActivityMeter(); - virtual void applyOptions(); + KviWindowListItem * addItem(KviWindow *) override; + bool removeItem(KviWindowListItem *) override; + void setActiveItem(KviWindowListItem *) override; + KviWindowListItem * firstItem() override; + KviWindowListItem * lastItem(void) override; + KviWindowListItem * nextItem() override; + KviWindowListItem * prevItem(void) override; + bool setIterationPointer(KviWindowListItem * it) override; + void updateActivityMeter() override; + void applyOptions() override; protected slots: void orientationChangedSlot(Qt::Orientation o); void doLayout(); @@ -223,8 +223,8 @@ private: KviWindowListBase * m_pParent; public: - QSize sizeHint() const; - void paintEvent(QPaintEvent *); + QSize sizeHint() const override; + void paintEvent(QPaintEvent *) override; }; #endif //_KVI_WINDOWLIST_H_ diff --git a/src/kvirc/ui/KviWindowStack.cpp b/src/kvirc/ui/KviWindowStack.cpp index 51ba67261..1c8664265 100644 --- a/src/kvirc/ui/KviWindowStack.cpp +++ b/src/kvirc/ui/KviWindowStack.cpp @@ -87,7 +87,13 @@ void KviWindowStack::addWindow(KviWindow * pWnd) void KviWindowStack::showAndActivate(KviWindow * pWnd) { - setCurrentWidget(pWnd); + if(pWnd->isDocked()) + setCurrentWidget(pWnd); + else + { + pWnd->raise(); + pWnd->activateWindow(); + } if(!pWnd->hasFocus()) pWnd->setFocus(); diff --git a/src/kvirc/ui/KviWindowStack.h b/src/kvirc/ui/KviWindowStack.h index 00c549e52..9c79d740c 100644 --- a/src/kvirc/ui/KviWindowStack.h +++ b/src/kvirc/ui/KviWindowStack.h @@ -64,7 +64,7 @@ public: * \brief Filters out some events: (de)activation events, window switching * \return bool */ - //bool eventFilter(QObject *obj, QEvent *event); + //bool eventFilter(QObject *obj, QEvent *event) override; protected: /// Holds the specialized window popup QMenu * m_pWindowPopup; @@ -88,7 +88,7 @@ public: * \brief Returns the window popup * \return QMenu * */ - inline QMenu * windowPopup() { return m_pWindowPopup; }; + QMenu * windowPopup() const { return m_pWindowPopup; } /** * \brief Remove and delete the subwindow diff --git a/src/modules/about/AboutDialog.cpp b/src/modules/about/AboutDialog.cpp index 2f177a253..c1d33bd34 100644 --- a/src/modules/about/AboutDialog.cpp +++ b/src/modules/about/AboutDialog.cpp @@ -42,6 +42,10 @@ #include <QEvent> #include <QCloseEvent> +#ifdef COMPILE_SSL_SUPPORT +#include <openssl/crypto.h> +#endif //COMPILE_SSL_SUPPORT + extern AboutDialog * g_pAboutDialog; /* "<font color=\"#FFFF00\"><b>KVIrc public releases :</b></font><br>\n" \ @@ -159,10 +163,6 @@ AboutDialog::AboutDialog() infoString += ": "; infoString += KviBuildInfo::buildRevision(); infoString += "<br>"; - infoString += __tr2qs_ctx("System name", "about"); - infoString += ": "; - infoString += KviBuildInfo::buildSystem(); - infoString += "<br>"; infoString += __tr2qs_ctx("CPU name", "about"); infoString += ": "; infoString += KviBuildInfo::buildCPU(); @@ -191,6 +191,32 @@ AboutDialog::AboutDialog() infoString += __tr2qs_ctx("Features", "about"); infoString += ": "; infoString += KviBuildInfo::features(); +#ifdef COMPILE_SSL_SUPPORT + infoString += "<br>"; + infoString += __tr2qs_ctx("OpenSSL version", "about"); + infoString += ": "; +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) + infoString += SSLeay_version(SSLEAY_VERSION); +#else + infoString += OpenSSL_version(OPENSSL_VERSION); +#endif + infoString += "<br>"; + infoString += __tr2qs_ctx("OpenSSL compiler flags", "about"); + infoString += ": "; +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) + infoString += SSLeay_version(SSLEAY_CFLAGS); +#else + infoString += OpenSSL_version(OPENSSL_CFLAGS); +#endif + infoString += "<br>"; + infoString += __tr2qs_ctx("OpenSSL ", "about"); +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) + infoString += SSLeay_version(SSLEAY_BUILT_ON); +#else + infoString += OpenSSL_version(OPENSSL_BUILT_ON); +#endif + infoString += "<br>"; +#endif //COMPILE_SSL_SUPPORT v->setText(infoString); @@ -220,7 +246,7 @@ AboutDialog::AboutDialog() QString szLicense; QString szLicensePath; - g_pApp->getGlobalKvircDirectory(szLicensePath, KviApplication::License, "COPYING"); + g_pApp->getGlobalKvircDirectory(szLicensePath, KviApplication::License, "ABOUT-LICENSE"); if(!KviFileUtils::loadFile(szLicensePath, szLicense)) { diff --git a/src/modules/about/AboutDialog.h b/src/modules/about/AboutDialog.h index 7f4f819df..6cf4608e2 100644 --- a/src/modules/about/AboutDialog.h +++ b/src/modules/about/AboutDialog.h @@ -34,7 +34,7 @@ public: ~AboutDialog(); protected: - virtual void closeEvent(QCloseEvent * e); + void closeEvent(QCloseEvent * e) override; protected slots: void closeButtonPressed(); }; diff --git a/src/modules/about/abouttext.inc b/src/modules/about/abouttext.inc index 93141bd8e..617eba562 100644 --- a/src/modules/about/abouttext.inc +++ b/src/modules/about/abouttext.inc @@ -4,11 +4,11 @@ static const char * g_szAboutText = "" \ "<title>Honor and glory</title>" \ "</head>" \ "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FF0000\"><center>" \ -"<h4>" \ +"<h4><font color=\"#000000\">" \ "This is a partial list of the people that have " \ "contributed in some way to the KVIrc project.<br><br>" \ "Honor and glory to:<br>" \ -"</h4>" \ +"</font></h4>" \ "<br><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">" \ "<tr><td align=\"center\">" \ "<font color=\"#000000\" size=\"+3\"><b>Core developers</b></font>" \ diff --git a/src/modules/about/libkviabout.h b/src/modules/about/libkviabout.h index b396f64eb..386b488fd 100644 --- a/src/modules/about/libkviabout.h +++ b/src/modules/about/libkviabout.h @@ -44,8 +44,8 @@ public: KviDlgAbout * m_pAboutDialog; QPixmap * m_pMemPixmap; public: - virtual void drawContents(QPainter *p); - virtual void resizeEvent(QResizeEvent *e); + void drawContents(QPainter *p) override; + void resizeEvent(QResizeEvent *e) override; }; @@ -60,8 +60,8 @@ public: // void closed(); private slots: void close(); - virtual void closeEvent(QCloseEvent *); -// virtual void paintEvent(QPaintEvent *); + void closeEvent(QCloseEvent *) override; +// void paintEvent(QPaintEvent *) override; void scrollText(); public: int m_posy; @@ -80,7 +80,7 @@ public: private slots: void close(); private: - virtual void closeEvent(QCloseEvent *); + void closeEvent(QCloseEvent *) override; QLabel * m_pPicLabel; QLabel * m_pTextLabel; diff --git a/src/modules/about/mkabouttext.pl b/src/modules/about/mkabouttext.pl index a5c0da76f..6e6fc99a4 100755 --- a/src/modules/about/mkabouttext.pl +++ b/src/modules/about/mkabouttext.pl @@ -120,11 +120,11 @@ p " </head>"; p " <body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FF0000\"><center>"; -p " <h4>"; +p " <h4><font color=\"#000000\">"; p "This is a partial list of the people that have "; p "contributed in some way to the KVIrc project.<br><br>"; p "Honor and glory to:<br>"; -p " </h4>"; +p " </font></h4>"; $i = 0; $cnt++; diff --git a/src/modules/actioneditor/ActionEditor.cpp b/src/modules/actioneditor/ActionEditor.cpp index 19d6cddd3..d90d4fb35 100644 --- a/src/modules/actioneditor/ActionEditor.cpp +++ b/src/modules/actioneditor/ActionEditor.cpp @@ -72,7 +72,7 @@ ActionEditorTreeWidgetItem::ActionEditorTreeWidgetItem(QTreeWidget * v, ActionDa m_pTreeWidget = v; //setFlags(Qt::ItemIsUserSelectable); QString t = "<b>" + m_pActionData->m_szName + "</b>"; - t += "<br><font color=\"#454545\" size=\"-1\">" + m_pActionData->m_szVisibleName + "</font>"; + t += R"(<br><font color="#454545" size="-1">)" + m_pActionData->m_szVisibleName + "</font>"; m_szKey = m_pActionData->m_szName.toUpper(); setText(0, t); QPixmap * p = g_pIconManager->getBigIcon(m_pActionData->m_szBigIcon); diff --git a/src/modules/actioneditor/ActionEditor.h b/src/modules/actioneditor/ActionEditor.h index 0877f524a..cd35d1e80 100644 --- a/src/modules/actioneditor/ActionEditor.h +++ b/src/modules/actioneditor/ActionEditor.h @@ -79,9 +79,6 @@ public: protected: ActionData * m_pActionData; - //QSimpleRichText * m_pText; - QTextDocument * m_pText; - QPixmap * m_pIcon; QTreeWidget * m_pTreeWidget; QString m_szKey; @@ -102,7 +99,7 @@ public: ~ActionEditorTreeView(); protected: - virtual void resizeEvent(QResizeEvent * e); + void resizeEvent(QResizeEvent * e) override; }; class SingleActionEditor : public QWidget @@ -195,10 +192,10 @@ protected: ActionEditor * m_pEditor; protected: - virtual QPixmap * myIconPtr(); - virtual void getConfigGroupName(QString & szName); - virtual void saveProperties(KviConfigurationFile *); - virtual void loadProperties(KviConfigurationFile *); + QPixmap * myIconPtr() override; + void getConfigGroupName(QString & szName) override; + void saveProperties(KviConfigurationFile *) override; + void loadProperties(KviConfigurationFile *) override; protected slots: void cancelClicked(); void okClicked(); diff --git a/src/modules/addon/AddonFunctions.cpp b/src/modules/addon/AddonFunctions.cpp index 5ffd5466c..5aa50a1be 100644 --- a/src/modules/addon/AddonFunctions.cpp +++ b/src/modules/addon/AddonFunctions.cpp @@ -44,7 +44,7 @@ #include <QFile> #include <QDateTime> -#include <stdlib.h> +#include <cstdlib> namespace AddonFunctions { diff --git a/src/modules/addon/AddonFunctions.h b/src/modules/addon/AddonFunctions.h index 6d4d9cae2..27071dc56 100644 --- a/src/modules/addon/AddonFunctions.h +++ b/src/modules/addon/AddonFunctions.h @@ -50,7 +50,7 @@ namespace AddonFunctions bool checkDirTree(const QString & szDirPath, QString * pszError); bool pack(AddonInfo & info, QString & szError); bool notAValidAddonPackage(QString & szError); - bool installAddonPackage(const QString & szAddonPackageFileName, QString & szError, QWidget * pDialogParent = 0); + bool installAddonPackage(const QString & szAddonPackageFileName, QString & szError, QWidget * pDialogParent = nullptr); QString createRandomDir(); } diff --git a/src/modules/addon/AddonManagementDialog.h b/src/modules/addon/AddonManagementDialog.h index 2a1a50d74..86abd484a 100644 --- a/src/modules/addon/AddonManagementDialog.h +++ b/src/modules/addon/AddonManagementDialog.h @@ -47,8 +47,6 @@ public: protected: KviKvsScriptAddon * m_pAddon; - QTextDocument * m_pText; - QPixmap * m_pIcon; QListWidget * m_pListWidget; QString m_szKey; @@ -86,7 +84,7 @@ public: protected: void fillListView(); - virtual void closeEvent(QCloseEvent * e); + void closeEvent(QCloseEvent * e) override; protected slots: void currentChanged(QListWidgetItem * i, QListWidgetItem *); void closeClicked(); diff --git a/src/modules/addon/PackAddonDialog.cpp b/src/modules/addon/PackAddonDialog.cpp index cf416a4c3..6bb8c7099 100644 --- a/src/modules/addon/PackAddonDialog.cpp +++ b/src/modules/addon/PackAddonDialog.cpp @@ -182,7 +182,7 @@ bool PackAddonDialog::packAddon() return false; } - QMessageBox::information(this, __tr2qs_ctx("Exporting Addon Completed - KVIrc", "addon"), __tr2qs_ctx("The Package was saved successfully in %1", "addon").arg(m_szSavePath), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); + QMessageBox::information(this, __tr2qs_ctx("Exporting Addon Completed - KVIrc", "addon"), __tr2qs_ctx("The package was saved successfully in %1", "addon").arg(info.szSavePath), QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); return true; } diff --git a/src/modules/addon/PackAddonDialog.h b/src/modules/addon/PackAddonDialog.h index e9b88bc33..4464f2da0 100644 --- a/src/modules/addon/PackAddonDialog.h +++ b/src/modules/addon/PackAddonDialog.h @@ -92,7 +92,7 @@ protected: * \brief Runs the packAddon() function and closes the wizard * \return void */ - virtual void accept(); + void accept() override; /** * \brief Creates the addon package @@ -201,7 +201,7 @@ protected: * \brief Perform initial tasks before showing the widget * \return void */ - virtual void initializePage(); + void initializePage() override; }; /** @@ -226,17 +226,13 @@ public: protected: QLabel * m_pLabelInfo; - QLabel * m_pLabelAuthor; - QLabel * m_pPackageName; - QLabel * m_pPackageVersion; - QLabel * m_pPackageDescription; protected: /** * \brief Perform initial tasks before showing the widget * \return void */ - virtual void initializePage(); + void initializePage() override; }; class PackAddonSummaryFilesWidget : public QDialog @@ -253,10 +249,10 @@ protected: public: void setPath(QString & szPath) { m_szPath = szPath; }; protected: - virtual void showEvent(QShowEvent *); + void showEvent(QShowEvent *) override; protected slots: - virtual void accept(); - virtual void reject(); + void accept() override; + void reject() override; }; #endif //!_PACKADDONDIALOG_H_ diff --git a/src/modules/aliaseditor/AliasEditorWindow.cpp b/src/modules/aliaseditor/AliasEditorWindow.cpp index 7870564c3..634e916a4 100644 --- a/src/modules/aliaseditor/AliasEditorWindow.cpp +++ b/src/modules/aliaseditor/AliasEditorWindow.cpp @@ -137,6 +137,9 @@ AliasEditorWidget::AliasEditorWidget(QWidget * par) m_pTreeWidget = new AliasEditorTreeWidget(box); + QPushButton * btn = new QPushButton(__tr2qs_ctx("&Export All to...", "editor"), box); + connect(btn, SIGNAL(clicked()), this, SLOT(exportAll())); + box = new KviTalVBox(m_pSplitter); KviTalHBox * hbox = new KviTalHBox(box); hbox->setSpacing(0); @@ -361,7 +364,7 @@ void AliasEditorWidget::itemRenamed(QTreeWidgetItem * it, int col) bool AliasEditorWidget::hasSelectedItems() { - return m_pTreeWidget->selectedItems().count() ? 1 : 0; + return m_pTreeWidget->selectedItems().count() ? true : false; } bool AliasEditorWidget::itemExists(QTreeWidgetItem * pSearchFor) diff --git a/src/modules/aliaseditor/AliasEditorWindow.h b/src/modules/aliaseditor/AliasEditorWindow.h index c9102b559..f9dd3d8ee 100644 --- a/src/modules/aliaseditor/AliasEditorWindow.h +++ b/src/modules/aliaseditor/AliasEditorWindow.h @@ -62,17 +62,17 @@ protected: int m_cPos; public: - inline const QString & name() { return m_szName; }; + const QString & name() const { return m_szName; } void setName(const QString & szName); - inline Type type() { return m_eType; }; + Type type() const { return m_eType; } void setType(Type t); - inline bool isAlias() { return m_eType == Alias; }; - inline bool isNamespace() { return m_eType == Namespace; }; + bool isAlias() const { return m_eType == Alias; } + bool isNamespace() const { return m_eType == Namespace; } void setParentItem(AliasEditorTreeWidgetItem * it) { m_pParentItem = it; }; AliasEditorTreeWidgetItem * parentItem() { return m_pParentItem; }; - inline void setBuffer(const QString & szBuffer) { m_szBuffer = szBuffer; }; - inline const QString & buffer() { return m_szBuffer; }; - inline const int & cursorPosition() { return m_cPos; }; + void setBuffer(const QString & szBuffer) { m_szBuffer = szBuffer; } + const QString & buffer() const { return m_szBuffer; } + const int & cursorPosition() const { return m_cPos; } void setCursorPosition(const int & cPos) { m_cPos = cPos; }; }; @@ -182,10 +182,10 @@ protected: AliasEditorWidget * m_pEditor; protected: - virtual QPixmap * myIconPtr(); - virtual void getConfigGroupName(QString & szName); - virtual void saveProperties(KviConfigurationFile *); - virtual void loadProperties(KviConfigurationFile *); + QPixmap * myIconPtr() override; + void getConfigGroupName(QString & szName) override; + void saveProperties(KviConfigurationFile *) override; + void loadProperties(KviConfigurationFile *) override; protected slots: void cancelClicked(); void okClicked(); diff --git a/src/modules/avatar/libkviavatar.h b/src/modules/avatar/libkviavatar.h index 0509ebc2f..54f3c5a5a 100644 --- a/src/modules/avatar/libkviavatar.h +++ b/src/modules/avatar/libkviavatar.h @@ -45,7 +45,7 @@ protected: KviIrcConnection * m_pConnection; protected: - virtual void closeEvent(QCloseEvent * e); + void closeEvent(QCloseEvent * e) override; const QString & avatarName() { return m_szAvatarName; }; protected slots: void okClicked(); diff --git a/src/modules/channelsjoin/ChannelsJoinDialog.cpp b/src/modules/channelsjoin/ChannelsJoinDialog.cpp index b373e87ea..d2c03f419 100644 --- a/src/modules/channelsjoin/ChannelsJoinDialog.cpp +++ b/src/modules/channelsjoin/ChannelsJoinDialog.cpp @@ -61,8 +61,6 @@ ChannelsJoinDialog::ChannelsJoinDialog(const char * name) setWindowTitle(__tr2qs("Join Channels - KVIrc")); setWindowIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Channel))); - m_pConsole = nullptr; - QGridLayout * g = new QGridLayout(this); m_pTreeWidget = new ChannelsJoinDialogTreeWidget(this); diff --git a/src/modules/channelsjoin/ChannelsJoinDialog.h b/src/modules/channelsjoin/ChannelsJoinDialog.h index 1022ac08d..541fcfe81 100644 --- a/src/modules/channelsjoin/ChannelsJoinDialog.h +++ b/src/modules/channelsjoin/ChannelsJoinDialog.h @@ -37,8 +37,8 @@ #include <QTreeWidget> class KviConsoleWindow; -class QGroupBox; class QCheckBox; +class QGroupBox; class QLineEdit; class QPushButton; class QString; @@ -52,7 +52,7 @@ class ChannelsJoinDialogTreeWidget : public QTreeWidget Q_OBJECT public: ChannelsJoinDialogTreeWidget(QWidget * par) - : QTreeWidget(par), m_pJoinPopup(nullptr){}; + : QTreeWidget(par){}; ~ChannelsJoinDialogTreeWidget() { @@ -61,14 +61,14 @@ public: }; protected: - QMenu * m_pJoinPopup; + QMenu * m_pJoinPopup = nullptr; /** * \brief Called when the user clicks on the list * \param e mouse event descriptor * \return void */ - virtual void mousePressEvent(QMouseEvent * e); - virtual void mouseDoubleClickEvent(QMouseEvent * e); + void mousePressEvent(QMouseEvent * e) override; + void mouseDoubleClickEvent(QMouseEvent * e) override; }; /** @@ -100,19 +100,19 @@ protected: RecentChannelItem, RegisteredChannelItem }; - QLineEdit * m_pChannelEdit; - ChannelsJoinDialogTreeWidget * m_pTreeWidget; - QGroupBox * m_pGroupBox; - QLineEdit * m_pPass; - QCheckBox * m_pShowAtStartupCheck; - QCheckBox * m_pCloseAfterJoinCheck; - QPushButton * m_pJoinButton; - QPushButton * m_pRegButton; - QPushButton * m_pClearButton; - KviConsoleWindow * m_pConsole; + QLineEdit * m_pChannelEdit = nullptr; + ChannelsJoinDialogTreeWidget * m_pTreeWidget = nullptr; + QGroupBox * m_pGroupBox = nullptr; + QLineEdit * m_pPass = nullptr; + QCheckBox * m_pShowAtStartupCheck = nullptr; + QCheckBox * m_pCloseAfterJoinCheck = nullptr; + QPushButton * m_pJoinButton = nullptr; + QPushButton * m_pRegButton = nullptr; + QPushButton * m_pClearButton = nullptr; + KviConsoleWindow * m_pConsole = nullptr; public: - virtual void closeEvent(QCloseEvent * e); + void closeEvent(QCloseEvent * e) override; /** * \brief Fills in the servers' list diff --git a/src/modules/classeditor/ClassEditorWindow.cpp b/src/modules/classeditor/ClassEditorWindow.cpp index 8f9c5d1bb..39c265341 100644 --- a/src/modules/classeditor/ClassEditorWindow.cpp +++ b/src/modules/classeditor/ClassEditorWindow.cpp @@ -461,7 +461,7 @@ void ClassEditorWidget::createFullClass(KviKvsObjectClass * pClass, ClassEditorT bool ClassEditorWidget::hasSelectedItems() { - return m_pTreeWidget->selectedItems().count() ? 1 : 0; + return m_pTreeWidget->selectedItems().count() ? true : false; } bool ClassEditorWidget::classExists(QString & szFullItemName) @@ -808,7 +808,7 @@ void ClassEditorWidget::currentItemChanged(QTreeWidgetItem * pTree, QTreeWidgetI { QString szReminderText = __tr2qs_ctx("Reminder text.", "editor"); szReminderText += ": <b>"; - szReminderText += m_pLastEditedItem->reminder().toHtmlEscaped(); + szReminderText += m_pLastEditedItem->reminder(); szReminderText += "</b>"; m_pReminderLabel->setText(szReminderText); m_pReminderLabel->show(); @@ -1054,15 +1054,12 @@ void ClassEditorWidget::exportClassBuffer(QString & szBuffer, ClassEditorTreeWid ClassEditorTreeWidgetItem * pFunction = (ClassEditorTreeWidgetItem *)pItem->child(i); if(pFunction->isMethod()) { - QString reminder = pFunction->reminder(); - KviQString::escapeKvs(&reminder); - szBuffer += "\t"; if(pFunction->isInternalFunction()) szBuffer += "internal "; szBuffer += "function "; szBuffer += pFunction->name(); - szBuffer += "(\"" + reminder + "\")\n"; + szBuffer += "(" + pFunction->reminder() + ")\n"; QString szCode = pFunction->buffer(); KviCommandFormatter::blockFromBuffer(szCode); KviCommandFormatter::indent(szCode); @@ -2074,7 +2071,7 @@ KviClassEditorFunctionDialog::KviClassEditorFunctionDialog(QWidget * pParent, co pLabel = new QLabel(pHBox); pLabel->setObjectName("reminderlabel"); - pLabel->setWordWrap(1); + pLabel->setWordWrap(true); pLabel->setText(__tr2qs_ctx("Please enter the optional reminder string for the member function:", "editor")); m_pReminderLineEdit = new QLineEdit(pHBox); diff --git a/src/modules/classeditor/ClassEditorWindow.h b/src/modules/classeditor/ClassEditorWindow.h index e12386a5e..c320937a2 100644 --- a/src/modules/classeditor/ClassEditorWindow.h +++ b/src/modules/classeditor/ClassEditorWindow.h @@ -73,7 +73,7 @@ public: ~ClassEditorTreeWidget(); protected: - virtual void mousePressEvent(QMouseEvent * e); + void mousePressEvent(QMouseEvent * e) override; signals: /** * \brief Emitted when we press the mouse right button @@ -305,14 +305,14 @@ public: * \param pCfg The configuration file * \return void */ - virtual void saveProperties(KviConfigurationFile * pCfg); + void saveProperties(KviConfigurationFile * pCfg); /** * \brief Called to load the window properties * \param pCfg The configuration file * \return void */ - virtual void loadProperties(KviConfigurationFile * pCfg); + void loadProperties(KviConfigurationFile * pCfg); /** * \brief Builds the class! @@ -497,7 +497,7 @@ protected: * \brief Returns the class editor small icon * \return QPixmap * */ - virtual QPixmap * myIconPtr(); + QPixmap * myIconPtr() override; /** * \brief Sets the configuration group name as classeditor @@ -511,14 +511,14 @@ protected: * \param pCfg The configuration file * \return void */ - virtual void saveProperties(KviConfigurationFile * pCfg); + void saveProperties(KviConfigurationFile * pCfg) override; /** * \brief Called to load the window properties * \param pCfg The configuration file * \return void */ - virtual void loadProperties(KviConfigurationFile * pCfg); + void loadProperties(KviConfigurationFile * pCfg) override; protected slots: /** * \brief Called when we click the cancel button diff --git a/src/modules/codetester/CodeTesterWindow.cpp b/src/modules/codetester/CodeTesterWindow.cpp index 1e8b4a762..951553b2c 100644 --- a/src/modules/codetester/CodeTesterWindow.cpp +++ b/src/modules/codetester/CodeTesterWindow.cpp @@ -34,6 +34,7 @@ #include "KviConsoleWindow.h" #include "KviKvsScript.h" #include "KviKvsVariantList.h" +#include "KviIrcView.h" #include <QPushButton> #include <QLayout> @@ -44,11 +45,19 @@ extern std::unordered_set<CodeTesterWindow *> g_pCodeTesterWindowList; -CodeTesterWidget::CodeTesterWidget(QWidget * par) - : QWidget(par) +CodeTesterWindow::CodeTesterWindow() + : KviWindow(KviWindow::ScriptEditor, "codetester", nullptr) { + g_pCodeTesterWindowList.insert(this); setObjectName("code_tester"); - QGridLayout * g = new QGridLayout(this); + + m_pSplitter = new KviTalSplitter(Qt::Horizontal, this); + m_pSplitter->setObjectName("main_splitter"); + m_pSplitter->setChildrenCollapsible(false); + + // layouts can't be added to splitters directly, so we embed the layout in a widget. + QWidget * l = new QWidget(this); + QGridLayout * g = new QGridLayout(l); m_pEditor = KviScriptEditor::createInstance(this); g->addWidget(m_pEditor, 0, 0, 1, 4); @@ -61,36 +70,28 @@ CodeTesterWidget::CodeTesterWidget(QWidget * par) m_pParams = new QLineEdit(this); m_pParams->setToolTip(__tr2qs_ctx("Here you can specify a semicolon-separated list of parameters that will be available in the code as $0, $1, $2, ..", "editor")); g->addWidget(m_pParams, 1, 2); + + m_pSplitter->addWidget(l); + + m_pIrcView = new KviIrcView(m_pSplitter, this); + + QList<int> li { width() / 2, width() / 2 }; + m_pSplitter->setSizes(li); } -CodeTesterWidget::~CodeTesterWidget() +CodeTesterWindow::~CodeTesterWindow() { KviScriptEditor::destroyInstance(m_pEditor); + g_pCodeTesterWindowList.erase(this); } -//#warning "Allow to bind the command to a specified window" - -void CodeTesterWidget::execute() +void CodeTesterWindow::execute() { QString buffer; m_pEditor->getText(buffer); - KviConsoleWindow * pConsole = g_pApp->activeConsole(); QStringList slParams = m_pParams->text().split(';'); KviKvsVariantList params{&slParams}; - KviKvsScript::run(buffer, pConsole, ¶ms); -} - -CodeTesterWindow::CodeTesterWindow() - : KviWindow(KviWindow::ScriptEditor, "codetester", nullptr) -{ - g_pCodeTesterWindowList.insert(this); - - m_pTester = new CodeTesterWidget(this); -} - -CodeTesterWindow::~CodeTesterWindow() -{ - g_pCodeTesterWindowList.erase(this); + KviKvsScript::run(buffer, this, ¶ms); } QPixmap * CodeTesterWindow::myIconPtr() @@ -100,7 +101,7 @@ QPixmap * CodeTesterWindow::myIconPtr() void CodeTesterWindow::resizeEvent(QResizeEvent *) { - m_pTester->setGeometry(0, 0, width(), height()); + m_pSplitter->setGeometry(0, 0, width(), height()); } void CodeTesterWindow::fillCaptionBuffers() diff --git a/src/modules/codetester/CodeTesterWindow.h b/src/modules/codetester/CodeTesterWindow.h index 992ce52e5..d71dbbf31 100644 --- a/src/modules/codetester/CodeTesterWindow.h +++ b/src/modules/codetester/CodeTesterWindow.h @@ -33,39 +33,30 @@ class QPushButton; class QLabel; class KviScriptEditor; -class CodeTesterWidget : public QWidget +class CodeTesterWindow : public KviWindow { Q_OBJECT public: - CodeTesterWidget(QWidget * par); - ~CodeTesterWidget(); + CodeTesterWindow(); + ~CodeTesterWindow(); private: + KviTalSplitter * m_pSplitter; KviScriptEditor * m_pEditor; - QLineEdit * m_pParams; QPushButton * m_pExecuteButton; QLabel * m_pModeLabel; + QLineEdit * m_pParams; + private slots: void execute(); -}; - -class CodeTesterWindow : public KviWindow -{ - Q_OBJECT -public: - CodeTesterWindow(); - ~CodeTesterWindow(); - -protected: - CodeTesterWidget * m_pTester; protected: - virtual QPixmap * myIconPtr(); - virtual void fillCaptionBuffers(); - virtual void resizeEvent(QResizeEvent * e); - virtual void getConfigGroupName(QString & szName); - virtual void saveProperties(KviConfigurationFile *){}; - virtual void loadProperties(KviConfigurationFile *){}; + QPixmap * myIconPtr() override; + void fillCaptionBuffers() override; + void resizeEvent(QResizeEvent * e) override; + void getConfigGroupName(QString & szName) override; + void saveProperties(KviConfigurationFile *) override {} + void loadProperties(KviConfigurationFile *) override {} }; #endif //_CODETESTER_H_ diff --git a/src/modules/context/libkvicontext.cpp b/src/modules/context/libkvicontext.cpp index 163e4e86b..11eaaf93c 100644 --- a/src/modules/context/libkvicontext.cpp +++ b/src/modules/context/libkvicontext.cpp @@ -51,16 +51,16 @@ KVSM_PARAMETERS_BEGIN(c) \ KVSM_PARAMETER("irc_context_id", KVS_PT_UINT, KVS_PF_OPTIONAL, iContextId) \ KVSM_PARAMETERS_END(c) \ - KviConsoleWindow * pConsole = NULL; \ + KviConsoleWindow * pConsole = nullptr; \ if(c->parameterCount() > 0) \ pConsole = g_pApp->findConsole(iContextId); \ else \ pConsole = c->window()->console(); #define GET_CONNECTION_FROM_STANDARD_PARAMS \ - GET_CONSOLE_FROM_STANDARD_PARAMS \ - KviIrcConnection * pConnection = NULL; \ - if(pConsole) \ + GET_CONSOLE_FROM_STANDARD_PARAMS \ + KviIrcConnection * pConnection = nullptr; \ + if(pConsole) \ pConnection = pConsole->context()->connection(); #define STANDARD_IRC_CONNECTION_TARGET_PARAMETER(_fncName, _setCall) \ @@ -655,7 +655,7 @@ static bool context_kvs_fnc_getSSLCertInfo(KviKvsModuleFunctionCall * c) QString szQuery; QString szType; QString szParam1; - bool bRemote = true; + bool bRemote; KVSM_PARAMETERS_BEGIN(c) KVSM_PARAMETER("query", KVS_PT_STRING, 0, szQuery) @@ -689,16 +689,17 @@ static bool context_kvs_fnc_getSSLCertInfo(KviKvsModuleFunctionCall * c) { bRemote = false; } + else if(szType.compare("remote") == 0 || szType.isEmpty()) + { + bRemote = true; + } else { - // already defaults to true, we only catch the error condition - if(szType.compare("remote") != 0) - { - c->warning(__tr2qs("You specified a bad string for the parameter \"type\"")); - c->returnValue()->setString(""); - return true; - } + c->warning(__tr2qs("You specified a bad string for the parameter \"type\"")); + c->returnValue()->setString(""); + return true; } + //context is never null, connection can be null if(!pConsole->context()->connection()) { diff --git a/src/modules/dcc/DccBroker.cpp b/src/modules/dcc/DccBroker.cpp index dda25a544..6de88fe67 100644 --- a/src/modules/dcc/DccBroker.cpp +++ b/src/modules/dcc/DccBroker.cpp @@ -241,7 +241,7 @@ void DccBroker::rsendExecute(DccDescriptor * dcc) szTag = t->m_szTag; // DCC [ST]SEND <filename> <fakeipaddress> <zero-port> <filesize> <sessionid> - dcc->console()->connection()->sendFmtData("PRIVMSG %s :%cDCC %s %s 127.0.0.1 0 %s %s%c", + dcc->console()->connection()->sendFmtData("PRIVMSG %s :%cDCC %s %s 2130706433 0 %s %s%c", dcc->console()->connection()->encodeText(dcc->szNick).data(), 0x01, dcc->console()->connection()->encodeText(dcc->szType).data(), diff --git a/src/modules/dcc/DccCanvasWindow.cpp b/src/modules/dcc/DccCanvasWindow.cpp index 19389dab0..e2adee2a4 100644 --- a/src/modules/dcc/DccCanvasWindow.cpp +++ b/src/modules/dcc/DccCanvasWindow.cpp @@ -114,7 +114,7 @@ DccCanvasWindow::DccCanvasWindow(DccDescriptor * dcc, const char * name) output(KVI_OUT_DCCMSG, __tr2qs_ctx("Contacting host %Q on port %Q", "dcc"), &(dcc->szIp), &(dcc->szPort)); } - // m_pSlaveThread = 0; + // m_pSlaveThread = nullptr; } DccCanvasWindow::~DccCanvasWindow() @@ -124,7 +124,7 @@ DccCanvasWindow::~DccCanvasWindow() // { // m_pSlaveThread->terminate(); // delete m_pSlaveThread; - // m_pSlaveThread = 0; + // m_pSlaveThread = nullptr; // } KviThreadManager::killPendingEvents(this); // delete m_pDescriptor; @@ -162,7 +162,7 @@ void DccCanvasWindow::getBaseLogFileName(KviCString & buffer) buffer.sprintf("%s_%s_%s", m_pDescriptor->szNick.toUtf8().data(), m_pDescriptor->szIp.toUtf8().data(), m_pDescriptor->szPort.toUtf8().data()); } -void DccCanvasWindow::ownMessage(const char * text, bool bUserFeedback) +void DccCanvasWindow::ownMessage(const QString & text, bool bUserFeedback) { KviCString buf(KviCString::Format, "%s\r\n", text); // m_pSlaveThread->sendRawData(buf.ptr(),buf.len()); @@ -173,11 +173,11 @@ void DccCanvasWindow::ownMessage(const char * text, bool bUserFeedback) m_pDescriptor->szLocalHost.toUtf8().data(), text); } -void DccCanvasWindow::ownAction(const char * text) +void DccCanvasWindow::ownAction(const QString & text) { KviCString buf(KviCString::Format, "%cACTION %s%c\r\n", text); // m_pSlaveThread->sendRawData(buf.ptr(),buf.len()); - output(KVI_OUT_ACTION, "%Q %s", &(m_pDescriptor->szLocalNick), text); + output(KVI_OUT_OWNACTION, "%Q %s", &(m_pDescriptor->szLocalNick), text); } bool DccCanvasWindow::event(QEvent * e) diff --git a/src/modules/dcc/DccCanvasWindow.h b/src/modules/dcc/DccCanvasWindow.h index 6b89bc735..7e3e6ff29 100644 --- a/src/modules/dcc/DccCanvasWindow.h +++ b/src/modules/dcc/DccCanvasWindow.h @@ -53,15 +53,15 @@ protected: QString m_szTarget; protected: - virtual const QString & target(); - virtual void fillCaptionBuffers(); - virtual void getBaseLogFileName(KviCString & buffer); - virtual QPixmap * myIconPtr(); - virtual void resizeEvent(QResizeEvent * e); - virtual QSize sizeHint() const; - virtual bool event(QEvent * e); - virtual void ownMessage(const char * text, bool bUserFeedback = true); - virtual void ownAction(const char * text); + const QString & target() override; + void fillCaptionBuffers() override; + void getBaseLogFileName(KviCString & buffer) override; + QPixmap * myIconPtr() override; + void resizeEvent(QResizeEvent * e) override; + QSize sizeHint() const override; + bool event(QEvent * e) override; + void ownMessage(const QString & text, bool bUserFeedback = true) override; + void ownAction(const QString & text) override; protected slots: void handleMarshalError(int err); void connected(); diff --git a/src/modules/dcc/DccChatWindow.cpp b/src/modules/dcc/DccChatWindow.cpp index 1af5aa314..f10caab61 100644 --- a/src/modules/dcc/DccChatWindow.cpp +++ b/src/modules/dcc/DccChatWindow.cpp @@ -407,7 +407,7 @@ void DccChatWindow::ownAction(const QString & text) return; KviCString buf(KviCString::Format, "%cACTION %s%c\r\n", 0x01, d, 0x01); m_pSlaveThread->sendRawData(buf.ptr(), buf.len()); - output(KVI_OUT_ACTION, "%Q %Q", &(m_pDescriptor->szLocalNick), &szTmpBuffer); + output(KVI_OUT_OWNACTION, "%Q %Q", &(m_pDescriptor->szLocalNick), &szTmpBuffer); } else { @@ -904,9 +904,9 @@ bool DccChatThread::tryFlushOutBuffers() { int err = kvi_socket_error(); #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - if((err != EAGAIN) || (err != EINTR) || (err != WSAEWOULDBLOCK)) + if((err != EAGAIN) && (err != EINTR) && (err != WSAEWOULDBLOCK)) #else - if((err != EAGAIN) || (err != EINTR)) + if((err != EAGAIN) && (err != EINTR)) #endif { postErrorEvent(KviError::translateSystemError(err)); diff --git a/src/modules/dcc/DccChatWindow.h b/src/modules/dcc/DccChatWindow.h index b23da0943..2af9892c0 100644 --- a/src/modules/dcc/DccChatWindow.h +++ b/src/modules/dcc/DccChatWindow.h @@ -74,7 +74,7 @@ class DccChatWindow : public DccWindow public: DccChatWindow(DccDescriptor * dcc, const char * name); ~DccChatWindow(); - QFrame * buttonContainer() { return (QFrame *)m_pButtonContainer; }; + QFrame * buttonContainer() override { return (QFrame *)m_pButtonContainer; } protected: DccChatThread * m_pSlaveThread; QString m_szTarget; @@ -84,20 +84,20 @@ protected: KviTalHBox * m_pButtonContainer; protected: - virtual const QString & target(); - virtual void fillCaptionBuffers(); - virtual void getBaseLogFileName(QString & buffer); - virtual QPixmap * myIconPtr(); - virtual void resizeEvent(QResizeEvent * e); - virtual QSize sizeHint() const; - virtual const QString & localNick(); - virtual bool event(QEvent * e); - virtual void ownMessage(const QString & text, bool bUserFeedback = true); - virtual void ownAction(const QString & text); - virtual void triggerCreationEvents(); - virtual void triggerDestructionEvents(); + const QString & target() override; + void fillCaptionBuffers() override; + void getBaseLogFileName(QString & buffer) override; + QPixmap * myIconPtr() override; + void resizeEvent(QResizeEvent * e) override; + QSize sizeHint() const override; + const QString & localNick() override; + bool event(QEvent * e) override; + void ownMessage(const QString & text, bool bUserFeedback = true) override; + void ownAction(const QString & text) override; + void triggerCreationEvents() override; + void triggerDestructionEvents() override; void startConnection(); - virtual DccThread * getSlaveThread() { return m_pSlaveThread; }; + DccThread * getSlaveThread() override { return m_pSlaveThread; } protected slots: void handleMarshalError(KviError::Code eError); void connected(); diff --git a/src/modules/dcc/DccDialog.cpp b/src/modules/dcc/DccDialog.cpp index a6d113404..6beb70ad8 100644 --- a/src/modules/dcc/DccDialog.cpp +++ b/src/modules/dcc/DccDialog.cpp @@ -27,6 +27,7 @@ #include "KviLocale.h" #include "KviIconManager.h" #include "KviApplication.h" +#include "KviMainWindow.h" #include <QLayout> #include <QPushButton> @@ -119,8 +120,11 @@ void DccAcceptDialog::closeEvent(QCloseEvent * e) void DccAcceptDialog::showEvent(QShowEvent * e) { - QRect rect = g_pApp->desktop()->screenGeometry(g_pApp->desktop()->primaryScreen()); - move((rect.width() - width()) / 2, (rect.height() - height()) / 2); + int iScreen = g_pApp->desktop()->screenNumber(g_pMainWindow); + if(iScreen < 0) + iScreen = g_pApp->desktop()->primaryScreen(); + QRect rect = g_pApp->desktop()->screenGeometry(iScreen); + move(rect.x() + ((rect.width() - width()) / 2),rect.y() + ((rect.height() - height()) / 2)); QWidget::showEvent(e); } @@ -182,8 +186,11 @@ void DccRenameDialog::closeEvent(QCloseEvent * e) void DccRenameDialog::showEvent(QShowEvent * e) { - QRect rect = g_pApp->desktop()->screenGeometry(g_pApp->desktop()->primaryScreen()); - move((rect.width() - width()) / 2, (rect.height() - height()) / 2); + int iScreen = g_pApp->desktop()->screenNumber(g_pMainWindow); + if(iScreen < 0) + iScreen = g_pApp->desktop()->primaryScreen(); + QRect rect = g_pApp->desktop()->screenGeometry(iScreen); + move(rect.x() + ((rect.width() - width()) / 2),rect.y() + ((rect.height() - height()) / 2)); QWidget::showEvent(e); } diff --git a/src/modules/dcc/DccDialog.h b/src/modules/dcc/DccDialog.h index ded6dc942..a6e6d8c7d 100644 --- a/src/modules/dcc/DccDialog.h +++ b/src/modules/dcc/DccDialog.h @@ -50,8 +50,8 @@ public: ~DccAcceptDialog(); protected: - virtual void closeEvent(QCloseEvent * e); - virtual void showEvent(QShowEvent * e); + void closeEvent(QCloseEvent * e) override; + void showEvent(QShowEvent * e) override; private slots: void acceptClicked(); void rejectClicked(); @@ -68,8 +68,8 @@ public: ~DccRenameDialog(); protected: - virtual void closeEvent(QCloseEvent * e); - virtual void showEvent(QShowEvent * e); + void closeEvent(QCloseEvent * e) override; + void showEvent(QShowEvent * e) override; private slots: void renameClicked(); void overwriteClicked(); diff --git a/src/modules/dcc/DccFileTransfer.cpp b/src/modules/dcc/DccFileTransfer.cpp index 2f3302521..34fa1ff34 100644 --- a/src/modules/dcc/DccFileTransfer.cpp +++ b/src/modules/dcc/DccFileTransfer.cpp @@ -1035,13 +1035,6 @@ void DccSendThread::run() goto handle_system_error; break; case KviSSL::SyscallError: - if(written == 0) - { - raiseSSLError(); - postErrorEvent(KviError::RemoteEndClosedConnection); - goto exit_dcc; - } - else { int iSSLErr = m_pSSL->getLastError(true); if(iSSLErr != 0) @@ -1889,9 +1882,9 @@ QString DccFileTransfer::tipText() { QString s; - s = QString("<table><tr><td bgcolor=\"#000000\"><font color=\"#FFFFFF\"><b>DCC %1 (ID %2)</b></font></td></tr>").arg(m_szDccType.ptr()).arg(id()); + s = QString(R"(<table><tr><td bgcolor="#000000"><font color="#FFFFFF"><b>DCC %1 (ID %2)</b></font></td></tr>)").arg(m_szDccType.ptr()).arg(id()); - s += "<tr><td bgcolor=\"#404040\"><font color=\"#FFFFFF\">"; + s += R"(<tr><td bgcolor="#404040"><font color="#FFFFFF">)"; s += __tr2qs_ctx("Transfer Log", "dcc"); s += "</font></td></tr>"; s += "<tr><td bgcolor=\"#C0C0C0\">"; @@ -2386,12 +2379,6 @@ bool DccFileTransfer::doResume(const char * filename, const char * port, quint64 if(!bFileNameMatches) { - // bad file name - if(!bPortMatches) - return false; // neither filename nor port match - - // port matches (this is very likely to be the right transfer) - if(!KVI_OPTION_BOOL(KviOption_boolAcceptBrokenFileNameDccResumeRequests)) { if(_OUTPUT_VERBOSE) diff --git a/src/modules/dcc/DccFileTransfer.h b/src/modules/dcc/DccFileTransfer.h index f8fb48a05..4154cdcfc 100644 --- a/src/modules/dcc/DccFileTransfer.h +++ b/src/modules/dcc/DccFileTransfer.h @@ -51,7 +51,7 @@ class DccFileTransfer; class DccMarshal; class QMenu; -typedef struct _KviDccSendThreadOptions +struct KviDccSendThreadOptions { KviCString szFileName; quint64 uStartPosition; @@ -61,7 +61,7 @@ typedef struct _KviDccSendThreadOptions bool bNoAcks; bool bIsTdcc; unsigned int uMaxBandwidth; -} KviDccSendThreadOptions; +}; class DccSendThread : public DccThread { @@ -74,8 +74,8 @@ private: uint m_uAverageSpeed; uint m_uInstantSpeed; quint64 m_uFilePosition; - quint64 m_uAckedBytes; - quint64 m_uTotalSentBytes; + quint64 m_uAckedBytes = 0; + quint64 m_uTotalSentBytes = 0; // internal unsigned long m_uStartTime; unsigned long m_uInstantSpeedInterval; @@ -99,7 +99,7 @@ protected: virtual void run(); }; -typedef struct _KviDccRecvThreadOptions +struct KviDccRecvThreadOptions { bool bResume; KviCString szFileName; @@ -110,7 +110,7 @@ typedef struct _KviDccRecvThreadOptions bool bNoAcks; bool bIsTdcc; unsigned int uMaxBandwidth; -} KviDccRecvThreadOptions; +}; class DccRecvThread : public DccThread { @@ -165,7 +165,7 @@ protected: QSpinBox * m_pLimitBox; protected: - virtual void closeEvent(QCloseEvent * e); + void closeEvent(QCloseEvent * e) override; protected slots: void okClicked(); void cancelClicked(); @@ -221,18 +221,18 @@ public: static bool handleResumeAccepted(const char * filename, const char * port, const char * szZeroPortTag); static bool handleResumeRequest(const char * filename, const char * port, quint64 filePos); - virtual bool event(QEvent * e); + bool event(QEvent * e) override; - virtual KviWindow * dccMarshalOutputWindow(); - virtual const char * dccMarshalOutputContextString(); + KviWindow * dccMarshalOutputWindow() override; + const char * dccMarshalOutputContextString() override; - virtual void displayPaint(QPainter * p, int column, QRect rect); - virtual int displayHeight(int iLineSpacing); - virtual void fillContextPopup(QMenu * m); + void displayPaint(QPainter * p, int column, QRect rect) override; + int displayHeight(int iLineSpacing) override; + void fillContextPopup(QMenu * m) override; virtual void fillStatusString(QString & szBuffer); - virtual bool active(); - virtual QString tipText(); - virtual QString localFileName(); + bool active() override; + QString tipText() override; + QString localFileName() override; bool isFileUpload() { return m_pDescriptor->isFileUpload(); }; diff --git a/src/modules/dcc/DccMarshal.cpp b/src/modules/dcc/DccMarshal.cpp index fa7d2b0b3..486aa9aee 100644 --- a/src/modules/dcc/DccMarshal.cpp +++ b/src/modules/dcc/DccMarshal.cpp @@ -32,7 +32,7 @@ #include "kvi_socket.h" #include "KviFileUtils.h" -#include <stdlib.h> //for exit() +#include <cstdlib> //for exit() #include <QTimer> diff --git a/src/modules/dcc/DccThread.h b/src/modules/dcc/DccThread.h index 25f6fc4fd..14cd96929 100644 --- a/src/modules/dcc/DccThread.h +++ b/src/modules/dcc/DccThread.h @@ -46,11 +46,11 @@ // KviThreadDataEvent<int> #define KVI_DCC_THREAD_EVENT_ACTION (KVI_THREAD_USER_EVENT_BASE + 5) -typedef struct _KviDccThreadIncomingData +struct KviDccThreadIncomingData { int iLen; char * buffer; -} KviDccThreadIncomingData; +}; class DccThread : public KviSensitiveThread { diff --git a/src/modules/dcc/DccVideoWindow.cpp b/src/modules/dcc/DccVideoWindow.cpp index ea19273fb..963a30b36 100644 --- a/src/modules/dcc/DccVideoWindow.cpp +++ b/src/modules/dcc/DccVideoWindow.cpp @@ -72,9 +72,8 @@ bool kvi_dcc_video_is_valid_codec(const char * codecName) return false; } -static DccVideoCodec * kvi_dcc_video_get_codec(const char * codecName) +static DccVideoCodec * kvi_dcc_video_get_codec([[maybe_unused]] const char * codecName) { - Q_UNUSED(codecName); #ifndef COMPILE_DISABLE_OGG_THEORA if(kvi_strEqualCI("theora", codecName)) return new DccVideoTheoraCodec(); @@ -259,7 +258,7 @@ bool DccVideoThread::handleIncomingData(KviDccThreadIncomingData * data, bool bC // no more data in the buffer KVI_ASSERT(data->iLen == 0); KviMemory::free(data->buffer); - data->buffer = end = aux = 0; + data->buffer = end = aux = nullptr; } postEvent(parent(), e); } @@ -281,7 +280,7 @@ bool DccVideoThread::handleIncomingData(KviDccThreadIncomingData * data, bool bC e->setData(s); data->iLen = 0; KviMemory::free(data->buffer); - data->buffer = 0; + data->buffer = nullptr; postEvent(parent(), e); } } @@ -396,8 +395,8 @@ DccVideoWindow::DccVideoWindow(DccDescriptor * dcc, const char * name) : DccWindow(KviWindow::DccVideo, name, dcc) { m_pDescriptor = dcc; - m_pSlaveThread = 0; - m_pszTarget = 0; + m_pSlaveThread = nullptr; + m_pszTarget = nullptr; m_pButtonBox = new KviTalHBox(this); @@ -501,51 +500,51 @@ DccVideoWindow::~DccVideoWindow() if(m_pInVideoLabel) { delete m_pInVideoLabel; - m_pInVideoLabel = 0; + m_pInVideoLabel = nullptr; } if(m_pCameraView) { delete m_pCameraView; - m_pCameraView = 0; + m_pCameraView = nullptr; } if(m_pCameraImage) { delete m_pCameraImage; - m_pCameraImage = 0; + m_pCameraImage = nullptr; } if(m_pCamera) { delete m_pCamera; - m_pCamera = 0; + m_pCamera = nullptr; } if(m_pCDevices) { delete m_pCDevices; - m_pCDevices = 0; + m_pCDevices = nullptr; } if(m_pCInputs) { delete m_pCInputs; - m_pCInputs = 0; + m_pCInputs = nullptr; } if(m_pCStandards) { delete m_pCStandards; - m_pCStandards = 0; + m_pCStandards = nullptr; } if(m_pVideoLabel[0]) { delete m_pVideoLabel[2]; delete m_pVideoLabel[1]; delete m_pVideoLabel[0]; - m_pVideoLabel[2] = 0; - m_pVideoLabel[1] = 0; - m_pVideoLabel[0] = 0; + m_pVideoLabel[2] = nullptr; + m_pVideoLabel[1] = nullptr; + m_pVideoLabel[0] = nullptr; } if(m_pLayout) { delete m_pLayout; - m_pLayout = 0; + m_pLayout = nullptr; } g_pDccBroker->unregisterDccWindow(this); @@ -554,7 +553,7 @@ DccVideoWindow::~DccVideoWindow() { m_pSlaveThread->terminate(); delete m_pSlaveThread; - m_pSlaveThread = 0; + m_pSlaveThread = nullptr; } KviThreadManager::killPendingEvents(this); @@ -562,7 +561,7 @@ DccVideoWindow::~DccVideoWindow() if(m_pszTarget) { delete m_pszTarget; - m_pszTarget = 0; + m_pszTarget = nullptr; } } @@ -792,7 +791,7 @@ void DccVideoWindow::ownAction(const QString & text) return; KviCString buf(KviCString::Format, "%cACTION %s%c\r\n", 0x01, d, 0x01); m_tmpTextDataOut.append(buf.ptr(), buf.len()); - output(KVI_OUT_ACTION, "%Q %Q", &(m_pDescriptor->szLocalNick), &szTmpBuffer); + output(KVI_OUT_OWNACTION, "%Q %Q", &(m_pDescriptor->szLocalNick), &szTmpBuffer); } else { diff --git a/src/modules/dcc/DccVideoWindow.h b/src/modules/dcc/DccVideoWindow.h index eca3ed97f..1210dcc8b 100644 --- a/src/modules/dcc/DccVideoWindow.h +++ b/src/modules/dcc/DccVideoWindow.h @@ -64,11 +64,11 @@ extern bool kvi_dcc_video_is_valid_codec(const char * codecName); #define KVI_DCC_VIDEO_THREAD_ACTION_STOP_PLAYING 3 #define KVI_DCC_VIDEO_THREAD_ACTION_GRAB_FRAME 4 -typedef struct _KviDccVideoThreadOptions +struct KviDccVideoThreadOptions { QString szVideoDevice; DccVideoCodec * pCodec; -} KviDccVideoThreadOptions; +}; class DccVideoThread : public DccThread { @@ -102,9 +102,9 @@ protected: void stopRecording(); void startPlaying(); void stopPlaying(); - inline bool isPlaying() { return m_bPlaying; }; - virtual void run(); - virtual bool handleIncomingData(KviDccThreadIncomingData * data, bool bCritical); + bool isPlaying() const { return m_bPlaying; } + void run() override; + bool handleIncomingData(KviDccThreadIncomingData * data, bool bCritical) override; }; class DccVideoWindow : public DccWindow @@ -135,21 +135,21 @@ protected: QString m_szLocalNick; protected: - virtual void triggerCreationEvents(); - virtual void triggerDestructionEvents(); - virtual const QString & target(); - virtual void fillCaptionBuffers(); - virtual QPixmap * myIconPtr(); - virtual bool event(QEvent * e); - virtual void getBaseLogFileName(QString & buffer); + void triggerCreationEvents() override; + void triggerDestructionEvents() override; + const QString & target() override; + void fillCaptionBuffers() override; + QPixmap * myIconPtr() override; + bool event(QEvent * e) override; + void getBaseLogFileName(QString & buffer) override; void startTalking(); void stopTalking(); void startConnection(); - virtual const QString & localNick(); - virtual void ownMessage(const QString & text, bool bUserFeedback = true); - virtual void ownAction(const QString & text); - virtual void resizeEvent(QResizeEvent *); - virtual QSize sizeHint() const; + const QString & localNick() override; + void ownMessage(const QString & text, bool bUserFeedback = true) override; + void ownAction(const QString & text) override; + void resizeEvent(QResizeEvent *) override; + QSize sizeHint() const override; protected slots: void handleMarshalError(KviError::Code eError); void connected(); diff --git a/src/modules/dcc/DccVoiceAdpcmCodec.cpp b/src/modules/dcc/DccVoiceAdpcmCodec.cpp index f3b9e0334..de05544e1 100644 --- a/src/modules/dcc/DccVoiceAdpcmCodec.cpp +++ b/src/modules/dcc/DccVoiceAdpcmCodec.cpp @@ -53,7 +53,7 @@ #define _ADPCMCODEC_CPP_ #include "DccVoiceAdpcmCodec.h" -#include <stdio.h> /*DBG*/ +#include <cstdio> /*DBG*/ #ifndef __STDC__ #define signed diff --git a/src/modules/dcc/DccVoiceAdpcmCodec.h b/src/modules/dcc/DccVoiceAdpcmCodec.h index e437c18b5..8015bd052 100644 --- a/src/modules/dcc/DccVoiceAdpcmCodec.h +++ b/src/modules/dcc/DccVoiceAdpcmCodec.h @@ -47,11 +47,11 @@ #include "DccVoiceCodec.h" -typedef struct adpcm_state +struct ADPCM_state { short valprev; /* Previous output value */ char index; /* HelpIndex into stepsize table */ -} ADPCM_state; +}; class DccVoiceAdpcmCodec : public DccVoiceCodec { diff --git a/src/modules/dcc/DccVoiceCodec.cpp b/src/modules/dcc/DccVoiceCodec.cpp index 8f52060a2..5e70d176c 100644 --- a/src/modules/dcc/DccVoiceCodec.cpp +++ b/src/modules/dcc/DccVoiceCodec.cpp @@ -29,8 +29,7 @@ #include <QBuffer> DccVoiceCodec::DccVoiceCodec() -{ -} + = default; DccVoiceCodec::~DccVoiceCodec() = default; @@ -95,8 +94,7 @@ int DccVoiceNullCodec::decodedFrameSize() } DccVideoCodec::DccVideoCodec() -{ -} + = default; DccVideoCodec::~DccVideoCodec() = default; @@ -265,19 +263,19 @@ DccVideoTheoraCodec::DccVideoTheoraCodec() : DccVideoCodec() { m_szName = "theora"; - m_pEncoder = 0; - m_pDecoder = 0; + m_pEncoder = nullptr; + m_pDecoder = nullptr; } DccVideoTheoraCodec::~DccVideoTheoraCodec() { if(m_pEncoder) delete m_pEncoder; - m_pEncoder = 0; + m_pEncoder = nullptr; if(m_pDecoder) delete m_pDecoder; - m_pDecoder = 0; + m_pDecoder = nullptr; } void DccVideoTheoraCodec::encodeVideo(KviDataBuffer * videoSignal, KviDataBuffer * stream) diff --git a/src/modules/dcc/DccVoiceGsmCodec.cpp b/src/modules/dcc/DccVoiceGsmCodec.cpp index e2a23bb4e..3a7929b3d 100644 --- a/src/modules/dcc/DccVoiceGsmCodec.cpp +++ b/src/modules/dcc/DccVoiceGsmCodec.cpp @@ -33,12 +33,12 @@ #define GSM_UNPACKED_FRAME_SIZE_IN_BYTES 320 #define GSM_UNPACKED_FRAME_SIZE_IN_SHORTS 160 -void * (*gsm_session_create)() = 0; -void (*gsm_session_destroy)(void *) = 0; -void (*gsm_session_encode)(void *, short *, unsigned char *) = 0; -int (*gsm_session_decode)(void *, unsigned char *, short *) = 0; +void * (*gsm_session_create)() = nullptr; +void (*gsm_session_destroy)(void *) = nullptr; +void (*gsm_session_encode)(void *, short *, unsigned char *) = nullptr; +int (*gsm_session_decode)(void *, unsigned char *, short *) = nullptr; -void * g_pGSMCodecLibraryHandle = 0; +void * g_pGSMCodecLibraryHandle = nullptr; bool kvi_gsm_codec_init() { @@ -57,7 +57,7 @@ bool kvi_gsm_codec_init() if(!(gsm_session_create && gsm_session_destroy && gsm_session_encode && gsm_session_decode)) { dlclose(g_pGSMCodecLibraryHandle); - g_pGSMCodecLibraryHandle = 0; + g_pGSMCodecLibraryHandle = nullptr; return false; } return true; @@ -68,7 +68,7 @@ void kvi_gsm_codec_done() if(g_pGSMCodecLibraryHandle) { dlclose(g_pGSMCodecLibraryHandle); - g_pGSMCodecLibraryHandle = 0; + g_pGSMCodecLibraryHandle = nullptr; } } diff --git a/src/modules/dcc/DccVoiceWindow.cpp b/src/modules/dcc/DccVoiceWindow.cpp index be04e9e83..279823727 100644 --- a/src/modules/dcc/DccVoiceWindow.cpp +++ b/src/modules/dcc/DccVoiceWindow.cpp @@ -49,7 +49,7 @@ #include <sys/time.h> #include <sys/types.h> #include <unistd.h> -#include <errno.h> +#include <cerrno> #include <fcntl.h> #include <sys/stat.h> // for open() #include <sys/ioctl.h> // for ioctl() @@ -1014,7 +1014,7 @@ void DccVoiceWindow::startOrStopTalking(bool bStart) stopTalking(); } -int DccVoiceWindow::getMixerVolume(void) const +int DccVoiceWindow::getMixerVolume() const { #ifndef COMPILE_DISABLE_DCC_VOICE int fd; diff --git a/src/modules/dcc/DccVoiceWindow.h b/src/modules/dcc/DccVoiceWindow.h index e0d526382..f0f7dc898 100644 --- a/src/modules/dcc/DccVoiceWindow.h +++ b/src/modules/dcc/DccVoiceWindow.h @@ -51,14 +51,14 @@ extern bool kvi_dcc_voice_is_valid_codec(const char * codecName); #define KVI_DCC_VOICE_THREAD_ACTION_START_PLAYING 2 #define KVI_DCC_VOICE_THREAD_ACTION_STOP_PLAYING 3 -typedef struct _KviDccVoiceThreadOptions +struct KviDccVoiceThreadOptions { bool bForceHalfDuplex; int iPreBufferSize; int iSampleRate; KviCString szSoundDevice; DccVoiceCodec * pCodec; -} KviDccVoiceThreadOptions; +}; class DccVoiceThread : public DccThread { @@ -125,14 +125,14 @@ protected: DccVoiceThread * m_pSlaveThread; protected: - virtual void focusInEvent(QFocusEvent *); - virtual const QString & target(); - virtual void fillCaptionBuffers(); - virtual QPixmap * myIconPtr(); - virtual void resizeEvent(QResizeEvent * e); - virtual QSize sizeHint() const; - virtual bool event(QEvent * e); - virtual void getBaseLogFileName(QString & buffer); + void focusInEvent(QFocusEvent *) override; + const QString & target() override; + void fillCaptionBuffers() override; + QPixmap * myIconPtr() override; + void resizeEvent(QResizeEvent * e) override; + QSize sizeHint() const override; + bool event(QEvent * e) override; + void getBaseLogFileName(QString & buffer) override; void startTalking(); void stopTalking(); void startConnection(); @@ -188,7 +188,7 @@ public: KviVoiceParty::KviVoiceParty(const QString &szNick,const QString &szIp,unsigned short uPort) : m_szIp(szIp), m_uPort(uPort), m_szNick(szNick) { - m_pChildrenTree = 0; + m_pChildrenTree = nullptr; } KviVoiceParty::~KviVoiceParty() @@ -241,8 +241,8 @@ KviVoiceLink::KviVoiceLink(KviVoiceParty * pRemoteParty) { KviQString::sprintf("%Q:%u",&(pRemoteParty->nick()),pRemoteParty->port()); m_pRemoteParty = pRemoteParty; - m_pAudioEncoder = 0; - m_pAudioDecoder = 0; + m_pAudioEncoder = nullptr; + m_pAudioDecoder = nullptr; } KviVoiceLink::~KviVoiceLink() diff --git a/src/modules/dcc/DccWindow.h b/src/modules/dcc/DccWindow.h index 31a4710fd..483f1ad43 100644 --- a/src/modules/dcc/DccWindow.h +++ b/src/modules/dcc/DccWindow.h @@ -45,7 +45,7 @@ protected: public: DccDescriptor * descriptor() { return m_pDescriptor; }; const DccMarshal * marshal() { return m_pMarshal; }; - virtual DccThread * getSlaveThread() { return 0; }; + virtual DccThread * getSlaveThread() { return nullptr; } virtual KviWindow * dccMarshalOutputWindow(); virtual const char * dccMarshalOutputContextString(); }; diff --git a/src/modules/dcc/canvaswidget.cpp b/src/modules/dcc/canvaswidget.cpp index 8da7a0204..03d69ac58 100644 --- a/src/modules/dcc/canvaswidget.cpp +++ b/src/modules/dcc/canvaswidget.cpp @@ -466,7 +466,7 @@ KviCanvasView::KviCanvasView(QCanvas * c, DccCanvasWidget * cw, QWidget * par) m_pCanvasWidget = cw; m_state = Idle; m_dragMode = None; - m_pSelectedItem = 0; + m_pSelectedItem = nullptr; viewport()->setMouseTracking(true); } @@ -562,7 +562,7 @@ static void calcPolygonPoints(QPointArray & pnts, unsigned int nVertices) void KviCanvasView::insertObjectAt(const QPoint & pnt, ObjectType o) { - QCanvasItem * r = 0; + QCanvasItem * r = nullptr; switch(o) { @@ -655,7 +655,7 @@ void KviCanvasView::clearSelection() if(!m_pSelectedItem) return; m_pSelectedItem->setSelected(false); - m_pSelectedItem = 0; + m_pSelectedItem = nullptr; m_pCanvasWidget->m_pPropertiesWidget->editItem(0); } @@ -1297,7 +1297,7 @@ QWidget * KviVariantTableItem::createEditor() const default: break; } - return 0; + return nullptr; } void KviVariantTableItem::setContentFromEditor(QWidget * w) @@ -1429,7 +1429,7 @@ void KviCanvasItemPropertiesWidget::editItem(QCanvasItem * it) return; } - QMap<QString, QVariant> * m = 0; + QMap<QString, QVariant> * m = nullptr; switch(KVI_CANVAS_RTTI_CONTROL_TYPE(it)) { diff --git a/src/modules/dcc/canvaswidget.h b/src/modules/dcc/canvaswidget.h index d6737cef4..c03a750c7 100644 --- a/src/modules/dcc/canvaswidget.h +++ b/src/modules/dcc/canvaswidget.h @@ -263,9 +263,9 @@ protected: void setItemSelected(QCanvasItem * it); void clearSelection(); void insertObjectAt(const QPoint & pnt, ObjectType o); - virtual void contentsMousePressEvent(QMouseEvent * e); - virtual void contentsMouseMoveEvent(QMouseEvent * e); - virtual void contentsMouseReleaseEvent(QMouseEvent * e); + void contentsMousePressEvent(QMouseEvent * e) override; + void contentsMouseMoveEvent(QMouseEvent * e) override; + void contentsMouseReleaseEvent(QMouseEvent * e) override; public slots: void insertRectangle(); void insertRichText(); @@ -328,7 +328,7 @@ protected: KviCanvasItemPropertiesWidget * m_pPropertiesWidget; protected: - virtual void resizeEvent(QResizeEvent *); + void resizeEvent(QResizeEvent *) override; }; #endif diff --git a/src/modules/dcc/libkvidcc.cpp b/src/modules/dcc/libkvidcc.cpp index 510c5b122..16427465b 100644 --- a/src/modules/dcc/libkvidcc.cpp +++ b/src/modules/dcc/libkvidcc.cpp @@ -2420,7 +2420,7 @@ static bool dcc_kvs_fnc_ircContext(KviKvsModuleFunctionCall * c) } else { - c->error(__tr2qs_ctx("The IRC context that originated the DCC doesn't exists anymore.", "dcc")); + c->error(__tr2qs_ctx("The IRC context that originated the DCC doesn't exist anymore.", "dcc")); return false; } } diff --git a/src/modules/dcc/requests.cpp b/src/modules/dcc/requests.cpp index 2e856ac44..7440c58ad 100644 --- a/src/modules/dcc/requests.cpp +++ b/src/modules/dcc/requests.cpp @@ -1175,12 +1175,12 @@ static void dccModuleParseDccList(KviDccRequest *) // FIXME! } -typedef void (*dccParseProc)(KviDccRequest *); -typedef struct _dccParseProcEntry +using dccParseProc = void (*)(KviDccRequest *); +struct dccParseProcEntry { const char * type; dccParseProc proc; -} dccParseProcEntry; +}; #define KVI_NUM_KNOWN_DCC_TYPES 28 diff --git a/src/modules/dialog/libkvidialog.h b/src/modules/dialog/libkvidialog.h index 5bec526e4..ac0eb86fc 100644 --- a/src/modules/dialog/libkvidialog.h +++ b/src/modules/dialog/libkvidialog.h @@ -49,7 +49,7 @@ public: KviWindow * pWindow, bool modal = false); ~KviKvsCallbackMessageBox(); protected slots: - virtual void done(int code); + void done(int code) override; }; class KviKvsCallbackTextInput : public QDialog, public KviKvsCallbackObject @@ -79,13 +79,13 @@ protected: int m_iDefaultButton; protected: - virtual void closeEvent(QCloseEvent * e); - virtual void showEvent(QShowEvent * e); + void closeEvent(QCloseEvent * e) override; + void showEvent(QShowEvent * e) override; protected slots: void b0Clicked(); void b1Clicked(); void b2Clicked(); - virtual void done(int code); + void done(int code) override; }; class KviKvsCallbackFileDialog : public KviFileDialog, public KviKvsCallbackObject @@ -102,7 +102,7 @@ public: ~KviKvsCallbackFileDialog(); protected: - virtual void done(int code); + void done(int code) override; }; class KviKvsCallbackImageDialog : public KviImageDialog, public KviKvsCallbackObject @@ -120,7 +120,7 @@ public: ~KviKvsCallbackImageDialog(); protected: - virtual void done(int code); + void done(int code) override; }; #endif //_KVI_DIALOG_H_ diff --git a/src/modules/editor/ScriptEditorImplementation.cpp b/src/modules/editor/ScriptEditorImplementation.cpp index c05308977..f21ef4fdb 100644 --- a/src/modules/editor/ScriptEditorImplementation.cpp +++ b/src/modules/editor/ScriptEditorImplementation.cpp @@ -317,10 +317,6 @@ void ScriptEditorWidget::updateOptions() disableSyntaxHighlighter(); enableSyntaxHighlighter(); - p = ((ScriptEditorImplementation *)m_pParent)->findLineEdit()->palette(); - p.setColor(foregroundRole(), g_clrFind); - ((ScriptEditorImplementation *)m_pParent)->findLineEdit()->setPalette(p); - //set cursor custom width if(KVI_OPTION_BOOL(KviOption_boolEnableCustomCursorWidth)) { @@ -715,16 +711,16 @@ ScriptEditorImplementation::ScriptEditorImplementation(QWidget * par) m_lastCursorPos = 0; QGridLayout * g = new QGridLayout(this); + m_pEditor = new ScriptEditorWidget(this); + m_pFindLineEdit = new QLineEdit(" ", this); m_pFindLineEdit->setText(""); QPalette p = m_pFindLineEdit->palette(); - p.setColor(foregroundRole(), g_clrFind); + p.setColor(QPalette::Text, g_clrFind); m_pFindLineEdit->setPalette(p); - m_pEditor = new ScriptEditorWidget(this); - - g->addWidget(m_pEditor, 0, 0, 1, 4); + g->addWidget(m_pEditor, 0, 0, 1, 5); g->setRowStretch(0, 1); QToolButton * b = new QToolButton(this); @@ -753,13 +749,18 @@ ScriptEditorImplementation::ScriptEditorImplementation(QWidget * par) pLab->setAlignment(Qt::AlignRight | Qt::AlignVCenter); g->addWidget(pLab, 1, 1); + m_pFindButton = new QPushButton(QString(__tr2qs_ctx("&Find", "editor")), this); + g->addWidget(m_pFindButton, 1, 3); + m_pRowColLabel = new QLabel(QString(__tr2qs_ctx("Line: %1 Col: %2", "editor")).arg(1).arg(1), this); m_pRowColLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel); m_pRowColLabel->setMinimumWidth(80); - g->addWidget(m_pRowColLabel, 1, 3); + g->addWidget(m_pRowColLabel, 1, 4); connect(m_pFindLineEdit, SIGNAL(returnPressed()), m_pEditor, SLOT(slotFind())); connect(m_pFindLineEdit, SIGNAL(returnPressed()), this, SLOT(slotFind())); + connect(m_pFindButton, SIGNAL(clicked()), m_pEditor, SLOT(slotFind())); + connect(m_pFindButton, SIGNAL(clicked()), this, SLOT(slotFind())); connect(m_pEditor, SIGNAL(cursorPositionChanged()), this, SLOT(updateRowColLabel())); connect(m_pEditor, SIGNAL(selectionChanged()), this, SLOT(updateRowColLabel())); m_lastCursorPos = 0; diff --git a/src/modules/editor/ScriptEditorImplementation.h b/src/modules/editor/ScriptEditorImplementation.h index 1a99aa490..35ee28ba9 100644 --- a/src/modules/editor/ScriptEditorImplementation.h +++ b/src/modules/editor/ScriptEditorImplementation.h @@ -155,6 +155,7 @@ protected: ScriptEditorWidgetColorOptions * m_pOptionsDialog; ScriptEditorWidget * m_pEditor; QLabel * m_pRowColLabel; + QPushButton * m_pFindButton; int m_lastCursorPos; public: @@ -201,7 +202,7 @@ class ScriptEditorReplaceDialog final : public QDialog { Q_OBJECT public: - ScriptEditorReplaceDialog(QWidget * parent = 0, const QString & szName = QString()); + ScriptEditorReplaceDialog(QWidget * parent = nullptr, const QString & szName = QString()); public: QLineEdit * m_pFindLineEdit; diff --git a/src/modules/eventeditor/EventEditorWindow.cpp b/src/modules/eventeditor/EventEditorWindow.cpp index d54d110d3..ca9ef2cfd 100644 --- a/src/modules/eventeditor/EventEditorWindow.cpp +++ b/src/modules/eventeditor/EventEditorWindow.cpp @@ -39,6 +39,7 @@ #include "KviQString.h" #include "KviKvsEventManager.h" #include "KviTalVBox.h" +#include "KviTalHBox.h" #include <QMessageBox> #include <QSplitter> @@ -47,11 +48,14 @@ #include <QPushButton> #include <QMouseEvent> #include <QMenu> +#include <utility> extern EventEditorWindow * g_pEventEditorWindow; -EventEditorEventTreeWidgetItem::EventEditorEventTreeWidgetItem(QTreeWidget * par, unsigned int uEvIdx, const QString & name, const QString & params) - : QTreeWidgetItem(par), m_uEventIdx(uEvIdx), m_szParams(params) +EventEditorEventTreeWidgetItem::EventEditorEventTreeWidgetItem(QTreeWidget * par, unsigned int uEvIdx, const QString & name, QString params) + : QTreeWidgetItem(par) + , m_uEventIdx(uEvIdx) + , m_szParams(std::move(params)) { setName(name); } @@ -62,8 +66,9 @@ void EventEditorEventTreeWidgetItem::setName(const QString & szName) setText(0, m_szName); } -EventEditorHandlerTreeWidgetItem::EventEditorHandlerTreeWidgetItem(QTreeWidgetItem * par, const QString & name, const QString & buffer, bool bEnabled) - : QTreeWidgetItem(par), m_szBuffer(buffer) +EventEditorHandlerTreeWidgetItem::EventEditorHandlerTreeWidgetItem(QTreeWidgetItem * par, const QString & name, QString buffer, bool bEnabled) + : QTreeWidgetItem(par) + , m_szBuffer(std::move(buffer)) { m_cPos = 0; setEnabled(bEnabled); //this updates the icon too @@ -110,11 +115,25 @@ EventEditor::EventEditor(QWidget * par) box->setSpacing(0); box->setMargin(0); - m_pNameEditor = new QLineEdit(box); + KviTalHBox * hbox = new KviTalHBox(box); + hbox->setContentsMargins(10, 0, 10, 0); + + m_pIsEnabled = new QCheckBox(hbox); + m_pIsEnabled->setText(__tr2qs_ctx("E&nabled", "editor")); + m_pIsEnabled->setEnabled(false); + connect(m_pIsEnabled, SIGNAL(clicked(bool)), this, SLOT(toggleCurrentHandlerEnabled())); + + m_pNameEditor = new QLineEdit(hbox); + m_pNameEditor->setText(__tr2qs_ctx("No item selected", "editor")); m_pNameEditor->setToolTip(__tr2qs_ctx("Edit the event handler name.", "editor")); + m_pNameEditor->setEnabled(false); + QRegExpValidator * pValidator = new QRegExpValidator(QRegExp(KVI_KVS_EVENT_HANDLER_NAME_REG_EXP), this); + m_pNameEditor->setValidator(pValidator); + m_pNameEditor->setEnabled(false); m_pEditor = KviScriptEditor::createInstance(box); m_pEditor->setFocus(); + m_pEditor->setEnabled(false); m_bOneTimeSetupDone = false; m_pLastEditedItem = nullptr; } @@ -163,6 +182,14 @@ void EventEditor::eventHandlerDisabled(const QString & szHandler) QString szEventName = szHandler.split("::")[0]; QString szHandlerName = szHandler.split("::")[1]; qDebug("Handler %s of event %s : disabled", szHandlerName.toUtf8().data(), szEventName.toUtf8().data()); + + QTreeWidgetItem * pSelectedItem = nullptr; + QList <QTreeWidgetItem *> itemList = m_pTreeWidget->selectedItems(); + if (!itemList.isEmpty()) + { + pSelectedItem = itemList.first(); + } + for(int i = 0; i < m_pTreeWidget->topLevelItemCount(); i++) { EventEditorEventTreeWidgetItem * pItem = (EventEditorEventTreeWidgetItem *)m_pTreeWidget->topLevelItem(i); @@ -173,6 +200,8 @@ void EventEditor::eventHandlerDisabled(const QString & szHandler) if(KviQString::equalCI(szHandlerName, ((EventEditorHandlerTreeWidgetItem *)pItem->child(j))->name())) { ((EventEditorHandlerTreeWidgetItem *)pItem->child(j))->setEnabled(false); + if (pItem->child(j) == pSelectedItem) + m_pIsEnabled->setChecked(false); return; } } @@ -310,6 +339,7 @@ void EventEditor::removeCurrentHandler() parent->setIcon(0, QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::EventNoHandlers)))); } + m_pIsEnabled->setEnabled(false); m_pEditor->setEnabled(false); m_pNameEditor->setEnabled(false); } @@ -320,6 +350,7 @@ void EventEditor::toggleCurrentHandlerEnabled() KVI_ASSERT(m_bOneTimeSetupDone); if(m_pLastEditedItem) { + m_pIsEnabled->setChecked(!(m_pLastEditedItem->m_bEnabled)); m_pLastEditedItem->setEnabled(!(m_pLastEditedItem->m_bEnabled)); m_pTreeWidget->repaint(m_pTreeWidget->visualItemRect(m_pLastEditedItem)); currentItemChanged(m_pLastEditedItem, nullptr); @@ -368,8 +399,7 @@ void EventEditor::saveLastEditedItem() return; ((EventEditorHandlerTreeWidgetItem *)m_pLastEditedItem)->setCursorPosition(m_pEditor->getCursor()); QString buffer = m_pNameEditor->text(); - //not-so elaborate fix for #218, we'd better rework this - buffer.replace(QRegExp("[^A-Za-z0-9_]"), ""); + KviKvsEventManager::instance()->cleanHandlerName(buffer); if(!KviQString::equalCI(buffer, m_pLastEditedItem->m_szName)) { getUniqueHandlerName((EventEditorEventTreeWidgetItem *)(m_pLastEditedItem->parent()), buffer); @@ -398,6 +428,8 @@ void EventEditor::currentItemChanged(QTreeWidgetItem * it, QTreeWidgetItem *) if(it->parent()) { m_pLastEditedItem = (EventEditorHandlerTreeWidgetItem *)it; + m_pIsEnabled->setEnabled(true); + m_pIsEnabled->setChecked(m_pLastEditedItem->isEnabled()); m_pNameEditor->setEnabled(true); m_pNameEditor->setText(m_pLastEditedItem->name()); m_pEditor->setEnabled(true); @@ -408,8 +440,10 @@ void EventEditor::currentItemChanged(QTreeWidgetItem * it, QTreeWidgetItem *) else { m_pLastEditedItem = nullptr; + m_pIsEnabled->setEnabled(false); + m_pIsEnabled->setChecked(false); m_pNameEditor->setEnabled(false); - m_pNameEditor->setText(""); + m_pNameEditor->setText(__tr2qs_ctx("No item selected", "editor")); m_pEditor->setEnabled(false); QString parms = ((EventEditorEventTreeWidgetItem *)it)->m_szParams; if(parms.isEmpty()) diff --git a/src/modules/eventeditor/EventEditorWindow.h b/src/modules/eventeditor/EventEditorWindow.h index f6ca3644f..0425b13ea 100644 --- a/src/modules/eventeditor/EventEditorWindow.h +++ b/src/modules/eventeditor/EventEditorWindow.h @@ -31,6 +31,7 @@ #include <QLineEdit> #include <QTreeWidget> #include <QMenu> +#include <QCheckBox> class KviScriptEditor; @@ -42,7 +43,7 @@ public: QString m_szParams; public: - EventEditorEventTreeWidgetItem(QTreeWidget * par, unsigned int uEvIdx, const QString & name, const QString & params); + EventEditorEventTreeWidgetItem(QTreeWidget * par, unsigned int uEvIdx, const QString & name, QString params); ~EventEditorEventTreeWidgetItem(){}; public: @@ -59,20 +60,20 @@ public: int m_cPos; public: - EventEditorHandlerTreeWidgetItem(QTreeWidgetItem * par, const QString & name, const QString & buffer, bool bEnabled); + EventEditorHandlerTreeWidgetItem(QTreeWidgetItem * par, const QString & name, QString buffer, bool bEnabled); ~EventEditorHandlerTreeWidgetItem(){}; public: const int & cursorPosition() { return m_cPos; }; void setCursorPosition(const int & cPos) { - qDebug("set cursor to %d", cPos); m_cPos = cPos; }; void setName(const QString & szName); QString name() const { return m_szName; }; void setEnabled(const bool bEnabled); + bool isEnabled() { return m_bEnabled; }; }; class EventEditorTreeWidget : public QTreeWidget @@ -83,7 +84,7 @@ public: ~EventEditorTreeWidget(){}; protected: - void mousePressEvent(QMouseEvent * e); + void mousePressEvent(QMouseEvent * e) override; signals: void rightButtonPressed(QTreeWidgetItem *, QPoint); }; @@ -99,7 +100,8 @@ public: KviScriptEditor * m_pEditor; EventEditorTreeWidget * m_pTreeWidget; QLineEdit * m_pNameEditor; - QMenu * m_pContextPopup; + QCheckBox * m_pIsEnabled; + QMenu * m_pContextPopup = nullptr; EventEditorHandlerTreeWidgetItem * m_pLastEditedItem; bool m_bOneTimeSetupDone; @@ -119,7 +121,7 @@ protected slots: void eventHandlerDisabled(const QString & szName); protected: - void showEvent(QShowEvent * e); + void showEvent(QShowEvent * e) override; private: void oneTimeSetup(); @@ -136,11 +138,11 @@ protected: EventEditor * m_pEditor; protected: - virtual QPixmap * myIconPtr(); - virtual void fillCaptionBuffers(); - virtual void getConfigGroupName(QString & szName); - virtual void saveProperties(KviConfigurationFile *); - virtual void loadProperties(KviConfigurationFile *); + QPixmap * myIconPtr() override; + void fillCaptionBuffers() override; + void getConfigGroupName(QString & szName) override; + void saveProperties(KviConfigurationFile *) override; + void loadProperties(KviConfigurationFile *) override; protected slots: void cancelClicked(); void okClicked(); diff --git a/src/modules/file/libkvifile.cpp b/src/modules/file/libkvifile.cpp index 84d7d5d37..2ff800b5f 100644 --- a/src/modules/file/libkvifile.cpp +++ b/src/modules/file/libkvifile.cpp @@ -53,6 +53,12 @@ #endif #include <openssl/evp.h> + +#if OPENSSL_VERSION_NUMBER < 0x10100005L +#define EVP_MD_CTX_new EVP_MD_CTX_create +#define EVP_MD_CTX_free EVP_MD_CTX_destroy +#endif + #else // The fallback we can always use, but with very limited set of // functionality. @@ -707,20 +713,20 @@ static bool file_kvs_fnc_ps(KviKvsModuleFunctionCall * c) The <directory> should be given as a UNIX style path and is adjusted according to the system that KVIrc is running on.[br][br] <flags> may be a combination of the following characters:[br] [pre] - [b]d:[/b] list directories[br] - [b]f:[/b] list files[br] - [b]l:[/b] list symbolic links[br] - [b]r:[/b] list readable files[br] - [b]w:[/b] list writable files[br] - [b]x:[/b] list executable files[br] - [b]h:[/b] list hidden files[br] - [b]s:[/b] list system files[br] - [b]n:[/b] sort files by name[br] - [b]t:[/b] sort files by file time[br] - [b]b:[/b] sort files by file size[br] - [b]z:[/b] put the directories first, then the files[br] - [b]k:[/b] invert sort order[br] - [b]i:[/b] case insensitive sort[br] + [b]d:[/b] list directories + [b]f:[/b] list files + [b]l:[/b] list symbolic links + [b]r:[/b] list readable files + [b]w:[/b] list writable files + [b]x:[/b] list executable files + [b]h:[/b] list hidden files + [b]s:[/b] list system files + [b]n:[/b] sort files by name + [b]t:[/b] sort files by file time + [b]b:[/b] sort files by file size + [b]z:[/b] put the directories first, then the files + [b]k:[/b] invert sort order + [b]i:[/b] case insensitive sort [/pre] If <flags> is empty, then a default of [b]dfrwxhs[/b] is set. If none of the [b]r[/b],[b]w[/b],[b]x[/b] flags are set then KVIrc sets all of them by default.[br][br] If <namefilter> is passed then it is interpreted as a wildcard string @@ -1483,7 +1489,7 @@ static bool file_kvs_fnc_diskSpace(KviKvsModuleFunctionCall * c) // this for win #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) ULARGE_INTEGER free, total; - if (GetDiskFreeSpaceEx(szPath.toStdWString().c_str(), NULL, &total, &free) == 0) { + if (GetDiskFreeSpaceEx(szPath.toStdWString().c_str(), nullptr, &total, &free) == 0) { c->warning(__tr2qs("An error occurred retrieving the amount of free space in '%Q'"), &szPath); return true; } @@ -1553,7 +1559,7 @@ static bool file_kvs_fnc_digest(KviKvsModuleFunctionCall * c) if(szAlgo.isEmpty()) szAlgo = "md5"; - EVP_MD_CTX mdctx; + EVP_MD_CTX *mdctx; const EVP_MD * pMD; unsigned char ucMDValue[EVP_MAX_MD_SIZE]; unsigned int uMDLen, u; @@ -1567,11 +1573,11 @@ static bool file_kvs_fnc_digest(KviKvsModuleFunctionCall * c) return true; } - EVP_MD_CTX_init(&mdctx); - EVP_DigestInit_ex(&mdctx, pMD, nullptr); - EVP_DigestUpdate(&mdctx, content.constData(), content.size()); - EVP_DigestFinal_ex(&mdctx, ucMDValue, &uMDLen); - EVP_MD_CTX_cleanup(&mdctx); + mdctx = EVP_MD_CTX_new(); + EVP_DigestInit_ex(mdctx, pMD, nullptr); + EVP_DigestUpdate(mdctx, content.constData(), content.size()); + EVP_DigestFinal_ex(mdctx, ucMDValue, &uMDLen); + EVP_MD_CTX_free(mdctx); for(u = 0; u < uMDLen; u++) { diff --git a/src/modules/filetransferwindow/FileTransferWindow.cpp b/src/modules/filetransferwindow/FileTransferWindow.cpp index d802c2bc1..03328ecd5 100644 --- a/src/modules/filetransferwindow/FileTransferWindow.cpp +++ b/src/modules/filetransferwindow/FileTransferWindow.cpp @@ -248,7 +248,7 @@ void FileTransferItemDelegate::paint(QPainter * p, const QStyleOptionViewItem & QSize FileTransferItemDelegate::sizeHint(const QStyleOptionViewItem &, const QModelIndex &) const { // FIXME fixed width - return QSize(((FileTransferWidget *)parent())->viewport()->size().width(), 68); + return { ((FileTransferWidget *)parent())->viewport()->size().width(), 68 }; } FileTransferWindow::FileTransferWindow( @@ -666,7 +666,7 @@ void FileTransferWindow::openLocalFile() if(tmp.isEmpty()) return; tmp.replace("/", "\\"); - ShellExecute(0, TEXT("open"), tmp.toStdWString().c_str(), NULL, NULL, SW_SHOWNORMAL); //You have to link the shell32.lib + ShellExecute(0, TEXT("open"), tmp.toStdWString().c_str(), nullptr, nullptr, SW_SHOWNORMAL); //You have to link the shell32.lib #else // G&N end #ifdef COMPILE_KDE4_SUPPORT diff --git a/src/modules/filetransferwindow/FileTransferWindow.h b/src/modules/filetransferwindow/FileTransferWindow.h index 120d87c50..9c13d1c0c 100644 --- a/src/modules/filetransferwindow/FileTransferWindow.h +++ b/src/modules/filetransferwindow/FileTransferWindow.h @@ -51,11 +51,11 @@ class FileTransferWidget : public KviTalTableWidget public: FileTransferWidget(QWidget * pParent); ~FileTransferWidget(){}; - void paintEvent(QPaintEvent * event); + void paintEvent(QPaintEvent * event) override; int dummyRead() const { return 0; }; protected: - void mousePressEvent(QMouseEvent * e); - void mouseDoubleClickEvent(QMouseEvent * e); + void mousePressEvent(QMouseEvent * e) override; + void mouseDoubleClickEvent(QMouseEvent * e) override; signals: void rightButtonPressed(FileTransferItem *, QPoint pnt); void doubleClicked(FileTransferItem *, QPoint pnt); @@ -81,7 +81,7 @@ class FileTransferItemDelegate : public KviTalIconAndRichTextItemDelegate { Q_OBJECT public: - FileTransferItemDelegate(QAbstractItemView * pWidget = 0) + FileTransferItemDelegate(QAbstractItemView * pWidget = nullptr) : KviTalIconAndRichTextItemDelegate(pWidget){}; ~FileTransferItemDelegate(){}; QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const; @@ -117,18 +117,18 @@ public: // Methods virtual void die(); protected: - virtual QPixmap * myIconPtr(); - virtual void fillCaptionBuffers(); - virtual void applyOptions(); - virtual void resizeEvent(QResizeEvent * e); - virtual void getBaseLogFileName(QString & buffer); + QPixmap * myIconPtr() override; + void fillCaptionBuffers() override; + void applyOptions() override; + void resizeEvent(QResizeEvent * e) override; + void getBaseLogFileName(QString & buffer) override; FileTransferItem * findItem(KviFileTransfer * t); void fillTransferView(); KviFileTransfer * selectedTransfer(); - bool eventFilter(QObject * obj, QEvent * ev); + bool eventFilter(QObject * obj, QEvent * ev) override; public: - virtual QSize sizeHint() const; + QSize sizeHint() const override; int lineSpacing() { return m_iLineSpacing; }; protected slots: void transferRegistered(KviFileTransfer * t); diff --git a/src/modules/fish/libkvifish.cpp b/src/modules/fish/libkvifish.cpp index 437b6c6e6..5d17ec994 100644 --- a/src/modules/fish/libkvifish.cpp +++ b/src/modules/fish/libkvifish.cpp @@ -81,25 +81,34 @@ static bool fish_DH1080_gen(unsigned char ** szPubKey, int * iLen) if(!g_fish_dh) { BIGNUM * dhp = BN_new(); - BN_init(dhp); if(!BN_hex2bn(&dhp, g_fish_prime1080_hex)) return false; BIGNUM * dhg = BN_new(); - BN_init(dhg); if(!BN_hex2bn(&dhg, g_fish_generator)) return false; g_fish_dh = DH_new(); +#if OPENSSL_VERSION_NUMBER >= 0x10100005L + DH_set0_pqg(g_fish_dh, dhp, nullptr, dhg); +#else g_fish_dh->p = dhp; g_fish_dh->g = dhg; +#endif DH_generate_key(g_fish_dh); } - *iLen = BN_num_bytes(g_fish_dh->pub_key); + const BIGNUM* pub_key; +#if OPENSSL_VERSION_NUMBER >= 0x10100005L + DH_get0_key(g_fish_dh, &pub_key, nullptr); +#else + pub_key = g_fish_dh->pub_key; +#endif + + *iLen = BN_num_bytes(pub_key); *szPubKey = (unsigned char *)KviMemory::allocate(*iLen); - BN_bn2bin(g_fish_dh->pub_key, *szPubKey); + BN_bn2bin(pub_key, *szPubKey); return true; #else diff --git a/src/modules/help/HelpIndex.cpp b/src/modules/help/HelpIndex.cpp index f34a9fc47..102b666e8 100644 --- a/src/modules/help/HelpIndex.cpp +++ b/src/modules/help/HelpIndex.cpp @@ -45,20 +45,26 @@ #include <QTextStream> #include <QUrl> #include <QTextCodec> -#include <ctype.h> +#include <cctype> #include <QTextDocument> #include <QTimer> #include <algorithm> +#include <utility> QT_BEGIN_NAMESPACE struct Term { - Term() : frequency(-1) {} - Term(const QString & t, int f, QVector<Document> l) : term(t), frequency(f), documents(l) {} + Term() = default; + Term(QString t, int f, QVector<Document> l) + : term(std::move(t)) + , frequency(f) + , documents(std::move(l)) + { + } QString term; - int frequency; + int frequency = -1; QVector<Document> documents; bool operator<(const Term & i2) const { return frequency < i2.frequency; } }; @@ -77,15 +83,13 @@ QDataStream & operator<<(QDataStream & s, const Document & l) return s; } -HelpIndex::HelpIndex(const QString & dp, const QString & hp) - : QObject(nullptr), docPath(dp) +HelpIndex::HelpIndex(QString dp, const QString & /* hp */) + : QObject(nullptr) + , docPath(std::move(dp)) { - Q_UNUSED(hp); - alreadyHaveDocList = false; - lastWindowClosed = false; - connect(qApp, SIGNAL(lastWindowClosed()), - this, SLOT(setLastWinClosed())); + + connect(qApp, SIGNAL(lastWindowClosed()), this, SLOT(setLastWinClosed())); m_pTimer = new QTimer(this); m_pTimer->setSingleShot(true); @@ -93,13 +97,12 @@ HelpIndex::HelpIndex(const QString & dp, const QString & hp) connect(m_pTimer, SIGNAL(timeout()), this, SLOT(filterNext())); } -HelpIndex::HelpIndex(const QStringList & dl, const QString & hp) +HelpIndex::HelpIndex(QStringList dl, const QString & /* hp */) : QObject(nullptr) + , docList{ std::move(dl) } { - Q_UNUSED(hp); - docList = dl; alreadyHaveDocList = true; - lastWindowClosed = false; + connect(qApp, SIGNAL(lastWindowClosed()), this, SLOT(setLastWinClosed())); } diff --git a/src/modules/help/HelpIndex.h b/src/modules/help/HelpIndex.h index 0a6b401f8..5938ec136 100644 --- a/src/modules/help/HelpIndex.h +++ b/src/modules/help/HelpIndex.h @@ -52,8 +52,8 @@ QT_BEGIN_NAMESPACE struct Document { + Document() = default; Document(int d, int f) : docNumber(d), frequency(f) {} - Document() : docNumber(-1), frequency(0) {} bool operator==(const Document & doc) const { return docNumber == doc.docNumber; @@ -70,8 +70,8 @@ struct Document { return frequency < doc.frequency; } - qint16 docNumber; - qint16 frequency; + qint16 docNumber = -1; + qint16 frequency = 0; }; QDataStream & operator>>(QDataStream & s, Document & l); @@ -93,8 +93,8 @@ public: QList<uint> positions; }; - HelpIndex(const QString & dp, const QString & hp); - HelpIndex(const QStringList & dl, const QString & hp); + HelpIndex(QString dp, const QString & hp); + HelpIndex(QStringList dl, const QString & hp); void writeDict(); void readDict(); void makeIndex(); @@ -104,8 +104,8 @@ public: void setDocListFile(const QString &); void setDocList(const QStringList &); - const QStringList & documentList() { return docList; }; - const QStringList & titlesList() { return titleList; }; + const QStringList & documentList() const { return docList; }; + const QStringList & titlesList() const { return titleList; }; signals: void indexingStart(int); @@ -127,19 +127,21 @@ private: QVector<Document> setupDummyTerm(const QStringList &); bool searchForPattern(const QStringList &, const QStringList &, const QString &); void buildMiniDict(const QString &); + QString getCharsetForDocument(QFile *); QStringList docList; QStringList titleList; QHash<QString, Entry *> dict; QHash<QString, PosEntry *> miniDict; - uint wordNum; + uint wordNum = 0; QString docPath; - QString dictFile, docListFile; + QString dictFile; + QString docListFile; bool alreadyHaveDocList; - bool lastWindowClosed; + bool lastWindowClosed = false; QHash<QString, QString> documentTitleCache; - QTimer * m_pTimer; - int m_iCurItem; + QTimer * m_pTimer = nullptr; + int m_iCurItem = 0; }; #endif diff --git a/src/modules/help/HelpWindow.cpp b/src/modules/help/HelpWindow.cpp index 8ae68e57b..c7140d641 100644 --- a/src/modules/help/HelpWindow.cpp +++ b/src/modules/help/HelpWindow.cpp @@ -186,7 +186,7 @@ void HelpWindow::startSearch() str = str.replace("`", "\""); QString buf = str; str = str.replace("-", " "); - str = str.replace(QRegExp("\\s[\\S]?\\s"), " "); + str = str.replace(QRegExp(R"(\s[\S]?\s)"), " "); m_terms = str.split(" ", QString::SkipEmptyParts); QStringList termSeq; QStringList seqWords; diff --git a/src/modules/help/HelpWindow.h b/src/modules/help/HelpWindow.h index 1447d15dc..865fb5fee 100644 --- a/src/modules/help/HelpWindow.h +++ b/src/modules/help/HelpWindow.h @@ -72,11 +72,11 @@ protected: public: HelpWidget * helpWidget() { return m_pHelpWidget; }; protected: - virtual QPixmap * myIconPtr(); - virtual void fillCaptionBuffers(); - virtual void resizeEvent(QResizeEvent * e); - virtual void saveProperties(KviConfigurationFile * cfg); - virtual void loadProperties(KviConfigurationFile * cfg); + QPixmap * myIconPtr() override; + void fillCaptionBuffers() override; + void resizeEvent(QResizeEvent * e) override; + void saveProperties(KviConfigurationFile * cfg) override; + void loadProperties(KviConfigurationFile * cfg) override; public: #ifdef COMPILE_WEBKIT_SUPPORT diff --git a/src/modules/http/HttpFileTransfer.cpp b/src/modules/http/HttpFileTransfer.cpp index d1112450e..b21b81904 100644 --- a/src/modules/http/HttpFileTransfer.cpp +++ b/src/modules/http/HttpFileTransfer.cpp @@ -304,11 +304,11 @@ int HttpFileTransfer::displayHeight(int iLineSpacing) QString HttpFileTransfer::tipText() { QString s; - s = QString("<table><tr><td bgcolor=\"#000000\"><font color=\"#FFFFFF\"><b>HTTP Transfer (ID %1)</b></font></td></tr>").arg(id()); + s = QString(R"(<table><tr><td bgcolor="#000000"><font color="#FFFFFF"><b>HTTP Transfer (ID %1)</b></font></td></tr>)").arg(id()); if(m_lRequest.count() > 0) { - s += "<tr><td bgcolor=\"#404040\"><font color=\"#FFFFFF\">Request Headers</font></td></tr>"; + s += R"(<tr><td bgcolor="#404040"><font color="#FFFFFF">Request Headers</font></td></tr>)"; s += "<tr><td bgcolor=\"#C0C0C0\">"; for(QStringList::ConstIterator it = m_lRequest.begin(); it != m_lRequest.end(); ++it) { @@ -321,7 +321,7 @@ QString HttpFileTransfer::tipText() if(m_lHeaders.count() > 0) { - s += "<tr><td bgcolor=\"#404040\"><font color=\"#FFFFFF\">Response Headers</font></td></tr>"; + s += R"(<tr><td bgcolor="#404040"><font color="#FFFFFF">Response Headers</font></td></tr>)"; s += "<tr><td bgcolor=\"#C0C0C0\">"; for(QStringList::ConstIterator it = m_lHeaders.begin(); it != m_lHeaders.end(); ++it) { diff --git a/src/modules/ident/libkviident.cpp b/src/modules/ident/libkviident.cpp index dcfe35ebf..c81554fda 100644 --- a/src/modules/ident/libkviident.cpp +++ b/src/modules/ident/libkviident.cpp @@ -46,7 +46,6 @@ extern KVIRC_API int g_iIdentDaemonRunningUsers; void startIdentService() { - // qDebug("Stargin"); if(!g_pIdentDaemon) g_pIdentDaemon = new KviIdentDaemon(); if(!g_pIdentDaemon->isRunning()) @@ -59,16 +58,13 @@ void startIdentService() usleep(100); #endif } - // qDebug("Service started"); } void stopIdentService() { - // qDebug("Stopping"); if(g_pIdentDaemon) delete g_pIdentDaemon; g_pIdentDaemon = nullptr; - // qDebug("Stopped"); } KviIdentSentinel::KviIdentSentinel() @@ -155,7 +151,6 @@ KviIdentRequest::~KviIdentRequest() KviIdentDaemon::KviIdentDaemon() : KviSensitiveThread() { - // qDebug("Thread constructor"); m_szUser = KVI_OPTION_STRING(KviOption_stringIdentdUser); if(m_szUser.isEmpty()) m_szUser = "kvirc"; @@ -166,17 +161,14 @@ KviIdentDaemon::KviIdentDaemon() m_bEnableIPv6 = false; #endif m_bIPv6ContainsIPv4 = KVI_OPTION_BOOL(KviOption_boolIdentdIPv6ContainsIPv4); - // qDebug("Thread constructor done"); } KviIdentDaemon::~KviIdentDaemon() { - // qDebug("Thread destructor"); terminate(); g_iIdentDaemonRunningUsers = 0; g_pIdentDaemon = nullptr; - // qDebug("Destructor gone"); } void KviIdentDaemon::postMessage(const char * message, KviIdentRequest * r, const char * szAux) @@ -201,7 +193,6 @@ void KviIdentDaemon::postMessage(const char * message, KviIdentRequest * r, cons void KviIdentDaemon::run() { - // qDebug("RUN STARTED"); m_sock = KVI_INVALID_SOCKET; m_sock6 = KVI_INVALID_SOCKET; bool bEventPosted = false; @@ -511,7 +502,6 @@ ipv6_failure: } else { - // qDebug("Data is : (%s)",r->m_szData.ptr()); if(r->m_szData.len() > 1024) { // request too long...kill it @@ -556,7 +546,6 @@ exit_thread: delete m_pRequestList; m_pRequestList = nullptr; - // qDebug("RUN EXITING"); } /* diff --git a/src/modules/ident/libkviident.h b/src/modules/ident/libkviident.h index 238755aa6..2aa573402 100644 --- a/src/modules/ident/libkviident.h +++ b/src/modules/ident/libkviident.h @@ -47,13 +47,13 @@ public: time_t m_tStart; }; -typedef struct _KviIdentMessageData +struct KviIdentMessageData { KviCString szMessage; KviCString szHost; KviCString szAux; unsigned int uPort; -} KviIdentMessageData; +}; class KviIdentSentinel : public QObject { @@ -63,7 +63,7 @@ public: ~KviIdentSentinel(); protected: - virtual bool event(QEvent * e); + bool event(QEvent * e) override; }; class KviIdentDaemon : public KviSensitiveThread @@ -79,13 +79,13 @@ private: bool m_bIPv6ContainsIPv4; kvi_socket_t m_sock; kvi_socket_t m_sock6; - KviPointerList<KviIdentRequest> * m_pRequestList; + KviPointerList<KviIdentRequest> * m_pRequestList = nullptr; public: - virtual void run(); + void run() override; protected: - void postMessage(const char * message, KviIdentRequest * r, const char * szAux = 0); + void postMessage(const char * message, KviIdentRequest * r, const char * szAux = nullptr); }; #endif //_LIBKVIIDENT_H_ diff --git a/src/modules/iograph/libkviiograph.cpp b/src/modules/iograph/libkviiograph.cpp index c9149a682..8e08bb427 100644 --- a/src/modules/iograph/libkviiograph.cpp +++ b/src/modules/iograph/libkviiograph.cpp @@ -22,7 +22,7 @@ // //============================================================================= -#include <math.h> +#include <cmath> #include "libkviiograph.h" #include "KviMainWindow.h" diff --git a/src/modules/iograph/libkviiograph.h b/src/modules/iograph/libkviiograph.h index c66812b48..9c7c0eeb1 100644 --- a/src/modules/iograph/libkviiograph.h +++ b/src/modules/iograph/libkviiograph.h @@ -51,8 +51,8 @@ protected: kvi_u64_t m_uLastRecvBytes; protected: - virtual void timerEvent(QTimerEvent * e); - virtual void paintEvent(QPaintEvent * e); + void timerEvent(QTimerEvent * e) override; + void paintEvent(QPaintEvent * e) override; }; class KviIOGraphWindow : public KviWindow @@ -67,12 +67,12 @@ private: virtual void updatePseudoTransparency(); protected: - virtual QPixmap * myIconPtr(); - virtual void fillCaptionBuffers(); - virtual void resizeEvent(QResizeEvent * e); + QPixmap * myIconPtr() override; + void fillCaptionBuffers() override; + void resizeEvent(QResizeEvent * e) override; virtual void die(); - virtual void moveEvent(QMoveEvent *); - virtual void paintEvent(QPaintEvent * e); + void moveEvent(QMoveEvent *) override; + void paintEvent(QPaintEvent * e) override; }; #endif diff --git a/src/modules/language/detector.cpp b/src/modules/language/detector.cpp index bbdb67812..9e5694972 100644 --- a/src/modules/language/detector.cpp +++ b/src/modules/language/detector.cpp @@ -23,30 +23,31 @@ // DO NOT EDIT THIS FILE: Edit detector/build_detector.pl instead! // -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <ctype.h> +#include <cstdlib> +#include <cstdio> +#include <cstring> +#include <cctype> #include "detector.h" +namespace { // // CORE DEFS // -typedef struct _DetectorNGram +struct DetectorNGram { const unsigned char * szNGram; double dScore; -} DetectorNGram; +}; -typedef struct _DetectorDescriptor +struct DetectorDescriptor { const char * szLanguage; const char * szEncoding; double single_char_data[256]; DetectorNGram * ngram_hash[256]; -} DetectorDescriptor; +}; static DetectorNGram X[] = { { nullptr, 0 } }; @@ -18712,6 +18713,7 @@ static int utf8score(const unsigned char * p) } static const char * unknown_string = "?"; +} // namespace void detect_language_and_encoding(const char * data, LanguageAndEncodingResult * retBuffer, int iFlags = 0) { diff --git a/src/modules/language/detector.h b/src/modules/language/detector.h index 7ed71bb6c..b11200904 100644 --- a/src/modules/language/detector.h +++ b/src/modules/language/detector.h @@ -27,18 +27,18 @@ #define DLE_NUM_BEST_MATCHES 4 #define DLE_STRICT_UTF8_CHECKING 1 -typedef struct _LanguageAndEncodingMatch +struct LanguageAndEncodingMatch { const char * szLanguage; const char * szEncoding; double dScore; -} LanguageAndEncodingMatch; +}; -typedef struct _LanguageAndEncodingResult +struct LanguageAndEncodingResult { LanguageAndEncodingMatch match[DLE_NUM_BEST_MATCHES]; // the first best matches double dAccuracy; // accuracy score: from 0 to 100 -} LanguageAndEncodingResult; +}; void detect_language_and_encoding(const char * data, LanguageAndEncodingResult * retBuffer, int iFlags); diff --git a/src/modules/language/detector/build_detector.pl b/src/modules/language/detector/build_detector.pl index 45c75d5fc..df702ca5a 100755 --- a/src/modules/language/detector/build_detector.pl +++ b/src/modules/language/detector/build_detector.pl @@ -95,30 +95,31 @@ print OUTPUT "//\n"; print OUTPUT "// DO NOT EDIT THIS FILE: Edit detector/build_detector.pl instead!\n"; print OUTPUT "//\n"; print OUTPUT "\n"; -print OUTPUT "#include <stdlib.h>\n"; -print OUTPUT "#include <stdio.h>\n"; -print OUTPUT "#include <string.h>\n"; -print OUTPUT "#include <ctype.h>\n"; +print OUTPUT "#include <cstdlib>\n"; +print OUTPUT "#include <cstdio>\n"; +print OUTPUT "#include <cstring>\n"; +print OUTPUT "#include <cctype>\n"; print OUTPUT "\n"; print OUTPUT "#include \"detector.h\"\n"; print OUTPUT "\n"; +print OUTPUT "namespace {\n"; print OUTPUT "///////////////////////////////////////////////////////////////////////////////\n"; print OUTPUT "// CORE DEFS\n"; print OUTPUT "///////////////////////////////////////////////////////////////////////////////\n"; print OUTPUT "\n"; -print OUTPUT "typedef struct _DetectorNGram\n"; +print OUTPUT "struct DetectorNGram\n"; print OUTPUT "{\n"; print OUTPUT " const unsigned char * szNGram;\n"; print OUTPUT " ".$g_dataTypeName." dScore;\n"; -print OUTPUT "} DetectorNGram;\n"; +print OUTPUT "};\n"; print OUTPUT "\n"; -print OUTPUT "typedef struct _DetectorDescriptor\n"; +print OUTPUT "struct DetectorDescriptor\n"; print OUTPUT "{\n"; print OUTPUT " const char * szLanguage;\n"; print OUTPUT " const char * szEncoding;\n"; print OUTPUT " ".$g_dataTypeName." single_char_data[256];\n"; print OUTPUT " DetectorNGram * ngram_hash[256];\n"; -print OUTPUT "} DetectorDescriptor;\n"; +print OUTPUT "};\n"; print OUTPUT "\n"; print OUTPUT "static DetectorNGram X[] = { { 0, 0 } };\n"; print OUTPUT "\n"; @@ -786,6 +787,7 @@ print OUTPUT "\n"; print OUTPUT "\n"; print OUTPUT "static const char * unknown_string = \"?\";\n"; +print OUTPUT "} // namespace\n"; print OUTPUT "\n"; print OUTPUT "void detect_language_and_encoding(const char * data,LanguageAndEncodingResult * retBuffer,int iFlags = 0)\n"; print OUTPUT "{\n"; diff --git a/src/modules/links/LinksWindow.h b/src/modules/links/LinksWindow.h index 89b4b40b6..4cf166adb 100644 --- a/src/modules/links/LinksWindow.h +++ b/src/modules/links/LinksWindow.h @@ -40,13 +40,13 @@ class KviThemedLabel; -typedef struct _KviLink +struct KviLink { KviCString host; KviCString parent; int hops; KviCString description; -} KviLink; +}; class LinksListView : public KviThemedTreeWidget { @@ -56,7 +56,7 @@ public: ~LinksListView(){}; protected: - void mousePressEvent(QMouseEvent * e); + void mousePressEvent(QMouseEvent * e) override; signals: void rightButtonPressed(QTreeWidgetItem *, QPoint); }; @@ -79,16 +79,16 @@ protected: KviThemedLabel * m_pInfoLabel; public: // Methods - virtual void control(int msg); - virtual void processData(KviIrcMessage * msg); - virtual void die(); + void control(int msg) override; + void processData(KviIrcMessage * msg) override; + void die() override; protected: - virtual QPixmap * myIconPtr(); - virtual void fillCaptionBuffers(); - virtual void applyOptions(); - virtual void resizeEvent(QResizeEvent * e); - virtual void getBaseLogFileName(QString & buffer); + QPixmap * myIconPtr() override; + void fillCaptionBuffers() override; + void applyOptions() override; + void resizeEvent(QResizeEvent * e) override; + void getBaseLogFileName(QString & buffer) override; protected slots: void showHostPopup(QTreeWidgetItem * i, const QPoint & p); void hostPopupClicked(QAction * pAction); @@ -96,7 +96,7 @@ protected slots: void connectionStateChange(); public: - virtual QSize sizeHint() const; + QSize sizeHint() const override; private: void reset(); diff --git a/src/modules/list/ListWindow.cpp b/src/modules/list/ListWindow.cpp index 392ab9d60..8a52f28e8 100644 --- a/src/modules/list/ListWindow.cpp +++ b/src/modules/list/ListWindow.cpp @@ -113,7 +113,7 @@ QSize ChannelTreeWidgetItemDelegate::sizeHint(const QStyleOptionViewItem & sovIt ChannelTreeWidgetItem * item = dynamic_cast<ChannelTreeWidgetItem *>(treeWidget->itemFromIndex(index)); if(!item) - return QSize(100, iHeight); + return { 100, iHeight }; QFontMetrics fm(sovItem.font); switch(index.column()) diff --git a/src/modules/list/ListWindow.h b/src/modules/list/ListWindow.h index 08c8811b0..0eba68571 100644 --- a/src/modules/list/ListWindow.h +++ b/src/modules/list/ListWindow.h @@ -44,7 +44,7 @@ class KviThemedLineEdit; class ChannelTreeWidgetItemDelegate : public QItemDelegate { public: - ChannelTreeWidgetItemDelegate(QTreeWidget * pWidget = 0); + ChannelTreeWidgetItemDelegate(QTreeWidget * pWidget = nullptr); ~ChannelTreeWidgetItemDelegate(); void paint(QPainter * pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const; QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const; @@ -80,7 +80,7 @@ private: public: bool operator<(const QTreeWidgetItem & other) const; - inline ChannelTreeWidgetItemData * itemData() { return m_pData; }; + ChannelTreeWidgetItemData * itemData() const { return m_pData; } }; class ChannelTreeWidget : public KviThemedTreeWidget @@ -115,17 +115,17 @@ protected: KviPointerList<ChannelTreeWidgetItemData> * m_pItemList; public: // Methods - virtual void control(int iMsg); - virtual void processData(KviIrcMessage * pMsg); - virtual void die(); - virtual QSize sizeHint() const; + void control(int iMsg) override; + void processData(KviIrcMessage * pMsg) override; + void die() override; + QSize sizeHint() const override; protected: - virtual QPixmap * myIconPtr(); - virtual void fillCaptionBuffers(); - virtual void applyOptions(); - virtual void resizeEvent(QResizeEvent * e); - virtual void getBaseLogFileName(QString & szBuffer); + QPixmap * myIconPtr() override; + void fillCaptionBuffers() override; + void applyOptions() override; + void resizeEvent(QResizeEvent * e) override; + void getBaseLogFileName(QString & szBuffer) override; protected slots: void flush(); void itemDoubleClicked(QTreeWidgetItem * it, int); diff --git a/src/modules/logview/LogFile.h b/src/modules/logview/LogFile.h index 53281af8a..9b4984aa7 100644 --- a/src/modules/logview/LogFile.h +++ b/src/modules/logview/LogFile.h @@ -37,16 +37,15 @@ class QString; /** -* \typedef LogFileData * \struct _LogFileData * \brief A struct that contains the data of a log */ -typedef struct _LogFileData +struct LogFileData { QString szName; /**< the name of the log */ QString szType; /**< the type of the log */ QString szFile; /**< the name of the exported log */ -} LogFileData; +}; /** * \class LogFile diff --git a/src/modules/logview/LogViewWindow.cpp b/src/modules/logview/LogViewWindow.cpp index c0cb2590d..f954ad9df 100644 --- a/src/modules/logview/LogViewWindow.cpp +++ b/src/modules/logview/LogViewWindow.cpp @@ -58,7 +58,7 @@ #include <QCheckBox> #include <QMenu> -#include <limits.h> //for INT_MAX +#include <climits> //for INT_MAX extern LogViewWindow * g_pLogViewWindow; @@ -739,7 +739,7 @@ void LogViewWindow::createLog(LogFile * pLog, int iId, QString * pszFile) // insert msgtype icon at start of the current text line KviMessageTypeSettings msg(KVI_OPTION_MSGTYPE(iMsgType)); QString szIcon = g_pIconManager->getSmallIconResourceName((KviIconManager::SmallIcon)msg.pixId()); - szTmp.prepend("<img src=\"" + szIcon + "\" alt=\"\" /> "); + szTmp.prepend("<img src=\"" + szIcon + R"(" alt="" /> )"); /* * Check if the nick who has talked is the same of the above line. diff --git a/src/modules/logview/LogViewWindow.h b/src/modules/logview/LogViewWindow.h index c2e2ed850..b90866b39 100644 --- a/src/modules/logview/LogViewWindow.h +++ b/src/modules/logview/LogViewWindow.h @@ -55,7 +55,7 @@ public: ~LogViewListView(){}; protected: - void mousePressEvent(QMouseEvent * pEvent); + void mousePressEvent(QMouseEvent * pEvent) override; signals: void rightButtonPressed(QTreeWidgetItem *, QPoint); }; @@ -89,7 +89,6 @@ protected: QDateEdit * m_pFromDateEdit; QDateEdit * m_pToDateEdit; - QStringList * m_pFileNames; QTabWidget * m_pTabWidget; KviTalVBox * m_pIndexTab; KviTalVBox * m_pLeftLayout; @@ -98,10 +97,10 @@ protected: QPushButton * m_pCancelButton; KviTalHBox * m_pBottomLayout; QProgressBar * m_pProgressBar; - LogListViewItem * m_pLastCategory; - LogListViewItemFolder * m_pLastGroupItem; + LogListViewItem * m_pLastCategory = nullptr; + LogListViewItemFolder * m_pLastGroupItem = nullptr; QString m_szLastGroup; - bool m_bAborted; + bool m_bAborted = false; QTimer * m_pTimer; QMenu * m_pExportLogPopup; @@ -120,12 +119,12 @@ protected: void recurseDirectory(const QString & szDir); void setupItemList(); - virtual QPixmap * myIconPtr(); - virtual void resizeEvent(QResizeEvent * pEvent); - virtual void keyPressEvent(QKeyEvent * pEvent); - virtual void fillCaptionBuffers(); + QPixmap * myIconPtr() override; + void resizeEvent(QResizeEvent * pEvent) override; + void keyPressEvent(QKeyEvent * pEvent) override; + void fillCaptionBuffers() override; virtual void die(); - virtual QSize sizeHint() const; + QSize sizeHint() const override; protected slots: void rightButtonClicked(QTreeWidgetItem *, const QPoint &); void itemSelected(QTreeWidgetItem * pItem, QTreeWidgetItem *); diff --git a/src/modules/mediaplayer/MpAmipInterface.cpp b/src/modules/mediaplayer/MpAmipInterface.cpp index 640c9fc8f..2514ba52b 100644 --- a/src/modules/mediaplayer/MpAmipInterface.cpp +++ b/src/modules/mediaplayer/MpAmipInterface.cpp @@ -51,7 +51,7 @@ enum ac_ErrorCode #define AC_BUFFER_SIZE 2048 -static HINSTANCE amip_dll = NULL; +static HINSTANCE amip_dll = nullptr; #define MP_AC_DYNPTR(__rettype, __func, __args) \ typedef __rettype(CALLBACK * lp_##__func)(__args); \ @@ -94,7 +94,7 @@ static bool loadAmipDll() static QTextCodec * mediaplayer_get_codec() { - QTextCodec * pCodec = 0; + QTextCodec * pCodec = nullptr; pCodec = QTextCodec::codecForName(KVI_OPTION_STRING(KviOption_stringWinampTextEncoding).toUtf8()); if(!pCodec) @@ -120,7 +120,7 @@ MpAmipInterface::MpAmipInterface() bool res = loadAmipDll(); if(!res) { - amip_dll = NULL; + amip_dll = nullptr; return; } ac_init(AC_START_CLIENT); @@ -133,7 +133,7 @@ MpAmipInterface::~MpAmipInterface() return; ac_uninit(); FreeLibrary(amip_dll); - amip_dll = NULL; + amip_dll = nullptr; } int MpAmipInterface::detect(bool bStart) diff --git a/src/modules/mediaplayer/MpInterface.cpp b/src/modules/mediaplayer/MpInterface.cpp index f0feb5861..ae17beb61 100644 --- a/src/modules/mediaplayer/MpInterface.cpp +++ b/src/modules/mediaplayer/MpInterface.cpp @@ -104,8 +104,7 @@ QString MpInterface::amipEval(const QString &) mp3info mp3; \ if(!scan_mp3_file(f, &mp3)) \ return QString(); \ - QTextCodec * pCodec; \ - pCodec = mediaplayer_get_codec(); + [[maybe_unused]] QTextCodec * pCodec = mediaplayer_get_codec(); #define SCAN_MP3_FILE_RET_INT \ QString f = getLocalFile(); \ @@ -142,7 +141,6 @@ QString MpInterface::comment() QString MpInterface::year() { SCAN_MP3_FILE - Q_UNUSED(pCodec); return QString(mp3.id3.year); } diff --git a/src/modules/mediaplayer/MpInterface.h b/src/modules/mediaplayer/MpInterface.h index a82016b24..69ec610bb 100644 --- a/src/modules/mediaplayer/MpInterface.h +++ b/src/modules/mediaplayer/MpInterface.h @@ -219,7 +219,7 @@ public: _interfaceclass##Descriptor::_interfaceclass##Descriptor() \ : MpInterfaceDescriptor() \ { \ - m_pInstance = 0; \ + m_pInstance = nullptr; \ m_szName = _name; \ m_szDescription = _description; \ } \ diff --git a/src/modules/mediaplayer/MpMp3.cpp b/src/modules/mediaplayer/MpMp3.cpp index 98366a9c7..7218e4ffc 100644 --- a/src/modules/mediaplayer/MpMp3.cpp +++ b/src/modules/mediaplayer/MpMp3.cpp @@ -239,7 +239,7 @@ int get_first_header(mp3info * mp3, long startpos) long valid_start = 0; fseek(mp3->file, startpos, SEEK_SET); - while(1) + while(true) { while((c = fgetc(mp3->file)) != 255 && (c != EOF)) { @@ -384,9 +384,8 @@ int get_id3(mp3info * mp3) } else { - size_t dummy = fread(fbuf, 1, 3, mp3->file); + (void)fread(fbuf, 1, 3, mp3->file); fbuf[3] = '\0'; - Q_UNUSED(dummy); mp3->id3.genre[0] = 255; if(!strcmp((const char *)"TAG", (const char *)fbuf)) @@ -394,21 +393,21 @@ int get_id3(mp3info * mp3) mp3->id3_isvalid = 1; mp3->datasize -= 128; fseek(mp3->file, -125, SEEK_END); - dummy = fread(mp3->id3.title, 1, 30, mp3->file); + (void)fread(mp3->id3.title, 1, 30, mp3->file); mp3->id3.title[30] = '\0'; - dummy = fread(mp3->id3.artist, 1, 30, mp3->file); + (void)fread(mp3->id3.artist, 1, 30, mp3->file); mp3->id3.artist[30] = '\0'; - dummy = fread(mp3->id3.album, 1, 30, mp3->file); + (void)fread(mp3->id3.album, 1, 30, mp3->file); mp3->id3.album[30] = '\0'; - dummy = fread(mp3->id3.year, 1, 4, mp3->file); + (void)fread(mp3->id3.year, 1, 4, mp3->file); mp3->id3.year[4] = '\0'; - dummy = fread(mp3->id3.comment, 1, 30, mp3->file); + (void)fread(mp3->id3.comment, 1, 30, mp3->file); mp3->id3.comment[30] = '\0'; if(mp3->id3.comment[28] == '\0') { mp3->id3.track[0] = mp3->id3.comment[29]; } - dummy = fread(mp3->id3.genre, 1, 1, mp3->file); + (void)fread(mp3->id3.genre, 1, 1, mp3->file); unpad(mp3->id3.title); unpad(mp3->id3.artist); unpad(mp3->id3.album); diff --git a/src/modules/mediaplayer/MpMp3.h b/src/modules/mediaplayer/MpMp3.h index 6d534e625..5051f14a8 100644 --- a/src/modules/mediaplayer/MpMp3.h +++ b/src/modules/mediaplayer/MpMp3.h @@ -66,7 +66,7 @@ enum VBR_REPORT VBR_MEDIAN }; -typedef struct +struct mp3header { unsigned int sync; unsigned int version; @@ -81,9 +81,9 @@ typedef struct unsigned int copyright; unsigned int original; unsigned int emphasis; -} mp3header; +}; -typedef struct +struct id3tag { char title[31]; char artist[31]; @@ -92,9 +92,9 @@ typedef struct char comment[31]; unsigned char track[1]; unsigned char genre[1]; -} id3tag; +}; -typedef struct +struct mp3info { QString filename; FILE * file; @@ -108,7 +108,7 @@ typedef struct int seconds; int frames; int badframes; -} mp3info; +}; // mode field: // 00 - Stereo diff --git a/src/modules/mediaplayer/MpWinampInterface.cpp b/src/modules/mediaplayer/MpWinampInterface.cpp index 0d08cc4b5..875fc8838 100644 --- a/src/modules/mediaplayer/MpWinampInterface.cpp +++ b/src/modules/mediaplayer/MpWinampInterface.cpp @@ -83,13 +83,13 @@ // ** (requires Winamp 2.04+, only usable from plug-ins (not external apps)) // ** char *name=SendMessage(hwnd_winamp,WM_WA_IPC,index,IPC_GETPLAYLISTFILE); // ** IPC_GETPLAYLISTFILE gets the filename of the playlist entry [index]. -// ** returns a pointer to it. returns NULL on error. +// ** returns a pointer to it. returns nullptr on error. #define IPC_GETPLAYLISTTITLE 212 // * (requires Winamp 2.04+, only usable from plug-ins (not external apps)) // ** char *name=SendMessage(hwnd_winamp,WM_WA_IPC,index,IPC_GETPLAYLISTTITLE); // ** IPC_GETPLAYLISTTITLE gets the title of the playlist entry [index]. -// ** returns a pointer to it. returns NULL on error. +// ** returns a pointer to it. returns nullptr on error. #define IPC_GET_SHUFFLE 250 // ** val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_SHUFFLE); @@ -131,7 +131,7 @@ // ** cds.dwData = IPC_PLAYFILE; // ** cds.lpData = (void *) "file.mp3"; // ** cds.cbData = strlen((char *) cds.lpData)+1; // include space for null char -// ** SendMessage(hwnd_winamp,WM_COPYDATA,(WPARAM)NULL,(LPARAM)&cds); +// ** SendMessage(hwnd_winamp,WM_COPYDATA,(WPARAM)nullptr,(LPARAM)&cds); // ** // ** This will play the file "file.mp3". @@ -165,8 +165,7 @@ static QTextCodec * mediaplayer_get_codec() { - QTextCodec * pCodec = 0; - pCodec = QTextCodec::codecForName(KVI_OPTION_STRING(KviOption_stringWinampTextEncoding).toUtf8()); + QTextCodec * pCodec = QTextCodec::codecForName(KVI_OPTION_STRING(KviOption_stringWinampTextEncoding).toUtf8()); if(!pCodec) pCodec = QTextCodec::codecForLocale(); @@ -175,7 +174,7 @@ static QTextCodec * mediaplayer_get_codec() static HWND find_winamp(KviWinampInterface * i) { - HWND hWnd = FindWindow(TEXT("Winamp v1.x"), NULL); + HWND hWnd = FindWindow(TEXT("Winamp v1.x"), nullptr); if(!hWnd) { // try to start the process ? @@ -385,7 +384,7 @@ bool KviWinampInterface::playMrl(const QString & mrl) cds.dwData = IPC_PLAYFILE; cds.lpData = (void *)szMrl.ptr(); cds.cbData = szMrl.len() + 1; // include space for null char - SendMessage(hWinamp, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds); + SendMessage(hWinamp, WM_COPYDATA, (WPARAM)nullptr, (LPARAM)&cds); return true; } return false; @@ -429,11 +428,11 @@ bool KviWinampInterface::jumpTo(kvs_int_t & iPos) bool KviWinampInterface::hide() { HWND hWinamp = find_winamp(this); - HWND hWinampPE = FindWindow(TEXT("Winamp PE"), NULL); /*Playlist*/ - HWND hWinampEQ = FindWindow(TEXT("Winamp EQ"), NULL); /*Equalizer*/ - HWND hWinampMB = FindWindow(TEXT("Winamp MB"), NULL); /*MiniBrowser*/ - HWND hWinampGen = FindWindow(TEXT("Winamp Gen"), NULL); /*Library*/ - HWND hWinampVideo = FindWindow(TEXT("Winamp Video"), NULL); /*Video*/ + HWND hWinampPE = FindWindow(TEXT("Winamp PE"), nullptr); /*Playlist*/ + HWND hWinampEQ = FindWindow(TEXT("Winamp EQ"), nullptr); /*Equalizer*/ + HWND hWinampMB = FindWindow(TEXT("Winamp MB"), nullptr); /*MiniBrowser*/ + HWND hWinampGen = FindWindow(TEXT("Winamp Gen"), nullptr); /*Library*/ + HWND hWinampVideo = FindWindow(TEXT("Winamp Video"), nullptr); /*Video*/ if(hWinamp) { ShowWindow(hWinamp, SW_HIDE); diff --git a/src/modules/mediaplayer/winamp.cpp b/src/modules/mediaplayer/winamp.cpp index bf8b29138..0d701558a 100644 --- a/src/modules/mediaplayer/winamp.cpp +++ b/src/modules/mediaplayer/winamp.cpp @@ -31,7 +31,7 @@ // This stuff is compiled only on windows, as a separate dll module -typedef struct +struct winampGeneralPurposePlugin { int version; char * description; @@ -40,7 +40,7 @@ typedef struct void (*quit)(); HWND hwndParent; HINSTANCE hDllInstance; -} winampGeneralPurposePlugin; +}; #define GPPHDR_VER 0x10 @@ -72,7 +72,7 @@ winampGeneralPurposePlugin plugin = { #define KVIRC_WM_USER_CHECK 13123 #define KVIRC_WM_USER_CHECK_REPLY 13124 -void * lpWndProcOld = 0; +void * lpWndProcOld = nullptr; char szBuffer[4096]; diff --git a/src/modules/mircimport/libkvimircimport.h b/src/modules/mircimport/libkvimircimport.h index 3069849b4..4c8e00206 100644 --- a/src/modules/mircimport/libkvimircimport.h +++ b/src/modules/mircimport/libkvimircimport.h @@ -43,8 +43,8 @@ public: public: int doImport(const QString & filename); - virtual void start(); - virtual void die(); + void start() override; + void die() override; }; class KviRemoteMircServersIniImport : public KviMircServersIniImport @@ -58,8 +58,8 @@ protected: KviRemoteMircServerImportWizard * m_pWizard; public: - virtual void start(); - virtual void die(); + void start() override; + void die() override; }; class KviRemoteMircServerImportWizard : public KviTalWizard @@ -77,8 +77,8 @@ protected: QString m_szTmpFileName; protected: - virtual void closeEvent(QCloseEvent * e); - virtual void done(int r); + void closeEvent(QCloseEvent * e) override; + void done(int r) override; void start(); protected slots: void getListMessage(const QString & message); diff --git a/src/modules/my/Idle_win.cpp b/src/modules/my/Idle_win.cpp index fe440e9bc..c7dd5004b 100644 --- a/src/modules/my/Idle_win.cpp +++ b/src/modules/my/Idle_win.cpp @@ -24,11 +24,12 @@ #include <QLibrary> -typedef struct tagLASTINPUTINFO +struct LASTINPUTINFO { UINT cbSize; DWORD dwTime; -} LASTINPUTINFO, *PLASTINPUTINFO; +}; +using PLASTINPUTINFO = LASTINPUTINFO *; class IdlePlatform::Private { diff --git a/src/modules/my/libkvimy.cpp b/src/modules/my/libkvimy.cpp index 43ea72c1c..822559314 100644 --- a/src/modules/my/libkvimy.cpp +++ b/src/modules/my/libkvimy.cpp @@ -37,7 +37,7 @@ Idle * g_pIdle; #define GET_KVS_CONSOLE \ kvs_uint_t uiWnd; \ - KviConsoleWindow * wnd = 0; \ + KviConsoleWindow * wnd = nullptr; \ KVSM_PARAMETERS_BEGIN(c) \ KVSM_PARAMETER("context_id", KVS_PT_UINT, KVS_PF_OPTIONAL, uiWnd) \ KVSM_PARAMETERS_END(c) \ diff --git a/src/modules/notifier/NotifierMessage.cpp b/src/modules/notifier/NotifierMessage.cpp index b0a6e401b..6e9018a0d 100644 --- a/src/modules/notifier/NotifierMessage.cpp +++ b/src/modules/notifier/NotifierMessage.cpp @@ -31,19 +31,12 @@ #include <QRect> #include <QResizeEvent> +#include <utility> -NotifierMessage::NotifierMessage(QPixmap * pPixmap, const QString & szText) +NotifierMessage::NotifierMessage(QPixmap * pPixmap, QString szText) + : m_szText{ std::move(szText) } + , m_pPixmap{ pPixmap } { - m_pLabel0 = nullptr; - m_pLabel1 = nullptr; - - m_szText = szText; - m_pPixmap = pPixmap; - - //QByteArray utf8 = szText.toUtf8(); - //if(utf8.data()) - // qDebug("NOTIFIER TEXT MESSAGE: \n%s\n",utf8.data()); - m_pHBox = new QHBoxLayout(this); m_pHBox->setSpacing(SPACING); m_pHBox->setMargin(SPACING); @@ -63,14 +56,14 @@ NotifierMessage::~NotifierMessage() void NotifierMessage::updateGui() { - bool bShowImages = KVI_OPTION_BOOL(KviOption_boolIrcViewShowImages); - if(m_pLabel0) delete m_pLabel0; if(m_pLabel1) delete m_pLabel1; + bool bShowImages = KVI_OPTION_BOOL(KviOption_boolIrcViewShowImages); + if(bShowImages) { m_pLabel0 = new QLabel(this); diff --git a/src/modules/notifier/NotifierMessage.h b/src/modules/notifier/NotifierMessage.h index c0179f0e1..60c0d76b4 100644 --- a/src/modules/notifier/NotifierMessage.h +++ b/src/modules/notifier/NotifierMessage.h @@ -44,6 +44,7 @@ class NotifierMessage : public QWidget { friend class NotifierWindow; + Q_OBJECT public: /** * \brief Constructs the NotifierMessage object @@ -51,7 +52,7 @@ public: * \param szText const reference to message text in irc format * \return NotifierMessage */ - NotifierMessage(QPixmap * pPixmap, const QString & szText); + NotifierMessage(QPixmap * pPixmap, QString szText); /** * \brief Destroys the NotifierMessage object */ @@ -61,25 +62,25 @@ private: /// The message text QString m_szText; /// The message icon (can be null) - QPixmap * m_pPixmap; + QPixmap * m_pPixmap = nullptr; /// Layout for the labels - QHBoxLayout * m_pHBox; + QHBoxLayout * m_pHBox = nullptr; /// Label for the message icon - QLabel * m_pLabel0; + QLabel * m_pLabel0 = nullptr; /// Label for the message text - QLabel * m_pLabel1; + QLabel * m_pLabel1 = nullptr; public: /** * \brief Returns the original irc message - * \return QString + * \return const QString & */ - inline QString text() const { return m_szText; }; + const QString & text() const { return m_szText; } /** * \brief Returns the message icon * \return QPixmap * */ - inline QPixmap * pixmap() const { return m_pPixmap; }; + QPixmap * pixmap() const { return m_pPixmap; } /** * \brief Updates the aspect of this message * \return void diff --git a/src/modules/notifier/NotifierWindow.cpp b/src/modules/notifier/NotifierWindow.cpp index 4ce8ea027..956383176 100644 --- a/src/modules/notifier/NotifierWindow.cpp +++ b/src/modules/notifier/NotifierWindow.cpp @@ -38,43 +38,34 @@ #include "KviThemedLineEdit.h" #include <QApplication> -#include <QImage> #include <QDesktopWidget> -#include <QToolTip> #include <QEvent> -#include <QPen> #include <QFontMetrics> -#include <QRegExp> +#include <QImage> +#include <QMouseEvent> #include <QPainter> #include <QPaintEvent> -#include <QMouseEvent> +#include <QPen> +#include <QRegExp> +#include <QToolTip> extern NotifierWindow * g_pNotifierWindow; NotifierWindow::NotifierWindow() - : QWidget(nullptr, + : QWidget(nullptr, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) - Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint) + | Qt::Tool) #else - Qt::FramelessWindowHint | #ifndef COMPILE_ON_MAC - Qt::Tool | Qt::X11BypassWindowManagerHint | + | Qt::Tool | Qt::X11BypassWindowManagerHint #endif - Qt::WindowStaysOnTopHint) + ) #endif { setObjectName("kvirc_notifier_window"); g_pNotifierWindow = this; - m_eState = Hidden; - m_dOpacity = 0.0; - m_pShowHideTimer = nullptr; - m_pBlinkTimer = nullptr; - m_tAutoHideAt = 0; - m_tStartedAt = 0; - m_pAutoHideTimer = nullptr; - m_pWndBorder = new NotifierWindowBorder(); setFocusPolicy(Qt::NoFocus); @@ -83,24 +74,6 @@ NotifierWindow::NotifierWindow() hide(); - m_bBlinkOn = false; - - m_bCloseDown = false; - m_bPrevDown = false; - m_bNextDown = false; - m_bWriteDown = false; - - m_bLeftButtonIsPressed = false; - m_bDiagonalResizing = false; - m_bResizing = false; - - m_pContextPopup = nullptr; - m_pDisablePopup = nullptr; - - m_bDragging = false; - - m_bDisableHideOnMainWindowGotAttention = false; - // Positioning the notifier bottom-right QDesktopWidget * pDesktop = QApplication::desktop(); QRect r = pDesktop->availableGeometry(pDesktop->primaryScreen()); @@ -162,19 +135,15 @@ void NotifierWindow::updateGui() m_pLineEdit->setFont(KVI_OPTION_FONT(KviOption_fontNotifier)); for(int i = 0; i < m_pWndTabs->count(); ++i) - { ((NotifierWindowTab *)m_pWndTabs->widget(i))->updateGui(); - } } void NotifierWindow::addMessage(KviWindow * pWnd, const QString & szImageId, const QString & szText, unsigned int uMessageTime) { - QPixmap * pIcon; + QPixmap * pIcon = nullptr; QString szMessage = szText; szMessage.replace(QRegExp("\r([^\r])*\r([^\r])+\r"), "\\2"); - if(szImageId.isEmpty()) - pIcon = nullptr; - else + if(!szImageId.isEmpty()) pIcon = g_pIconManager->getImage(szImageId); NotifierMessage * pMessage = new NotifierMessage(pIcon ? new QPixmap(*pIcon) : nullptr, szMessage); @@ -192,9 +161,7 @@ void NotifierWindow::addMessage(KviWindow * pWnd, const QString & szImageId, con } if(!pTab) - { pTab = new NotifierWindowTab(pWnd, m_pWndTabs); - } //if the notifier is already visible, don't steal the focus from the current tab! //the user could be writing a message on it (bug #678) @@ -223,11 +190,8 @@ void NotifierWindow::addMessage(KviWindow * pWnd, const QString & szImageId, con m_tAutoHideAt = 0; } - if(pWnd) - { - if(pWnd->hasAttention(KviWindow::MainWindowIsVisible)) - m_bDisableHideOnMainWindowGotAttention = true; - } + if(pWnd && pWnd->hasAttention(KviWindow::MainWindowIsVisible)) + m_bDisableHideOnMainWindowGotAttention = true; if(isVisible()) update(); @@ -385,8 +349,6 @@ bool NotifierWindow::shouldHideIfMainWindowGotAttention() void NotifierWindow::heartbeat() { - bool bIncreasing; - double targetOpacity = 0; switch(m_eState) { case Hidden: @@ -410,7 +372,7 @@ void NotifierWindow::heartbeat() else { m_dOpacity += OPACITY_STEP; - targetOpacity = isActiveWindow() ? KVI_OPTION_UINT(KviOption_uintNotifierActiveTransparency) : KVI_OPTION_UINT(KviOption_uintNotifierInactiveTransparency); + double targetOpacity = isActiveWindow() ? KVI_OPTION_UINT(KviOption_uintNotifierActiveTransparency) : KVI_OPTION_UINT(KviOption_uintNotifierInactiveTransparency); targetOpacity /= 100; if(m_dOpacity >= targetOpacity) @@ -429,9 +391,10 @@ void NotifierWindow::heartbeat() } break; case FocusingOn: - targetOpacity = KVI_OPTION_UINT(KviOption_uintNotifierActiveTransparency); + { + double targetOpacity = KVI_OPTION_UINT(KviOption_uintNotifierActiveTransparency); targetOpacity /= 100; - bIncreasing = targetOpacity > m_dOpacity; + bool bIncreasing = targetOpacity > m_dOpacity; m_dOpacity += bIncreasing ? OPACITY_STEP : -(OPACITY_STEP); if((bIncreasing && (m_dOpacity >= targetOpacity)) || (!bIncreasing && (m_dOpacity <= targetOpacity))) { @@ -441,13 +404,15 @@ void NotifierWindow::heartbeat() } setWindowOpacity(m_dOpacity); + } break; case FocusingOff: - targetOpacity = KVI_OPTION_UINT(KviOption_uintNotifierInactiveTransparency); + { + double targetOpacity = KVI_OPTION_UINT(KviOption_uintNotifierInactiveTransparency); targetOpacity /= 100; - bIncreasing = targetOpacity > m_dOpacity; + bool bIncreasing = targetOpacity > m_dOpacity; m_dOpacity += bIncreasing ? OPACITY_STEP : -(OPACITY_STEP); - //qDebug("%f %f %i %i",m_dOpacity,targetOpacity,bIncreasing,(m_dOpacity >= targetOpacity)); + if((bIncreasing && (m_dOpacity >= targetOpacity)) || (!bIncreasing && (m_dOpacity <= targetOpacity))) { m_dOpacity = targetOpacity; @@ -456,6 +421,7 @@ void NotifierWindow::heartbeat() } setWindowOpacity(m_dOpacity); + } break; case Hiding: m_dOpacity -= OPACITY_STEP; @@ -512,7 +478,6 @@ void NotifierWindow::doHide(bool bDoAnimate) if((!bDoAnimate) || (x() != m_pWndBorder->x()) || (y() != m_pWndBorder->y())) { - //qDebug("just hide quickly with notifier x() %d and notifier y() % - WBorderx() %d and WBordery() %d and bDoanimate %d",x(),y(),m_pWndBorder->x(),m_pWndBorder->y(),bDoAnimate); // the user asked to not animate or // the window has been moved and the animation would suck anyway // just hide quickly @@ -520,7 +485,6 @@ void NotifierWindow::doHide(bool bDoAnimate) } else { - //qDebug("starting hide animation notifier x() %d and notifier y() % - WBorderx() %d and WBordery() %d and bDoanimate %d",x(),y(),m_pWndBorder->x(),m_pWndBorder->y(),bDoAnimate); m_pShowHideTimer = new QTimer(); connect(m_pShowHideTimer, SIGNAL(timeout()), this, SLOT(heartbeat())); m_dOpacity = 1.0 - OPACITY_STEP; @@ -613,35 +577,18 @@ void NotifierWindow::paintEvent(QPaintEvent * e) if(width() != m_pWndBorder->width() || height() != m_pWndBorder->height()) m_pWndBorder->resize(size()); - if(m_bBlinkOn) - { - m_pWndBorder->draw(pPaint, true); - } - else - { - m_pWndBorder->draw(pPaint); - } + m_pWndBorder->draw(pPaint, m_bBlinkOn); pPaint->setPen(KVI_OPTION_COLOR(KviOption_colorNotifierTitleForeground)); pPaint->setFont(KVI_OPTION_FONT(KviOption_fontNotifierTitle)); QString szTitle = "KVIrc - "; NotifierWindowTab * pTab = (NotifierWindowTab *)m_pWndTabs->currentWidget(); - if(pTab) - { - if(pTab->wnd()) - { - szTitle += pTab->wnd()->plainTextCaption(); - } - else - { - szTitle += "notifier"; - } - } + if(pTab && pTab->wnd()) + szTitle += pTab->wnd()->plainTextCaption(); else - { szTitle += "notifier"; - } + pPaint->drawText(m_pWndBorder->titleRect(), Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, szTitle); delete pPaint; @@ -652,19 +599,14 @@ void NotifierWindow::mouseMoveEvent(QMouseEvent * e) { if(!m_bLeftButtonIsPressed) { - if(checkResizing(e->pos())) - goto sartelo; - - if(m_pWndBorder->captionRect().contains(e->pos())) + if(!checkResizing(e->pos()) && m_pWndBorder->captionRect().contains(e->pos())) { if(m_pWndBorder->closeRect().contains(e->pos())) m_pWndBorder->setCloseIcon(WDG_ICON_OVER); else m_pWndBorder->setCloseIcon(WDG_ICON_OUT); - goto sartelo; } - sartelo: update(); } @@ -922,7 +864,7 @@ void NotifierWindow::resize(QPoint, bool) setGeometry(m_wndRect); } -inline void NotifierWindow::setCursor(int iCur) +void NotifierWindow::setCursor(int iCur) { if(m_cursor.shape() != iCur) { @@ -1141,7 +1083,7 @@ void NotifierWindow::returnPressed() addMessage(pTab->wnd(), szTmp.ptr(), szHtml, 0); m_pLineEdit->setText(""); - KviUserInput::parse(szTxt, pTab->wnd(), QString(), 1); + KviUserInput::parse(szTxt, pTab->wnd(), QString(), true); } void NotifierWindow::progressUpdate() diff --git a/src/modules/notifier/NotifierWindow.h b/src/modules/notifier/NotifierWindow.h index c85c1d18e..20665b871 100644 --- a/src/modules/notifier/NotifierWindow.h +++ b/src/modules/notifier/NotifierWindow.h @@ -62,28 +62,28 @@ public: ~NotifierWindow(); protected: - QTimer * m_pShowHideTimer; - QTimer * m_pBlinkTimer; - QTimer * m_pAutoHideTimer; - State m_eState; - bool m_bBlinkOn; - double m_dOpacity; + QTimer * m_pShowHideTimer = nullptr; + QTimer * m_pBlinkTimer = nullptr; + QTimer * m_pAutoHideTimer = nullptr; + State m_eState = Hidden; + bool m_bBlinkOn = false; + double m_dOpacity = 0.0; - bool m_bCloseDown; - bool m_bPrevDown; - bool m_bNextDown; - bool m_bWriteDown; + bool m_bCloseDown = false; + bool m_bPrevDown = false; + bool m_bNextDown = false; + bool m_bWriteDown = false; bool m_bCrashShowWorkAround; QRect m_wndRect; - NotifierMessage * m_pCurrentMessage; - KviThemedLineEdit * m_pLineEdit; + NotifierMessage * m_pCurrentMessage = nullptr; + KviThemedLineEdit * m_pLineEdit = nullptr; - bool m_bDragging; - bool m_bLeftButtonIsPressed; - bool m_bDiagonalResizing; - bool m_bResizing; + bool m_bDragging = false; + bool m_bLeftButtonIsPressed = false; + bool m_bDiagonalResizing = false; + bool m_bResizing = false; int m_whereResizing; @@ -91,19 +91,19 @@ protected: QPoint m_pntPos; QPoint m_pntClick; int m_iBlinkCount; - QMenu * m_pContextPopup; - QMenu * m_pDisablePopup; - KviWindow * m_pWindowToRaise; - kvi_time_t m_tAutoHideAt; - kvi_time_t m_tStartedAt; + QMenu * m_pContextPopup = nullptr; + QMenu * m_pDisablePopup = nullptr; + KviWindow * m_pWindowToRaise = nullptr; + kvi_time_t m_tAutoHideAt = 0; + kvi_time_t m_tStartedAt = 0; QTime m_qtStartedAt; - bool m_bDisableHideOnMainWindowGotAttention; + bool m_bDisableHideOnMainWindowGotAttention = false; QCursor m_cursor; - QTabWidget * m_pWndTabs; - QProgressBar * m_pProgressBar; - NotifierWindowBorder * m_pWndBorder; + QTabWidget * m_pWndTabs = nullptr; + QProgressBar * m_pProgressBar = nullptr; + NotifierWindowBorder * m_pWndBorder = nullptr; public: void doShow(bool bDoAnimate); @@ -112,24 +112,24 @@ public: void addMessage(KviWindow * pWnd, const QString & szImageId, const QString & szText, unsigned int uMessageTime); void setDisableHideOnMainWindowGotAttention(bool b) { m_bDisableHideOnMainWindowGotAttention = b; }; void showLineEdit(bool bShow); - inline int countTabs() const + int countTabs() const { if(m_pWndTabs) return m_pWndTabs->count(); return 0; - }; - inline State state() const { return m_eState; }; + } + State state() const { return m_eState; } protected: - virtual void showEvent(QShowEvent * e); - virtual void hideEvent(QHideEvent * e); - virtual void paintEvent(QPaintEvent * e); - virtual void mousePressEvent(QMouseEvent * e); - virtual void mouseReleaseEvent(QMouseEvent * e); - virtual void mouseMoveEvent(QMouseEvent * e); - virtual void leaveEvent(QEvent * e); - virtual void enterEvent(QEvent * e); - virtual bool eventFilter(QObject * pEdit, QEvent * e); - virtual void keyPressEvent(QKeyEvent * e); + void showEvent(QShowEvent * e) override; + void hideEvent(QHideEvent * e) override; + void paintEvent(QPaintEvent * e) override; + void mousePressEvent(QMouseEvent * e) override; + void mouseReleaseEvent(QMouseEvent * e) override; + void mouseMoveEvent(QMouseEvent * e) override; + void leaveEvent(QEvent * e) override; + void enterEvent(QEvent * e) override; + bool eventFilter(QObject * pEdit, QEvent * e) override; + void keyPressEvent(QKeyEvent * e) override; public slots: void hideNow(); void toggleLineEdit(); diff --git a/src/modules/notifier/NotifierWindowBorder.h b/src/modules/notifier/NotifierWindowBorder.h index df07079d8..1c6a6ff90 100644 --- a/src/modules/notifier/NotifierWindowBorder.h +++ b/src/modules/notifier/NotifierWindowBorder.h @@ -26,9 +26,9 @@ #include "NotifierSettings.h" -#include <QSize> -#include <QRect> #include <QPixmap> +#include <QRect> +#include <QSize> class QPainter; @@ -38,9 +38,6 @@ public: NotifierWindowBorder(QSize = QSize(WDG_MIN_WIDTH, WDG_MIN_HEIGHT)); ~NotifierWindowBorder(); - // ================================ - // Put members declaration below... - // ================================ private: QRect m_rct; QPoint m_pnt; @@ -52,18 +49,18 @@ private: QRect m_titleRect; // Pictures - QPixmap * m_pixSX; - QPixmap * m_pixDX; - QPixmap * m_pixDWN; - QPixmap * m_pixDWNSX; - QPixmap * m_pixDWNDX; - QPixmap * m_pixCaptionSX; - QPixmap * m_pixCaptionDX; - QPixmap * m_pixCaptionBKG; - QPixmap * m_pixIconClose_out; - QPixmap * m_pixIconClose_over; - QPixmap * m_pixIconClose_clicked; - QPixmap * m_pixIconClose; + QPixmap * m_pixSX = nullptr; + QPixmap * m_pixDX = nullptr; + QPixmap * m_pixDWN = nullptr; + QPixmap * m_pixDWNSX = nullptr; + QPixmap * m_pixDWNDX = nullptr; + QPixmap * m_pixCaptionSX = nullptr; + QPixmap * m_pixCaptionDX = nullptr; + QPixmap * m_pixCaptionBKG = nullptr; + QPixmap * m_pixIconClose_out = nullptr; + QPixmap * m_pixIconClose_over = nullptr; + QPixmap * m_pixIconClose_clicked = nullptr; + QPixmap * m_pixIconClose = nullptr; QPixmap m_pixSX_N; QPixmap m_pixDX_N; @@ -105,23 +102,23 @@ public: { setWidth(w); setHeight(h); - }; + } void resize(QSize r) { setWidth(r.width()); setHeight(r.height()); - }; + } void setGeometry(QRect r) { r.topLeft(); - r.size(); /*qDebug("x,y: %d,%d", r.x(), r.y()); qDebug("w,h: %d,%d", r.width(), r.height());*/ - }; + r.size(); + } void setGeometry(QPoint p, QSize s) { setPoint(p.x(), p.y()); setWidth(s.width()); setHeight(s.height()); - }; + } void setPoint(int x, int y) { @@ -129,23 +126,23 @@ public: m_pnt.setY(y); m_rct.setX(x); m_rct.setY(y); - }; + } void setCloseIcon(int state); void resetIcons(); // writing methods... - inline int x() const { return m_pnt.x(); }; - inline int y() const { return m_pnt.y(); }; - inline int width() const { return m_rct.width(); }; - inline int height() const { return m_rct.height(); }; - inline int baseLine() const { return (y() + height()); }; + int x() const { return m_pnt.x(); } + int y() const { return m_pnt.y(); } + int width() const { return m_rct.width(); } + int height() const { return m_rct.height(); } + int baseLine() const { return (y() + height()); } - inline QRect bodyRect() const { return m_bodyRect; }; - inline QRect captionRect() const { return m_captionRect; }; - inline QRect rect() const { return m_rct; }; - inline QRect closeRect() const { return m_closeIconRect; }; - inline QRect titleRect() const { return m_titleRect; }; + QRect bodyRect() const { return m_bodyRect; } + QRect captionRect() const { return m_captionRect; } + QRect rect() const { return m_rct; } + QRect closeRect() const { return m_closeIconRect; } + QRect titleRect() const { return m_titleRect; } void draw(QPainter *, bool b = false); void setPics(bool b = false); diff --git a/src/modules/notifier/NotifierWindowTab.cpp b/src/modules/notifier/NotifierWindowTab.cpp index d02fd095d..0ec9f2a90 100644 --- a/src/modules/notifier/NotifierWindowTab.cpp +++ b/src/modules/notifier/NotifierWindowTab.cpp @@ -36,9 +36,9 @@ #include "KviPixmapUtils.h" #include "KviWindow.h" -#include <QScrollBar> -#include <QResizeEvent> #include <QPainter> +#include <QResizeEvent> +#include <QScrollBar> #include <QTabWidget> #include <QVBoxLayout> #include <QWidget> @@ -51,9 +51,8 @@ extern KVIRC_API QPixmap * g_pShadedChildGlobalDesktopBackground; extern NotifierWindow * g_pNotifierWindow; NotifierWindowTab::NotifierWindowTab(KviWindow * pWnd, QTabWidget * pParent) - : QScrollArea(pParent) + : QScrollArea(pParent), m_pWnd{pWnd}, m_pParent{pParent} { - m_pWnd = pWnd; if(m_pWnd) { m_szLabel = m_pWnd->windowName(); @@ -65,11 +64,8 @@ NotifierWindowTab::NotifierWindowTab(KviWindow * pWnd, QTabWidget * pParent) m_szLabel = "----"; } - if(pParent) - { - m_pParent = pParent; + if(m_pParent) m_pParent->addTab(this, m_szLabel); - } setFocusPolicy(Qt::NoFocus); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -170,24 +166,18 @@ void NotifierWindowTab::closeMe() { int iIdx = m_pParent->indexOf(this); if(iIdx != -1) - { g_pNotifierWindow->slotTabCloseRequested(iIdx); - } } } void NotifierWindowTab::resizeEvent(QResizeEvent *) { - if(m_pVBox) + int iWidth = viewport()->width(); + for(int i = 0; i < m_pVBox->count(); i++) { - int iWidth = viewport()->width(); - NotifierMessage * pMessage; - for(int i = 0; i < m_pVBox->count(); i++) - { - pMessage = (NotifierMessage *)m_pVBox->itemAt(i)->widget(); - if(pMessage) - pMessage->setFixedWidth(iWidth); - } + NotifierMessage * pMessage = (NotifierMessage *)m_pVBox->itemAt(i)->widget(); + if(pMessage) + pMessage->setFixedWidth(iWidth); } } diff --git a/src/modules/notifier/NotifierWindowTab.h b/src/modules/notifier/NotifierWindowTab.h index 784936aa6..550d3dd60 100644 --- a/src/modules/notifier/NotifierWindowTab.h +++ b/src/modules/notifier/NotifierWindowTab.h @@ -36,11 +36,11 @@ #include <QScrollArea> +class KviWindow; +class QPainter; +class QTabWidget; class QVBoxLayout; class QWidget; -class QTabWidget; -class QPainter; -class KviWindow; /** * \class NotifierWindowTab @@ -65,10 +65,10 @@ public: private: QString m_szLabel; - KviWindow * m_pWnd; - QTabWidget * m_pParent; - QVBoxLayout * m_pVBox; - QWidget * m_pVWidget; + KviWindow * m_pWnd = nullptr; + QTabWidget * m_pParent = nullptr; + QVBoxLayout * m_pVBox = nullptr; + QWidget * m_pVWidget = nullptr; public: /** @@ -88,17 +88,17 @@ public: * \brief Returns the name of the current window * \return QString */ - inline QString label() const { return m_szLabel; }; + QString label() const { return m_szLabel; } /** * \brief Returns the pointer of the current window * \return KviWindow * */ - inline KviWindow * wnd() const { return m_pWnd; }; + KviWindow * wnd() const { return m_pWnd; } protected: - virtual void mouseDoubleClickEvent(QMouseEvent * e); - virtual void resizeEvent(QResizeEvent * e); - virtual void paintEvent(QPaintEvent * e); + void mouseDoubleClickEvent(QMouseEvent * e) override; + void resizeEvent(QResizeEvent * e) override; + void paintEvent(QPaintEvent * e) override; private slots: /** * \brief Emitted when the scrollbar range is changed diff --git a/src/modules/notifier/libkvinotifier.cpp b/src/modules/notifier/libkvinotifier.cpp index fa21755df..47f814964 100644 --- a/src/modules/notifier/libkvinotifier.cpp +++ b/src/modules/notifier/libkvinotifier.cpp @@ -36,8 +36,6 @@ #include "KviTimeUtils.h" #include "KviOptions.h" -#include <QSplitter> - NotifierWindow * g_pNotifierWindow = nullptr; kvi_time_t g_tNotifierDisabledUntil = 0; @@ -255,10 +253,8 @@ static bool notifier_kvs_cmd_show(KviKvsModuleCommandCall * c) static bool notifier_kvs_fnc_isEnabled(KviKvsModuleFunctionCall * c) { - bool bCheck; - if(!KVI_OPTION_BOOL(KviOption_boolEnableNotifier)) - bCheck = false; - else + bool bCheck = false; + if(KVI_OPTION_BOOL(KviOption_boolEnableNotifier)) bCheck = g_tNotifierDisabledUntil < kvi_unixTime(); c->returnValue()->setBoolean(bCheck); return true; diff --git a/src/modules/objects/KvsObject_button.h b/src/modules/objects/KvsObject_button.h index 45e1e3408..cb8758d57 100644 --- a/src/modules/objects/KvsObject_button.h +++ b/src/modules/objects/KvsObject_button.h @@ -36,7 +36,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setText(KviKvsObjectFunctionCall * c); bool text(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_checkBox.h b/src/modules/objects/KvsObject_checkBox.h index 1db7575f8..68dca40ff 100644 --- a/src/modules/objects/KvsObject_checkBox.h +++ b/src/modules/objects/KvsObject_checkBox.h @@ -36,7 +36,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setChecked(KviKvsObjectFunctionCall * c); bool isChecked(KviKvsObjectFunctionCall * c); bool toggleEvent(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_colorDialog.h b/src/modules/objects/KvsObject_colorDialog.h index 35321731c..a6d37121f 100644 --- a/src/modules/objects/KvsObject_colorDialog.h +++ b/src/modules/objects/KvsObject_colorDialog.h @@ -36,7 +36,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); } protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setCurrentColor(KviKvsObjectFunctionCall * c); bool currentColorChangedEvent(KviKvsObjectFunctionCall * c); bool colorSelectedEvent(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_comboBox.cpp b/src/modules/objects/KvsObject_comboBox.cpp index 331f3fe5a..e4ec1924c 100644 --- a/src/modules/objects/KvsObject_comboBox.cpp +++ b/src/modules/objects/KvsObject_comboBox.cpp @@ -306,8 +306,6 @@ KVSO_CLASS_FUNCTION(comboBox, setCurrentItem) } KVSO_CLASS_FUNCTION(comboBox, popup) { - Q_UNUSED(c); - if(widget()) ((QComboBox *)widget())->showPopup(); return true; diff --git a/src/modules/objects/KvsObject_comboBox.h b/src/modules/objects/KvsObject_comboBox.h index 2d14c01f9..dc0376229 100644 --- a/src/modules/objects/KvsObject_comboBox.h +++ b/src/modules/objects/KvsObject_comboBox.h @@ -37,7 +37,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool insertItem(KviKvsObjectFunctionCall * c); bool changeItem(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_dateTimeEdit.h b/src/modules/objects/KvsObject_dateTimeEdit.h index f10340900..400c32f8a 100644 --- a/src/modules/objects/KvsObject_dateTimeEdit.h +++ b/src/modules/objects/KvsObject_dateTimeEdit.h @@ -39,7 +39,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool date(KviKvsObjectFunctionCall * c); bool setDate(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_dialog.h b/src/modules/objects/KvsObject_dialog.h index 14c2b668c..9975d944b 100644 --- a/src/modules/objects/KvsObject_dialog.h +++ b/src/modules/objects/KvsObject_dialog.h @@ -35,7 +35,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setModal(KviKvsObjectFunctionCall * c); }; diff --git a/src/modules/objects/KvsObject_dockWindow.h b/src/modules/objects/KvsObject_dockWindow.h index dab239f54..0fe56de9c 100644 --- a/src/modules/objects/KvsObject_dockWindow.h +++ b/src/modules/objects/KvsObject_dockWindow.h @@ -34,7 +34,7 @@ class KvsObject_dockWindow : public KvsObject_widget public: KVSO_DECLARE_OBJECT(KvsObject_dockWindow) protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool addWidget(KviKvsObjectFunctionCall * c); bool setAllowedDockAreas(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_file.cpp b/src/modules/objects/KvsObject_file.cpp index d0f773b85..2b2e10746 100644 --- a/src/modules/objects/KvsObject_file.cpp +++ b/src/modules/objects/KvsObject_file.cpp @@ -93,12 +93,12 @@ const QIODevice::OpenMode mod_cod[] = { Attempts to open the file in specified mode or modes [i]sum[/i]. Valid modes are:[br] [pre] - RAW - RAW, non-buffered access[br] - ReadOnly - opens the file read-only[br] - WriteOnly - opens the file write-only[br] - ReadWrite - opens the file in read-write mode[br] - Append - opens the file in append mode. The file index is set to the end of the file.[br] - Truncate - truncates the file[br] + RAW - RAW, non-buffered access + ReadOnly - opens the file read-only + WriteOnly - opens the file write-only + ReadWrite - opens the file in read-write mode + Append - opens the file in append mode. The file index is set to the end of the file. + Truncate - truncates the file [/pre] If you call this function without any parameters, the file is opened in read-only mode.[br] @@ -335,8 +335,8 @@ KVSO_CLASS_FUNCTION(file, putch) KVSO_PARAMETERS_END(c) if(szChar.length() > 1) c->warning(__tr2qs_ctx("Argument too long, using only first char", "objects")); - const char * ch = szChar.toUtf8().data(); - if(!m_pFile->putChar(ch[0])) + QByteArray szCh = szChar.toUtf8(); + if(!m_pFile->putChar(szCh[0])) c->warning(__tr2qs_ctx("Write error occurred!", "objects")); return true; } @@ -375,8 +375,8 @@ KVSO_CLASS_FUNCTION(file, unGetch) KVSO_PARAMETERS_END(c) if(szChar.length() > 1) c->warning(__tr2qs_ctx("Argument too long, using only the first char", "objects")); - const char * ch = szChar.toUtf8().data(); - m_pFile->ungetChar(ch[0]); + QByteArray szCh = szChar.toUtf8(); + m_pFile->ungetChar(szCh[0]); return true; } @@ -554,8 +554,8 @@ KVSO_CLASS_FUNCTION(file, writeBlock) } QString szBlock; pVariantData->asString(szBlock); - const char * block = szBlock.toUtf8().data(); - int rlen = m_pFile->write(block, uLen); + QByteArray block = szBlock.toUtf8(); + int rlen = m_pFile->write(block.data(), uLen); c->returnValue()->setInteger(rlen); } } diff --git a/src/modules/objects/KvsObject_groupBox.h b/src/modules/objects/KvsObject_groupBox.h index 50cf5a78e..f2506d6fa 100644 --- a/src/modules/objects/KvsObject_groupBox.h +++ b/src/modules/objects/KvsObject_groupBox.h @@ -36,7 +36,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setTitle(KviKvsObjectFunctionCall * c); bool title(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_hBox.h b/src/modules/objects/KvsObject_hBox.h index ef2ce93ca..e94717587 100644 --- a/src/modules/objects/KvsObject_hBox.h +++ b/src/modules/objects/KvsObject_hBox.h @@ -34,7 +34,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setMargin(KviKvsObjectFunctionCall * c); bool setSpacing(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_label.cpp b/src/modules/objects/KvsObject_label.cpp index 6d9ebf848..da4744cbd 100644 --- a/src/modules/objects/KvsObject_label.cpp +++ b/src/modules/objects/KvsObject_label.cpp @@ -120,21 +120,21 @@ const int frame_cod[] = { Returns a string containing alignment flags that are set for this label. The flags are separated by commas.[br] An example output could look like this:[br] - [pre]Bottom, Right[/pre][br] + [pre]Bottom, Right[/pre] See [classfnc]$setAlignment[/classfnc]() for explanation of all alignment flags. !fn: $setAlignment(<flag1:string>, <flag2:string>, ...) This function sets alignment flags, given as parameters, for this label. Valid flags are: [pre] - Right - Text is aligned to right border[br] - Left - Text is aligned to left border[br] - Top - Text is aligned to the top border[br] - Bottom - Text is aligned to the bottom border[br] - HCenter - Text is horizontally centered[br] - VCenter - Text is vertically centered[br] - Center - Equals HCenter + VCenter[br] - Justify - Text is spaced apart to cover available room[br] + Right - Text is aligned to right border + Left - Text is aligned to left border + Top - Text is aligned to the top border + Bottom - Text is aligned to the bottom border + HCenter - Text is horizontally centered + VCenter - Text is vertically centered + Center - Equals HCenter + VCenter + Justify - Text is spaced apart to cover available room [/pre] It is obvious that you can not set [i]Right[/i] and [i]Left[/i] simultaneously - this will [b]not[/b] @@ -153,17 +153,17 @@ const int frame_cod[] = { The flags determine the shape or shadow of the label's frame. Valid shape flags are:[br] [pre] - NoFrame - Draw no frame. You shouldn't specify a shadow when using this.[br] - Box - Draws a rectangular box. Its borders can be [i]Raised[/i] or [i]Sunken[/i][br] - Panel - Draws a rectangular panel which can be [i]Raised[/i] or [i]Sunken[/i][br] - WinPanel - Similar to [i]Panel[/i], but is more in Win95 style[br] + NoFrame - Draw no frame. You shouldn't specify a shadow when using this. + Box - Draws a rectangular box. Its borders can be [i]Raised[/i] or [i]Sunken[/i] + Panel - Draws a rectangular panel which can be [i]Raised[/i] or [i]Sunken[/i] + WinPanel - Similar to [i]Panel[/i], but is more in Win95 style Hline - Draws a horizontal line that frames nothing (useful as separator) [/pre] Valid shadow flags are:[br] [pre] - Plain - No 3D effect (draws using foreground color)[br] - Raised - Makes the label look like it was raised above the parent widget[br] - Sunken - Makes the label look like it was [i]pushed[/i] inside the parent widget[br] + Plain - No 3D effect (draws using foreground color) + Raised - Makes the label look like it was raised above the parent widget + Sunken - Makes the label look like it was [i]pushed[/i] inside the parent widget [/pre] !fn: $setImage(<image_id>) Sets the image to be displayed on this label. diff --git a/src/modules/objects/KvsObject_label.h b/src/modules/objects/KvsObject_label.h index 1382c60f6..de6728ab2 100644 --- a/src/modules/objects/KvsObject_label.h +++ b/src/modules/objects/KvsObject_label.h @@ -35,7 +35,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setTitle(KviKvsObjectFunctionCall * c); bool setText(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_layout.cpp b/src/modules/objects/KvsObject_layout.cpp index 2c57a60fd..b48e5b2e7 100644 --- a/src/modules/objects/KvsObject_layout.cpp +++ b/src/modules/objects/KvsObject_layout.cpp @@ -98,10 +98,10 @@ const int align_cod[] = { Sets the resize mode of the parent widget in relation to this layout. <mode> can be one of:[br] [pre] - -Auto: this is the default[br] - -Fixed: the parent widget of this layout is resized to the "sizeHint" value and it cannot be resized by the user.[br] - -Minimum: the minimum size of the parent widget of this layout is set to minimumSize() and it cannot be smaller[br] - -FreeResize: the parent widget of this layout is not constrained at all[br] + -Auto: this is the default + -Fixed: the parent widget of this layout is resized to the "sizeHint" value and it cannot be resized by the user. + -Minimum: the minimum size of the parent widget of this layout is set to minimumSize() and it cannot be smaller + -FreeResize: the parent widget of this layout is not constrained at all [/pre] */ diff --git a/src/modules/objects/KvsObject_layout.h b/src/modules/objects/KvsObject_layout.h index 99b0c1238..c41a01e66 100644 --- a/src/modules/objects/KvsObject_layout.h +++ b/src/modules/objects/KvsObject_layout.h @@ -33,7 +33,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool addWidget(KviKvsObjectFunctionCall * c); bool addMultiCellWidget(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_lcd.h b/src/modules/objects/KvsObject_lcd.h index 3595aa164..f1a923906 100644 --- a/src/modules/objects/KvsObject_lcd.h +++ b/src/modules/objects/KvsObject_lcd.h @@ -34,7 +34,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool displayStr(KviKvsObjectFunctionCall * c); bool setMode(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_lineEdit.cpp b/src/modules/objects/KvsObject_lineEdit.cpp index 8af1498ce..daeea0142 100644 --- a/src/modules/objects/KvsObject_lineEdit.cpp +++ b/src/modules/objects/KvsObject_lineEdit.cpp @@ -72,9 +72,9 @@ static const int mode_cod[] = { !fn: $setEchoMode(<echo_mode:string>) Sets the line edit's echo mode. Possible value are:[br] [pre] - -Normal: display chars as they entered[br] - -Noecho: do not display anything[br] - -Password: display asterisks instead of the characters actually entered[br] + -Normal: display chars as they entered + -Noecho: do not display anything + -Password: display asterisks instead of the characters actually entered [/pre] See also [classfnc]$echoMode[/classfnc](). !fn: <string> $echoMode() diff --git a/src/modules/objects/KvsObject_lineEdit.h b/src/modules/objects/KvsObject_lineEdit.h index a004190a2..92e1d8754 100644 --- a/src/modules/objects/KvsObject_lineEdit.h +++ b/src/modules/objects/KvsObject_lineEdit.h @@ -42,7 +42,7 @@ protected: QCompleter * m_pCompleter; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setCompleter(KviKvsObjectFunctionCall * c); bool enableCompleter(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_list.cpp b/src/modules/objects/KvsObject_list.cpp index 25ccf5dfc..83bc9ca5c 100644 --- a/src/modules/objects/KvsObject_list.cpp +++ b/src/modules/objects/KvsObject_list.cpp @@ -26,7 +26,7 @@ #include "KviMemory.h" #include "KviLocale.h" #include "KvsObject_list.h" -#include <stdlib.h> +#include <cstdlib> /* @doc: list @@ -48,6 +48,23 @@ [classfnc:list]$moveNext[/classfnc](),[classfnc:list]$movePrev[/classfnc](), [classfnc:list]$current[/classfnc]() and [classfnc:list]$eof[/classfnc]() functions. @functions: + !fn: $sort(<bReverse:bool>) + Sorts items in the list alphabetically ($true) or in reverse order ($false); Default to $false. + [example] + %list=$new(list);[br] + %list->$append('Foo');[br] + %list->$append('Bar');[br] + %list->$append('Dummy');[br] + %list->$append('Aria');[br] + [br] + %list->$sort(true);[br] + %list->$moveFirst();[br] + while(%list->$eof())[br] + {[br] + echo %list->$current();[br] + %list->$moveNext();[br] + }[br] + [/example] !fn: <integer> $count() Returns the number of items in the list !fn: <boolean> $isEmpty() @@ -168,7 +185,7 @@ KVSO_CLASS_FUNCTION(list, current) KVSO_CLASS_FUNCTION(list, eof) { CHECK_INTERNAL_POINTER(m_pDataList) - c->returnValue()->setBoolean(m_pDataList->current() != nullptr); + c->returnValue()->setBoolean(m_pDataList->safeCurrent() != nullptr); return true; } @@ -299,7 +316,7 @@ KVSO_CLASS_FUNCTION(list, clear) return true; } -inline int kvi_compare(const KviKvsVariant * p1, const KviKvsVariant * p2) +int kvi_compare(const KviKvsVariant * p1, const KviKvsVariant * p2) { return p1->compare(p2); } @@ -307,7 +324,13 @@ inline int kvi_compare(const KviKvsVariant * p1, const KviKvsVariant * p2) KVSO_CLASS_FUNCTION(list, sort) { CHECK_INTERNAL_POINTER(m_pDataList) + bool bReverse; + KVSO_PARAMETERS_BEGIN(c) + KVSO_PARAMETER("bReverse", KVS_PT_BOOL, KVS_PF_OPTIONAL, bReverse) + KVSO_PARAMETERS_END(c) m_pDataList->sort(); + if(bReverse) + m_pDataList->invert(); return true; } diff --git a/src/modules/objects/KvsObject_listWidget.cpp b/src/modules/objects/KvsObject_listWidget.cpp index df2db43a1..e7a634f57 100644 --- a/src/modules/objects/KvsObject_listWidget.cpp +++ b/src/modules/objects/KvsObject_listWidget.cpp @@ -288,7 +288,7 @@ KVSO_CLASS_FUNCTION(listWidget, isChecked) QListWidgetItem * pItem = ((QListWidget *)widget())->item(iIdx); if(!pItem) return true; - c->returnValue()->setBoolean(pItem->checkState() == Qt::Checked ? 1 : 0); + c->returnValue()->setBoolean(pItem->checkState() == Qt::Checked ? true : false); return true; } diff --git a/src/modules/objects/KvsObject_listWidget.h b/src/modules/objects/KvsObject_listWidget.h index c1eb80fcb..90a6b14c4 100644 --- a/src/modules/objects/KvsObject_listWidget.h +++ b/src/modules/objects/KvsObject_listWidget.h @@ -36,7 +36,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool insertItem(KviKvsObjectFunctionCall * c); bool changeItem(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_mainWindow.h b/src/modules/objects/KvsObject_mainWindow.h index 88eb727bd..01e1f0859 100644 --- a/src/modules/objects/KvsObject_mainWindow.h +++ b/src/modules/objects/KvsObject_mainWindow.h @@ -35,7 +35,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setCentralWidget(KviKvsObjectFunctionCall * c); }; diff --git a/src/modules/objects/KvsObject_menuBar.h b/src/modules/objects/KvsObject_menuBar.h index f0bcd5c14..a1e8a5478 100644 --- a/src/modules/objects/KvsObject_menuBar.h +++ b/src/modules/objects/KvsObject_menuBar.h @@ -35,7 +35,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool insertItem(KviKvsObjectFunctionCall * c); }; diff --git a/src/modules/objects/KvsObject_multiLineEdit.h b/src/modules/objects/KvsObject_multiLineEdit.h index a17bbb39b..576715d59 100644 --- a/src/modules/objects/KvsObject_multiLineEdit.h +++ b/src/modules/objects/KvsObject_multiLineEdit.h @@ -36,7 +36,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool functionTextLine(KviKvsObjectFunctionCall * c); bool functionInsertLine(KviKvsObjectFunctionCall * c); bool functionRemoveLine(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_painter.cpp b/src/modules/objects/KvsObject_painter.cpp index 2c447d368..4918253d3 100644 --- a/src/modules/objects/KvsObject_painter.cpp +++ b/src/modules/objects/KvsObject_painter.cpp @@ -235,10 +235,10 @@ const char * const brushstyles_tbl[] = { All parameters are in integer form. The HSV system, like RGB, has three components:[br] [pre] - * H, for hue, is either 0-359 if the color is chromatic (not gray), or meaningless if it is gray.[br] - It represents degrees on the color wheel familiar to most people. Red is 0 (degrees), green is 120 and blue is 240.[br] - * S, for saturation, is 0-255, and the bigger it is, the stronger the color is. Grayish colors have saturation near 0; very strong colors have saturation near 255.[br] - * V, for value, is 0-255 and represents lightness or brightness of the color. 0 is black; 255 is as far from black as possible.[br] + * H, for hue, is either 0-359 if the color is chromatic (not gray), or meaningless if it is gray. + It represents degrees on the color wheel familiar to most people. Red is 0 (degrees), green is 120 and blue is 240. + * S, for saturation, is 0-255, and the bigger it is, the stronger the color is. Grayish colors have saturation near 0; very strong colors have saturation near 255. + * V, for value, is 0-255 and represents lightness or brightness of the color. 0 is black; 255 is as far from black as possible. [/pre] Examples: [b]Red[/b] is H=0, S=255, V=255.[br] Light red could have H about 0, S about 50-100, and S=255. @@ -284,17 +284,17 @@ const char * const brushstyles_tbl[] = { Draws the given <text> within the rectangle specified by <x>,<y> <width> and <height>.[br] The <flag> parameters may be:[br] [pre] - Left[br] - Top[br] - Right[br] - Bottom[br] - HCenter[br] - VCenter[br] - Center[br] - TextSingleLine[br] - TextExpandTabs[br] - TextShowMnemonic[br] - TextWordWrap[br] + Left + Top + Right + Bottom + HCenter + VCenter + Center + TextSingleLine + TextExpandTabs + TextShowMnemonic + TextWordWrap TextIncludeTrailingSpaces [/pre] !fn: $drawPixmap(<x:integer>,<y:integer>,<pixmap:hobject>,<sx:integer>,<sy:integer>,<ex:integer>,<ey:integer>) @@ -302,12 +302,12 @@ const char * const brushstyles_tbl[] = { !fn: $setFont(<family:string>,<size:integer>[,<style:enum>,<style:enum>,..])[br] Set the font's family, size and style, valid flag for style are:[br] [pre] - italic[br] - bold [br] - underline [br] - overline [br] - strikeout [br] - fixedpitch [br] + italic + bold + underline + overline + strikeout + fixedpitch [/pre] !fn: $setFontSize(<size:unsigned integer>)[br] Set the current painter font's size.[br] @@ -333,7 +333,7 @@ const char * const brushstyles_tbl[] = { Sets the background mode of the painter to <bgMode>: Valid values are:[br] [pre] - - Transparent (that is the default value);[br] + - Transparent (that is the default value); - Opaque. [/pre] !fn: $setOpacity(<opacity_factor:real>) @@ -418,7 +418,7 @@ const char * const brushstyles_tbl[] = { if ($$->%scrollright >= 550) return %P->$scale(0.$$->%Zoomindex,0.$$->%Zoomindex) %P->$translate(400,350) - %P->$drawText($$->%scrollright,10,"Another cool class brought to you by...",-1,Auto) + %P->$drawText($$->%scrollright,10,"Another cool class brought to you by...",-1,Auto) $$->%scrollright += 3; %P->$reset() } @@ -1271,8 +1271,6 @@ void KvsObject_painter::detachDevice() KVSO_CLASS_FUNCTION(painter, end) { - Q_UNUSED(c); - if(!m_pDeviceObject) { m_pPainter->end(); @@ -1958,7 +1956,6 @@ KVSO_CLASS_FUNCTION(painter, setGradientAsBrush) KVSO_CLASS_FUNCTION(painter, clearGradient) { - Q_UNUSED(c); if(!m_pGradient) delete m_pGradient; m_pGradient = nullptr; @@ -2113,7 +2110,7 @@ KVSO_CLASS_FUNCTION(painter, drawPath) CHECK_INTERNAL_POINTER(m_pPainter) m_pPainter->drawPath(*m_pPainterPath); //delete m_pPainterPath; - //m_pPainterPath=0; + //m_pPainterPath=nullptr; return true; } @@ -2144,7 +2141,6 @@ KVSO_CLASS_FUNCTION(painter, setCompositionMode) } KVSO_CLASS_FUNCTION(painter, resetPath) { - Q_UNUSED(c); if(m_pPainterPath) { delete m_pPainterPath; diff --git a/src/modules/objects/KvsObject_pixmap.cpp b/src/modules/objects/KvsObject_pixmap.cpp index c2b56476d..e3ef0a5c8 100644 --- a/src/modules/objects/KvsObject_pixmap.cpp +++ b/src/modules/objects/KvsObject_pixmap.cpp @@ -533,7 +533,6 @@ KVSO_CLASS_FUNCTION(pixmap, loadAnimation) KVSO_CLASS_FUNCTION(pixmap, startAnimation) { - Q_UNUSED(c); if(m_pAnimatedPixmap) m_pAnimatedPixmap->start(); return true; @@ -541,7 +540,6 @@ KVSO_CLASS_FUNCTION(pixmap, startAnimation) KVSO_CLASS_FUNCTION(pixmap, stopAnimation) { - Q_UNUSED(c); if(m_pAnimatedPixmap) m_pAnimatedPixmap->stop(); return true; diff --git a/src/modules/objects/KvsObject_pixmap.h b/src/modules/objects/KvsObject_pixmap.h index 35874f1f6..63b4de5c4 100644 --- a/src/modules/objects/KvsObject_pixmap.h +++ b/src/modules/objects/KvsObject_pixmap.h @@ -58,7 +58,7 @@ public: { *m_pImage = m_pPixmap->toImage(); delete m_pPixmap; - m_pPixmap = 0; + m_pPixmap = nullptr; } } m_currentType = Image; @@ -75,7 +75,7 @@ public: { *m_pPixmap = m_pPixmap->fromImage(*m_pImage); delete m_pImage; - m_pImage = 0; + m_pImage = nullptr; } } m_currentType = Pixmap; diff --git a/src/modules/objects/KvsObject_popupMenu.h b/src/modules/objects/KvsObject_popupMenu.h index 67624bf72..ac52f7744 100644 --- a/src/modules/objects/KvsObject_popupMenu.h +++ b/src/modules/objects/KvsObject_popupMenu.h @@ -38,7 +38,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool insertItem(KviKvsObjectFunctionCall * c); bool setTitle(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_progressBar.h b/src/modules/objects/KvsObject_progressBar.h index 4a957ae20..284753c45 100644 --- a/src/modules/objects/KvsObject_progressBar.h +++ b/src/modules/objects/KvsObject_progressBar.h @@ -35,7 +35,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setProgress(KviKvsObjectFunctionCall * c); bool setTotalSteps(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_radioButton.h b/src/modules/objects/KvsObject_radioButton.h index b57cd3801..81af5d1c9 100644 --- a/src/modules/objects/KvsObject_radioButton.h +++ b/src/modules/objects/KvsObject_radioButton.h @@ -36,7 +36,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setText(KviKvsObjectFunctionCall * c); bool isChecked(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_slider.cpp b/src/modules/objects/KvsObject_slider.cpp index 73b71937e..b36350810 100644 --- a/src/modules/objects/KvsObject_slider.cpp +++ b/src/modules/objects/KvsObject_slider.cpp @@ -67,11 +67,11 @@ Sets the tickmark settings for this slider.[br] Values are:[br] [pre] - NoMarks - do not draw any tickmarks.[br] - Both - draw tickmarks on both sides of the groove.[br] - Above - draw tickmarks above the (horizontal) slider[br] - Below - draw tickmarks below the (horizontal) slider[br] - Left - draw tickmarks to the left of the (vertical) slider[br] + NoMarks - do not draw any tickmarks. + Both - draw tickmarks on both sides of the groove. + Above - draw tickmarks above the (horizontal) slider + Below - draw tickmarks below the (horizontal) slider + Left - draw tickmarks to the left of the (vertical) slider Right - draw tickmarks to the right of the (vertical) slider [/pre] !fn: $setTickInterval(<value>) diff --git a/src/modules/objects/KvsObject_slider.h b/src/modules/objects/KvsObject_slider.h index 953add8a9..5ce6ae201 100644 --- a/src/modules/objects/KvsObject_slider.h +++ b/src/modules/objects/KvsObject_slider.h @@ -36,7 +36,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setTracking(KviKvsObjectFunctionCall * c); bool setValue(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_socket.cpp b/src/modules/objects/KvsObject_socket.cpp index 92f2e3db9..b1e492c7e 100644 --- a/src/modules/objects/KvsObject_socket.cpp +++ b/src/modules/objects/KvsObject_socket.cpp @@ -101,10 +101,10 @@ const char * const sockerrors_tbl[] = { [pre] 0 = Unconnected 1 = HostLookUp - 2 = Connecting[br] - 3 = Connected[br] - 4 = Bound[br] - 5 = Closing[br] + 2 = Connecting + 3 = Connected + 4 = Bound + 5 = Closing 6 = Listening [/pre] !fn: $connect(<host>,<port>) @@ -325,7 +325,6 @@ KVSO_CLASS_FUNCTION(socket, status) KVSO_CLASS_FUNCTION(socket, close) { - Q_UNUSED(c); m_pSocket->disconnectFromHost(); return true; } @@ -408,7 +407,7 @@ KVSO_CLASS_FUNCTION(socket, read) // convert NULLS to char 255 char * buffer = (char *)KviMemory::allocate(iLen); m_pSocket->read(buffer, iLen); - for(size_t i{}; i < iLen; i++) + for(int i{}; i < iLen; i++) { if(!buffer[i]) buffer[i] = (char)(255); diff --git a/src/modules/objects/KvsObject_socket.h b/src/modules/objects/KvsObject_socket.h index 2bb623be9..09c8159eb 100644 --- a/src/modules/objects/KvsObject_socket.h +++ b/src/modules/objects/KvsObject_socket.h @@ -35,13 +35,13 @@ class KvsObject_socket : public KviKvsObject public: KVSO_DECLARE_OBJECT(KvsObject_socket) protected: - QAbstractSocket * m_pSocket; - QTcpServer * m_pServer; - KviKvsRunTimeContext * m_pContext; - bool bIsSetFromExternal; + QAbstractSocket * m_pSocket = nullptr; + QTcpServer * m_pServer = nullptr; + KviKvsRunTimeContext * m_pContext = nullptr; + bool bIsSetFromExternal = false; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; const char * getStateString(QAbstractSocket::SocketState); void setInternalSocket(QAbstractSocket * pSocket) diff --git a/src/modules/objects/KvsObject_spinBox.h b/src/modules/objects/KvsObject_spinBox.h index f0eb2313d..76f25d9e2 100644 --- a/src/modules/objects/KvsObject_spinBox.h +++ b/src/modules/objects/KvsObject_spinBox.h @@ -36,7 +36,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setTracking(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_sql.cpp b/src/modules/objects/KvsObject_sql.cpp index 7fd68c240..a4c036546 100644 --- a/src/modules/objects/KvsObject_sql.cpp +++ b/src/modules/objects/KvsObject_sql.cpp @@ -27,7 +27,7 @@ #include "KviLocale.h" #include "KvsObject_sql.h" #include "KvsObject_memoryBuffer.h" -#include <stdlib.h> +#include <cstdlib> #include <QHash> #include <QSqlDriver> #include <QSqlError> @@ -482,8 +482,7 @@ KVSO_CLASS_FUNCTION(sql, queryRecord) else pValue = new KviKvsVariant(QString()); pHash->set(record.fieldName(i), pValue); - KviKvsVariant * value2 = pHash->get(record.fieldName(i)); - value2->type(); + (void)pHash->get(record.fieldName(i)); } c->returnValue()->setHash(pHash); return true; diff --git a/src/modules/objects/KvsObject_tabWidget.h b/src/modules/objects/KvsObject_tabWidget.h index 9b0b14d1c..5db1f58b3 100644 --- a/src/modules/objects/KvsObject_tabWidget.h +++ b/src/modules/objects/KvsObject_tabWidget.h @@ -36,7 +36,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; QList<kvs_hobject_t> tabsList; bool addTab(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_tableWidget.cpp b/src/modules/objects/KvsObject_tableWidget.cpp index 17c12fd66..d2d7bee17 100644 --- a/src/modules/objects/KvsObject_tableWidget.cpp +++ b/src/modules/objects/KvsObject_tableWidget.cpp @@ -737,28 +737,24 @@ KVSO_CLASS_FUNCTION(tableWidget, setCellWidget) KVSO_CLASS_FUNCTION(tableWidget, hideHorizontalHeader) { - Q_UNUSED(c); ((QTableWidget *)widget())->horizontalHeader()->hide(); return true; } KVSO_CLASS_FUNCTION(tableWidget, hideVerticalHeader) { - Q_UNUSED(c); ((QTableWidget *)widget())->verticalHeader()->hide(); return true; } KVSO_CLASS_FUNCTION(tableWidget, showHorizontalHeader) { - Q_UNUSED(c); ((QTableWidget *)widget())->horizontalHeader()->show(); return true; } KVSO_CLASS_FUNCTION(tableWidget, showVerticalHeader) { - Q_UNUSED(c); ((QTableWidget *)widget())->verticalHeader()->show(); return true; } diff --git a/src/modules/objects/KvsObject_tableWidget.h b/src/modules/objects/KvsObject_tableWidget.h index b25613c36..416e78f9b 100644 --- a/src/modules/objects/KvsObject_tableWidget.h +++ b/src/modules/objects/KvsObject_tableWidget.h @@ -39,15 +39,15 @@ class KvsObject_tableWidget; class KviCellItemDelegate : public QItemDelegate { public: - KviCellItemDelegate(QAbstractItemView * pWidget = 0, KvsObject_tableWidget * pParent = 0); + KviCellItemDelegate(QAbstractItemView * pWidget = nullptr, KvsObject_tableWidget * pParent = nullptr); ~KviCellItemDelegate(); protected: KvsObject_tableWidget * m_pParentScript; public: - QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const; - void paint(QPainter * pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const; + QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const override; + void paint(QPainter * pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; }; class KvsObject_tableWidget : public KvsObject_widget @@ -60,11 +60,11 @@ public: bool paint(QPainter * pPainter, const QStyleOptionViewItem & option, const QModelIndex & index); protected: - KviKvsRunTimeContext * m_pContext; - KviCellItemDelegate * m_pCellItemDelegate; + KviKvsRunTimeContext * m_pContext = nullptr; + KviCellItemDelegate * m_pCellItemDelegate = nullptr; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setText(KviKvsObjectFunctionCall * c); bool setForeground(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_textBrowser.h b/src/modules/objects/KvsObject_textBrowser.h index a4fc36041..eda1d4ea6 100644 --- a/src/modules/objects/KvsObject_textBrowser.h +++ b/src/modules/objects/KvsObject_textBrowser.h @@ -38,7 +38,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setSource(KviKvsObjectFunctionCall * c); bool forward(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_toolBar.h b/src/modules/objects/KvsObject_toolBar.h index ce6fa0620..7eaa60bae 100644 --- a/src/modules/objects/KvsObject_toolBar.h +++ b/src/modules/objects/KvsObject_toolBar.h @@ -35,7 +35,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool addSeparator(KviKvsObjectFunctionCall * c); bool setLabel(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_toolButton.h b/src/modules/objects/KvsObject_toolButton.h index f9dcbb7d7..7cb4e43b4 100644 --- a/src/modules/objects/KvsObject_toolButton.h +++ b/src/modules/objects/KvsObject_toolButton.h @@ -36,7 +36,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setImage(KviKvsObjectFunctionCall * c); bool setUsesBigPixmap(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_trayIcon.cpp b/src/modules/objects/KvsObject_trayIcon.cpp index 127be0065..d09523888 100644 --- a/src/modules/objects/KvsObject_trayIcon.cpp +++ b/src/modules/objects/KvsObject_trayIcon.cpp @@ -62,10 +62,10 @@ Message can be clicked by the user; the messageClickedEvent() will be triggered when this occurs.[br] Valid values for message_icon are: [pre] - - NoIcon : No icon is shown.[br] - - Information : An information icon is shown.[br] - - Warning : A standard warning icon is shown.[br] - - Critical : A critical warning icon is shown.[br] + - NoIcon : No icon is shown. + - Information : An information icon is shown. + - Warning : A standard warning icon is shown. + - Critical : A critical warning icon is shown. [/pre] !fn: setContextMenu(<popupmenu:hobject>). Associates the given <popupmenu> with the tray icon. @@ -74,11 +74,11 @@ If you reimplement this function the reason parameter will be passed as $0. Values for reason are:[br] [pre] - - Unknown : Unknown reason.[br] - - Context : The context menu for the tray icon was requested.[br] - - DoubleClick : The tray icon was double clicked.[br] - - Trigger : The tray icon was clicked.[br] - - MiddleClick : The tray icon was clicked with the middle mouse button.[br] + - Unknown : Unknown reason. + - Context : The context menu for the tray icon was requested. + - DoubleClick : The tray icon was double clicked. + - Trigger : The tray icon was clicked. + - MiddleClick : The tray icon was clicked with the middle mouse button. [/pre] The default implementation emits the [classfnc]$activated[/classfnc]() signal. !fn: messageClickedEvent() diff --git a/src/modules/objects/KvsObject_treeWidget.cpp b/src/modules/objects/KvsObject_treeWidget.cpp index afaf389ca..15b8e1a47 100644 --- a/src/modules/objects/KvsObject_treeWidget.cpp +++ b/src/modules/objects/KvsObject_treeWidget.cpp @@ -318,7 +318,6 @@ KVSO_CLASS_FUNCTION(treeWidget, setAcceptDrops) KVSO_CLASS_FUNCTION(treeWidget, clear) { - Q_UNUSED(c); if(widget()) ((QTreeWidget *)object())->clear(); return true; @@ -443,14 +442,12 @@ KVSO_CLASS_FUNCTION(treeWidget, setAllColumnsShowFocus) KVSO_CLASS_FUNCTION(treeWidget, hideListViewHeader) { - Q_UNUSED(c); ((QTreeWidget *)widget())->header()->hide(); return true; } KVSO_CLASS_FUNCTION(treeWidget, showListViewHeader) { - Q_UNUSED(c); ((QTreeWidget *)widget())->header()->show(); return true; } diff --git a/src/modules/objects/KvsObject_treeWidget.h b/src/modules/objects/KvsObject_treeWidget.h index db277c107..bfa64c589 100644 --- a/src/modules/objects/KvsObject_treeWidget.h +++ b/src/modules/objects/KvsObject_treeWidget.h @@ -42,7 +42,7 @@ public: void fileDropped(QString &, QTreeWidgetItem *); protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setBackgroundImage(KviKvsObjectFunctionCall * c); bool addColumn(KviKvsObjectFunctionCall * c); @@ -90,15 +90,15 @@ class KviKvsTreeWidget : public QTreeWidget Q_OBJECT public: KviKvsTreeWidget(QWidget * par, const char * name, KvsObject_treeWidget *); - virtual ~KviKvsTreeWidget(); + ~KviKvsTreeWidget(); protected: KvsObject_treeWidget * m_pParentScript; protected: - void dropEvent(QDropEvent * e); - void dragEnterEvent(QDragEnterEvent * e); - void dragMoveEvent(QDragMoveEvent * e); + void dropEvent(QDropEvent * e) override; + void dragEnterEvent(QDragEnterEvent * e) override; + void dragMoveEvent(QDragMoveEvent * e) override; }; #endif // _CLASS_TREEWIDGET_H_ diff --git a/src/modules/objects/KvsObject_treeWidgeteItem.cpp b/src/modules/objects/KvsObject_treeWidgeteItem.cpp index dc38fc591..ca5419f1e 100644 --- a/src/modules/objects/KvsObject_treeWidgeteItem.cpp +++ b/src/modules/objects/KvsObject_treeWidgeteItem.cpp @@ -345,7 +345,7 @@ KVSO_CLASS_FUNCTION(treeWidgetItem, isChecked) c->returnValue()->setBoolean(false); return true; } - c->returnValue()->setBoolean(((QTreeWidgetItem *)m_pTreeWidgetItem)->checkState(0) == Qt::Checked ? 1 : 0); + c->returnValue()->setBoolean(((QTreeWidgetItem *)m_pTreeWidgetItem)->checkState(0) == Qt::Checked ? true : false); return true; } diff --git a/src/modules/objects/KvsObject_treeWidgeteItem.h b/src/modules/objects/KvsObject_treeWidgeteItem.h index 8d3aa01f6..9e4c13f6e 100644 --- a/src/modules/objects/KvsObject_treeWidgeteItem.h +++ b/src/modules/objects/KvsObject_treeWidgeteItem.h @@ -40,7 +40,7 @@ protected: QTreeWidgetItem * m_pTreeWidgetItem; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; protected: bool setText(KviKvsObjectFunctionCall * c); @@ -68,7 +68,7 @@ class KviKvsStandardTreeWidgetItem : public QTreeWidgetItem public: KviKvsStandardTreeWidgetItem(KvsObject_treeWidgetItem * ob, QTreeWidget * par); KviKvsStandardTreeWidgetItem(KvsObject_treeWidgetItem * ob, QTreeWidgetItem * par); - virtual ~KviKvsStandardTreeWidgetItem(); + ~KviKvsStandardTreeWidgetItem(); protected: KvsObject_treeWidgetItem * m_pMasterObject; diff --git a/src/modules/objects/KvsObject_vBox.cpp b/src/modules/objects/KvsObject_vBox.cpp index 76f750fc1..557dd5b35 100644 --- a/src/modules/objects/KvsObject_vBox.cpp +++ b/src/modules/objects/KvsObject_vBox.cpp @@ -82,15 +82,15 @@ const int align_cod[] = { Adds a stretchable space with zero minimum size and stretch factor stretch to the end of this box layout. !fn: $setAlignment(<flag1:string>, <flag2:string>, ...) Sets the alignment for widget w to flags, given as parameters.[br] - Valid flags are:[br] + Valid flags are: [pre] - Right[br] - Left[br] - Top[br] - Bottom[br] - HCenter[br] - VCenter[br] - Center[br] + Right + Left + Top + Bottom + HCenter + VCenter + Center Justify [/pre] */ @@ -111,11 +111,8 @@ KVSO_BEGIN_DESTRUCTOR(KvsObject_vBox) KVSO_END_CONSTRUCTOR(KvsObject_vBox) -bool KvsObject_vBox::init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) +bool KvsObject_vBox::init(KviKvsRunTimeContext *, KviKvsVariantList *) { - Q_UNUSED(pContext); - Q_UNUSED(pParams); - SET_OBJECT(KviTalVBox); return true; } diff --git a/src/modules/objects/KvsObject_vBox.h b/src/modules/objects/KvsObject_vBox.h index 24b7ae590..4b46c4274 100644 --- a/src/modules/objects/KvsObject_vBox.h +++ b/src/modules/objects/KvsObject_vBox.h @@ -36,7 +36,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setMargin(KviKvsObjectFunctionCall * c); bool setSpacing(KviKvsObjectFunctionCall * c); bool setStretchFactor(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_webView.cpp b/src/modules/objects/KvsObject_webView.cpp index 0a0a24354..abb46faba 100644 --- a/src/modules/objects/KvsObject_webView.cpp +++ b/src/modules/objects/KvsObject_webView.cpp @@ -1094,7 +1094,6 @@ KVSO_CLASS_FUNCTION(webView, addToJavaScriptWindowObject) } KVSO_CLASS_FUNCTION(webView, setEventFilter) { - Q_UNUSED(c); QWebFrame * pFrame; pFrame = ((QWebView *)widget())->page()->mainFrame(); pFrame->addToJavaScriptWindowObject("kvs", this); @@ -1323,8 +1322,7 @@ void KvsObject_webView::slotDownloadRequest(const QNetworkRequest & r) pReply->deleteLater(); return; } - KviKvsDownloadHandler * pHandler = new KviKvsDownloadHandler(this, pFile, pReply, g_iDownloadId); - Q_UNUSED(pHandler); + (void)new KviKvsDownloadHandler(this, pFile, pReply, g_iDownloadId); g_iDownloadId++; } } diff --git a/src/modules/objects/KvsObject_webView.h b/src/modules/objects/KvsObject_webView.h index 45de20ceb..92c47804a 100644 --- a/src/modules/objects/KvsObject_webView.h +++ b/src/modules/objects/KvsObject_webView.h @@ -44,15 +44,15 @@ public: KviKvsWebView(QWidget * par, const char * name, KvsObject_webView *); //void accept(); //void reject(); - virtual ~KviKvsWebView(); + ~KviKvsWebView(); protected: KvsObject_webView * m_pParentScript; protected: - virtual void mouseMoveEvent(QMouseEvent * ev); - virtual void contextMenuEvent(QContextMenuEvent *); - virtual bool event(QEvent * e); + void mouseMoveEvent(QMouseEvent * ev) override; + void contextMenuEvent(QContextMenuEvent *) override; + bool event(QEvent * e) override; /*protected slots: void slotNextClicked(); void slotBackClicked(); @@ -65,16 +65,16 @@ class KvsObject_webView : public KviKvsObject public: KVSO_DECLARE_OBJECT(KvsObject_webView) protected: - KviKvsRunTimeContext * m_pContext; - int elementMapId; + KviKvsRunTimeContext * m_pContext = nullptr; + int elementMapId = 1; int insertElement(const QWebElement & ele); QWebElement getElement(int iIdx); int getElementId(const QWebElement &); QHash<int, QWebElement> m_elementMapper; - KviPointerList<KviKvsObject> * lWebelement; + KviPointerList<KviKvsObject> * lWebelement = nullptr; QHash<QString, QWebElement *> m_dictCache; - KviPointerList<QNetworkReply> * m_pReplyList; - QNetworkAccessManager * m_pNetworkManager; + KviPointerList<QNetworkReply> * m_pReplyList = nullptr; + QNetworkAccessManager * m_pNetworkManager = nullptr; QWebElementCollection m_webElementCollection; QWebElement m_currentElement; @@ -83,7 +83,7 @@ public: protected: void getFrames(QWebFrame * pCurFrame, QStringList & szFramesNames); QWebFrame * findFrame(QWebFrame * pCurFrame, QString & szFrameName); - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool removeFromDocument(KviKvsObjectFunctionCall * c); bool makePreview(KviKvsObjectFunctionCall * c); @@ -160,7 +160,7 @@ class KviKvsDownloadHandler : public QObject public: KviKvsDownloadHandler(KvsObject_webView * pParent, QFile * pFile, QNetworkReply * pNetReply, int iId); - virtual ~KviKvsDownloadHandler(); + ~KviKvsDownloadHandler(); protected: KvsObject_webView * m_pParentScript; diff --git a/src/modules/objects/KvsObject_widget.cpp b/src/modules/objects/KvsObject_widget.cpp index eb3009a2b..c41183d5b 100644 --- a/src/modules/objects/KvsObject_widget.cpp +++ b/src/modules/objects/KvsObject_widget.cpp @@ -422,15 +422,15 @@ const char * const widgettypes_tbl[] = { This function sets widget flags, given as parameters. Valid flags are: [pre] - TopLevel - indicates that this widget is a top-level widget[br] - Dialog - indicates that this widget is a top-level window that should be decorated as a dialog[br] - Desktop - indicates that this widget is the desktop[br] - Popup - indicates that this widget is a popup top-level window[br] - Title - gives the window a title bar[br] - StaysOnTop - window stays on top [br] - SysMenu - add a windows system menu[br] - Minimize - add a minimize button for the sysmenu style[br] - Maximize - add a maximize button for the sysmenu style[br] + TopLevel - indicates that this widget is a top-level widget + Dialog - indicates that this widget is a top-level window that should be decorated as a dialog + Desktop - indicates that this widget is the desktop + Popup - indicates that this widget is a popup top-level window + Title - gives the window a title bar + StaysOnTop - window stays on top + SysMenu - add a windows system menu + Minimize - add a minimize button for the sysmenu style + Maximize - add a maximize button for the sysmenu style [/pre] !fn: $centerToScreen() Centers the window on the screen (useful only for toplevel widgets).[br] @@ -439,48 +439,48 @@ const char * const widgettypes_tbl[] = { Sets the way the widget accepts keyboard focus.[br] Valid parameters are: [pre] - - TabFocus; (widget accepts keyboard focus by tabbing)[br] - - ClickFocus; (widget accepts keyboard focus by clicking)[br] - - StrongFocus; (widget accepts both tabbing/clicking)[br] - - No Focus; (widget does not accept focus at all; this is the default value)[br] + - TabFocus; (widget accepts keyboard focus by tabbing) + - ClickFocus; (widget accepts keyboard focus by clicking) + - StrongFocus; (widget accepts both tabbing/clicking) + - NoFocus; (widget does not accept focus at all; this is the default value) [/pre] !fn: $keyPressEvent(<key>) If widget accepts keyboard focus (see [classfnc]$setFocusPolicy[/classfnc] ) this function handles for keys; In its argument the key pressed.[br] Special keys are: [pre] - - Return [br] - - Enter [br] - - Down (cursor arrow down) [br] - - Up (cursor arrow up) [br] - - Left (cursor arrow left) [br] - - Right (cursor arrow right) [br] - - Shift [br] - - Ctrl [br] - - Alt [br] - - CapsLock [br] - - Backspace [br] - - Del [br] - - Esc [br] - - 0 [br] - - 1 [br] - - 2 [br] - - 3 [br] - - 4 [br] - - 5 [br] - - 6 [br] - - 7 [br] - - 8 [br] - - 9 [br] - - + [br] - - - [br] - - * [br] - - / [br] - - ( [br] - - ) [br] - - = [br] - - . [br] - - ^ [br] + - Return + - Enter + - Down (cursor arrow down) + - Up (cursor arrow up) + - Left (cursor arrow left) + - Right (cursor arrow right) + - Shift + - Ctrl + - Alt + - CapsLock + - Backspace + - Del + - Esc + - 0 + - 1 + - 2 + - 3 + - 4 + - 5 + - 6 + - 7 + - 8 + - 9 + - + + - - + - * + - / + - ( + - ) + - = + - . + - ^ [/pre] !fn: $mapFromGlobal(<x>,<y>) Translates the global screen coordinate pos to widget coordinates. diff --git a/src/modules/objects/KvsObject_widget.h b/src/modules/objects/KvsObject_widget.h index 4d35b34e1..a7fc36a17 100644 --- a/src/modules/objects/KvsObject_widget.h +++ b/src/modules/objects/KvsObject_widget.h @@ -46,14 +46,14 @@ public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; #ifdef COMPILE_WEBKIT_SUPPORT - QWebView * m_pWebview; + QWebView * m_pWebview = nullptr; #endif - virtual bool eventFilter(QObject * o, QEvent * e); - KviKvsRunTimeContext * m_pContext; - QGraphicsDropShadowEffect * pGraphicsEffect; + bool eventFilter(QObject * o, QEvent * e) override; + KviKvsRunTimeContext * m_pContext = nullptr; + QGraphicsDropShadowEffect * pGraphicsEffect = nullptr; // ok, it is clear that we're messing with the naming conventions for the // object classes :D // let's try to use this one: @@ -144,12 +144,12 @@ class KviKvsWidget : public QWidget Q_PROPERTY(QSize sizeHint READ sizeHint) public: KviKvsWidget(KvsObject_widget * ob, QWidget * par); - virtual ~KviKvsWidget(); + ~KviKvsWidget(); protected: KvsObject_widget * m_pObject; public: - QSize sizeHint() const; + QSize sizeHint() const override; }; #endif //_CLASS_WIDGET_H_ diff --git a/src/modules/objects/KvsObject_window.cpp b/src/modules/objects/KvsObject_window.cpp index 28ccbd7a8..5bd8b428a 100644 --- a/src/modules/objects/KvsObject_window.cpp +++ b/src/modules/objects/KvsObject_window.cpp @@ -34,8 +34,6 @@ KviKvsScriptWindowWindow::KviKvsScriptWindowWindow(const QString & szName) : KviWindow(KviWindow::ScriptObject, szName) { - m_pCentralWidget = nullptr; - m_pIcon = nullptr; } KviKvsScriptWindowWindow::~KviKvsScriptWindowWindow() diff --git a/src/modules/objects/KvsObject_window.h b/src/modules/objects/KvsObject_window.h index 172db20de..0c21138ff 100644 --- a/src/modules/objects/KvsObject_window.h +++ b/src/modules/objects/KvsObject_window.h @@ -36,12 +36,12 @@ public: ~KviKvsScriptWindowWindow(); protected: - KvsObject_widget * m_pCentralWidgetObject; - QWidget * m_pCentralWidget; - QPixmap * m_pIcon; + KvsObject_widget * m_pCentralWidgetObject = nullptr; + QWidget * m_pCentralWidget = nullptr; + QPixmap * m_pIcon = nullptr; public: - virtual QPixmap * myIconPtr(); + QPixmap * myIconPtr() override; void setIcon(QPixmap * pPixmap) { m_pIcon = pPixmap; }; void setCentralWidget(KvsObject_widget * o, QWidget * w); void setWindowTitleString(const QString & s) @@ -49,7 +49,7 @@ public: setFixedCaption(s); fillCaptionBuffers(); }; - virtual void resizeEvent(QResizeEvent * e); + void resizeEvent(QResizeEvent * e) override; protected slots: void centralWidgetObjectDestroyed(); void centralWidgetDestroyed(); @@ -60,10 +60,10 @@ class KvsObject_window : public KvsObject_widget public: KVSO_DECLARE_OBJECT(KvsObject_window) public: - QWidget * widget() { return (QWidget *)object(); }; + QWidget * widget() { return (QWidget *)object(); } protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool setWindowTitle(KviKvsObjectFunctionCall * c); bool setIcon(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_wizard.h b/src/modules/objects/KvsObject_wizard.h index 976e25f93..b37b0aa8a 100644 --- a/src/modules/objects/KvsObject_wizard.h +++ b/src/modules/objects/KvsObject_wizard.h @@ -41,7 +41,7 @@ public: void backClicked(); protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool addPage(KviKvsObjectFunctionCall * c); bool insertPage(KviKvsObjectFunctionCall * c); @@ -68,7 +68,7 @@ public: KviKvsMdmWizard(QWidget * par, const char * name, KvsObject_wizard *); void accept(); void reject(); - virtual ~KviKvsMdmWizard(); + ~KviKvsMdmWizard(); protected: KvsObject_wizard * m_pParentScript; diff --git a/src/modules/objects/KvsObject_workspace.h b/src/modules/objects/KvsObject_workspace.h index 3a8aa1c0a..40d7bb5c8 100644 --- a/src/modules/objects/KvsObject_workspace.h +++ b/src/modules/objects/KvsObject_workspace.h @@ -36,7 +36,7 @@ public: QWidget * widget() { return (QWidget *)object(); }; protected: QHash<kvs_hobject_t, QMdiSubWindow *> * pWidgetDict; - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; bool addSubWindow(KviKvsObjectFunctionCall * c); bool removeSubWindow(KviKvsObjectFunctionCall * c); diff --git a/src/modules/objects/KvsObject_wrapper.cpp b/src/modules/objects/KvsObject_wrapper.cpp index 1131aa4c2..2c7763a1b 100644 --- a/src/modules/objects/KvsObject_wrapper.cpp +++ b/src/modules/objects/KvsObject_wrapper.cpp @@ -285,19 +285,16 @@ QWidget * KvsObject_wrapper::findTopLevelWidgetToWrap(const QString & szClass, c if(list.isEmpty()) return nullptr; - Q_FOREACH(QWidget * w, list) + for(QWidget * w : list) { - //qDebug("TLW: %s::%s (look for %s::%s)",w->metaObject()->className(),w->objectName().toUtf8().data(),szClass.toUtf8().data(),szName.toUtf8().data()); - if( - ( - szClass.isEmpty() || KviQString::equalCI(w->metaObject()->className(), szClass)) + if((szClass.isEmpty() || KviQString::equalCI(w->metaObject()->className(), szClass)) && (szName.isEmpty() || KviQString::equalCI(w->objectName(), szName))) return w; } if(bRecursive) { - Q_FOREACH(QWidget * w, list) + for(QWidget * w : list) { w = findWidgetToWrap(szClass, szName, w, bRecursive); if(w) @@ -314,22 +311,20 @@ QWidget * KvsObject_wrapper::findWidgetToWrap(const QString & szClass, const QSt if(list.isEmpty()) return nullptr; - Q_FOREACH(QObject * obj, list) + for(QObject * obj : list) { if(!obj->isWidgetType()) continue; QWidget * w = (QWidget *)obj; - if( - ( - szClass.isEmpty() || KviQString::equalCI(w->metaObject()->className(), szClass)) + if((szClass.isEmpty() || KviQString::equalCI(w->metaObject()->className(), szClass)) && (szName.isEmpty() || KviQString::equalCI(w->objectName(), szName))) return w; } if(bRecursive) { - Q_FOREACH(QObject * obj, list) + for(QObject * obj : list) { if(!obj->isWidgetType()) continue; diff --git a/src/modules/objects/KvsObject_wrapper.h b/src/modules/objects/KvsObject_wrapper.h index 523ffe6c6..0a79d2d3b 100644 --- a/src/modules/objects/KvsObject_wrapper.h +++ b/src/modules/objects/KvsObject_wrapper.h @@ -37,7 +37,7 @@ public: public: QWidget * widget() { return (QWidget *)object(); }; protected: - virtual bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams); + bool init(KviKvsRunTimeContext * pContext, KviKvsVariantList * pParams) override; QWidget * findTopLevelWidgetToWrap(const QString & szClass, const QString & szName, bool bRecursive); QWidget * findWidgetToWrap(const QString & szClass, const QString & szName, QWidget * pParent, bool bRecursive); }; diff --git a/src/modules/objects/libkviobjects.cpp b/src/modules/objects/libkviobjects.cpp index d44bc06f2..12d9e6c00 100644 --- a/src/modules/objects/libkviobjects.cpp +++ b/src/modules/objects/libkviobjects.cpp @@ -174,7 +174,7 @@ static bool objects_kvs_cmd_killClass(KviKvsModuleCommandCall * c) kills only all the instances of that class (derived class definitions and instances in this case are [b]not[/b] killed).[br] @seealso: - [cmd]class[/cmd], [cmd]objects.clear[/cmd], [fnc]$classDefined[/fnc](), + [cmd]class[/cmd], [cmd]objects.clearObjects[/cmd], [fnc]$classDefined[/fnc](), [doc:objects]Object scripting[/doc] */ @@ -202,15 +202,15 @@ static bool objects_kvs_cmd_killClass(KviKvsModuleCommandCall * c) static bool objects_kvs_cmd_clearObjects(KviKvsModuleCommandCall * c) { /* - @doc: objects.clear + @doc: objects.clearObjects @title: - objects.clear + objects.clearObjects @type: command @short: Removes all the user class definitions @syntax: - objects.clear [-i] + objects.clearObjects [-i] @description: Removes the definition of all the user classes and kill all the object instances (also instances of the builtin classes).[br] diff --git a/src/modules/objects/object_macros.h b/src/modules/objects/object_macros.h index f89318575..28525e7d0 100644 --- a/src/modules/objects/object_macros.h +++ b/src/modules/objects/object_macros.h @@ -58,7 +58,7 @@ g_pKvs##__className##Class->registerStandardFalseReturnFunctionHandler(__szName); #define KVSO_BEGIN_REGISTERCLASS(__className, __stringName, __baseClass) \ - static KviKvsObjectClass * g_pKvs##__className##Class = 0; \ + static KviKvsObjectClass * g_pKvs##__className##Class = nullptr; \ static KviKvsObject * kvs_##__className##_createInstance(KviKvsObjectClass * pClass, KviKvsObject * pParent, const QString & szName) \ { \ return new __className(pClass, pParent, szName); \ @@ -66,7 +66,7 @@ void __className::unregisterSelf() \ { \ delete g_pKvs##__className##Class; \ - g_pKvs##__className##Class = 0; \ + g_pKvs##__className##Class = nullptr; \ } \ void __className::registerSelf() \ { \ @@ -92,7 +92,7 @@ } #define KVSO_CLASS_FUNCTION(__className, __functionName) \ - bool KvsObject_##__className::__functionName(KviKvsObjectFunctionCall * c) + bool KvsObject_##__className::__functionName([[maybe_unused]] KviKvsObjectFunctionCall * c) #define CHECK_INTERNAL_POINTER(__pointer) \ if(!__pointer) \ diff --git a/src/modules/objects/qtftp/qftp.cpp b/src/modules/objects/qtftp/qftp.cpp index 565172619..935bdb8b0 100644 --- a/src/modules/objects/qtftp/qftp.cpp +++ b/src/modules/objects/qtftp/qftp.cpp @@ -43,6 +43,8 @@ //#define QFTPDTP_DEBUG #include "qftp.h" + +#include <utility> #include "qabstractsocket.h" #ifndef QT_NO_FTP @@ -90,14 +92,18 @@ public: QBasicAtomicInt QFtpCommand::idCounter = Q_BASIC_ATOMIC_INITIALIZER(1); QFtpCommand::QFtpCommand(QFtp::Command cmd, QStringList raw, const QByteArray & ba) - : command(cmd), rawCmds(raw), is_ba(true) + : command(cmd) + , rawCmds(std::move(raw)) + , is_ba(true) { id = idCounter.fetchAndAddRelaxed(1); data.ba = new QByteArray(ba); } QFtpCommand::QFtpCommand(QFtp::Command cmd, QStringList raw, QIODevice * dev) - : command(cmd), rawCmds(raw), is_ba(false) + : command(cmd) + , rawCmds(std::move(raw)) + , is_ba(false) { id = idCounter.fetchAndAddRelaxed(1); data.dev = dev; @@ -958,7 +964,7 @@ bool QFtpPI::processReply() // both examples where the parenthesis are used, and where // they are missing. We need to scan for the address and host // info. - QRegExp addrPortPattern(QLatin1String("(\\d+),(\\d+),(\\d+),(\\d+),(\\d+),(\\d+)")); + QRegExp addrPortPattern(QLatin1String(R"((\d+),(\d+),(\d+),(\d+),(\d+),(\d+))")); if(addrPortPattern.indexIn(replyText) == -1) { #if defined(QFTPPI_DEBUG) diff --git a/src/modules/objects/qtftp/qurlinfo.cpp b/src/modules/objects/qtftp/qurlinfo.cpp index 2df6adfdb..6e19960c5 100644 --- a/src/modules/objects/qtftp/qurlinfo.cpp +++ b/src/modules/objects/qtftp/qurlinfo.cpp @@ -43,38 +43,32 @@ #include "qurl.h" #include "qdir.h" -#include <limits.h> +#include <climits> QT_BEGIN_NAMESPACE class QUrlInfoPrivate { public: - QUrlInfoPrivate() : permissions(0), - size(0), - isDir(false), - isFile(true), - isSymLink(false), - isWritable(true), - isReadable(true), - isExecutable(false) + QUrlInfoPrivate() + { } QString name; - int permissions; + int permissions{ 0 }; QString owner; QString group; - qint64 size; + qint64 size{ 0 }; QDateTime lastModified; QDateTime lastRead; - bool isDir; - bool isFile; - bool isSymLink; - bool isWritable; - bool isReadable; - bool isExecutable; + bool isDir{ false }; + bool isFile{ true }; + bool isSymLink{ false }; + bool isWritable{ true }; + bool isReadable{ true }; + bool isExecutable{ false }; }; /*! diff --git a/src/modules/objects/qthttp/qhttp.cpp b/src/modules/objects/qthttp/qhttp.cpp index dbecaa42e..84e5e28e5 100644 --- a/src/modules/objects/qthttp/qhttp.cpp +++ b/src/modules/objects/qthttp/qhttp.cpp @@ -42,6 +42,8 @@ //#define QHTTP_DEBUG #include <qplatformdefs.h> + +#include <utility> #include "qhttp.h" #ifndef QT_NO_HTTP @@ -71,7 +73,7 @@ class QHttpNormalRequest; class QHttpRequest { public: - QHttpRequest() : finished(false) + QHttpRequest() { id = idCounter.fetchAndAddRelaxed(1); } @@ -86,7 +88,7 @@ public: virtual QIODevice * destinationDevice() = 0; int id; - bool finished; + bool finished{ false }; private: static QBasicAtomicInt idCounter; @@ -98,11 +100,20 @@ public: Q_DECLARE_PUBLIC(QHttp) inline QHttpPrivate(QHttp * parent) - : socket(nullptr), reconnectAttempts(2), - deleteSocket(0), state(QHttp::Unconnected), - error(QHttp::NoError), port(0), mode(QHttp::ConnectionModeHttp), - toDevice(nullptr), postDevice(nullptr), bytesDone(0), chunkedSize(-1), - repost(false), pendingPost(false), q_ptr(parent) + : socket(nullptr) + , reconnectAttempts(2) + , deleteSocket(false) + , state(QHttp::Unconnected) + , error(QHttp::NoError) + , port(0) + , mode(QHttp::ConnectionModeHttp) + , toDevice(nullptr) + , postDevice(nullptr) + , bytesDone(0) + , chunkedSize(-1) + , repost(false) + , pendingPost(false) + , q_ptr(parent) { } @@ -346,8 +357,10 @@ void QHttpPGHRequest::start(QHttp * http) class QHttpSetHostRequest : public QHttpRequest { public: - QHttpSetHostRequest(const QString & h, quint16 p, QHttp::ConnectionMode m) - : hostName(h), port(p), mode(m) + QHttpSetHostRequest(QString h, quint16 p, QHttp::ConnectionMode m) + : hostName(std::move(h)) + , port(p) + , mode(m) { } @@ -396,7 +409,9 @@ void QHttpSetHostRequest::start(QHttp * http) class QHttpSetUserRequest : public QHttpRequest { public: - QHttpSetUserRequest(const QString & userName, const QString & password) : user(userName), pass(password) + QHttpSetUserRequest(QString userName, QString password) + : user(std::move(userName)) + , pass(std::move(password)) { } @@ -510,8 +525,7 @@ class QHttpCloseRequest : public QHttpRequest { public: QHttpCloseRequest() - { - } + = default; void start(QHttp *) override; QIODevice * sourceDevice() override diff --git a/src/modules/objects/qthttp/qhttpauthenticator.cpp b/src/modules/objects/qthttp/qhttpauthenticator.cpp index c6063c6c4..194fe856d 100644 --- a/src/modules/objects/qthttp/qhttpauthenticator.cpp +++ b/src/modules/objects/qthttp/qhttpauthenticator.cpp @@ -860,10 +860,10 @@ const quint8 hirespversion = 1; class QNtlmBuffer { public: - QNtlmBuffer() : len(0), maxLen(0), offset(0) {} - quint16 len; - quint16 maxLen; - quint32 offset; + QNtlmBuffer() {} + quint16 len{ 0 }; + quint16 maxLen{ 0 }; + quint32 offset{ 0 }; enum { Size = 8 diff --git a/src/modules/options/OptionsDialog.cpp b/src/modules/options/OptionsDialog.cpp index 4249e2f54..6883337aa 100644 --- a/src/modules/options/OptionsDialog.cpp +++ b/src/modules/options/OptionsDialog.cpp @@ -191,7 +191,7 @@ OptionsDialog::OptionsDialog(QWidget * par, const QString & szGroup, bool bModal hbox->setMargin(3); m_pSearchLineEdit = new QLineEdit(hbox); - connect(m_pSearchLineEdit, SIGNAL(returnPressed()), this, SLOT(searchClicked())); + connect(m_pSearchLineEdit, SIGNAL(textEdited(const QString &)), this, SLOT(searchClicked())); m_pSearchButton = new QToolButton(hbox); m_pSearchButton->setIconSize(QSize(16, 16)); m_pSearchButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Search))); @@ -322,6 +322,7 @@ void OptionsDialog::searchLineEditTextChanged(const QString &) bool OptionsDialog::searchInSelectors(KviOptionsWidget * pOptionsWidget, const QStringList & lKeywords) { KviPointerList<KviSelectorInterface> * selectors = pOptionsWidget->selectors(); + bool bCleaningUp = lKeywords.isEmpty(); bool bFoundSomethingHere = false; if(selectors->count() > 0) { @@ -331,28 +332,38 @@ bool OptionsDialog::searchInSelectors(KviOptionsWidget * pOptionsWidget, const Q QWidget * pWidget = selectors->at(i)->widgetToHighlight(); if(!pWidget) continue; - QString szTmp = pWidget->toolTip(); - szTmp = szTmp.replace(QRegExp("<[^<>]+>"), ""); - szText.append(szTmp); - if(!szText.isEmpty()) + if(bCleaningUp) { - bool bOk = true; - for(int j = 0; j < lKeywords.count(); j++) + QFont font = pWidget->font(); + font.setBold(false); + font.setUnderline(false); + pWidget->setFont(font); + } + else + { + QString szTmp = pWidget->toolTip(); + szTmp = szTmp.replace(QRegExp("<[^<>]+>"), ""); + szText.append(szTmp); + if(!szText.isEmpty()) { - if(szText.indexOf(lKeywords.at(j), 0, Qt::CaseInsensitive) == -1) + bool bOk = true; + for(int j = 0; j < lKeywords.count(); j++) { - bOk = false; - break; + if(szText.indexOf(lKeywords.at(j), 0, Qt::CaseInsensitive) == -1) + { + bOk = false; + break; + } } + if(bOk) + { + bFoundSomethingHere = true; + } + QFont font = pWidget->font(); + font.setBold(bOk); + font.setUnderline(bOk); + pWidget->setFont(font); } - if(bOk) - { - bFoundSomethingHere = true; - } - QFont font = pWidget->font(); - font.setBold(bOk); - font.setUnderline(bOk); - pWidget->setFont(font); } } } @@ -369,6 +380,7 @@ bool OptionsDialog::recursiveSearch(OptionsDialogTreeWidgetItem * pItem, const Q m_pWidgetStack->addWidget(pItem->m_pOptionsWidget); } + bool bCleaningUp = lKeywords.isEmpty(); bool bFoundSomethingHere = false; KviOptionsWidget * pOptionsWidget = pItem->m_pOptionsWidget; QTabWidget * pTab = pOptionsWidget->tabWidget(); @@ -377,12 +389,12 @@ bool OptionsDialog::recursiveSearch(OptionsDialogTreeWidgetItem * pItem, const Q for(int i = 0; i < pTab->count(); i++) { QString szTxt = pTab->tabText(i); - if(KviQString::equalCIN(szTxt, ">>> ", 4)) + if(bCleaningUp || KviQString::equalCIN(szTxt, ">>> ", 4)) { szTxt.replace(">>> ", ""); szTxt.replace(" <<<", ""); } - if(searchInSelectors((KviOptionsWidget *)pTab->widget(i), lKeywords)) + if(searchInSelectors((KviOptionsWidget *)pTab->widget(i), lKeywords) && !bCleaningUp) { bFoundSomethingHere = true; szTxt.insert(0, ">>> "); @@ -393,18 +405,21 @@ bool OptionsDialog::recursiveSearch(OptionsDialogTreeWidgetItem * pItem, const Q } else { - if(searchInSelectors(pOptionsWidget, lKeywords)) + if(searchInSelectors(pOptionsWidget, lKeywords) && !bCleaningUp) bFoundSomethingHere = true; } - QStringList szInstanceKeywords = pItem->m_pInstanceEntry->szKeywords.split(QChar(',')); - // debug all the "search keywords" for each entry in the options tree - // qDebug("OPT %s",pItem->m_pInstanceEntry->szKeywords.toUtf8().data()); + if (!bCleaningUp) + { + QStringList szInstanceKeywords = pItem->m_pInstanceEntry->szKeywords.split(QChar(',')); + // debug all the "search keywords" for each entry in the options tree + // qDebug("OPT %s",pItem->m_pInstanceEntry->szKeywords.toUtf8().data()); - for(int i = 0; i < szInstanceKeywords.count() && !bFoundSomethingHere; i++) - for(int j = 0; j < lKeywords.count() && !bFoundSomethingHere; j++) - if(szInstanceKeywords.at(i).contains(lKeywords.at(j), Qt::CaseInsensitive)) - bFoundSomethingHere = true; + for(int i = 0; i < szInstanceKeywords.count() && !bFoundSomethingHere; i++) + for(int j = 0; j < lKeywords.count() && !bFoundSomethingHere; j++) + if(szInstanceKeywords.at(i).contains(lKeywords.at(j), Qt::CaseInsensitive)) + bFoundSomethingHere = true; + } if(bFoundSomethingHere) { @@ -424,7 +439,7 @@ bool OptionsDialog::recursiveSearch(OptionsDialogTreeWidgetItem * pItem, const Q for(int j = 0; j < ccount; j++) { OptionsDialogTreeWidgetItem * pChild = (OptionsDialogTreeWidgetItem *)pItem->child(j); - bool bRet = recursiveSearch(pChild, lKeywords); + bool bRet = recursiveSearch(pChild, lKeywords) && !bCleaningUp; if(bRet) bFoundSomethingInside = true; } @@ -455,11 +470,27 @@ void OptionsDialog::search(const QString & szKeywords) search(lKeywords); } +void OptionsDialog::clearSearch() +{ + m_pTreeWidget->setUpdatesEnabled(false); + + QTreeWidgetItemIterator it(m_pTreeWidget); + while (*it) { + recursiveSearch(((OptionsDialogTreeWidgetItem *)* it), QStringList()); + ++it; + } + + m_pTreeWidget->setUpdatesEnabled(true); + m_pTreeWidget->update(); +} + void OptionsDialog::searchClicked() { QString szTxt = m_pSearchLineEdit->text().trimmed(); - if(!szTxt.isEmpty()) + if(szTxt.length() > 1) search(szTxt); + else + clearSearch(); } void OptionsDialog::fillTreeWidget(QTreeWidgetItem * p, KviPointerList<OptionsWidgetInstanceEntry> * l, const QString & szGroup, bool bNotContainedOnly) diff --git a/src/modules/options/OptionsDialog.h b/src/modules/options/OptionsDialog.h index 1d2cc912b..8af5e1048 100644 --- a/src/modules/options/OptionsDialog.h +++ b/src/modules/options/OptionsDialog.h @@ -93,10 +93,11 @@ private slots: protected: void apply(bool bDialogAboutToClose); - virtual void closeEvent(QCloseEvent * e); - virtual void keyPressEvent(QKeyEvent * e); - virtual void showEvent(QShowEvent * e); + void closeEvent(QCloseEvent * e) override; + void keyPressEvent(QKeyEvent * e) override; + void showEvent(QShowEvent * e) override; bool recursiveSearch(OptionsDialogTreeWidgetItem * pItem, const QStringList & lKeywords); + void clearSearch(); bool searchInSelectors(KviOptionsWidget * pWidget, const QStringList & lKeywords); public: diff --git a/src/modules/options/OptionsInstanceManager.cpp b/src/modules/options/OptionsInstanceManager.cpp index 41ed5ae04..36291b24a 100644 --- a/src/modules/options/OptionsInstanceManager.cpp +++ b/src/modules/options/OptionsInstanceManager.cpp @@ -3712,7 +3712,7 @@ KviOptionsWidget * OptionsInstanceManager::getInstance(OptionsWidgetInstanceEntr QWidget * pOldPar = (QWidget *)pEntry->pWidget->parent(); pEntry->pWidget->setParent(pPar); pOldPar->deleteLater(); - pEntry->pWidget = 0; + pEntry->pWidget = nullptr; } } #endif diff --git a/src/modules/options/OptionsInstanceManager.h b/src/modules/options/OptionsInstanceManager.h index 6f52d928d..0abe1d811 100644 --- a/src/modules/options/OptionsInstanceManager.h +++ b/src/modules/options/OptionsInstanceManager.h @@ -39,9 +39,7 @@ #include "KviQString.h" #include "KviIconManager.h" -typedef struct _OptionsWidgetInstanceEntry OptionsWidgetInstanceEntry; - -typedef struct _OptionsWidgetInstanceEntry +struct OptionsWidgetInstanceEntry { KviOptionsWidget * (*createProc)(QWidget *); KviOptionsWidget * pWidget; // singleton @@ -57,7 +55,7 @@ typedef struct _OptionsWidgetInstanceEntry bool bIsNotContained; KviPointerList<OptionsWidgetInstanceEntry> * pChildList; bool bDoInsert; // a helper for OptionsDialog::fillListView() -} OptionsWidgetInstanceEntry; +}; class OptionsInstanceManager : public QObject { diff --git a/src/modules/options/OptionsWidgetContainer.cpp b/src/modules/options/OptionsWidgetContainer.cpp index 2fa75fb7d..6ff3e5e31 100644 --- a/src/modules/options/OptionsWidgetContainer.cpp +++ b/src/modules/options/OptionsWidgetContainer.cpp @@ -48,8 +48,6 @@ OptionsWidgetContainer::OptionsWidgetContainer(QWidget * par, bool bModal) setObjectName("container"); - m_pOptionsWidget = nullptr; - if(bModal) setWindowModality(par ? Qt::WindowModal : Qt::ApplicationModal); } diff --git a/src/modules/options/OptionsWidgetContainer.h b/src/modules/options/OptionsWidgetContainer.h index 5f26c2f5d..17328c12d 100644 --- a/src/modules/options/OptionsWidgetContainer.h +++ b/src/modules/options/OptionsWidgetContainer.h @@ -28,8 +28,8 @@ #include <QDialog> -class QPushButton; class QGridLayout; +class QPushButton; class OptionsWidgetContainer : public QDialog { @@ -39,9 +39,9 @@ public: ~OptionsWidgetContainer(); protected: - KviOptionsWidget * m_pOptionsWidget; - QPushButton * m_pCancel; - QGridLayout * m_pLayout; + KviOptionsWidget * m_pOptionsWidget = nullptr; + QPushButton * m_pCancel = nullptr; + QGridLayout * m_pLayout = nullptr; public: void setup(KviOptionsWidget * w); @@ -49,10 +49,10 @@ public: void setNextToLeft(QWidget * pWidget); protected: - virtual void closeEvent(QCloseEvent * e); - virtual void showEvent(QShowEvent * e); - virtual void childEvent(QChildEvent * e); - virtual void reject(); + void closeEvent(QCloseEvent * e) override; + void showEvent(QShowEvent * e) override; + void childEvent(QChildEvent * e) override; + void reject() override; protected slots: void okClicked(); void cancelClicked(); diff --git a/src/modules/options/OptionsWidget_connection.cpp b/src/modules/options/OptionsWidget_connection.cpp index bed814aa0..60fdce129 100644 --- a/src/modules/options/OptionsWidget_connection.cpp +++ b/src/modules/options/OptionsWidget_connection.cpp @@ -182,7 +182,10 @@ OptionsWidget_connectionSocket::OptionsWidget_connectionSocket(QWidget * parent) "you want to rely on the DNS server to provide the best choice.", "options")); - addRowSpacer(0, 5, 0, 5); + b = addBoolSelector(0, 5, 0, 5, __tr2qs_ctx("Drop connection on SASL authentication failure", "options"), KviOption_boolDropConnectionOnSaslFailure); + mergeTip(b, __tr2qs_ctx("This option will close the socket if no SASL authentication or any SASL fallback had succeeded.", "options")); + + addRowSpacer(0, 6, 0, 6); } OptionsWidget_connectionSocket::~OptionsWidget_connectionSocket() diff --git a/src/modules/options/OptionsWidget_identity.cpp b/src/modules/options/OptionsWidget_identity.cpp index 6efc60b7a..5d7c5bf76 100644 --- a/src/modules/options/OptionsWidget_identity.cpp +++ b/src/modules/options/OptionsWidget_identity.cpp @@ -515,7 +515,7 @@ OptionsWidget_identityAvatar::~OptionsWidget_identityAvatar() delete m_pLocalAvatar; } -void OptionsWidget_identityAvatar::commit(void) +void OptionsWidget_identityAvatar::commit() { KviOptionsWidget::commit(); diff --git a/src/modules/options/OptionsWidget_identity.h b/src/modules/options/OptionsWidget_identity.h index 6193ad09a..f06a02db0 100644 --- a/src/modules/options/OptionsWidget_identity.h +++ b/src/modules/options/OptionsWidget_identity.h @@ -70,7 +70,7 @@ protected: QString m_szAvatarName; protected: - virtual void closeEvent(QCloseEvent * e); + void closeEvent(QCloseEvent * e) override; const QString & avatarName() { return m_szAvatarName; }; protected slots: void okClicked(); @@ -94,7 +94,7 @@ protected: QString m_szUrl; protected: - virtual void closeEvent(QCloseEvent * e); + void closeEvent(QCloseEvent * e) override; const QString & localFileName() { return m_szLocalFileName; }; const QString & errorMessage() { return m_szErrorMessage; }; protected slots: @@ -161,7 +161,7 @@ protected slots: void setNickAlternatives(); protected: - virtual void commit(); + void commit() override; }; #define KVI_OPTIONS_WIDGET_ICON_OptionsWidget_identityAvatar KviIconManager::Avatar @@ -186,7 +186,7 @@ protected slots: void chooseAvatar(); protected: - virtual void commit(); + void commit() override; }; #define KVI_OPTIONS_WIDGET_ICON_OptionsWidget_identityAdvanced KviIconManager::Gui diff --git a/src/modules/options/OptionsWidget_input.cpp b/src/modules/options/OptionsWidget_input.cpp index 870e23ab3..e56881b12 100644 --- a/src/modules/options/OptionsWidget_input.cpp +++ b/src/modules/options/OptionsWidget_input.cpp @@ -148,21 +148,24 @@ OptionsWidget_inputFeatures::OptionsWidget_inputFeatures(QWidget * parent) u->setSuffix(__tr2qs_ctx(" spaces", "options")); KviTalGroupBox * g = addGroupBox(0, 6, 0, 6, Qt::Horizontal, __tr2qs_ctx("Nick Completion", "options")); - KviBoolSelector *b, *c; + KviBoolSelector *b, *c, *d; b = addBoolSelector(g, __tr2qs_ctx("Use bash-like nick completion", "options"), KviOption_boolBashLikeNickCompletion, !KVI_OPTION_BOOL(KviOption_boolZshLikeNickCompletion)); c = addBoolSelector(g, __tr2qs_ctx("Use zsh-like nick completion", "options"), KviOption_boolZshLikeNickCompletion, !KVI_OPTION_BOOL(KviOption_boolBashLikeNickCompletion)); + d = addBoolSelector(g, __tr2qs_ctx("Prioritize nick completion by last action time", "options"), KviOption_boolPrioritizeLastActionTime); connect(b, SIGNAL(toggled(bool)), c, SLOT(setDisabled(bool))); + connect(b, SIGNAL(toggled(bool)), d, SLOT(setDisabled(bool))); connect(c, SIGNAL(toggled(bool)), b, SLOT(setDisabled(bool))); + connect(c, SIGNAL(toggled(bool)), d, SLOT(setDisabled(bool))); addStringSelector(g, __tr2qs_ctx("Nick completion postfix string:", "options"), KviOption_stringNickCompletionPostfix); addBoolSelector(g, __tr2qs_ctx("Use the completion postfix string for the first word only", "options"), KviOption_boolUseNickCompletionPostfixForFirstWordOnly); addBoolSelector(g, __tr2qs_ctx("Ignore special characters in nick completion", "options"), KviOption_boolIgnoreSpecialCharactersInNickCompletion); - KviBoolSelector * d = addBoolSelector(0, 7, 0, 7, __tr2qs_ctx("Use a custom cursor width", "options"), KviOption_boolEnableCustomCursorWidth); + KviBoolSelector * e = addBoolSelector(0, 7, 0, 7, __tr2qs_ctx("Use a custom cursor width", "options"), KviOption_boolEnableCustomCursorWidth); KviUIntSelector * f = addUIntSelector(0, 8, 0, 8, __tr2qs_ctx("Custom cursor width:", "options"), KviOption_uintCustomCursorWidth, 1, 24, 8, KVI_OPTION_BOOL(KviOption_boolEnableCustomCursorWidth)); f->setSuffix(__tr2qs_ctx(" pixels", "options")); - connect(d, SIGNAL(toggled(bool)), f, SLOT(setEnabled(bool))); + connect(e, SIGNAL(toggled(bool)), f, SLOT(setEnabled(bool))); addRowSpacer(0, 9, 0, 9); } diff --git a/src/modules/options/OptionsWidget_interfaceFeatures.cpp b/src/modules/options/OptionsWidget_interfaceFeatures.cpp index aff19dc3b..27e04300b 100644 --- a/src/modules/options/OptionsWidget_interfaceFeatures.cpp +++ b/src/modules/options/OptionsWidget_interfaceFeatures.cpp @@ -32,7 +32,7 @@ #include <QLayout> #include <QLabel> -#include <string.h> +#include <cstring> OptionsWidget_interfaceFeatures::OptionsWidget_interfaceFeatures(QWidget * parent) : KviOptionsWidget(parent) @@ -40,8 +40,6 @@ OptionsWidget_interfaceFeatures::OptionsWidget_interfaceFeatures(QWidget * paren setObjectName("interfacefeatures_options_widget"); createLayout(); - KviTalGroupBox * g; - addBoolSelector(0, 0, 0, 0, __tr2qs_ctx("Minimize application on startup", "options"), KviOption_boolStartupMinimized); addBoolSelector(0, 1, 0, 1, __tr2qs_ctx("Confirm quit with active connections", "options"), KviOption_boolConfirmCloseWhenThereAreConnections); addBoolSelector(0, 2, 0, 2, __tr2qs_ctx("Remember window properties", "options"), KviOption_boolWindowsRememberProperties); diff --git a/src/modules/options/OptionsWidget_message.cpp b/src/modules/options/OptionsWidget_message.cpp index d9fa9cd85..2755bedfe 100644 --- a/src/modules/options/OptionsWidget_message.cpp +++ b/src/modules/options/OptionsWidget_message.cpp @@ -73,14 +73,21 @@ OptionsWidget_privmsg::OptionsWidget_privmsg(QWidget * parent) m_pUseSmartColorSelector = addBoolSelector(g, __tr2qs_ctx("Smart nickname colors", "options"), KviOption_boolColorNicks); + connect(m_pUseSmartColorSelector, SIGNAL(toggled(bool)), this, SLOT(enableDisableSmartColorSelector(bool))); + + m_pUseSmartColorWithBackgroundSelector = addBoolSelector(g, __tr2qs_ctx("Use a background color for smart nickname colors", "options"), KviOption_boolColorNicksWithBackground, KVI_OPTION_BOOL(KviOption_boolColorNicks)); + KviTalHBox * hb = new KviTalHBox(g); hb->setSpacing(4); - m_pSpecialSmartColorSelector = addBoolSelector(hb, __tr2qs_ctx("Use specified colors for own nick:", "options"), KviOption_boolUseSpecifiedSmartColorForOwnNick, KVI_OPTION_BOOL(KviOption_boolColorNicks)); + m_pSpecialSmartColorSelector = addBoolSelector(hb, __tr2qs_ctx("Use specified smart colors for own nick:", "options"), KviOption_boolUseSpecifiedSmartColorForOwnNick, KVI_OPTION_BOOL(KviOption_boolColorNicks)); m_pSmartColorSelector = addMircTextColorSelector(hb, "", KviOption_uintUserIrcViewOwnForeground, KviOption_uintUserIrcViewOwnBackground, KVI_OPTION_BOOL(KviOption_boolColorNicks) && KVI_OPTION_BOOL(KviOption_boolUseSpecifiedSmartColorForOwnNick)); connect(m_pSpecialSmartColorSelector, SIGNAL(toggled(bool)), this, SLOT(enableDisableSmartColorSelector(bool))); connect(m_pUseSmartColorSelector, SIGNAL(toggled(bool)), m_pSpecialSmartColorSelector, SLOT(setEnabled(bool))); + connect(m_pUseSmartColorSelector, SIGNAL(toggled(bool)), m_pUseSmartColorWithBackgroundSelector, SLOT(setEnabled(bool))); + + enableDisableSmartColorSelector(true); KviBoolSelector * b2 = addBoolSelector(g, __tr2qs_ctx("Use same colors as in the userlist", "options"), KviOption_boolUseUserListColorsAsNickColors, !KVI_OPTION_BOOL(KviOption_boolColorNicks)); connect(m_pUseSmartColorSelector, SIGNAL(toggled(bool)), b2, SLOT(setNotEnabled(bool))); @@ -116,7 +123,7 @@ OptionsWidget_privmsg::OptionsWidget_privmsg(QWidget * parent) void OptionsWidget_privmsg::enableDisableSmartColorSelector(bool) { - m_pSmartColorSelector->setEnabled(m_pUseSmartColorSelector->isChecked() && m_pUseSmartColorSelector->isChecked()); + m_pSmartColorSelector->setEnabled(m_pSpecialSmartColorSelector->isChecked() && m_pUseSmartColorSelector->isChecked()); } OptionsWidget_privmsg::~OptionsWidget_privmsg() @@ -272,15 +279,15 @@ void MessageListWidgetItemDelegate::paint(QPainter * p, const QStyleOptionViewIt p->drawPixmap(pt, *(g_pIconManager->getSmallIcon(it->msgType()->pixId()))); pt.setX(pt.x() + 18); // draw the background - if(it->msgType()->back() < 16) + if(it->msgType()->back() <= KVI_EXTCOLOR_MAX) { - QColor bColor = KVI_OPTION_MIRCCOLOR(it->msgType()->back()); + QColor bColor = getMircColor(it->msgType()->back()); p->fillRect(pt.x(), pt.y(), opt.rect.width() - pt.x(), opt.rect.height(), bColor); } unsigned char ucFore = it->msgType()->fore(); - if(ucFore > 15) + if(ucFore > KVI_EXTCOLOR_MAX) ucFore = 0; - p->setPen(QPen(KVI_OPTION_MIRCCOLOR(ucFore))); + p->setPen(QPen(getMircColor(ucFore))); pt.setX(pt.x() + 2); p->drawText(pt.x(), pt.y(), opt.rect.width() - pt.x(), opt.rect.height(), Qt::AlignLeft | Qt::AlignVCenter, szText); @@ -305,14 +312,14 @@ MessageColorListWidgetItem::MessageColorListWidgetItem(KviTalListWidget * b, int { m_iClrIdx = idx; - if((idx < 0) || (idx > 15)) + if((idx < 0) || (idx > KVI_EXTCOLOR_MAX)) { setText(__tr2qs_ctx("Transparent", "options")); setBackground(listWidget()->isEnabled() ? Qt::transparent : Qt::gray); } else { - setBackground(QColor(KVI_OPTION_MIRCCOLOR(m_iClrIdx))); + setBackground(QColor(getMircColor(m_iClrIdx))); setText(" "); } } @@ -329,9 +336,9 @@ void MessageColorListWidgetItemDelegate::paint(QPainter * p, const QStyleOptionV const KviTalListWidget * lb = (const KviTalListWidget *)parent(); MessageColorListWidgetItem * it = static_cast<MessageColorListWidgetItem *>(index.internalPointer()); - if((it->clrIdx() >= 0) && (it->clrIdx() <= 15)) + if((it->clrIdx() >= 0) && (it->clrIdx() <= KVI_EXTCOLOR_MAX)) { - clr = KVI_OPTION_MIRCCOLOR(it->clrIdx()); + clr = getMircColor(it->clrIdx()); } else { @@ -630,9 +637,7 @@ void OptionsWidget_messageColors::load() //qDebug("SYMLINKING %s to %s",szGlobal.ptr(),szLocal.ptr()); //qDebug("SYMLINK RETURNS %d (%d)",::symlink(szGlobal.ptr(),szLocal.ptr())); //qDebug("ERRNO (%d)",errno); - int dummy; // make gcc happy - dummy = symlink(szGlobal.toLocal8Bit().data(), szLocal.toLocal8Bit().data()); - Q_UNUSED(dummy); + (void)symlink(szGlobal.toLocal8Bit().data(), szLocal.toLocal8Bit().data()); // FIXME: Do it also on windows... #endif diff --git a/src/modules/options/OptionsWidget_message.h b/src/modules/options/OptionsWidget_message.h index b080edc79..9652a7b0c 100644 --- a/src/modules/options/OptionsWidget_message.h +++ b/src/modules/options/OptionsWidget_message.h @@ -66,6 +66,7 @@ public: public: KviBoolSelector * m_pUseSmartColorSelector; KviBoolSelector * m_pSpecialSmartColorSelector; + KviBoolSelector * m_pUseSmartColorWithBackgroundSelector; KviMircTextColorSelector * m_pSmartColorSelector; protected slots: void enableDisableSmartColorSelector(bool); @@ -112,7 +113,7 @@ class MessageListWidgetItemDelegate : public QItemDelegate { Q_OBJECT public: - MessageListWidgetItemDelegate(QAbstractItemView * pWidget = 0) + MessageListWidgetItemDelegate(QAbstractItemView * pWidget = nullptr) : QItemDelegate(pWidget){}; ~MessageListWidgetItemDelegate(){}; void paint(QPainter * p, const QStyleOptionViewItem & opt, const QModelIndex & index) const; @@ -129,8 +130,8 @@ private: KviMessageTypeSettings * m_pMsgType; public: - inline int optionId() { return m_iOptId; }; - inline KviMessageTypeSettings * msgType() { return m_pMsgType; }; + int optionId() const { return m_iOptId; } + KviMessageTypeSettings * msgType() const { return m_pMsgType; } }; class MessageColorListWidgetItem : public KviTalListWidgetText @@ -143,14 +144,14 @@ public: int m_iClrIdx; public: - inline int clrIdx() { return m_iClrIdx; }; + int clrIdx() const { return m_iClrIdx; } }; class MessageColorListWidgetItemDelegate : public QItemDelegate { Q_OBJECT public: - MessageColorListWidgetItemDelegate(QAbstractItemView * pWidget = 0) + MessageColorListWidgetItemDelegate(QAbstractItemView * pWidget = nullptr) : QItemDelegate(pWidget){}; ~MessageColorListWidgetItemDelegate(){}; void paint(QPainter * p, const QStyleOptionViewItem & opt, const QModelIndex & index) const; diff --git a/src/modules/options/OptionsWidget_servers.cpp b/src/modules/options/OptionsWidget_servers.cpp index af11bb343..3e93b93c3 100644 --- a/src/modules/options/OptionsWidget_servers.cpp +++ b/src/modules/options/OptionsWidget_servers.cpp @@ -55,6 +55,7 @@ #include "KviPointerHashTable.h" #include "KviTalToolTip.h" #include "KviIrcNetwork.h" +#include "KviSASL.h" #include <QLineEdit> #include <QCursor> @@ -901,19 +902,33 @@ IrcServerDetailsWidget::IrcServerDetailsWidget(QWidget * par, KviIrcServer * s) m_pEnableSASLCheck->setChecked(s->enabledSASL()); - l = new QLabel(__tr2qs_ctx("SASL nickname:", "options"), pSASLGroup); + l = new QLabel(__tr2qs_ctx("SASL method:", "options"), pSASLGroup); pSASLLayout->addWidget(l, 1, 0); + m_pSaslMethodComboBox = new QComboBox(pSASLGroup); + m_pSaslMethodComboBox->setDuplicatesEnabled(false); + for(auto&& method : KviSASL::supportedMethods()) + m_pSaslMethodComboBox->addItem(method); + KviTalToolTip::add(m_pSaslMethodComboBox, __tr2qs_ctx("Select which SASL method you want to use to authenticate with.<br><br>" + "EXTERNAL will fallback to PLAIN if a non-SSL connection is used or no .pem file is loaded.", "options")); + pSASLLayout->addWidget(m_pSaslMethodComboBox, 1, 1); + + int index = m_pSaslMethodComboBox->findText(s->saslMethod()); + if(index != -1) + m_pSaslMethodComboBox->setCurrentIndex(index); + + l = new QLabel(__tr2qs_ctx("SASL nickname:", "options"), pSASLGroup); + pSASLLayout->addWidget(l, 2, 0); m_pSaslNickEditor = new QLineEdit(pSASLGroup); m_pSaslNickEditor->setText(s->saslNick()); - KviTalToolTip::add(m_pSaslNickEditor, __tr2qs_ctx("If you want to enable SASL authentication, insert your nickname here.", "options")); - pSASLLayout->addWidget(m_pSaslNickEditor, 1, 1); + KviTalToolTip::add(m_pSaslNickEditor, __tr2qs_ctx("If you want to enable SASL authentication, insert your nickname here. (Not required for EXTERNAL)", "options")); + pSASLLayout->addWidget(m_pSaslNickEditor, 2, 1); l = new QLabel(__tr2qs_ctx("SASL password:", "options"), pSASLGroup); - pSASLLayout->addWidget(l, 2, 0); - m_pSaslPassEditor = new KviPasswordLineEdit(pSASLGroup); // <---- ????? + pSASLLayout->addWidget(l, 3, 0); + m_pSaslPassEditor = new KviPasswordLineEdit(pSASLGroup); m_pSaslPassEditor->setText(s->saslPass()); - KviTalToolTip::add(m_pSaslPassEditor, __tr2qs_ctx("If you want to enable SASL authentication, insert your password here.", "options")); - pSASLLayout->addWidget(m_pSaslPassEditor, 2, 1); + KviTalToolTip::add(m_pSaslPassEditor, __tr2qs_ctx("If you want to enable SASL authentication, insert your password here. (Not required for EXTERNAL)", "options")); + pSASLLayout->addWidget(m_pSaslPassEditor, 3, 1); pSASLGroup->setEnabled(s->enabledCAP()); connect(m_pEnableCAPCheck, SIGNAL(toggled(bool)), pSASLGroup, SLOT(setEnabled(bool))); @@ -1115,10 +1130,11 @@ void IrcServerDetailsWidget::fillData(KviIrcServer * s) if(m_pEnableSTARTTLSCheck) s->setEnabledSTARTTLS(m_pEnableSTARTTLSCheck->isChecked()); + s->setSaslMethod(m_pSaslMethodComboBox->currentText()); s->setSaslNick(m_pSaslNickEditor->text()); s->setSaslPass(m_pSaslPassEditor->text()); if(m_pEnableSASLCheck) - s->setEnabledSASL(m_pEnableSASLCheck->isChecked() && !m_pSaslNickEditor->text().isEmpty() && !m_pSaslPassEditor->text().isEmpty()); + s->setEnabledSASL(m_pEnableSASLCheck->isChecked() && ((!m_pSaslNickEditor->text().isEmpty() && !m_pSaslPassEditor->text().isEmpty()) || (m_pSaslMethodComboBox->currentText() == QStringLiteral("EXTERNAL")))); if(m_pIdEditor) s->setId(m_pIdEditor->text()); if(s->id().isEmpty()) @@ -2069,7 +2085,7 @@ void OptionsWidget_servers::updateFavoritesFilter(bool bSet) { m_bShowingFavoritesOnly = bSet; IrcServerOptionsTreeWidgetItem * network; - for(unsigned i = 0; i < m_pTreeWidget->topLevelItemCount(); i++) + for(int i = 0; i < m_pTreeWidget->topLevelItemCount(); i++) { network = static_cast<IrcServerOptionsTreeWidgetItem *>(m_pTreeWidget->topLevelItem(i)); uint uServers = 0; diff --git a/src/modules/options/OptionsWidget_servers.h b/src/modules/options/OptionsWidget_servers.h index b6a2fdb68..483a01777 100644 --- a/src/modules/options/OptionsWidget_servers.h +++ b/src/modules/options/OptionsWidget_servers.h @@ -154,6 +154,7 @@ protected: QLineEdit * m_pPortEditor; QStringList m_lstChannels; KviChannelListSelector * m_pChannelListSelector; + QComboBox * m_pSaslMethodComboBox; QComboBox * m_pProxyEditor; protected slots: @@ -193,18 +194,15 @@ protected: QMenu * m_pImportPopup; KviIrcServer * m_pClipboard; QPushButton * m_pConnectCurrent; - QPushButton * m_pConnectNew; IrcServerOptionsTreeWidgetItem * m_pLastEditedItem; IrcServerDetailsWidget * m_pServerDetailsDialog; IrcNetworkDetailsWidget * m_pNetworkDetailsDialog; KviMexServerImport * m_pImportFilter; KviBoolSelector * m_pShowThisDialogAtStartupSelector; - KviBoolSelector * m_pShowFavoritesOnly; QToolButton * m_pNewServerButton; QToolButton * m_pNewNetworkButton; QToolButton * m_pRemoveButton; - QToolButton * m_pFavoriteServer; QToolButton * m_pCopyServerButton; QToolButton * m_pPasteServerButton; QToolButton * m_pImportButton; diff --git a/src/modules/options/OptionsWidget_sound.cpp b/src/modules/options/OptionsWidget_sound.cpp index e5c72ef1f..4b84b3e41 100644 --- a/src/modules/options/OptionsWidget_sound.cpp +++ b/src/modules/options/OptionsWidget_sound.cpp @@ -218,25 +218,18 @@ void OptionsWidget_soundGeneral::mediaAutoDetect() void OptionsWidget_soundGeneral::soundFillBox() { QStringList l; - QStringList::Iterator it; - int cnt; - int i; + unsigned int cnt, i; KviModule * m = g_pModuleManager->getModule("snd"); - if(!m) - goto disable; - - if(!m->ctrl("getAvailableSoundSystems", &l)) + if(!m || !m->ctrl("getAvailableSoundSystems", &l)) goto disable; m_pSoundSystemBox->clear(); - for(it = l.begin(); it != l.end(); ++it) - { - m_pSoundSystemBox->addItem(*it); - } - cnt = m_pSoundSystemBox->count(); + for(const auto& it : l) + m_pSoundSystemBox->addItem(it); + cnt = m_pSoundSystemBox->count(); for(i = 0; i < cnt; i++) { QString t = m_pSoundSystemBox->itemText(i); @@ -258,22 +251,18 @@ disable: void OptionsWidget_soundGeneral::mediaFillBox() { QStringList l; - QStringList::Iterator it; - int cnt; - int i; + unsigned int cnt, i; KviModule * m = g_pModuleManager->getModule("mediaplayer"); - if(!m) - goto disable; - if(!m->ctrl("getAvailableMediaPlayers", &l)) + if(!m || !m->ctrl("getAvailableMediaPlayers", &l)) goto disable; + m_pMediaPlayerBox->clear(); - for(it = l.begin(); it != l.end(); ++it) - { - m_pMediaPlayerBox->addItem(*it); - } - cnt = m_pMediaPlayerBox->count(); + for(const auto& it : l) + m_pMediaPlayerBox->addItem(it); + + cnt = m_pMediaPlayerBox->count(); for(i = 0; i < cnt; i++) { QString t = m_pMediaPlayerBox->itemText(i); diff --git a/src/modules/options/OptionsWidget_sound.h b/src/modules/options/OptionsWidget_sound.h index 06f7c2920..82e1abb8e 100644 --- a/src/modules/options/OptionsWidget_sound.h +++ b/src/modules/options/OptionsWidget_sound.h @@ -72,8 +72,8 @@ protected: protected: void soundFillBox(); void mediaFillBox(); - virtual void commit(); - virtual void showEvent(QShowEvent * e); + void commit() override; + void showEvent(QShowEvent * e) override; protected slots: void soundTest(); void soundAutoDetect(); diff --git a/src/modules/options/OptionsWidget_textIcons.h b/src/modules/options/OptionsWidget_textIcons.h index e1b78f2ba..bcfcfc80b 100644 --- a/src/modules/options/OptionsWidget_textIcons.h +++ b/src/modules/options/OptionsWidget_textIcons.h @@ -67,7 +67,7 @@ public: protected: QTableWidget * m_pTable; int m_iLastEditedRow; - TextIconTableItem * m_pCurrentItem; + TextIconTableItem * m_pCurrentItem = nullptr; QPushButton * m_pAdd; QPushButton * m_pDel; QPushButton * m_pRestore; diff --git a/src/modules/options/OptionsWidget_userList.cpp b/src/modules/options/OptionsWidget_userList.cpp index a1d0e2aa0..c43becd72 100644 --- a/src/modules/options/OptionsWidget_userList.cpp +++ b/src/modules/options/OptionsWidget_userList.cpp @@ -223,7 +223,7 @@ OptionsWidget_userListFeatures::OptionsWidget_userListFeatures(QWidget * parent) KviUIntSelector * u; - u = addUIntSelector(0, 0, 0, 0, __tr2qs_ctx("Minimum width:", "options"), KviOption_uintUserListMinimumWidth, 100, 1024, 150); + u = addUIntSelector(0, 0, 0, 0, __tr2qs_ctx("Minimum width:", "options"), KviOption_uintUserListMinimumWidth, 50, 1024, 150); u->setSuffix(__tr2qs_ctx(" pixels", "options")); mergeTip(u, __tr2qs_ctx("Here you can select a desired minimum width for the userlist when visible. " "Suggested values range between 120 and 170 pixels. " diff --git a/src/modules/options/OptionsWidget_windowList.cpp b/src/modules/options/OptionsWidget_windowList.cpp index 3367b569c..9842e7ac5 100644 --- a/src/modules/options/OptionsWidget_windowList.cpp +++ b/src/modules/options/OptionsWidget_windowList.cpp @@ -26,6 +26,7 @@ #include "kvi_settings.h" #include "KviLocale.h" +#define _WANT_OPTION_FLAGS_ #include "KviOptions.h" OptionsWidget_windowList::OptionsWidget_windowList(QWidget * parent) @@ -34,7 +35,14 @@ OptionsWidget_windowList::OptionsWidget_windowList(QWidget * parent) setObjectName("windowlist_options_widget"); createLayout(); - addBoolSelector(0, 0, 0, 0, __tr2qs_ctx("Show tree window list", "options"), KviOption_boolUseTreeWindowList); + KviTalHBox * hbox = new KviTalHBox(this); + (void)new QLabel(__tr2qs_ctx("Window list type:", "options"), hbox); + m_pWindowListType = new QComboBox(hbox); + m_pWindowListType->addItem(__tr2qs_ctx("Tree", "options")); + m_pWindowListType->addItem(__tr2qs_ctx("Classic", "options")); + m_pWindowListType->setCurrentIndex(KVI_OPTION_BOOL(KviOption_boolUseTreeWindowList) ? 0 : 1); + addWidgetToLayout(hbox, 0, 0, 0, 0); + addBoolSelector(0, 1, 0, 1, __tr2qs_ctx("Sort windows by name", "options"), KviOption_boolSortWindowListItemsByName); addBoolSelector(0, 2, 0, 2, __tr2qs_ctx("Show window icons in window list", "options"), KviOption_boolUseWindowListIcons); KviBoolSelector * b = addBoolSelector(0, 3, 0, 3, __tr2qs_ctx("Show activity meter in window list", "options"), KviOption_boolUseWindowListActivityMeter); @@ -47,17 +55,26 @@ OptionsWidget_windowList::OptionsWidget_windowList(QWidget * parent) "activity causes the indicator to be shaded blue.", "options")); addBoolSelector(0, 4, 0, 4, __tr2qs_ctx("Show IRC context indicator in window list", "options"), KviOption_boolUseWindowListIrcContextIndicator); - addBoolSelector(0, 5, 0, 5, __tr2qs_ctx("Show close button on window list items", "options"), KviOption_boolUseWindowListCloseButton); - addBoolSelector(0, 6, 0, 6, __tr2qs_ctx("Enable window tooltips", "options"), KviOption_boolShowWindowListToolTips); - addBoolSelector(0, 7, 0, 7, __tr2qs_ctx("Allow the window list to be moved", "options"), KviOption_boolShowTreeWindowListHandle); - addBoolSelector(0, 8, 0, 8, __tr2qs_ctx("Show user flag for channels", "options"), KviOption_boolShowUserFlagForChannelsInWindowList); + addBoolSelector(0, 5, 0, 5, __tr2qs_ctx("Enable window tooltips", "options"), KviOption_boolShowWindowListToolTips); + addBoolSelector(0, 6, 0, 6, __tr2qs_ctx("Allow the window list to be moved", "options"), KviOption_boolShowTreeWindowListHandle); + addBoolSelector(0, 7, 0, 7, __tr2qs_ctx("Show user flag for channels", "options"), KviOption_boolShowUserFlagForChannelsInWindowList); - addRowSpacer(0, 9, 0, 9); + addRowSpacer(0, 8, 0, 8); } OptionsWidget_windowList::~OptionsWidget_windowList() = default; +void OptionsWidget_windowList::commit() +{ + // we need to add this flag manually to the reset list because there's no other + // option in this options widget that uses it. + mergeResetFlag(KviOption_resetUpdateWindowList); + KVI_OPTION_BOOL(KviOption_boolUseTreeWindowList) = (m_pWindowListType->currentIndex() == 0); + + KviOptionsWidget::commit(); +} + OptionsWidget_windowListTree::OptionsWidget_windowListTree(QWidget * parent) : KviOptionsWidget(parent) { @@ -235,8 +252,9 @@ OptionsWidget_windowListClassic::OptionsWidget_windowListClassic(QWidget * paren u = addUIntSelector(0, 5, 0, 5, __tr2qs_ctx("Maximum width of buttons:", "options"), KviOption_uintClassicWindowListMaximumButtonWidth, 24, 9999, 100); u->setSuffix(__tr2qs_ctx(" pixels", "options")); addBoolSelector(0, 6, 0, 6, __tr2qs_ctx("Use flat buttons", "options"), KviOption_boolUseFlatClassicWindowListButtons); + addBoolSelector(0, 7, 0, 7, __tr2qs_ctx("Show close button on window list items", "options"), KviOption_boolUseWindowListCloseButton); - addRowSpacer(0, 7, 0, 7); + addRowSpacer(0, 8, 0, 8); } OptionsWidget_windowListClassic::~OptionsWidget_windowListClassic() diff --git a/src/modules/options/OptionsWidget_windowList.h b/src/modules/options/OptionsWidget_windowList.h index c666f8a62..a7fcbe88e 100644 --- a/src/modules/options/OptionsWidget_windowList.h +++ b/src/modules/options/OptionsWidget_windowList.h @@ -40,6 +40,12 @@ class OptionsWidget_windowList : public KviOptionsWidget public: OptionsWidget_windowList(QWidget * parent); ~OptionsWidget_windowList(); + +protected: + void commit() override; + +private: + QComboBox * m_pWindowListType; }; #define KVI_OPTIONS_WIDGET_ICON_OptionsWidget_windowListTree KviIconManager::TreeWindowList diff --git a/src/modules/options/mkcreateinstanceproc.sh b/src/modules/options/mkcreateinstanceproc.sh index 1bd42fb2e..d1c33c518 100755 --- a/src/modules/options/mkcreateinstanceproc.sh +++ b/src/modules/options/mkcreateinstanceproc.sh @@ -54,10 +54,8 @@ cat >> OptionsInstanceManager.h <<EOF #include "KviQString.h" #include "KviIconManager.h" -typedef struct _OptionsWidgetInstanceEntry OptionsWidgetInstanceEntry; - -typedef struct _OptionsWidgetInstanceEntry +struct OptionsWidgetInstanceEntry { KviOptionsWidget * (*createProc)(QWidget *); KviOptionsWidget * pWidget; // singleton @@ -73,7 +71,7 @@ typedef struct _OptionsWidgetInstanceEntry bool bIsNotContained; KviPointerList<OptionsWidgetInstanceEntry> * pChildList; bool bDoInsert; // a helper for OptionsDialog::fillListView() -} OptionsWidgetInstanceEntry; +}; class OptionsInstanceManager : public QObject @@ -231,7 +229,7 @@ printclass() echo "$3 e$1 = new OptionsWidgetInstanceEntry;" >> $TARGET echo -n "$3 e$1->createProc = &class$2" >> $TARGET echo "_createInstanceProc;" >> $TARGET - echo "$3 e$1->pWidget = 0;" >> $TARGET + echo "$3 e$1->pWidget = nullptr;" >> $TARGET echo "$3 e$1->szClassName = g_szClassName_$2;" >> $TARGET echo "$3 e$1->eIcon = KVI_OPTIONS_WIDGET_ICON_$2;" >> $TARGET @@ -290,7 +288,7 @@ addchildren() NEXTLEVEL=`expr $1 + 1` addchildren $NEXTLEVEL $achild "$3 " else - echo "$3 e$1->pChildList = 0;" >> $TARGET + echo "$3 e$1->pChildList = nullptr;" >> $TARGET fi done fi @@ -318,7 +316,7 @@ void OptionsInstanceManager::deleteInstanceTree(KviPointerList<OptionsWidgetInst { disconnect(pEntry->pWidget,SIGNAL(destroyed()),this,SLOT(widgetDestroyed())); delete pEntry->pWidget->parent(); - pEntry->pWidget = 0; + pEntry->pWidget = nullptr; } else { qDebug("Ops...i have deleted the options dialog ?"); } @@ -339,14 +337,14 @@ OptionsInstanceManager::~OptionsInstanceManager() void OptionsInstanceManager::cleanup(KviModule *) { deleteInstanceTree(m_pInstanceTree); - m_pInstanceTree = 0; + m_pInstanceTree = nullptr; } void OptionsInstanceManager::widgetDestroyed() { OptionsWidgetInstanceEntry * pEntry = findInstanceEntry(sender(),m_pInstanceTree); if(pEntry) - pEntry->pWidget = 0; + pEntry->pWidget = nullptr; if(g_iOptionWidgetInstances > 0) g_iOptionWidgetInstances--; @@ -355,7 +353,7 @@ void OptionsInstanceManager::widgetDestroyed() KviOptionsWidget * OptionsInstanceManager::getInstance(OptionsWidgetInstanceEntry * pEntry, QWidget * pPar) { if(!pEntry) - return NULL; + return nullptr; #if 0 if(pEntry->pWidget) @@ -365,7 +363,7 @@ KviOptionsWidget * OptionsInstanceManager::getInstance(OptionsWidgetInstanceEntr QWidget * pOldPar = (QWidget *)pEntry->pWidget->parent(); pEntry->pWidget->setParent(pPar); pOldPar->deleteLater(); - pEntry->pWidget = 0; + pEntry->pWidget = nullptr; } } #endif diff --git a/src/modules/package/libkvipackage.cpp b/src/modules/package/libkvipackage.cpp index 678df3230..9a390bf90 100644 --- a/src/modules/package/libkvipackage.cpp +++ b/src/modules/package/libkvipackage.cpp @@ -37,7 +37,7 @@ #include <QFile> #include <QFileInfo> -#include <stdlib.h> +#include <cstdlib> static QString createRandomDir() { @@ -154,7 +154,7 @@ static bool package_kvs_fnc_info(KviKvsModuleFunctionCall * c) QStringList sl = KviFileUtils::getFileListing(szUnpackPath); - Q_FOREACH(QString fn, sl) + for(const auto & fn : sl) pFilesArray->append(new KviKvsVariant(fn)); // delete the random tmp dir diff --git a/src/modules/perlcore/libkviperlcore.cpp b/src/modules/perlcore/libkviperlcore.cpp index fcd66152b..3fdd42def 100644 --- a/src/modules/perlcore/libkviperlcore.cpp +++ b/src/modules/perlcore/libkviperlcore.cpp @@ -270,13 +270,10 @@ bool KviPerlInterpreter::execute( int idx = 0; for(auto tmp : args) { - const char * val = tmp.toUtf8().data(); - if(val) - { - pArg = newSVpv(val, tmp.length()); - if(!av_store(pArgs, idx, pArg)) - SvREFCNT_dec(pArg); - } + QByteArray szVal = tmp.toUtf8(); + pArg = newSVpv(szVal.data(), tmp.length()); + if(!av_store(pArgs, idx, pArg)) + SvREFCNT_dec(pArg); idx++; } } diff --git a/src/modules/perlcore/perlcoreinterface.h b/src/modules/perlcore/perlcoreinterface.h index 3f904345a..bfaf089f9 100644 --- a/src/modules/perlcore/perlcoreinterface.h +++ b/src/modules/perlcore/perlcoreinterface.h @@ -32,7 +32,7 @@ #define KVI_PERLCORECTRLCOMMAND_EXECUTE "execute" -typedef struct _KviPerlCoreCtrlCommand_execute +struct KviPerlCoreCtrlCommand_execute { unsigned int uSize; KviKvsRunTimeContext * pKvsContext; @@ -44,14 +44,14 @@ typedef struct _KviPerlCoreCtrlCommand_execute QStringList lWarnings; QStringList lArgs; bool bQuiet; -} KviPerlCoreCtrlCommand_execute; +}; #define KVI_PERLCORECTRLCOMMAND_DESTROY "destroy" -typedef struct _KviPerlCoreCtrlCommand_destroy +struct KviPerlCoreCtrlCommand_destroy { unsigned int uSize; QString szContext; -} KviPerlCoreCtrlCommand_destroy; +}; #endif // !_PERLCOREINTERFACE_H_ diff --git a/src/modules/perlcore/ppport.h b/src/modules/perlcore/ppport.h index 3a17f47d6..00c15fdbd 100644 --- a/src/modules/perlcore/ppport.h +++ b/src/modules/perlcore/ppport.h @@ -4,9 +4,9 @@ /* ---------------------------------------------------------------------- - ppport.h -- Perl/Pollution/Portability Version 3.36 + ppport.h -- Perl/Pollution/Portability Version 3.42 - Automatically created by Devel::PPPort running under perl 5.026000. + Automatically created by Devel::PPPort running under perl 5.028000. Version 3.x, Copyright (c) 2004-2013, Marcus Holland-Moritz. @@ -23,8 +23,8 @@ SKIP if (@ARGV && $ARGV[0] eq '--unstrip') { eval { require Devel::PPPort }; $@ and die "Cannot require Devel::PPPort, please install.\n"; - if (eval $Devel::PPPort::VERSION < 3.36) { - die "ppport.h was originally generated with Devel::PPPort 3.36.\n" + if (eval $Devel::PPPort::VERSION < 3.42) { + die "ppport.h was originally generated with Devel::PPPort 3.42.\n" . "Your Devel::PPPort is only version $Devel::PPPort::VERSION.\n" . "Please install a newer version, or --unstrip will not work.\n"; } @@ -63,8 +63,8 @@ __DATA__*/ #define PERL_SUBVERSION SUBVERSION #endif #endif -#define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) -#define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION)) +#define D_PPP_DEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) +#define PERL_BCDVERSION ((D_PPP_DEC2BCD(PERL_REVISION)<<24)|(D_PPP_DEC2BCD(PERL_VERSION)<<12)|D_PPP_DEC2BCD(PERL_SUBVERSION)) #if PERL_REVISION != 5 #error ppport.h only works with Perl version 5 #endif @@ -503,9 +503,123 @@ sv_setnv(sv, (double)TeMpUv); \ #ifndef Newxz #define Newxz(v,n,t) Newz(0,v,n,t) #endif +#ifndef PERL_MAGIC_sv +#define PERL_MAGIC_sv '\0' +#endif +#ifndef PERL_MAGIC_overload +#define PERL_MAGIC_overload 'A' +#endif +#ifndef PERL_MAGIC_overload_elem +#define PERL_MAGIC_overload_elem 'a' +#endif +#ifndef PERL_MAGIC_overload_table +#define PERL_MAGIC_overload_table 'c' +#endif +#ifndef PERL_MAGIC_bm +#define PERL_MAGIC_bm 'B' +#endif +#ifndef PERL_MAGIC_regdata +#define PERL_MAGIC_regdata 'D' +#endif +#ifndef PERL_MAGIC_regdatum +#define PERL_MAGIC_regdatum 'd' +#endif +#ifndef PERL_MAGIC_env +#define PERL_MAGIC_env 'E' +#endif +#ifndef PERL_MAGIC_envelem +#define PERL_MAGIC_envelem 'e' +#endif +#ifndef PERL_MAGIC_fm +#define PERL_MAGIC_fm 'f' +#endif +#ifndef PERL_MAGIC_regex_global +#define PERL_MAGIC_regex_global 'g' +#endif +#ifndef PERL_MAGIC_isa +#define PERL_MAGIC_isa 'I' +#endif +#ifndef PERL_MAGIC_isaelem +#define PERL_MAGIC_isaelem 'i' +#endif +#ifndef PERL_MAGIC_nkeys +#define PERL_MAGIC_nkeys 'k' +#endif +#ifndef PERL_MAGIC_dbfile +#define PERL_MAGIC_dbfile 'L' +#endif +#ifndef PERL_MAGIC_dbline +#define PERL_MAGIC_dbline 'l' +#endif +#ifndef PERL_MAGIC_mutex +#define PERL_MAGIC_mutex 'm' +#endif +#ifndef PERL_MAGIC_shared +#define PERL_MAGIC_shared 'N' +#endif +#ifndef PERL_MAGIC_shared_scalar +#define PERL_MAGIC_shared_scalar 'n' +#endif +#ifndef PERL_MAGIC_collxfrm +#define PERL_MAGIC_collxfrm 'o' +#endif +#ifndef PERL_MAGIC_tied +#define PERL_MAGIC_tied 'P' +#endif +#ifndef PERL_MAGIC_tiedelem +#define PERL_MAGIC_tiedelem 'p' +#endif +#ifndef PERL_MAGIC_tiedscalar +#define PERL_MAGIC_tiedscalar 'q' +#endif #ifndef PERL_MAGIC_qr #define PERL_MAGIC_qr 'r' #endif +#ifndef PERL_MAGIC_sig +#define PERL_MAGIC_sig 'S' +#endif +#ifndef PERL_MAGIC_sigelem +#define PERL_MAGIC_sigelem 's' +#endif +#ifndef PERL_MAGIC_taint +#define PERL_MAGIC_taint 't' +#endif +#ifndef PERL_MAGIC_uvar +#define PERL_MAGIC_uvar 'U' +#endif +#ifndef PERL_MAGIC_uvar_elem +#define PERL_MAGIC_uvar_elem 'u' +#endif +#ifndef PERL_MAGIC_vstring +#define PERL_MAGIC_vstring 'V' +#endif +#ifndef PERL_MAGIC_vec +#define PERL_MAGIC_vec 'v' +#endif +#ifndef PERL_MAGIC_utf8 +#define PERL_MAGIC_utf8 'w' +#endif +#ifndef PERL_MAGIC_substr +#define PERL_MAGIC_substr 'x' +#endif +#ifndef PERL_MAGIC_defelem +#define PERL_MAGIC_defelem 'y' +#endif +#ifndef PERL_MAGIC_glob +#define PERL_MAGIC_glob '*' +#endif +#ifndef PERL_MAGIC_arylen +#define PERL_MAGIC_arylen '#' +#endif +#ifndef PERL_MAGIC_pos +#define PERL_MAGIC_pos '.' +#endif +#ifndef PERL_MAGIC_backref +#define PERL_MAGIC_backref '<' +#endif +#ifndef PERL_MAGIC_ext +#define PERL_MAGIC_ext '~' +#endif #ifndef cBOOL #define cBOOL(cbool) ((cbool) ? (bool)1 : (bool)0) #endif @@ -524,6 +638,9 @@ sv_setnv(sv, (double)TeMpUv); \ #ifndef OpMAYBESIB_set #define OpMAYBESIB_set(o, sib, parent) ((o)->op_sibling = (sib)) #endif +#ifndef HEf_SVKEY +#define HEf_SVKEY -2 +#endif #ifndef SvRX #if defined(NEED_SvRX) static void * DPPP_(my_SvRX)(pTHX_ SV *rv); @@ -531,11 +648,11 @@ static #else extern void * DPPP_(my_SvRX)(pTHX_ SV *rv); #endif +#if defined(NEED_SvRX) || defined(NEED_SvRX_GLOBAL) #ifdef SvRX #undef SvRX #endif #define SvRX(a) DPPP_(my_SvRX)(aTHX_ a) -#if defined(NEED_SvRX) || defined(NEED_SvRX_GLOBAL) void * DPPP_(my_SvRX)(pTHX_ SV *rv) { @@ -820,7 +937,8 @@ typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*); #if (PERL_BCDVERSION < 0x5010000) #undef isPRINT #endif -#ifdef HAS_QUAD +#ifndef WIDEST_UTYPE +#ifdef QUADKIND #ifdef U64TYPE #define WIDEST_UTYPE U64TYPE #else @@ -829,6 +947,7 @@ typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*); #else #define WIDEST_UTYPE U32 #endif +#endif #ifndef isALNUMC #define isALNUMC(c) (isALPHA(c) || isDIGIT(c)) #endif @@ -864,6 +983,240 @@ SvUTF8(HeKEY_sv(he)) : \ #ifndef C_ARRAY_END #define C_ARRAY_END(a) ((a) + C_ARRAY_LENGTH(a)) #endif +#ifndef MUTABLE_PTR +#if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) +#define MUTABLE_PTR(p) ({ void *_p = (p); _p; }) +#else +#define MUTABLE_PTR(p) ((void *) (p)) +#endif +#endif +#ifndef MUTABLE_SV +#define MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p)) +#endif +#ifdef NEED_mess_sv +#define NEED_mess +#endif +#ifdef NEED_mess +#define NEED_mess_nocontext +#define NEED_vmess +#endif +#ifndef croak_sv +#if (PERL_BCDVERSION >= 0x5007003) || ( (PERL_BCDVERSION >= 0x5006001) && (PERL_BCDVERSION < 0x5007000) ) +#if ( (PERL_BCDVERSION >= 0x5008000) && (PERL_BCDVERSION < 0x5008009) ) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5010001) ) +#define D_PPP_FIX_UTF8_ERRSV(errsv, sv) \ +STMT_START { \ +if (sv != ERRSV) \ +SvFLAGS(ERRSV) = (SvFLAGS(ERRSV) & ~SVf_UTF8) | \ +(SvFLAGS(sv) & SVf_UTF8); \ +} STMT_END +#else +#define D_PPP_FIX_UTF8_ERRSV(errsv, sv) STMT_START {} STMT_END +#endif +#define croak_sv(sv) \ +STMT_START { \ +if (SvROK(sv)) { \ +sv_setsv(ERRSV, sv); \ +croak(NULL); \ +} else { \ +D_PPP_FIX_UTF8_ERRSV(ERRSV, sv); \ +croak("%" SVf, SVfARG(sv)); \ +} \ +} STMT_END +#elif (PERL_BCDVERSION >= 0x5004000) +#define croak_sv(sv) croak("%" SVf, SVfARG(sv)) +#else +#define croak_sv(sv) croak("%s", SvPV_nolen(sv)) +#endif +#endif +#ifndef die_sv +#if defined(NEED_die_sv) +static OP * DPPP_(my_die_sv)(pTHX_ SV *sv); +static +#else +extern OP * DPPP_(my_die_sv)(pTHX_ SV *sv); +#endif +#if defined(NEED_die_sv) || defined(NEED_die_sv_GLOBAL) +#ifdef die_sv +#undef die_sv +#endif +#define die_sv(a) DPPP_(my_die_sv)(aTHX_ a) +#define Perl_die_sv DPPP_(my_die_sv) +OP * +DPPP_(my_die_sv)(pTHX_ SV *sv) +{ +croak_sv(sv); +return (OP *)NULL; +} +#endif +#endif +#ifndef warn_sv +#if (PERL_BCDVERSION >= 0x5004000) +#define warn_sv(sv) warn("%" SVf, SVfARG(sv)) +#else +#define warn_sv(sv) warn("%s", SvPV_nolen(sv)) +#endif +#endif +#ifndef vmess +#if defined(NEED_vmess) +static SV * DPPP_(my_vmess)(pTHX_ const char * pat, va_list * args); +static +#else +extern SV * DPPP_(my_vmess)(pTHX_ const char * pat, va_list * args); +#endif +#if defined(NEED_vmess) || defined(NEED_vmess_GLOBAL) +#ifdef vmess +#undef vmess +#endif +#define vmess(a,b) DPPP_(my_vmess)(aTHX_ a,b) +#define Perl_vmess DPPP_(my_vmess) +SV* +DPPP_(my_vmess)(pTHX_ const char* pat, va_list* args) +{ +mess(pat, args); +return PL_mess_sv; +} +#endif +#endif +#if (PERL_BCDVERSION < 0x5006000) +#undef mess +#endif +#if !defined(mess_nocontext) && !defined(Perl_mess_nocontext) +#if defined(NEED_mess_nocontext) +static SV * DPPP_(my_mess_nocontext)(const char * pat, ...); +static +#else +extern SV * DPPP_(my_mess_nocontext)(const char * pat, ...); +#endif +#if defined(NEED_mess_nocontext) || defined(NEED_mess_nocontext_GLOBAL) +#define mess_nocontext DPPP_(my_mess_nocontext) +#define Perl_mess_nocontext DPPP_(my_mess_nocontext) +SV* +DPPP_(my_mess_nocontext)(const char* pat, ...) +{ +dTHX; +SV *sv; +va_list args; +va_start(args, pat); +sv = vmess(pat, &args); +va_end(args); +return sv; +} +#endif +#endif +#ifndef mess +#if defined(NEED_mess) +static SV * DPPP_(my_mess)(pTHX_ const char * pat, ...); +static +#else +extern SV * DPPP_(my_mess)(pTHX_ const char * pat, ...); +#endif +#if defined(NEED_mess) || defined(NEED_mess_GLOBAL) +#define Perl_mess DPPP_(my_mess) +SV* +DPPP_(my_mess)(pTHX_ const char* pat, ...) +{ +SV *sv; +va_list args; +va_start(args, pat); +sv = vmess(pat, &args); +va_end(args); +return sv; +} +#ifdef mess_nocontext +#define mess mess_nocontext +#else +#define mess Perl_mess_nocontext +#endif +#endif +#endif +#ifndef mess_sv +#if defined(NEED_mess_sv) +static SV * DPPP_(my_mess_sv)(pTHX_ SV * basemsg, bool consume); +static +#else +extern SV * DPPP_(my_mess_sv)(pTHX_ SV * basemsg, bool consume); +#endif +#if defined(NEED_mess_sv) || defined(NEED_mess_sv_GLOBAL) +#ifdef mess_sv +#undef mess_sv +#endif +#define mess_sv(a,b) DPPP_(my_mess_sv)(aTHX_ a,b) +#define Perl_mess_sv DPPP_(my_mess_sv) +SV * +DPPP_(my_mess_sv)(pTHX_ SV *basemsg, bool consume) +{ +SV *tmp; +SV *ret; +if (SvPOK(basemsg) && SvCUR(basemsg) && *(SvEND(basemsg)-1) == '\n') { +if (consume) +return basemsg; +ret = mess(""); +SvSetSV_nosteal(ret, basemsg); +return ret; +} +if (consume) { +sv_catsv(basemsg, mess("")); +return basemsg; +} +ret = mess(""); +tmp = newSVsv(ret); +SvSetSV_nosteal(ret, basemsg); +sv_catsv(ret, tmp); +sv_dec(tmp); +return ret; +} +#endif +#endif +#ifndef warn_nocontext +#define warn_nocontext warn +#endif +#ifndef croak_nocontext +#define croak_nocontext croak +#endif +#ifndef croak_no_modify +#define croak_no_modify() croak_nocontext("%s", PL_no_modify) +#define Perl_croak_no_modify() croak_no_modify() +#endif +#ifndef croak_memory_wrap +#if (PERL_BCDVERSION >= 0x5009002) || ( (PERL_BCDVERSION >= 0x5008006) && (PERL_BCDVERSION < 0x5009000) ) +#define croak_memory_wrap() croak_nocontext("%s", PL_memory_wrap) +#else +#define croak_memory_wrap() croak_nocontext("panic: memory wrap") +#endif +#endif +#ifndef croak_xs_usage +#if defined(NEED_croak_xs_usage) +static void DPPP_(my_croak_xs_usage)(const CV * const cv, const char * const params); +static +#else +extern void DPPP_(my_croak_xs_usage)(const CV * const cv, const char * const params); +#endif +#if defined(NEED_croak_xs_usage) || defined(NEED_croak_xs_usage_GLOBAL) +#define croak_xs_usage DPPP_(my_croak_xs_usage) +#define Perl_croak_xs_usage DPPP_(my_croak_xs_usage) +#ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE +#define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params) +#endif +void +DPPP_(my_croak_xs_usage)(const CV *const cv, const char *const params) +{ +dTHX; +const GV *const gv = CvGV(cv); +PERL_ARGS_ASSERT_CROAK_XS_USAGE; +if (gv) { +const char *const gvname = GvNAME(gv); +const HV *const stash = GvSTASH(gv); +const char *const hvname = stash ? HvNAME(stash) : NULL; +if (hvname) +croak("Usage: %s::%s(%s)", hvname, gvname, params); +else +croak("Usage: %s(%s)", gvname, params); +} else { +croak("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params); +} +} +#endif +#endif #ifndef PERL_SIGNALS_UNSAFE_FLAG #define PERL_SIGNALS_UNSAFE_FLAG 0x0001 #if (PERL_BCDVERSION < 0x5008000) @@ -1046,12 +1399,12 @@ static #else extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); #endif +#if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) #ifdef eval_pv #undef eval_pv #endif #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b) #define Perl_eval_pv DPPP_(my_eval_pv) -#if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error) { @@ -1063,8 +1416,8 @@ SvREFCNT_dec(sv); SPAGAIN; sv = POPs; PUTBACK; -if (croak_on_error && SvTRUE(GvSV(errgv))) -croak(SvPVx(GvSV(errgv), na)); +if (croak_on_error && SvTRUEx(ERRSV)) +croak_sv(ERRSV); return sv; } #endif @@ -1076,12 +1429,12 @@ static #else extern void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); #endif +#if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) #ifdef vload_module #undef vload_module #endif #define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d) #define Perl_vload_module DPPP_(my_vload_module) -#if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args) { @@ -1139,12 +1492,12 @@ static #else extern void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); #endif +#if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) #ifdef load_module #undef load_module #endif #define load_module DPPP_(my_load_module) #define Perl_load_module DPPP_(my_load_module) -#if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...) { @@ -1165,12 +1518,12 @@ static #else extern SV * DPPP_(my_newRV_noinc)(SV *sv); #endif +#if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL) #ifdef newRV_noinc #undef newRV_noinc #endif #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a) #define Perl_newRV_noinc DPPP_(my_newRV_noinc) -#if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL) SV * DPPP_(my_newRV_noinc)(SV *sv) { @@ -1187,12 +1540,12 @@ static #else extern void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); #endif +#if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) #ifdef newCONSTSUB #undef newCONSTSUB #endif #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c) #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB) -#if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) #define D_PPP_PL_copline PL_copline void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv) @@ -1379,12 +1732,12 @@ static #else extern SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); #endif +#if defined(NEED_newSV_type) || defined(NEED_newSV_type_GLOBAL) #ifdef newSV_type #undef newSV_type #endif #define newSV_type(a) DPPP_(my_newSV_type)(aTHX_ a) #define Perl_newSV_type DPPP_(my_newSV_type) -#if defined(NEED_newSV_type) || defined(NEED_newSV_type_GLOBAL) SV* DPPP_(my_newSV_type)(pTHX_ svtype const t) { @@ -1417,12 +1770,12 @@ static #else extern SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); #endif +#if defined(NEED_newSVpvn_flags) || defined(NEED_newSVpvn_flags_GLOBAL) #ifdef newSVpvn_flags #undef newSVpvn_flags #endif #define newSVpvn_flags(a,b,c) DPPP_(my_newSVpvn_flags)(aTHX_ a,b,c) #define Perl_newSVpvn_flags DPPP_(my_newSVpvn_flags) -#if defined(NEED_newSVpvn_flags) || defined(NEED_newSVpvn_flags_GLOBAL) SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags) { @@ -1449,12 +1802,12 @@ static #else extern char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); #endif +#if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL) #ifdef sv_2pvbyte #undef sv_2pvbyte #endif #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b) #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte) -#if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL) char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp) { @@ -1511,12 +1864,12 @@ static #else extern char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif +#if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL) #ifdef sv_2pv_flags #undef sv_2pv_flags #endif #define sv_2pv_flags(a,b,c) DPPP_(my_sv_2pv_flags)(aTHX_ a,b,c) #define Perl_sv_2pv_flags DPPP_(my_sv_2pv_flags) -#if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL) char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { @@ -1530,12 +1883,12 @@ static #else extern char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif +#if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL) #ifdef sv_pvn_force_flags #undef sv_pvn_force_flags #endif #define sv_pvn_force_flags(a,b,c) DPPP_(my_sv_pvn_force_flags)(aTHX_ a,b,c) #define Perl_sv_pvn_force_flags DPPP_(my_sv_pvn_force_flags) -#if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL) char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { @@ -1545,9 +1898,9 @@ return sv_pvn_force(sv, lp ? lp : &n_a); #endif #endif #if (PERL_BCDVERSION < 0x5008008) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5009003) ) -#define DPPP_SVPV_NOLEN_LP_ARG &PL_na +#define D_PPP_SVPV_NOLEN_LP_ARG &PL_na #else -#define DPPP_SVPV_NOLEN_LP_ARG 0 +#define D_PPP_SVPV_NOLEN_LP_ARG 0 #endif #ifndef SvPV_const #define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC) @@ -1570,7 +1923,7 @@ return sv_pvn_force(sv, lp ? lp : &n_a); #define SvPV_flags_const_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : \ -(const char*) sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN)) +(const char*) sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_mutable #define SvPV_flags_mutable(sv, lp, flags) \ @@ -1601,7 +1954,7 @@ sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #ifndef SvPV_force_flags_nolen #define SvPV_force_flags_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ -? SvPVX(sv) : sv_pvn_force_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags)) +? SvPVX(sv) : sv_pvn_force_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, flags)) #endif #ifndef SvPV_force_flags_mutable #define SvPV_force_flags_mutable(sv, lp, flags) \ @@ -1612,12 +1965,12 @@ sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #ifndef SvPV_nolen #define SvPV_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ -? SvPVX(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC)) +? SvPVX(sv) : sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC)) #endif #ifndef SvPV_nolen_const #define SvPV_nolen_const(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ -? SvPVX_const(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN)) +? SvPVX_const(sv) : sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN)) #endif #ifndef SvPV_nomg #define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0) @@ -1630,7 +1983,7 @@ sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_nomg_nolen #define SvPV_nomg_nolen(sv) ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ -? SvPVX(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, 0)) +? SvPVX(sv) : sv_2pv_flags(sv, D_PPP_SVPV_NOLEN_LP_ARG, 0)) #endif #ifndef SvPV_renew #define SvPV_renew(sv,n) STMT_START { SvLEN_set(sv, n); \ @@ -1693,12 +2046,12 @@ static #else extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); #endif +#if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL) #ifdef vnewSVpvf #undef vnewSVpvf #endif #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b) #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf) -#if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL) SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args) { @@ -1721,8 +2074,8 @@ static #else extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif -#define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL) +#define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg) void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { @@ -1742,9 +2095,9 @@ static #else extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif +#if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) -#if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...) { @@ -1779,8 +2132,8 @@ static #else extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif -#define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL) +#define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg) void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { @@ -1800,9 +2153,9 @@ static #else extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif +#if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) -#if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...) { @@ -1837,12 +2190,12 @@ static #else extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); #endif +#if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) #ifdef newSVpvn_share #undef newSVpvn_share #endif #define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c) #define Perl_newSVpvn_share DPPP_(my_newSVpvn_share) -#if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash) { @@ -1876,12 +2229,12 @@ static #else extern GV* DPPP_(my_gv_fetchpvn_flags)(pTHX_ const char* name, STRLEN len, int flags, int types); #endif +#if defined(NEED_gv_fetchpvn_flags) || defined(NEED_gv_fetchpvn_flags_GLOBAL) #ifdef gv_fetchpvn_flags #undef gv_fetchpvn_flags #endif #define gv_fetchpvn_flags(a,b,c,d) DPPP_(my_gv_fetchpvn_flags)(aTHX_ a,b,c,d) #define Perl_gv_fetchpvn_flags DPPP_(my_gv_fetchpvn_flags) -#if defined(NEED_gv_fetchpvn_flags) || defined(NEED_gv_fetchpvn_flags_GLOBAL) GV* DPPP_(my_gv_fetchpvn_flags)(pTHX_ const char* name, STRLEN len, int flags, int types) { char *namepv = savepvn(name, len); @@ -2064,8 +2417,8 @@ static #else extern void DPPP_(my_warner)(U32 err, const char *pat, ...); #endif -#define Perl_warner DPPP_(my_warner) #if defined(NEED_warner) || defined(NEED_warner_GLOBAL) +#define Perl_warner DPPP_(my_warner) void DPPP_(my_warner)(U32 err, const char *pat, ...) { @@ -2118,136 +2471,6 @@ warn("%s", SvPV_nolen(sv)); #ifndef SvGETMAGIC #define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END #endif -#ifndef HEf_SVKEY -#define HEf_SVKEY -2 -#endif -#ifndef MUTABLE_PTR -#if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) -#define MUTABLE_PTR(p) ({ void *_p = (p); _p; }) -#else -#define MUTABLE_PTR(p) ((void *) (p)) -#endif -#endif -#ifndef MUTABLE_SV -#define MUTABLE_SV(p) ((SV *)MUTABLE_PTR(p)) -#endif -#ifndef PERL_MAGIC_sv -#define PERL_MAGIC_sv '\0' -#endif -#ifndef PERL_MAGIC_overload -#define PERL_MAGIC_overload 'A' -#endif -#ifndef PERL_MAGIC_overload_elem -#define PERL_MAGIC_overload_elem 'a' -#endif -#ifndef PERL_MAGIC_overload_table -#define PERL_MAGIC_overload_table 'c' -#endif -#ifndef PERL_MAGIC_bm -#define PERL_MAGIC_bm 'B' -#endif -#ifndef PERL_MAGIC_regdata -#define PERL_MAGIC_regdata 'D' -#endif -#ifndef PERL_MAGIC_regdatum -#define PERL_MAGIC_regdatum 'd' -#endif -#ifndef PERL_MAGIC_env -#define PERL_MAGIC_env 'E' -#endif -#ifndef PERL_MAGIC_envelem -#define PERL_MAGIC_envelem 'e' -#endif -#ifndef PERL_MAGIC_fm -#define PERL_MAGIC_fm 'f' -#endif -#ifndef PERL_MAGIC_regex_global -#define PERL_MAGIC_regex_global 'g' -#endif -#ifndef PERL_MAGIC_isa -#define PERL_MAGIC_isa 'I' -#endif -#ifndef PERL_MAGIC_isaelem -#define PERL_MAGIC_isaelem 'i' -#endif -#ifndef PERL_MAGIC_nkeys -#define PERL_MAGIC_nkeys 'k' -#endif -#ifndef PERL_MAGIC_dbfile -#define PERL_MAGIC_dbfile 'L' -#endif -#ifndef PERL_MAGIC_dbline -#define PERL_MAGIC_dbline 'l' -#endif -#ifndef PERL_MAGIC_mutex -#define PERL_MAGIC_mutex 'm' -#endif -#ifndef PERL_MAGIC_shared -#define PERL_MAGIC_shared 'N' -#endif -#ifndef PERL_MAGIC_shared_scalar -#define PERL_MAGIC_shared_scalar 'n' -#endif -#ifndef PERL_MAGIC_collxfrm -#define PERL_MAGIC_collxfrm 'o' -#endif -#ifndef PERL_MAGIC_tied -#define PERL_MAGIC_tied 'P' -#endif -#ifndef PERL_MAGIC_tiedelem -#define PERL_MAGIC_tiedelem 'p' -#endif -#ifndef PERL_MAGIC_tiedscalar -#define PERL_MAGIC_tiedscalar 'q' -#endif -#ifndef PERL_MAGIC_qr -#define PERL_MAGIC_qr 'r' -#endif -#ifndef PERL_MAGIC_sig -#define PERL_MAGIC_sig 'S' -#endif -#ifndef PERL_MAGIC_sigelem -#define PERL_MAGIC_sigelem 's' -#endif -#ifndef PERL_MAGIC_taint -#define PERL_MAGIC_taint 't' -#endif -#ifndef PERL_MAGIC_uvar -#define PERL_MAGIC_uvar 'U' -#endif -#ifndef PERL_MAGIC_uvar_elem -#define PERL_MAGIC_uvar_elem 'u' -#endif -#ifndef PERL_MAGIC_vstring -#define PERL_MAGIC_vstring 'V' -#endif -#ifndef PERL_MAGIC_vec -#define PERL_MAGIC_vec 'v' -#endif -#ifndef PERL_MAGIC_utf8 -#define PERL_MAGIC_utf8 'w' -#endif -#ifndef PERL_MAGIC_substr -#define PERL_MAGIC_substr 'x' -#endif -#ifndef PERL_MAGIC_defelem -#define PERL_MAGIC_defelem 'y' -#endif -#ifndef PERL_MAGIC_glob -#define PERL_MAGIC_glob '*' -#endif -#ifndef PERL_MAGIC_arylen -#define PERL_MAGIC_arylen '#' -#endif -#ifndef PERL_MAGIC_pos -#define PERL_MAGIC_pos '.' -#endif -#ifndef PERL_MAGIC_backref -#define PERL_MAGIC_backref '<' -#endif -#ifndef PERL_MAGIC_ext -#define PERL_MAGIC_ext '~' -#endif #ifndef sv_catpvn_nomg #define sv_catpvn_nomg sv_catpvn #endif @@ -2379,9 +2602,9 @@ static #else extern MAGIC * DPPP_(my_mg_findext)(SV * sv, int type, const MGVTBL *vtbl); #endif +#if defined(NEED_mg_findext) || defined(NEED_mg_findext_GLOBAL) #define mg_findext DPPP_(my_mg_findext) #define Perl_mg_findext DPPP_(my_mg_findext) -#if defined(NEED_mg_findext) || defined(NEED_mg_findext_GLOBAL) MAGIC * DPPP_(my_mg_findext)(SV * sv, int type, const MGVTBL *vtbl) { if (sv) { @@ -2405,12 +2628,12 @@ static #else extern int DPPP_(my_sv_unmagicext)(pTHX_ SV * const sv, const int type, MGVTBL * vtbl); #endif +#if defined(NEED_sv_unmagicext) || defined(NEED_sv_unmagicext_GLOBAL) #ifdef sv_unmagicext #undef sv_unmagicext #endif #define sv_unmagicext(a,b,c) DPPP_(my_sv_unmagicext)(aTHX_ a,b,c) #define Perl_sv_unmagicext DPPP_(my_sv_unmagicext) -#if defined(NEED_sv_unmagicext) || defined(NEED_sv_unmagicext_GLOBAL) int DPPP_(my_sv_unmagicext)(pTHX_ SV *const sv, const int type, MGVTBL *vtbl) { @@ -2547,12 +2770,12 @@ static #else extern const PERL_CONTEXT * DPPP_(my_caller_cx)(pTHX_ I32 count, const PERL_CONTEXT **dbcxp); #endif +#if defined(NEED_caller_cx) || defined(NEED_caller_cx_GLOBAL) #ifdef caller_cx #undef caller_cx #endif #define caller_cx(a,b) DPPP_(my_caller_cx)(aTHX_ a,b) #define Perl_caller_cx DPPP_(my_caller_cx) -#if defined(NEED_caller_cx) || defined(NEED_caller_cx_GLOBAL) const PERL_CONTEXT * DPPP_(my_caller_cx)(pTHX_ I32 count, const PERL_CONTEXT **dbcxp) { @@ -2639,12 +2862,12 @@ static #else extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); #endif +#if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) #ifdef grok_numeric_radix #undef grok_numeric_radix #endif #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b) #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix) -#if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) bool DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send) { @@ -2687,12 +2910,12 @@ static #else extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); #endif +#if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) #ifdef grok_number #undef grok_number #endif #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c) #define Perl_grok_number DPPP_(my_grok_number) -#if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) int DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) { @@ -2869,12 +3092,12 @@ static #else extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif +#if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) #ifdef grok_bin #undef grok_bin #endif #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d) #define Perl_grok_bin DPPP_(my_grok_bin) -#if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) UV DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { @@ -2951,12 +3174,12 @@ static #else extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif +#if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) #ifdef grok_hex #undef grok_hex #endif #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d) #define Perl_grok_hex DPPP_(my_grok_hex) -#if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) UV DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { @@ -3034,12 +3257,12 @@ static #else extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif +#if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) #ifdef grok_oct #undef grok_oct #endif #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d) #define Perl_grok_oct DPPP_(my_grok_oct) -#if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) UV DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { @@ -3106,9 +3329,9 @@ static #else extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); #endif +#if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) #define my_snprintf DPPP_(my_my_snprintf) #define Perl_my_snprintf DPPP_(my_my_snprintf) -#if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) int DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...) { @@ -3135,9 +3358,9 @@ static #else extern int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); #endif +#if defined(NEED_my_sprintf) || defined(NEED_my_sprintf_GLOBAL) #define my_sprintf DPPP_(my_my_sprintf) #define Perl_my_sprintf DPPP_(my_my_sprintf) -#if defined(NEED_my_sprintf) || defined(NEED_my_sprintf_GLOBAL) int DPPP_(my_my_sprintf)(char *buffer, const char* pat, ...) { @@ -3171,9 +3394,9 @@ static #else extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); #endif +#if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) #define my_strlcat DPPP_(my_my_strlcat) #define Perl_my_strlcat DPPP_(my_my_strlcat) -#if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) Size_t DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size) { @@ -3196,9 +3419,9 @@ static #else extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); #endif +#if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) #define my_strlcpy DPPP_(my_my_strlcpy) #define Perl_my_strlcpy DPPP_(my_my_strlcpy) -#if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) Size_t DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size) { @@ -3262,12 +3485,12 @@ static #else extern char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); #endif +#if defined(NEED_pv_escape) || defined(NEED_pv_escape_GLOBAL) #ifdef pv_escape #undef pv_escape #endif #define pv_escape(a,b,c,d,e,f) DPPP_(my_pv_escape)(aTHX_ a,b,c,d,e,f) #define Perl_pv_escape DPPP_(my_pv_escape) -#if defined(NEED_pv_escape) || defined(NEED_pv_escape_GLOBAL) char * DPPP_(my_pv_escape)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, @@ -3362,12 +3585,12 @@ static #else extern char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); #endif +#if defined(NEED_pv_pretty) || defined(NEED_pv_pretty_GLOBAL) #ifdef pv_pretty #undef pv_pretty #endif #define pv_pretty(a,b,c,d,e,f,g) DPPP_(my_pv_pretty)(aTHX_ a,b,c,d,e,f,g) #define Perl_pv_pretty DPPP_(my_pv_pretty) -#if defined(NEED_pv_pretty) || defined(NEED_pv_pretty_GLOBAL) char * DPPP_(my_pv_pretty)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, @@ -3403,12 +3626,12 @@ static #else extern char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); #endif +#if defined(NEED_pv_display) || defined(NEED_pv_display_GLOBAL) #ifdef pv_display #undef pv_display #endif #define pv_display(a,b,c,d,e) DPPP_(my_pv_display)(aTHX_ a,b,c,d,e) #define Perl_pv_display DPPP_(my_pv_display) -#if defined(NEED_pv_display) || defined(NEED_pv_display_GLOBAL) char * DPPP_(my_pv_display)(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim) { diff --git a/src/modules/perlcore/typemap b/src/modules/perlcore/typemap index 4bfba95e9..68863a329 100644 --- a/src/modules/perlcore/typemap +++ b/src/modules/perlcore/typemap @@ -1,447 +1,36 @@ -# basic C types -int T_IV -unsigned T_UV -unsigned int T_UV -long T_IV -unsigned long T_UV -short T_IV -unsigned short T_UV -char T_CHAR -unsigned char T_U_CHAR -char * T_PV -unsigned char * T_PV -const char * T_PV -caddr_t T_PV -wchar_t * T_PV -wchar_t T_IV -# bool_t is defined in <rpc/rpc.h> -bool_t T_IV -size_t T_UV -ssize_t T_IV -time_t T_NV -unsigned long * T_OPAQUEPTR -char ** T_PACKEDARRAY -void * T_PTR -Time_t * T_PV -SV * T_SV +################################################################################ +# +# typemap -- XS type mappings not present in early perls +# +################################################################################ +# +# Version 3.x, Copyright (C) 2004-2013, Marcus Holland-Moritz. +# Version 2.x, Copyright (C) 2001, Paul Marquess. +# Version 1.x, Copyright (C) 1999, Kenneth Albanowski. +# +# This program is free software; you can redistribute it and/or +# modify it under the same terms as Perl itself. +# +################################################################################ -# These are the backwards-compatibility AV*/HV* typemaps that -# do not decrement refcounts. Locally override with -# "AV* T_AVREF_REFCOUNT_FIXED", "HV* T_HVREF_REFCOUNT_FIXED", -# "CV* T_CVREF_REFCOUNT_FIXED", "SVREF T_SVREF_REFCOUNT_FIXED", -# to get the fixed versions. -SVREF T_SVREF -CV * T_CVREF -AV * T_AVREF -HV * T_HVREF - -IV T_IV -UV T_UV +UV T_UV NV T_NV -I32 T_IV -I16 T_IV -I8 T_IV -STRLEN T_UV -U32 T_U_LONG -U16 T_U_SHORT -U8 T_UV -Result T_U_CHAR -Boolean T_BOOL -float T_FLOAT -double T_DOUBLE -SysRet T_SYSRET -SysRetLong T_SYSRET -FILE * T_STDIO -PerlIO * T_INOUT -FileHandle T_PTROBJ -InputStream T_IN -InOutStream T_INOUT -OutputStream T_OUT -bool T_BOOL +HV * T_HVREF +STRLEN T_UV -############################################################################# INPUT -T_SV - $var = $arg -T_SVREF - STMT_START { - SV* const xsub_tmp_sv = $arg; - SvGETMAGIC(xsub_tmp_sv); - if (SvROK(xsub_tmp_sv)){ - $var = SvRV(xsub_tmp_sv); - } - else{ - Perl_croak_nocontext(\"%s: %s is not a reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\"); - } - } STMT_END -T_SVREF_REFCOUNT_FIXED - STMT_START { - SV* const xsub_tmp_sv = $arg; - SvGETMAGIC(xsub_tmp_sv); - if (SvROK(xsub_tmp_sv)){ - $var = SvRV(xsub_tmp_sv); - } - else{ - Perl_croak_nocontext(\"%s: %s is not a reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\"); - } - } STMT_END -T_AVREF - STMT_START { - SV* const xsub_tmp_sv = $arg; - SvGETMAGIC(xsub_tmp_sv); - if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVAV){ - $var = (AV*)SvRV(xsub_tmp_sv); - } - else{ - Perl_croak_nocontext(\"%s: %s is not an ARRAY reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\"); - } - } STMT_END -T_AVREF_REFCOUNT_FIXED - STMT_START { - SV* const xsub_tmp_sv = $arg; - SvGETMAGIC(xsub_tmp_sv); - if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVAV){ - $var = (AV*)SvRV(xsub_tmp_sv); - } - else{ - Perl_croak_nocontext(\"%s: %s is not an ARRAY reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\"); - } - } STMT_END -T_HVREF - STMT_START { - SV* const xsub_tmp_sv = $arg; - SvGETMAGIC(xsub_tmp_sv); - if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVHV){ - $var = (HV*)SvRV(xsub_tmp_sv); - } - else{ - Perl_croak_nocontext(\"%s: %s is not a HASH reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\"); - } - } STMT_END -T_HVREF_REFCOUNT_FIXED - STMT_START { - SV* const xsub_tmp_sv = $arg; - SvGETMAGIC(xsub_tmp_sv); - if (SvROK(xsub_tmp_sv) && SvTYPE(SvRV(xsub_tmp_sv)) == SVt_PVHV){ - $var = (HV*)SvRV(xsub_tmp_sv); - } - else{ - Perl_croak_nocontext(\"%s: %s is not a HASH reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\"); - } - } STMT_END -T_CVREF - STMT_START { - HV *st; - GV *gvp; - SV * const xsub_tmp_sv = $arg; - SvGETMAGIC(xsub_tmp_sv); - $var = sv_2cv(xsub_tmp_sv, &st, &gvp, 0); - if (!$var) { - Perl_croak_nocontext(\"%s: %s is not a CODE reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\"); - } - } STMT_END -T_CVREF_REFCOUNT_FIXED - STMT_START { - HV *st; - GV *gvp; - SV * const xsub_tmp_sv = $arg; - SvGETMAGIC(xsub_tmp_sv); - $var = sv_2cv(xsub_tmp_sv, &st, &gvp, 0); - if (!$var) { - Perl_croak_nocontext(\"%s: %s is not a CODE reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\"); - } - } STMT_END -T_SYSRET - $var NOT IMPLEMENTED T_UV - $var = ($type)SvUV($arg) -T_IV - $var = ($type)SvIV($arg) -T_INT - $var = (int)SvIV($arg) -T_ENUM - $var = ($type)SvIV($arg) -T_BOOL - $var = (bool)SvTRUE($arg) -T_U_INT - $var = (unsigned int)SvUV($arg) -T_SHORT - $var = (short)SvIV($arg) -T_U_SHORT - $var = (unsigned short)SvUV($arg) -T_LONG - $var = (long)SvIV($arg) -T_U_LONG - $var = (unsigned long)SvUV($arg) -T_CHAR - $var = (char)*SvPV_nolen($arg) -T_U_CHAR - $var = (unsigned char)SvUV($arg) -T_FLOAT - $var = (float)SvNV($arg) + $var = ($type)SvUV($arg) T_NV - $var = ($type)SvNV($arg) -T_DOUBLE - $var = (double)SvNV($arg) -T_PV - $var = ($type)SvPV_nolen($arg) -T_PTR - $var = INT2PTR($type,SvIV($arg)) -T_PTRREF - if (SvROK($arg)) { - IV tmp = SvIV((SV*)SvRV($arg)); - $var = INT2PTR($type,tmp); - } - else - Perl_croak_nocontext(\"%s: %s is not a reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\") -T_REF_IV_REF - if (sv_isa($arg, \"${ntype}\")) { - IV tmp = SvIV((SV*)SvRV($arg)); - $var = *INT2PTR($type *, tmp); - } - else - Perl_croak_nocontext(\"%s: %s is not of type %s\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\", \"$ntype\") -T_REF_IV_PTR - if (sv_isa($arg, \"${ntype}\")) { - IV tmp = SvIV((SV*)SvRV($arg)); - $var = INT2PTR($type, tmp); - } - else - Perl_croak_nocontext(\"%s: %s is not of type %s\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\", \"$ntype\") -T_PTROBJ - if (SvROK($arg) && sv_derived_from($arg, \"${ntype}\")) { - IV tmp = SvIV((SV*)SvRV($arg)); - $var = INT2PTR($type,tmp); - } - else - Perl_croak_nocontext(\"%s: %s is not of type %s\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\", \"$ntype\") -T_PTRDESC - if (sv_isa($arg, \"${ntype}\")) { - IV tmp = SvIV((SV*)SvRV($arg)); - ${type}_desc = (\U${type}_DESC\E*) tmp; - $var = ${type}_desc->ptr; - } - else - Perl_croak_nocontext(\"%s: %s is not of type %s\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\", \"$ntype\") -T_REFREF - if (SvROK($arg)) { - IV tmp = SvIV((SV*)SvRV($arg)); - $var = *INT2PTR($type,tmp); - } - else - Perl_croak_nocontext(\"%s: %s is not a reference\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\") -T_REFOBJ - if (sv_isa($arg, \"${ntype}\")) { - IV tmp = SvIV((SV*)SvRV($arg)); - $var = *INT2PTR($type,tmp); - } - else - Perl_croak_nocontext(\"%s: %s is not of type %s\", - ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, - \"$var\", \"$ntype\") -T_OPAQUE - $var = *($type *)SvPV_nolen($arg) -T_OPAQUEPTR - $var = ($type)SvPV_nolen($arg) -T_PACKED - $var = XS_unpack_$ntype($arg) -T_PACKEDARRAY - $var = XS_unpack_$ntype($arg) -T_ARRAY - U32 ix_$var = $argoff; - $var = $ntype(items -= $argoff); - while (items--) { - DO_ARRAY_ELEM; - ix_$var++; - } - /* this is the number of elements in the array */ - ix_$var -= $argoff -T_STDIO - $var = PerlIO_findFILE(IoIFP(sv_2io($arg))) -T_IN - $var = IoIFP(sv_2io($arg)) -T_INOUT - $var = IoIFP(sv_2io($arg)) -T_OUT - $var = IoOFP(sv_2io($arg)) -############################################################################# -OUTPUT -T_SV - $arg = $var; -T_SVREF - $arg = newRV((SV*)$var); -T_SVREF_REFCOUNT_FIXED - $arg = newRV_noinc((SV*)$var); -T_AVREF - $arg = newRV((SV*)$var); -T_AVREF_REFCOUNT_FIXED - $arg = newRV_noinc((SV*)$var); + $var = ($type)SvNV($arg) T_HVREF - $arg = newRV((SV*)$var); -T_HVREF_REFCOUNT_FIXED - $arg = newRV_noinc((SV*)$var); -T_CVREF - $arg = newRV((SV*)$var); -T_CVREF_REFCOUNT_FIXED - $arg = newRV_noinc((SV*)$var); -T_IV - sv_setiv($arg, (IV)$var); + if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVHV) + $var = (HV*)SvRV($arg); + else + Perl_croak(aTHX_ \"$var is not a hash reference\") + +OUTPUT T_UV - sv_setuv($arg, (UV)$var); -T_INT - sv_setiv($arg, (IV)$var); -T_SYSRET - if ($var != -1) { - if ($var == 0) - sv_setpvn($arg, "0 but true", 10); - else - sv_setiv($arg, (IV)$var); - } -T_ENUM - sv_setiv($arg, (IV)$var); -T_BOOL - ${"$var" eq "RETVAL" ? \"$arg = boolSV($var);" : \"sv_setsv($arg, boolSV($var));"} -T_U_INT - sv_setuv($arg, (UV)$var); -T_SHORT - sv_setiv($arg, (IV)$var); -T_U_SHORT - sv_setuv($arg, (UV)$var); -T_LONG - sv_setiv($arg, (IV)$var); -T_U_LONG - sv_setuv($arg, (UV)$var); -T_CHAR - sv_setpvn($arg, (char *)&$var, 1); -T_U_CHAR - sv_setuv($arg, (UV)$var); -T_FLOAT - sv_setnv($arg, (double)$var); + sv_setuv($arg, (UV)$var); T_NV - sv_setnv($arg, (NV)$var); -T_DOUBLE - sv_setnv($arg, (double)$var); -T_PV - sv_setpv((SV*)$arg, $var); -T_PTR - sv_setiv($arg, PTR2IV($var)); -T_PTRREF - sv_setref_pv($arg, Nullch, (void*)$var); -T_REF_IV_REF - sv_setref_pv($arg, \"${ntype}\", (void*)new $ntype($var)); -T_REF_IV_PTR - sv_setref_pv($arg, \"${ntype}\", (void*)$var); -T_PTROBJ - sv_setref_pv($arg, \"${ntype}\", (void*)$var); -T_PTRDESC - sv_setref_pv($arg, \"${ntype}\", (void*)new\U${type}_DESC\E($var)); -T_REFREF - NOT_IMPLEMENTED -T_REFOBJ - NOT IMPLEMENTED -T_OPAQUE - sv_setpvn($arg, (char *)&$var, sizeof($var)); -T_OPAQUEPTR - sv_setpvn($arg, (char *)$var, sizeof(*$var)); -T_PACKED - XS_pack_$ntype($arg, $var); -T_PACKEDARRAY - XS_pack_$ntype($arg, $var, count_$ntype); -T_ARRAY - { - U32 ix_$var; - SSize_t extend_size = - /* The weird way this is written is because g++ is dumb - * enough to warn "comparison is always false" on something - * like: - * - * sizeof(a) > sizeof(b) && a > B_t_MAX - * - * (where the LH condition is false) - */ - (size_$var > (sizeof(size_$var) > sizeof(SSize_t) - ? SSize_t_MAX : size_$var)) - ? -1 : (SSize_t)size_$var; - EXTEND(SP, extend_size); - for (ix_$var = 0; ix_$var < size_$var; ix_$var++) { - ST(ix_$var) = sv_newmortal(); - DO_ARRAY_ELEM - } - } -T_STDIO - { - GV *gv = newGVgen("$Package"); - PerlIO *fp = PerlIO_importFILE($var,0); - if ( fp && do_open(gv, "+<&", 3, FALSE, 0, 0, fp) ) { - SV *rv = newRV_inc((SV*)gv); - rv = sv_bless(rv, GvSTASH(gv)); - ${"$var" eq "RETVAL" ? \"$arg = sv_2mortal(rv);" - : \"sv_setsv($arg, rv);\n\t\tSvREFCNT_dec_NN(rv);"} - }${"$var" ne "RETVAL" ? \" - else - sv_setsv($arg, &PL_sv_undef);\n" : \""} - } -T_IN - { - GV *gv = newGVgen("$Package"); - if ( do_open(gv, "<&", 2, FALSE, 0, 0, $var) ) { - SV *rv = newRV_inc((SV*)gv); - rv = sv_bless(rv, GvSTASH(gv)); - ${"$var" eq "RETVAL" ? \"$arg = sv_2mortal(rv);" - : \"sv_setsv($arg, rv);\n\t\tSvREFCNT_dec_NN(rv);"} - }${"$var" ne "RETVAL" ? \" - else - sv_setsv($arg, &PL_sv_undef);\n" : \""} - } -T_INOUT - { - GV *gv = newGVgen("$Package"); - if ( do_open(gv, "+<&", 3, FALSE, 0, 0, $var) ) { - SV *rv = newRV_inc((SV*)gv); - rv = sv_bless(rv, GvSTASH(gv)); - ${"$var" eq "RETVAL" ? \"$arg = sv_2mortal(rv);" - : \"sv_setsv($arg, rv);\n\t\tSvREFCNT_dec_NN(rv);"} - }${"$var" ne "RETVAL" ? \" - else - sv_setsv($arg, &PL_sv_undef);\n" : \""} - } -T_OUT - { - GV *gv = newGVgen("$Package"); - if ( do_open(gv, "+>&", 3, FALSE, 0, 0, $var) ) { - SV *rv = newRV_inc((SV*)gv); - rv = sv_bless(rv, GvSTASH(gv)); - ${"$var" eq "RETVAL" ? \"$arg = sv_2mortal(rv);" - : \"sv_setsv($arg, rv);\n\t\tSvREFCNT_dec_NN(rv);"} - }${"$var" ne "RETVAL" ? \" - else - sv_setsv($arg, &PL_sv_undef);\n" : \""} - } + sv_setnv($arg, (NV)$var); diff --git a/src/modules/perlcore/xs.inc b/src/modules/perlcore/xs.inc index 125ff0f55..5c99d114a 100644 --- a/src/modules/perlcore/xs.inc +++ b/src/modules/perlcore/xs.inc @@ -1,5 +1,5 @@ /* - * This file was generated automatically by ExtUtils::ParseXS version 3.34 from the + * This file was generated automatically by ExtUtils::ParseXS version 3.39 from the * contents of KVIrc.xs. Do not edit this file, edit KVIrc.xs instead. * * ANY CHANGES MADE HERE WILL BE LOST! diff --git a/src/modules/popupeditor/PopupEditorWindow.cpp b/src/modules/popupeditor/PopupEditorWindow.cpp index 60b7741f6..572a8e7bd 100644 --- a/src/modules/popupeditor/PopupEditorWindow.cpp +++ b/src/modules/popupeditor/PopupEditorWindow.cpp @@ -450,15 +450,10 @@ void SinglePopupEditor::customContextMenuRequested(const QPoint & pos) __tr2qs_ctx("Paste Inside", "editor"), this, SLOT(contextPasteInside())) ->setEnabled(it && bIsMenu && m_pClipboard); - bool bSeparatorInserted = false; - m_pContextPopup->addSeparator(); - bSeparatorInserted = true; m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Prologue)), __tr2qs_ctx("New Menu Prologue", "editor"), this, SLOT(contextNewPrologue())); - if(!bSeparatorInserted) - m_pContextPopup->addSeparator(); m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Epilogue)), __tr2qs_ctx("New Menu Epilogue", "editor"), this, SLOT(contextNewEpilogue())); diff --git a/src/modules/popupeditor/PopupEditorWindow.h b/src/modules/popupeditor/PopupEditorWindow.h index 127ed1994..62228bdec 100644 --- a/src/modules/popupeditor/PopupEditorWindow.h +++ b/src/modules/popupeditor/PopupEditorWindow.h @@ -104,7 +104,7 @@ public: protected: // theItem is the item above the first item that has to be inserted - void populateMenu(KviKvsPopupMenu * pop, PopupTreeWidgetItem * par, PopupTreeWidgetItem * theItem = 0); + void populateMenu(KviKvsPopupMenu * pop, PopupTreeWidgetItem * par, PopupTreeWidgetItem * theItem = nullptr); void saveLastSelectedItem(); void addItemToMenu(KviKvsPopupMenu * pop, PopupTreeWidgetItem * par); PopupTreeWidgetItem * newItem(PopupTreeWidgetItem * par, PopupTreeWidgetItem * after, PopupTreeWidgetItem::Type t); @@ -189,7 +189,7 @@ protected slots: void popupRefresh(const QString & szName); protected: - void showEvent(QShowEvent * e); + void showEvent(QShowEvent * e) override; void getExportPopupBuffer(QString & buffer, MenuTreeWidgetItem * it); private: diff --git a/src/modules/pythoncore/kvircmodule.cpp b/src/modules/pythoncore/kvircmodule.cpp index 659345d7e..8f7d15958 100644 --- a/src/modules/pythoncore/kvircmodule.cpp +++ b/src/modules/pythoncore/kvircmodule.cpp @@ -66,9 +66,8 @@ extern KviCString g_szLastReturnValue; extern QStringList g_lWarningList; extern QString g_lError; -static PyObject * PyKVIrc_echo(PyObject * pSelf, PyObject * pArgs) +static PyObject * PyKVIrc_echo(PyObject * /* pSelf */, PyObject * pArgs) { - Q_UNUSED(pSelf); const char *pcText = nullptr, *pcWinId = nullptr; KviWindow * pWnd = nullptr; int iColorSet = 0; @@ -104,9 +103,8 @@ static PyObject * PyKVIrc_echo(PyObject * pSelf, PyObject * pArgs) return Py_BuildValue("i", 1); } -static PyObject * PyKVIrc_say(PyObject * pSelf, PyObject * pArgs) +static PyObject * PyKVIrc_say(PyObject * /* pSelf */, PyObject * pArgs) { - Q_UNUSED(pSelf); const char *pcText = nullptr, *pcWinId = nullptr; KviWindow * pWnd = nullptr; @@ -143,9 +141,8 @@ static PyObject * PyKVIrc_say(PyObject * pSelf, PyObject * pArgs) return Py_BuildValue("i", 1); } -static PyObject * PyKVIrc_warning(PyObject * pSelf, PyObject * pArgs) +static PyObject * PyKVIrc_warning(PyObject * /* pSelf */, PyObject * pArgs) { - Q_UNUSED(pSelf); const char * pcText = nullptr; if(QThread::currentThread() != g_pApp->thread()) @@ -166,9 +163,8 @@ static PyObject * PyKVIrc_warning(PyObject * pSelf, PyObject * pArgs) return Py_BuildValue("i", 1); } -static PyObject * PyKVIrc_getLocal(PyObject * pSelf, PyObject * pArgs) +static PyObject * PyKVIrc_getLocal(PyObject * /* pSelf */, PyObject * pArgs) { - Q_UNUSED(pSelf); const char * szVarName = nullptr; QString tmp; @@ -197,9 +193,8 @@ static PyObject * PyKVIrc_getLocal(PyObject * pSelf, PyObject * pArgs) return nullptr; } -static PyObject * PyKVIrc_setLocal(PyObject * pSelf, PyObject * pArgs) +static PyObject * PyKVIrc_setLocal(PyObject * /* pSelf */, PyObject * pArgs) { - Q_UNUSED(pSelf); const char *szVarName = nullptr, *szVarValue = nullptr; QString tmp; @@ -228,9 +223,8 @@ static PyObject * PyKVIrc_setLocal(PyObject * pSelf, PyObject * pArgs) return nullptr; } -static PyObject * PyKVIrc_getGlobal(PyObject * pSelf, PyObject * pArgs) +static PyObject * PyKVIrc_getGlobal(PyObject * /* pSelf */, PyObject * pArgs) { - Q_UNUSED(pSelf); const char * szVarName = nullptr; QString tmp; @@ -259,9 +253,8 @@ static PyObject * PyKVIrc_getGlobal(PyObject * pSelf, PyObject * pArgs) return nullptr; } -static PyObject * PyKVIrc_setGlobal(PyObject * pSelf, PyObject * pArgs) +static PyObject * PyKVIrc_setGlobal(PyObject * /* pSelf */, PyObject * pArgs) { - Q_UNUSED(pSelf); const char *szVarName = nullptr, *szVarValue = nullptr; QString tmp; @@ -290,9 +283,8 @@ static PyObject * PyKVIrc_setGlobal(PyObject * pSelf, PyObject * pArgs) return nullptr; } -static PyObject * PyKVIrc_eval(PyObject * pSelf, PyObject * pArgs) +static PyObject * PyKVIrc_eval(PyObject * /* pSelf */, PyObject * pArgs) { - Q_UNUSED(pSelf); const char * pcCode = nullptr; KviWindow * pWnd = nullptr; char * pcRetVal = nullptr; @@ -330,9 +322,8 @@ static PyObject * PyKVIrc_eval(PyObject * pSelf, PyObject * pArgs) return Py_BuildValue("s", pcRetVal); } -static PyObject * PyKVIrc_internalWarning(PyObject * pSelf, PyObject * pArgs) +static PyObject * PyKVIrc_internalWarning(PyObject * /* pSelf */, PyObject * pArgs) { - Q_UNUSED(pSelf); const char * pcText = nullptr; if(QThread::currentThread() != g_pApp->thread()) @@ -350,9 +341,8 @@ static PyObject * PyKVIrc_internalWarning(PyObject * pSelf, PyObject * pArgs) return Py_BuildValue("i", 1); } -static PyObject * PyKVIrc_error(PyObject * pSelf, PyObject * pArgs) +static PyObject * PyKVIrc_error(PyObject * /* pSelf */, PyObject * pArgs) { - Q_UNUSED(pSelf); const char * pcText = nullptr; if(QThread::currentThread() != g_pApp->thread()) diff --git a/src/modules/pythoncore/pythoncoreinterface.h b/src/modules/pythoncore/pythoncoreinterface.h index 26b42aa1a..5dae39698 100644 --- a/src/modules/pythoncore/pythoncoreinterface.h +++ b/src/modules/pythoncore/pythoncoreinterface.h @@ -32,7 +32,7 @@ #define KVI_PYTHONCORECTRLCOMMAND_EXECUTE "execute" -typedef struct _KviPythonCoreCtrlCommand_execute +struct KviPythonCoreCtrlCommand_execute { unsigned int uSize; KviKvsRunTimeContext * pKvsContext; @@ -44,14 +44,14 @@ typedef struct _KviPythonCoreCtrlCommand_execute QStringList lWarnings; QStringList lArgs; bool bQuiet; -} KviPythonCoreCtrlCommand_execute; +}; #define KVI_PYTHONCORECTRLCOMMAND_DESTROY "destroy" -typedef struct _KviPythonCoreCtrlCommand_destroy +struct KviPythonCoreCtrlCommand_destroy { unsigned int uSize; QString szContext; -} KviPythonCoreCtrlCommand_destroy; +}; #endif // !_PYTHONCOREINTERFACE_H_ diff --git a/src/modules/raweditor/RawEditorWindow.cpp b/src/modules/raweditor/RawEditorWindow.cpp index 53364371a..c9aedb643 100644 --- a/src/modules/raweditor/RawEditorWindow.cpp +++ b/src/modules/raweditor/RawEditorWindow.cpp @@ -153,11 +153,11 @@ void RawEditorWidget::customContextMenuRequested(const QPoint & pos) m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::HandlerDisabled)), __tr2qs_ctx("&Disable Handler", "editor"), this, SLOT(toggleCurrentHandlerEnabled())); - m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Discard)), - __tr2qs_ctx("Re&move Handler", "editor"), this, SLOT(removeCurrentHandler())); + m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Discard)), + __tr2qs_ctx("Re&move Handler", "editor"), this, SLOT(removeCurrentHandler())); - m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Save)), - __tr2qs_ctx("&Export Handler to...", "editor"), this, SLOT(exportCurrentHandler())); + m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Save)), + __tr2qs_ctx("&Export Handler to...", "editor"), this, SLOT(exportCurrentHandler())); } else { diff --git a/src/modules/raweditor/RawEditorWindow.h b/src/modules/raweditor/RawEditorWindow.h index 903c76c94..dc8c42b8e 100644 --- a/src/modules/raweditor/RawEditorWindow.h +++ b/src/modules/raweditor/RawEditorWindow.h @@ -123,7 +123,7 @@ protected slots: void exportCurrentHandler(); protected: - void showEvent(QShowEvent * e); + void showEvent(QShowEvent * e) override; private: void oneTimeSetup(); @@ -140,11 +140,11 @@ protected: RawEditorWidget * m_pEditor; protected: - virtual QPixmap * myIconPtr(); - virtual void fillCaptionBuffers(); - virtual void getConfigGroupName(QString & szName); - virtual void saveProperties(KviConfigurationFile *); - virtual void loadProperties(KviConfigurationFile *); + QPixmap * myIconPtr() override; + void fillCaptionBuffers() override; + void getConfigGroupName(QString & szName) override; + void saveProperties(KviConfigurationFile *) override; + void loadProperties(KviConfigurationFile *) override; protected slots: void cancelClicked(); void okClicked(); diff --git a/src/modules/reguser/RegisteredUserEntryDialog.cpp b/src/modules/reguser/RegisteredUserEntryDialog.cpp index ef08d3b67..87b97cfeb 100644 --- a/src/modules/reguser/RegisteredUserEntryDialog.cpp +++ b/src/modules/reguser/RegisteredUserEntryDialog.cpp @@ -415,7 +415,7 @@ RegisteredUserEntryDialog::RegisteredUserEntryDialog(QWidget * p, KviRegisteredU m_pCustomColorCheck->setChecked(r->getBoolProperty("useCustomColor")); g->addWidget(m_pCustomColorCheck, 5, 0, 1, 2); - m_pCustomColorSelector = new KviColorSelector(p2, QString(), m_pCustomColor, 1); + m_pCustomColorSelector = new KviColorSelector(p2, QString(), m_pCustomColor, true); g->addWidget(m_pCustomColorSelector, 5, 2); QPushButton * pb = new QPushButton(__tr2qs_ctx("All Properties...", "register"), p2); diff --git a/src/modules/reguser/RegisteredUserEntryDialog.h b/src/modules/reguser/RegisteredUserEntryDialog.h index 36dd0d640..8bb40f72e 100644 --- a/src/modules/reguser/RegisteredUserEntryDialog.h +++ b/src/modules/reguser/RegisteredUserEntryDialog.h @@ -61,7 +61,7 @@ protected: protected: void fillData(); - virtual void closeEvent(QCloseEvent *); + void closeEvent(QCloseEvent *) override; protected slots: void okClicked(); void addClicked(); @@ -82,7 +82,7 @@ protected: QLineEdit * m_pUserEdit; QLineEdit * m_pHostEdit; - virtual void closeEvent(QCloseEvent *); + void closeEvent(QCloseEvent *) override; protected slots: void okClicked(); }; @@ -92,7 +92,7 @@ class RegisteredUserEntryDialog : public KviTalTabDialog Q_OBJECT public: RegisteredUserEntryDialog(QWidget * p, KviRegisteredUser * r, bool bModal = true); - virtual ~RegisteredUserEntryDialog(); + ~RegisteredUserEntryDialog(); protected: KviRegisteredUser * m_pUser; @@ -129,7 +129,7 @@ protected: QCheckBox * m_pIgnoreDcc; QCheckBox * m_pIgnoreHighlight; - virtual void closeEvent(QCloseEvent *); + void closeEvent(QCloseEvent *) override; protected slots: void okClicked(); void addMaskClicked(); diff --git a/src/modules/reguser/RegisteredUsersDialog.cpp b/src/modules/reguser/RegisteredUsersDialog.cpp index 907119896..5f51decd6 100644 --- a/src/modules/reguser/RegisteredUsersDialog.cpp +++ b/src/modules/reguser/RegisteredUsersDialog.cpp @@ -219,7 +219,7 @@ QSize RegisteredUsersDialogItemDelegate::sizeHint(const QStyleOptionViewItem & o //users // RegisteredUsersDialogItem *it=(RegisteredUsersDialogItem*)item; - return QSize(300, LVI_ICON_SIZE + 2 * LVI_BORDER); + return { 300, LVI_ICON_SIZE + 2 * LVI_BORDER }; } } @@ -445,9 +445,9 @@ void RegisteredUsersDialog::editGroup(KviRegisteredUserGroup * group) if(ok && !text.isEmpty()) { QString szOldGroup = group->name(); - g_pLocalRegisteredUserDataBase->groupDict()->setAutoDelete(0); + g_pLocalRegisteredUserDataBase->groupDict()->setAutoDelete(false); g_pLocalRegisteredUserDataBase->groupDict()->remove(szOldGroup); - g_pLocalRegisteredUserDataBase->groupDict()->setAutoDelete(1); + g_pLocalRegisteredUserDataBase->groupDict()->setAutoDelete(true); group->setName(text); g_pLocalRegisteredUserDataBase->groupDict()->insert(text, group); @@ -697,12 +697,12 @@ void RegisteredUsersDialog::selectionChanged() #define KVI_REGUSER_DB_FILE_MAGIC 0x5334DBDB #define KVI_REGUSER_DB_FILE_VERSION 1 -typedef struct _KviReguserDbFileHeader +struct KviReguserDbFileHeader { kvi_u32_t magic; kvi_u32_t version; kvi_u32_t nentries; -} KviReguserDbFileHeader; +}; void RegisteredUsersDialog::exportClicked() { diff --git a/src/modules/reguser/RegisteredUsersDialog.h b/src/modules/reguser/RegisteredUsersDialog.h index 5a049dc20..f6cd209ae 100644 --- a/src/modules/reguser/RegisteredUsersDialog.h +++ b/src/modules/reguser/RegisteredUsersDialog.h @@ -46,7 +46,7 @@ public: ~KviRegisteredUsersListView(){}; protected: - void mousePressEvent(QMouseEvent * e); + void mousePressEvent(QMouseEvent * e) override; signals: void rightButtonPressed(QTreeWidgetItem *, QPoint); }; @@ -54,11 +54,11 @@ signals: class RegisteredUsersDialogItemDelegate : public QStyledItemDelegate { public: - RegisteredUsersDialogItemDelegate(KviRegisteredUsersListView * pWidget = 0) + RegisteredUsersDialogItemDelegate(KviRegisteredUsersListView * pWidget = nullptr) : QStyledItemDelegate(pWidget){}; ~RegisteredUsersDialogItemDelegate(){}; - QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const; - void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const; + QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const override; + void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; }; class RegisteredUsersDialogItemBase : public QTreeWidgetItem @@ -123,7 +123,7 @@ class RegisteredUsersDialog : public QWidget { Q_OBJECT public: - RegisteredUsersDialog(QWidget * par = 0); + RegisteredUsersDialog(QWidget * par = nullptr); ~RegisteredUsersDialog(); public: @@ -141,7 +141,7 @@ protected: void fillList(); void editItem(RegisteredUsersDialogItem * i); void editGroup(KviRegisteredUserGroup * group); - virtual void closeEvent(QCloseEvent *); + void closeEvent(QCloseEvent *) override; protected slots: void cancelClicked(); void okClicked(); diff --git a/src/modules/reguser/RegistrationWizard.h b/src/modules/reguser/RegistrationWizard.h index b41ac6a06..a3cd710ed 100644 --- a/src/modules/reguser/RegistrationWizard.h +++ b/src/modules/reguser/RegistrationWizard.h @@ -43,7 +43,7 @@ class RegistrationWizard : public KviTalWizard { Q_OBJECT public: - RegistrationWizard(const QString & startMask, KviRegisteredUserDataBase * db = 0, QWidget * par = 0, bool bModal = false); + RegistrationWizard(const QString & startMask, KviRegisteredUserDataBase * db = nullptr, QWidget * par = nullptr, bool bModal = false); ~RegistrationWizard(); KviRegisteredUserDataBase * m_pDb; @@ -80,9 +80,9 @@ public: KviPixmap * m_pAvatar; protected: - virtual void showEvent(QShowEvent * e); - virtual void accept(); - virtual void reject(); + void showEvent(QShowEvent * e) override; + void accept() override; + void reject() override; protected slots: void realNameChanged(const QString & str); void maskChanged(const QString & str); diff --git a/src/modules/reguser/libkvireguser.cpp b/src/modules/reguser/libkvireguser.cpp index ebb9d6abb..a695cac9b 100644 --- a/src/modules/reguser/libkvireguser.cpp +++ b/src/modules/reguser/libkvireguser.cpp @@ -223,7 +223,7 @@ static bool reguser_kvs_cmd_add(KviKvsModuleCommandCall * c) { KviIrcMask * m = new KviIrcMask(szMask); u = g_pRegisteredUserDataBase->addMask(u, m); - if(!u) + if(u) { if(!c->hasSwitch('q', "quiet")) c->warning(__tr2qs_ctx("Mask %Q is already used to identify user %s", "register"), &szMask, u->name().toUtf8().data()); diff --git a/src/modules/rijndael/BlowFish.cpp b/src/modules/rijndael/BlowFish.cpp index e56178276..1d16a1d43 100644 --- a/src/modules/rijndael/BlowFish.cpp +++ b/src/modules/rijndael/BlowFish.cpp @@ -436,7 +436,7 @@ void BlowFish::Decrypt(SBlock & block) } //Semi-Portable Byte Shuffling -inline void BytesToBlock(unsigned char const * p, SBlock & b) +void BytesToBlock(unsigned char const * p, SBlock & b) { unsigned int y; //Left @@ -467,7 +467,7 @@ inline void BytesToBlock(unsigned char const * p, SBlock & b) b.m_uir |= y; } -inline void BlockToBytes(SBlock const & b, unsigned char * p) +void BlockToBytes(SBlock const & b, unsigned char * p) { unsigned int y; //Right diff --git a/src/modules/rijndael/InitVectorEngine.cpp b/src/modules/rijndael/InitVectorEngine.cpp index 776308260..e0ba47b36 100644 --- a/src/modules/rijndael/InitVectorEngine.cpp +++ b/src/modules/rijndael/InitVectorEngine.cpp @@ -24,7 +24,7 @@ #include "InitVectorEngine.h" -#include <stdlib.h> +#include <cstdlib> #include "KviTimeUtils.h" namespace InitVectorEngine diff --git a/src/modules/rijndael/Rijndael.h b/src/modules/rijndael/Rijndael.h index 6905397e9..95331c07a 100644 --- a/src/modules/rijndael/Rijndael.h +++ b/src/modules/rijndael/Rijndael.h @@ -145,31 +145,31 @@ protected: public: // Initializes the crypt session // Returns RIJNDAEL_SUCCESS or an error code - int init(Mode mode, Direction dir, const UINT8 * key, KeyLength keyLen, UINT8 * initVector = 0); + int init(Mode mode, Direction dir, const UINT8 * key, KeyLength keyLen, UINT8 * initVector = nullptr); // Input len is in BITS! // Encrypts inputLen / 128 blocks of input and puts it in outBuffer // outBuffer must be at least inputLen / 8 bytes long. // Returns the encrypted buffer length in BITS or an error code < 0 in case of error - int blockEncrypt(const UINT8 * input, int inputLen, UINT8 * outBuffer, UINT8 * initVector = 0); + int blockEncrypt(const UINT8 * input, int inputLen, UINT8 * outBuffer, UINT8 * initVector = nullptr); // Input len is in BYTES! // outBuffer must be at least inputLen + 16 bytes long // Returns the encrypted buffer length in BYTES or an error code < 0 in case of error - int padEncrypt(const UINT8 * input, int inputOctets, UINT8 * outBuffer, UINT8 * initVector = 0); + int padEncrypt(const UINT8 * input, int inputOctets, UINT8 * outBuffer, UINT8 * initVector = nullptr); // Input len is in BITS! // outBuffer must be at least inputLen / 8 bytes long // Returns the decrypted buffer length in BITS and an error code < 0 in case of error - int blockDecrypt(const UINT8 * input, int inputLen, UINT8 * outBuffer, UINT8 * initVector = 0); + int blockDecrypt(const UINT8 * input, int inputLen, UINT8 * outBuffer, UINT8 * initVector = nullptr); // Input len is in BYTES! // outBuffer must be at least inputLen bytes long // Returns the decrypted buffer length in BYTES and an error code < 0 in case of error - int padDecrypt(const UINT8 * input, int inputOctets, UINT8 * outBuffer, UINT8 * initVector = 0); + int padDecrypt(const UINT8 * input, int inputOctets, UINT8 * outBuffer, UINT8 * initVector = nullptr); protected: void keySched(UINT8 key[_MAX_KEY_COLUMNS][4]); void keyEncToDec(); void encrypt(const UINT8 a[16], UINT8 b[16]); void decrypt(const UINT8 a[16], UINT8 b[16]); - void updateInitVector(UINT8 * initVector = 0); + void updateInitVector(UINT8 * initVector = nullptr); }; #endif // COMPILE_CRYPT_SUPPORT diff --git a/src/modules/rijndael/libkvirijndael.h b/src/modules/rijndael/libkvirijndael.h index ef54e7ec6..eb9a371d3 100644 --- a/src/modules/rijndael/libkvirijndael.h +++ b/src/modules/rijndael/libkvirijndael.h @@ -38,7 +38,7 @@ class KviRijndaelEngine : public KviCryptEngine Q_OBJECT public: KviRijndaelEngine(); - virtual ~KviRijndaelEngine(); + ~KviRijndaelEngine(); private: enum OperationalMode @@ -71,7 +71,7 @@ class KviRijndaelHexEngine : public KviRijndaelEngine Q_OBJECT public: KviRijndaelHexEngine() : KviRijndaelEngine(){} - virtual ~KviRijndaelHexEngine(){} + ~KviRijndaelHexEngine() = default; protected: bool binaryToAscii(const char * inBuffer, int len, KviCString & outBuffer) override; @@ -83,7 +83,7 @@ class KviRijndael128HexEngine : public KviRijndaelHexEngine Q_OBJECT public: KviRijndael128HexEngine() : KviRijndaelHexEngine(){} - virtual ~KviRijndael128HexEngine(){} + ~KviRijndael128HexEngine() = default; protected: int getKeyLen() const override { return 16; } @@ -95,7 +95,7 @@ class KviRijndael192HexEngine : public KviRijndaelHexEngine Q_OBJECT public: KviRijndael192HexEngine() : KviRijndaelHexEngine(){} - virtual ~KviRijndael192HexEngine(){} + ~KviRijndael192HexEngine() = default; protected: int getKeyLen() const override { return 24; } @@ -107,7 +107,7 @@ class KviRijndael256HexEngine : public KviRijndaelHexEngine Q_OBJECT public: KviRijndael256HexEngine() : KviRijndaelHexEngine(){} - virtual ~KviRijndael256HexEngine(){} + ~KviRijndael256HexEngine() = default; protected: int getKeyLen() const override { return 32; } @@ -118,7 +118,7 @@ class KviRijndaelBase64Engine : public KviRijndaelEngine Q_OBJECT public: KviRijndaelBase64Engine() : KviRijndaelEngine(){} - virtual ~KviRijndaelBase64Engine(){} + ~KviRijndaelBase64Engine() = default; protected: bool binaryToAscii(const char * inBuffer, int len, KviCString & outBuffer) override; @@ -130,7 +130,7 @@ class KviRijndael128Base64Engine : public KviRijndaelBase64Engine Q_OBJECT public: KviRijndael128Base64Engine() : KviRijndaelBase64Engine(){} - virtual ~KviRijndael128Base64Engine(){} + ~KviRijndael128Base64Engine() = default; protected: int getKeyLen() const override { return 16; } @@ -142,7 +142,7 @@ class KviRijndael192Base64Engine : public KviRijndaelBase64Engine Q_OBJECT public: KviRijndael192Base64Engine() : KviRijndaelBase64Engine(){} - virtual ~KviRijndael192Base64Engine(){} + ~KviRijndael192Base64Engine() = default; protected: int getKeyLen() const override { return 24; } @@ -154,7 +154,7 @@ class KviRijndael256Base64Engine : public KviRijndaelBase64Engine Q_OBJECT public: KviRijndael256Base64Engine() : KviRijndaelBase64Engine(){} - virtual ~KviRijndael256Base64Engine(){} + ~KviRijndael256Base64Engine() = default; protected: int getKeyLen() const override { return 32; } @@ -169,7 +169,7 @@ class KviMircryptionEngine : public KviCryptEngine Q_OBJECT public: KviMircryptionEngine(); - virtual ~KviMircryptionEngine(); + ~KviMircryptionEngine(); protected: KviCString m_szEncryptKey; diff --git a/src/modules/setup/SetupWizard.cpp b/src/modules/setup/SetupWizard.cpp index 8ae48632f..8cef633e1 100644 --- a/src/modules/setup/SetupWizard.cpp +++ b/src/modules/setup/SetupWizard.cpp @@ -192,7 +192,7 @@ SetupWizard::SetupWizard() ed->setWordWrapMode(QTextOption::NoWrap); QString szLicense; QString szLicensePath; - g_pApp->getGlobalKvircDirectory(szLicensePath, KviApplication::License, "COPYING"); + g_pApp->getGlobalKvircDirectory(szLicensePath, KviApplication::License, "ABOUT-LICENSE"); if(!KviFileUtils::loadFile(szLicensePath, szLicense)) { szLicense = __tr("Oops! Can't find the license file.\n" @@ -806,7 +806,7 @@ void SetupWizard::makeLink() 0, KEY_QUERY_VALUE, &hCU) == ERROR_SUCCESS) { - RegQueryValueEx(hCU, TEXT("Desktop"), NULL, &lpType, + RegQueryValueEx(hCU, TEXT("Desktop"), nullptr, &lpType, (unsigned char *)&szLink, &ulSize); RegCloseKey(hCU); } @@ -819,13 +819,13 @@ void SetupWizard::makeLink() szKvircExec.append("\\kvirc.exe"); // Trigger a horrible machinery - CoInitialize(NULL); // we need COM+OLE + CoInitialize(nullptr); // we need COM+OLE // Fiddle with an obscure shell interface IShellLink * psl; // Get a pointer to the IShellLink interface: this is kinda ugly :) - if(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, + if(CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl) == S_OK) { @@ -1019,9 +1019,7 @@ void SetupWizard::accept() // Make local->global link QString localPath = QString("%1/global").arg(g_pApp->m_szLocalKvircDir); unlink(QTextCodec::codecForLocale()->fromUnicode(localPath).data()); - int dummy; // make gcc happy - dummy = symlink(QTextCodec::codecForLocale()->fromUnicode(g_pApp->m_szGlobalKvircDir).data(), QTextCodec::codecForLocale()->fromUnicode(localPath).data()); - Q_UNUSED(dummy); + (void)symlink(QTextCodec::codecForLocale()->fromUnicode(g_pApp->m_szGlobalKvircDir).data(), QTextCodec::codecForLocale()->fromUnicode(localPath).data()); #endif #ifdef COMPILE_KDE_SUPPORT diff --git a/src/modules/setup/SetupWizard.h b/src/modules/setup/SetupWizard.h index 9cec49c09..be71335a7 100644 --- a/src/modules/setup/SetupWizard.h +++ b/src/modules/setup/SetupWizard.h @@ -137,14 +137,14 @@ public: protected: void makeLink(); void setUrlHandlers(); - virtual void showEvent(QShowEvent * e); + void showEvent(QShowEvent * e) override; void enableOrDisableIdentityPageNextButton(); public slots: void chooseOldDataPath(); void chooseDataPath(); void chooseIncomingPath(); - virtual void accept(); - virtual void reject(); + void accept() override; + void reject() override; void oldDirClicked(); void newDirClicked(); diff --git a/src/modules/setup/libkvisetup.cpp b/src/modules/setup/libkvisetup.cpp index 606ca9ac6..4c576e3a8 100644 --- a/src/modules/setup/libkvisetup.cpp +++ b/src/modules/setup/libkvisetup.cpp @@ -33,10 +33,13 @@ #include "KviWindow.h" #include "KviTheme.h" #include "KviIrcServerDataBase.h" +#include "KviModuleManager.h" #include <QString> #include <QFile> +extern KVIRC_API KviModuleManager * g_pModuleManager; + // this will be chosen during the setup process QString g_szChoosenIncomingDirectory; int g_iThemeToApply = THEME_APPLY_NONE; @@ -117,6 +120,11 @@ KVIMODULEEXPORTFUNC void setup_finish() delete pParams; KVI_OPTION_BOOL(KviOption_boolShowServersConnectDialogOnStart) = true; } + + // detect the most appropriate sound system + KviModule * m = g_pModuleManager->getModule("snd"); + if(m) + m->ctrl("detectSoundSystem", nullptr); } } diff --git a/src/modules/sharedfile/libkvisharedfile.cpp b/src/modules/sharedfile/libkvisharedfile.cpp index 199c25fce..fd9cb880e 100644 --- a/src/modules/sharedfile/libkvisharedfile.cpp +++ b/src/modules/sharedfile/libkvisharedfile.cpp @@ -33,7 +33,7 @@ #include "KviMainWindow.h" #include "KviPointerHashTable.h" -#include <time.h> +#include <ctime> extern KVIRC_API KviSharedFilesManager * g_pSharedFilesManager; diff --git a/src/modules/sharedfileswindow/SharedFilesWindow.h b/src/modules/sharedfileswindow/SharedFilesWindow.h index fd9fd6dee..96de53ef3 100644 --- a/src/modules/sharedfileswindow/SharedFilesWindow.h +++ b/src/modules/sharedfileswindow/SharedFilesWindow.h @@ -57,7 +57,7 @@ class SharedFileEditDialog : public QDialog { Q_OBJECT public: - SharedFileEditDialog(QWidget * par, KviSharedFile * f = 0); + SharedFileEditDialog(QWidget * par, KviSharedFile * f = nullptr); virtual ~SharedFileEditDialog(); QDateTimeEdit * m_pExpireDateTimeEdit; diff --git a/src/modules/snd/libkvisnd.cpp b/src/modules/snd/libkvisnd.cpp index a324b91a9..4c56ab380 100644 --- a/src/modules/snd/libkvisnd.cpp +++ b/src/modules/snd/libkvisnd.cpp @@ -49,7 +49,7 @@ #include <QFile> #include <unistd.h> -#include <errno.h> +#include <cerrno> #ifdef COMPILE_ESD_SUPPORT #include <esd.h> @@ -210,22 +210,12 @@ bool KviSoundPlayer::event(QEvent * e) void KviSoundPlayer::detectSoundSystem() { -#ifdef COMPILE_PHONON_SUPPORT - // FIXME: Phonon seems to freeze on windows sometimes.. maybe it's better to auto-detect winmm ? - if(!m_pPhononPlayer) - m_pPhononPlayer = Phonon::createPlayer(Phonon::MusicCategory); - if(m_pPhononPlayer->state() != Phonon::ErrorState) - { - KVI_OPTION_STRING(KviOption_stringSoundSystem) = "phonon"; - return; - } -#endif #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) KVI_OPTION_STRING(KviOption_stringSoundSystem) = "winmm"; #else #ifdef COMPILE_ESD_SUPPORT esd_format_t format = ESD_BITS16 | ESD_STREAM | ESD_PLAY | ESD_MONO; - int esd_fd = esd_play_stream(format, 8012, NULL, "kvirc"); + int esd_fd = esd_play_stream(format, 8012, nullptr, "kvirc"); if(esd_fd >= 0) { KVI_OPTION_STRING(KviOption_stringSoundSystem) = "esd"; @@ -655,7 +645,7 @@ KviEsdSoundThread::~KviEsdSoundThread() void KviEsdSoundThread::play() { // ESD has a really nice API - if(!esd_play_file(NULL, m_szFileName.toUtf8().data(), 1)) // this is sync.. FIXME: it can't be stopped! + if(!esd_play_file(nullptr, m_szFileName.toUtf8().data(), 1)) // this is sync.. FIXME: it can't be stopped! qDebug("Could not play sound %s! [ESD]", m_szFileName.toUtf8().data()); } diff --git a/src/modules/snd/libkvisnd.h b/src/modules/snd/libkvisnd.h index 47f8ce119..38e2e03a2 100644 --- a/src/modules/snd/libkvisnd.h +++ b/src/modules/snd/libkvisnd.h @@ -170,7 +170,7 @@ protected: protected: void registerSoundThread(KviSoundThread * t); void unregisterSoundThread(KviSoundThread * t); - virtual bool event(QEvent * e); + bool event(QEvent * e) override; protected: void stopAllSoundThreads(); diff --git a/src/modules/spaste/SlowPasteController.cpp b/src/modules/spaste/SlowPasteController.cpp index 726d0cc85..8d724e766 100644 --- a/src/modules/spaste/SlowPasteController.cpp +++ b/src/modules/spaste/SlowPasteController.cpp @@ -81,7 +81,7 @@ bool SlowPasteController::pasteFileInit(QString & fileName) return true; } -bool SlowPasteController::pasteClipboardInit(void) +bool SlowPasteController::pasteClipboardInit() { if(m_pFile) return false; // can't paste clipboard while pasting a file @@ -103,7 +103,7 @@ bool SlowPasteController::pasteClipboardInit(void) return true; } -void SlowPasteController::pasteFile(void) +void SlowPasteController::pasteFile() { QString line; char data[1024]; @@ -132,7 +132,7 @@ void SlowPasteController::pasteFile(void) } } -void SlowPasteController::pasteClipboard(void) +void SlowPasteController::pasteClipboard() { if(m_pClipBuff->isEmpty() || !g_pApp->windowExists(m_pWindow)) { diff --git a/src/modules/spaste/libkvispaste.h b/src/modules/spaste/libkvispaste.h index bdd9da8a2..ab2309524 100644 --- a/src/modules/spaste/libkvispaste.h +++ b/src/modules/spaste/libkvispaste.h @@ -27,10 +27,10 @@ #include "KviWindow.h" -typedef struct _SPasteThreadData +struct SPasteThreadData { QString * strData; KviWindow * win; -} SPasteThreadData; +}; #endif diff --git a/src/modules/spellchecker/libkvispellchecker.cpp b/src/modules/spellchecker/libkvispellchecker.cpp index 8d1f218e8..abb6a52f2 100644 --- a/src/modules/spellchecker/libkvispellchecker.cpp +++ b/src/modules/spellchecker/libkvispellchecker.cpp @@ -142,8 +142,7 @@ static bool spellchecker_kvs_suggestions(KviKvsModuleFunctionCall * c) KviKvsArray * pArray = new KviKvsArray(); - QList<QString> lSuggestions = hAllSuggestions.keys(); - Q_FOREACH(QString szSuggestion, lSuggestions) + for(const auto & szSuggestion : hAllSuggestions.keys()) pArray->append(new KviKvsVariant(szSuggestion)); c->returnValue()->setArray(pArray); @@ -158,6 +157,9 @@ static void spellchecker_reload_dicts() const QStringList & wantedDictionaries = KVI_OPTION_STRINGLIST(KviOption_stringlistSpellCheckerDictionaries); foreach(QString szLang, wantedDictionaries) { + if(szLang.isEmpty()) + continue; + EnchantDict * pDict = enchant_broker_request_dict(g_pEnchantBroker, szLang.toUtf8().data()); if(pDict) { diff --git a/src/modules/str/libkvistr.cpp b/src/modules/str/libkvistr.cpp index c695be123..bd836d4a0 100644 --- a/src/modules/str/libkvistr.cpp +++ b/src/modules/str/libkvistr.cpp @@ -43,6 +43,12 @@ #include "KviSSL.h" #include <openssl/evp.h> #include <openssl/pem.h> + +#if OPENSSL_VERSION_NUMBER < 0x10100005L +#define EVP_MD_CTX_new EVP_MD_CTX_create +#define EVP_MD_CTX_free EVP_MD_CTX_destroy +#endif + #else // The fallback we can always use, but with very limited set of // functionality. @@ -1138,9 +1144,9 @@ static bool str_kvs_fnc_match(KviKvsModuleFunctionCall * c) KVSM_PARAMETER("flags", KVS_PT_STRING, KVS_PF_OPTIONAL, szFlags) KVSM_PARAMETER("case", KVS_PT_BOOL, KVS_PF_OPTIONAL, bCase) KVSM_PARAMETERS_END(c) - bool bRegExp = szFlags.indexOf('r', 0, Qt::CaseInsensitive) != -1; - bool bExact = szFlags.indexOf('e', 0, Qt::CaseInsensitive) != -1; - bool bIs = KviQString::matchString(szWildcard, szString, bRegExp, bExact, bCase ? true : false); + bool bRegExp = szFlags.contains('r', Qt::CaseInsensitive); + bool bExact = szFlags.contains('e', Qt::CaseInsensitive); + bool bIs = KviQString::matchString(szWildcard, szString, bRegExp, bExact, bCase); c->returnValue()->setBoolean(bIs); return true; } @@ -1383,7 +1389,7 @@ static bool str_kvs_fnc_digest(KviKvsModuleFunctionCall * c) if(szType.isEmpty()) szType = "md5"; - EVP_MD_CTX mdctx; + EVP_MD_CTX *mdctx; const EVP_MD * md; unsigned char md_value[EVP_MAX_MD_SIZE]; unsigned int md_len, i; @@ -1397,11 +1403,11 @@ static bool str_kvs_fnc_digest(KviKvsModuleFunctionCall * c) return true; } - EVP_MD_CTX_init(&mdctx); - EVP_DigestInit_ex(&mdctx, md, nullptr); - EVP_DigestUpdate(&mdctx, szString.toUtf8().data(), szString.toUtf8().length()); - EVP_DigestFinal_ex(&mdctx, md_value, &md_len); - EVP_MD_CTX_cleanup(&mdctx); + mdctx = EVP_MD_CTX_new(); + EVP_DigestInit_ex(mdctx, md, nullptr); + EVP_DigestUpdate(mdctx, szString.toUtf8().data(), szString.toUtf8().length()); + EVP_DigestFinal_ex(mdctx, md_value, &md_len); + EVP_MD_CTX_free(mdctx); for(i = 0; i < md_len; i++) { @@ -1470,7 +1476,7 @@ static bool str_kvs_fnc_join(KviKvsModuleFunctionCall * c) KVSM_PARAMETERS_END(c) QString szRet; - bool bSkipEmpty = szFlags.indexOf('n', 0, Qt::CaseInsensitive) != -1; + bool bSkipEmpty = szFlags.contains('n', Qt::CaseInsensitive); bool bFirst = true; @@ -1572,15 +1578,15 @@ static bool str_kvs_fnc_grep(KviKvsModuleFunctionCall * c) KviKvsArray * a = ac.array(); - bool bCaseSensitive = szFlags.indexOf('s', 0, Qt::CaseInsensitive) != -1; - bool bRegexp = szFlags.indexOf('r', 0, Qt::CaseInsensitive) != -1; - bool bWild = szFlags.indexOf('w', 0, Qt::CaseInsensitive) != -1; + bool bCaseSensitive = szFlags.contains('s', Qt::CaseInsensitive); + bool bRegexp = szFlags.contains('r', Qt::CaseInsensitive); + bool bWild = szFlags.contains('w', Qt::CaseInsensitive); // FIXME: The sub pattern matching does not belong to grep. // FIXME: DO NOT DOCUMENT FLAGS p and x (they should be removed) // 2015.08.24: Left for compatibility: remove in some years :) - bool bSubPatterns = szFlags.indexOf('p', 0, Qt::CaseInsensitive) != -1; - bool bExcludeCompleteMatch = szFlags.indexOf('x', 0, Qt::CaseInsensitive) != -1; + bool bSubPatterns = szFlags.contains('p', Qt::CaseInsensitive); + bool bExcludeCompleteMatch = szFlags.contains('x', Qt::CaseInsensitive); // 2015.08.24: End of "left for compatibility": remove in some years :) int idx = 0; @@ -1589,7 +1595,7 @@ static bool str_kvs_fnc_grep(KviKvsModuleFunctionCall * c) int i = 0; if(bRegexp || bWild) { - QRegExp re(szMatch, bCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive, bRegexp ? QRegExp::RegExp : QRegExp::Wildcard); + QRegExp re(szMatch, bCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive, bRegexp ? QRegExp::RegExp2 : QRegExp::Wildcard); while(idx < cnt) { KviKvsVariant * v = a->at(idx); @@ -1642,7 +1648,7 @@ static bool str_kvs_fnc_grep(KviKvsModuleFunctionCall * c) { QString sz; v->asString(sz); - if(sz.indexOf(szMatch, 0, bCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive) != -1) + if(sz.contains(szMatch, bCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive)) { n->set(i, new KviKvsVariant(sz)); i++; @@ -1737,7 +1743,7 @@ static bool str_kvs_fnc_split(KviKvsModuleFunctionCall * c) QVector<QStringRef> list; if(bWild || bContainsR) - list = szStr.splitRef(QRegExp{szSep, sensitivity, bWild ? QRegExp::Wildcard : QRegExp::RegExp}, splitBehavior); + list = szStr.splitRef(QRegExp{szSep, sensitivity, bWild ? QRegExp::Wildcard : QRegExp::RegExp2}, splitBehavior); else list = szStr.splitRef(szSep, splitBehavior, sensitivity); @@ -1768,10 +1774,10 @@ static bool str_kvs_fnc_split(KviKvsModuleFunctionCall * c) if(iMaxItems == 0) return true; - bool bWild = szFla.indexOf('w', 0, Qt::CaseInsensitive) != -1; - bool bContainsR = szFla.indexOf('r', 0, Qt::CaseInsensitive) != -1; - bool bCaseSensitive = szFla.indexOf('s', 0, Qt::CaseInsensitive) != -1; - bool bNoEmpty = szFla.indexOf('n', 0, Qt::CaseInsensitive) != -1; + bool bWild = szFla.contains('w', Qt::CaseInsensitive); + bool bContainsR = szFla.contains('r', Qt::CaseInsensitive); + bool bCaseSensitive = szFla.contains('s', Qt::CaseInsensitive); + bool bNoEmpty = szFla.contains('n', Qt::CaseInsensitive); int id = 0; @@ -1781,7 +1787,7 @@ static bool str_kvs_fnc_split(KviKvsModuleFunctionCall * c) if(bContainsR || bWild) { - QRegExp re(szSep, bCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive, bWild ? QRegExp::Wildcard : QRegExp::RegExp); + QRegExp re(szSep, bCaseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive, bWild ? QRegExp::Wildcard : QRegExp::RegExp2); while((iMatch != -1) && (iMatch < iStrLen) && ((id < (iMaxItems - 1)) || (iMaxItems < 0))) { @@ -2314,10 +2320,11 @@ static bool str_kvs_fnc_evpSign(KviKvsModuleFunctionCall * c) #if defined(COMPILE_SSL_SUPPORT) KviSSL::globalSSLInit(); - EVP_MD_CTX md_ctx; + EVP_MD_CTX *md_ctx; EVP_PKEY * pKey = nullptr; unsigned int len = 0; unsigned char * sig = nullptr; + int err; if(szCert.isEmpty()) { @@ -2368,9 +2375,12 @@ static bool str_kvs_fnc_evpSign(KviKvsModuleFunctionCall * c) len = EVP_PKEY_size(pKey); sig = (unsigned char *)KviMemory::allocate(len * sizeof(char)); - EVP_SignInit(&md_ctx, EVP_sha1()); - EVP_SignUpdate(&md_ctx, (unsigned char *)szMessage.data(), szMessage.length()); - if(EVP_SignFinal(&md_ctx, sig, &len, pKey)) + md_ctx = EVP_MD_CTX_new(); + EVP_SignInit(md_ctx, EVP_sha1()); + EVP_SignUpdate(md_ctx, (unsigned char *)szMessage.data(), szMessage.length()); + err = EVP_SignFinal(md_ctx, sig, &len, pKey); + EVP_MD_CTX_free(md_ctx); + if(err) { QByteArray szSign((const char *)sig, len); OPENSSL_free(sig); @@ -2451,7 +2461,7 @@ static bool str_kvs_fnc_evpVerify(KviKvsModuleFunctionCall * c) szSign = QByteArray::fromBase64(szSignB64); const char * message = szMessage.data(); - EVP_MD_CTX md_ctx; + EVP_MD_CTX* md_ctx; EVP_PKEY * pKey = nullptr; X509 * cert = nullptr; int err = -1; @@ -2518,10 +2528,11 @@ static bool str_kvs_fnc_evpVerify(KviKvsModuleFunctionCall * c) } } - EVP_VerifyInit(&md_ctx, EVP_sha1()); - EVP_VerifyUpdate(&md_ctx, message, strlen(message)); - err = EVP_VerifyFinal(&md_ctx, (unsigned char *)szSign.data(), szSign.size(), pKey); - EVP_MD_CTX_cleanup(&md_ctx); + md_ctx = EVP_MD_CTX_new(); + EVP_VerifyInit(md_ctx, EVP_sha1()); + EVP_VerifyUpdate(md_ctx, message, strlen(message)); + err = EVP_VerifyFinal(md_ctx, (unsigned char *)szSign.data(), szSign.size(), pKey); + EVP_MD_CTX_free(md_ctx); EVP_PKEY_free(pKey); switch(err) { diff --git a/src/modules/system/libkvisystem.cpp b/src/modules/system/libkvisystem.cpp index 42adb10b1..2abab2c10 100644 --- a/src/modules/system/libkvisystem.cpp +++ b/src/modules/system/libkvisystem.cpp @@ -41,7 +41,7 @@ #if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW) #include <sys/utsname.h> -#include <stdlib.h> +#include <cstdlib> #include <unistd.h> #endif diff --git a/src/modules/term/TermWidget.cpp b/src/modules/term/TermWidget.cpp index 57ff5b65b..304daea00 100644 --- a/src/modules/term/TermWidget.cpp +++ b/src/modules/term/TermWidget.cpp @@ -55,8 +55,8 @@ TermWidget::TermWidget(QWidget * par, bool bIsStandalone) g_pTermWidgetList.insert(this); m_bIsStandalone = bIsStandalone; - m_pKonsolePart = 0; - m_pKonsoleWidget = 0; + m_pKonsolePart = nullptr; + m_pKonsoleWidget = nullptr; if(bIsStandalone) { @@ -71,9 +71,9 @@ TermWidget::TermWidget(QWidget * par, bool bIsStandalone) } else { - m_pHBox = 0; - m_pTitleLabel = 0; - m_pCloseButton = 0; + m_pHBox = nullptr; + m_pTitleLabel = nullptr; + m_pCloseButton = nullptr; } setFrameStyle(QFrame::Sunken | QFrame::Panel); @@ -138,8 +138,8 @@ void TermWidget::closeClicked() void TermWidget::konsoleDestroyed() { - m_pKonsoleWidget = 0; - m_pKonsolePart = 0; + m_pKonsoleWidget = nullptr; + m_pKonsolePart = nullptr; hide(); QTimer::singleShot(0, this, SLOT(autoClose())); } diff --git a/src/modules/term/TermWidget.h b/src/modules/term/TermWidget.h index 78d1b89c4..d9e41fae0 100644 --- a/src/modules/term/TermWidget.h +++ b/src/modules/term/TermWidget.h @@ -53,7 +53,7 @@ private: QWidget * m_pKonsoleWidget; protected: - virtual void resizeEvent(QResizeEvent * e); + void resizeEvent(QResizeEvent * e) override; protected slots: void closeClicked(); void changeTitle(int i, const QString & str); @@ -62,7 +62,7 @@ protected slots: public: QWidget * konsoleWidget() { return m_pKonsoleWidget ? m_pKonsoleWidget : this; }; - virtual QSize sizeHint() const; + QSize sizeHint() const override; int dummy() const { return 0; }; protected slots: void konsoleDestroyed(); diff --git a/src/modules/term/TermWindow.cpp b/src/modules/term/TermWindow.cpp index 93f17852d..9ee745226 100644 --- a/src/modules/term/TermWindow.cpp +++ b/src/modules/term/TermWindow.cpp @@ -42,7 +42,7 @@ TermWindow::TermWindow(const char * name) : KviWindow(KviWindow::Terminal, name) { g_pTermWindowList.insert(this); - m_pTermWidget = 0; + m_pTermWidget = nullptr; m_pTermWidget = new TermWidget(this); } diff --git a/src/modules/term/TermWindow.h b/src/modules/term/TermWindow.h index 954d9dc6f..2fc4a87ec 100644 --- a/src/modules/term/TermWindow.h +++ b/src/modules/term/TermWindow.h @@ -43,12 +43,12 @@ protected: TermWidget * m_pTermWidget; protected: - virtual QPixmap * myIconPtr(); - virtual void fillCaptionBuffers(); - virtual void resizeEvent(QResizeEvent * e); + QPixmap * myIconPtr() override; + void fillCaptionBuffers() override; + void resizeEvent(QResizeEvent * e) override; public: - virtual QSize sizeHint() const; + QSize sizeHint() const override; }; #else #include <QObject> diff --git a/src/modules/theme/PackThemeDialog.h b/src/modules/theme/PackThemeDialog.h index 0fc4fe98e..aabdb9f90 100644 --- a/src/modules/theme/PackThemeDialog.h +++ b/src/modules/theme/PackThemeDialog.h @@ -66,7 +66,7 @@ protected: //QWidget * m_pImageSelectionPage; protected: - virtual void accept(); + void accept() override; bool packTheme(); }; @@ -95,7 +95,7 @@ public: QLineEdit * m_pPackageAuthorEdit; protected: - virtual void initializePage(); + void initializePage() override; }; class PackThemeImageWidget : public QWizardPage @@ -125,7 +125,7 @@ protected: QString m_szPackagePath; protected: - virtual void initializePage(); + void initializePage() override; }; #endif //!_PACKTHEMEDIALOG_H_ diff --git a/src/modules/theme/SaveThemeDialog.cpp b/src/modules/theme/SaveThemeDialog.cpp index eda0f371e..d625a9b72 100644 --- a/src/modules/theme/SaveThemeDialog.cpp +++ b/src/modules/theme/SaveThemeDialog.cpp @@ -113,7 +113,7 @@ SaveThemeDialog::SaveThemeDialog(QWidget * pParent) m_pThemeVersionEdit = new QLineEdit(pPage); m_pThemeVersionEdit->setText(info.version()); - QRegExp rx("\\d{1,2}\\.\\d{1,2}(\\.\\d{1,2})?"); + QRegExp rx(R"(\d{1,2}\.\d{1,2}(\.\d{1,2})?)"); QValidator * validator = new QRegExpValidator(rx, this); m_pThemeVersionEdit->setValidator(validator); diff --git a/src/modules/theme/SaveThemeDialog.h b/src/modules/theme/SaveThemeDialog.h index 2f852615c..903f30784 100644 --- a/src/modules/theme/SaveThemeDialog.h +++ b/src/modules/theme/SaveThemeDialog.h @@ -54,16 +54,14 @@ protected: QLineEdit * m_pThemeVersionEdit; QLineEdit * m_pAuthorNameEdit; QWidget * m_pImageSelectionPage; - QPushButton * m_pOkButton; QCheckBox * m_pSaveIconsCheckBox; protected: - virtual void accept(); + void accept() override; bool saveTheme(); protected slots: void makeScreenshot(); void imageSelectionChanged(const QString & szImagePath); - //void themeNameChanged(const QString &txt); }; #endif //!_SAVETHEMEDIALOG_H_ diff --git a/src/modules/theme/ThemeFunctions.h b/src/modules/theme/ThemeFunctions.h index f4b68fdf9..af6ef10de 100644 --- a/src/modules/theme/ThemeFunctions.h +++ b/src/modules/theme/ThemeFunctions.h @@ -35,7 +35,7 @@ namespace ThemeFunctions { - bool installThemePackage(const QString & szThemePackageFileName, QString & szError, QWidget * pDialogParent = 0); + bool installThemePackage(const QString & szThemePackageFileName, QString & szError, QWidget * pDialogParent = nullptr); void getThemeHtmlDescription( QString & szBuffer, @@ -49,7 +49,7 @@ namespace ThemeFunctions const QString & szThemeThemeEngineVersion, const QPixmap & pixScreenshot, int iUniqueIndexInDocument = 0, - KviHtmlDialogData * hd = 0); + KviHtmlDialogData * hd = nullptr); bool makeKVIrcScreenshot(const QString & szSavePngFilePath, bool bMaximizeFrame = false); diff --git a/src/modules/theme/ThemeManagementDialog.h b/src/modules/theme/ThemeManagementDialog.h index b09b4b2c8..5ce7dfa41 100644 --- a/src/modules/theme/ThemeManagementDialog.h +++ b/src/modules/theme/ThemeManagementDialog.h @@ -52,7 +52,7 @@ class ThemeListWidgetItem : public KviTalListWidgetItem { public: ThemeListWidgetItem(KviTalListWidget * pBox, KviThemeInfo * pInfo); - virtual ~ThemeListWidgetItem(); + ~ThemeListWidgetItem(); public: KviThemeInfo * m_pThemeInfo; @@ -66,7 +66,7 @@ class ThemeManagementDialog : public QWidget Q_OBJECT public: ThemeManagementDialog(QWidget * parent); - virtual ~ThemeManagementDialog(); + ~ThemeManagementDialog(); protected: static ThemeManagementDialog * m_pInstance; @@ -86,7 +86,7 @@ public: protected: void fillThemeBox(bool bBuiltin); - virtual void closeEvent(QCloseEvent * e); + void closeEvent(QCloseEvent * e) override; protected slots: void saveCurrentTheme(); void getMoreThemes(); diff --git a/src/modules/theme/WebThemeInterfaceDialog.h b/src/modules/theme/WebThemeInterfaceDialog.h index cc517027c..3e840daee 100644 --- a/src/modules/theme/WebThemeInterfaceDialog.h +++ b/src/modules/theme/WebThemeInterfaceDialog.h @@ -34,7 +34,7 @@ class WebThemeInterfaceDialog : public KviWebPackageManagementDialog { Q_OBJECT public: - WebThemeInterfaceDialog(QWidget * par = 0); + WebThemeInterfaceDialog(QWidget * par = nullptr); ~WebThemeInterfaceDialog(); private: @@ -42,8 +42,8 @@ private: QString m_szGlobalThemesPath; protected: - virtual bool packageIsInstalled(const QString & szId, const QString & szVersion); - virtual bool installPackage(const QString & szPath, QString & szError); + bool packageIsInstalled(const QString & szId, const QString & szVersion) override; + bool installPackage(const QString & szPath, QString & szError) override; }; #endif //COMPILE_WEBKIT_SUPPORT diff --git a/src/modules/theme/libkvitheme.cpp b/src/modules/theme/libkvitheme.cpp index c2ea476f0..4f500a4e6 100644 --- a/src/modules/theme/libkvitheme.cpp +++ b/src/modules/theme/libkvitheme.cpp @@ -322,7 +322,7 @@ static bool theme_kvs_cmd_pack(KviKvsModuleCommandCall * c) KviPointerList<KviThemeInfo> lThemeInfoList; lThemeInfoList.setAutoDelete(true); - Q_FOREACH(QString szTheme, lThemeList) + for(const auto & szTheme : lThemeList) { KviThemeInfo * pInfo = new KviThemeInfo(); if(!pInfo->load(szTheme, KviThemeInfo::External)) diff --git a/src/modules/tip/libkvitip.h b/src/modules/tip/libkvitip.h index 09f06a120..89880864b 100644 --- a/src/modules/tip/libkvitip.h +++ b/src/modules/tip/libkvitip.h @@ -60,7 +60,7 @@ protected: KviConfigurationFile * m_pConfig; QString m_szConfigFileName; // no path! protected: - virtual void showEvent(QShowEvent * e); + void showEvent(QShowEvent * e) override; public: bool openConfig(QString filename, bool bEnsureExists = true); diff --git a/src/modules/tip/libkvitip_fi.kvc b/src/modules/tip/libkvitip_fi.kvc index 86698f0f5..79b83ee43 100644 --- a/src/modules/tip/libkvitip_fi.kvc +++ b/src/modules/tip/libkvitip_fi.kvc @@ -1,26 +1,26 @@ -[KVIrc]
-uNextTip=0
-uNumTips=22
-TranslatorHint=This-file-MUST-be-encoded-in-UTF8
-0=Voit avata yhteyden moeen palvelimeen yhdellä KVIrc-ikkuna, valitse vain "Uusi IRC-konteksti" KVIrc-valikosta.
-1=IPv6 on nyt täysin tuettu, jopa DCC-tiedonsiirtoihin.<br><b>/server -i <palvelimen nimi></b> komentoa käyttäen :)
-2=KVIrcillä on tuki SSL-salaukseen.<br>SSL-salattuja yhteyksiä voidaan luoda käyttämällä komentoa <b>/server -s</b> ja DCC-yhteyksiä käyttämällä komentoa <b>/dcc.chat -s</b><br>Se toimii myös IPv6:n kautta.
-3=<b>IRC-konteksti</b> on sarja resursseja, jotka kommunikoivat palvelimen yhteyden kanssa. Se on yhdistetty <b>konsoli</b>-ikkunaan, joka näyttää järjestelmä- ja palvelinviestit.
-4=KVIrc on modulaarinen sovellus. Moodulit ladataan ja puretaan näkymättömästi käyttäjälle (ja skripterille!) Voit myös kirjoittaa omia moduulejasi, jotka laajentavat skriptauskieltä, tai lisäävät uusia ominaisuuksia.
-5=KVIrcillä on tuki monelle käsittelijäskriptille yhdelle tapahtumalle. Tämä sallii monien skriptien asentaminen samaan aikaan, vältetään käsittelijöiden törmäykset ja auttaa lisäämään/poistamaan ja akvoimaan/deaktivoimaan skriptiosioita.
-6=KVIrcillä tukee <b>irc://</b> Uniform Resource Locatoria (URL:ää). Aja komento: <br><b>kvirc irc://irc.palvelimesi.org:6667/kanava</b><br> yhdistääksesi palvelimeen.<br>Yleinen syntaksi on:<br><b>irc[6]://<palvelimennimi>[:<port>][/[<kanava>[?<salasana>]]]</b>
-7=KVIrc-suoritettava käyttäytyy kuin "netscape -ohjaus" komento, jos jokin KVIrcin osa on jo käynnissä, komentorivin parametrit siihen osaan suoritetaan IPC:n kautta. Voit ylikirjoittaa tämän ominaisuuden <b>-f</b> kytkimellä.
-8=KVIrc voi olla selaimesi käsittelijä <b>irc://</b> URL:lle. Jos KVIrcillä on käännetty KDE-tuen kanssa, sinun pitäisi pystyä ajamaan se yksinkertaisesti kirjoittamalla <b>irc://</b> URL Konqueror:in sijaintipalkkiin.<br>Kokeile <b>irc://irc.freenode.net/kvirc</b> :)
-9=URL-osoitteita voi tehdä myös IPv6-palvelimilli seuraavalla syntaksilla:<br><b>irc6://<ipv6-palvelimennimi>[:<portti>][/[<kanava>[?<salasana>]]]</b>
-10=Voit vaihtaa ikkunoiden välillä painamalla <b>Alt+ylös/alas</b>. <b>Vaihto+ylös/alas</b> vaihtaa ikkunoita vain nykyisessä kontekstissa.
-11=Nopea tapa yhdistää palvelimeen uudessa IRC-kontekstissa on <b>/server -n <palvelimennimi></b>
-12=KVIrc on siirrettävä Windowsin, Mac OSX:n, Linuxin ja muiden Unix-koneiden kanssa. Jos olet hyvä skripteri, sinunkin skriptisi ovat siirrettäviä!
-13=Haluatko automaattisesti liittyä kanavalla yhdistettäessä?<br>Helppoa!<br>Klikkaa vain "Edistynyt (Advanced)" palvelimen asetuksissa ja lisää kanava "Liity kanaville (Join Channels)" välilehdellä. Tämä toimii kaikille palvelimille: <b>/event(OnIrc,autojoin){ join #kanavasi; }</b>
-14=Tiedätkö mikä avatar on? Saa se selville komennolla <b>/help The AVATAR idea</b>
-15=DCC-asetussivulla on paljon valintoja, jotka voivat ratkaista monia yleisiä DCC-yhteysongelmia. Ihmiset palomuurin takana voivat lähettää myös dataa. Se on vain parin asetuksen takana. :)
-16=KVIrc tukee monia 8-bittisiä kirjainsalauksia. Voit "puhua" KOI8-R:ään perustuvaa venäjää toisella kanavalla ja japania toisella, samassa yhteydessä (asianmukaisilla fonteilla). Me suoittelemme käyttämään <b>Unicode</b>-merkistöä (UTF-8), mikä tukee melkein kaikkia kieliä maailmassa.
-17=Välttääksesi liiallisia DCC-siirtoja, on suositeltavaa, että teet avatarisi niin, että ne ovat saatavissa verkosta. Voit myös käyttää jo verkossa olevaa kuvaa avatarina.<br><b>/avatar #kanavasi http://hauskapalvelin.fi/hauskaa/hauskakuva.png</b> toimii!
-18=KVIrc sisältää sisäänrakennetun HTTP-asiakkaan, ja voit ladata tiedostoja verkosta käyttämällä komentoa <b>/http.get</b>.
-19=Etkö pidä ikkunoiden puutehtäväpalkkitilasta? Voit käyttää perinteistä tehtäväpalkkia (samanlainen kuin mIRCissä) tehtäväpalkin asetussivulla.
-20=Voit kopioida tekstiä teksti-ikkunasta leikepöydälle yksinkertaisesti "maalaamalla" (valitsemalla) sen hiirellä. Jos pidät vaihtonäppäintä samaan aikaan pohjassa, silloin myös värikoodit kopioituvat.
-21=Tämä on viimeinen vinkki. Voit lisätä omia vinkkejäsi - käytä komentoa <b>/help tip.open</b> saadaksesi lisätietoja. Voit myös lähettää uudet vinkkisi (millä tahansa kielellä) sähköpostilla osoitteeseen <b>trisk-kvirc(at)quasarnet.org</b>.
+[KVIrc] +uNextTip=0 +uNumTips=22 +TranslatorHint=This-file-MUST-be-encoded-in-UTF8 +0=Voit avata yhteyden moeen palvelimeen yhdellä KVIrc-ikkuna, valitse vain "Uusi IRC-konteksti" KVIrc-valikosta. +1=IPv6 on nyt täysin tuettu, jopa DCC-tiedonsiirtoihin.<br><b>/server -i <palvelimen nimi></b> komentoa käyttäen :) +2=KVIrcillä on tuki SSL-salaukseen.<br>SSL-salattuja yhteyksiä voidaan luoda käyttämällä komentoa <b>/server -s</b> ja DCC-yhteyksiä käyttämällä komentoa <b>/dcc.chat -s</b><br>Se toimii myös IPv6:n kautta. +3=<b>IRC-konteksti</b> on sarja resursseja, jotka kommunikoivat palvelimen yhteyden kanssa. Se on yhdistetty <b>konsoli</b>-ikkunaan, joka näyttää järjestelmä- ja palvelinviestit. +4=KVIrc on modulaarinen sovellus. Moodulit ladataan ja puretaan näkymättömästi käyttäjälle (ja skripterille!) Voit myös kirjoittaa omia moduulejasi, jotka laajentavat skriptauskieltä, tai lisäävät uusia ominaisuuksia. +5=KVIrcillä on tuki monelle käsittelijäskriptille yhdelle tapahtumalle. Tämä sallii monien skriptien asentaminen samaan aikaan, vältetään käsittelijöiden törmäykset ja auttaa lisäämään/poistamaan ja akvoimaan/deaktivoimaan skriptiosioita. +6=KVIrcillä tukee <b>irc://</b> Uniform Resource Locatoria (URL:ää). Aja komento: <br><b>kvirc irc://irc.palvelimesi.org:6667/kanava</b><br> yhdistääksesi palvelimeen.<br>Yleinen syntaksi on:<br><b>irc[6]://<palvelimennimi>[:<port>][/[<kanava>[?<salasana>]]]</b> +7=KVIrc-suoritettava käyttäytyy kuin "netscape -ohjaus" komento, jos jokin KVIrcin osa on jo käynnissä, komentorivin parametrit siihen osaan suoritetaan IPC:n kautta. Voit ylikirjoittaa tämän ominaisuuden <b>-f</b> kytkimellä. +8=KVIrc voi olla selaimesi käsittelijä <b>irc://</b> URL:lle. Jos KVIrcillä on käännetty KDE-tuen kanssa, sinun pitäisi pystyä ajamaan se yksinkertaisesti kirjoittamalla <b>irc://</b> URL Konqueror:in sijaintipalkkiin.<br>Kokeile <b>irc://irc.freenode.net/kvirc</b> :) +9=URL-osoitteita voi tehdä myös IPv6-palvelimilli seuraavalla syntaksilla:<br><b>irc6://<ipv6-palvelimennimi>[:<portti>][/[<kanava>[?<salasana>]]]</b> +10=Voit vaihtaa ikkunoiden välillä painamalla <b>Alt+ylös/alas</b>. <b>Vaihto+ylös/alas</b> vaihtaa ikkunoita vain nykyisessä kontekstissa. +11=Nopea tapa yhdistää palvelimeen uudessa IRC-kontekstissa on <b>/server -n <palvelimennimi></b> +12=KVIrc on siirrettävä Windowsin, Mac OSX:n, Linuxin ja muiden Unix-koneiden kanssa. Jos olet hyvä skripteri, sinunkin skriptisi ovat siirrettäviä! +13=Haluatko automaattisesti liittyä kanavalla yhdistettäessä?<br>Helppoa!<br>Klikkaa vain "Edistynyt (Advanced)" palvelimen asetuksissa ja lisää kanava "Liity kanaville (Join Channels)" välilehdellä. Tämä toimii kaikille palvelimille: <b>/event(OnIrc,autojoin){ join #kanavasi; }</b> +14=Tiedätkö mikä avatar on? Saa se selville komennolla <b>/help The AVATAR idea</b> +15=DCC-asetussivulla on paljon valintoja, jotka voivat ratkaista monia yleisiä DCC-yhteysongelmia. Ihmiset palomuurin takana voivat lähettää myös dataa. Se on vain parin asetuksen takana. :) +16=KVIrc tukee monia 8-bittisiä kirjainsalauksia. Voit "puhua" KOI8-R:ään perustuvaa venäjää toisella kanavalla ja japania toisella, samassa yhteydessä (asianmukaisilla fonteilla). Me suoittelemme käyttämään <b>Unicode</b>-merkistöä (UTF-8), mikä tukee melkein kaikkia kieliä maailmassa. +17=Välttääksesi liiallisia DCC-siirtoja, on suositeltavaa, että teet avatarisi niin, että ne ovat saatavissa verkosta. Voit myös käyttää jo verkossa olevaa kuvaa avatarina.<br><b>/avatar #kanavasi http://hauskapalvelin.fi/hauskaa/hauskakuva.png</b> toimii! +18=KVIrc sisältää sisäänrakennetun HTTP-asiakkaan, ja voit ladata tiedostoja verkosta käyttämällä komentoa <b>/http.get</b>. +19=Etkö pidä ikkunoiden puutehtäväpalkkitilasta? Voit käyttää perinteistä tehtäväpalkkia (samanlainen kuin mIRCissä) tehtäväpalkin asetussivulla. +20=Voit kopioida tekstiä teksti-ikkunasta leikepöydälle yksinkertaisesti "maalaamalla" (valitsemalla) sen hiirellä. Jos pidät vaihtonäppäintä samaan aikaan pohjassa, silloin myös värikoodit kopioituvat. +21=Tämä on viimeinen vinkki. Voit lisätä omia vinkkejäsi - käytä komentoa <b>/help tip.open</b> saadaksesi lisätietoja. Voit myös lähettää uudet vinkkisi (millä tahansa kielellä) sähköpostilla osoitteeseen <b>trisk-kvirc(at)quasarnet.org</b>. diff --git a/src/modules/tip/libkvitip_uk.kvc b/src/modules/tip/libkvitip_uk.kvc index 3936b028e..9368d6921 100644 --- a/src/modules/tip/libkvitip_uk.kvc +++ b/src/modules/tip/libkvitip_uk.kvc @@ -1,26 +1,26 @@ -[KVIrc]
-uNextTip=0
-uNumTips=22
-TranslatorHint=This-file-MUST-be-encoded-in-UTF8
-0=Ви можете відкрити з'єднання для кількох серверів в одному вікні KVIrc, просто виберіть "Новий Контекст IRC" в меню KVIrc.
-1=Тепер IPv6 повністю підтримується, навіть для DCC.<br><b>/сервер -i <назва-сервера></b> потрібна вам команда. :)
-2=KVIrc підтримує SSL-шифрування.<br>Зашифрувати IRC-з'єднання через SSL можна командою <b>/server -s</b>, а DCC-з'єднання командою <b>/dcc.chat -s</b><br>SSL також працює через IPv6.
-3=<b>Контекст IRC</b> це набір ресурсів, що відносяться до одного з'єднання з сервером. Він має відповідне вікно <b>Консолі</b> що відображає системні повідомлення та повідомлення сервера.
-4=KVIrc є високомодульною програмою. Модулі завантажуються та вивантажуються прозоро для користувача (і навіть для розробника скриптів!). Ви можете написати власні модулі, що розширюють мову сценаріїв, або додають можливості.
-5=KVIrc підтримує скрипти з кількома ручками для одної події. Це дозволяє одночасно встановити кілька скриптів, запобігає конфліктам ручок і допомагає в додаванні/усуненні та ввімкненні/вимкненні секцій скриптів.
-6=KVIrc підтримує <b>irc://</b> Uniform Resource Locator (URL). Виконайте команду: <br><b>kvirc irc://irc.сервер.org:6667/канал</b><br> для при'єднання до серверу.<br>Загальний синтаксис:<br><b>irc[6]://<назва-сервера>[:<порт>][/[<канал>[?<пароль>]]]</b>
-7=Виконавчий файл KVIrc працює як команда "netscape -remote", якщо вже запущена одна копія KVIrc, параметри команди надсилаються до цієї копії через IPC. Ви можете перевизначити цю поведінку перемикачем <b>-f</b>.
-8=KVIrc може виконувати роль браузера для URL типу <b>irc://</b>. Якщо KVIrc має підтримку KDE, ви зможете запустити його набравши <b>irc://</b> URL в рядок розміщення Konqueror.<br>Спробуйте <b>irc://irc.freenode.net/kvirc</b> :)
-9=Також можна створити URL для IPv6 IRC серверів, скориставшись наступним синтаксисом:<br><b>irc6://<назва-сервера-ipv6>[:<порт>][/[<канал>[?<пароль>]]]</b>
-10=Ви можете змінити вікно натиснувши <b>Alt+Вверх/Вниз</b>. <b>Shift+Alt+Вверх/Вниз</b> переходить лише між вікнами поточного контексту.
-11=Швидким методом приєднатись до сервера в новому IRC-контексті є <b>/server -n <назва_сервера></b>
-12=KVIrc є переносним між Windows, Mac OSX, Linux та багатьма іншими ОС типу Unix. Якщо ви вмієте писати скрипти, ваші скрипти теж будуть переносними!
-13=Хочете автоматично зайти на канал при з'єднанні?<br>Легко!<br>Натисніть "Розширені" в параметрах сервера і додайте канал в закладці "Зайти на канали". Якщо хочете зробити це для всіх серверів, спробуйте <b>/event(OnIrc,autojoin){ join #ваш_канал; }</b>
-14=Ви знаєте що таке аватар? Гляньте <b>/help The AVATAR idea</b>
-15=Сторінка параметрів DCC має багато опцій, які допоможуть вирішити поширені проблеми з з'єднанням через DCC. Люди за фаєрволом також можуть відсилати дані. Просто все залежить від налаштувань. :)
-16=KVIrc підтримує багато 8-бітних кодувань символів. Ви можете "розмовляти" базованою на KOI8-R Російською на одному каналі і Японською на іншому через те ж з'єднання (якщо наявні потрібні шрифти). Ви радимо вам використовувати <b>Юнікод</b> (UTF-8), який підтримує майже всі мови світу.
-17=Щоб уникнути надмірних передач в DCC, краще зробити ваших аватарів доступними в Веб. Ви також можете використати будь-яке доступне в Веб зображення в якості аватара.<br><b>/avatar #ваш_канал http://funnyhost.com/funny/funny.png</b> спрацює!
-18=KVIrc має вбудований HTTP-клієнт, і ви можете завантажити файли з Веб використавши команду <b>/http.get</b>.
-19=Не подобається режим дерева вікон на панелі завдань? Ви можете перейти до традиційної панелі (як в mIRC) на сторінці параметрів панелі завдань в налаштуваннях.
-20=Ви можете скопіювати текст з текстового вікна в буфер вибравши його мишкою. Якщо ж ви ще й затиснете кнопку Shift, то скопіюється також колір.
-21=Це остання порада. Ви можете додати власні - Дивіться <b>/help tip.open</b>. Надсилайте поради (на будь-якій мові) на адресу <b>trisk-kvirc(at)quasarnet.org</b>.
+[KVIrc] +uNextTip=0 +uNumTips=22 +TranslatorHint=This-file-MUST-be-encoded-in-UTF8 +0=Ви можете відкрити з'єднання для кількох серверів в одному вікні KVIrc, просто виберіть "Новий Контекст IRC" в меню KVIrc. +1=Тепер IPv6 повністю підтримується, навіть для DCC.<br><b>/сервер -i <назва-сервера></b> потрібна вам команда. :) +2=KVIrc підтримує SSL-шифрування.<br>Зашифрувати IRC-з'єднання через SSL можна командою <b>/server -s</b>, а DCC-з'єднання командою <b>/dcc.chat -s</b><br>SSL також працює через IPv6. +3=<b>Контекст IRC</b> це набір ресурсів, що відносяться до одного з'єднання з сервером. Він має відповідне вікно <b>Консолі</b> що відображає системні повідомлення та повідомлення сервера. +4=KVIrc є високомодульною програмою. Модулі завантажуються та вивантажуються прозоро для користувача (і навіть для розробника скриптів!). Ви можете написати власні модулі, що розширюють мову сценаріїв, або додають можливості. +5=KVIrc підтримує скрипти з кількома ручками для одної події. Це дозволяє одночасно встановити кілька скриптів, запобігає конфліктам ручок і допомагає в додаванні/усуненні та ввімкненні/вимкненні секцій скриптів. +6=KVIrc підтримує <b>irc://</b> Uniform Resource Locator (URL). Виконайте команду: <br><b>kvirc irc://irc.сервер.org:6667/канал</b><br> для при'єднання до серверу.<br>Загальний синтаксис:<br><b>irc[6]://<назва-сервера>[:<порт>][/[<канал>[?<пароль>]]]</b> +7=Виконавчий файл KVIrc працює як команда "netscape -remote", якщо вже запущена одна копія KVIrc, параметри команди надсилаються до цієї копії через IPC. Ви можете перевизначити цю поведінку перемикачем <b>-f</b>. +8=KVIrc може виконувати роль браузера для URL типу <b>irc://</b>. Якщо KVIrc має підтримку KDE, ви зможете запустити його набравши <b>irc://</b> URL в рядок розміщення Konqueror.<br>Спробуйте <b>irc://irc.freenode.net/kvirc</b> :) +9=Також можна створити URL для IPv6 IRC серверів, скориставшись наступним синтаксисом:<br><b>irc6://<назва-сервера-ipv6>[:<порт>][/[<канал>[?<пароль>]]]</b> +10=Ви можете змінити вікно натиснувши <b>Alt+Вверх/Вниз</b>. <b>Shift+Alt+Вверх/Вниз</b> переходить лише між вікнами поточного контексту. +11=Швидким методом приєднатись до сервера в новому IRC-контексті є <b>/server -n <назва_сервера></b> +12=KVIrc є переносним між Windows, Mac OSX, Linux та багатьма іншими ОС типу Unix. Якщо ви вмієте писати скрипти, ваші скрипти теж будуть переносними! +13=Хочете автоматично зайти на канал при з'єднанні?<br>Легко!<br>Натисніть "Розширені" в параметрах сервера і додайте канал в закладці "Зайти на канали". Якщо хочете зробити це для всіх серверів, спробуйте <b>/event(OnIrc,autojoin){ join #ваш_канал; }</b> +14=Ви знаєте що таке аватар? Гляньте <b>/help The AVATAR idea</b> +15=Сторінка параметрів DCC має багато опцій, які допоможуть вирішити поширені проблеми з з'єднанням через DCC. Люди за фаєрволом також можуть відсилати дані. Просто все залежить від налаштувань. :) +16=KVIrc підтримує багато 8-бітних кодувань символів. Ви можете "розмовляти" базованою на KOI8-R Російською на одному каналі і Японською на іншому через те ж з'єднання (якщо наявні потрібні шрифти). Ви радимо вам використовувати <b>Юнікод</b> (UTF-8), який підтримує майже всі мови світу. +17=Щоб уникнути надмірних передач в DCC, краще зробити ваших аватарів доступними в Веб. Ви також можете використати будь-яке доступне в Веб зображення в якості аватара.<br><b>/avatar #ваш_канал http://funnyhost.com/funny/funny.png</b> спрацює! +18=KVIrc має вбудований HTTP-клієнт, і ви можете завантажити файли з Веб використавши команду <b>/http.get</b>. +19=Не подобається режим дерева вікон на панелі завдань? Ви можете перейти до традиційної панелі (як в mIRC) на сторінці параметрів панелі завдань в налаштуваннях. +20=Ви можете скопіювати текст з текстового вікна в буфер вибравши його мишкою. Якщо ж ви ще й затиснете кнопку Shift, то скопіюється також колір. +21=Це остання порада. Ви можете додати власні - Дивіться <b>/help tip.open</b>. Надсилайте поради (на будь-якій мові) на адресу <b>trisk-kvirc(at)quasarnet.org</b>. diff --git a/src/modules/toolbareditor/CustomizeToolBarsDialog.h b/src/modules/toolbareditor/CustomizeToolBarsDialog.h index 937c5c72e..4077f5c15 100644 --- a/src/modules/toolbareditor/CustomizeToolBarsDialog.h +++ b/src/modules/toolbareditor/CustomizeToolBarsDialog.h @@ -61,8 +61,8 @@ public: static void cleanup(); protected: - virtual void showEvent(QShowEvent * e); - virtual void closeEvent(QCloseEvent * e); + void showEvent(QShowEvent * e) override; + void closeEvent(QCloseEvent * e) override; protected slots: void closeClicked(); void newToolBar(); @@ -112,7 +112,7 @@ class TrashcanLabel : public QLabel Q_OBJECT public: TrashcanLabel(QWidget * p); - virtual ~TrashcanLabel(); + ~TrashcanLabel(); protected: unsigned int m_uFlashCount; @@ -120,8 +120,8 @@ protected: QColor m_clrOriginal; protected: - virtual void dragEnterEvent(QDragEnterEvent * e); - virtual void dropEvent(QDropEvent * e); + void dragEnterEvent(QDragEnterEvent * e) override; + void dropEvent(QDropEvent * e) override; public slots: void flash(); protected slots: diff --git a/src/modules/torrent/KTorrentDbusInterface.cpp b/src/modules/torrent/KTorrentDbusInterface.cpp index 5341ddc8f..4f63f91ee 100644 --- a/src/modules/torrent/KTorrentDbusInterface.cpp +++ b/src/modules/torrent/KTorrentDbusInterface.cpp @@ -50,8 +50,7 @@ KTorrentDbusInterface::KTorrentDbusInterface() } KTorrentDbusInterface::~KTorrentDbusInterface() -{ -} + = default; bool KTorrentDbusInterface::findRunningApp() { diff --git a/src/modules/torrent/KTorrentDbusInterface.h b/src/modules/torrent/KTorrentDbusInterface.h index 0aadd8396..5cbcc51b6 100644 --- a/src/modules/torrent/KTorrentDbusInterface.h +++ b/src/modules/torrent/KTorrentDbusInterface.h @@ -38,35 +38,35 @@ class KTorrentDbusInterface : public TorrentInterface public: KTorrentDbusInterface(); - virtual ~KTorrentDbusInterface(); + ~KTorrentDbusInterface(); - virtual int detect(); + int detect() override; - virtual bool startAll(); - virtual bool stopAll(); + bool startAll() override; + bool stopAll() override; - virtual int count(); - virtual bool start(int i); - virtual bool stop(int i); - virtual bool announce(int i); - virtual QString state(int i); - virtual QString name(int i); - virtual int fileCount(int i); - virtual QString fileName(int i, int file); - virtual QString filePriority(int i, int file); - virtual bool setFilePriority(int i, int file, const QString & prio); + int count() override; + bool start(int i) override; + bool stop(int i) override; + bool announce(int i) override; + QString state(int i) override; + QString name(int i) override; + int fileCount(int i) override; + QString fileName(int i, int file) override; + QString filePriority(int i, int file) override; + bool setFilePriority(int i, int file, const QString & prio) override; - virtual int maxUploadSpeed(); - virtual int maxDownloadSpeed(); + int maxUploadSpeed() override; + int maxDownloadSpeed() override; - virtual bool setMaxUploadSpeed(int kbytes_per_sec); - virtual bool setMaxDownloadSpeed(int kbytes_per_sec); + bool setMaxUploadSpeed(int kbytes_per_sec) override; + bool setMaxDownloadSpeed(int kbytes_per_sec) override; - virtual float speedUp(); - virtual float speedDown(); + float speedUp() override; + float speedDown() override; - virtual float trafficUp(); - virtual float trafficDown(); + float trafficUp() override; + float trafficDown() override; /* private slots: // polls client and extracts information. diff --git a/src/modules/torrent/StatusBarApplet.h b/src/modules/torrent/StatusBarApplet.h index 26d3358c9..53c013262 100644 --- a/src/modules/torrent/StatusBarApplet.h +++ b/src/modules/torrent/StatusBarApplet.h @@ -36,7 +36,7 @@ class StatusBarApplet : public KviStatusBarApplet Q_OBJECT public: StatusBarApplet(KviStatusBar * parent, KviStatusBarAppletDescriptor * desc); - virtual ~StatusBarApplet(); + ~StatusBarApplet() override; static void selfRegister(KviStatusBar * bar); private slots: void update(); diff --git a/src/modules/torrent/TorrentInterface.h b/src/modules/torrent/TorrentInterface.h index efae2a708..31329b0b0 100644 --- a/src/modules/torrent/TorrentInterface.h +++ b/src/modules/torrent/TorrentInterface.h @@ -35,7 +35,7 @@ class TorrentInterface : public QObject { public: TorrentInterface() {} - virtual ~TorrentInterface() {} + ~TorrentInterface() {} virtual int detect() = 0; @@ -119,7 +119,7 @@ public: { \ public: \ _interfaceclass##Descriptor(); \ - virtual ~_interfaceclass##Descriptor(); \ + ~_interfaceclass##Descriptor(); \ \ protected: \ _interfaceclass * m_pInstance; \ @@ -127,16 +127,16 @@ public: QString m_szDescription; \ \ public: \ - virtual const QString & name(); \ - virtual const QString & description(); \ - virtual TorrentInterface * instance(); \ + const QString & name() override; \ + const QString & description() override; \ + TorrentInterface * instance() override; \ }; #define TORR_IMPLEMENT_DESCRIPTOR(_interfaceclass, _name, _description) \ _interfaceclass##Descriptor::_interfaceclass##Descriptor() \ : TorrentInterfaceDescriptor() \ { \ - m_pInstance = 0; \ + m_pInstance = nullptr; \ m_szName = _name; \ m_szDescription = _description; \ } \ diff --git a/src/modules/trayicon/libkvitrayicon.cpp b/src/modules/trayicon/libkvitrayicon.cpp index 787e1d3ef..b2dceb40d 100644 --- a/src/modules/trayicon/libkvitrayicon.cpp +++ b/src/modules/trayicon/libkvitrayicon.cpp @@ -688,7 +688,7 @@ static bool trayicon_kvs_cmd_hide(KviKvsModuleCommandCall *) Hides the window, associated with trayicon @syntax: trayicon.hidewindow - @description + @description: Hides the window, associated with trayicon @seealso: [cmd]trayicon.show[/cmd], [cmd]trayicon.hide[/cmd] diff --git a/src/modules/upnp/Manager.h b/src/modules/upnp/Manager.h index 69fd14ed5..4ee83d435 100644 --- a/src/modules/upnp/Manager.h +++ b/src/modules/upnp/Manager.h @@ -59,7 +59,7 @@ namespace UPnP public: // public methods // The destructor - virtual ~Manager(); + ~Manager(); // Return the external IP address QString getExternalIpAddress() const; diff --git a/src/modules/upnp/RootService.h b/src/modules/upnp/RootService.h index 971e86be2..97d319fa0 100644 --- a/src/modules/upnp/RootService.h +++ b/src/modules/upnp/RootService.h @@ -55,7 +55,7 @@ namespace UPnP // The constructor RootService(const QString & hostname, int port, const QString & rootUrl); // The destructor - virtual ~RootService(); + ~RootService(); // Return the device type QString getDeviceType() const; @@ -74,7 +74,7 @@ namespace UPnP protected: // Protected methods // The control point received a response to callInformationUrl() - virtual void gotInformationResponse(const QDomNode & response); + void gotInformationResponse(const QDomNode & response) override; private: // Private methods // Recursively add all devices and embedded devices to the deviceServices_ map diff --git a/src/modules/upnp/Service.cpp b/src/modules/upnp/Service.cpp index f7e7f4baa..cc337f972 100644 --- a/src/modules/upnp/Service.cpp +++ b/src/modules/upnp/Service.cpp @@ -36,6 +36,7 @@ #include <QDebug> #include <QByteArray> +#include <utility> #include "KviNetworkAccessManager.h" @@ -49,8 +50,11 @@ namespace UPnP { // The constructor for information services - Service::Service(const QString & hostname, int port, const QString & informationUrl) - : m_iPendingRequests(0), m_szBaseXmlPrefix("s"), m_szHostname(hostname), m_iPort(port) + Service::Service(QString hostname, int port, const QString & informationUrl) + : m_iPendingRequests(0) + , m_szBaseXmlPrefix("s") + , m_szHostname(std::move(hostname)) + , m_iPort(port) { m_szInformationUrl = informationUrl; qDebug() << "UPnP::Service: created information service url='" << m_szInformationUrl << "'." << endl; diff --git a/src/modules/upnp/Service.h b/src/modules/upnp/Service.h index de81a5ee6..c65c132c6 100644 --- a/src/modules/upnp/Service.h +++ b/src/modules/upnp/Service.h @@ -71,11 +71,11 @@ namespace UPnP public: // public methods // The constructor for the root service - Service(const QString & hostname, int port, const QString & informationUrl); + Service(QString hostname, int port, const QString & informationUrl); // The constructor for action services Service(const ServiceParameters & params); // The destructor - virtual ~Service(); + ~Service(); // Get the number of pending requests int getPendingRequests() const; diff --git a/src/modules/upnp/SsdpConnection.h b/src/modules/upnp/SsdpConnection.h index 0068f2f25..8be9cdc3c 100644 --- a/src/modules/upnp/SsdpConnection.h +++ b/src/modules/upnp/SsdpConnection.h @@ -58,7 +58,7 @@ namespace UPnP public: SsdpConnection(); - virtual ~SsdpConnection(); + ~SsdpConnection(); void queryDevices(int bindPort = 1500); diff --git a/src/modules/upnp/WanConnectionService.h b/src/modules/upnp/WanConnectionService.h index 24e306dff..6e950dd5b 100644 --- a/src/modules/upnp/WanConnectionService.h +++ b/src/modules/upnp/WanConnectionService.h @@ -68,7 +68,7 @@ namespace UPnP // The constructor WanConnectionService(const ServiceParameters & params); // The destructor - virtual ~WanConnectionService(); + ~WanConnectionService(); // Add a port mapping void addPortMapping(const QString & protocol, const QString & remoteHost, int externalPort, @@ -93,7 +93,7 @@ namespace UPnP protected: // protected methods // The control point received a response to callAction() - virtual void gotActionResponse(const QString & responseType, const QMap<QString, QString> & resultValues); + void gotActionResponse(const QString & responseType, const QMap<QString, QString> & resultValues) override; private: // private attributes // The external IP address diff --git a/src/modules/upnp/igdcontrolpoint.h b/src/modules/upnp/igdcontrolpoint.h index e292c0e72..209b28ee7 100644 --- a/src/modules/upnp/igdcontrolpoint.h +++ b/src/modules/upnp/igdcontrolpoint.h @@ -61,7 +61,7 @@ namespace UPnP // The constructor IgdControlPoint(const QString & hostname, int port, const QString & rootUrl); // The destructor - virtual ~IgdControlPoint(); + ~IgdControlPoint(); // Return the external IP address QString getExternalIpAddress() const; diff --git a/src/modules/url/libkviurl.cpp b/src/modules/url/libkviurl.cpp index 279c414cd..a10d5171c 100644 --- a/src/modules/url/libkviurl.cpp +++ b/src/modules/url/libkviurl.cpp @@ -54,11 +54,11 @@ extern KVIRC_API QPixmap * g_pShadedChildGlobalDesktopBackground; #endif -typedef struct _UrlDlgList +struct UrlDlgList { UrlDialog * dlg; int menu_id; -} UrlDlgList; +}; const char * g_pUrlListFilename = "/list.kviurl"; const char * g_pBanListFilename = "/list.kviban"; @@ -288,10 +288,10 @@ void UrlDialog::addUrl(QString url, QString window, QString count, QString times UrlItem->setText(2, count); UrlItem->setText(3, timestamp); - UrlItem->setForeground(0, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_URL).fore())); - UrlItem->setForeground(1, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore())); - UrlItem->setForeground(2, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore())); - UrlItem->setForeground(3, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore())); + UrlItem->setForeground(0, getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_URL).fore())); + UrlItem->setForeground(1, getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore())); + UrlItem->setForeground(2, getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore())); + UrlItem->setForeground(3, getMircColor(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore())); m_pUrlList->resizeColumnToContents(0); m_pUrlList->resizeColumnToContents(3); diff --git a/src/modules/url/libkviurl.h b/src/modules/url/libkviurl.h index 623d11b5a..cb14edac7 100644 --- a/src/modules/url/libkviurl.h +++ b/src/modules/url/libkviurl.h @@ -48,13 +48,13 @@ #include <unordered_set> #include <vector> -typedef struct _KviUrl +struct KviUrl { QString url; QString window; int count; QString timestamp; -} KviUrl; +}; class UrlDialogTreeWidget : public QTreeWidget { @@ -64,8 +64,8 @@ public: ~UrlDialogTreeWidget(){}; protected: - void mousePressEvent(QMouseEvent * e); - void paintEvent(QPaintEvent * event); + void mousePressEvent(QMouseEvent * e) override; + void paintEvent(QPaintEvent * event) override; signals: void rightButtonPressed(QTreeWidgetItem *, QPoint); void contextMenuRequested(QPoint); @@ -80,11 +80,11 @@ public: private: KviTalMenuBar * m_pMenuBar; - QMenu * m_pListPopup; // dynamic popup menu + QMenu * m_pListPopup = nullptr; // dynamic popup menu QString m_szUrl; // used to pass URLs to sayToWin slot protected: - QPixmap * myIconPtr(); - void resizeEvent(QResizeEvent *); + QPixmap * myIconPtr() override; + void resizeEvent(QResizeEvent *) override; public: UrlDialogTreeWidget * m_pUrlList; @@ -109,7 +109,7 @@ class BanFrame : public QFrame { Q_OBJECT public: - BanFrame(QWidget * parent = 0, const char * name = 0, bool banEnable = false); + BanFrame(QWidget * parent = nullptr, const char * name = nullptr, bool banEnable = false); ~BanFrame(); void saveBans(KviConfigurationFile * cfg); @@ -136,7 +136,7 @@ public: private: QCheckBox * cb[cbnum]; BanFrame * m_pBanFrame; - void closeEvent(QCloseEvent *); + void closeEvent(QCloseEvent *) override; protected slots: void acceptbtn(); void discardbtn(); diff --git a/src/modules/window/UserWindow.h b/src/modules/window/UserWindow.h index 43df1af47..a7a8cd597 100644 --- a/src/modules/window/UserWindow.h +++ b/src/modules/window/UserWindow.h @@ -37,16 +37,16 @@ public: }; public: - UserWindow(const char * pcName, QString & szIcon, KviConsoleWindow * pConsole = 0, int iCreationFlags = 0); + UserWindow(const char * pcName, QString & szIcon, KviConsoleWindow * pConsole = nullptr, int iCreationFlags = 0); ~UserWindow(); protected: QString m_szIcon; protected: - virtual void resizeEvent(QResizeEvent *); - virtual QPixmap * myIconPtr(); - virtual void fillCaptionBuffers(); + void resizeEvent(QResizeEvent *) override; + QPixmap * myIconPtr() override; + void fillCaptionBuffers() override; public: void setWindowTitleStrings(const QString & szPlainText); diff --git a/src/modules/zzz_afterlastmodule/CMakeLists.txt b/src/modules/zzz_afterlastmodule/CMakeLists.txt index 317ed1402..e209fe082 100644 --- a/src/modules/zzz_afterlastmodule/CMakeLists.txt +++ b/src/modules/zzz_afterlastmodule/CMakeLists.txt @@ -1,5 +1,9 @@ # CMakeLists.txt for src/modules/zzz_afterlastmodule if(APPLE) + set(QT_LIBRARY_DIR "${Qt5Widgets_DIR}/../../") + get_filename_component(QT_LIBRARY_DIR ${QT_LIBRARY_DIR} PATH) + get_filename_component(QT_LIBRARY_DIR "${QT_LIBRARY_DIR}/.." ABSOLUTE) + install(CODE " file(GLOB_RECURSE KVIRC_INSTALLED_MODULES \"${KVIRC_MOD_PATH}/*.so\") |
