aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Elvio Basello2010-10-23 16:08:16 +0000
committerGravatar Elvio Basello2010-10-23 16:08:16 +0000
commitd2a69fca10949401468d3f7d64d04ad0cd9ecd20 (patch)
treef6f86d2dfe26b2e231dffc5e28d4320ce6c9dfbc /src
parentfixed format strings in http module (diff)
downloadKVIrc-d2a69fca10949401468d3f7d64d04ad0cd9ecd20.tar.gz
KVIrc-d2a69fca10949401468d3f7d64d04ad0cd9ecd20.tar.bz2
KVIrc-d2a69fca10949401468d3f7d64d04ad0cd9ecd20.zip
improved hungarian notation;
added doxygen comments; cleaned code; updated TODO; git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@5105 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
-rw-r--r--src/kvirc/kernel/kvi_action.cpp276
-rw-r--r--src/kvirc/kernel/kvi_action.h357
-rw-r--r--src/kvirc/kernel/kvi_coreactions.cpp4
-rw-r--r--src/kvirc/kvs/kvi_kvs_action.cpp33
-rw-r--r--src/kvirc/kvs/kvi_kvs_action.h54
-rw-r--r--src/kvirc/kvs/kvi_kvs_array.cpp121
-rw-r--r--src/kvirc/kvs/kvi_kvs_array.h125
-rw-r--r--src/kvirc/kvs/kvi_kvs_variant.h4
8 files changed, 682 insertions, 292 deletions
diff --git a/src/kvirc/kernel/kvi_action.cpp b/src/kvirc/kernel/kvi_action.cpp
index 916dfb4ea..42cc4ec61 100644
--- a/src/kvirc/kernel/kvi_action.cpp
+++ b/src/kvirc/kernel/kvi_action.cpp
@@ -22,53 +22,40 @@
//
//=============================================================================
-
#include "kvi_action.h"
#include "kvi_customtoolbar.h"
#include "kvi_frame.h"
#include "kvi_irccontext.h"
-#include "kvi_ircconnection.h"
#include "kvi_iconmanager.h"
#include "kvi_app.h"
#include "kvi_window.h"
#include "kvi_channel.h"
-#include "kvi_console.h"
#include "kvi_query.h"
#include "kvi_tal_popupmenu.h"
-KviAction::KviAction(
- QObject * pParent,
- const QString &szName,
- const QString &szVisibleName,
- const QString &szDescription,
- KviActionCategory * pCategory,
- const QString &szBigIconId,
- const QString &szSmallIconId,
- unsigned int uFlags,
- const QString &szKeySequence
- )
- : QObject(pParent),
- m_szName(szName),
- m_szVisibleName(szVisibleName),
- m_szDescription(szDescription),
- m_pCategory(pCategory),
- m_szBigIconId(szBigIconId),
- m_szSmallIconId(szSmallIconId),
- m_pWidgetList(NULL),
- m_uInternalFlags(KVI_ACTION_FLAG_ENABLED),
- m_uFlags(uFlags),
- m_szKeySequence(szKeySequence),
- m_pAccel(NULL)
+#include <QShortcut>
+
+KviActionCategory::KviActionCategory(const QString & szName, const QString & szVisibleName, const QString & szDescription)
+: m_szName(szName), m_szVisibleName(szVisibleName), m_szDescription(szDescription)
+{
+}
+
+KviActionCategory::~KviActionCategory()
{
}
+KviAction::KviAction(QObject * pParent, const QString & szName, const QString & szVisibleName, const QString & szDescription, KviActionCategory * pCategory, const QString & szBigIconId, const QString & szSmallIconId, unsigned int uFlags, const QString & szKeySequence)
+: QObject(pParent),m_szName(szName),m_szVisibleName(szVisibleName),m_szDescription(szDescription),m_pCategory(pCategory),m_szBigIconId(szBigIconId),m_szSmallIconId(szSmallIconId),m_pWidgetList(NULL),m_uInternalFlags(KviAction::Enabled),m_uFlags(uFlags),m_szKeySequence(szKeySequence),m_pAccel(NULL)
+{
+}
+
KviAction::~KviAction()
{
if(m_pWidgetList)
{
- for(QWidget * b = m_pWidgetList->first();b;b = m_pWidgetList->next())
- disconnect(b,SIGNAL(destroyed()),this,SLOT(widgetDestroyed()));
+ for(QWidget * pWidget = m_pWidgetList->first(); pWidget; pWidget = m_pWidgetList->next())
+ disconnect(pWidget,SIGNAL(destroyed()),this,SLOT(widgetDestroyed()));
m_pWidgetList->setAutoDelete(true);
delete m_pWidgetList;
}
@@ -93,7 +80,7 @@ void KviAction::registerAccelerator()
{
if(!m_szKeySequence.isEmpty())
{
- m_pAccel = new QShortcut(m_szKeySequence, g_pFrame, 0, 0, Qt::ApplicationShortcut);
+ m_pAccel = new QShortcut(m_szKeySequence,g_pFrame,0,0,Qt::ApplicationShortcut);
connect(m_pAccel,SIGNAL(activated()),this,SLOT(activate()));
//no way to have Ctrl+Alt+Key events fired as no-ambiguous, probably qt bug
connect(m_pAccel,SIGNAL(activatedAmbiguously()),this,SLOT(activate()));
@@ -113,19 +100,25 @@ void KviAction::unregisterAccelerator()
void KviAction::setEnabled(bool bEnabled)
{
if(bEnabled)
- m_uInternalFlags |= KVI_ACTION_FLAG_ENABLED;
+ m_uInternalFlags |= KviAction::Enabled;
else
- m_uInternalFlags &= ~KVI_ACTION_FLAG_ENABLED;
+ m_uInternalFlags &= ~KviAction::Enabled;
if(m_pWidgetList)
{
if(bEnabled)
{
- for(QWidget * t = m_pWidgetList->first();t;t = m_pWidgetList->next())
- if(!t->isEnabled())t->setEnabled(true);
+ for(QWidget * pWidget = m_pWidgetList->first(); pWidget; pWidget = m_pWidgetList->next())
+ {
+ if(!pWidget->isEnabled())
+ pWidget->setEnabled(true);
+ }
} else {
- for(QWidget * t = m_pWidgetList->first();t;t = m_pWidgetList->next())
- if(t->isEnabled())t->setEnabled(false);
+ for(QWidget * pWidget = m_pWidgetList->first(); pWidget; pWidget = m_pWidgetList->next())
+ {
+ if(pWidget->isEnabled())
+ pWidget->setEnabled(false);
+ }
}
}
}
@@ -172,10 +165,11 @@ void KviAction::setup()
{
connect(g_pFrame,SIGNAL(activeContextChanged()),this,SLOT(activeContextChanged()));
connect(g_pFrame,SIGNAL(activeContextStateChanged()),this,SLOT(activeContextStateChanged()));
- KviIrcContext * c = g_pFrame->activeContext();
- if(!c)setEnabled(false);
+ KviIrcContext * pContext = g_pFrame->activeContext();
+ if(!pContext)
+ setEnabled(false);
else {
- switch(c->state())
+ switch(pContext->state())
{
case KviIrcContext::LoggingIn:
setEnabled(m_uFlags & EnableAtLogin);
@@ -192,24 +186,27 @@ void KviAction::setup()
if(m_uFlags & NeedsContext)
{
connect(g_pFrame,SIGNAL(activeContextChanged()),this,SLOT(activeContextChanged()));
- if(!g_pFrame->activeContext())setEnabled(false);
- else setEnabled(true);
+ if(!g_pFrame->activeContext())
+ setEnabled(false);
+ else
+ setEnabled(true);
}
}
}
- m_uInternalFlags |= KVI_ACTION_FLAG_SETUPDONE;
+ m_uInternalFlags |= KviAction::SetupDone;
}
void KviAction::reloadImages()
{
- if(!m_pWidgetList)return;
- QPixmap * p = bigIcon();
- for(QWidget * b = m_pWidgetList->first();b;b = m_pWidgetList->next())
+ if(!m_pWidgetList)
+ return;
+ QPixmap * pPix = bigIcon();
+ for(QWidget * pWidget = m_pWidgetList->first(); pWidget; pWidget = m_pWidgetList->next())
{
- if(b->inherits("QToolButton"))
- ((QToolButton *)b)->setIcon(p ? *p : QPixmap());
+ if(pWidget->inherits("QToolButton"))
+ ((QToolButton *)pWidget)->setIcon(pPix ? *pPix : QPixmap());
}
}
@@ -219,7 +216,8 @@ void KviAction::activeWindowChanged()
{
if(!g_pFrame->activeContext())
{
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
return;
}
}
@@ -231,7 +229,8 @@ void KviAction::activeWindowChanged()
case KviIrcContext::LoggingIn:
if(!(m_uFlags & EnableAtLogin))
{
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
return;
}
break;
@@ -239,7 +238,8 @@ void KviAction::activeWindowChanged()
// this is ok
break;
default:
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
return;
break;
}
@@ -247,7 +247,8 @@ void KviAction::activeWindowChanged()
if(!g_pActiveWindow)
{
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
return;
}
@@ -259,12 +260,15 @@ void KviAction::activeWindowChanged()
if(m_uFlags & WindowOnlyIfUsersSelected)
{
bool bEnabled = ((KviConsole *)g_pActiveWindow)->selectedCount() > 0;
- if(bEnabled != isEnabled())setEnabled(bEnabled);
+ if(bEnabled != isEnabled())
+ setEnabled(bEnabled);
} else {
- if(!isEnabled())setEnabled(true);
+ if(!isEnabled())
+ setEnabled(true);
}
} else {
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
}
break;
case KVI_WINDOW_TYPE_CHANNEL:
@@ -273,12 +277,15 @@ void KviAction::activeWindowChanged()
if(m_uFlags & WindowOnlyIfUsersSelected)
{
bool bEnabled = ((KviChannel *)g_pActiveWindow)->selectedCount() > 0;
- if(bEnabled != isEnabled())setEnabled(bEnabled);
+ if(bEnabled != isEnabled())
+ setEnabled(bEnabled);
} else {
- if(!isEnabled())setEnabled(true);
+ if(!isEnabled())
+ setEnabled(true);
}
} else {
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
}
break;
case KVI_WINDOW_TYPE_QUERY:
@@ -287,34 +294,40 @@ void KviAction::activeWindowChanged()
if(m_uFlags & WindowOnlyIfUsersSelected)
{
bool bEnabled = ((KviQuery *)g_pActiveWindow)->selectedCount() > 0;
- if(bEnabled != isEnabled())setEnabled(bEnabled);
+ if(bEnabled != isEnabled())
+ setEnabled(bEnabled);
} else {
- if(!isEnabled())setEnabled(true);
+ if(!isEnabled())
+ setEnabled(true);
}
} else {
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
}
break;
case KVI_WINDOW_TYPE_DCCCHAT:
if(m_uFlags & WindowDccChat)
{
- if(!isEnabled())setEnabled(true);
+ if(!isEnabled())
+ setEnabled(true);
} else {
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
}
break;
default:
if(m_uFlags & InternalWindowMask)
{
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
} else {
- if(!isEnabled())setEnabled(true);
+ if(!isEnabled())
+ setEnabled(true);
}
break;
}
}
-
void KviAction::activeWindowSelectionStateChanged(bool bSelectedNow)
{
// we jump here ONLY if m_uFlags & WindowOnlyIfUsersSelected
@@ -324,140 +337,163 @@ void KviAction::activeWindowSelectionStateChanged(bool bSelectedNow)
case KVI_WINDOW_TYPE_CONSOLE:
if(m_uFlags & WindowConsole)
{
- if(bSelectedNow != isEnabled())setEnabled(bSelectedNow);
+ if(bSelectedNow != isEnabled())
+ setEnabled(bSelectedNow);
} else {
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
}
break;
case KVI_WINDOW_TYPE_CHANNEL:
if(m_uFlags & WindowChannel)
{
- if(bSelectedNow != isEnabled())setEnabled(bSelectedNow);
+ if(bSelectedNow != isEnabled())
+ setEnabled(bSelectedNow);
} else {
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
}
break;
case KVI_WINDOW_TYPE_QUERY:
if(m_uFlags & WindowQuery)
{
- if(bSelectedNow != isEnabled())setEnabled(bSelectedNow);
+ if(bSelectedNow != isEnabled())
+ setEnabled(bSelectedNow);
} else {
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
}
break;
case KVI_WINDOW_TYPE_DCCCHAT:
if(m_uFlags & WindowDccChat)
{
- if(!isEnabled())setEnabled(true);
+ if(!isEnabled())
+ setEnabled(true);
} else {
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
}
break;
default:
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
break;
}
}
-
void KviAction::activeContextChanged()
{
// works only if NeedsContext is specified!
- KviIrcContext * c = g_pFrame->activeContext();
- if(c)
+ KviIrcContext * pContext = g_pFrame->activeContext();
+ if(pContext)
{
if(m_uFlags & NeedsConnection)
activeContextStateChanged();
else
- if(!isEnabled())setEnabled(true);
+ if(!isEnabled())
+ setEnabled(true);
} else {
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
}
}
void KviAction::activeContextStateChanged()
{
- KviIrcContext * c = g_pFrame->activeContext();
- if(c)
+ KviIrcContext * pContext = g_pFrame->activeContext();
+ if(pContext)
{
- switch(c->state())
+ switch(pContext->state())
{
case KviIrcContext::Idle:
case KviIrcContext::Connecting:
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
break;
case KviIrcContext::LoggingIn:
if(m_uFlags & EnableAtLogin)
{
- if(!isEnabled())setEnabled(true);
+ if(!isEnabled())
+ setEnabled(true);
} else {
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
}
break;
case KviIrcContext::Connected:
- if(!isEnabled())setEnabled(true);
+ if(!isEnabled())
+ setEnabled(true);
break;
default:
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
break;
}
} else {
- if(isEnabled())setEnabled(false);
+ if(isEnabled())
+ setEnabled(false);
}
}
-bool KviAction::addToPopupMenu(KviTalPopupMenu *pMenu)
+bool KviAction::addToPopupMenu(KviTalPopupMenu * pMenu)
{
- if(!setupDone())setup();
- QPixmap * p = smallIcon();
- int id;
- QString t = visibleName();
- if(!m_szKeySequence.isEmpty())t += '\t' + m_szKeySequence;
- if(p)
- {
- id = pMenu->insertItem(*p,t,this,SLOT(activate()));
- } else {
- id = pMenu->insertItem(t,this,SLOT(activate()));
- }
- if(!isEnabled())pMenu->setItemEnabled(id,false);
+ if(!setupDone())
+ setup();
+ QPixmap * pPix = smallIcon();
+ int iId;
+ QString szTmp = visibleName();
+
+ if(!m_szKeySequence.isEmpty())
+ szTmp += '\t' + m_szKeySequence;
+
+ if(pPix)
+ iId = pMenu->insertItem(*pPix,szTmp,this,SLOT(activate()));
+ else
+ iId = pMenu->insertItem(szTmp,this,SLOT(activate()));
+
+ if(!isEnabled())
+ pMenu->setItemEnabled(iId,false);
return true;
}
void KviAction::widgetDestroyed()
{
- if(!m_pWidgetList)return;
- QWidget * b = (QWidget *)sender();
- m_pWidgetList->removeRef(b);
+ if(!m_pWidgetList)
+ return;
+ QWidget * pWidget = (QWidget *)sender();
+ m_pWidgetList->removeRef(pWidget);
}
-void KviAction::registerWidget(QWidget * b)
+void KviAction::registerWidget(QWidget * pWidget)
{
- connect(b,SIGNAL(destroyed()),this,SLOT(widgetDestroyed()));
+ connect(pWidget,SIGNAL(destroyed()),this,SLOT(widgetDestroyed()));
if(!m_pWidgetList)
{
m_pWidgetList = new KviPointerList<QWidget>;
m_pWidgetList->setAutoDelete(false);
}
- m_pWidgetList->append(b);
+ m_pWidgetList->append(pWidget);
}
-QWidget * KviAction::addToCustomToolBar(KviCustomToolBar *pParentToolBar)
+QWidget * KviAction::addToCustomToolBar(KviCustomToolBar * pParentToolBar)
{
- if(!setupDone())setup();
- QPixmap * p = bigIcon();
- QToolButton * b = new QToolButton(pParentToolBar);
+ if(!setupDone())
+ setup();
+ QPixmap * pPix = bigIcon();
+ QToolButton * pTool = new QToolButton(pParentToolBar);
- b->setIcon(p ? *p : QPixmap());
- b->setText(visibleName());
- b->setToolTip(visibleName());
- b->setObjectName(m_szName.toUtf8().data());
- connect(b,SIGNAL(clicked()),this,SLOT(activate()));
+ pTool->setIcon(pPix ? *pPix : QPixmap());
+ pTool->setText(visibleName());
+ pTool->setToolTip(visibleName());
+ pTool->setObjectName(m_szName.toUtf8().data());
+ connect(pTool,SIGNAL(clicked()),this,SLOT(activate()));
- QAction *a = pParentToolBar->addWidget(b);
- a->setVisible(true);
- if(!isEnabled())b->setEnabled(false);
- registerWidget(b);
- return b;
+ QAction * pAction = pParentToolBar->addWidget(pTool);
+ pAction->setVisible(true);
+ if(!isEnabled())
+ pTool->setEnabled(false);
+ registerWidget(pTool);
+ return pTool;
}
void KviAction::activate()
diff --git a/src/kvirc/kernel/kvi_action.h b/src/kvirc/kernel/kvi_action.h
index f32d23956..5ca659584 100644
--- a/src/kvirc/kernel/kvi_action.h
+++ b/src/kvirc/kernel/kvi_action.h
@@ -6,7 +6,7 @@
// Creation date : Sun 21 Nov 2004 03:36:34 by Szymon Stefanek
//
// This file is part of the KVIrc IRC Client distribution
-// Copyright (C) 2004-2008 Szymon Stefanek <pragma at kvirc dot net>
+// Copyright (C) 2004-2010 Szymon Stefanek <pragma at kvirc dot net>
//
// This program is FREE software. You can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -24,26 +24,28 @@
//
//=============================================================================
+/**
+* \file kvi_action.h
+* \author Szymon Stefanek
+* \brief Actions handling
+*/
+
#include "kvi_settings.h"
#include "kvi_pointerlist.h"
#include <QObject>
-#include <QString>
-#include <QShortcut>
-
-// The action name is INTERNAL: it should be never shown to the user
-// if it contains a dot then the part before the dot is considered to
-// be a module name to be loaded when the
-
-// Known categories are: general (or empty), irc, script
-//
+class QShortcut;
+class QPixmap;
class KviTalPopupMenu;
-class QWidget;
class KviCustomToolBar;
-class QPixmap;
-class KviKvsScript;
+/**
+* \class KviActionCategory
+* \brief Holds the categories of an action
+*
+* Known categories are: general (or empty), irc, script
+*/
class KVIRC_API KviActionCategory
{
protected:
@@ -51,98 +53,323 @@ protected:
QString m_szVisibleName;
QString m_szDescription;
public:
- KviActionCategory(const QString &szName,const QString &szVisibleName,const QString &szDescription)
- : m_szName(szName), m_szVisibleName(szVisibleName), m_szDescription(szDescription) {};
- ~KviActionCategory(){};
+ /**
+ * \brief Constructs an action category object
+ * \param szName The name of the category
+ * \param szVisibleName Permanent visible name, visible at least in the action drawer
+ * \param szDescription Description of the category
+ * \return KviActionCategory
+ */
+ KviActionCategory(const QString & szName, const QString & szVisibleName, const QString & szDescription);
+
+ /**
+ * \brief Destroys an action category object
+ */
+ ~KviActionCategory();
public:
+ /**
+ * \brief Returns the name of the category
+ * \return const QString &
+ */
const QString & name(){ return m_szName; };
+
+ /**
+ * \brief Returns the visible name of the category
+ * \return const QString &
+ */
const QString & visibleName(){ return m_szVisibleName; };
+
+ /**
+ * \brief Returns the description of the category
+ * \return const QString &
+ */
const QString & description(){ return m_szDescription; };
};
-// these flags are INTERNAL
-#define KVI_ACTION_FLAG_ENABLED 1
-#define KVI_ACTION_FLAG_SETUPDONE 2
-
+/**
+* \class KviAction
+* \brief Defines an action inside KVIrc
+*/
class KVIRC_API KviAction : public QObject
{
friend class KviActionManager;
Q_OBJECT
-protected:
- QString m_szName; // the internal name of the action, must be in form [module.]name
- QString m_szVisibleName;
- QString m_szDescription;
- KviActionCategory * m_pCategory; // may be 0, not owned!
- QString m_szBigIconId;
- QString m_szSmallIconId;
- KviPointerList<QWidget> * m_pWidgetList;
- unsigned short int m_uInternalFlags;
- unsigned int m_uFlags;
- QString m_szKeySequence;
- QShortcut * m_pAccel;
public:
+ /**
+ * \enum InternalFlags
+ * \brief Holds the internal flags of an action
+ */
+ enum InternalFlags {
+ Enabled = 1, /**< the action is enabled */
+ SetupDone = 2 /**< the setup of the action is done */
+ };
+
+ /**
+ * \enum Flags
+ * \brief Holds the flags of an action
+ */
enum Flags {
- NeedsContext = 1,
- NeedsConnection = 2, // implies NeedsContext
- WindowConsole = 4,
- WindowChannel = 8,
- WindowQuery = 16,
- WindowDccChat = 32,
- InternalWindowMask = WindowConsole | WindowChannel | WindowQuery | WindowDccChat,
- EnableAtLogin = 64, // implies NeedsConnection
- WindowOnlyIfUsersSelected = 128 // implies at least one of WindowConsole | WindowChannel | WindowQuery
+ NeedsContext = 1, /**< the action needs a context */
+ NeedsConnection = 2, /**< the action needs a connection; implies NeedsContext */
+ WindowConsole = 4, /**< the action is bound to a console window */
+ WindowChannel = 8, /**< the action is bound to a channel window */
+ WindowQuery = 16, /**< the action is bound to a query window */
+ WindowDccChat = 32, /**< the action is bound to a DCC Chat window */
+ InternalWindowMask = WindowConsole | WindowChannel | WindowQuery | WindowDccChat, /**< the action is bound to a window */
+ EnableAtLogin = 64, /**< the action is enabled at login; implies NeedsConnection */
+ WindowOnlyIfUsersSelected = 128 /**< the action is bound to a window only if it's selected by the user; implies at least one of WindowConsole | WindowChannel | WindowQuery */
};
public:
- KviAction(QObject * pParent, // can be 0, but using a QObject will help in deleting this action :)
- const QString &szName, // internal name of this action, in form [module.]name
- const QString &szVisibleName, // permanent visible name, visible at least in the action drawer
- const QString &szDescription, // what this action does ?
- KviActionCategory * pCategory = NULL, // one of KviActionManager::category*() or 0 (default category)
- const QString &szBigIconId = QString(),
- const QString &szSmallIconId = QString(),
- unsigned int uFlags = 0,
- const QString &szKeySequence = QString()
- );
+ /**
+ * \brief Constructs the action object
+ * \param pParent The parent object
+ *
+ * It can be 0, but using a QObject will help in deleting this action :)
+ * \param szName Internal name of this action, in form [module.]name
+ *
+ * The action name is INTERNAL: it should be never shown to the user. If it contains a dot
+ * then the part before the dot is considered to be a module name to be loaded when the
+ * module is loaded.
+ * \param szVisibleName Permanent visible name, visible at least in the action drawer
+ * \param szDescription What this action does
+ * \param pCategory One of KviActionManager::category*() or 0 (default category), not owned!
+ * \param szBigIconId The big icon associated to the action (32x32)
+ * \param szSmallIconId The small icon associated to the action (16x16)
+ * \param uFlags The flags of the action, like needs and configuration
+ * \param szKeySequence The shortcut to activate the action
+ * \return KviAction
+ */
+ KviAction(QObject * pParent, const QString & szName, const QString & szVisibleName, const QString & szDescription, KviActionCategory * pCategory = NULL, const QString & szBigIconId = QString(), const QString & szSmallIconId = QString(), unsigned int uFlags = 0, const QString & szKeySequence = QString());
+
+ /**
+ * \brief Destroys the action object
+ */
virtual ~KviAction();
+protected:
+ QString m_szName;
+ QString m_szVisibleName;
+ QString m_szDescription;
+ KviActionCategory * m_pCategory;
+ QString m_szBigIconId;
+ QString m_szSmallIconId;
+ KviPointerList<QWidget> * m_pWidgetList;
+ unsigned short int m_uInternalFlags;
+ unsigned int m_uFlags;
+ QString m_szKeySequence;
+ QShortcut * m_pAccel;
public:
+ /**
+ * \brief Validates the flags of the action
+ * \param iFlagsToValidate The flags to validate
+ * \return int
+ */
static int validateFlags(int iFlagsToValidate);
+
+ /**
+ * \brief Returns the name of the action
+ * \return const QString &
+ */
const QString & name() const { return m_szName; };
+
+ /**
+ * \brief Returns the visible name of the action
+ * \return const QString &
+ */
virtual const QString & visibleName();
+
+ /**
+ * \brief Returns the description of the action
+ * \return const QString &
+ */
virtual const QString & description();
+
+ /**
+ * \brief Returns the shortcut of the action
+ * \return const QString &
+ */
const QString & keySequence() const { return m_szKeySequence; };
+
+ /**
+ * \brief Returns the id of the big icon associated to the action
+ * \return const QString &
+ */
const QString & bigIconId() const { return m_szBigIconId; };
+
+ /**
+ * \brief Returns the id of the small icon associated to the action
+ * \return const QString &
+ */
const QString & smallIconId() const { return m_szSmallIconId; };
+
+ /**
+ * \brief Returns the category of the action
+ * \return const QString &
+ */
KviActionCategory * category() const { return m_pCategory; };
- bool isEnabled() const { return (m_uInternalFlags & KVI_ACTION_FLAG_ENABLED); };
+
+ /**
+ * \brief Returns true if the action is enabled
+ * \return bool
+ */
+ bool isEnabled() const { return (m_uInternalFlags & KviAction::Enabled); };
+
+ /**
+ * \brief Returns the flag associated to the action
+ * \return unsigned int
+ */
unsigned int flags(){ return m_uFlags; };
+
+ /**
+ * \brief Returns true if the action is user-defined
+ * \warning By default, this function returns always false
+ * \return bool
+ */
virtual bool isKviUserActionNeverOverrideThis();
+
+ /**
+ * \brief Enables the action
+ * \param bEnabled Whether to enable the action
+ * \return void
+ */
virtual void setEnabled(bool bEnabled);
- virtual QPixmap * smallIcon(); // FIXME: maybe doesn't need to be virtual anymore
- virtual QPixmap * bigIcon(); // FIXME: maybe doesn't need to be virtual anymore
- virtual bool addToPopupMenu(KviTalPopupMenu *pMenu);
- virtual QWidget * addToCustomToolBar(KviCustomToolBar *pParentToolBar);
- void suicide() { delete this; };
+
+ /**
+ * \brief Returns the small icon associated to the action
+ * \return const QString &
+ */
+ QPixmap * smallIcon();
+
+ /**
+ * \brief Returns the big icon associated to the action
+ * \return const QString &
+ */
+ QPixmap * bigIcon();
+
+ /**
+ * \brief Adds the action to the given popup
+ * \param pMenu The menu where to add the action
+ * \return bool
+ */
+ virtual bool addToPopupMenu(KviTalPopupMenu * pMenu);
+
+ /**
+ * \brief Adds the action to the given toolbar
+ * \param pParentToolBar The toolbar where to add the action
+ * \return QWidget *
+ */
+ virtual QWidget * addToCustomToolBar(KviCustomToolBar * pParentToolBar);
+
+ /**
+ * \brief Destroys itself. Maybe the best function in the whole APIs :)
+ * \return void
+ */
+ void suicide(){ delete this; };
protected:
- // called once before the FIRST button or menu item is created
- bool setupDone() const { return (m_uInternalFlags & KVI_ACTION_FLAG_SETUPDONE); };
+ /**
+ * \brief Returns true if the setup is finished
+ * \note Called once before the FIRST button or menu item is created
+ * \return bool
+ */
+ bool setupDone() const { return (m_uInternalFlags & KviAction::SetupDone); };
+
+ /**
+ * \brief Enables or disables the action upon starting KVIrc
+ * \return void
+ */
virtual void setup();
+
+ /**
+ * \brief Returns the list of widgets associated to the action
+ * \return KviPointerList<QWidget> *
+ */
KviPointerList<QWidget> * widgetList(){ return m_pWidgetList; };
+
+ /**
+ * \brief Registers the action shortcut in the application
+ * \return void
+ */
void registerAccelerator();
+
+ /**
+ * \brief Removes the action shortcut from the application
+ * \return void
+ */
void unregisterAccelerator();
- void registerWidget(QWidget * b);
+
+ /**
+ * \brief Adds the widget to the list
+ * \param pWidget The widget to add
+ * \return void
+ */
+ void registerWidget(QWidget * pWidget);
+public slots:
+ /**
+ * \brief Activates the action
+ *
+ * It's called when the user activates the action clicking on the toolbar, the menu or by
+ * hitting its shortcut.
+ * \return void
+ */
+ virtual void activate();
protected slots:
+ /**
+ * \brief Removes the widget from the list
+ *
+ * Called when the widget is being destroyed
+ * \return void
+ */
virtual void widgetDestroyed();
+
+ /**
+ * \brief Reloads the images
+ *
+ * Called when the application wants to refresh the images in the toolbar
+ * \return void
+ */
virtual void reloadImages();
+
+ /**
+ * \brief Enables or disables the action upon checking the active context
+ *
+ * If the context doesn't exist, the action is disabled
+ *
+ * Called when the frame changes the active context.
+ * \note It works only if NeedsContext is specified
+ * \return void
+ */
virtual void activeContextChanged();
+
+ /**
+ * \brief Enables or disables the action upon checking the active context
+ *
+ * Called when the frame changes the state of the context
+ * \return void
+ */
virtual void activeContextStateChanged();
+
+ /**
+ * \brief Enables or disables the action upon checking the active window
+ *
+ * Called when the frame changes the active window.
+ * \return void
+ */
virtual void activeWindowChanged();
+
+ /**
+ * \brief Enables or disables the action upon checking the active window
+ *
+ * Called when the frame changes the active window.
+ * \note We jump here ONLY if m_uFlags & WindowOnlyIfUsersSelected and thus also
+ * m_uFlags & InternalWindowMask
+ * \return void
+ */
virtual void activeWindowSelectionStateChanged(bool bSelectedNow);
-public slots:
- virtual void activate();
signals:
+ /**
+ * \brief Emitted when the action is being activated
+ * \return void
+ */
void activated();
};
-
-
-#endif //!_KVI_ACTION_H_
+#endif // _KVI_ACTION_H_
diff --git a/src/kvirc/kernel/kvi_coreactions.cpp b/src/kvirc/kernel/kvi_coreactions.cpp
index ea9ee506a..ec8cd50d0 100644
--- a/src/kvirc/kernel/kvi_coreactions.cpp
+++ b/src/kvirc/kernel/kvi_coreactions.cpp
@@ -1034,14 +1034,14 @@ void KviGoAwayAction::activeContextStateChanged()
b->setIcon(QIcon(*p));
b->setText(txt);
}
- m_uInternalFlags |= KVI_ACTION_FLAG_ENABLED;
+ m_uInternalFlags |= KviAction::Enabled;
setEnabled(true);
} else {
for(QToolButton * b = (QToolButton *)bl->first();b;b = (QToolButton *)bl->next())
{
if(b->isEnabled())b->setEnabled(false);
}
- m_uInternalFlags &= ~KVI_ACTION_FLAG_ENABLED;
+ m_uInternalFlags &= ~KviAction::Enabled;
setEnabled(true);
}
}
diff --git a/src/kvirc/kvs/kvi_kvs_action.cpp b/src/kvirc/kvs/kvi_kvs_action.cpp
index ce7be3690..e6f288acf 100644
--- a/src/kvirc/kvs/kvi_kvs_action.cpp
+++ b/src/kvirc/kvs/kvi_kvs_action.cpp
@@ -4,7 +4,7 @@
// Creation date : Sat 04 Dec 2004 04:22:12 by Szymon Stefanek
//
// This file is part of the KVIrc IRC client distribution
-// Copyright (C) 2004-2008 Szymon Stefanek <pragma at kvirc dot net>
+// Copyright (C) 2004-2010 Szymon Stefanek <pragma at kvirc dot net>
//
// This program is FREE software. You can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -22,40 +22,16 @@
//
//=============================================================================
-
-
#include "kvi_kvs_action.h"
#include "kvi_kvs_script.h"
#include "kvi_window.h"
-KviKvsAction::KviKvsAction(
- QObject * pParent,
- const QString &szName,
- const QString &szScriptCode,
- const QString &szVisibleName,
- const QString &szDescription,
- KviActionCategory * pCategory,
- const QString &szBigIconId,
- const QString &szSmallIconId,
- unsigned int uFlags,
- const QString &szKeySequence
- )
- : KviAction(
- pParent,
- szName,
- szVisibleName,
- szDescription,
- pCategory,
- szBigIconId,
- szSmallIconId,
- uFlags,
- szKeySequence
- )
+KviKvsAction::KviKvsAction(QObject * pParent, const QString & szName, const QString & szScriptCode, const QString & szVisibleName, const QString & szDescription, KviActionCategory * pCategory, const QString & szBigIconId, const QString & szSmallIconId, unsigned int uFlags, const QString & szKeySequence)
+: KviAction(pParent,szName,szVisibleName,szDescription,pCategory,szBigIconId,szSmallIconId,uFlags,szKeySequence)
{
m_szScript = QString(szScriptCode);
}
-
KviKvsAction::~KviKvsAction()
{
unregisterAccelerator();
@@ -68,6 +44,7 @@ const QString & KviKvsAction::scriptCode()
void KviKvsAction::activate()
{
- if(!isEnabled())return; // no way
+ if(!isEnabled())
+ return; // no way
KviKvsScript::run(m_szScript,g_pActiveWindow);
}
diff --git a/src/kvirc/kvs/kvi_kvs_action.h b/src/kvirc/kvs/kvi_kvs_action.h
index dca5512b8..f79df171e 100644
--- a/src/kvirc/kvs/kvi_kvs_action.h
+++ b/src/kvirc/kvs/kvi_kvs_action.h
@@ -6,7 +6,7 @@
// Creation date : Sat 04 Dec 2004 04:22:12 by Szymon Stefanek
//
// This file is part of the KVIrc IRC client distribution
-// Copyright (C) 2004-2008 Szymon Stefanek <pragma at kvirc dot net>
+// Copyright (C) 2004-2010 Szymon Stefanek <pragma at kvirc dot net>
//
// This program is FREE software. You can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -24,33 +24,59 @@
//
//=============================================================================
+/**
+* \file kvi_kvs_action.h
+* \author Szymon Stefanek
+* \brief Actions handling
+*/
+
#include "kvi_settings.h"
#include "kvi_action.h"
class KviKvsScript;
+/**
+* \class KviKvsAction
+* \brief This class handles the actions
+*/
class KVIRC_API KviKvsAction : public KviAction
{
Q_OBJECT
protected:
QString m_szScript;
public:
- KviKvsAction(
- QObject * pParent,
- const QString &szName,
- const QString &szScriptCode,
- const QString &szVisibleName,
- const QString &szDescription,
- KviActionCategory * pCategory = NULL,
- const QString &szBigIconId = QString(),
- const QString &szSmallIconId = QString(),
- unsigned int uFlags = 0,
- const QString &szKeySequence = QString()
- );
+ /**
+ * \brief Contructs the action object
+ * \param pParent The parent object
+ * \param szName The name of the action
+ * \param szScriptCode The code of the script contained in the action
+ * \param szVisibleName Permanent visible name, visible at least in the action drawer
+ * \param szDescription The description of the action
+ * \param pCategory One of KviActionManager::category*() or 0 (default category)
+ * \param szBigIconId The id of a big icon (32x32)
+ * \param szSmallIconId The id of a small icon (16x16)
+ * \param uFlags Flags of the action like connection needed, context needed, ...
+ * \param szKeySequence The shortcut to activate the action
+ * \return KviKvsAction
+ */
+ KviKvsAction(QObject * pParent, const QString & szName, const QString & szScriptCode, const QString & szVisibleName, const QString & szDescription, KviActionCategory * pCategory = NULL, const QString & szBigIconId = QString(), const QString & szSmallIconId = QString(), unsigned int uFlags = 0, const QString & szKeySequence = QString());
+
+ /**
+ * \brief Destroys the action object
+ */
~KviKvsAction();
public:
+ /**
+ * \brief Returns the code of the script contained in the action
+ * \return const QString &
+ */
const QString & scriptCode();
+
+ /**
+ * \brief Executes the action
+ * \return void
+ */
virtual void activate();
};
-#endif //!_KVI_KVSACTION_H_
+#endif // _KVI_KVSACTION_H_
diff --git a/src/kvirc/kvs/kvi_kvs_array.cpp b/src/kvirc/kvs/kvi_kvs_array.cpp
index 7a68eb088..12caedc1e 100644
--- a/src/kvirc/kvs/kvi_kvs_array.cpp
+++ b/src/kvirc/kvs/kvi_kvs_array.cpp
@@ -22,8 +22,6 @@
//
//=============================================================================
-
-
#include "kvi_kvs_array.h"
#include "kvi_malloc.h"
@@ -39,18 +37,21 @@ KviKvsArray::KviKvsArray()
m_uAllocSize = 0;
}
-KviKvsArray::KviKvsArray(const KviKvsArray &a)
+KviKvsArray::KviKvsArray(const KviKvsArray & array)
: KviHeapObject()
{
- m_uSize = a.m_uSize;
- m_uAllocSize = a.m_uAllocSize;
+ m_uSize = array.m_uSize;
+ m_uAllocSize = array.m_uAllocSize;
if(m_uAllocSize > 0)
{
m_pData = (KviKvsVariant **)kvi_malloc((sizeof(KviKvsVariant *)) * m_uAllocSize);
- kvs_uint_t i;
- for(i=0;i<m_uSize;i++)
- if(a.m_pData[i])m_pData[i] = new KviKvsVariant(*(a.m_pData[i]));
- else m_pData[i] = 0;
+ kvs_uint_t u;
+ for(u = 0; u < m_uSize; u++)
+ {
+ if(array.m_pData[u])
+ m_pData[u] = new KviKvsVariant(*(array.m_pData[u]));
+ else m_pData[u] = 0;
+ }
} else {
m_pData = 0;
}
@@ -60,44 +61,53 @@ KviKvsArray::~KviKvsArray()
{
if(m_pData)
{
- for(kvs_uint_t i=0;i<m_uSize;i++)
- if(m_pData[i])delete m_pData[i];
+ for(kvs_uint_t u = 0; u < m_uSize; u++)
+ {
+ if(m_pData[u])
+ delete m_pData[u];
+ }
kvi_free(m_pData);
}
}
-static int kvs_array_reverse_compare_func(const void * v1,const void * v2)
+int KviKvsArray::compareReverse(const void * pV1, const void * pV2)
{
- if(*((KviKvsVariant **)v1))return (*((KviKvsVariant **)v1))->compare(*((KviKvsVariant **)v2));
- if(*((KviKvsVariant **)v2))return -(*((KviKvsVariant **)v2))->compare(*((KviKvsVariant **)v1));
+ if(*((KviKvsVariant **)pV1))
+ return (*((KviKvsVariant **)pV1))->compare(*((KviKvsVariant **)pV2));
+ if(*((KviKvsVariant **)pV2))
+ return -(*((KviKvsVariant **)pV2))->compare(*((KviKvsVariant **)pV1));
return 0;
}
-static int kvs_array_compare_func(const void * v1,const void * v2)
+int KviKvsArray::compare(const void * pV1, const void * pV2)
{
- if(*((KviKvsVariant **)v1))return -(*((KviKvsVariant **)v1))->compare(*((KviKvsVariant **)v2));
- if(*((KviKvsVariant **)v2))return (*((KviKvsVariant **)v2))->compare(*((KviKvsVariant **)v1));
+ if(*((KviKvsVariant **)pV1))
+ return -(*((KviKvsVariant **)pV1))->compare(*((KviKvsVariant **)pV2));
+ if(*((KviKvsVariant **)pV2))
+ return (*((KviKvsVariant **)pV2))->compare(*((KviKvsVariant **)pV1));
return 0;
}
-
void KviKvsArray::sort()
{
- if(m_uSize < 2)return; // already sorted
- qsort(m_pData,m_uSize,sizeof(KviKvsVariant *),kvs_array_compare_func);
+ if(m_uSize < 2)
+ return; // already sorted
+ qsort(m_pData,m_uSize,sizeof(KviKvsVariant *),compare);
findNewSize();
}
void KviKvsArray::rsort()
{
- if(m_uSize < 2)return; // already sorted
- qsort(m_pData,m_uSize,sizeof(KviKvsVariant *),kvs_array_reverse_compare_func);
+ if(m_uSize < 2)
+ return; // already sorted
+ qsort(m_pData,m_uSize,sizeof(KviKvsVariant *),compareReverse);
findNewSize();
}
void KviKvsArray::unset(kvs_uint_t uIdx)
{
- if(uIdx >= m_uSize)return;
+ if(uIdx >= m_uSize)
+ return;
if(m_pData[uIdx])
{
@@ -114,14 +124,18 @@ void KviKvsArray::unset(kvs_uint_t uIdx)
void KviKvsArray::findNewSize()
{
// find the new size
- if(m_uSize == 0)return;
+ if(m_uSize == 0)
+ return;
kvs_uint_t u = m_uSize - 1;
while(u > 0)
{
- if(m_pData[u])break;
+ if(m_pData[u])
+ break;
u--;
}
- if(m_pData[u])m_uSize = u + 1;
+
+ if(m_pData[u])
+ m_uSize = u + 1;
else {
// u == 0, and there is no data in there
m_uSize = 0;
@@ -142,26 +156,27 @@ void KviKvsArray::findNewSize()
}
}
-void KviKvsArray::set(kvs_uint_t uIdx,KviKvsVariant * pVal)
+void KviKvsArray::set(kvs_uint_t uIdx, KviKvsVariant * pVal)
{
if(uIdx >= m_uSize)
{
if(uIdx == m_uSize)
- {
m_uAllocSize += KVI_KVS_ARRAY_ALLOC_CHUNK; // sequential set
- } else {
+ else
m_uAllocSize = uIdx + 1;
- }
+
if(m_pData)
m_pData = (KviKvsVariant **)kvi_realloc(m_pData,(sizeof(KviKvsVariant *)) * m_uAllocSize);
else
m_pData = (KviKvsVariant **)kvi_malloc((sizeof(KviKvsVariant *)) * m_uAllocSize);
+
for(kvs_uint_t u=m_uSize;u<uIdx;u++)
m_pData[u] = 0;
m_uSize = uIdx+1;
m_pData[uIdx] = pVal;
} else {
- if(m_pData[uIdx])delete m_pData[uIdx];
+ if(m_pData[uIdx])
+ delete m_pData[uIdx];
m_pData[uIdx] = pVal;
}
}
@@ -171,16 +186,16 @@ KviKvsVariant * KviKvsArray::getAt(kvs_uint_t uIdx)
if(uIdx >= m_uSize)
{
if(uIdx == m_uSize)
- {
m_uAllocSize += KVI_KVS_ARRAY_ALLOC_CHUNK; // sequential set
- } else {
+ else
m_uAllocSize = uIdx + 1;
- }
+
if(m_pData)
m_pData = (KviKvsVariant **)kvi_realloc(m_pData,(sizeof(KviKvsVariant *)) * m_uAllocSize);
else
m_pData = (KviKvsVariant **)kvi_malloc((sizeof(KviKvsVariant *)) * m_uAllocSize);
- for(kvs_uint_t u=m_uSize;u<uIdx;u++)
+
+ for(kvs_uint_t u = m_uSize; u < uIdx; u++)
m_pData[u] = 0;
m_uSize = uIdx+1;
m_pData[uIdx] = new KviKvsVariant();
@@ -191,36 +206,44 @@ KviKvsVariant * KviKvsArray::getAt(kvs_uint_t uIdx)
return m_pData[uIdx];
}
-void KviKvsArray::serialize(QString& result)
+void KviKvsArray::serialize(QString & szResult)
{
- QString tmpBuffer;
- result="[";
+ QString szBuffer;
+ szResult = "[";
kvs_uint_t u = 0;
bool bNeedComma = false;
while(u < m_uSize)
{
- if(bNeedComma)result.append(',');
- else bNeedComma = true;
- if(m_pData[u]) {
- m_pData[u]->serialize(tmpBuffer);
- result.append(tmpBuffer);
+ if(bNeedComma)
+ szResult.append(',');
+ else
+ bNeedComma = true;
+
+ if(m_pData[u])
+ {
+ m_pData[u]->serialize(szBuffer);
+ szResult.append(szBuffer);
} else {
- result.append("null");
+ szResult.append("null");
}
u++;
}
- result.append(']');
+ szResult.append(']');
}
-void KviKvsArray::appendAsString(QString &szBuffer)
+void KviKvsArray::appendAsString(QString & szBuffer)
{
kvs_uint_t u = 0;
bool bNeedComma = false;
while(u < m_uSize)
{
- if(bNeedComma)szBuffer.append(',');
- else bNeedComma = true;
- if(m_pData[u])m_pData[u]->appendAsString(szBuffer);
+ if(bNeedComma)
+ szBuffer.append(',');
+ else
+ bNeedComma = true;
+
+ if(m_pData[u])
+ m_pData[u]->appendAsString(szBuffer);
u++;
}
}
diff --git a/src/kvirc/kvs/kvi_kvs_array.h b/src/kvirc/kvs/kvi_kvs_array.h
index 091a40fce..f92b1616b 100644
--- a/src/kvirc/kvs/kvi_kvs_array.h
+++ b/src/kvirc/kvs/kvi_kvs_array.h
@@ -6,7 +6,7 @@
// Creation date : Tue 07 Oct 2003 01:07:31 by Szymon Stefanek
//
// This file is part of the KVIrc IRC client distribution
-// Copyright (C) 2003-2008 Szymon Stefanek <pragma at kvirc dot net>
+// Copyright (C) 2003-2010 Szymon Stefanek <pragma at kvirc dot net>
//
// This program is FREE software. You can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -24,39 +24,140 @@
//
//=============================================================================
+/**
+* \file kvi_kvs_array.h
+* \author Szymon Stefanek
+* \brief Handling of array data type in KVS
+*/
+
#include "kvi_settings.h"
-#include "kvi_qstring.h"
#include "kvi_kvs_variant.h"
#include "kvi_heapobject.h"
-
-// This class must not have virtual funcitons nor destructor
-// Otherwise it will happily crash on windows when it is
-// allocated in modules and destroyed anywhere else around...
+/**
+* \class KviKvsArray
+* \brief This class defines a new data type which contains array data
+* \warning This class must not have virtual functions nor destructor. Otherwise it will happily
+* crash on windows when it is allocated in modules and destroyed anywhere else around
+*/
class KVIRC_API KviKvsArray : public KviHeapObject
{
public:
+ /**
+ * \brief Constructs the array data
+ * \return KviKvsArray
+ */
KviKvsArray();
- KviKvsArray(const KviKvsArray &a);
+
+ /**
+ * \brief Constructs the array data
+ *
+ * This is a carbon copy
+ * \param array The array to copy from
+ * \return KviKvsArray
+ */
+ KviKvsArray(const KviKvsArray & array);
+
+ /**
+ * \brief Destroys the array data
+ */
~KviKvsArray();
protected:
KviKvsVariant ** m_pData;
kvs_uint_t m_uSize;
kvs_uint_t m_uAllocSize;
public:
+ /**
+ * \brief Unsets an element from the array
+ * \param uIdx The index of the element to unset
+ * \return void
+ */
void unset(kvs_uint_t uIdx);
- void set(kvs_uint_t uIdx,KviKvsVariant * pVal);
+
+ /**
+ * \brief Sets an element into the array at the given index
+ * \param uIdx The index of the element to set
+ * \param pVal The value to set
+ * \return void
+ */
+ void set(kvs_uint_t uIdx, KviKvsVariant * pVal);
+
+ /**
+ * \brief Returns the element at the given index
+ * \param uIdx The index of the element to retrieve
+ * \return KviKvsVariant *
+ */
KviKvsVariant * at(kvs_uint_t uIdx) const { return (uIdx < m_uSize) ? m_pData[uIdx] : 0; };
+
+ /**
+ * \brief Returns the element at the given index
+ *
+ * If the element doesn't exists, it returns an empty element. If the index is out of
+ * array bounds, it increases the array size, fillin the array in with zeros.
+ * \param uIdx The index of the element to retrieve
+ * \return KviKvsVariant *
+ */
KviKvsVariant * getAt(kvs_uint_t uIdx);
+
+ /**
+ * \brief Returns true if the array is empty
+ * \return bool
+ */
bool isEmpty(){ return m_uSize == 0; };
+
+ /**
+ * \brief Returns the size of the array
+ * \return kvs_uint_t
+ */
kvs_uint_t size(){ return m_uSize; };
- void appendAsString(QString &szBuffer);
- void serialize(QString& result);
+
+ /**
+ * \brief Appends data to the array converting it into a string
+ * \param szBuffer The string to append
+ * \return void
+ */
+ void appendAsString(QString & szBuffer);
+
+ /**
+ * \brief Serializes the array to a given buffer
+ * \param szResult The buffer to store
+ * \return void
+ */
+ void serialize(QString & szResult);
+
+ /**
+ * \brief Sorts the array
+ * \return void
+ */
void sort();
+
+ /**
+ * \brief Sorts the array in reverse order
+ * \return void
+ */
void rsort();
protected:
+ /**
+ * \brief Finds the new size of the array
+ * \return void
+ */
void findNewSize();
-};
+private:
+ /**
+ * \brief Compares two elements of the array
+ * \param pV1 The first element to compare
+ * \param pV2 The second element to compare
+ * \return int
+ */
+ static int compare(const void * pV1, const void * pV2);
+ /**
+ * \brief Compares two elements of the array in reverse order
+ * \param pV1 The first element to compare
+ * \param pV2 The second element to compare
+ * \return int
+ */
+ static int compareReverse(const void * pV1, const void * pV2);
+};
-#endif //!_KVI_KVS_ARRAY_H_
+#endif // _KVI_KVS_ARRAY_H_
diff --git a/src/kvirc/kvs/kvi_kvs_variant.h b/src/kvirc/kvs/kvi_kvs_variant.h
index 47bf5b7d7..cb5ca0fea 100644
--- a/src/kvirc/kvs/kvi_kvs_variant.h
+++ b/src/kvirc/kvs/kvi_kvs_variant.h
@@ -27,7 +27,7 @@
/**
* \file kvi_kvs_variant.h
* \author Szymon Stefanek
-* \brief Handling of variant data
+* \brief Handling of variant data type in KVS
*/
#include "kvi_settings.h"
@@ -331,7 +331,7 @@ public:
/**
* \class KviKvsVariant
-* \brief This class holds the variant data
+* \brief This class defines a new data type which contains variant data
*
* A variant data is a data which can assume different data types. This is very useful when you
* don't know in advance which data type you have to manage.