aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Elvio Basello2008-09-08 23:16:17 +0000
committerGravatar Elvio Basello2008-09-08 23:16:17 +0000
commit2ecbb358757dfa191c01119ba7100b09bb6e9d13 (patch)
tree166bc2c3e5c01144db5a04002645f9532a911406 /src
parentsome performance fix to windowlist (diff)
downloadKVIrc-2ecbb358757dfa191c01119ba7100b09bb6e9d13.tar.gz
KVIrc-2ecbb358757dfa191c01119ba7100b09bb6e9d13.tar.bz2
KVIrc-2ecbb358757dfa191c01119ba7100b09bb6e9d13.zip
more work on KviInput*; fixed doxygen comments
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2431 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
-rw-r--r--src/kvilib/config/kvi_confignames.h1
-rw-r--r--src/kvilib/config/kvi_defaults.h1
-rw-r--r--src/kvilib/config/kvi_fileextensions.h2
-rw-r--r--src/kvilib/core/kvi_pointerhashtable.h55
-rw-r--r--src/kvilib/core/kvi_pointerlist.h44
-rw-r--r--src/kvilib/core/kvi_qstring.h12
-rw-r--r--src/kvilib/file/kvi_fileutils.h4
-rw-r--r--src/kvilib/file/kvi_packagefile.h41
-rw-r--r--src/kvilib/irc/kvi_avatar.h5
-rw-r--r--src/kvilib/irc/kvi_ircmask.h12
-rw-r--r--src/kvilib/irc/kvi_ircuserdb.h1
-rw-r--r--src/kvilib/irc/kvi_network.h8
-rw-r--r--src/kvilib/system/kvi_env.h1
-rw-r--r--src/kvilib/system/kvi_process.h1
-rw-r--r--src/kvirc/kernel/kvi_app.cpp4
-rw-r--r--src/kvirc/ui/kvi_input.cpp44
-rw-r--r--src/kvirc/ui/kvi_input.h146
-rw-r--r--src/kvirc/ui/kvi_input_editor.cpp848
-rw-r--r--src/kvirc/ui/kvi_input_editor.h387
-rw-r--r--src/kvirc/ui/kvi_input_history.cpp26
-rw-r--r--src/kvirc/ui/kvi_input_history.h5
21 files changed, 1131 insertions, 517 deletions
diff --git a/src/kvilib/config/kvi_confignames.h b/src/kvilib/config/kvi_confignames.h
index 38455bab0..1b94096f5 100644
--- a/src/kvilib/config/kvi_confignames.h
+++ b/src/kvilib/config/kvi_confignames.h
@@ -29,6 +29,7 @@
* \file kvi_confignames.h
* \author Szymon Stefanek
* \brief This file contains the config file names used in KVIrc
+*
* You can play a bit with these, but be aware that some (bad) scripts may find
* themselves in trouble
*
diff --git a/src/kvilib/config/kvi_defaults.h b/src/kvilib/config/kvi_defaults.h
index f4b0b263f..da411822c 100644
--- a/src/kvilib/config/kvi_defaults.h
+++ b/src/kvilib/config/kvi_defaults.h
@@ -29,6 +29,7 @@
* \file kvi_defaults.h
* \author Szymon Stefanek
* \brief This file contains (more or less) freely customizable compile time defaults
+*
* You can safely play with the ones you understand the meaning of
*
* \def KVI_HOME_CONFIG_FILE_NAME Configuration file in home directory
diff --git a/src/kvilib/config/kvi_fileextensions.h b/src/kvilib/config/kvi_fileextensions.h
index 1aed2baaf..b23e3196f 100644
--- a/src/kvilib/config/kvi_fileextensions.h
+++ b/src/kvilib/config/kvi_fileextensions.h
@@ -32,6 +32,7 @@
/**
* \brief File extensions
+*
* \def KVI_FILEEXTENSION_CONFIG Configuration file .kvc
* \def KVI_FILEEXTENSION_SCRIPT Script file .kvs
* \def KVI_FILEEXTENSION_THEMEPACKAGE Theme package .kvt
@@ -44,6 +45,7 @@
/**
* \brief Filters
+*
* \def KVI_FILTER_CONFIG Configuration file *.kvs
* \def KVI_FILTER_SCRIPT Script file *.kvs
* \def KVI_FILTER_THEME Theme package *.kvt
diff --git a/src/kvilib/core/kvi_pointerhashtable.h b/src/kvilib/core/kvi_pointerhashtable.h
index b2adf30a6..f9392399a 100644
--- a/src/kvilib/core/kvi_pointerhashtable.h
+++ b/src/kvilib/core/kvi_pointerhashtable.h
@@ -343,7 +343,8 @@ protected:
unsigned int m_uIteratorIdx;
public:
/**
- * \brief Returns the item associated to the key hKey
+ * \brief Returns the item associated to the key
+ *
* Returns NULL 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
@@ -362,6 +363,7 @@ public:
/**
* \brief Returns the item associated to the key hKey
+ *
* Returns NULL 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().
@@ -393,6 +395,7 @@ public:
/**
* \brief Inserts the item pData at the position specified by the key hKey.
+ *
* Replaces any previous item with the same key
* The replaced item is deleted if autodelete is enabled.
* The hash table iterator is placed at the newly inserted item.
@@ -429,6 +432,7 @@ public:
/**
* \brief Inserts the item pData at the position specified by the key hKey.
+ *
* Replaces any previous item with the same key.
* The replaced item is deleted if autodelete is enabled.
* The hash table iterator is placed at the newly inserted item.
@@ -444,6 +448,7 @@ public:
/**
* \brief Removes the item pointer associated to the key hKey, if such an item exists in the hash table.
+ *
* The item is deleted if autodeletion is enabled. Returns true if the
* item was found and removed and false if it wasn't found.
* Invalidates the hash table iterator.
@@ -475,6 +480,7 @@ public:
/**
* \brief Removes the first occurence of the item pointer pRef.
+ *
* The item is deleted if autodeletion is enabled. Returns true if the
* pointer was found and false otherwise.
* Invalidates the hash table iterator.
@@ -510,6 +516,7 @@ public:
/**
* \brief Removes all the items from the hash table.
+ *
* The items are deleted if autodeletion is enabled.
* Invalidates the hash table iterator.
* \return void
@@ -535,6 +542,7 @@ public:
/**
* \brief Searches for the item pointer pRef
+ *
* Returns its hash table entry, if found, and NULL otherwise.
* The hash table iterator is placed at the item found.
* \param pRef The pointer to search
@@ -557,6 +565,7 @@ public:
/**
* \brief Returns the entry pointed by the hash table iterator.
+ *
* This function must be preceeded by a call to firstEntry(), first()
* or findRef().
* \return KviPointerHashTableEntry<Key,T> *
@@ -585,6 +594,7 @@ public:
/**
* \brief Places the hash table iterator at the next entry and returns it.
+ *
* This function must be preceeded by a call to firstEntry(), first()
* or findRef().
* \return KviPointerHashTableEntry<Key,T> *
@@ -614,6 +624,7 @@ public:
/**
* \brief Returns the data value pointer pointed by the hash table iterator.
+ *
* This function must be preceeded by a call to firstEntry(), first()
* or findRef().
* \return T *
@@ -632,6 +643,7 @@ public:
/**
* \brief Returns the key pointed by the hash table iterator.
+ *
* This function must be preceeded by a call to firstEntry(), first()
* or findRef().
* \return const Key &
@@ -649,6 +661,7 @@ public:
}
/** \brief Places the hash table iterator at the first entry
+ *
* It returns the associated data value pointer.
* \return T *
*/
@@ -667,6 +680,7 @@ public:
/**
* \brief Places the hash table iterator at the next entry and returns the associated data value pointer.
+ *
* This function must be preceeded by a call to firstEntry(), first()
* or findRef().
* \return T *
@@ -700,6 +714,7 @@ public:
/**
* \brief Removes all items in the hash table and then makes a complete shallow copy of the data contained in t.
+ *
* The removed items are deleted if autodeletion is enabled.
* The hash table iterator is invalidated.
* Does not change autodelete flag: make sure you don't delete the
@@ -716,6 +731,7 @@ public:
/**
* \brief Inserts a complete shallow copy of the data contained in t.
+ *
* The hash table iterator is invalidated.
* \param t The data to insert
* \return void
@@ -728,6 +744,7 @@ public:
/**
* \brief Enables or disabled the autodeletion feature.
+ *
* Items are deleted upon removal when the feature is enabled.
* \param bAutoDelete Set the autodelete state
* \return void
@@ -739,6 +756,7 @@ public:
/**
* \brief Creates an empty hash table.
+ *
* Automatic deletion is enabled.
* \param uSize The number of hash buckets: does NOT necesairly need to be prime
* \param bCaseSensitive Are the key comparisons case sensitive ?
@@ -758,6 +776,7 @@ public:
/**
* \brief First creates an empty hash table and then inserts a copy of all the item pointers present in t.
+ *
* The autodelete feature is automatically disabled (take care!).
* \param t The data to copy
* \return KviPointerHashTable
@@ -776,6 +795,7 @@ public:
/**
* \brief Destroys the hash table and all the items contained within.
+ *
* Items are deleted if autodeletion is enabled.
*/
~KviPointerHashTable()
@@ -798,8 +818,10 @@ protected:
public:
/**
* \brief Creates an iterator copy.
+ *
* The new iterator points exactly to the item pointed by src.
* \param src The source pointer to copy from
+ * \return void
*/
void operator = (const KviPointerHashTableIterator<Key,T> & src)
{
@@ -813,8 +835,9 @@ public:
/**
* \brief Moves the iterator to the first element of the hash table.
- * Returns true in case of success or false if the hash table is
- * empty.
+ *
+ * Returns true in case of success or false if the hash table is empty.
+ * \return bool
*/
bool moveFirst()
{
@@ -845,8 +868,9 @@ public:
/**
* \brief Moves the iterator to the last element of the hash table.
- * Returns true in case of success or false if the hash table is
- * empty.
+ *
+ * Returns true in case of success or false if the hash table is empty.
+ * \return bool
*/
bool moveLast()
{
@@ -877,8 +901,10 @@ public:
/**
* \brief Moves the iterator to the next element of the hash table.
+ *
* The iterator must be actually valid for this function to work.
* Returns true in case of success or false if there is no next item.
+ * \return bool
*/
bool moveNext()
{
@@ -910,9 +936,11 @@ public:
/**
* \brief Moves the iterator to the next element of the hash table.
+ *
* The iterator must be actually valid for this function to work.
* Returns true in case of success or false if there is no next item.
* This is just an alias to moveNext().
+ * \return bool
*/
bool operator ++()
{
@@ -921,9 +949,11 @@ public:
/**
* \brief Moves the iterator to the previous element of the hash table.
+ *
* The iterator must be actually valid for this function to work.
* Returns true in case of success or false if there is no previous
* item.
+ * \return bool
*/
bool movePrev()
{
@@ -958,10 +988,12 @@ public:
/**
* \brief Moves the iterator to the previous element of the hash table.
+ *
* The iterator must be actually valid for this function to work.
* Returns true in case of success or false if there is no previous
* item.
* This is just an alias to movePrev() with a different name.
+ * \return bool
*/
bool operator --()
{
@@ -970,8 +1002,10 @@ public:
/**
* \brief Returs the value pointed by the iterator
+ *
* If the iterator is not valid it returns a default constructed value
* This is an alias to operator *() with just a different name.
+ * \return T *
*/
T * current() const
{
@@ -980,8 +1014,10 @@ public:
/**
* \brief Returs the value pointed by the iterator
+ *
* If the iterator is not valid it returns a default constructed value
* This is an alias to current() with just a different name.
+ * \return T *
*/
T * operator *() const
{
@@ -990,7 +1026,9 @@ public:
/**
* \brief Returs the key pointed by the iterator
+ *
* If the iterator is not valid it returns a default constructed value
+ * \return const Key &
*/
const Key & currentKey() const
{
@@ -1001,7 +1039,9 @@ public:
/**
* \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.
+ * \return T *
*/
T * toFirst()
{
@@ -1013,6 +1053,7 @@ public:
/**
* \brief Creates an iterator pointing to the first item in the hash table, if any.
* \param hTable The hash table
+ * \return KviPointerHashTableIterator
*/
KviPointerHashTableIterator(const KviPointerHashTable<Key,T> & hTable)
{
@@ -1022,7 +1063,9 @@ public:
moveFirst();
}
- /// Destroys the iterator
+ /**
+ * \brief Destroys the iterator
+ */
~KviPointerHashTableIterator()
{
if(m_pIterator)
diff --git a/src/kvilib/core/kvi_pointerlist.h b/src/kvilib/core/kvi_pointerlist.h
index 4014f29bd..ba5c3bb88 100644
--- a/src/kvilib/core/kvi_pointerlist.h
+++ b/src/kvilib/core/kvi_pointerlist.h
@@ -148,6 +148,7 @@ protected:
public:
/**
* \brief Creates an iterator copy.
+ *
* The new iterator points exactly to the item pointed by src.
* \param src The source item to point to
* \return KviPointerListIterator
@@ -160,6 +161,7 @@ public:
/**
* \brief Creates an iterator for the list l.
+ *
* The iterator points to the first list item, if any.
* \param l The source list to point to
* \return KviPointerListIterator
@@ -172,6 +174,7 @@ public:
/**
* \brief Creates an iterator for the list l.
+ *
* The iterator points to the specified list node.
* \param l The source list
* \param pNode The list node to point to
@@ -185,6 +188,7 @@ public:
/**
* \brief Creates an iterator copy.
+ *
* The new iterator points exactly to the item pointed by src.
* \param src The source item to copy
* \return void
@@ -197,6 +201,7 @@ public:
public:
/**
* \brief Moves the iterator to the first element of the list.
+ *
* Returns true in case of success or false if the list is empty.
* \return bool
*/
@@ -208,6 +213,7 @@ public:
/**
* \brief Moves the iterator to the last element of the list.
+ *
* Returns true in case of success or false if the list is empty.
* \return bool
*/
@@ -219,6 +225,7 @@ public:
/**
* \brief Moves the iterator to the next element of the list.
+ *
* The iterator must be actually valid for this function to work.
* Returns true in case of success or false if there is no next item.
* \return bool
@@ -232,6 +239,7 @@ public:
/**
* \brief Moves the iterator to the next element of the list.
+ *
* The iterator must be actually valid for this operator to work.
* Returns true in case of success or false if there is no next item.
* This is just a convenient alias to moveNext().
@@ -246,6 +254,7 @@ public:
/**
* \brief Moves the iterator to the previous element of the list.
+ *
* The iterator must be actually valid for this function to work.
* Returns true in case of success or false if there is no previous
* item.
@@ -260,6 +269,7 @@ public:
/**
* \brief Moves the iterator to the previous element of the list.
+ *
* The iterator must be actually valid for this operator to work.
* Returns true in case of success or false if there is no previous
* item.
@@ -275,6 +285,7 @@ public:
/**
* \brief Returs the value pointed by the iterator.
+ *
* If the iterator is not valid, returns NULL.
* \return T *
*/
@@ -285,6 +296,7 @@ public:
/**
* \brief Returs the value pointed by the iterator.
+ *
* If the iterator is not valid, returns NULL.
* This is just an alias to current().
* \return T *
@@ -296,6 +308,7 @@ public:
/**
* \brief Returns true if this iterator points to a valid element
+ *
* Returns false otherwise.
* \return bool
*/
@@ -363,6 +376,7 @@ protected:
protected:
/**
* \brief Inserts the item d before the item ref
+ *
* If ref is not found in the list, it inserts d at the beginning
* Also sets the current iteration pointer to the newly inserted
* item
@@ -388,8 +402,7 @@ protected:
}
/**
- * Grabs the first element from the list src
- * and puts it as the first element of this list.
+ * \brief Grabs the first element from the list src and puts it as the first element of this list.
* \param src The source list
* \return void
*/
@@ -447,6 +460,7 @@ protected:
public:
/**
* \brief Inserts the list src inside this list
+ *
* It respects the sort order.
* The src list elements are removed.
* \param src The list to insert
@@ -517,6 +531,7 @@ public:
/**
* \brief Sorts this list in ascending order.
+ *
* There must be an int kvi_compare(const T *p1, const T *p2)
* function which returns a value less than, equal to or greater
* than zero when the item p1 is considered lower than, equal to or
@@ -552,6 +567,7 @@ public:
/**
* \brief Inserts the item respecting the sorting order inside the list.
+ *
* The list itself must be already sorted for this to work
* correctly.
* There must be a int kvi_compare(const T *p1, const T * p2) that
@@ -588,6 +604,7 @@ public:
/**
* \brief Returns the first item in the list
+ *
* Sets the iteration pointer to the first item in the list and
* returns that item (or 0 if the list is empty)
* \return T *
@@ -605,6 +622,7 @@ public:
/**
* \brief Removes the first element from the list
+ *
* It returns the item to the caller. This function obviously never
* deletes the item (regadless of autoDeletion()).
* \return T *
@@ -638,6 +656,7 @@ public:
/**
* \brief Returns the last item in the list
+ *
* Sets the iteration pointer to the last item in the list
* and returns that item (or 0 if the list is empty)
* \return T *
@@ -664,6 +683,7 @@ public:
/**
* \brief Returns the current iteration item
+ *
* A call to this function MUST be preceded by a call to
* first(),last(),at() or findRef()
* \return T *
@@ -675,6 +695,7 @@ public:
/**
* \brief Returns the current iteration item
+ *
* 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
@@ -688,6 +709,7 @@ public:
/**
* \brief Returns an iterator pointing to the current item in the list.
+ *
* A call to this function MUST be preceded by a call to
* first(),last(),at() or findRef()
* \return KviPointerListIterator<T>
@@ -699,6 +721,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)
* A call to this function MUST be preceded by a _succesfull_ call
@@ -715,6 +738,7 @@ public:
/**
* \brief Returns the previous item in the list
+ *
* Sets the iteration pointer to the previous item in the list and
* returns that item (or 0 if the beginning of the list has been
* reached).
@@ -732,6 +756,7 @@ public:
/**
* \brief Returns the item at index position
+ *
* Sets the iteration pointer to the nTh item in the list
* and returns that item (or 0 if the index is out of range)
* \param idx The index of the element to return
@@ -771,6 +796,7 @@ public:
/**
* \brief Returns the position of an item
+ *
* Sets the iteration pointer to the item with pointer d
* and returns its position (zero based index) in the list or -1 if
* the item cannot be found
@@ -875,6 +901,7 @@ public:
/**
* \brief Inserts the item d at the position specified by iIndex.
+ *
* The position is zero-based. If the specified position is out of
* the list then the item is appended.
* Note that this function costs O(n).
@@ -900,6 +927,7 @@ public:
/**
* \brief Removes the first item (if any)
+ *
* The item is deleted if autoDelete() is set to true
* \return bool
*/
@@ -928,6 +956,7 @@ public:
/**
* \brief Removes the firstitem (if any)
+ *
* The item is deleted if autoDelete() is set to true
* \return bool
*/
@@ -956,6 +985,7 @@ public:
/**
* \brief Removes the item at zero-based position iIndex.
+ *
* Does nothing and returns false if iIndex is out of the list.
* Please note that this function costs O(n).
* \param iIndex The index where to remove the item
@@ -977,6 +1007,7 @@ public:
/**
* \brief Sets the autodelete flag
+ *
* When this flag is on (default), all the items are deleted when
* removed from the list (or when the list is destroyed or cleared
* explicitly)
@@ -999,7 +1030,8 @@ public:
/**
* \brief Removes all the items from the list
- * (the items are deleted if the autoDelete() flag is set to true)
+ *
+ * The items are deleted if the autoDelete() flag is set to true
* \return void
*/
void clear()
@@ -1009,6 +1041,7 @@ public:
/**
* \brief Removes the current iteration item.
+ *
* Returns true if the current iteration item was valid (and was
* removed) and false otherwise.
* \return bool
@@ -1023,6 +1056,7 @@ public:
/**
* \brief Removes the item pointed by d (if found in the list)
+ *
* The item is deleted if the autoDelete() flag is set to true)
* Returns true if the item was in the list and false otherwise.
* \param d The pointer to the item to delete
@@ -1037,6 +1071,7 @@ public:
/**
* \brief Inserts the item d after the item ref
+ *
* If ref is not found in the list, the item is inserted at the end
* Also sets the current iteration pointer to the newly inserted
* item
@@ -1065,6 +1100,7 @@ public:
/**
* \brief Inserts the item d before the item ref
+ *
* If ref is not found in the list, the item is inserted at the
* beginning.
* Also sets the current iteration pointer to the newly inserted
@@ -1126,6 +1162,7 @@ public:
/**
* \brief Clears the list and inserts all the items from the list l
+ *
* This is just an alias to copyFrom(l)
* \param l The source list to copy from
* \return KviPointerList<T> &
@@ -1152,6 +1189,7 @@ public:
/**
* \brief Destroys the list
+ *
* If autoDelete() is set to true, all the items are deleted
*/
virtual ~KviPointerList<T>()
diff --git a/src/kvilib/core/kvi_qstring.h b/src/kvilib/core/kvi_qstring.h
index 850611875..df3861519 100644
--- a/src/kvilib/core/kvi_qstring.h
+++ b/src/kvilib/core/kvi_qstring.h
@@ -140,6 +140,7 @@ namespace KviQString
/**
* \brief A portability wrapper which with Qt3 and Qt4.
+ *
* Returns a lowcase version of the parameter string.
* \param s The source string
* \return QString
@@ -151,6 +152,7 @@ namespace KviQString
/**
* \brief Returns the index position of the last occurrence of the character
+ *
* The search is made forward starting from index.
* \param s The source string
* \param c The character to find
@@ -165,6 +167,7 @@ namespace KviQString
/**
* \brief Returns the index position of the last occurrence of the character
+ *
* The search is made forward starting from index.
* \param s The source string
* \param c The character to find
@@ -179,6 +182,7 @@ namespace KviQString
/**
* \brief Returns the index position of the last occurrence of the string
+ *
* The search is made forward starting from index.
* \param s The source string
* \param str The string to find
@@ -193,6 +197,7 @@ namespace KviQString
/**
* \brief Returns the index position of the last occurrence of the string
+ *
* The search is made forward starting from index.
* \param s The source string
* \param str The string to find
@@ -207,6 +212,7 @@ namespace KviQString
/**
* \brief Returns the index position of the last occurrence of the string
+ *
* The search is made forward starting from index.
* \param s The source string
* \param rx The regexp to match
@@ -220,6 +226,7 @@ namespace KviQString
/**
* \brief Returns the index position of the last occurrence of the character
+ *
* The search is made backward.
* If index is -1 the search starts at the last character.
* \param s The source string
@@ -235,6 +242,7 @@ namespace KviQString
/**
* \brief Returns the index position of the last occurrence of the character
+ *
* The search is made backward.
* If index is -1 the search starts at the last character.
* \param s The source string
@@ -250,6 +258,7 @@ namespace KviQString
/**
* \brief Returns the index position of the last occurrence of the string str
+ *
* The search is made backward.
* If index is -1 the search starts at the last character.
* \param s The source string
@@ -265,6 +274,7 @@ namespace KviQString
/**
* \brief Returns the index position of the last occurrence of the string str
+ *
* The search is made backward.
* If index is -1 the search starts at the last character.
* \param s The source string
@@ -280,6 +290,7 @@ namespace KviQString
/**
* \brief Returns the index position of the last match of the regexp
+ *
* The search is made backward.
* If index is -1 the search starts at the last character.
* \param s The source string
@@ -294,6 +305,7 @@ namespace KviQString
/**
* \brief Return a whitespace-trimmed string
+ *
* Spaces are trimmed at start and end of the string
* \param s The source string
* \return QString
diff --git a/src/kvilib/file/kvi_fileutils.h b/src/kvilib/file/kvi_fileutils.h
index f4947656d..afd16d012 100644
--- a/src/kvilib/file/kvi_fileutils.h
+++ b/src/kvilib/file/kvi_fileutils.h
@@ -28,6 +28,7 @@
* \file kvi_fileutils.h
* \author Szymon Stefanek
* \brief File utilities functions
+*
* \def KVI_PATH_SEPARATOR Defines the path separator, UNIX or win32
* \def KVI_PATH_SEPARATOR_CHAR Defines the path separator char, UNIX or win32
*/
@@ -163,6 +164,7 @@ namespace KviFileUtils
/**
* \brief Reads a complete file and puts it in the string szBuffer
+ *
* The file must be smaller than uMaxSize bytes
* \param szPath The path to the file to read
* \param szBuffer The buffer where to load the file
@@ -173,6 +175,7 @@ namespace KviFileUtils
/**
* \brief Reads a complete file and puts it in the string szBuffer
+ *
* The file must be smaller than uMaxSize bytes
* \param path The path to the file to read
* \param szBuffer The buffer where to load the file
@@ -277,6 +280,7 @@ namespace KviFileUtils
/**
* \brief Translates ANY string into a valid filename (with no path!)
+ *
* There is NO way to come back to the original string the algo is
* one-way only
* \param path
diff --git a/src/kvilib/file/kvi_packagefile.h b/src/kvilib/file/kvi_packagefile.h
index ff094cbc4..8c61259c8 100644
--- a/src/kvilib/file/kvi_packagefile.h
+++ b/src/kvilib/file/kvi_packagefile.h
@@ -65,7 +65,10 @@ public:
* \return KviPackageIOEngine
*/
KviPackageIOEngine();
- /// Destroys the object
+
+ /**
+ * \brief Destroys the object
+ */
virtual ~KviPackageIOEngine();
protected:
QString m_szLastError;
@@ -123,6 +126,7 @@ protected:
/**
* \brief Sets the last error as write error
+ *
* This is a shortcut to setLastError()
* \return bool
*/
@@ -130,6 +134,7 @@ protected:
/**
* \brief Sets the last error as read error
+ *
* This is a shortcut to setLastError()
* \return bool
*/
@@ -139,6 +144,7 @@ protected:
/**
* \class KviPackageWriter
* \brief This class is used to create KVIrc package files.
+*
* You simply instantiate it, add some info fields, add some files and then call
* pack().
*/
@@ -150,7 +156,10 @@ public:
* \return KviPackageWriter
*/
KviPackageWriter();
- /// Destroys the object
+
+ /**
+ * \brief Destroys the object
+ */
virtual ~KviPackageWriter();
protected:
/**
@@ -172,19 +181,24 @@ protected:
KviPointerList<DataField> * m_pDataFields;
int m_iCurrentProgress;
public:
- /// \enum AddFileFlags
+ /**
+ * \enum AddFileFlags
+ */
enum AddFileFlags {
NoCompression = 1, /**< If you don't want to compress the file */
FollowSymLinks = 2 /**< If you want to follow the symlinks */
};
- /// \enum PackFlags
+ /**
+ * \enum PackFlags
+ */
enum PackFlags {
NoProgressDialog = 1 /**< If you want to avoid the progress dialog */
};
/**
* \brief Adds a file to the package.
+ *
* The file must be specified as absolute local path and as target path
* relative to the KVIrc local directory.
* This is a shortcut to addFileInternal()
@@ -223,6 +237,7 @@ public:
/**
* \brief Attempts to pack everything and store it as the specified file.
+ *
* This is a shortcut to packInternal() hiding the progress dialog
* There is no mandatory extension but you *should* use
* KVI_FILEEXTENSION_THEMEPACKAGE for themes and
@@ -235,6 +250,7 @@ public:
private:
/**
* \brief Attempts to pack everything and store it as the specified file.
+ *
* This is a shortcut to packFile() performing some checks
* \param szFileName The file name of the package
* \param uPackFlags The flags of the package
@@ -244,6 +260,7 @@ private:
/**
* \brief Attempts to pack everything and store it as the specified file.
+ *
* This is the real pack() function
* \param pFile The source file package
* \param pDataField The data field for the package
@@ -253,6 +270,7 @@ private:
/**
* \brief Adds a file to the package.
+ *
* This is the real addFile() function
* \param fi THe information of the file
* \param szLocalFileName The source file
@@ -266,6 +284,7 @@ private:
/**
* \class KviPackageReader
* \brief This class is used to read KVIrc package files.
+*
* You simply instantiate it and then call unpack().
*/
class KVILIB_API KviPackageReader : public KviPackageIOEngine
@@ -276,16 +295,22 @@ public:
* \return KviPackageReader
*/
KviPackageReader();
- /// Destroys the object
+
+ /**
+ * \brief Destroys the object
+ */
virtual ~KviPackageReader();
public:
- /// \enum UnpackFlags
+ /**
+ * \enum UnpackFlags
+ */
enum UnpackFlags {
NoProgressDialog = 1 /**< If you want to avoid the progress dialog */
};
/**
* \brief Read the header of the package
+ *
* This is a shortcut to readHeaderInternal()
* \param szLocalFileName The source package
* \return bool
@@ -302,6 +327,7 @@ public:
/**
* \brief Unpack the KVIrc package file
+ *
* This is a shortcut to unpackInternal() hiding the progress dialog
* \param szLocalFileName The source package
* \param szUnpackPath The path where to unpack the package
@@ -312,6 +338,7 @@ public:
private:
/**
* \brief Unpack the KVIrc package file
+ *
* This is a shortcut to unpackFile() performing some checks
* \param szLocalFileName The source package
* \param szUnpackPath The path where to unpack the package
@@ -322,6 +349,7 @@ private:
/**
* \brief Unpack the KVIrc package file
+ *
* This is the real unpack() function.
* \param pFile The source file package
* \param szUnpackPath The path where to unpack the package
@@ -331,6 +359,7 @@ private:
/**
* \brief Read the header of the package
+ *
* This is the real readHeader() function
* \param pFile The pointer to the real file
* \param szLocalFileName The source package
diff --git a/src/kvilib/irc/kvi_avatar.h b/src/kvilib/irc/kvi_avatar.h
index f6899e57e..e675204d8 100644
--- a/src/kvilib/irc/kvi_avatar.h
+++ b/src/kvilib/irc/kvi_avatar.h
@@ -94,6 +94,7 @@ public:
/**
* \brief Returns fiename.
+ *
* For remote avatars, remote address will be returned.
* \return const QString &
*/
@@ -127,6 +128,7 @@ public:
/**
* \brief Returns true if pixmap has at least one loaded frame.
+ *
* Returns false otherwise.
* \return bool
*/
@@ -145,6 +147,7 @@ public:
/**
* \brief Returns animated pixmap, scaled to the requisted size.
+ *
* Scaling automagically keeps aspect ratio.
* Scaled image cached.
*
@@ -160,6 +163,7 @@ public:
/**
* \brief Returns animated pixmap, scaled to the requisted size.
+ *
* Scaling automagically keeps aspect ratio.
* Scaled image cached.
*
@@ -178,6 +182,7 @@ public:
/**
* \brief Returns the string that uniquely identifies this avatar.
+ *
* For remote avatars that have name starting with http:// the name is used.
* For local avatars the localPath is used instead
* \return const QString &
diff --git a/src/kvilib/irc/kvi_ircmask.h b/src/kvilib/irc/kvi_ircmask.h
index eaa9ad548..5c17ef8bf 100644
--- a/src/kvilib/irc/kvi_ircmask.h
+++ b/src/kvilib/irc/kvi_ircmask.h
@@ -119,6 +119,7 @@ public:
public:
/**
* \brief Sets the nick for this user.
+ *
* If szNick is NULL or it points to an empty string the nick is set to "*".
* \param szNick The nickname of the user
* \return void
@@ -127,6 +128,7 @@ public:
/**
* \brief Sets the username for this user.
+ *
* If szUsername is NULL or it points to an empty string the username is set to "*".
* \param szUser The username of the user
* \return void
@@ -135,6 +137,7 @@ public:
/**
* \brief Sets the username for this user.
+ *
* If szUsername is NULL or it points to an empty string the username is set to "*".
* This is an alias of setUsername()
* \param szUser The username of the user
@@ -144,6 +147,7 @@ public:
/**
* \brief Sets the host for this user.
+ *
* If szHost is NULL or it points to an empty string the host is set to "*".
* \param szHost The hostname of the user
* \return void
@@ -166,6 +170,7 @@ public:
/**
* \brief Returns the nickname of this user.
+ *
* In the worst case you get a string == "*"
* \return const QString &
*/
@@ -173,6 +178,7 @@ public:
/**
* \brief Returns the username of this user.
+ *
* In the worst case you get a string == "*"
* \return const QString &
*/
@@ -180,6 +186,7 @@ public:
/**
* \brief Returns the hostname of this user.
+ *
* In the worst case you get a string == "*"
* \return const QString &
*/
@@ -205,6 +212,7 @@ public:
/**
* \brief Returns in szMask the specified (if possible) mask of this user.
+ *
* If the host or username are not known , the mask may contain less
* information than requested.
* \param szMask The mask of the user
@@ -268,6 +276,7 @@ public:
private:
/**
* \brief Returns the number of characters which are parts of the IP
+ *
* The IP is in the form xxx.xxx.xxx.*
* \return int
*/
@@ -275,6 +284,7 @@ private:
/**
* \brief Returns the number of characters which are parts of the IP
+ *
* The IP is in the form xxx.xxx.*
* \return int
*/
@@ -293,7 +303,7 @@ private:
QString getLargeHostDomainMask() const;
/**
- * \brief
+ * \brief Returns true if the user has the ip in the mask
* \return bool
* \warning This is just a GUESS and must be called AFTER making sure that it is NOT a plain numeric IP
*/
diff --git a/src/kvilib/irc/kvi_ircuserdb.h b/src/kvilib/irc/kvi_ircuserdb.h
index fed7ffff9..3e98bf75e 100644
--- a/src/kvilib/irc/kvi_ircuserdb.h
+++ b/src/kvilib/irc/kvi_ircuserdb.h
@@ -32,6 +32,7 @@
*
* The defines are ordered from the least to the most powerful. All the flags are
* usermodes.
+*
* \def KVI_USERFLAG_USEROP Defines the userop user
* \def KVI_USERFLAG_VOICE Defines the voice user
* \def KVI_USERFLAG_HALFOP Defines the halfop user
diff --git a/src/kvilib/irc/kvi_network.h b/src/kvilib/irc/kvi_network.h
index 620d7eabc..96f851841 100644
--- a/src/kvilib/irc/kvi_network.h
+++ b/src/kvilib/irc/kvi_network.h
@@ -93,16 +93,18 @@ public:
/**
* \brief Returns the encoding of the network
- * \return const QString &
+ *
* Some informations as nickname and channel names are encoded when
* communicating with the server
+ * \return const QString &
*/
inline const QString & encoding() const { return m_szEncoding; };
/**
* \brief Returns the text encoding of the network
- * \return const QString &
+ *
* This is the default encoding when talking on channels or queries
+ * \return const QString &
*/
inline const QString & textEncoding() const { return m_szTextEncoding; };
@@ -189,6 +191,7 @@ public:
/**
* \brief Sets the encondig of the network
+ *
* Some informations as nickname and channel names are encoded when
* communicating with the server
* \param szEncoding The encoding of the network
@@ -198,6 +201,7 @@ public:
/**
* \brief Sets the text encondig of the network
+ *
* This is the default encoding when talking on channels or queries
* \param szEncoding The text encoding of the network
* \return void
diff --git a/src/kvilib/system/kvi_env.h b/src/kvilib/system/kvi_env.h
index 7b3d544c6..f44868050 100644
--- a/src/kvilib/system/kvi_env.h
+++ b/src/kvilib/system/kvi_env.h
@@ -29,6 +29,7 @@
* \file kvi_env.h
* \author Szymon Stefanek
* \brief Environment function wrappers
+*
* \def kvi_setenv(__name,__value) Defines kvi_setenv(__name,__value) as SetEnvironmentVariable(__name,__value) on win32
* \def kvi_unsetenv(__name) Defines kvi_unsetenv(__name) as SetEnvironmentVariable(__name,NULL) on win32
*/
diff --git a/src/kvilib/system/kvi_process.h b/src/kvilib/system/kvi_process.h
index 24b30a1f0..a81aaaf36 100644
--- a/src/kvilib/system/kvi_process.h
+++ b/src/kvilib/system/kvi_process.h
@@ -28,6 +28,7 @@
* \file kvi_process.h
* \author Szymon Stefanek
* \brief A simple name redefinition
+*
* \def KviProcess Defines KviProcess as QProcess
*/
#include "kvi_settings.h"
diff --git a/src/kvirc/kernel/kvi_app.cpp b/src/kvirc/kernel/kvi_app.cpp
index 2bc679dbc..b5874685a 100644
--- a/src/kvirc/kernel/kvi_app.cpp
+++ b/src/kvirc/kernel/kvi_app.cpp
@@ -444,8 +444,8 @@ void KviApp::setup()
KVI_SPLASH_SET_PROGRESS(89)
KviInputHistory::init();
- if(getReadOnlyConfigPath(tmp,KVI_CONFIGFILE_INPUTHISTORY))
- KviInputHistory::instance()->load(tmp);
+ if(getReadOnlyConfigPath(tmp,KVI_CONFIGFILE_INPUTHISTORY))
+ KviInputHistory::instance()->load(tmp);
KVI_SPLASH_SET_PROGRESS(90)
diff --git a/src/kvirc/ui/kvi_input.cpp b/src/kvirc/ui/kvi_input.cpp
index 9337b6ec4..1a56b86b8 100644
--- a/src/kvirc/ui/kvi_input.cpp
+++ b/src/kvirc/ui/kvi_input.cpp
@@ -72,8 +72,8 @@ extern KviTalPopupMenu * g_pInputPopup;
QFontMetrics * g_pLastFontMetrics = 0;
-KviInput::KviInput(KviWindow * par ,KviUserListView * view)
-: QWidget(par)
+KviInput::KviInput(KviWindow * pPar ,KviUserListView * pView)
+: QWidget(pPar)
{
setObjectName("input_widget");
m_pLayout=new QHBoxLayout(this);
@@ -82,7 +82,7 @@ KviInput::KviInput(KviWindow * par ,KviUserListView * view)
m_pLayout->setMargin(0);
m_pLayout->setSpacing(0);
- m_pWindow = par;
+ m_pWindow = pPar;
m_pMultiLineEditor = 0;
m_pHideToolsButton = new QToolButton(this);
@@ -96,7 +96,7 @@ KviInput::KviInput(KviWindow * par ,KviUserListView * view)
connect(m_pHideToolsButton,SIGNAL(clicked()),this,SLOT(toggleToolButtons()));
- m_pButtonContainer=new KviTalHBox(this);
+ m_pButtonContainer = new KviTalHBox(this);
m_pButtonContainer->setSpacing(0);
m_pButtonContainer->setMargin(0);
@@ -161,7 +161,7 @@ KviInput::KviInput(KviWindow * par ,KviUserListView * view)
connect(m_pMultiEditorButton,SIGNAL(toggled(bool)),this,SLOT(multilineEditorButtonToggled(bool)));
- m_pInputEditor = new KviInputEditor(this,par,view);
+ m_pInputEditor = new KviInputEditor(this,pPar,pView);
connect(m_pInputEditor,SIGNAL(enterPressed()),this,SLOT(inputEditorEnterPressed()));
m_pInputEditor->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Ignored));
@@ -179,7 +179,8 @@ KviInput::KviInput(KviWindow * par ,KviUserListView * view)
KviInput::~KviInput()
{
- if(m_pMultiLineEditor)KviScriptEditor::destroyInstance(m_pMultiLineEditor);
+ if(m_pMultiLineEditor)
+ KviScriptEditor::destroyInstance(m_pMultiLineEditor);
}
bool KviInput::isButtonsHidden()
@@ -189,8 +190,10 @@ bool KviInput::isButtonsHidden()
void KviInput::setButtonsHidden(bool bHidden)
{
- if(!m_pHideToolsButton || !m_pButtonContainer) return;
- if(bHidden==m_pButtonContainer->isHidden()) return;
+ if(!m_pHideToolsButton || !m_pButtonContainer)
+ return;
+ if(bHidden==m_pButtonContainer->isHidden())
+ return;
m_pButtonContainer->setHidden(bHidden);
QPixmap * pix= bHidden ?
g_pIconManager->getBigIcon("kvi_horizontal_right.png") :
@@ -250,11 +253,11 @@ void KviInput::keyPressEvent(QKeyEvent *e)
this,
__tr2qs("Confirm Multiline Message"),
__tr2qs("You're about to send a message with %1 lines of text.<br><br>" \
- "There is nothing wrong with it, this warning is<br>" \
- "here to prevent you from accidentally sending<br>" \
- "a really large message just because you didn't edit it<br>" \
- "properly after pasting text from the clipboard.<br><br>" \
- "Do you want the message to be sent?").arg(nLines),
+ "There is nothing wrong with it, this warning is<br>" \
+ "here to prevent you from accidentally sending<br>" \
+ "a really large message just because you didn't edit it<br>" \
+ "properly after pasting text from the clipboard.<br><br>" \
+ "Do you want the message to be sent?").arg(nLines),
__tr2qs("Yes, always"),
__tr2qs("Yes"),
__tr2qs("No"),
@@ -288,7 +291,8 @@ void KviInput::keyPressEvent(QKeyEvent *e)
void KviInput::multiLinePaste(const QString & szText)
{
- if(!m_pMultiLineEditor)multilineEditorButtonToggled(true);
+ if(!m_pMultiLineEditor)
+ multilineEditorButtonToggled(true);
m_pMultiLineEditor->setText(szText);
}
@@ -296,7 +300,7 @@ void KviInput::multilineEditorButtonToggled(bool bOn)
{
if(m_pMultiLineEditor)
{
- if(bOn)return;
+ if(bOn) return;
QString szTmp;
m_pMultiLineEditor->getText(szTmp);
m_pLayout->removeWidget(m_pMultiLineEditor);
@@ -309,7 +313,7 @@ void KviInput::multilineEditorButtonToggled(bool bOn)
m_pInputEditor->setFocus();
m_pMultiEditorButton->setChecked(false);
} else {
- if(!bOn)return;
+ if(!bOn) return;
m_pMultiLineEditor = KviScriptEditor::createInstance(this);
QString szText = __tr2qs("<Ctrl+Return>; submits, <Ctrl+Backspace>; hides this editor");
m_pMultiLineEditor->setFindText(szText);
@@ -333,7 +337,8 @@ void KviInput::iconButtonClicked()
void KviInput::historyButtonClicked()
{
- if(!g_pHistoryWindow)g_pHistoryWindow = new KviHistoryWindowWidget();
+ if(!g_pHistoryWindow)
+ g_pHistoryWindow = new KviHistoryWindowWidget();
QPoint pnt = mapToGlobal(QPoint(0,0));
@@ -377,7 +382,8 @@ int KviInput::heightHint() const
void KviInput::setText(const QString & szText)
{
// FIXME: Latin1 -> QString ?
- if(m_pMultiLineEditor)m_pMultiLineEditor->setText(szText);
+ if(m_pMultiLineEditor)
+ m_pMultiLineEditor->setText(szText);
else m_pInputEditor->setText(szText);
}
@@ -426,7 +432,7 @@ QString KviInput::text()
if(m_pMultiLineEditor)
m_pMultiLineEditor->getText(szText);
else
- szText=m_pInputEditor->text();
+ szText = m_pInputEditor->text();
return szText;
}
#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
diff --git a/src/kvirc/ui/kvi_input.h b/src/kvirc/ui/kvi_input.h
index 1b79cb00f..a9e4a33ad 100644
--- a/src/kvirc/ui/kvi_input.h
+++ b/src/kvirc/ui/kvi_input.h
@@ -24,6 +24,12 @@
//
//============================================================================
+/**
+* \file kvi_input.h
+* \author Szymon Stefanek
+* \brief Input handling
+*/
+
#include "kvi_settings.h"
#include "kvi_input_history.h"
@@ -38,11 +44,25 @@ class KviTalHBox;
class KviTalPopupMenu;
class KviScriptEditor;
+/**
+* \class KviInput
+* \brief Input handling class
+*/
class KVIRC_API KviInput : public QWidget
{
Q_OBJECT
public:
- KviInput(KviWindow * par, KviUserListView * view = 0);
+ /**
+ * \brief Constructs the input object
+ * \param pPar The parent window
+ * \param pView The userlist
+ * \return KviInput
+ */
+ KviInput(KviWindow * pPar, KviUserListView * pView = 0);
+
+ /**
+ * \brief Destroys the input object
+ */
~KviInput();
public:
KviWindow * m_pWindow;
@@ -55,33 +75,133 @@ public:
QToolButton * m_pCommandlineModeButton;
QToolButton * m_pHideToolsButton;
QHBoxLayout * m_pLayout;
-protected:
- //virtual void resizeEvent(QResizeEvent * e);
- virtual void focusInEvent(QFocusEvent * e);
- virtual void setFocusProxy(QWidget * w);
- virtual void keyPressEvent(QKeyEvent * e);
-public slots:
- void multilineEditorButtonToggled(bool bOn);
- void historyButtonClicked();
- void iconButtonClicked();
- void inputEditorEnterPressed();
- void toggleToolButtons();
public:
+ /**
+ * \brief Sets the focus to the input line
+ * \return void
+ */
virtual void setFocus();
+
+ /**
+ * \brief Opens the multiline editor and pastes the given text
+ * \param szText The text to paste
+ * \return void
+ */
void multiLinePaste(const QString & szText);
+
+ /**
+ * \brief Returns true if the input line is in user-friendly mode
+ * \return bool
+ */
bool isUserFriendly() { return m_pCommandlineModeButton->isChecked(); };
+
+ /**
+ * \brief Sets the user-friendly mode to the input line
+ * \param bSet Whether to set the user-friendly mode
+ * \return void
+ */
void setUserFriendly(bool bSet) { m_pCommandlineModeButton->setChecked(bSet); };
+
+ /**
+ * \brief Returns the height of the input line
+ * \return int
+ */
int heightHint() const;
+
+ /**
+ * \brief Sets the given text
+ * \param szText The text to set in the input line
+ * \return void
+ */
void setText(const QString & szText);
+
+ /**
+ * \brief Inserts the given character
+ * \param c The character to insert
+ * \return void
+ */
void insertChar(char c);
+
+ /**
+ * \brief Inserts the given text
+ * \param szText The text to insert
+ * \return void
+ */
void insertText(const QString & szText);
+
+ /**
+ * \brief Saves and applies the options
+ * \return void
+ */
void applyOptions();
+
+ /**
+ * \brief Returns true if the buttons on the right are hidden
+ * \return bool
+ */
bool isButtonsHidden();
+
+ /**
+ * \brief Sets the hidden status of the button on the right
+ * \param bHidden Whether to hide the buttons
+ * \return void
+ */
void setButtonsHidden(bool bHidden);
- //const QString & text();
+
+ /**
+ * \brief Returns the text written in the input line
+ * \return QString
+ */
QString text();
+ //const QString & text();
+
+ /**
+ * \brief Return the instance of the input editor
+ * \return KviInputEditor *
+ */
inline KviInputEditor * editor(){ return m_pInputEditor; };
+
+ /**
+ * \brief Return the instance of the input history
+ * \return KviInputHistory *
+ */
inline KviInputHistory * history(){ return KviInputHistory::instance(); };
+public slots:
+ /**
+ * \brief Toggles the multiline editor
+ * \param bOn Whether to activate the multiline editor
+ * \return void
+ */
+ void multilineEditorButtonToggled(bool bOn);
+
+ /**
+ * \brief Shows the history popup
+ * \return void
+ */
+ void historyButtonClicked();
+
+ /**
+ * \brief Shows the icon popup
+ * \return void
+ */
+ void iconButtonClicked();
+
+ /**
+ * \brief Parses the text written and clears the input line
+ * \return void
+ */
+ void inputEditorEnterPressed();
+
+ /**
+ * \brief Toggles the buttons
+ * \return void
+ */
+ void toggleToolButtons();
+protected:
+ //virtual void resizeEvent(QResizeEvent * e);
+ virtual void focusInEvent(QFocusEvent * e);
+ virtual void setFocusProxy(QWidget * w);
+ virtual void keyPressEvent(QKeyEvent * e);
};
#endif //_KVI_INPUT_H_
diff --git a/src/kvirc/ui/kvi_input_editor.cpp b/src/kvirc/ui/kvi_input_editor.cpp
index 26ab8c16b..ea9560a09 100644
--- a/src/kvirc/ui/kvi_input_editor.cpp
+++ b/src/kvirc/ui/kvi_input_editor.cpp
@@ -21,6 +21,8 @@
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
//============================================================================
+// This file was originally part of kvi_input.h
+//============================================================================
#include "kvi_input.h"
#include "kvi_input_editor.h"
@@ -51,16 +53,10 @@
#include <QPixmap>
#include <QFileDialog>
#include <QFontMetrics>
-
#include <QKeyEvent>
#include <QDragEnterEvent>
-#ifndef ACCEL_KEY
-#define ACCEL_KEY(k) "\t" + QString(QKeySequence( Qt::CTRL | Qt::Key_ ## k ))
-#endif
-
-
// from kvi_input.cpp
extern QFontMetrics * g_pLastFontMetrics;
@@ -70,18 +66,16 @@ extern KviTextIconWindowWidget * g_pTextIconWindow;
extern KviColorWindow * g_pColorWindow;
extern QPixmap * g_pShadedChildGlobalDesktopBackground;
-
-
static int g_iInputFontCharWidth[256];
static bool g_bInputFontMetricsDirty = true;
-KviInputEditor::KviInputEditor(QWidget * par,KviWindow *wnd,KviUserListView * view)
-:QFrame(par)
+KviInputEditor::KviInputEditor(QWidget * pPar, KviWindow * pWnd, KviUserListView * pView)
+:QFrame(pPar)
{
setObjectName("input_frame");
m_pIconMenu = 0;
- m_pInputParent = par;
+ m_pInputParent = pPar;
m_iMaxBufferSize = KVI_INPUT_MAX_BUFFER_SIZE;
m_iCursorPosition = 0; //Index of the char AFTER the cursor
m_iFirstVisibleChar = 0; //Index of the first visible character
@@ -101,8 +95,8 @@ KviInputEditor::KviInputEditor(QWidget * par,KviWindow *wnd,KviUserListView * vi
m_iSelectionAnchorChar = -1; //Character clicked at the beginning of the selection process
m_iCurHistoryIdx = -1; //No data in the history
m_bUpdatesEnabled = true;
- m_pKviWindow = wnd;
- m_pUserListView = view;
+ m_pKviWindow = pWnd;
+ m_pUserListView = pView;
m_pHistory = new KviPointerList<QString>;
m_pHistory->setAutoDelete(true);
m_bReadOnly = FALSE;
@@ -123,27 +117,35 @@ KviInputEditor::KviInputEditor(QWidget * par,KviWindow *wnd,KviUserListView * vi
KviInputEditor::~KviInputEditor()
{
- if(g_pLastFontMetrics) delete g_pLastFontMetrics;
+ if(g_pLastFontMetrics)
+ delete g_pLastFontMetrics;
g_pLastFontMetrics = 0;
- if(m_pIconMenu)delete m_pIconMenu;
+
+ if(m_pIconMenu)
+ delete m_pIconMenu;
+
delete m_pHistory;
- if(m_iCursorTimer)killTimer(m_iCursorTimer);
+
+ if(m_iCursorTimer)
+ killTimer(m_iCursorTimer);
killDragTimer();
}
-void KviInputEditor::recalcFontMetrics(QFontMetrics * pFm)
+void KviInputEditor::recalcFontMetrics()
{
QFontMetrics fm(KVI_OPTION_FONT(KviOption_fontInput));
- unsigned short i;
- for(i=1;i<32;i++)
+ unsigned short u;
+ for(u=1; u<32; u++)
{
- QChar c = getSubstituteChar(i);
- g_iInputFontCharWidth[i] = fm.width(c);
- if(c != QChar(i))g_iInputFontCharWidth[i] += 4;
+ QChar c = getSubstituteChar(u);
+ g_iInputFontCharWidth[u] = fm.width(c);
+ if(c != QChar(u))
+ g_iInputFontCharWidth[u] += 4;
}
- for(i=32;i<256;i++)
+
+ for(u=32; u<256; u++)
{
- g_iInputFontCharWidth[i] = fm.width(QChar(i));
+ g_iInputFontCharWidth[u] = fm.width(QChar(u));
}
g_bInputFontMetricsDirty = false;
}
@@ -154,12 +156,13 @@ void KviInputEditor::applyOptions()
update();
}
-void KviInputEditor::dragEnterEvent(QDragEnterEvent *e)
+void KviInputEditor::dragEnterEvent(QDragEnterEvent * e)
{
- if(e->mimeData()->hasUrls()) e->acceptProposedAction();
+ if(e->mimeData()->hasUrls())
+ e->acceptProposedAction();
}
-void KviInputEditor::dropEvent(QDropEvent *e)
+void KviInputEditor::dropEvent(QDropEvent * e)
{
QList<QUrl> list;
if(e->mimeData()->hasUrls())
@@ -173,17 +176,18 @@ void KviInputEditor::dropEvent(QDropEvent *e)
for( ; it != list.end(); ++it )
{
QUrl url = *it;
- QString path = url.path();
+ QString szPath = url.path();
#if !defined(COMPILE_ON_WINDOWS) && !defined(COMPILE_ON_MINGW)
- if(path.length() > 0)
+ if(szPath.length() > 0)
{
- if(path[0] != QChar('/'))path.prepend("/"); //HACK HACK HACK for Qt bug (?!?)
+ if(szPath[0] != QChar('/'))
+ szPath.prepend("/"); //HACK HACK HACK for Qt bug (?!?)
}
#endif
- path.prepend("/PARSE \"");
- path.append("\"");
+ szPath.prepend("/PARSE \"");
+ szPath.append("\"");
if(m_pKviWindow)
- KviKvsScript::run(path,m_pKviWindow);
+ KviKvsScript::run(szPath,m_pKviWindow);
}
}
}
@@ -205,14 +209,11 @@ QSize KviInputEditor::sizeHint() const
QStyleOption opt;
opt.initFrom(this);
return (style()->sizeFromContents(QStyle::CT_LineEdit,&opt,
- QSize( w + m, h + m ).
- expandedTo(QApplication::globalStrut()),this));
+ QSize( w + m, h + m ).
+ expandedTo(QApplication::globalStrut()),this));
}
-#define KVI_INPUT_DEF_BACK 100
-#define KVI_INPUT_DEF_FORE 101
-
-void KviInputEditor::paintEvent(QPaintEvent *e)
+void KviInputEditor::paintEvent(QPaintEvent * e)
{
QPainter p(this);
SET_ANTI_ALIASING(p);
@@ -220,15 +221,15 @@ void KviInputEditor::paintEvent(QPaintEvent *e)
drawContents(&p);
}
-void KviInputEditor::drawContents(QPainter *p)
+void KviInputEditor::drawContents(QPainter * p)
{
if(!isVisible())return;
QRect rect = contentsRect();
- int widgetWidth = rect.width();
- int widgetHeight = rect.height();
+ int iWidgetWidth = rect.width();
+ int iWidgetHeight = rect.height();
- KviDoubleBuffer doublebuffer(widgetWidth,widgetHeight);
+ KviDoubleBuffer doublebuffer(iWidgetWidth,iWidgetHeight);
QPixmap * pDoubleBufferPixmap = doublebuffer.pixmap();
QPainter pa(pDoubleBufferPixmap);
@@ -242,42 +243,40 @@ void KviInputEditor::drawContents(QPainter *p)
g_pLastFontMetrics = new QFontMetrics(pa.fontMetrics());
if(g_bInputFontMetricsDirty)
- recalcFontMetrics(&fm);
-
+ recalcFontMetrics();
#ifdef COMPILE_PSEUDO_TRANSPARENCY
if(g_pShadedChildGlobalDesktopBackground)
{
QPoint pnt = mapToGlobal(rect.topLeft());
- pa.drawTiledPixmap(0,0,widgetWidth,widgetHeight,*g_pShadedChildGlobalDesktopBackground,pnt.x(),pnt.y());
+ pa.drawTiledPixmap(0,0,iWidgetWidth,iWidgetHeight,*g_pShadedChildGlobalDesktopBackground,pnt.x(),pnt.y());
} else {
#endif
- QPixmap *pix=KVI_OPTION_PIXMAP(KviOption_pixmapInputBackground).pixmap();
+ QPixmap * pPix = KVI_OPTION_PIXMAP(KviOption_pixmapInputBackground).pixmap();
- pa.fillRect(0,0,widgetWidth,widgetHeight,KVI_OPTION_COLOR(KviOption_colorInputBackground));
- if(pix)
- KviPixmapUtils::drawPixmapWithPainter(&pa,pix,KVI_OPTION_UINT(KviOption_uintInputPixmapAlign),rect,widgetWidth,widgetHeight);
+ pa.fillRect(0,0,iWidgetWidth,iWidgetHeight,KVI_OPTION_COLOR(KviOption_colorInputBackground));
+ if(pPix)
+ KviPixmapUtils::drawPixmapWithPainter(&pa,pPix,KVI_OPTION_UINT(KviOption_uintInputPixmapAlign),rect,iWidgetWidth,iWidgetHeight);
#ifdef COMPILE_PSEUDO_TRANSPARENCY
}
#endif
-
- int curXPos = KVI_INPUT_MARGIN;
- int maxXPos = widgetWidth-2*KVI_INPUT_MARGIN;
+ int iCurXPos = KVI_INPUT_MARGIN;
+ int iMaxXPos = iWidgetWidth-2*KVI_INPUT_MARGIN;
m_iCurBack = KVI_INPUT_DEF_BACK; //transparent
m_iCurFore = KVI_INPUT_DEF_FORE; //normal fore color
m_bCurBold = false;
m_bCurUnderline = false;
- int bottom = widgetHeight-(widgetHeight-fm.height())/2;
- int textBaseline = fm.ascent()+(widgetHeight-fm.height())/2;
- int top = (widgetHeight-fm.height())/2;
+ int iBottom = iWidgetHeight-(iWidgetHeight-fm.height())/2;
+ int iTextBaseline = fm.ascent()+(iWidgetHeight-fm.height())/2;
+ int iTop = (iWidgetHeight-fm.height())/2;
runUpToTheFirstVisibleChar();
- int charIdx = m_iFirstVisibleChar;
+ int iCharIdx = m_iFirstVisibleChar;
- pa.setClipRect(0,0,widgetWidth,widgetHeight);
+ pa.setClipRect(0,0,iWidgetWidth,iWidgetHeight);
//Control the selection state
if((m_iSelectionEnd < m_iSelectionBegin) || (m_iSelectionEnd == -1) || (m_iSelectionBegin == -1))
@@ -290,13 +289,14 @@ void KviInputEditor::drawContents(QPainter *p)
{
int iSelStart = m_iSelectionBegin;
- // TODO Refactor: write a function to combine this with the code determining iIMStart and iIMSelectionStart
- if(iSelStart < m_iFirstVisibleChar)iSelStart = m_iFirstVisibleChar;
- int xLeft = xPositionFromCharIndex(fm,iSelStart,TRUE);
- int xRight = xPositionFromCharIndex(fm,m_iSelectionEnd + 1,TRUE);
+ // TODO Refactor: write a function to combine this with the code determining iIMStart and iIMSelectionStart
+ if(iSelStart < m_iFirstVisibleChar)
+ iSelStart = m_iFirstVisibleChar;
+ int iXLeft = xPositionFromCharIndex(fm,iSelStart,TRUE);
+ int iXRight = xPositionFromCharIndex(fm,m_iSelectionEnd + 1,TRUE);
// pa.setRasterOp(Qt::NotROP);
- pa.fillRect(xLeft,frameWidth(),xRight - xLeft,widgetWidth,KVI_OPTION_COLOR(KviOption_colorInputSelectionBackground));
+ pa.fillRect(iXLeft,frameWidth(),iXRight - iXLeft,iWidgetWidth,KVI_OPTION_COLOR(KviOption_colorInputSelectionBackground));
// pa.setRasterOp(Qt::CopyROP);
}
@@ -310,11 +310,13 @@ void KviInputEditor::drawContents(QPainter *p)
{
// TODO Write a function to combine IM selection drawing code. maybe the preedit area too.
int iIMSelectionStart = m_iIMSelectionBegin;
- if(iIMSelectionStart < m_iFirstVisibleChar) iIMSelectionStart = m_iFirstVisibleChar;
- int xIMSelectionLeft = xPositionFromCharIndex(fm,iIMSelectionStart,TRUE);
- int xIMSelectionRight = xPositionFromCharIndex(fm,iIMSelectionStart + m_iIMSelectionLength,TRUE);
+ if(iIMSelectionStart < m_iFirstVisibleChar)
+ iIMSelectionStart = m_iFirstVisibleChar;
+
+ int iXIMSelectionLeft = xPositionFromCharIndex(fm,iIMSelectionStart,TRUE);
+ int iXIMSelectionRight = xPositionFromCharIndex(fm,iIMSelectionStart + m_iIMSelectionLength,TRUE);
// pa.setRasterOp(Qt::NotROP);
- pa.fillRect(xIMSelectionLeft,0,xIMSelectionRight - xIMSelectionLeft, widgetWidth,KVI_OPTION_COLOR(KviOption_colorInputSelectionBackground));
+ pa.fillRect(iXIMSelectionLeft,0,iXIMSelectionRight - iXIMSelectionLeft, iWidgetWidth,KVI_OPTION_COLOR(KviOption_colorInputSelectionBackground));
// pa.setRasterOp(Qt::CopyROP);
// highlight the IM selection
@@ -325,81 +327,78 @@ void KviInputEditor::drawContents(QPainter *p)
// underline the IM preedit
// Maybe should be put in drawTextBlock, similar to drawing underlined text
- pa.drawLine(xIMLeft, bottom, xIMRight, bottom);
+ pa.drawLine(xIMLeft, iBottom, xIMRight, iBottom);
}
pa.setClipping(false);
- while((charIdx < ((int)(m_szTextBuffer.length()))) && (curXPos < maxXPos))
+ while((iCharIdx < ((int)(m_szTextBuffer.length()))) && (iCurXPos < iMaxXPos))
{
- extractNextBlock(charIdx,fm,curXPos,maxXPos);
+ extractNextBlock(iCharIdx,fm,iCurXPos,iMaxXPos);
if(m_bControlBlock)
{
pa.setPen(KVI_OPTION_COLOR(KviOption_colorInputControl));
- QString s = getSubstituteChar(m_szTextBuffer[charIdx].unicode());
+ QString s = getSubstituteChar(m_szTextBuffer[iCharIdx].unicode());
// the block width is 4 pixels more than the actual character
- pa.drawText(curXPos + 2,textBaseline,s.left(1));
+ pa.drawText(iCurXPos + 2,iTextBaseline,s.left(1));
- pa.drawRect(curXPos,top,m_iBlockWidth-1,bottom);
+ pa.drawRect(iCurXPos,iTop,m_iBlockWidth-1,iBottom);
} else {
if(m_iSelectionBegin!=-1)
{
- int iBlockEnd=charIdx+m_iBlockLen;
+ int iBlockEnd = iCharIdx + m_iBlockLen;
//block is selected (maybe partially)
- if( iBlockEnd>m_iSelectionBegin && charIdx<=m_iSelectionEnd )
+ if( iBlockEnd > m_iSelectionBegin && iCharIdx <= m_iSelectionEnd )
{
int iSubStart,iSubLen;
//in common it consists of 3 parts: unselected-selected-unselected
//some of thst parts can be empty (for example block is fully selected)
//first part start is always equal to the block start
- iSubStart=charIdx;
- iSubLen = m_iSelectionBegin>charIdx ? m_iSelectionBegin-charIdx : 0;
-
+ iSubStart = iCharIdx;
+ iSubLen = m_iSelectionBegin > iCharIdx ? m_iSelectionBegin-iCharIdx : 0;
if(iSubLen)
{
- drawTextBlock(&pa,fm,curXPos,textBaseline,iSubStart,iSubLen,FALSE);
- curXPos += m_iBlockWidth;
+ drawTextBlock(&pa,fm,iCurXPos,iTextBaseline,iSubStart,iSubLen,FALSE);
+ iCurXPos += m_iBlockWidth;
m_iBlockWidth=0;
}
//second one
- iSubStart+=iSubLen;
- iSubLen=m_iSelectionEnd<iBlockEnd ? m_iSelectionEnd-iSubStart+1 : iBlockEnd-iSubStart;
-
+ iSubStart += iSubLen;
+ iSubLen = m_iSelectionEnd<iBlockEnd ? m_iSelectionEnd-iSubStart+1 : iBlockEnd-iSubStart;
if(iSubLen)
{
- drawTextBlock(&pa,fm,curXPos,textBaseline,iSubStart,iSubLen,TRUE);
- curXPos += m_iBlockWidth;
+ drawTextBlock(&pa,fm,iCurXPos,iTextBaseline,iSubStart,iSubLen,TRUE);
+ iCurXPos += m_iBlockWidth;
m_iBlockWidth=0;
}
- if( m_iSelectionEnd<(iBlockEnd-1))
+ if(m_iSelectionEnd<(iBlockEnd-1))
{
- iSubStart+=iSubLen;
- iSubLen=iBlockEnd-iSubStart;
- drawTextBlock(&pa,fm,curXPos,textBaseline,iSubStart,iSubLen,FALSE);
+ iSubStart += iSubLen;
+ iSubLen = iBlockEnd-iSubStart;
+ drawTextBlock(&pa,fm,iCurXPos,iTextBaseline,iSubStart,iSubLen,FALSE);
}
} else {
- drawTextBlock(&pa,fm,curXPos,textBaseline,charIdx,m_iBlockLen);
+ drawTextBlock(&pa,fm,iCurXPos,iTextBaseline,iCharIdx,m_iBlockLen);
}
} else {
- drawTextBlock(&pa,fm,curXPos,textBaseline,charIdx,m_iBlockLen);
+ drawTextBlock(&pa,fm,iCurXPos,iTextBaseline,iCharIdx,m_iBlockLen);
}
}
- curXPos += m_iBlockWidth;
- charIdx += m_iBlockLen;
+ iCurXPos += m_iBlockWidth;
+ iCharIdx += m_iBlockLen;
}
//Now the cursor
-
m_iLastCursorXPosition = KVI_INPUT_MARGIN;
m_iBlockLen = m_iFirstVisibleChar;
@@ -415,22 +414,22 @@ void KviInputEditor::drawContents(QPainter *p)
if(m_bCursorOn)
{
pa.setPen(KVI_OPTION_COLOR(KviOption_colorInputCursor));
- pa.drawLine(m_iLastCursorXPosition,0,m_iLastCursorXPosition,widgetHeight);
+ pa.drawLine(m_iLastCursorXPosition,0,m_iLastCursorXPosition,iWidgetHeight);
} else {
pa.setPen(KVI_OPTION_COLOR(KviOption_colorInputForeground));
}
// The other version of drawPixmap seems to be buggy
- p->drawPixmap(rect.x(),rect.y(),rect.width(),rect.height(),*pDoubleBufferPixmap,0,0,widgetWidth,widgetHeight);
+ p->drawPixmap(rect.x(),rect.y(),rect.width(),rect.height(),*pDoubleBufferPixmap,0,0,iWidgetWidth,iWidgetHeight);
}
-void KviInputEditor::drawTextBlock(QPainter * pa,QFontMetrics & fm,int curXPos,int textBaseline,int charIdx,int len,bool bSelected)
+void KviInputEditor::drawTextBlock(QPainter * pa, QFontMetrics & fm, int iCurXPos, int iTextBaseline, int iCharIdx, int iLen, bool bSelected)
{
- QString tmp = m_szTextBuffer.mid(charIdx,len);
- m_iBlockWidth = fm.width(tmp);
+ QString szTmp = m_szTextBuffer.mid(iCharIdx,iLen);
+ m_iBlockWidth = fm.width(szTmp);
QRect rect = contentsRect();
- int widgetHeight = rect.height();
+ int iWidgetHeight = rect.height();
if(m_iCurFore == KVI_INPUT_DEF_FORE)
{
@@ -448,25 +447,24 @@ void KviInputEditor::drawTextBlock(QPainter * pa,QFontMetrics & fm,int curXPos,i
{
if(((unsigned char)m_iCurBack) > 16)
{
- pa->fillRect(curXPos,(widgetHeight-fm.height())/2,m_iBlockWidth,fm.height(),KVI_OPTION_COLOR(KviOption_colorInputForeground));
+ pa->fillRect(iCurXPos,(iWidgetHeight-fm.height())/2,m_iBlockWidth,fm.height(),KVI_OPTION_COLOR(KviOption_colorInputForeground));
} else {
- pa->fillRect(curXPos,(widgetHeight-fm.height())/2,m_iBlockWidth,fm.height(),KVI_OPTION_MIRCCOLOR((unsigned char)m_iCurBack));
+ pa->fillRect(iCurXPos,(iWidgetHeight-fm.height())/2,m_iBlockWidth,fm.height(),KVI_OPTION_MIRCCOLOR((unsigned char)m_iCurBack));
}
}
- pa->drawText(curXPos,textBaseline,tmp);
+ pa->drawText(iCurXPos,iTextBaseline,szTmp);
- if(m_bCurBold)pa->drawText(curXPos+1,textBaseline,tmp);
+ if(m_bCurBold)pa->drawText(iCurXPos+1,iTextBaseline,szTmp);
if(m_bCurUnderline)
{
- pa->drawLine(curXPos,textBaseline + fm.descent(),curXPos+m_iBlockWidth,textBaseline + fm.descent());
+ pa->drawLine(iCurXPos,iTextBaseline + fm.descent(),iCurXPos+m_iBlockWidth,iTextBaseline + fm.descent());
}
-
}
-QChar KviInputEditor::getSubstituteChar(unsigned short control_code)
+QChar KviInputEditor::getSubstituteChar(unsigned short uControlCode)
{
- switch(control_code)
+ switch(uControlCode)
{
case KVI_TEXT_COLOR:
return QChar('K');
@@ -490,40 +488,46 @@ QChar KviInputEditor::getSubstituteChar(unsigned short control_code)
return QChar('I');
break;
default:
- return QChar(control_code);
+ return QChar(uControlCode);
break;
}
}
-void KviInputEditor::extractNextBlock(int idx,QFontMetrics & fm,int curXPos,int maxXPos)
+void KviInputEditor::extractNextBlock(int iIdx, QFontMetrics & fm, int iCurXPos, int iMaxXPos)
{
m_iBlockLen = 0;
m_iBlockWidth = 0;
- QChar c = m_szTextBuffer[idx];
+ QChar c = m_szTextBuffer[iIdx];
if((c.unicode() > 32) ||
((c != QChar(KVI_TEXT_COLOR)) &&
- (c != QChar(KVI_TEXT_BOLD)) && (c != QChar(KVI_TEXT_UNDERLINE)) &&
- (c != QChar(KVI_TEXT_RESET)) && (c != QChar(KVI_TEXT_REVERSE)) &&
- (c != QChar(KVI_TEXT_CRYPTESCAPE)) && (c != QChar(KVI_TEXT_ICON))))
+ (c != QChar(KVI_TEXT_BOLD)) &&
+ (c != QChar(KVI_TEXT_UNDERLINE)) &&
+ (c != QChar(KVI_TEXT_RESET)) &&
+ (c != QChar(KVI_TEXT_REVERSE)) &&
+ (c != QChar(KVI_TEXT_CRYPTESCAPE)) &&
+ (c != QChar(KVI_TEXT_ICON))))
{
m_bControlBlock = false;
//Not a control code...run..
- while((idx < ((int)(m_szTextBuffer.length()))) && (curXPos < maxXPos))
+ while((iIdx < ((int)(m_szTextBuffer.length()))) && (iCurXPos < iMaxXPos))
{
- c = m_szTextBuffer[idx];
+ c = m_szTextBuffer[iIdx];
if((c.unicode() > 32) ||
- ((c != QChar(KVI_TEXT_COLOR)) && (c != QChar(KVI_TEXT_BOLD)) &&
- (c != QChar(KVI_TEXT_UNDERLINE)) && (c != QChar(KVI_TEXT_RESET)) &&
- (c != QChar(KVI_TEXT_REVERSE)) && (c != QChar(KVI_TEXT_CRYPTESCAPE)) &&
+ ((c != QChar(KVI_TEXT_COLOR)) &&
+ (c != QChar(KVI_TEXT_BOLD)) &&
+ (c != QChar(KVI_TEXT_UNDERLINE)) &&
+ (c != QChar(KVI_TEXT_RESET)) &&
+ (c != QChar(KVI_TEXT_REVERSE)) &&
+ (c != QChar(KVI_TEXT_CRYPTESCAPE)) &&
(c != QChar(KVI_TEXT_ICON))))
{
m_iBlockLen++;
- int xxx = c.unicode() < 32 ? fm.width(getSubstituteChar(c.unicode())) + 3 : fm.width(c);;
- m_iBlockWidth +=xxx;
- curXPos +=xxx;
- idx++;
+ int iXxx = c.unicode() < 32 ? fm.width(getSubstituteChar(c.unicode())) + 3 : fm.width(c);;
+ m_iBlockWidth += iXxx;
+ iCurXPos += iXxx;
+ iIdx++;
} else break;
}
return;
@@ -548,9 +552,9 @@ void KviInputEditor::extractNextBlock(int idx,QFontMetrics & fm,int curXPos,int
break;
case KVI_TEXT_REVERSE:
{
- char auxClr = m_iCurFore;
+ char cAuxClr = m_iCurFore;
m_iCurFore = m_iCurBack;
- m_iCurBack = auxClr;
+ m_iCurBack = cAuxClr;
}
break;
case KVI_TEXT_CRYPTESCAPE:
@@ -559,15 +563,18 @@ void KviInputEditor::extractNextBlock(int idx,QFontMetrics & fm,int curXPos,int
break;
case KVI_TEXT_COLOR:
{
- idx++;
- if(idx >= ((int)(m_szTextBuffer.length())))return;
- unsigned char fore;
- unsigned char back;
- idx = getUnicodeColorBytes(m_szTextBuffer,idx,&fore,&back);
- if(fore != KVI_NOCHANGE)
+ iIdx++;
+ if(iIdx >= ((int)(m_szTextBuffer.length())))
+ return;
+
+ unsigned char uFore;
+ unsigned char uBack;
+ iIdx = getUnicodeColorBytes(m_szTextBuffer,iIdx,&uFore,&uBack);
+ if(uFore != KVI_NOCHANGE)
{
- m_iCurFore = fore;
- if(back != KVI_NOCHANGE)m_iCurBack = back;
+ m_iCurFore = uFore;
+ if(uBack != KVI_NOCHANGE)
+ m_iCurBack = uBack;
} else {
// ONLY a CTRL+K
m_iCurBack = KVI_INPUT_DEF_BACK;
@@ -585,13 +592,13 @@ void KviInputEditor::extractNextBlock(int idx,QFontMetrics & fm,int curXPos,int
void KviInputEditor::runUpToTheFirstVisibleChar()
{
- register int idx = 0;
- while(idx < m_iFirstVisibleChar)
+ register int iIdx = 0;
+ while(iIdx < m_iFirstVisibleChar)
{
- unsigned short c = m_szTextBuffer[idx].unicode();
- if(c < 32)
+ unsigned short uChar = m_szTextBuffer[iIdx].unicode();
+ if(uChar < 32)
{
- switch(c)
+ switch(uChar)
{
case KVI_TEXT_BOLD:
m_bCurBold = ! m_bCurBold;
@@ -607,22 +614,22 @@ void KviInputEditor::runUpToTheFirstVisibleChar()
break;
case KVI_TEXT_REVERSE:
{
- char auxClr = m_iCurFore;
- m_iCurFore = m_iCurBack;
- m_iCurBack = auxClr;
+ char cAuxClr = m_iCurFore;
+ m_iCurFore = m_iCurBack;
+ m_iCurBack = cAuxClr;
}
break;
case KVI_TEXT_COLOR:
{
- idx++;
- if(idx >= ((int)(m_szTextBuffer.length())))return;
- unsigned char fore;
- unsigned char back;
- idx = getUnicodeColorBytes(m_szTextBuffer,idx,&fore,&back);
- idx--;
- if(fore != KVI_NOCHANGE)m_iCurFore = fore;
+ iIdx++;
+ if(iIdx >= ((int)(m_szTextBuffer.length())))return;
+ unsigned char uFore;
+ unsigned char uBack;
+ iIdx = getUnicodeColorBytes(m_szTextBuffer,iIdx,&uFore,&uBack);
+ iIdx--;
+ if(uFore != KVI_NOCHANGE) m_iCurFore = uFore;
else m_iCurFore = KVI_INPUT_DEF_FORE;
- if(back != KVI_NOCHANGE)m_iCurBack = back;
+ if(uBack != KVI_NOCHANGE) m_iCurBack = uBack;
else m_iCurBack = KVI_INPUT_DEF_BACK;
}
break;
@@ -632,19 +639,18 @@ void KviInputEditor::runUpToTheFirstVisibleChar()
break;
}
}
- idx++;
+ iIdx++;
}
}
-
-void KviInputEditor::mousePressEvent(QMouseEvent *e)
+void KviInputEditor::mousePressEvent(QMouseEvent * e)
{
if(e->button() & Qt::LeftButton)
{
m_iCursorPosition = charIndexFromXPosition(e->pos().x());
//move the cursor to
- int anchorX = xPositionFromCharIndex(m_iCursorPosition);
- if(anchorX > (width()-frameWidth()))m_iFirstVisibleChar++;
+ int iAnchorX = xPositionFromCharIndex(m_iCursorPosition);
+ if(iAnchorX > (width()-frameWidth())) m_iFirstVisibleChar++;
m_iSelectionAnchorChar = m_iCursorPosition;
selectOneChar(-1);
//grabMouse(QCursor(crossCursor));
@@ -654,19 +660,19 @@ void KviInputEditor::mousePressEvent(QMouseEvent *e)
} else if(e->button() & Qt::RightButton)
{
- int type = g_pActiveWindow->type();
+ int iType = g_pActiveWindow->type();
//Popup menu
g_pInputPopup->clear();
QString szClip;
- QClipboard * c = QApplication::clipboard();
- if(c)
+ QClipboard * pClip = QApplication::clipboard();
+ if(pClip)
{
- szClip = c->text(QClipboard::Clipboard);
+ szClip = pClip->text(QClipboard::Clipboard);
- int occ = szClip.count(QChar('\n'));
+ int iOcc = szClip.count(QChar('\n'));
if(!szClip.isEmpty())
{
@@ -680,78 +686,78 @@ void KviInputEditor::mousePressEvent(QMouseEvent *e)
szClip.replace(QChar('>'),"&gt;");
szClip.replace(QChar('\n'),"<br>");
- QString label = "<center><b>";
- label += __tr2qs("Clipboard");
- label += ":</b><br>";
- label += szClip;
- label += "<br><b>";
+ QString szLabel = "<center><b>";
+ szLabel += __tr2qs("Clipboard");
+ szLabel += ":</b><br>";
+ szLabel += szClip;
+ szLabel += "<br><b>";
- QString num;
- num.setNum(occ);
+ QString szNum;
+ szNum.setNum(iOcc);
- label += num;
- label += QChar(' ');
- label += (occ == 1) ? __tr2qs("line break") : __tr2qs("line breaks");
- label += "</b></center>";
+ szLabel += szNum;
+ szLabel += QChar(' ');
+ szLabel += (iOcc == 1) ? __tr2qs("line break") : __tr2qs("line breaks");
+ szLabel += "</b></center>";
- QLabel * l = new QLabel(label,g_pInputPopup);
- l->setFrameStyle(QFrame::Raised | QFrame::StyledPanel);
- l->setMargin(5);
+ QLabel * pLabel = new QLabel(szLabel,g_pInputPopup);
+ pLabel->setFrameStyle(QFrame::Raised | QFrame::StyledPanel);
+ pLabel->setMargin(5);
// FIXME: This does NOT work under Qt 4.x (they seem to consider it as bad UI design)
- delete l;
+ delete pLabel;
}
}
- int id = g_pInputPopup->insertItem(__tr2qs("Cu&t") + ACCEL_KEY(X),this,SLOT(cut()));
- g_pInputPopup->setItemEnabled(id,hasSelection());
- id = g_pInputPopup->insertItem(__tr2qs("&Copy") + ACCEL_KEY(C),this,SLOT(copyToClipboard()));
- g_pInputPopup->setItemEnabled(id,hasSelection());
- id = g_pInputPopup->insertItem(__tr2qs("&Paste") + ACCEL_KEY(V),this,SLOT(pasteClipboardWithConfirmation()));
- g_pInputPopup->setItemEnabled(id,!szClip.isEmpty() && !m_bReadOnly);
- id = g_pInputPopup->insertItem(__tr2qs("Paste (Slowly)"),this,SLOT(pasteSlow()));
- if ((type == KVI_WINDOW_TYPE_CHANNEL) || (type == KVI_WINDOW_TYPE_QUERY) || (type == KVI_WINDOW_TYPE_DCCCHAT))
- g_pInputPopup->setItemEnabled(id,!szClip.isEmpty() && !m_bReadOnly);
+ int iId = g_pInputPopup->insertItem(__tr2qs("Cu&t") + ACCEL_KEY(X),this,SLOT(cut()));
+ g_pInputPopup->setItemEnabled(iId,hasSelection());
+ iId = g_pInputPopup->insertItem(__tr2qs("&Copy") + ACCEL_KEY(C),this,SLOT(copyToClipboard()));
+ g_pInputPopup->setItemEnabled(iId,hasSelection());
+ iId = g_pInputPopup->insertItem(__tr2qs("&Paste") + ACCEL_KEY(V),this,SLOT(pasteClipboardWithConfirmation()));
+ g_pInputPopup->setItemEnabled(iId,!szClip.isEmpty() && !m_bReadOnly);
+ iId = g_pInputPopup->insertItem(__tr2qs("Paste (Slowly)"),this,SLOT(pasteSlow()));
+ if ((iType == KVI_WINDOW_TYPE_CHANNEL) || (iType == KVI_WINDOW_TYPE_QUERY) || (iType == KVI_WINDOW_TYPE_DCCCHAT))
+ g_pInputPopup->setItemEnabled(iId,!szClip.isEmpty() && !m_bReadOnly);
else
- g_pInputPopup->setItemEnabled(id,false);
- id = g_pInputPopup->insertItem(__tr2qs("Paste &File") + ACCEL_KEY(L),this,SLOT(pasteFile()));
- if ((type != KVI_WINDOW_TYPE_CHANNEL) && (type != KVI_WINDOW_TYPE_QUERY) && (type != KVI_WINDOW_TYPE_DCCCHAT))
- g_pInputPopup->setItemEnabled(id,false);
+ g_pInputPopup->setItemEnabled(iId,false);
+ iId = g_pInputPopup->insertItem(__tr2qs("Paste &File") + ACCEL_KEY(L),this,SLOT(pasteFile()));
+ if ((iType != KVI_WINDOW_TYPE_CHANNEL) && (iType != KVI_WINDOW_TYPE_QUERY) && (iType != KVI_WINDOW_TYPE_DCCCHAT))
+ g_pInputPopup->setItemEnabled(iId,false);
else
- g_pInputPopup->setItemEnabled(id,!m_bReadOnly);
+ g_pInputPopup->setItemEnabled(iId,!m_bReadOnly);
if(m_bSpSlowFlag ==true)
{
- id = g_pInputPopup->insertItem(__tr2qs("Stop Paste"),this,SLOT(stopPasteSlow())); /*G&N 2005*/
+ iId = g_pInputPopup->insertItem(__tr2qs("Stop Paste"),this,SLOT(stopPasteSlow())); /*G&N 2005*/
}
- id = g_pInputPopup->insertItem(__tr2qs("Clear"),this,SLOT(clear()));
- g_pInputPopup->setItemEnabled(id,!m_szTextBuffer.isEmpty() && !m_bReadOnly);
+ iId = g_pInputPopup->insertItem(__tr2qs("Clear"),this,SLOT(clear()));
+ g_pInputPopup->setItemEnabled(iId,!m_szTextBuffer.isEmpty() && !m_bReadOnly);
g_pInputPopup->insertSeparator();
- id = g_pInputPopup->insertItem(__tr2qs("Select All"),this,SLOT(selectAll()));
- g_pInputPopup->setItemEnabled(id,(!m_szTextBuffer.isEmpty()));
-
+ iId = g_pInputPopup->insertItem(__tr2qs("Select All"),this,SLOT(selectAll()));
+ g_pInputPopup->setItemEnabled(iId,(!m_szTextBuffer.isEmpty()));
g_pInputPopup->insertSeparator();
m_pIconMenu->clear();
KviPointerHashTable<QString,KviTextIcon> * d = g_pTextIconManager->textIconDict();
KviPointerHashTableIterator<QString,KviTextIcon> it(*d);
- QStringList strList;
+ QStringList szList;
while(KviTextIcon * i = it.current())
{
- strList.append(it.currentKey());
+ szList.append(it.currentKey());
++it;
}
- strList.sort();
- KviTextIcon * icon;
- QPixmap *pix;
+ szList.sort();
+
+ KviTextIcon * pIcon;
+ QPixmap * pPix;
- for(QStringList::Iterator iter = strList.begin(); iter != strList.end(); ++iter)
+ for(QStringList::Iterator iter = szList.begin(); iter != szList.end(); ++iter)
{
- icon=g_pTextIconManager->lookupTextIcon(*iter);
- if(icon)
+ pIcon = g_pTextIconManager->lookupTextIcon(*iter);
+ if(pIcon)
{
- pix = icon->pixmap();
- if(pix) m_pIconMenu->insertItem(*pix,*iter);
+ pPix = pIcon->pixmap();
+ if(pPix) m_pIconMenu->insertItem(*pPix,*iter);
}
}
@@ -761,70 +767,70 @@ void KviInputEditor::mousePressEvent(QMouseEvent *e)
pasteSelectionWithConfirmation();
}
}
-void KviInputEditor::iconPopupActivated(int id)
+
+void KviInputEditor::iconPopupActivated(int iId)
{
if(!m_bReadOnly)
{
- QString text = m_pIconMenu->text(id);
- if(!text.isEmpty())
+ QString szText = m_pIconMenu->text(iId);
+ if(!szText.isEmpty())
{
- text.prepend(KVI_TEXT_ICON);
- text.append(' ');
- insertText(text);
+ szText.prepend(KVI_TEXT_ICON);
+ szText.append(' ');
+ insertText(szText);
}
}
}
bool KviInputEditor::hasSelection()
{
- return ((m_iSelectionBegin != -1)&&(m_iSelectionEnd != -1));
+ return ((m_iSelectionBegin != -1) && (m_iSelectionEnd != -1));
}
void KviInputEditor::copyToClipboard()
{
- if(!hasSelection())return;
- QClipboard * c = QApplication::clipboard();
- if(!c)return;
+ if(!hasSelection()) return;
+ QClipboard * pClip = QApplication::clipboard();
+ if(!pClip) return;
QString szTxt = m_szTextBuffer.mid(m_iSelectionBegin,(m_iSelectionEnd-m_iSelectionBegin)+1);
- c->setText(szTxt,QClipboard::Clipboard);
+ pClip->setText(szTxt,QClipboard::Clipboard);
repaintWithCursorOn();
}
void KviInputEditor::copyToSelection(bool bDonNotCopyToClipboard)
{
- if(!hasSelection())return;
- QClipboard * c = QApplication::clipboard();
- if(!c)return;
+ if(!hasSelection()) return;
+ QClipboard * pClip = QApplication::clipboard();
+ if(!pClip) return;
QString szTxt = m_szTextBuffer.mid(m_iSelectionBegin,(m_iSelectionEnd-m_iSelectionBegin)+1);
- if(c->supportsSelection())
- c->setText(szTxt,QClipboard::Selection);
+ if(pClip->supportsSelection())
+ pClip->setText(szTxt,QClipboard::Selection);
else if(!bDonNotCopyToClipboard)
- c->setText(szTxt,QClipboard::Clipboard);
+ pClip->setText(szTxt,QClipboard::Clipboard);
repaintWithCursorOn();
}
-
-void KviInputEditor::moveCursorTo(int idx,bool bRepaint)
+void KviInputEditor::moveCursorTo(int iIdx, bool bRepaint)
{
- if(idx < 0)idx = 0;
- if(idx > ((int)(m_szTextBuffer.length())))idx = m_szTextBuffer.length();
- if(idx > m_iCursorPosition)
+ if(iIdx < 0) iIdx = 0;
+ if(iIdx > ((int)(m_szTextBuffer.length()))) iIdx = m_szTextBuffer.length();
+ if(iIdx > m_iCursorPosition)
{
- while(m_iCursorPosition < idx)
+ while(m_iCursorPosition < iIdx)
{
moveRightFirstVisibleCharToShowCursor();
m_iCursorPosition++;
}
} else {
- m_iCursorPosition = idx;
+ m_iCursorPosition = iIdx;
if(m_iFirstVisibleChar > m_iCursorPosition)m_iFirstVisibleChar = m_iCursorPosition;
}
- if(bRepaint)repaintWithCursorOn();
+ if(bRepaint) repaintWithCursorOn();
}
void KviInputEditor::removeSelected()
{
- if(!hasSelection())return;
+ if(!hasSelection()) return;
m_szTextBuffer.remove(m_iSelectionBegin,(m_iSelectionEnd-m_iSelectionBegin)+1);
moveCursorTo(m_iSelectionBegin,false);
selectOneChar(-1);
@@ -833,23 +839,22 @@ void KviInputEditor::removeSelected()
void KviInputEditor::cut()
{
- if(!hasSelection())return;
- QClipboard * c = QApplication::clipboard();
- if(!c)return;
- c->setText(m_szTextBuffer.mid(m_iSelectionBegin,(m_iSelectionEnd-m_iSelectionBegin)+1),QClipboard::Clipboard);
+ if(!hasSelection()) return;
+ QClipboard * pClip = QApplication::clipboard();
+ if(!pClip) return;
+ pClip->setText(m_szTextBuffer.mid(m_iSelectionBegin,(m_iSelectionEnd-m_iSelectionBegin)+1),QClipboard::Clipboard);
m_szTextBuffer.remove(m_iSelectionBegin,(m_iSelectionEnd-m_iSelectionBegin)+1);
moveCursorTo(m_iSelectionBegin,false);
selectOneChar(-1);
repaintWithCursorOn();
}
-void KviInputEditor::insertText(const QString &text)
+void KviInputEditor::insertText(const QString & szTxt)
{
- QString szText = text; // crop away constness
+ QString szText = szTxt; // crop away constness
if(szText.isEmpty())return;
//szText.replaceAll('\t'," "); //Do not paste tabs
-
//szText.replace(QRegExp("\t")," "); // do not paste tabs
m_bUpdatesEnabled = false;
@@ -866,12 +871,12 @@ void KviInputEditor::insertText(const QString &text)
QString szBlock;
while(!szText.isEmpty())
{
- int idx = szText.indexOf('\n');
- if(idx != -1)
+ int iIdx = szText.indexOf('\n');
+ if(iIdx != -1)
{
- szBlock = szText.left(idx);
+ szBlock = szText.left(iIdx);
//else szBlock = QChar(KVI_TEXT_RESET);
- szText.remove(0,idx+1);
+ szText.remove(0,iIdx+1);
} else {
szBlock = szText;
szText = "";
@@ -880,36 +885,33 @@ void KviInputEditor::insertText(const QString &text)
m_szTextBuffer.insert(m_iCursorPosition,szBlock);
m_szTextBuffer.truncate(m_iMaxBufferSize);
- int pos = 0;
- while((pos < ((int)(m_szTextBuffer.length()))) && (m_szTextBuffer[pos] < 33))pos++;
- if((pos < ((int)(m_szTextBuffer.length()))) && (m_szTextBuffer[pos] == QChar('/')))m_szTextBuffer.insert(pos,"\\");
+ int iPos = 0;
+ while((iPos < ((int)(m_szTextBuffer.length()))) && (m_szTextBuffer[iPos] < 33)) iPos++;
+ if((iPos < ((int)(m_szTextBuffer.length()))) && (m_szTextBuffer[iPos] == QChar('/')))m_szTextBuffer.insert(iPos,"\\");
- returnPressed(idx != -1);
+ returnPressed(iIdx != -1);
}
}
}
-// Replace (length) characters in the buffer from (start) with (text), returns
-// the length of the text inserted (different from text.length() only if the
-// buffer was truncated.
-int KviInputEditor::replaceSegment(int start, int length, const QString &text)
+int KviInputEditor::replaceSegment(int iStart, int iLength, const QString & szText)
{
- m_szTextBuffer.remove(start, length);
- m_szTextBuffer.insert(start, text);
+ m_szTextBuffer.remove(iStart, iLength);
+ m_szTextBuffer.insert(iStart, szText);
m_szTextBuffer.truncate(m_iMaxBufferSize);
repaintWithCursorOn();
- int iInsertedLength = text.length();
- int iMaxInsertedLength = m_iMaxBufferSize - start;
+ int iInsertedLength = szText.length();
+ int iMaxInsertedLength = m_iMaxBufferSize - iStart;
if(iInsertedLength > iMaxInsertedLength) return iMaxInsertedLength;
return iInsertedLength;
}
void KviInputEditor::pasteClipboardWithConfirmation()
{
- QClipboard * c = QApplication::clipboard();
- if(!c)return;
- QString szText = c->text(QClipboard::Clipboard);
+ QClipboard * pClip = QApplication::clipboard();
+ if(!pClip) return;
+ QString szText = pClip->text(QClipboard::Clipboard);
if(szText.contains(QChar('\n')) > 0)
{
@@ -922,9 +924,9 @@ void KviInputEditor::pasteClipboardWithConfirmation()
void KviInputEditor::pasteSelectionWithConfirmation()
{
- QClipboard * c = QApplication::clipboard();
- if(!c)return;
- QString szText = c->text(c->supportsSelection() ? QClipboard::Selection : QClipboard::Clipboard);
+ QClipboard * pClip = QApplication::clipboard();
+ if(!pClip) return;
+ QString szText = pClip->text(pClip->supportsSelection() ? QClipboard::Selection : QClipboard::Clipboard);
if(szText.contains(QChar('\n')) > 0)
{
@@ -949,12 +951,12 @@ void KviInputEditor::stopPasteSlow()
void KviInputEditor::pasteFile()
{
- QString stmp = QFileDialog::getOpenFileName(this,"Choose a file","","");
- if(stmp!="")
+ QString szTmp = QFileDialog::getOpenFileName(this,"Choose a file","","");
+ if(szTmp != "")
{
- stmp.replace("\"", "\\\"");
- QString stmp1 = QString("spaste.file \"%1\"").arg(stmp);
- KviKvsScript::run(stmp1,g_pActiveWindow);
+ szTmp.replace("\"", "\\\"");
+ QString szTmp2 = QString("spaste.file \"%1\"").arg(szTmp);
+ KviKvsScript::run(szTmp2,g_pActiveWindow);
m_bSpSlowFlag = true;
}
}
@@ -976,15 +978,15 @@ void KviInputEditor::clear()
home();
}
-void KviInputEditor::setText(const QString text)
+void KviInputEditor::setText(const QString szText)
{
- m_szTextBuffer = text;
+ m_szTextBuffer = szText;
m_szTextBuffer.truncate(m_iMaxBufferSize);
selectOneChar(-1);
end();
}
-void KviInputEditor::mouseReleaseEvent(QMouseEvent *)
+void KviInputEditor::mouseReleaseEvent(QMouseEvent * e)
{
if(m_iDragTimer)
{
@@ -992,8 +994,7 @@ void KviInputEditor::mouseReleaseEvent(QMouseEvent *)
//releaseMouse();
killDragTimer();
}
- if(hasSelection())
- copyToSelection();
+ if(hasSelection()) copyToSelection();
}
void KviInputEditor::killDragTimer()
@@ -1005,7 +1006,7 @@ void KviInputEditor::killDragTimer()
}
}
-void KviInputEditor::timerEvent(QTimerEvent *e)
+void KviInputEditor::timerEvent(QTimerEvent * e)
{
if(e->timerId() == m_iCursorTimer)
{
@@ -1024,15 +1025,14 @@ void KviInputEditor::timerEvent(QTimerEvent *e)
void KviInputEditor::handleDragSelection()
{
- if(m_iSelectionAnchorChar == -1)return;
+ if(m_iSelectionAnchorChar == -1) return;
QPoint pnt = mapFromGlobal(QCursor::pos());
-
if(pnt.x() <= 0)
{
//Left side dragging
- if(m_iFirstVisibleChar > 0)m_iFirstVisibleChar--;
+ if(m_iFirstVisibleChar > 0) m_iFirstVisibleChar--;
m_iCursorPosition = m_iFirstVisibleChar;
} else if(pnt.x() >= width())
{
@@ -1046,7 +1046,8 @@ void KviInputEditor::handleDragSelection()
//Inside the window...
m_iCursorPosition = charIndexFromXPosition(pnt.x());
}
- if(m_iCursorPosition == m_iSelectionAnchorChar)selectOneChar(-1);
+
+ if(m_iCursorPosition == m_iSelectionAnchorChar) selectOneChar(-1);
else {
if(m_iCursorPosition > m_iSelectionAnchorChar)
{
@@ -1095,7 +1096,7 @@ void KviInputEditor::returnPressed(bool bRepaint)
*/
}
-void KviInputEditor::focusInEvent(QFocusEvent *)
+void KviInputEditor::focusInEvent(QFocusEvent * e)
{
if(m_iCursorTimer==0)
{
@@ -1103,25 +1104,19 @@ void KviInputEditor::focusInEvent(QFocusEvent *)
m_bCursorOn = true;
update();
}
- // XIM handling...
-#ifndef COMPILE_USE_QT4
- // THIS SEEMS TO BE GONE IN Qt4.x ? (even if the documentation states that it *should* be there)
- setMicroFocusHint(1,1,width() - 2,height() - 2,true,0);
-#endif
}
-void KviInputEditor::focusOutEvent(QFocusEvent *)
+void KviInputEditor::focusOutEvent(QFocusEvent * e)
{
- if(m_iCursorTimer)killTimer(m_iCursorTimer);
+ if(m_iCursorTimer) killTimer(m_iCursorTimer);
m_iCursorTimer = 0;
m_bCursorOn = false;
update();
}
-
void KviInputEditor::internalCursorRight(bool bShift)
{
- if(m_iCursorPosition >= ((int)(m_szTextBuffer.length())))return;
+ if(m_iCursorPosition >= ((int)(m_szTextBuffer.length()))) return;
moveRightFirstVisibleCharToShowCursor();
//Grow the selection if needed
if(bShift)
@@ -1138,26 +1133,28 @@ void KviInputEditor::internalCursorRight(bool bShift)
void KviInputEditor::internalCursorLeft(bool bShift)
{
- if(m_iCursorPosition <= 0)return;
+ if(m_iCursorPosition <= 0) return;
if(bShift)
{
- if((m_iSelectionBegin > -1)&&(m_iSelectionEnd > -1))
+ if((m_iSelectionBegin > -1) && (m_iSelectionEnd > -1))
{
- if(m_iSelectionBegin == m_iCursorPosition)m_iSelectionBegin--;
- else if(m_iSelectionEnd == m_iCursorPosition-1)m_iSelectionEnd--;
+ if(m_iSelectionBegin == m_iCursorPosition)
+ m_iSelectionBegin--;
+ else if(m_iSelectionEnd == m_iCursorPosition-1)
+ m_iSelectionEnd--;
else selectOneChar(m_iCursorPosition - 1);
} else selectOneChar(m_iCursorPosition - 1);
} else selectOneChar(-1);
m_iCursorPosition--;
- if(m_iFirstVisibleChar > m_iCursorPosition)m_iFirstVisibleChar--;
+ if(m_iFirstVisibleChar > m_iCursorPosition) m_iFirstVisibleChar--;
}
// remember the text before and after the cursor at this point, and put them
-// before and after the text inserted by IM in imEndEvent.
+// before and after the text inserted by IM in InputMethodEndEvent.
// hagabaka
-void KviInputEditor::imStartEvent(QInputMethodEvent *e)
+void KviInputEditor::inputMethodStartEvent(QInputMethodEvent * e)
{
removeSelected();
m_iIMStart = m_iIMSelectionBegin = m_iCursorPosition;
@@ -1168,7 +1165,7 @@ void KviInputEditor::imStartEvent(QInputMethodEvent *e)
// Whenever the IM's preedit changes, update the visuals and internal data. refer to <http://doc.trolltech.com/3.3/QInputMethodEvent.html> */
// hagabaka
-void KviInputEditor::imComposeEvent(QInputMethodEvent *e)
+void KviInputEditor::inputMethodComposeEvent(QInputMethodEvent * e)
{
// replace the old pre-edit string with e->text()
m_bUpdatesEnabled = false;
@@ -1188,7 +1185,7 @@ void KviInputEditor::imComposeEvent(QInputMethodEvent *e)
// Input method is done; put its resulting text to where the preedit area was
// hagabaka
-void KviInputEditor::imEndEvent(QInputMethodEvent *e)
+void KviInputEditor::inputMethodEndEvent(QInputMethodEvent * e)
{
// replace the preedit area with the IM result text
m_bUpdatesEnabled = false;
@@ -1210,7 +1207,7 @@ void KviInputEditor::imEndEvent(QInputMethodEvent *e)
// FIXME According to <http://www.kde.gr.jp/~asaki/how-to-support-input-method.html>, if the XIM
// style used is OverTheTop, code needs to be added in keyPressEvent handler */
// hagabaka
-void KviInputEditor::keyPressEvent(QKeyEvent *e)
+void KviInputEditor::keyPressEvent(QKeyEvent * e)
{
// disable the keyPress handling when IM is in composition.
if(m_bIMComposing)
@@ -1231,7 +1228,6 @@ void KviInputEditor::keyPressEvent(QKeyEvent *e)
}
}
-
if(e->key() == Qt::Key_Escape)
{
emit escapePressed();
@@ -1334,11 +1330,15 @@ void KviInputEditor::keyPressEvent(QKeyEvent *e)
if(!m_bReadOnly)
{
insertChar(KVI_TEXT_ICON); // THE NEXT WORD IS AN ICON NAME
- int xPos = xPositionFromCharIndex(m_iCursorPosition);
- if(xPos > 24)xPos-=24;
- if(!g_pTextIconWindow)g_pTextIconWindow = new KviTextIconWindowWidget();
- if(xPos+g_pTextIconWindow->width() > width())xPos = width()-(g_pTextIconWindow->width()+2);
- g_pTextIconWindow->move(mapToGlobal(QPoint(xPos,-KVI_TEXTICON_WIN_HEIGHT)));
+ int iXPos = xPositionFromCharIndex(m_iCursorPosition);
+ if(iXPos > 24)
+ iXPos-=24;
+ if(!g_pTextIconWindow)
+ g_pTextIconWindow = new KviTextIconWindowWidget();
+
+ if(iXPos+g_pTextIconWindow->width() > width())
+ iXPos = width()-(g_pTextIconWindow->width()+2);
+ g_pTextIconWindow->move(mapToGlobal(QPoint(iXPos,-KVI_TEXTICON_WIN_HEIGHT)));
g_pTextIconWindow->popup(this);
}
}
@@ -1359,24 +1359,29 @@ void KviInputEditor::keyPressEvent(QKeyEvent *e)
// skip whitespace
while(m_iCursorPosition > 0)
{
- if(!m_szTextBuffer.at(m_iCursorPosition - 1).isSpace())break;
+ if(!m_szTextBuffer.at(m_iCursorPosition - 1).isSpace())
+ break;
m_szTextBuffer.remove(m_iCursorPosition-1,1);
m_iCursorPosition--;
- if(m_iFirstVisibleChar > m_iCursorPosition)m_iFirstVisibleChar--;
+ if(m_iFirstVisibleChar > m_iCursorPosition)
+ m_iFirstVisibleChar--;
}
// skip nonwhitespace
while(m_iCursorPosition > 0)
{
- if(m_szTextBuffer.at(m_iCursorPosition - 1).isSpace())break;
+ if(m_szTextBuffer.at(m_iCursorPosition - 1).isSpace())
+ break;
m_szTextBuffer.remove(m_iCursorPosition-1,1);
m_iCursorPosition--;
- if(m_iFirstVisibleChar > m_iCursorPosition)m_iFirstVisibleChar--;
+ if(m_iFirstVisibleChar > m_iCursorPosition)
+ m_iFirstVisibleChar--;
}
repaintWithCursorOn();
}
break;
case Qt::Key_PageUp:
- if(!KVI_OPTION_BOOL(KviOption_boolEnableInputHistory)) break;
+ if(!KVI_OPTION_BOOL(KviOption_boolEnableInputHistory))
+ break;
if(m_pInputParent->inherits("KviInput"))
((KviInput*)(m_pInputParent))->historyButtonClicked();
break;
@@ -1601,18 +1606,18 @@ void KviInputEditor::keyPressEvent(QKeyEvent *e)
}
}
-void KviInputEditor::keyReleaseEvent(QKeyEvent *e)
+void KviInputEditor::keyReleaseEvent(QKeyEvent * e)
{
if((e->key() == Qt::Key_Alt) || (e->key() == Qt::Key_Meta))
{
if(m_szAltKeyCode.hasData())
{
bool bOk;
- unsigned short ch = m_szAltKeyCode.toUShort(&bOk);
- if(bOk && ch != 0)
+ unsigned short uCh = m_szAltKeyCode.toUShort(&bOk);
+ if(bOk && uCh != 0)
{
//debug("INSERTING CHAR %d",ch);
- insertChar(QChar(ch));
+ insertChar(QChar(uCh));
e->accept();
}
}
@@ -1621,25 +1626,25 @@ void KviInputEditor::keyReleaseEvent(QKeyEvent *e)
e->ignore();
}
-void KviInputEditor::getWordBeforeCursor(QString &buffer,bool * bIsFirstWordInLine)
+void KviInputEditor::getWordBeforeCursor(QString & szBuffer, bool * bIsFirstWordInLine)
{
if(m_szTextBuffer.isEmpty() || m_iCursorPosition <= 0)
{
- buffer = "";
+ szBuffer = "";
return;
}
- buffer = m_szTextBuffer.left(m_iCursorPosition);
+ szBuffer = m_szTextBuffer.left(m_iCursorPosition);
- int idx = buffer.lastIndexOf(' ');
- int idx2 = buffer.lastIndexOf(','); // This is for comma separated lists...
- int idx3 = buffer.lastIndexOf('(');
- int idx4 = buffer.lastIndexOf('"');
- if(idx2 > idx)idx = idx2;
- if(idx3 > idx)idx = idx3;
- if(idx4 > idx)idx = idx4;
+ int iIdx = szBuffer.lastIndexOf(' ');
+ int iIdx2 = szBuffer.lastIndexOf(','); // This is for comma separated lists...
+ int iIdx3 = szBuffer.lastIndexOf('(');
+ int iIdx4 = szBuffer.lastIndexOf('"');
+ if(iIdx2 > iIdx) iIdx = iIdx2;
+ if(iIdx3 > iIdx) iIdx = iIdx3;
+ if(iIdx4 > iIdx) iIdx = iIdx4;
*bIsFirstWordInLine = false;
- if(idx > -1)buffer.remove(0,idx+1);
+ if(iIdx > -1) szBuffer.remove(0,iIdx+1);
else *bIsFirstWordInLine = true;
}
@@ -1649,17 +1654,17 @@ void KviInputEditor::completion(bool bShift)
// On windows the KVI_PATH_SEPARATOR_CHARacters are breaking everything...
// Well.... :D
- QString word;
- QString match;
-
+ QString szWord;
+ QString szMatch;
bool bFirstWordInLine;
- getWordBeforeCursor(word,&bFirstWordInLine);
- if(word.isEmpty())
+
+ getWordBeforeCursor(szWord,&bFirstWordInLine);
+ if(szWord.isEmpty())
{
- if(m_szLastCompletedNick.isEmpty())return; // nothing to complete
+ if(m_szLastCompletedNick.isEmpty()) return; // nothing to complete
else {
// this is standard nick completion continued
- standardNickCompletion(bShift,word,bFirstWordInLine);
+ standardNickCompletion(bShift,szWord,bFirstWordInLine);
repaintWithCursorOn();
return;
}
@@ -1671,62 +1676,62 @@ void KviInputEditor::completion(bool bShift)
bool bIsDir = false;
bool bIsNick = false;
- unsigned short uc = word[0].unicode();
+ unsigned short uc = szWord[0].unicode();
if(uc == '/')
{
if(bFirstWordInLine)
{
// command completion
- word.remove(0,1);
- if(word.isEmpty())return;
- KviKvsKernel::instance()->completeCommand(word,&tmp);
+ szWord.remove(0,1);
+ if(szWord.isEmpty())return;
+ KviKvsKernel::instance()->completeCommand(szWord,&tmp);
bIsCommand = true;
} else {
// directory completion attempt
- g_pApp->completeDirectory(word,&tmp);
+ g_pApp->completeDirectory(szWord,&tmp);
bIsDir = true;
}
} else if(uc == '$')
{
// function/identifer completion
- word.remove(0,1);
- if(word.isEmpty())return;
- KviKvsKernel::instance()->completeFunction(word,&tmp);
+ szWord.remove(0,1);
+ if(szWord.isEmpty()) return;
+ KviKvsKernel::instance()->completeFunction(szWord,&tmp);
} else if(uc == '#' || uc == '&' || uc == '!')
{
if(m_pKviWindow)
{
- if( (word.length()==1) && (m_pKviWindow->windowName()[0].unicode()==uc))
+ if( (szWord.length()==1) && (m_pKviWindow->windowName()[0].unicode()==uc))
{
- match=m_pKviWindow->windowName();
- match.append(" ");
- replaceWordBeforeCursor(word,match,false);
+ szMatch=m_pKviWindow->windowName();
+ szMatch.append(" ");
+ replaceWordBeforeCursor(szWord,szMatch,false);
repaintWithCursorOn();
return;
} else {
if(m_pKviWindow->console())
- m_pKviWindow->console()->completeChannel(word,&tmp);
+ m_pKviWindow->console()->completeChannel(szWord,&tmp);
}
}
//FIXME: Complete also on irc:// starting strings, not only irc.?
- } else if(KviQString::equalCIN(word,"irc.",4))
+ } else if(KviQString::equalCIN(szWord,"irc.",4))
{
// irc server name
if(m_pKviWindow)
if(m_pKviWindow->console())
- m_pKviWindow->console()->completeServer(word,&tmp);
+ m_pKviWindow->console()->completeServer(szWord,&tmp);
} else {
// empty word will end up here
if(m_pUserListView)
{
if(KVI_OPTION_BOOL(KviOption_boolBashLikeNickCompletion))
{
- m_pUserListView->completeNickBashLike(word,&tmp,bShift);
+ m_pUserListView->completeNickBashLike(szWord,&tmp,bShift);
bIsNick = true;
} else {
- standardNickCompletion(bShift,word,bFirstWordInLine);
+ standardNickCompletion(bShift,szWord,bFirstWordInLine);
repaintWithCursorOn();
return;
}
@@ -1734,96 +1739,95 @@ void KviInputEditor::completion(bool bShift)
}
// Lookup the longest exact match
-
if(tmp.count() > 0)
{
if(tmp.count() == 1)
{
- match = *(tmp.first());
- if(bIsCommand)match.append(' ');
+ szMatch = *(tmp.first());
+ if(bIsCommand)szMatch.append(' ');
else if(bIsNick)
{
if(!KVI_OPTION_STRING(KviOption_stringNickCompletionPostfix).isEmpty())
{
if(bFirstWordInLine || (!KVI_OPTION_BOOL(KviOption_boolUseNickCompletionPostfixForFirstWordOnly)))
- match.append(KVI_OPTION_STRING(KviOption_stringNickCompletionPostfix));
+ szMatch.append(KVI_OPTION_STRING(KviOption_stringNickCompletionPostfix));
}
}
} else {
- QString all;
- QString * s = tmp.first();
- match = *s;
- int wLen = word.length();
- for(;s;s = tmp.next())
+ QString szAll;
+ QString * szTmp = tmp.first();
+ szMatch = *szTmp;
+ int iWLen = szWord.length();
+ for(; szTmp; szTmp = tmp.next())
{
- if(s->length() < match.length())
- match.remove(s->length(),match.length() - s->length());
+ if(szTmp->length() < szMatch.length())
+ szMatch.remove(szTmp->length(),szMatch.length() - szTmp->length());
// All the matches here have length >= word.len()!!!
- const QChar * b1 = KviQString::nullTerminatedArray(*s) + wLen;
- const QChar * b2 = KviQString::nullTerminatedArray(match) + wLen;
+ const QChar * b1 = KviQString::nullTerminatedArray(*szTmp) + iWLen;
+ const QChar * b2 = KviQString::nullTerminatedArray(szMatch) + iWLen;
const QChar * c1 = b1;
const QChar * c2 = b2;
if(bIsDir)while(c1->unicode() && (c1->unicode() == c2->unicode()))c1++,c2++;
else while(c1->unicode() && (c1->toLower().unicode() == c2->toLower().unicode()))c1++,c2++;
- int len = wLen + (c1 - b1);
- if(len < ((int)(match.length())))match.remove(len,match.length() - len);
- if(!all.isEmpty())all.append(", ");
- all.append(*s);
+ int iLen = iWLen + (c1 - b1);
+ if(iLen < ((int)(szMatch.length())))szMatch.remove(iLen,szMatch.length() - iLen);
+ if(!szAll.isEmpty())szAll.append(", ");
+ szAll.append(*szTmp);
}
if(m_pKviWindow)
- m_pKviWindow->output(KVI_OUT_SYSTEMMESSAGE,__tr2qs("%d matches: %Q"),tmp.count(),&all);
+ m_pKviWindow->output(KVI_OUT_SYSTEMMESSAGE,__tr2qs("%d matches: %Q"),tmp.count(),&szAll);
}
} else
if(m_pKviWindow)
m_pKviWindow->outputNoFmt(KVI_OUT_SYSTEMMESSAGE,__tr2qs("No matches"));
- if(!match.isEmpty())
+ if(!szMatch.isEmpty())
{
//if(!bIsDir && !bIsNick)match = match.toLower(); <-- why? It is nice to have
// $module.someFunctionName instad
// of unreadable $module.somefunctionfame
- replaceWordBeforeCursor(word,match,false);
+ replaceWordBeforeCursor(szWord,szMatch,false);
}
repaintWithCursorOn();
}
-void KviInputEditor::replaceWordBeforeCursor(const QString &word,const QString &replacement,bool bRepaint)
+void KviInputEditor::replaceWordBeforeCursor(const QString & szWord, const QString & szRreplacement, bool bRepaint)
{
selectOneChar(-1);
- m_iCursorPosition -= word.length();
- m_szTextBuffer.remove(m_iCursorPosition,word.length());
- m_szTextBuffer.insert(m_iCursorPosition,replacement);
+ m_iCursorPosition -= szWord.length();
+ m_szTextBuffer.remove(m_iCursorPosition,szWord.length());
+ m_szTextBuffer.insert(m_iCursorPosition,szRreplacement);
m_szTextBuffer.truncate(m_iMaxBufferSize);
- moveCursorTo(m_iCursorPosition + replacement.length());
+ moveCursorTo(m_iCursorPosition + szRreplacement.length());
if(bRepaint)repaintWithCursorOn();
}
-void KviInputEditor::standardNickCompletion(bool bAddMask,QString &word,bool bFirstWordInLine)
+void KviInputEditor::standardNickCompletion(bool bAddMask, QString & szWord, bool bFirstWordInLine)
{
// FIXME: this could be really simplified...
- if(!m_pUserListView)return;
+ if(!m_pUserListView) return;
selectOneChar(-1);
- QString buffer;
+ QString szBuffer;
if(m_szLastCompletedNick.isEmpty())
{
// New completion session: we NEED sth to complete
- if(word.isEmpty())return;
- if(m_pUserListView->completeNickStandard(word,m_szLastCompletedNick,buffer,bAddMask))
+ if(szWord.isEmpty()) return;
+ if(m_pUserListView->completeNickStandard(szWord,m_szLastCompletedNick,szBuffer,bAddMask))
{
// completed: save the buffer
m_szLastCompletionBuffer = m_szTextBuffer;
m_iLastCompletionCursorPosition = m_iCursorPosition;
m_iLastCompletionCursorXPosition = m_iLastCursorXPosition;
m_iLastCompletionFirstVisibleChar = m_iFirstVisibleChar;
- m_szLastCompletedNick = buffer;
+ m_szLastCompletedNick = szBuffer;
if(!KVI_OPTION_STRING(KviOption_stringNickCompletionPostfix).isEmpty())
{
if(bFirstWordInLine || (!KVI_OPTION_BOOL(KviOption_boolUseNickCompletionPostfixForFirstWordOnly)))
- buffer.append(KVI_OPTION_STRING(KviOption_stringNickCompletionPostfix));
+ szBuffer.append(KVI_OPTION_STRING(KviOption_stringNickCompletionPostfix));
}
- replaceWordBeforeCursor(word,buffer,false);
+ replaceWordBeforeCursor(szWord,szBuffer,false);
m_bLastCompletionFinished=0;
// REPAINT CALLED FROM OUTSIDE!
} // else no match at all
@@ -1837,18 +1841,18 @@ void KviInputEditor::standardNickCompletion(bool bAddMask,QString &word,bool bFi
// re-extract
//word = m_szTextBuffer.left(m_iCursorPosition);
- getWordBeforeCursor(word,&bFirstWordInLine);
- if(word.isEmpty())return;
- if(m_pUserListView->completeNickStandard(word,m_szLastCompletedNick,buffer,bAddMask))
+ getWordBeforeCursor(szWord,&bFirstWordInLine);
+ if(szWord.isEmpty())return;
+ if(m_pUserListView->completeNickStandard(szWord,m_szLastCompletedNick,szBuffer,bAddMask))
{
// completed
- m_szLastCompletedNick = buffer;
+ m_szLastCompletedNick = szBuffer;
if(!KVI_OPTION_STRING(KviOption_stringNickCompletionPostfix).isEmpty())
{
if(bFirstWordInLine || (!KVI_OPTION_BOOL(KviOption_boolUseNickCompletionPostfixForFirstWordOnly)))
- buffer.append(KVI_OPTION_STRING(KviOption_stringNickCompletionPostfix));
+ szBuffer.append(KVI_OPTION_STRING(KviOption_stringNickCompletionPostfix));
}
- replaceWordBeforeCursor(word,buffer,false);
+ replaceWordBeforeCursor(szWord,szBuffer,false);
m_bLastCompletionFinished=0;
// REPAINT CALLED FROM OUTSIDE!
} else {
@@ -1860,21 +1864,21 @@ void KviInputEditor::standardNickCompletion(bool bAddMask,QString &word,bool bFi
// re-extract
//word = m_szTextBuffer.left(m_iCursorPosition);
//getWordBeforeCursor(word,&bFirstWordInLine);
- if(word.isEmpty())return;
- if(m_pUserListView->completeNickStandard(word,"",buffer,bAddMask))
+ if(szWord.isEmpty())return;
+ if(m_pUserListView->completeNickStandard(szWord,"",szBuffer,bAddMask))
{
// completed
m_szLastCompletionBuffer = m_szTextBuffer;
m_iLastCompletionCursorPosition = m_iCursorPosition;
m_iLastCompletionCursorXPosition = m_iLastCursorXPosition;
m_iLastCompletionFirstVisibleChar = m_iFirstVisibleChar;
- m_szLastCompletedNick = buffer;
+ m_szLastCompletedNick = szBuffer;
if(!KVI_OPTION_STRING(KviOption_stringNickCompletionPostfix).isEmpty())
{
if(bFirstWordInLine || (!KVI_OPTION_BOOL(KviOption_boolUseNickCompletionPostfixForFirstWordOnly)))
- buffer.append(KVI_OPTION_STRING(KviOption_stringNickCompletionPostfix));
+ szBuffer.append(KVI_OPTION_STRING(KviOption_stringNickCompletionPostfix));
}
- replaceWordBeforeCursor(word,buffer,false);
+ replaceWordBeforeCursor(szWord,szBuffer,false);
m_bLastCompletionFinished=0;
// REPAINT CALLED FROM OUTSIDE!
} else {
@@ -1884,9 +1888,7 @@ void KviInputEditor::standardNickCompletion(bool bAddMask,QString &word,bool bFi
}
}
-
//Funky helpers
-
void KviInputEditor::end()
{
m_iLastCursorXPosition = frameWidth();
@@ -1909,7 +1911,8 @@ void KviInputEditor::home()
void KviInputEditor::insertChar(QChar c)
{
- if(m_szTextBuffer.length() >= m_iMaxBufferSize)return;
+ if(m_szTextBuffer.length() >= m_iMaxBufferSize)
+ return;
// Kill the selection
if((m_iSelectionBegin > -1) || (m_iSelectionEnd > -1))
@@ -1957,67 +1960,68 @@ void KviInputEditor::repaintWithCursorOn()
}
}
-void KviInputEditor::selectOneChar(int pos)
+void KviInputEditor::selectOneChar(int iPos)
{
- m_iSelectionBegin = pos;
- m_iSelectionEnd = pos;
+ m_iSelectionBegin = iPos;
+ m_iSelectionEnd = iPos;
}
-int KviInputEditor::charIndexFromXPosition(int xPos)
+int KviInputEditor::charIndexFromXPosition(int iXPos)
{
- int curXPos = frameWidth()+KVI_INPUT_MARGIN;
- int curChar = m_iFirstVisibleChar;
- int bufLen = m_szTextBuffer.length();
+ int iCurXPos = frameWidth()+KVI_INPUT_MARGIN;
+ int iCurChar = m_iFirstVisibleChar;
+ int iBufLen = m_szTextBuffer.length();
QFontMetrics fm(KVI_OPTION_FONT(KviOption_fontInput));
- while(curChar < bufLen)
+ while(iCurChar < iBufLen)
{
- QChar c = m_szTextBuffer.at(curChar);
+ QChar c = m_szTextBuffer.at(iCurChar);
- int widthCh = c.unicode() < 32 ? fm.width(getSubstituteChar(c.unicode())) + 3 : fm.width(c);;
+ int iWidthCh = c.unicode() < 32 ? fm.width(getSubstituteChar(c.unicode())) + 3 : fm.width(c);
- if(xPos < (curXPos+(widthCh/2)))return curChar;
- else if(xPos < (curXPos+widthCh))return (curChar+1);
+ if(iXPos < (iCurXPos+(iWidthCh/2))) return iCurChar;
+ else if(iXPos < (iCurXPos+iWidthCh)) return (iCurChar+1);
{
- curXPos+=widthCh;
- curChar++;
+ iCurXPos += iWidthCh;
+ iCurChar++;
}
}
- return curChar;
+ return iCurChar;
}
-int KviInputEditor::xPositionFromCharIndex(QFontMetrics& fm,int chIdx,bool bContentsCoords)
+int KviInputEditor::xPositionFromCharIndex(QFontMetrics & fm, int iChIdx, bool bContentsCoords)
{
// FIXME: this could use fm.width(m_szTextBuffer,chIdx)
- int curXPos = bContentsCoords ? KVI_INPUT_MARGIN : frameWidth()+KVI_INPUT_MARGIN;
- int curChar = m_iFirstVisibleChar;
- while(curChar < chIdx)
+ int iCurXPos = bContentsCoords ? KVI_INPUT_MARGIN : frameWidth()+KVI_INPUT_MARGIN;
+ int iCurChar = m_iFirstVisibleChar;
+ while(iCurChar < iChIdx)
{
- QChar c = m_szTextBuffer.at(curChar);
+ QChar c = m_szTextBuffer.at(iCurChar);
- curXPos += c.unicode() < 32 ? fm.width(getSubstituteChar(c.unicode())) + 3 : fm.width(c);;
+ iCurXPos += c.unicode() < 32 ? fm.width(getSubstituteChar(c.unicode())) + 3 : fm.width(c);;
- curChar++;
+ iCurChar++;
}
- return curXPos;
+ return iCurXPos;
}
-int KviInputEditor::xPositionFromCharIndex(int chIdx,bool bContentsCoords)
+int KviInputEditor::xPositionFromCharIndex(int iChIdx, bool bContentsCoords)
{
// FIXME: this could use fm.width(m_szTextBuffer,chIdx)
- int curXPos = bContentsCoords ? KVI_INPUT_MARGIN : frameWidth()+KVI_INPUT_MARGIN;
- int curChar = m_iFirstVisibleChar;
+ int iCurXPos = bContentsCoords ? KVI_INPUT_MARGIN : frameWidth()+KVI_INPUT_MARGIN;
+ int iCurChar = m_iFirstVisibleChar;
//debug("%i",g_pLastFontMetrics);
if(!g_pLastFontMetrics) g_pLastFontMetrics = new QFontMetrics(KVI_OPTION_FONT(KviOption_fontInput));
- while(curChar < chIdx)
+ while(iCurChar < iChIdx)
{
- QChar c = m_szTextBuffer.at(curChar);
+ QChar c = m_szTextBuffer.at(iCurChar);
- curXPos += c.unicode() < 32 ? g_pLastFontMetrics->width(getSubstituteChar(c.unicode())) + 3 : g_pLastFontMetrics->width(c);
+ iCurXPos += c.unicode() < 32 ? g_pLastFontMetrics->width(getSubstituteChar(c.unicode())) + 3 : g_pLastFontMetrics->width(c);
- curChar++;
+ iCurChar++;
}
- return curXPos;
+
+ return iCurXPos;
}
/*
diff --git a/src/kvirc/ui/kvi_input_editor.h b/src/kvirc/ui/kvi_input_editor.h
index a51f11494..103c69d26 100644
--- a/src/kvirc/ui/kvi_input_editor.h
+++ b/src/kvirc/ui/kvi_input_editor.h
@@ -23,6 +23,23 @@
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
//============================================================================
+// This file was originally part of kvi_input.h
+//============================================================================
+
+/**
+* \file kvi_input_editor.h
+* \author Elvio Basello
+* \brief Input editor
+*
+* \def KVI_INPUT_MAX_BUFFER_SIZE Default maximum buffer size
+* \def KVI_INPUT_BORDER Default border
+* \def KVI_INPUT_MARGIN Default margin
+* \def KVI_INPUT_BLINK_TIME Cursor blink time...just don't set it to a value less than 100 if you don't want to be lagged by your cursors :)
+* \def KVI_INPUT_DRAG_TIMEOUT Drag scroll speed...(smaller values = faster)
+* \def KVI_INPUT_DEF_BACK Default background color
+* \def KVI_INPUT_DEF_FORE Default foreground color
+* \def ACCEL_KEY Accelerator key
+*/
#include "kvi_settings.h"
#include "kvi_pointerlist.h"
@@ -38,30 +55,43 @@ class QDragEnterEvent;
class KviUserListView;
class KviTalPopupMenu;
-// Default maximum buffer size.
#define KVI_INPUT_MAX_BUFFER_SIZE 400
-// Border , better do not touch this
#define KVI_INPUT_BORDER 1
#define KVI_INPUT_MARGIN 2
-// Cursor blink time...just don't set it to a value less than 100 if
-// you don't want to be lagged by your cursors :)
#define KVI_INPUT_BLINK_TIME 800
-// Drag scroll speed...(smaller values = faster)
#define KVI_INPUT_DRAG_TIMEOUT 80
+#define KVI_INPUT_DEF_BACK 100
+#define KVI_INPUT_DEF_FORE 101
+#ifndef ACCEL_KEY
+#define ACCEL_KEY(k) "\t" + QString(QKeySequence( Qt::CTRL | Qt::Key_ ## k ))
+#endif
+/**
+* \class KviInputEditor
+* \brief Input editor class
+*/
class KVIRC_API KviInputEditor : public QFrame
{
// friend class KviUserParser;
//Q_PROPERTY( int KviProperty_FocusOwner READ heightHint )
Q_PROPERTY( int TransparencyCapable READ heightHint )
-
Q_OBJECT
public:
- KviInputEditor(QWidget * par, KviWindow * wnd, KviUserListView * view = 0);
+ /**
+ * \brief Constructs the input editor object
+ * \param pPar The parent widget
+ * \param pWnd The KviWindow object
+ * \param pView The userlist
+ * \return KviInputEditor
+ */
+ KviInputEditor(QWidget * pPar, KviWindow * pWnd, KviUserListView * pView = 0);
+
+ /**
+ * \brief Destroys the Input editor object
+ */
~KviInputEditor();
protected:
-
QString m_szTextBuffer;
int m_iCursorPosition;
int m_iFirstVisibleChar;
@@ -117,73 +147,368 @@ protected:
KviTalPopupMenu * m_pIconMenu;
bool m_bReadOnly;
public:
- int heightHint() const;
+ /**
+ * \brief Returns the height of the editor
+ * \return int
+ */
+ int heightHint() const;
+
+ /**
+ * \brief Returns the size of the editor
+ * \return QSize
+ */
virtual QSize sizeHint() const;
- void setText(const QString text);
+
+ /**
+ * \brief Sets the text in the input line
+ * \param szText The text to set
+ * \return void
+ */
+ void setText(const QString szText);
+
+ /**
+ * \brief Returns the text in the buffer
+ * \return QString
+ */
QString text() { return m_szTextBuffer; };
+
+ /**
+ * \brief Inserts a character at the current position
+ * \param c The character to insert
+ * \return void
+ */
void insertChar(QChar c);
- void insertText(const QString & text);
+
+ /**
+ * \brief Inserts the text at the current position
+ * \param szTxt The text to insert
+ * \return void
+ */
+ void insertText(const QString & szTxt);
+
+ /**
+ * \brief Applies the options and update
+ * \return void
+ */
void applyOptions();
- void setMaxBufferSize(int size) { m_iMaxBufferSize = size; };
+
+ /**
+ * \brief Sets the maximum buffer size
+ * \param iSize The size of the buffer to set
+ * \return void
+ */
+ void setMaxBufferSize(int iSize) { m_iMaxBufferSize = iSize; };
+
+ /**
+ * \brief Sets the read only state for the input line
+ * \param bReadOnly Whether to set the read only state
+ * \return void
+ */
void setReadOnly(bool bReadOnly) { m_bReadOnly = bReadOnly; };
+
+ /**
+ * \brief Returns true if the input line is in read only state
+ * \return bool
+ */
bool readOnly() { return m_bReadOnly; };
private:
- void replaceWordBeforeCursor(const QString & word, const QString & replacement, bool bRepaint = true);
- int replaceSegment(int start, int length, const QString & string);
- void getWordBeforeCursor(QString & buffer, bool * bIsFirstWordInLine);
+ /**
+ * \brief Replaces the word before the cursor
+ * \param szWord The word to replace
+ * \param szReplacement The new word to use
+ * \param bRepaint Whether to repain the input line
+ * \return void
+ */
+ void replaceWordBeforeCursor(const QString & szWord, const QString & szReplacement, bool bRepaint = true);
+
+ /**
+ * \brief Replace characters in the buffer
+ *
+ * Returns the length of the text inserted (different from text.length() only if the buffer was truncated.
+ * \param iStart The starting character
+ * \param iLength The length of the string to replace
+ * \param szString The string to replace with
+ * \return int
+ */
+ int replaceSegment(int iStart, int iLength, const QString & szString);
+
+ /**
+ * \brief Gets the word before the cursor and puts it to the buffer
+ * \param szBuffer The buffer where to put the word got
+ * \param bIsFirstWordInLine Returns true if the word is the first
+ * \return void
+ */
+ void getWordBeforeCursor(QString & szBuffer, bool * bIsFirstWordInLine);
+
+ /**
+ * \brief Moves the cursor to the first visible character
+ * \return void
+ */
void runUpToTheFirstVisibleChar();
- void extractNextBlock(int idx, QFontMetrics & fm, int curXPos, int maxXPos);
- void drawTextBlock(QPainter * pa, QFontMetrics & fm, int curXPos, int textBaseline, int idx, int len, bool bSelected = false);
- QChar getSubstituteChar(unsigned short control_code);
+
+ /**
+ * \brief Extracts the next block of text
+ * \param iIdx The index of the character to check
+ * \param fm The font metrics to use
+ * \param iCurXPos The current position
+ * \param iMaxXPos The maximum position of the text
+ */
+ void extractNextBlock(int iIdx, QFontMetrics & fm, int iCurXPos, int iMaxXPos);
+
+ /**
+ * \brief Draws a block of text
+ * \param pa The pointer to the painter
+ * \param fm The font metrics to use
+ * \param iCurXPos The current X posistion
+ * \param iTextBaseline The current Y position
+ * \param iIdx The index of the character to start crop
+ * \param iLen The length of the string to crop
+ * \param bSelected Whether the text is selected
+ * \return void
+ */
+ void drawTextBlock(QPainter * pa, QFontMetrics & fm, int iCurXPos, int iTextBaseline, int iIdx, int iLen, bool bSelected = false);
+
+ /**
+ * \brief Gets the substitute character for control codes
+ * \param uControlCode The control code inserted
+ * \return QChar
+ */
+ QChar getSubstituteChar(unsigned short uControlCode);
+
+ /**
+ * \brief Moves the internal cursor to the first visibile char to the right
+ * \return void
+ */
void moveRightFirstVisibleCharToShowCursor();
+
+ /**
+ * \brief Repaints the input line with the visible cursor
+ * \return void
+ */
void repaintWithCursorOn();
- void selectOneChar(int pos);
- int charIndexFromXPosition(int xPos);
- int xPositionFromCharIndex(QFontMetrics & fm, int chIdx, bool bContentsCoords = false);
- int xPositionFromCharIndex(int chIdx, bool bContentsCoords = false);
+
+ /**
+ * \brief Selects one character at the given position
+ * \param iPos The position of the character to select
+ * \return void
+ */
+ void selectOneChar(int iPos);
+
+ /**
+ * \brief Returns the current character from a given position
+ * \param iXPos The position to grab
+ * \return int
+ */
+ int charIndexFromXPosition(int iXPos);
+
+ /**
+ * \brief Returns the current position from a given character
+ * \param fm The font metrics
+ * \param iChIdx Th index of the character
+ * \param bContentsCoords Whether to use the frame width in addiction to the margin
+ * \return int
+ */
+ int xPositionFromCharIndex(QFontMetrics & fm, int iChIdx, bool bContentsCoords = false);
+
+ /**
+ * \brief Returns the current position from a given character
+ * \param iChIdx Th index of the character
+ * \param bContentsCoords Whether to use the frame width in addiction to the margin
+ * \return int
+ */
+ int xPositionFromCharIndex(int iChIdx, bool bContentsCoords = false);
+
+ /**
+ * \brief Kills the drag timer
+ * \return void
+ */
void killDragTimer();
+
+ /**
+ * \brief Handles the drag selection
+ * \return void
+ */
void handleDragSelection();
+
+ /**
+ * \brief Moves the cursor to the end of the input line
+ * \return void
+ */
void end();
+
+ /**
+ * \brief Moves the cursor to the start of the input line
+ * \return void
+ */
void home();
+
+ /**
+ * \brief Returns true if the input line has focus
+ * \return bool
+ */
bool hasSelection();
- void moveCursorTo(int idx,bool bRepaint = true);
+
+ /**
+ * \brief Moves the cursor to the specified position
+ * \param iIdx The index of the character to move the cursor to
+ * \param bRepaint Whether to repaint the input line
+ * \return void
+ */
+ void moveCursorTo(int iIdx, bool bRepaint = true);
+
+ /**
+ * \brief Adds the text to the history
+ *
+ * Triggered when the user press return
+ * \param bRepaint Whether to repain the input line
+ * \return void
+ */
void returnPressed(bool bRepaint = true);
+
+ /**
+ * \brief Autocompletion function
+ *
+ * To autocomplete, this function looks for a nickname, a directory, or a
+ * nickname.
+ * \param bShift Whether to complete with the mask of the nickname
+ * \return void
+ */
void completion(bool bShift);
- void standardNickCompletion(bool bAddMask, QString & word, bool bFirstWordInLine);
- void recalcFontMetrics(QFontMetrics * pFm);
+
+ /**
+ * \brief Completes the nickname
+ * \param bAddMask Whether to complete with the mask of the nickname
+ * \param szWord The nickname to complete
+ * \param bFirstWordInLine Whether to add the suffix from option panel
+ * \return void
+ */
+ void standardNickCompletion(bool bAddMask, QString & szWord, bool bFirstWordInLine);
+
+ /**
+ * \brief Recalculates the font metrics
+ * \return void
+ */
+ void recalcFontMetrics();
+
+ /**
+ * \brief Moves the cursor one character to the right
+ * \param bShift Whether to shift the selection
+ * \return void
+ */
void internalCursorRight(bool bShift);
+
+ /**
+ * \brief Moves the cursor one character to the left
+ * \param bShift Whether to shift the selection
+ * \return void
+ */
void internalCursorLeft(bool bShift);
public slots:
- void iconPopupActivated(int id);
+ /**
+ * \brief Opens the icon popup with icon description
+ * \param iId The id of the icon
+ * \return void
+ */
+ void iconPopupActivated(int iId);
+
+ /**
+ * \brief Copies the text to the system clipboard
+ *
+ * If the system supports the mouse clipboard, the text will be
+ * copied there
+ * \return void
+ */
void copyToSelection(bool bDonNotCopyToClipboard = true);
+
+ /**
+ * \brief Copies the text to the system clipboard
+ * \return void
+ */
void copyToClipboard();
+
+ /**
+ * \brief Removes the selected text
+ * \return void
+ */
void removeSelected();
+
+ /**
+ * \brief Cuts the selection from the input line
+ * \return void
+ */
void cut();
+
+ /**
+ * \brief Pastes the text to the system clipboard
+ * \return void
+ */
void pasteClipboardWithConfirmation();
+
+ /**
+ * \brief Pastes the text to the system clipboard
+ *
+ * If the system supports the mouse clipboard, the text will be
+ * copied there
+ * \return void
+ */
void pasteSelectionWithConfirmation();
+
+ /**
+ * \brief Starts a slow paste in the buffer
+ * \return void
+ */
void pasteSlow();
+
+ /**
+ * \brief Stops a slow paste in the buffer
+ * \return void
+ */
void stopPasteSlow();
+
+ /**
+ * \brief Pastes a file to the buffer
+ * \return void
+ */
void pasteFile();
+
+ /**
+ * \brief Selects all text in the input line
+ * \return void
+ */
void selectAll();
+
+ /**
+ * \brief Clears the input line
+ * \return void
+ */
void clear();
signals:
+ /**
+ * \brief Called when the user press escape
+ * \return void
+ */
void escapePressed();
+
+ /**
+ * \brief Called when the user press enter/return
+ * \return void
+ */
void enterPressed();
protected:
virtual void drawContents(QPainter *);
- //virtual void resizeEvent(QResizeEvent *);
+ //virtual void resizeEvent(QResizeEvent * e);
virtual void timerEvent(QTimerEvent * e);
virtual void focusInEvent(QFocusEvent * e);
- virtual void focusOutEvent(QFocusEvent *);
+ virtual void focusOutEvent(QFocusEvent * e);
virtual void keyPressEvent(QKeyEvent * e);
virtual void keyReleaseEvent(QKeyEvent * e);
virtual void mousePressEvent(QMouseEvent * e);
virtual void mouseReleaseEvent(QMouseEvent * e);
virtual void dragEnterEvent(QDragEnterEvent * e);
virtual void dropEvent(QDropEvent * e);
- virtual void imStartEvent(QInputMethodEvent * e);
- virtual void imComposeEvent(QInputMethodEvent * e);
- virtual void imEndEvent(QInputMethodEvent * e);
+ virtual void inputMethodStartEvent(QInputMethodEvent * e);
+ virtual void inputMethodComposeEvent(QInputMethodEvent * e);
+ virtual void inputMethodEndEvent(QInputMethodEvent * e);
virtual void paintEvent(QPaintEvent * e);
};
diff --git a/src/kvirc/ui/kvi_input_history.cpp b/src/kvirc/ui/kvi_input_history.cpp
index 9f8b8530b..3586a8fcf 100644
--- a/src/kvirc/ui/kvi_input_history.cpp
+++ b/src/kvirc/ui/kvi_input_history.cpp
@@ -21,6 +21,8 @@
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
//============================================================================
+// This file was originally part of kvi_input.h
+//============================================================================
#include "kvi_input_history.h"
#include "kvi_config.h"
@@ -77,17 +79,17 @@ void KviInputHistory::load(const QString & szFileName)
{
KviConfig c(szFileName,KviConfig::Read);
- int cnt = c.readIntEntry("Count",0);
+ int iCount = c.readIntEntry("Count",0);
- if(cnt > KVI_INPUT_MAX_GLOBAL_HISTORY_ENTRIES)
- cnt = KVI_INPUT_MAX_GLOBAL_HISTORY_ENTRIES;
+ if(iCount > KVI_INPUT_MAX_GLOBAL_HISTORY_ENTRIES)
+ iCount = KVI_INPUT_MAX_GLOBAL_HISTORY_ENTRIES;
- KviStr tmp;
+ KviStr szTmp;
- for(int i=0;i<cnt;i++)
+ for(int i=0; i<iCount; i++)
{
- tmp.sprintf("S%d",i);
- QString szEntry = c.readQStringEntry(tmp.ptr(),"");
+ szTmp.sprintf("S%d",i);
+ QString szEntry = c.readQStringEntry(szTmp.ptr(),"");
if(!szEntry.isEmpty())
add(new QString(szEntry));
}
@@ -100,16 +102,16 @@ void KviInputHistory::save(const QString & szFileName)
c.writeEntry("Count",m_pStringList->count());
- KviStr tmp;
- int idx = 0;
+ KviStr szTmp;
+ int iIdx = 0;
for(QString * szString = m_pStringList->first(); szString; szString = m_pStringList->next())
{
if(!szString->isEmpty())
{
- tmp.sprintf("S%d",idx);
- c.writeEntry(tmp.ptr(),*szString);
- idx++;
+ szTmp.sprintf("S%d",iIdx);
+ c.writeEntry(szTmp.ptr(),*szString);
+ iIdx++;
}
}
}
diff --git a/src/kvirc/ui/kvi_input_history.h b/src/kvirc/ui/kvi_input_history.h
index 49ae81062..bb27123df 100644
--- a/src/kvirc/ui/kvi_input_history.h
+++ b/src/kvirc/ui/kvi_input_history.h
@@ -23,11 +23,16 @@
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
//============================================================================
+// This file was originally part of kvi_input.h
+//============================================================================
/**
* \file kvi_input_history.h
* \author Elvio Basello
* \brief Input history management
+*
+* \def KVI_INPUT_MAX_GLOBAL_HISTORY_ENTRIES
+* \def KVI_INPUT_MAX_LOCAL_HISTORY_ENTRIES
*/
#include "kvi_settings.h"