aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/classeditor/classeditor.cpp
diff options
context:
space:
mode:
authorGravatar Elvio Basello2010-08-23 23:57:34 +0000
committerGravatar Elvio Basello2010-08-23 23:57:34 +0000
commit3297e2db09c47ec12d85d532e9144290f7d0d38a (patch)
treea1bdd8f029f47f0d653b923d55ecce343954a09d /src/modules/classeditor/classeditor.cpp
parentupdate (diff)
downloadKVIrc-3297e2db09c47ec12d85d532e9144290f7d0d38a.tar.gz
KVIrc-3297e2db09c47ec12d85d532e9144290f7d0d38a.tar.bz2
KVIrc-3297e2db09c47ec12d85d532e9144290f7d0d38a.zip
cleaned code;
added doxygen comments (wip); improved indentation and hungarian notation; git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4930 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/classeditor/classeditor.cpp')
-rw-r--r--src/modules/classeditor/classeditor.cpp1661
1 files changed, 891 insertions, 770 deletions
diff --git a/src/modules/classeditor/classeditor.cpp b/src/modules/classeditor/classeditor.cpp
index b625afb75..cbaa0ec1a 100644
--- a/src/modules/classeditor/classeditor.cpp
+++ b/src/modules/classeditor/classeditor.cpp
@@ -56,148 +56,170 @@
#include <QMessageBox>
#include <QInputDialog>
#include <QRegExp>
-#include <QTreeWidget>
#include <QMouseEvent>
-#include <QList>
#include <QPainter>
#include <QBrush>
+#include <QStringList>
+#include <QLabel>
extern KviClassEditorWindow * g_pClassEditorWindow;
extern KviModule * g_pClassEditorModule;
-KviClassEditorTreeWidgetItem::KviClassEditorTreeWidgetItem(QTreeWidget * pTreeWidget,Type eType,const QString &szName)
-: QTreeWidgetItem(pTreeWidget), KviHeapObject(), m_eType(eType)
+KviClassEditorTreeWidget::KviClassEditorTreeWidget(QWidget * pParent)
+: QTreeWidget(pParent)
{
- setName(szName);
- m_szInheritsClassName="";
- m_cPos=0;
- m_bInternal=false;
- if(eType==KviClassEditorTreeWidgetItem::Namespace) setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_NAMESPACE))));
- else setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLASS))));
- m_bClassModified=false;
+ setColumnCount (1);
+ setHeaderLabel(__tr2qs_ctx("Class","editor"));
+ setSelectionMode(QAbstractItemView::ExtendedSelection);
+ setSortingEnabled(true);
+ setRootIsDecorated(true);
+ setAnimated(true);
}
-KviClassEditorTreeWidgetItem::KviClassEditorTreeWidgetItem(KviClassEditorTreeWidgetItem * pParentItem,Type eType,const QString &szName)
-: QTreeWidgetItem(pParentItem), m_eType(eType)
+KviClassEditorTreeWidget::~KviClassEditorTreeWidget()
{
- setName(szName);
- m_szInheritsClassName="";
- m_bInternal=false;
- m_cPos=0;
- setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
- if(eType==KviClassEditorTreeWidgetItem::Namespace)
- setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_NAMESPACE))));
- else if(eType==KviClassEditorTreeWidgetItem::Class)
- setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLASS))));
- else setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_FUNCTION))));
- m_bClassModified=false;
+ //remove and delete all items
+ clear();
}
-void KviClassEditorTreeWidgetItem::setClassNotBuilt(bool bModified)
+void KviClassEditorTreeWidget::mousePressEvent(QMouseEvent * e)
{
- m_bClassModified=bModified;
- if (bModified)
- setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLASSNOTBUILT))));
- else setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLASS))));
+ if(e->button() == Qt::RightButton)
+ {
+ QTreeWidgetItem * pItem = itemAt(e->pos());
+ if(pItem)
+ emit rightButtonPressed(pItem,QCursor::pos());
+ }
+ QTreeWidget::mousePressEvent(e);
}
-void KviClassEditorTreeWidgetItem::setName(const QString & szName)
+KviClassEditorTreeWidgetItem::KviClassEditorTreeWidgetItem(QTreeWidget * pTreeWidget, Type eType, const QString & szName)
+: QTreeWidgetItem(pTreeWidget), KviHeapObject(), m_eType(eType)
{
- m_szName = szName;
- setText(0,m_szName);
+ setName(szName);
+ m_szInheritsClassName = "";
+ m_iPos = 0;
+ m_bInternal = false;
+ m_bClassModified = false;
+ QPixmap * pIcon = 0;
+
+ if(eType == KviClassEditorTreeWidgetItem::Namespace)
+ pIcon = g_pIconManager->getSmallIcon(KVI_SMALLICON_NAMESPACE);
+ else
+ pIcon = g_pIconManager->getSmallIcon(KVI_SMALLICON_CLASS);
+
+ setIcon(0,QIcon(*pIcon));
}
-void KviClassEditorTreeWidgetItem::setType(Type t)
+KviClassEditorTreeWidgetItem::KviClassEditorTreeWidgetItem(KviClassEditorTreeWidgetItem * pParentItem, Type eType, const QString & szName)
+: QTreeWidgetItem(pParentItem), m_eType(eType)
{
- m_eType=t;
- if(t==KviClassEditorTreeWidgetItem::Namespace)
- setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_NAMESPACE))));
- else if(t==KviClassEditorTreeWidgetItem::Class)
- setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLASS))));
- else setIcon(0,QIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_FUNCTION))));
+ setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
+ setName(szName);
+ m_szInheritsClassName = "";
+ m_bInternal = false;
+ m_iPos = 0;
+ m_bClassModified = false;
+ QPixmap * pIcon = 0;
+
+ if(eType == KviClassEditorTreeWidgetItem::Namespace)
+ pIcon = g_pIconManager->getSmallIcon(KVI_SMALLICON_NAMESPACE);
+ else if(eType == KviClassEditorTreeWidgetItem::Class)
+ pIcon = g_pIconManager->getSmallIcon(KVI_SMALLICON_CLASS);
+ else
+ pIcon = g_pIconManager->getSmallIcon(KVI_SMALLICON_FUNCTION);
+
+ setIcon(0,QIcon(*pIcon));
}
-KviClassEditorTreeWidget::KviClassEditorTreeWidget(QWidget * par)
-: QTreeWidget(par)
+void KviClassEditorTreeWidgetItem::setClassNotBuilt(bool bModified)
{
- setColumnCount (1);
- setHeaderLabel(__tr2qs_ctx("Class","editor"));
- setSelectionMode(QAbstractItemView::ExtendedSelection);
- setSortingEnabled(true);
- setRootIsDecorated(true);
- setAnimated(true);
+ m_bClassModified = bModified;
+ QPixmap * pIcon = 0;
+
+ if(bModified)
+ pIcon = g_pIconManager->getSmallIcon(KVI_SMALLICON_CLASSNOTBUILT);
+ else
+ pIcon = g_pIconManager->getSmallIcon(KVI_SMALLICON_CLASS);
+
+ setIcon(0,QIcon(*pIcon));
}
-KviClassEditorTreeWidget::~KviClassEditorTreeWidget()
+void KviClassEditorTreeWidgetItem::setName(const QString & szName)
{
- //remove and delete all items
- clear();
+ m_szName = szName;
+ setText(0,m_szName);
}
-void KviClassEditorTreeWidget::mousePressEvent (QMouseEvent * e)
+void KviClassEditorTreeWidgetItem::setType(Type eType)
{
- if (e->button() == Qt::RightButton)
- {
- QTreeWidgetItem *i=itemAt(e->pos());
- if (i) emit rightButtonPressed(i,QCursor::pos());
- }
- QTreeWidget::mousePressEvent(e);
+ m_eType = eType;
+ QPixmap * pIcon = 0;
+
+ if(eType == KviClassEditorTreeWidgetItem::Namespace)
+ pIcon = g_pIconManager->getSmallIcon(KVI_SMALLICON_NAMESPACE);
+ else if(eType == KviClassEditorTreeWidgetItem::Class)
+ pIcon = g_pIconManager->getSmallIcon(KVI_SMALLICON_CLASS);
+ else
+ pIcon = g_pIconManager->getSmallIcon(KVI_SMALLICON_FUNCTION);
+
+ setIcon(0,QIcon(*pIcon));
}
-KviClassEditor::KviClassEditor(QWidget * par)
-: QWidget(par)
+
+KviClassEditor::KviClassEditor(QWidget * pParent)
+: QWidget(pParent)
{
- m_pClasses=new KviPointerHashTable<QString,KviClassEditorTreeWidgetItem>(100,false);
+ m_pClasses = new KviPointerHashTable<QString,KviClassEditorTreeWidgetItem>(100,false);
m_pClasses->setAutoDelete(false);
// m_bSaving = false;
m_pLastEditedItem = 0;
m_pLastClickedItem = 0;
m_szDir = QDir::homePath();
- QGridLayout * l = new QGridLayout(this);
+ QGridLayout * pLayout = new QGridLayout(this);
m_pSplitter = new QSplitter(Qt::Horizontal,this);
m_pSplitter->setChildrenCollapsible(false);
- l->addWidget(m_pSplitter,0,0);
+ pLayout->addWidget(m_pSplitter,0,0);
- KviTalVBox * box = new KviTalVBox(m_pSplitter);
- box->setSpacing(0);
- box->setMargin(0);
- m_pTreeWidget = new KviClassEditorTreeWidget(box);
+ KviTalVBox * pVBox = new KviTalVBox(m_pSplitter);
+ pVBox->setSpacing(0);
+ pVBox->setMargin(0);
+ m_pTreeWidget = new KviClassEditorTreeWidget(pVBox);
- box = new KviTalVBox(m_pSplitter);
+ pVBox = new KviTalVBox(m_pSplitter);
- KviTalHBox * hbox = new KviTalHBox(box);
- hbox->setSpacing(0);
- hbox->setMargin(0);
- m_pClassNameLabel = new QLabel(__tr2qs_ctx("No item selected","editor"),hbox);
+ KviTalHBox * pHBox = new KviTalHBox(pVBox);
+ pHBox->setSpacing(0);
+ pHBox->setMargin(0);
+ pHBox->setStretchFactor(m_pClassNameLabel,2);
+ m_pClassNameLabel = new QLabel(__tr2qs_ctx("No item selected","editor"),pHBox);
m_pClassNameLabel->setWordWrap(true);
- m_pClassNameRenameButton = new QPushButton(__tr2qs_ctx("Rename","editor"),hbox);
+ m_pClassNameRenameButton = new QPushButton(__tr2qs_ctx("Rename","editor"),pHBox);
+ m_pClassNameRenameButton->setToolTip(__tr2qs_ctx("Edit the class or namespace name","editor"));
m_pClassNameRenameButton->setEnabled(false);
connect(m_pClassNameRenameButton,SIGNAL(clicked()),this,SLOT(renameItem()));
- hbox->setStretchFactor(m_pClassNameLabel,2);
- m_pClassNameRenameButton->setToolTip(__tr2qs_ctx("Edit the class or namespace name","editor"));
- hbox = new KviTalHBox(box);
- hbox->setSpacing(0);
- hbox->setMargin(0);
+ pHBox = new KviTalHBox(pVBox);
+ pHBox->setSpacing(0);
+ pHBox->setMargin(0);
+ pHBox = new KviTalHBox(pVBox);
+ pHBox->setSpacing(0);
+ pHBox->setMargin(0);
+ pHBox->setStretchFactor(m_pFunctionNameLabel,2);
+ m_pFunctionNameLabel = new QLabel(__tr2qs_ctx("No item selected","editor"),pHBox);
+ m_pFunctionNameRenameButton = new QPushButton(__tr2qs_ctx("Rename","editor"),pHBox);
+ m_pFunctionNameRenameButton->setToolTip(__tr2qs_ctx("Edit the function member name","editor"));
+ m_pFunctionNameRenameButton->setEnabled(false);
+ connect(m_pFunctionNameRenameButton,SIGNAL(clicked()),this,SLOT(renameFunction()));
- hbox = new KviTalHBox(box);
- hbox->setSpacing(0);
- hbox->setMargin(0);
- m_pFunctionNameLabel = new QLabel(__tr2qs_ctx("No item selected","editor"),hbox);
- m_pFunctionNameRenameButton = new QPushButton(__tr2qs_ctx("Rename","editor"),hbox);
- m_pFunctionNameRenameButton->setEnabled(false);
- connect(m_pFunctionNameRenameButton,SIGNAL(clicked()),this,SLOT(renameFunction()));
- hbox->setStretchFactor(m_pFunctionNameLabel,2);
- m_pFunctionNameRenameButton->setToolTip(__tr2qs_ctx("Edit the function member name","editor"));
+ m_pReminderLabel = new QLabel(__tr2qs_ctx("No item selected","editor"),pVBox);
+ m_pReminderLabel->hide();
+ m_pReminderLabel->setWordWrap(1);
- m_pReminderLabel = new QLabel(__tr2qs_ctx("No item selected","editor"),box);
- m_pReminderLabel->hide();
- m_pReminderLabel->setWordWrap(1);
- m_pEditor = KviScriptEditor::createInstance(box);
+ m_pEditor = KviScriptEditor::createInstance(pVBox);
m_pEditor->setFocus();
-
connect(m_pEditor,SIGNAL(find(const QString &)),this,SLOT(slotFindWord(const QString &)));
connect(m_pEditor,SIGNAL(replaceAll(const QString &,const QString &)),this,SLOT(slotReplaceAll(const QString &,const QString &)));
m_pContextPopup = new KviTalPopupMenu(this);
@@ -206,165 +228,186 @@ KviClassEditor::KviClassEditor(QWidget * par)
currentItemChanged(0,0);
}
+
KviClassEditor::~KviClassEditor()
{
m_pClasses->clear();
delete m_pClasses;
}
-void KviClassEditor::buildFullItemPath(KviClassEditorTreeWidgetItem * it, QString & szBuffer)
+void KviClassEditor::buildFullItemPath(KviClassEditorTreeWidgetItem * pItem, QString & szBuffer)
{
- if (!it) return;
- szBuffer.prepend(it->name()+"::");
- it=(KviClassEditorTreeWidgetItem*)it->parent();
- while(it)
+ if(!pItem)
+ return;
+ szBuffer.prepend(pItem->name() + "::");
+ pItem = (KviClassEditorTreeWidgetItem *)pItem->parent();
+ while(pItem)
{
- QString tmp = it->name();
- if(!tmp.isEmpty())
+ QString szTmp = pItem->name();
+ if(!szTmp.isEmpty())
{
szBuffer.prepend("::");
- szBuffer.prepend(tmp);
+ szBuffer.prepend(szTmp);
}
- it = (KviClassEditorTreeWidgetItem*)it->parent();
+ pItem = (KviClassEditorTreeWidgetItem *)pItem->parent();
}
}
-QString KviClassEditor::buildFullClassName(KviClassEditorTreeWidgetItem * it)
+QString KviClassEditor::buildFullClassName(KviClassEditorTreeWidgetItem * pItem)
{
- if(!it) return QString();
- QString szName = it->name();
- KviClassEditorTreeWidgetItem * nit =(KviClassEditorTreeWidgetItem *)it->parent();
- while(nit)
+ if(!pItem)
+ return QString();
+ QString szName = pItem->name();
+ KviClassEditorTreeWidgetItem * pNItem = (KviClassEditorTreeWidgetItem *)pItem->parent();
+ while(pNItem)
{
- QString tmp = nit->name();
- if(!tmp.isEmpty())
+ QString szTmp = pNItem->name();
+ if(!szTmp.isEmpty())
{
szName.prepend("::");
- szName.prepend(tmp);
+ szName.prepend(szTmp);
}
- nit = (KviClassEditorTreeWidgetItem *)nit->parent();
+ pNItem = (KviClassEditorTreeWidgetItem *)pNItem->parent();
}
return szName;
}
KviClassEditorTreeWidgetItem * KviClassEditor::findTopLevelItem(const QString & szName)
{
- for(int i=0;i<m_pTreeWidget->topLevelItemCount();i++)
+ for(int i=0; i < m_pTreeWidget->topLevelItemCount(); i++)
{
- if (KviQString::equalCI(m_pTreeWidget->topLevelItem(i)->text(0),szName))
- return (KviClassEditorTreeWidgetItem*)m_pTreeWidget->topLevelItem(i);
+ if(KviQString::equalCI(m_pTreeWidget->topLevelItem(i)->text(0),szName))
+ return (KviClassEditorTreeWidgetItem *)m_pTreeWidget->topLevelItem(i);
}
return 0;
}
KviClassEditorTreeWidgetItem * KviClassEditor::findItem(const QString & szFullName)
{
- QStringList lNamespaces=szFullName.split("::");
- if(!lNamespaces.count()) return 0;
- KviClassEditorTreeWidgetItem *pItem=findTopLevelItem(lNamespaces.at(0));
- if (!pItem) return 0;
bool bFound;
- for(int i=1;i<lNamespaces.count();i++)
+ QStringList lNamespaces = szFullName.split("::");
+ if(lNamespaces.count() == 0)
+ return 0;
+ KviClassEditorTreeWidgetItem * pItem = findTopLevelItem(lNamespaces.at(0));
+ if(!pItem)
+ return 0;
+
+ for(int i=1; i < lNamespaces.count(); i++)
{
- bFound=false;
- for(int j=0;j<pItem->childCount();j++)
+ bFound = false;
+ for(int j=0; j < pItem->childCount(); j++)
{
if (KviQString::equalCI(pItem->child(j)->text(0),lNamespaces.at(i)))
{
pItem=( KviClassEditorTreeWidgetItem *)pItem->child(j);
- bFound=true;
+ bFound = true;
break;
}
}
- if (!bFound) return 0;
+ if(!bFound)
+ return 0;
}
- return (KviClassEditorTreeWidgetItem *)pItem;
+ return (KviClassEditorTreeWidgetItem *)pItem;
}
KviClassEditorTreeWidgetItem * KviClassEditor::createFullItem(const QString & szFullName)
{
- QStringList lNamespaces=szFullName.split("::");
- if(!lNamespaces.count()) return 0;
- if (lNamespaces.count()==1)
+ bool bFound;
+ int i;
+
+ QStringList lNamespaces = szFullName.split("::");
+ if(lNamespaces.count() == 0)
+ return 0;
+ if(lNamespaces.count() == 1)
{
- KviClassEditorTreeWidgetItem *pItem=findTopLevelItem(lNamespaces.at(0));
- if(pItem) return pItem;
+ KviClassEditorTreeWidgetItem * pItem = findTopLevelItem(lNamespaces.at(0));
+ if(pItem)
+ return pItem;
return new KviClassEditorTreeWidgetItem(m_pTreeWidget,KviClassEditorTreeWidgetItem::Class,lNamespaces.at(0));
}
- KviClassEditorTreeWidgetItem *pItem=findTopLevelItem(lNamespaces.at(0));
- if (!pItem) pItem=new KviClassEditorTreeWidgetItem(m_pTreeWidget,KviClassEditorTreeWidgetItem::Namespace,lNamespaces.at(0));
- bool bFound;
- int i;
- for(i=1;i<lNamespaces.count()-1;i++)
+ KviClassEditorTreeWidgetItem * pItem = findTopLevelItem(lNamespaces.at(0));
+ if(!pItem)
+ pItem = new KviClassEditorTreeWidgetItem(m_pTreeWidget,KviClassEditorTreeWidgetItem::Namespace,lNamespaces.at(0));
+
+ for(i=1; i < lNamespaces.count()-1; i++)
{
- bFound=false;
- for(int j=0;j<pItem->childCount();j++)
+ bFound = false;
+ for(int j=0; j < pItem->childCount();j++)
{
- if (KviQString::equalCI(pItem->child(j)->text(0),lNamespaces.at(i)))
+ if(KviQString::equalCI(pItem->child(j)->text(0),lNamespaces.at(i)))
{
- pItem=( KviClassEditorTreeWidgetItem *)pItem->child(j);
- bFound=true;
+ pItem = (KviClassEditorTreeWidgetItem *)pItem->child(j);
+ bFound = true;
break;
}
}
- if (!bFound)
- pItem=new KviClassEditorTreeWidgetItem(pItem,KviClassEditorTreeWidgetItem::Namespace,lNamespaces.at(i));
+ if(!bFound)
+ pItem = new KviClassEditorTreeWidgetItem(pItem,KviClassEditorTreeWidgetItem::Namespace,lNamespaces.at(i));
}
return new KviClassEditorTreeWidgetItem(pItem,KviClassEditorTreeWidgetItem::Class,lNamespaces.at(i));
}
KviClassEditorTreeWidgetItem * KviClassEditor::createFullNamespace(const QString & szFullName)
{
- QStringList lNamespaces=szFullName.split("::");
- if(!lNamespaces.count()) return 0;
- KviClassEditorTreeWidgetItem *pItem=findTopLevelItem(lNamespaces.at(0));
- if (!pItem) pItem=new KviClassEditorTreeWidgetItem(m_pTreeWidget,KviClassEditorTreeWidgetItem::Namespace,lNamespaces.at(0));
- if (lNamespaces.count()==1) return pItem;
bool bFound;
int i;
- for(i=1;i<lNamespaces.count();i++)
+
+ QStringList lNamespaces = szFullName.split("::");
+ if(lNamespaces.count() == 0)
+ return 0;
+ KviClassEditorTreeWidgetItem * pItem = findTopLevelItem(lNamespaces.at(0));
+ if(!pItem)
+ pItem = new KviClassEditorTreeWidgetItem(m_pTreeWidget,KviClassEditorTreeWidgetItem::Namespace,lNamespaces.at(0));
+ if(lNamespaces.count() == 1)
+ return pItem;
+
+ for(i=1; i < lNamespaces.count(); i++)
{
- bFound=false;
+ bFound = false;
for(int j=0;j<pItem->childCount();j++)
{
- if (KviQString::equalCI(pItem->child(j)->text(0),lNamespaces.at(i)) && (( KviClassEditorTreeWidgetItem *)pItem->child(j))->isNamespace())
+ if(KviQString::equalCI(pItem->child(j)->text(0),lNamespaces.at(i)) && (( KviClassEditorTreeWidgetItem *)pItem->child(j))->isNamespace())
{
- pItem=( KviClassEditorTreeWidgetItem *)pItem->child(j);
- bFound=true;
+ pItem = (KviClassEditorTreeWidgetItem *)pItem->child(j);
+ bFound = true;
break;
}
}
- if (!bFound)
- pItem=new KviClassEditorTreeWidgetItem(pItem,KviClassEditorTreeWidgetItem::Namespace,lNamespaces.at(i));
+ if(!bFound)
+ pItem = new KviClassEditorTreeWidgetItem(pItem,KviClassEditorTreeWidgetItem::Namespace,lNamespaces.at(i));
}
return pItem;
}
void KviClassEditor::oneTimeSetup()
{
+ QStringList sl;
+ QString szClassName;
QString szPath;
g_pApp->getLocalKvircDirectory(szPath,KviApp::Classes);
QDir d(szPath);
- QStringList sl;
- QString extension = QString("*%1").arg(KVI_FILEEXTENSION_SCRIPT); // *.kvs
- sl = d.entryList(QStringList(extension), QDir::Files | QDir::NoDotAndDotDot);
- KviKvsObjectClass *pClass;
- KviClassEditorTreeWidgetItem *pClassItem;
+
+ QString szExtension = QString("*%1").arg(KVI_FILEEXTENSION_SCRIPT); // *.kvs
+ sl = d.entryList(QStringList(szExtension), QDir::Files | QDir::NoDotAndDotDot);
+
g_pModuleManager->getModule("objects");
KviPointerHashTableIterator<QString,KviKvsObjectClass> it(*KviKvsKernel::instance()->objectController()->classDict());
- QString szClassName;
- while(KviKvsObjectClass * pClass=it.current())
+
+ KviKvsObjectClass * pClass = 0;
+ KviClassEditorTreeWidgetItem * pClassItem = 0;
+ while(KviKvsObjectClass * pClass = it.current())
{
- if (pClass->isBuiltin())m_pClasses->insert(it.currentKey(),0);
+ if(pClass->isBuiltin())
+ m_pClasses->insert(it.currentKey(),0);
else
{
QString szTmp;
- szTmp=it.currentKey();
+ szTmp = it.currentKey();
szTmp.replace("::","--");
szTmp.append(".kvs");
- if (sl.indexOf(szTmp)==-1)
+ if(sl.indexOf(szTmp) == -1)
{
- szClassName=it.currentKey();
+ szClassName = it.currentKey();
pClassItem = createFullItem(szClassName);
createFullClass(it.current(),pClassItem,szClassName);
}
@@ -372,44 +415,47 @@ void KviClassEditor::oneTimeSetup()
++it;
}
- for(int i=0;i<sl.count();i++)
+ for(int i=0; i < sl.count(); i++)
{
- szClassName=sl.at(i);
+ szClassName = sl.at(i);
szClassName.replace("--","::");
szClassName.chop(4);
pClassItem = createFullItem(szClassName);
pClass = KviKvsKernel::instance()->objectController()->lookupClass(szClassName);
- if (pClass) createFullClass(pClass, pClassItem, szClassName);
+ if(pClass)
+ createFullClass(pClass, pClassItem, szClassName);
}
loadNotBuiltClasses();
connect(m_pTreeWidget,SIGNAL(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)),this,SLOT(currentItemChanged(QTreeWidgetItem *,QTreeWidgetItem *)));
m_pTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_pTreeWidget,SIGNAL(customContextMenuRequested(const QPoint &)),this,SLOT(customContextMenuRequested(const QPoint &)));
}
-void KviClassEditor::createFullClass(KviKvsObjectClass *pClass, KviClassEditorTreeWidgetItem *pClassItem, const QString &szClassName)
+
+void KviClassEditor::createFullClass(KviKvsObjectClass * pClass, KviClassEditorTreeWidgetItem * pClassItem, const QString & szClassName)
{
- KviPointerHashTableIterator<QString,KviKvsObjectFunctionHandler> it(* pClass->getHandlers());
- KviClassEditorTreeWidgetItem *pFunctionItem;
+ KviPointerHashTableIterator<QString,KviKvsObjectFunctionHandler> it(* pClass->getHandlers());
+ KviClassEditorTreeWidgetItem * pFunctionItem = 0;
m_pClasses->insert(szClassName,pClassItem);
- KviKvsObjectClass *pParentClass=pClass->parentClass();
+ KviKvsObjectClass * pParentClass = pClass->parentClass();
pClassItem->setInheritsClass(pParentClass->name());
while(it.current())
{
QString szCode;
- KviKvsObjectFunctionHandler *handler=pClass->lookupFunctionHandler(it.currentKey());
+ KviKvsObjectFunctionHandler * pHandler = pClass->lookupFunctionHandler(it.currentKey());
- if (pClass->isScriptHandler(it.currentKey()) && !handler->isClone())
+ if(pClass->isScriptHandler(it.currentKey()) && !pHandler->isClone())
{
- pFunctionItem=findFunction(it.currentKey(), pClassItem);
- if(!pFunctionItem) pFunctionItem = new KviClassEditorTreeWidgetItem(pClassItem,KviClassEditorTreeWidgetItem::Method,it.currentKey());
- pClass->getFunctionCode(szCode,*handler);
+ pFunctionItem = findFunction(it.currentKey(), pClassItem);
+ if(!pFunctionItem)
+ pFunctionItem = new KviClassEditorTreeWidgetItem(pClassItem,KviClassEditorTreeWidgetItem::Method,it.currentKey());
+ pClass->getFunctionCode(szCode,*pHandler);
pFunctionItem->setBuffer(szCode);
- pFunctionItem->setReminder(pClass->reminder(handler));
- if(handler->flags() & KviKvsObjectFunctionHandler::Internal) pFunctionItem->setInternalFunction(true);
+ pFunctionItem->setReminder(pClass->reminder(pHandler));
+ if(pHandler->flags() & KviKvsObjectFunctionHandler::Internal)
+ pFunctionItem->setInternalFunction(true);
}
++it;
}
-
}
@@ -435,8 +481,6 @@ void KviClassEditor::classRefresh(const QString & szName)
item->setBuffer(class->code());
m_pEditor->setText(class->code());
}
-
-
*/
bool KviClassEditor::hasSelectedItems()
@@ -452,41 +496,45 @@ bool KviClassEditor::classExists(QString & szFullItemName)
void KviClassEditor::renameFunction()
{
- if(!m_pLastEditedItem)return;
- KviClassEditorTreeWidgetItem *pFunction=m_pLastEditedItem;
- QString szClassName = buildFullClassName((KviClassEditorTreeWidgetItem*)pFunction->parent());
+ if(!m_pLastEditedItem)
+ return;
+ KviClassEditorTreeWidgetItem * pFunction = m_pLastEditedItem;
+ QString szClassName = buildFullClassName((KviClassEditorTreeWidgetItem *)pFunction->parent());
QString szFunctionName = pFunction->name();
- QString szReminder = pFunction->reminder();
- QString szNewReminder=szReminder;
- KviClassEditorTreeWidgetItem *pParentClass = (KviClassEditorTreeWidgetItem*) pFunction->parent();
+ QString szReminder = pFunction->reminder();
+ QString szNewReminder = szReminder;
+ KviClassEditorTreeWidgetItem * pParentClass = (KviClassEditorTreeWidgetItem *) pFunction->parent();
QString szNewFunctionName = szFunctionName;
- bool bInternal=pFunction->isInternalFunction();
- if(!askForFunction(szNewFunctionName,szNewReminder,&bInternal,szClassName, true)) return;
- if(KviQString::equalCI(szFunctionName,szNewFunctionName) && bInternal==pFunction->isInternalFunction())
- {
- if(!KviQString::equalCI(szNewReminder,szReminder))
- {
- pFunction->setReminder(szNewReminder);
- KviKvsObjectClass *pClass = KviKvsKernel::instance()->objectController()->lookupClass(szClassName);
- if (pClass){
- KviKvsObjectFunctionHandler *pHandler=pClass->lookupFunctionHandler(szFunctionName);
- if (pHandler){
- pClass->setReminder(szNewReminder,pHandler);
- QString szPath;
- QString szFileName = szClassName.toLower();
- szFileName += ".kvs";
- szFileName.replace("::","--");
- g_pApp->getLocalKvircDirectory(szPath,KviApp::Classes,szFileName);
- pClass->save(szPath);
- }
- }
- currentItemChanged(pFunction,pFunction);
+ bool bInternal = pFunction->isInternalFunction();
+ if(!askForFunction(szNewFunctionName,szNewReminder,&bInternal,szClassName,true))
+ return;
+ if(KviQString::equalCS(szFunctionName,szNewFunctionName) && bInternal == pFunction->isInternalFunction())
+ {
+ if(!KviQString::equalCS(szNewReminder,szReminder))
+ {
+ pFunction->setReminder(szNewReminder);
+ KviKvsObjectClass * pClass = KviKvsKernel::instance()->objectController()->lookupClass(szClassName);
+ if(pClass)
+ {
+ KviKvsObjectFunctionHandler * pHandler = pClass->lookupFunctionHandler(szFunctionName);
+ if(pHandler)
+ {
+ pClass->setReminder(szNewReminder,pHandler);
+ QString szPath;
+ QString szFileName = szClassName.toLower();
+ szFileName += ".kvs";
+ szFileName.replace("::","--");
+ g_pApp->getLocalKvircDirectory(szPath,KviApp::Classes,szFileName);
+ pClass->save(szPath);
+ }
+ }
+ currentItemChanged(pFunction,pFunction);
- }
- return;
- }
- if (findFunction(szNewFunctionName,pParentClass) && !KviQString::equalCI(szFunctionName,szNewFunctionName))
+ }
+ return;
+ }
+ if(findFunction(szNewFunctionName,pParentClass) && !KviQString::equalCS(szFunctionName,szNewFunctionName))
{
g_pClassEditorModule->lock();
QMessageBox::information(this,
@@ -497,51 +545,58 @@ void KviClassEditor::renameFunction()
return;
}
pFunction->setName(szNewFunctionName);
- pFunction->setReminder(szNewReminder);
- currentItemChanged(pFunction,pFunction);
+ pFunction->setReminder(szNewReminder);
+ currentItemChanged(pFunction,pFunction);
pFunction->setInternalFunction(bInternal);
pParentClass->setClassNotBuilt(true);
+
KviPointerList<KviClassEditorTreeWidgetItem> lInheritedClasses;
lInheritedClasses.setAutoDelete(false);
searchInheritedClasses(szClassName,lInheritedClasses);
- for(unsigned int i=0;i<lInheritedClasses.count();i++)
+ for(unsigned int i=0; i < lInheritedClasses.count(); i++)
lInheritedClasses.at(i)->setClassNotBuilt(true);
activateItem(pFunction);
}
-KviClassEditorTreeWidgetItem * KviClassEditor::findFunction(const QString &szFunctionName, KviClassEditorTreeWidgetItem *pClass)
+KviClassEditorTreeWidgetItem * KviClassEditor::findFunction(const QString & szFunctionName, KviClassEditorTreeWidgetItem * pClass)
{
- for(int i=0;i<pClass->childCount();i++)
+ for(int i=0; i < pClass->childCount(); i++)
{
if(KviQString::equalCI(szFunctionName,((KviClassEditorTreeWidgetItem *)pClass->child(i))->name()))
- return (KviClassEditorTreeWidgetItem*) pClass->child(i);
+ return (KviClassEditorTreeWidgetItem *) pClass->child(i);
}
return 0;
}
void KviClassEditor::renameItem()
{
- if(!m_pLastEditedItem)return;
- if(m_pLastEditedItem->isClass()) renameClass(m_pLastEditedItem);
- else if(m_pLastEditedItem->isNamespace()) renameNamespace(m_pLastEditedItem);
+ if(!m_pLastEditedItem)
+ return;
+ if(m_pLastEditedItem->isClass())
+ renameClass(m_pLastEditedItem);
+ else if(m_pLastEditedItem->isNamespace())
+ renameNamespace(m_pLastEditedItem);
else {
// is function
- KviClassEditorTreeWidgetItem *pParent = (KviClassEditorTreeWidgetItem*)m_pLastEditedItem->parent();
- if(pParent->isClass()) renameClass(pParent);
+ KviClassEditorTreeWidgetItem * pParent = (KviClassEditorTreeWidgetItem *)m_pLastEditedItem->parent();
+ if(pParent->isClass())
+ renameClass(pParent);
}
}
-void KviClassEditor::renameClass(KviClassEditorTreeWidgetItem *pClassItem)
+void KviClassEditor::renameClass(KviClassEditorTreeWidgetItem * pClassItem)
{
QString szClassName = buildFullClassName(pClassItem);
QString szNewClassName = szClassName;
- QString szInheritsClassName = pClassItem->InheritsClass();
+ QString szInheritsClassName = pClassItem->inheritsClass();
QString szNewInheritsClassName = szInheritsClassName;
- bool bOk=askForClassName(szNewClassName,szNewInheritsClassName,true);
- if (!bOk) return;
- if (KviQString::equalCI(szClassName,szNewClassName) && KviQString::equalCI(szInheritsClassName,szNewInheritsClassName)) return;
- if (classExists(szNewClassName) && KviQString::equalCI(szInheritsClassName,szNewInheritsClassName))
+ bool bOk = askForClassName(szNewClassName,szNewInheritsClassName,true);
+ if(!bOk)
+ return;
+ if(KviQString::equalCS(szClassName,szNewClassName) && KviQString::equalCS(szInheritsClassName,szNewInheritsClassName))
+ return;
+ if(classExists(szNewClassName) && KviQString::equalCS(szInheritsClassName,szNewInheritsClassName))
{
g_pClassEditorModule->lock();
QMessageBox::information(this,
@@ -562,12 +617,12 @@ void KviClassEditor::renameClass(KviClassEditorTreeWidgetItem *pClassItem)
szNewName = "";
continue;
}*/
- KviClassEditorTreeWidgetItem *pNewItem=0;
+ KviClassEditorTreeWidgetItem * pNewItem = 0;
m_pClasses->removeRef(pClassItem);
cutItem(pClassItem);
if(szNewClassName.contains("::"))
{
- pNewItem=createFullNamespace(szNewClassName.left(szNewClassName.lastIndexOf("::")));
+ pNewItem = createFullNamespace(szNewClassName.left(szNewClassName.lastIndexOf("::")));
pClassItem->setName(szNewClassName.section("::",-1,-1));
pNewItem->addChild(pClassItem);
} else {
@@ -577,16 +632,18 @@ void KviClassEditor::renameClass(KviClassEditorTreeWidgetItem *pClassItem)
m_pClasses->insert(szNewClassName,pClassItem);
pClassItem->setInheritsClass(szNewInheritsClassName);
pClassItem->setClassNotBuilt(true);
+
KviPointerList<KviClassEditorTreeWidgetItem> lInheritedClasses;
lInheritedClasses.setAutoDelete(false);
searchInheritedClasses(szClassName,lInheritedClasses);
- for(unsigned int i=0;i<lInheritedClasses.count();i++)
+ for(unsigned int i=0; i < lInheritedClasses.count(); i++)
{
lInheritedClasses.at(i)->setClassNotBuilt(true);
lInheritedClasses.at(i)->setExpanded(true);
lInheritedClasses.at(i)->setInheritsClass(szNewClassName);
}
- if (pNewItem)
+
+ if(pNewItem)
{
activateItem(pNewItem);
pNewItem->setExpanded(true);
@@ -594,42 +651,43 @@ void KviClassEditor::renameClass(KviClassEditorTreeWidgetItem *pClassItem)
activateItem(pClassItem);
pClassItem->setExpanded(true);
}
- qDebug("causa rename deleto classe %s",szClassName.toUtf8().data());
- KviKvsObjectClass *pClass = KviKvsKernel::instance()->objectController()->lookupClass(szClassName);
- if (pClass) KviKvsKernel::instance()->objectController()->deleteClass(pClass);
+
+ qDebug("delete class %s caused by rename",szClassName.toUtf8().data());
+ KviKvsObjectClass * pClass = KviKvsKernel::instance()->objectController()->lookupClass(szClassName);
+ if(pClass)
+ KviKvsKernel::instance()->objectController()->deleteClass(pClass);
}
-void KviClassEditor::cutItem(KviClassEditorTreeWidgetItem *pItem)
+void KviClassEditor::cutItem(KviClassEditorTreeWidgetItem * pItem)
{
- int iIdx=m_pTreeWidget->indexOfTopLevelItem(pItem);
- if (iIdx!=-1)
- {
+ int iIdx = m_pTreeWidget->indexOfTopLevelItem(pItem);
+ if(iIdx!=-1)
m_pTreeWidget->takeTopLevelItem(iIdx);
- } else {
- KviClassEditorTreeWidgetItem *pParent = (KviClassEditorTreeWidgetItem*)pItem->parent();
+ else {
+ KviClassEditorTreeWidgetItem * pParent = (KviClassEditorTreeWidgetItem *)pItem->parent();
pParent->removeChild(pItem);
}
}
-void KviClassEditor::renameNamespace(KviClassEditorTreeWidgetItem *pOldNamespaceItem)
+void KviClassEditor::renameNamespace(KviClassEditorTreeWidgetItem * pOldNamespaceItem)
{
QString szOldNameSpaceName = buildFullClassName(m_pLastEditedItem);
QString szNewNameSpaceName;
- if (!askForNamespaceName(__tr2qs_ctx("Rename Namespace","editor"),__tr2qs_ctx("Please enter the new name for the namespace","editor"),szOldNameSpaceName,szNewNameSpaceName)) return;
- if (KviQString::equalCI(szOldNameSpaceName,szNewNameSpaceName)) return;
- KviClassEditorTreeWidgetItem *pNewItem=findItem(szNewNameSpaceName);
- if (pNewItem)
+ if(!askForNamespaceName(__tr2qs_ctx("Rename Namespace","editor"),__tr2qs_ctx("Please enter the new name for the namespace","editor"),szOldNameSpaceName,szNewNameSpaceName))
+ return;
+ if(KviQString::equalCI(szOldNameSpaceName,szNewNameSpaceName))
+ return;
+ KviClassEditorTreeWidgetItem * pNewItem = findItem(szNewNameSpaceName);
+ if(pNewItem)
{
g_pClassEditorModule->lock();
- if (pNewItem->isClass())
+ if(pNewItem->isClass())
{
QMessageBox::information(this,
__tr2qs_ctx("Name already exists as Class name","editor"),
__tr2qs_ctx("This name is already in use as Class name. Please choose another one.","editor"),
__tr2qs_ctx("Ok, Let me try again...","editor"));
- }
- else
- {
+ } else {
QMessageBox::information(this,
__tr2qs_ctx("Namespace already exists","editor"),
__tr2qs_ctx("This name is already in use. Please choose another one.","editor"),
@@ -651,43 +709,44 @@ void KviClassEditor::renameNamespace(KviClassEditorTreeWidgetItem *pOldNamespace
m_pTreeWidget->addTopLevelItem(pOldNamespaceItem);
pOldNamespaceItem->setName(szNewNameSpaceName);
}
- for(unsigned int i=0;i<pList.count();i++)
+ for(unsigned int u=0; u < pList.count(); u++)
{
- KviPointerHashTableEntry<QString,KviClassEditorTreeWidgetItem> *entry=m_pClasses->findRef(pList.at(i));
- if (entry)
+ KviPointerHashTableEntry<QString,KviClassEditorTreeWidgetItem> * pEntry = m_pClasses->findRef(pList.at(u));
+ if(pEntry)
{
KviPointerList<KviClassEditorTreeWidgetItem> lInheritedClasses;
lInheritedClasses.setAutoDelete(false);
- QString szOldName = entry->key();
- QString szNewName = buildFullClassName(pList.at(i));
+ QString szOldName = pEntry->key();
+ QString szNewName = buildFullClassName(pList.at(u));
searchInheritedClasses(szOldName,lInheritedClasses);
- for(unsigned int j=0;j<lInheritedClasses.count();j++)
+ for(unsigned int v=0; v < lInheritedClasses.count(); v++)
{
- lInheritedClasses.at(j)->setClassNotBuilt(true);
- lInheritedClasses.at(j)->setExpanded(true);
- lInheritedClasses.at(j)->setInheritsClass(szNewName);
+ lInheritedClasses.at(v)->setClassNotBuilt(true);
+ lInheritedClasses.at(v)->setExpanded(true);
+ lInheritedClasses.at(v)->setInheritsClass(szNewName);
}
- m_pClasses->removeRef(pList.at(i));
- m_pClasses->insert(szNewName,pList.at(i));
- pList.at(i)->setClassNotBuilt(true);
+ m_pClasses->removeRef(pList.at(u));
+ m_pClasses->insert(szNewName,pList.at(u));
+ pList.at(u)->setClassNotBuilt(true);
- KviKvsObjectClass *pClass = KviKvsKernel::instance()->objectController()->lookupClass(szOldName);
- if (pClass) KviKvsKernel::instance()->objectController()->deleteClass(pClass);
+ KviKvsObjectClass * pClass = KviKvsKernel::instance()->objectController()->lookupClass(szOldName);
+ if(pClass)
+ KviKvsKernel::instance()->objectController()->deleteClass(pClass);
}
}
- if (pNewItem)
+ if(pNewItem)
{
- activateItem(pNewItem);
+ activateItem(pNewItem);
pNewItem->setExpanded(true);
} else {
activateItem(pOldNamespaceItem);
pOldNamespaceItem->setExpanded(true);
}
//searchReplace(szOldNameSpaceName+"::",true,szNewNameSpaceName+"::");
-
}
+
void KviClassEditor::saveLastEditedItem()
{
if(!m_pLastEditedItem)
@@ -701,10 +760,10 @@ void KviClassEditor::saveLastEditedItem()
((KviClassEditorTreeWidgetItem *)m_pLastEditedItem->parent())->setClassNotBuilt(true);
}
-void KviClassEditor::currentItemChanged(QTreeWidgetItem * it, QTreeWidgetItem *)
+void KviClassEditor::currentItemChanged(QTreeWidgetItem * pTree, QTreeWidgetItem *)
{
saveLastEditedItem();
- m_pLastEditedItem = (KviClassEditorTreeWidgetItem *)it;
+ m_pLastEditedItem = (KviClassEditorTreeWidgetItem *)pTree;
if(!m_pLastEditedItem)
{
m_pClassNameLabel->setText(__tr2qs_ctx("No item selected","editor"));
@@ -713,10 +772,15 @@ void KviClassEditor::currentItemChanged(QTreeWidgetItem * it, QTreeWidgetItem *)
m_pEditor->setEnabled(false);
return;
}
- KviClassEditorTreeWidgetItem * pClassItem;
- if(m_pLastEditedItem->isMethod()) pClassItem=(KviClassEditorTreeWidgetItem *)m_pLastEditedItem->parent();
- else pClassItem=m_pLastEditedItem;
+
+ KviClassEditorTreeWidgetItem * pClassItem = 0;
+ if(m_pLastEditedItem->isMethod())
+ pClassItem = (KviClassEditorTreeWidgetItem *)m_pLastEditedItem->parent();
+ else
+ pClassItem = m_pLastEditedItem;
+
QString szClassName = buildFullClassName(pClassItem);
+
if(m_pLastEditedItem->isNamespace())
{
QString szLabelText = __tr2qs_ctx("Namespace","editor");
@@ -726,24 +790,25 @@ void KviClassEditor::currentItemChanged(QTreeWidgetItem * it, QTreeWidgetItem *)
m_pClassNameLabel->setText(szLabelText);
m_pClassNameRenameButton->setEnabled(true);
m_pFunctionNameRenameButton->setEnabled(false);
- //m_pInheritsClassNameLabel->setText("");
+ //m_pinheritsClassNameLabel->setText("");
m_pFunctionNameLabel->setText("");
m_pEditor->setText("");
m_pEditor->setEnabled(false);
m_pTreeWidget->setFocus();
return;
}
+
QString szLabelText = __tr2qs_ctx("Class","editor");
szLabelText += ": <b>";
szLabelText += szClassName;
szLabelText += "</b>, ";
szLabelText += __tr2qs_ctx("inherits from class ","editor");
szLabelText += ": <b>";
- szLabelText += pClassItem->InheritsClass();
+ szLabelText += pClassItem->inheritsClass();
szLabelText += "</b>";
m_pClassNameLabel->setText(szLabelText);
- //m_pInheritsClassNameLabel->setText(szLabelText);
+ //m_pinheritsClassNameLabel->setText(szLabelText);
szLabelText = __tr2qs_ctx("Member Function","editor");
if(m_pLastEditedItem->isMethod())
@@ -751,30 +816,30 @@ void KviClassEditor::currentItemChanged(QTreeWidgetItem * it, QTreeWidgetItem *)
szLabelText += ": <b>";
szLabelText += m_pLastEditedItem->text(0);
szLabelText += "</b>";
- m_pFunctionNameRenameButton->setEnabled(true);
- if(!m_pLastEditedItem->reminder().isEmpty())
- {
- QString szReminderText =__tr2qs_ctx("Reminder text.","editor");
- szReminderText += ": <b>";
- szReminderText += m_pLastEditedItem->reminder();
- szReminderText += "</b>";
+ m_pFunctionNameRenameButton->setEnabled(true);
+ if(m_pLastEditedItem->reminder().isEmpty())
+ m_pReminderLabel->hide();
+ else {
+ QString szReminderText =__tr2qs_ctx("Reminder text.","editor");
+ szReminderText += ": <b>";
+ szReminderText += m_pLastEditedItem->reminder();
+ szReminderText += "</b>";
m_pReminderLabel->setText(szReminderText);
- m_pReminderLabel->show();
- }
- else m_pReminderLabel->hide();
- m_pFunctionNameLabel->setText(szLabelText);
- m_pFunctionNameLabel->show();
- m_pFunctionNameRenameButton->show();
- }
- else{
- m_pReminderLabel->hide();
- m_pFunctionNameLabel->hide();
- m_pClassNameRenameButton->setEnabled(true);
- m_pFunctionNameRenameButton->hide();
- }
- if(m_pLastEditedItem->isClass())
+ m_pReminderLabel->show();
+ }
+
+ m_pFunctionNameLabel->setText(szLabelText);
+ m_pFunctionNameLabel->show();
+ m_pFunctionNameRenameButton->show();
+ } else {
+ m_pReminderLabel->hide();
+ m_pFunctionNameLabel->hide();
+ m_pClassNameRenameButton->setEnabled(true);
+ m_pFunctionNameRenameButton->hide();
+ }
+ if(m_pLastEditedItem->isClass())
{
- m_pFunctionNameRenameButton->setEnabled(false);
+ m_pFunctionNameRenameButton->setEnabled(false);
m_pEditor->setText("");
m_pEditor->setEnabled(true);
m_pTreeWidget->setFocus();
@@ -782,27 +847,29 @@ void KviClassEditor::currentItemChanged(QTreeWidgetItem * it, QTreeWidgetItem *)
QStringList szFunctionsList;
KviPointerHashTable<QString,KviClassEditorTreeWidgetItem> lFunctions;
lFunctions.setAutoDelete(false);
- KviClassEditorTreeWidgetItem *pItem;
- for(int i=0;i<it->childCount();i++){
- pItem=((KviClassEditorTreeWidgetItem *)it->child(i));
+
+ KviClassEditorTreeWidgetItem * pItem = 0;
+ for(int i=0; i < pTree->childCount(); i++)
+ {
+ pItem = ((KviClassEditorTreeWidgetItem *)pTree->child(i));
szFunctionsList.append(pItem->name());
lFunctions.insert(pItem->name(),pItem);
}
szFunctionsList.sort();
- for(int i=0;i<szFunctionsList.count();i++)
+ for(int i=0; i < szFunctionsList.count(); i++)
{
- szBuffer+="Member Function: <b>$"+szFunctionsList.at(i)+"</b><br>";
+ szBuffer += "Member Function: <b>$" + szFunctionsList.at(i) + "</b><br>";
if(!lFunctions.find(szFunctionsList.at(i))->reminder().isEmpty())
- szBuffer+="Parameters reminder: "+lFunctions.find(szFunctionsList.at(i))->reminder()+"<br><br>";
+ szBuffer += "Parameters reminder: " + lFunctions.find(szFunctionsList.at(i))->reminder() + "<br><br>";
}
m_pEditor->setUnHighlightedText(szBuffer);
m_pEditor->setReadOnly(true);
return;
}
m_pEditor->setReadOnly(false);
- m_pEditor->setText(((KviClassEditorTreeWidgetItem *)it)->buffer());
+ m_pEditor->setText(((KviClassEditorTreeWidgetItem *)pTree)->buffer());
m_pEditor->setFocus();
- m_pEditor->setCursorPosition(((KviClassEditorTreeWidgetItem *)it)->cursorPosition());
+ m_pEditor->setCursorPosition(((KviClassEditorTreeWidgetItem *)pTree)->cursorPosition());
m_pEditor->setEnabled(true);
}
@@ -812,62 +879,65 @@ void KviClassEditor::customContextMenuRequested(QPoint pnt)
m_pLastClickedItem = (KviClassEditorTreeWidgetItem *)m_pTreeWidget->itemAt(pnt);
- int id;
-
- id = m_pContextPopup->insertItem(
- *(g_pIconManager->getSmallIcon(KVI_SMALLICON_NAMESPACE)),
- __tr2qs_ctx("Add Namespace","editor"),
- this,SLOT(newNamespace()));
- if (!m_pLastClickedItem)m_pContextPopup->setItemEnabled(id,true);
- else m_pContextPopup->setItemEnabled(id,m_pLastClickedItem->isNamespace());
-
- id = m_pContextPopup->insertItem(
- *(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLASS)),
- __tr2qs_ctx("Add Class","editor"),
- this,SLOT(newClass()));
- if (!m_pLastClickedItem)m_pContextPopup->setItemEnabled(id,true);
- else m_pContextPopup->setItemEnabled(id,m_pLastClickedItem->isNamespace());
-
+ int iId;
+ iId = m_pContextPopup->insertItem(
+ *(g_pIconManager->getSmallIcon(KVI_SMALLICON_NAMESPACE)),
+ __tr2qs_ctx("Add Namespace","editor"),
+ this,SLOT(newNamespace()));
+ if(!m_pLastClickedItem)
+ m_pContextPopup->setItemEnabled(iId,true);
+ else
+ m_pContextPopup->setItemEnabled(iId,m_pLastClickedItem->isNamespace());
- id = m_pContextPopup->insertItem(
- *(g_pIconManager->getSmallIcon(KVI_SMALLICON_FUNCTION)),
- __tr2qs_ctx("Add Member Function","editor"),
- this,SLOT(newMemberFunction()));
- if (!m_pLastClickedItem)m_pContextPopup->setItemEnabled(id,false);
- else m_pContextPopup->setItemEnabled(id,m_pLastClickedItem->isClass()| m_pLastClickedItem->isMethod());
+ iId = m_pContextPopup->insertItem(
+ *(g_pIconManager->getSmallIcon(KVI_SMALLICON_CLASS)),
+ __tr2qs_ctx("Add Class","editor"),
+ this,SLOT(newClass()));
+ if(!m_pLastClickedItem)
+ m_pContextPopup->setItemEnabled(iId,true);
+ else
+ m_pContextPopup->setItemEnabled(iId,m_pLastClickedItem->isNamespace());
+ iId = m_pContextPopup->insertItem(
+ *(g_pIconManager->getSmallIcon(KVI_SMALLICON_FUNCTION)),
+ __tr2qs_ctx("Add Member Function","editor"),
+ this,SLOT(newMemberFunction()));
+ if(!m_pLastClickedItem)
+ m_pContextPopup->setItemEnabled(iId,false);
+ else
+ m_pContextPopup->setItemEnabled(iId,m_pLastClickedItem->isClass()| m_pLastClickedItem->isMethod());
bool bHasItems = m_pTreeWidget->topLevelItemCount();
bool bHasSelected = hasSelectedItems();
m_pContextPopup->insertSeparator();
- id = m_pContextPopup->insertItem(
- *(g_pIconManager->getSmallIcon(KVI_SMALLICON_QUIT)),
- __tr2qs_ctx("Remove Selected","editor"),
- this,SLOT(removeSelectedItems()));
- m_pContextPopup->setItemEnabled(id,bHasSelected);
+ iId = m_pContextPopup->insertItem(
+ *(g_pIconManager->getSmallIcon(KVI_SMALLICON_QUIT)),
+ __tr2qs_ctx("Remove Selected","editor"),
+ this,SLOT(removeSelectedItems()));
+ m_pContextPopup->setItemEnabled(iId,bHasSelected);
m_pContextPopup->insertSeparator();
m_pContextPopup->insertItem(
- *(g_pIconManager->getSmallIcon(KVI_SMALLICON_FOLDER)),
- __tr2qs_ctx("Export Selected...","editor"),
- this,SLOT(exportSelected()));
- m_pContextPopup->setItemEnabled(id,bHasSelected);
+ *(g_pIconManager->getSmallIcon(KVI_SMALLICON_FOLDER)),
+ __tr2qs_ctx("Export Selected...","editor"),
+ this,SLOT(exportSelected()));
+ m_pContextPopup->setItemEnabled(iId,bHasSelected);
m_pContextPopup->insertItem(
- *(g_pIconManager->getSmallIcon(KVI_SMALLICON_FOLDER)),
- __tr2qs_ctx("Export Selected in singles files...","editor"),
- this,SLOT(exportSelectedSepFiles()));
+ *(g_pIconManager->getSmallIcon(KVI_SMALLICON_FOLDER)),
+ __tr2qs_ctx("Export Selected in singles files...","editor"),
+ this,SLOT(exportSelectedSepFiles()));
- m_pContextPopup->setItemEnabled(id,bHasSelected);
+ m_pContextPopup->setItemEnabled(iId,bHasSelected);
m_pContextPopup->insertItem(
*(g_pIconManager->getSmallIcon(KVI_SMALLICON_FOLDER)),
__tr2qs_ctx("Export All...","editor"),
this,SLOT(exportAll()));
- m_pContextPopup->setItemEnabled(id,bHasItems);
+ m_pContextPopup->setItemEnabled(iId,bHasItems);
m_pContextPopup->insertSeparator();
@@ -875,38 +945,39 @@ void KviClassEditor::customContextMenuRequested(QPoint pnt)
*(g_pIconManager->getSmallIcon(KVI_SMALLICON_SEARCH)),
__tr2qs_ctx("Find In Classes...","editor"),
this,SLOT(slotFind()));
- m_pContextPopup->setItemEnabled(id,bHasItems);
+ m_pContextPopup->setItemEnabled(iId,bHasItems);
m_pContextPopup->insertItem(
*(g_pIconManager->getSmallIcon(KVI_SMALLICON_NAMESPACE)),
__tr2qs_ctx("Collapse All Items","editor"),
this,SLOT(slotCollapseItems()));
- m_pContextPopup->setItemEnabled(id,bHasItems);
- m_pContextPopup->popup( m_pTreeWidget->mapToGlobal(pnt));
+ m_pContextPopup->setItemEnabled(iId,bHasItems);
+ m_pContextPopup->popup(m_pTreeWidget->mapToGlobal(pnt));
}
-void KviClassEditor::searchReplace(const QString &szSearch,bool bReplace,const QString &szReplace)
+void KviClassEditor::searchReplace(const QString & szSearch, bool bReplace, const QString & szReplace)
{
KviPointerHashTableIterator<QString,KviClassEditorTreeWidgetItem> it (*m_pClasses);
while(it.current())
{
- KviClassEditorTreeWidgetItem *pItem=it.current();
- for(int j=0;j<pItem->childCount();j++)
+ KviClassEditorTreeWidgetItem * pItem = it.current();
+ for(int j=0; j < pItem->childCount(); j++)
{
- bool bOpened=false;
+ bool bOpened = false;
if(((KviClassEditorTreeWidgetItem *)pItem->child(j))->buffer().indexOf(szSearch,0,Qt::CaseInsensitive) != -1)
{
pItem->child(j)->setBackground(0, QColor(255,0,0,128));
- if (bReplace){
+ if(bReplace)
+ {
QString &buffer=(QString &)((KviClassEditorTreeWidgetItem *)pItem->child(j))->buffer();
pItem->setClassNotBuilt(true);
buffer.replace(szSearch,szReplace,Qt::CaseInsensitive);
}
- if (!bOpened)
+ if(!bOpened)
{
openParentItems(pItem->child(j));
- bOpened=true;
+ bOpened = true;
}
} else {
pItem->child(j)->setBackground(0, QColor(255,255,255));
@@ -915,9 +986,9 @@ void KviClassEditor::searchReplace(const QString &szSearch,bool bReplace,const Q
++it;
}
}
+
void KviClassEditor::slotFind()
{
-
g_pClassEditorModule->lock();
bool bOk;
@@ -929,45 +1000,50 @@ void KviClassEditor::slotFind()
&bOk);
g_pClassEditorModule->unlock();
- if(!bOk)return;
- if(szSearch.isEmpty())return;
+ if(!bOk)
+ return;
+ if(szSearch.isEmpty())
+ return;
m_pEditor->setFindText(szSearch);
searchReplace(szSearch);
}
-void KviClassEditor::slotFindWord(const QString &szSearch)
+
+void KviClassEditor::slotFindWord(const QString & szSearch)
{
m_pEditor->setFindText(szSearch);
}
-void KviClassEditor::recursiveCollapseItems(KviClassEditorTreeWidgetItem * it)
+void KviClassEditor::recursiveCollapseItems(KviClassEditorTreeWidgetItem * pItem)
{
- if(!it)return;
- for (int i=0;i<it->childCount();i++)
+ if(!pItem)
+ return;
+ for(int i=0; i < pItem->childCount(); i++)
{
- if(it->child(i)->childCount())
+ if(pItem->child(i)->childCount())
{
- it->child(i)->setExpanded(false);
- recursiveCollapseItems((KviClassEditorTreeWidgetItem *)it->child(i));
+ pItem->child(i)->setExpanded(false);
+ recursiveCollapseItems((KviClassEditorTreeWidgetItem *)pItem->child(i));
}
}
}
void KviClassEditor::slotCollapseItems()
{
- for (int i=0;i<m_pTreeWidget->topLevelItemCount();i++)
+ for(int i=0; i < m_pTreeWidget->topLevelItemCount(); i++)
{
- if (m_pTreeWidget->topLevelItem(i)->childCount()){
+ if(m_pTreeWidget->topLevelItem(i)->childCount())
+ {
m_pTreeWidget->topLevelItem(i)->setExpanded(false);
recursiveCollapseItems((KviClassEditorTreeWidgetItem *)m_pTreeWidget->topLevelItem(i));
}
}
}
-void KviClassEditor::slotReplaceAll(const QString &szFind,const QString &szReplace)
+void KviClassEditor::slotReplaceAll(const QString & szFind, const QString & szReplace)
{
m_pEditor->setFindText(szReplace);
searchReplace(szFind,true,szReplace);
- /*
+ /*
for (int i=0;i<m_pTreeWidget->topLevelItemCount();i++)
{
recursiveSearchReplace(szFind,(KviClassEditorTreeWidgetItem *)m_pTreeWidget->topLevelItem(i),true,szReplace);
@@ -975,36 +1051,37 @@ void KviClassEditor::slotReplaceAll(const QString &szFind,const QString &szRepla
*/
}
-void KviClassEditor::getExportClassBuffer(QString &buffer,KviClassEditorTreeWidgetItem * it)
+void KviClassEditor::exportClassBuffer(QString & szBuffer, KviClassEditorTreeWidgetItem * pItem)
{
- QString szBuf = it->buffer();
- KviCommandFormatter::blockFromBuffer(szBuf);
- QString szNam = buildFullClassName(it);
+ QString szTmp = pItem->buffer();
+ KviCommandFormatter::blockFromBuffer(szTmp);
+ QString szName = buildFullClassName(pItem);
- buffer = "class(\"";
- buffer += szNam;
- if(!it->InheritsClass().isEmpty())
+ szBuffer = "class(\"";
+ szBuffer += szName;
+ if(!pItem->inheritsClass().isEmpty())
{
- buffer+="\",\"";
- buffer+=it->InheritsClass();
+ szBuffer += "\",\"";
+ szBuffer += pItem->inheritsClass();
}
- buffer += "\")\n{\n";
- for(int i=0;i<it->childCount();i++)
+ szBuffer += "\")\n{\n";
+ for(int i=0; i < pItem->childCount(); i++)
{
- KviClassEditorTreeWidgetItem * pFunction= (KviClassEditorTreeWidgetItem *)it->child(i);
+ KviClassEditorTreeWidgetItem * pFunction = (KviClassEditorTreeWidgetItem *)pItem->child(i);
if(pFunction->isMethod())
{
- buffer += "\t";
- if (pFunction->isInternalFunction()) buffer+="internal ";
- buffer += "function ";
- buffer += pFunction->name();
- buffer += "("+pFunction->reminder()+")";
- buffer += "\n\t{\n";
- buffer += pFunction->buffer();
- buffer += "\n\t}\n";
+ szBuffer += "\t";
+ if(pFunction->isInternalFunction())
+ szBuffer += "internal ";
+ szBuffer += "function ";
+ szBuffer += pFunction->name();
+ szBuffer += "(" + pFunction->reminder() + ")";
+ szBuffer += "\n\t{\n";
+ szBuffer += pFunction->buffer();
+ szBuffer += "\n\t}\n";
}
}
- buffer += "}\n";
+ szBuffer += "}\n";
}
void KviClassEditor::exportAll()
@@ -1014,7 +1091,7 @@ void KviClassEditor::exportAll()
void KviClassEditor::exportSelectedSepFiles()
{
- exportClasses (true,true);
+ exportClasses(true,true);
}
void KviClassEditor::exportSelected()
@@ -1022,10 +1099,13 @@ void KviClassEditor::exportSelected()
exportClasses(true);
}
-void KviClassEditor::exportSelectionInSinglesFiles(KviPointerList<KviClassEditorTreeWidgetItem> *l)
+void KviClassEditor::exportSelectionInSinglesFiles(KviPointerList<KviClassEditorTreeWidgetItem> * pList)
{
- if(!m_szDir.endsWith(QString(KVI_PATH_SEPARATOR)))m_szDir += KVI_PATH_SEPARATOR;
- if (!l->first())
+ bool bReplaceAll = false;
+
+ if(!m_szDir.endsWith(QString(KVI_PATH_SEPARATOR)))
+ m_szDir += KVI_PATH_SEPARATOR;
+ if(!pList->first())
{
g_pClassEditorModule->lock();
QMessageBox::warning(this,__tr2qs_ctx("Class Export","editor"),__tr2qs_ctx("There is no selection!","editor"),__tr2qs_ctx("OK","editor"));
@@ -1034,68 +1114,75 @@ void KviClassEditor::exportSelectionInSinglesFiles(KviPointerList<KviClassEditor
}
g_pClassEditorModule->lock();
- if(!KviFileDialog::askForDirectoryName(m_szDir,__tr2qs_ctx("Choose a Directory - KVIrc","editor"),m_szDir)){
+ if(!KviFileDialog::askForDirectoryName(m_szDir,__tr2qs_ctx("Choose a Directory - KVIrc","editor"),m_szDir))
+ {
g_pClassEditorModule->unlock();
return;
}
- if(!m_szDir.endsWith(QString(KVI_PATH_SEPARATOR)))m_szDir += KVI_PATH_SEPARATOR;
+ if(!m_szDir.endsWith(QString(KVI_PATH_SEPARATOR)))
+ m_szDir += KVI_PATH_SEPARATOR;
- bool bReplaceAll=false;
-
- for(KviClassEditorTreeWidgetItem * it = l->first();it;it = l->next())
+ for(KviClassEditorTreeWidgetItem * pItem = pList->first(); pItem; pItem = pList->next())
{
- QString tmp;
- getExportClassBuffer(tmp,it);
- QString szFileName=buildFullClassName(it);
+ QString szTmp;
+ exportClassBuffer(szTmp,pItem);
+ QString szFileName = buildFullClassName(pItem);
szFileName += ".kvs";
szFileName.replace("::","_");
- QString szCompletePath=m_szDir+szFileName;
- if (KviFileUtils::fileExists(szCompletePath) && !bReplaceAll)
+ QString szCompletePath = m_szDir+szFileName;
+ if(KviFileUtils::fileExists(szCompletePath) && !bReplaceAll)
{
- QString szMsg;
- KviQString::sprintf(szMsg,__tr2qs_ctx("The file \"%Q\" exists. Do you want to replace it ?","editor"),&szFileName);
- int ret = QMessageBox::question(this,__tr2qs_ctx("Replace file","editor"),szMsg,__tr2qs_ctx("Yes","editor"),__tr2qs_ctx("Yes to All","editor"),__tr2qs_ctx("No","editor"));
- if (ret!=2)
+ QString szMsg = __tr2qs_ctx("The file \"%1\" exists. Do you want to replace it?","editor").arg(szFileName);
+ int iRet = QMessageBox::question(this,__tr2qs_ctx("Replace file","editor"),szMsg,__tr2qs_ctx("Yes","editor"),__tr2qs_ctx("Yes to All","editor"),__tr2qs_ctx("No","editor"));
+ if(iRet != 2)
{
- KviFileUtils::writeFile(szCompletePath,tmp);
- if (ret==1) bReplaceAll=true;
+ KviFileUtils::writeFile(szCompletePath,szTmp);
+ if(iRet == 1)
+ bReplaceAll = true;
}
}
else
- KviFileUtils::writeFile(szCompletePath,tmp);
+ KviFileUtils::writeFile(szCompletePath,szTmp);
}
g_pClassEditorModule->unlock();
}
void KviClassEditor::exportClasses(bool bSelectedOnly, bool bSingleFiles)
{
+ QString szOut;
+ QString szNameFile;
+ QString szFile;
+ int iCount = 0;
+
saveLastEditedItem();
- KviPointerList<KviClassEditorTreeWidgetItem> l;
- l.setAutoDelete(false);
+ KviPointerList<KviClassEditorTreeWidgetItem> list;
+ list.setAutoDelete(false);
- QString out;
- if (bSelectedOnly) appendSelectedClassItems(&l);
- else appendAllClassItems(&l);
- if (bSingleFiles)
+ if(bSelectedOnly)
+ appendSelectedClassItems(&list);
+ else
+ appendAllClassItems(&list);
+
+ if(bSingleFiles)
{
- exportSelectionInSinglesFiles(&l);
+ exportSelectionInSinglesFiles(&list);
return;
}
- int count=0;
- KviClassEditorTreeWidgetItem * tempitem=0;
- for(KviClassEditorTreeWidgetItem * it = l.first();it;it = l.next())
+
+ KviClassEditorTreeWidgetItem * pTempItem = 0;
+ for(KviClassEditorTreeWidgetItem * pItem = list.first(); pItem; pItem = list.next())
{
- tempitem=it;
- count ++;
- QString tmp;
- getExportClassBuffer(tmp,it);
- out += tmp;
- out += "\n";
+ pTempItem = pItem;
+ iCount++;
+ QString szTmp;
+ exportClassBuffer(szTmp,pItem);
+ szOut += szTmp;
+ szOut += "\n";
}
- QString szNameFile;
- if(out.isEmpty())
+
+ if(szOut.isEmpty())
{
g_pClassEditorModule->lock();
QMessageBox::warning(this,__tr2qs_ctx("Class Export","editor"),__tr2qs_ctx("The exported file would be empty: cowardly refusing to write it","editor"),__tr2qs_ctx("OK","editor"));
@@ -1105,16 +1192,18 @@ void KviClassEditor::exportClasses(bool bSelectedOnly, bool bSingleFiles)
QString szName = m_szDir;
- if(!szName.endsWith(QString(KVI_PATH_SEPARATOR)))szName += KVI_PATH_SEPARATOR;
- QString szFile;
+ if(!szName.endsWith(QString(KVI_PATH_SEPARATOR)))
+ szName += KVI_PATH_SEPARATOR;
+
g_pClassEditorModule->lock();
- if (count==1)
- {
- QString tmp=buildFullClassName(tempitem);
- szNameFile = tmp.replace("::","_");
+ if(iCount != 1)
+ szNameFile = "classes";
+ else {
+ QString szTmp = buildFullClassName(pTempItem);
+ szNameFile = szTmp.replace("::","_");
}
- else szNameFile="classes";
+
szName += szNameFile;
szName += ".kvs";
if(!KviFileDialog::askForSaveFileName(szFile,__tr2qs_ctx("Choose a Filename - KVIrc","editor"),szName,KVI_FILTER_SCRIPT,false,true,true))
@@ -1125,7 +1214,7 @@ void KviClassEditor::exportClasses(bool bSelectedOnly, bool bSingleFiles)
m_szDir=QFileInfo(szFile).absolutePath();
g_pClassEditorModule->unlock();
- if(!KviFileUtils::writeFile(szFile,out))
+ if(!KviFileUtils::writeFile(szFile,szOut))
{
g_pClassEditorModule->lock();
QMessageBox::warning(this,__tr2qs_ctx("Write Failed - KVIrc","editor"),__tr2qs_ctx("Unable to write to the class file.","editor"),__tr2qs_ctx("OK","editor"));
@@ -1133,128 +1222,133 @@ void KviClassEditor::exportClasses(bool bSelectedOnly, bool bSingleFiles)
}
}
-void KviClassEditor::saveProperties(KviConfig * cfg)
+void KviClassEditor::saveProperties(KviConfig * pCfg)
{
- cfg->writeEntry("Sizes",m_pSplitter->sizes());
+ pCfg->writeEntry("Sizes",m_pSplitter->sizes());
QString szName;
if(m_pLastEditedItem)
szName = buildFullClassName(m_pLastEditedItem);
- cfg->writeEntry("LastClass",szName);
+ pCfg->writeEntry("LastClass",szName);
}
-void KviClassEditor::loadProperties(KviConfig * cfg)
+void KviClassEditor::loadProperties(KviConfig * pCfg)
{
QList<int> def;
def.append(20);
def.append(80);
- m_pSplitter->setSizes(cfg->readIntListEntry("Sizes",def));
- QString tmp = cfg->readEntry("LastClass",QString());
+ m_pSplitter->setSizes(pCfg->readIntListEntry("Sizes",def));
+ QString szTmp = pCfg->readEntry("LastClass",QString());
- KviClassEditorTreeWidgetItem * it = findItem(tmp);
- activateItem(it);
+ KviClassEditorTreeWidgetItem * pItem = findItem(szTmp);
+ activateItem(pItem);
}
-void KviClassEditor::appendSelectedClassItems(KviPointerList<KviClassEditorTreeWidgetItem> * l)
+void KviClassEditor::appendSelectedClassItems(KviPointerList<KviClassEditorTreeWidgetItem> * pList)
{
- QList<QTreeWidgetItem *> list=m_pTreeWidget->selectedItems();
- for(int i=0;i<list.count();i++)
+ QList<QTreeWidgetItem *> list = m_pTreeWidget->selectedItems();
+ for(int i=0; i < list.count(); i++)
{
- if (((KviClassEditorTreeWidgetItem *)list.at(i))->isClass())
- l->append((KviClassEditorTreeWidgetItem *)list.at(i));
- else appendSelectedClassItemsRecursive(l,list.at(i));
+ if(((KviClassEditorTreeWidgetItem *)list.at(i))->isClass())
+ pList->append((KviClassEditorTreeWidgetItem *)list.at(i));
+ else appendSelectedClassItemsRecursive(pList,list.at(i));
}
}
-void KviClassEditor::appendSelectedClassItemsRecursive(KviPointerList<KviClassEditorTreeWidgetItem> * l,QTreeWidgetItem * pStartFrom)
+
+void KviClassEditor::appendSelectedClassItemsRecursive(KviPointerList<KviClassEditorTreeWidgetItem> * pList, QTreeWidgetItem * pStartFrom)
{
- for (int i=0;i<pStartFrom->childCount();i++)
+ for(int i=0; i < pStartFrom->childCount(); i++)
{
- if (((KviClassEditorTreeWidgetItem *)pStartFrom->child(i))->isClass())
- l->append(((KviClassEditorTreeWidgetItem *)pStartFrom->child(i)));
+ if(((KviClassEditorTreeWidgetItem *)pStartFrom->child(i))->isClass())
+ pList->append(((KviClassEditorTreeWidgetItem *)pStartFrom->child(i)));
else
- appendSelectedClassItemsRecursive(l,pStartFrom->child(i));
+ appendSelectedClassItemsRecursive(pList,pStartFrom->child(i));
}
}
-void KviClassEditor::appendAllClassItems(KviPointerList<KviClassEditorTreeWidgetItem> * l)
+void KviClassEditor::appendAllClassItems(KviPointerList<KviClassEditorTreeWidgetItem> * pList)
{
KviPointerHashTableIterator<QString,KviClassEditorTreeWidgetItem> it (*m_pClasses);
while(it.current())
{
- l->append(it.current());
+ pList->append(it.current());
++it;
}
}
-void KviClassEditor::appendAllClassItemsRecursive(KviPointerList<KviClassEditorTreeWidgetItem> * l,QTreeWidgetItem * pStartFrom)
+void KviClassEditor::appendAllClassItemsRecursive(KviPointerList<KviClassEditorTreeWidgetItem> * pList, QTreeWidgetItem * pStartFrom)
{
- for (int i=0;i<pStartFrom->childCount();i++)
+ for(int i=0; i < pStartFrom->childCount(); i++)
{
- if (((KviClassEditorTreeWidgetItem *)pStartFrom->child(i))->isClass())
+ if(((KviClassEditorTreeWidgetItem *)pStartFrom->child(i))->isClass())
{
- l->append((KviClassEditorTreeWidgetItem *)pStartFrom->child(i));
+ pList->append((KviClassEditorTreeWidgetItem *)pStartFrom->child(i));
} else {
- appendAllClassItemsRecursive(l,pStartFrom->child(i));
+ appendAllClassItemsRecursive(pList,pStartFrom->child(i));
}
}
}
-void KviClassEditor::removeItemChildren(KviClassEditorTreeWidgetItem *it,KviPointerList <KviClassEditorTreeWidgetItem> &lRemovedItems)
+void KviClassEditor::removeItemChildren(KviClassEditorTreeWidgetItem * pItem, KviPointerList <KviClassEditorTreeWidgetItem> & lRemovedItems)
{
- if(it->isClass())
+ if(pItem->isClass())
{
KviPointerList<KviClassEditorTreeWidgetItem> lInheritedClasses;
lInheritedClasses.setAutoDelete(false);
- searchInheritedClasses(buildFullClassName(it),lInheritedClasses);
- for(unsigned int i=0;i<lInheritedClasses.count();i++)
+ searchInheritedClasses(buildFullClassName(pItem),lInheritedClasses);
+ for(unsigned int u=0; u < lInheritedClasses.count(); u++)
{
- lInheritedClasses.at(i)->setClassNotBuilt(true);
- lInheritedClasses.at(i)->setExpanded(true);
- lInheritedClasses.at(i)->setInheritsClass("object");
+ lInheritedClasses.at(u)->setClassNotBuilt(true);
+ lInheritedClasses.at(u)->setExpanded(true);
+ lInheritedClasses.at(u)->setInheritsClass("object");
}
}
- while(it->childCount() > 0)
+ while(pItem->childCount() > 0)
{
- KviClassEditorTreeWidgetItem * pChild = (KviClassEditorTreeWidgetItem *)(it->child(0));
+ KviClassEditorTreeWidgetItem * pChild = (KviClassEditorTreeWidgetItem *)(pItem->child(0));
if(pChild->childCount())
removeItemChildren(pChild,lRemovedItems);
if(pChild->isClass())
{
m_pClasses->removeRef(pChild);
- KviKvsObjectClass *pClass = KviKvsKernel::instance()->objectController()->lookupClass(buildFullClassName(pChild));
- if (pClass) KviKvsKernel::instance()->objectController()->deleteClass(pClass);
- qDebug("rimuovo class %s %p",buildFullClassName(pChild).toUtf8().data(), pClass);
+ KviKvsObjectClass * pClass = KviKvsKernel::instance()->objectController()->lookupClass(buildFullClassName(pChild));
+ if(pClass)
+ KviKvsKernel::instance()->objectController()->deleteClass(pClass);
+ qDebug("removing class %s %p",buildFullClassName(pChild).toUtf8().data(), pClass);
}
- it->removeChild(pChild);
- lRemovedItems.append(it);
+ pItem->removeChild(pChild);
+ lRemovedItems.append(pItem);
delete pChild;
}
}
-bool KviClassEditor::removeItem(KviClassEditorTreeWidgetItem *it,KviPointerList <KviClassEditorTreeWidgetItem> &lRemovedItems,bool * pbYesToAll,bool)
+bool KviClassEditor::removeItem(KviClassEditorTreeWidgetItem * pItem, KviPointerList <KviClassEditorTreeWidgetItem> & lRemovedItems, bool * pbYesToAll)
{
- if(!it)return true;
+ if(!pItem)
+ return true;
QString szMsg;
- QString szName = it->name();
+ QString szName = pItem->name();
if(!*pbYesToAll)
{
saveLastEditedItem();
- if(it->isClass())
+ if(pItem->isClass())
{
KviQString::sprintf(szMsg,__tr2qs_ctx("Do you really want to remove the class \"%Q\" ?","editor"),&szName);
- } else if(it->isNamespace()) {
+ } else if(pItem->isNamespace())
+ {
KviQString::sprintf(szMsg,__tr2qs_ctx("Do you really want to remove the namespace \"%Q\" ?","editor"),&szName);
szMsg += "<br>";
szMsg += __tr2qs_ctx("Please note that all the children classes/functions will be deleted too.","editor");
- } else if(it->isMethod()) {
+ } else if(pItem->isMethod())
+ {
KviQString::sprintf(szMsg,__tr2qs_ctx("Do you really want to remove the function \"%Q\" ?","editor"),&szName);
}
g_pClassEditorModule->lock();
- int ret = QMessageBox::question(this,__tr2qs_ctx("Remove item","editor"),szMsg,__tr2qs_ctx("Yes","editor"),__tr2qs_ctx("Yes to All","editor"),__tr2qs_ctx("No","editor"));
+ int iRet = QMessageBox::question(this,__tr2qs_ctx("Remove item","editor"),szMsg,__tr2qs_ctx("Yes","editor"),__tr2qs_ctx("Yes to All","editor"),__tr2qs_ctx("No","editor"));
g_pClassEditorModule->unlock();
- switch(ret)
+ switch(iRet)
{
case 0:
// nothing
@@ -1268,52 +1362,54 @@ bool KviClassEditor::removeItem(KviClassEditorTreeWidgetItem *it,KviPointerList
}
}
- if(it == m_pLastEditedItem)
+ if(pItem == m_pLastEditedItem)
m_pLastEditedItem = 0;
- if(it == m_pLastClickedItem)
+ if(pItem == m_pLastClickedItem)
m_pLastClickedItem = 0;
- if (it->childCount())
- removeItemChildren(it,lRemovedItems);
- if(it->isClass())
+ if(pItem->childCount())
+ removeItemChildren(pItem,lRemovedItems);
+ if(pItem->isClass())
{
- m_pClasses->removeRef(it);
- KviKvsObjectClass *pClass = KviKvsKernel::instance()->objectController()->lookupClass(buildFullClassName(it));
- qDebug("rimuovo class %s %p",buildFullClassName(it).toUtf8().data(), pClass);
- if (pClass) KviKvsKernel::instance()->objectController()->deleteClass(pClass);
+ m_pClasses->removeRef(pItem);
+ KviKvsObjectClass * pClass = KviKvsKernel::instance()->objectController()->lookupClass(buildFullClassName(pItem));
+ qDebug("rimuovo class %s %p",buildFullClassName(pItem).toUtf8().data(), pClass);
+ if(pClass)
+ KviKvsKernel::instance()->objectController()->deleteClass(pClass);
else
{
- QString szFileName=buildFullClassName(it);
+ QString szFileName = buildFullClassName(pItem);
szFileName.replace("::","--");
szFileName.append(KVI_FILEEXTENSION_SCRIPT);
QString szPath;
g_pApp->getLocalKvircDirectory(szPath,KviApp::Classes);
QDir d(szPath);
- if (d.exists(szFileName))
+ if(d.exists(szFileName))
{
qDebug("rimuovo dal disco il file %s",szFileName.toUtf8().data());
d.remove(szFileName);
}
}
}
- if(it->isMethod())
+ if(pItem->isMethod())
{
- updateClassHierarchy((KviClassEditorTreeWidgetItem*)it->parent());
+ updateClassHierarchy((KviClassEditorTreeWidgetItem *)pItem->parent());
}
- lRemovedItems.append(it);
- delete it;
+ lRemovedItems.append(pItem);
+ delete pItem;
return true;
}
-void KviClassEditor::updateClassHierarchy(KviClassEditorTreeWidgetItem* pClass)
+
+void KviClassEditor::updateClassHierarchy(KviClassEditorTreeWidgetItem * pClass)
{
pClass->setClassNotBuilt(true);
KviPointerList<KviClassEditorTreeWidgetItem> lInheritedClasses;
lInheritedClasses.setAutoDelete(false);
searchInheritedClasses(pClass->name(),lInheritedClasses);
- for(unsigned int i=0;i<lInheritedClasses.count();i++)
+ for(unsigned int u=0; u < lInheritedClasses.count(); u++)
{
- lInheritedClasses.at(i)->setClassNotBuilt(true);
- lInheritedClasses.at(i)->setInheritsClass(pClass->name());
- lInheritedClasses.at(i)->setExpanded(true);
+ lInheritedClasses.at(u)->setClassNotBuilt(true);
+ lInheritedClasses.at(u)->setInheritsClass(pClass->name());
+ lInheritedClasses.at(u)->setExpanded(true);
}
}
@@ -1321,26 +1417,28 @@ void KviClassEditor::removeSelectedItems()
{
KviPointerList<KviClassEditorTreeWidgetItem> lRemovedItems;
lRemovedItems.setAutoDelete(false);
- QList<QTreeWidgetItem *> list=m_pTreeWidget->selectedItems();
+ QList<QTreeWidgetItem *> list = m_pTreeWidget->selectedItems();
bool bYesToAll = false;
- for(int i=0;i<list.count();i++)
+ for(int i=0; i < list.count(); i++)
{
- if (lRemovedItems.findRef((KviClassEditorTreeWidgetItem *) list.at(i))!=-1) continue;
- if(!removeItem((KviClassEditorTreeWidgetItem *) list.at(i),lRemovedItems,&bYesToAll,false))return;
+ if(lRemovedItems.findRef((KviClassEditorTreeWidgetItem *) list.at(i)) != -1)
+ continue;
+ if(!removeItem((KviClassEditorTreeWidgetItem *) list.at(i),lRemovedItems,&bYesToAll))
+ return;
}
}
-bool KviClassEditor::askForClassName(QString &szClassName,QString &szInheritsClassName, bool bEdit)
+bool KviClassEditor::askForClassName(QString & szClassName, QString & szInheritsClassName, bool bEdit)
{
- KviClassEditorDialog *pDialog=new KviClassEditorDialog(this,"classdialog",m_pClasses,szClassName,szInheritsClassName,bEdit);
- szClassName="";
+ KviClassEditorDialog * pDialog = new KviClassEditorDialog(this,"classdialog",m_pClasses,szClassName,szInheritsClassName,bEdit);
+ szClassName = "";
g_pClassEditorModule->lock();
- bool bOk=pDialog->exec();
+ bool bOk = pDialog->exec();
g_pClassEditorModule->unlock();
if(bOk)
{
- szClassName=pDialog->getClassName();
- szInheritsClassName=pDialog->getInheritsClassName();
+ szClassName = pDialog->className();
+ szInheritsClassName = pDialog->inheritsClassName();
delete pDialog;
return true;
}
@@ -1348,18 +1446,18 @@ bool KviClassEditor::askForClassName(QString &szClassName,QString &szInheritsCla
return false;
}
-bool KviClassEditor::askForFunction(QString &szFunctionName,QString &szReminder,bool * bInternal,const QString &szClassName, bool bRenameMode)
+bool KviClassEditor::askForFunction(QString & szFunctionName, QString & szReminder, bool * bInternal, const QString & szClassName, bool bRenameMode)
{
- KviClassEditorFunctionDialog *pDialog=new KviClassEditorFunctionDialog(this,"function",szClassName,szFunctionName,szReminder,*bInternal, bRenameMode);
- szFunctionName="";
+ KviClassEditorFunctionDialog * pDialog = new KviClassEditorFunctionDialog(this,"function",szClassName,szFunctionName,szReminder,*bInternal, bRenameMode);
+ szFunctionName = "";
g_pClassEditorModule->lock();
- bool bOk=pDialog->exec();
+ bool bOk = pDialog->exec();
g_pClassEditorModule->unlock();
if(bOk)
{
- szFunctionName=pDialog->getFunctionName();
- szReminder=pDialog->getReminder();
- *bInternal=pDialog->isInternalFunction();
+ szFunctionName = pDialog->functionName();
+ szReminder = pDialog->reminder();
+ *bInternal = pDialog->isInternalFunction();
delete pDialog;
return true;
}
@@ -1367,20 +1465,21 @@ bool KviClassEditor::askForFunction(QString &szFunctionName,QString &szReminder,
return false;
}
-bool KviClassEditor::askForNamespaceName(const QString &szAction,const QString &szText,const QString &szInitialText, QString &szNewName)
+bool KviClassEditor::askForNamespaceName(const QString & szAction, const QString & szText, const QString & szInitialText, QString & szNewName)
{
bool bOk = false;
while(szNewName.isEmpty())
{
g_pClassEditorModule->lock();
szNewName = QInputDialog::getText(this,
- szAction,
- szText,
- QLineEdit::Normal,
- szInitialText,
- &bOk);
+ szAction,
+ szText,
+ QLineEdit::Normal,
+ szInitialText,
+ &bOk);
g_pClassEditorModule->unlock();
- if(!bOk)return false;
+ if(!bOk)
+ return false;
if(szNewName.isEmpty())
{
g_pClassEditorModule->lock();
@@ -1406,9 +1505,9 @@ bool KviClassEditor::askForNamespaceName(const QString &szAction,const QString &
continue;
}
// make sure that we have only doubled "::" and not ":" or ":::..."
- QString tmp = szNewName;
- tmp.replace("::","@"); // @ is not allowed by the rule above
- if(tmp.indexOf(":",Qt::CaseInsensitive) != -1)
+ QString szTmp = szNewName;
+ szTmp.replace("::","@"); // @ is not allowed by the rule above
+ if(szTmp.indexOf(":",Qt::CaseInsensitive) != -1)
{
g_pClassEditorModule->lock();
QMessageBox::information(this,
@@ -1419,7 +1518,7 @@ bool KviClassEditor::askForNamespaceName(const QString &szAction,const QString &
szNewName = "";
continue;
}
- if(tmp.indexOf("@@",Qt::CaseInsensitive) != -1)
+ if(szTmp.indexOf("@@",Qt::CaseInsensitive) != -1)
{
g_pClassEditorModule->lock();
QMessageBox::information(this,
@@ -1434,135 +1533,155 @@ bool KviClassEditor::askForNamespaceName(const QString &szAction,const QString &
return true;
}
-void KviClassEditor::openParentItems(QTreeWidgetItem * it)
+void KviClassEditor::openParentItems(QTreeWidgetItem * pItem)
{
- if(it->parent())
+ if(pItem->parent())
{
- it->parent()->setExpanded(true);
- openParentItems(it->parent());
+ pItem->parent()->setExpanded(true);
+ openParentItems(pItem->parent());
}
}
-void KviClassEditor::activateItem(QTreeWidgetItem * it)
+void KviClassEditor::activateItem(QTreeWidgetItem * pItem)
{
- if (!it) return;
- openParentItems(it);
- m_pTreeWidget->setCurrentItem(it);
+ if(!pItem)
+ return;
+ openParentItems(pItem);
+ m_pTreeWidget->setCurrentItem(pItem);
}
void KviClassEditor::newClass()
{
- QString szClassName,szInheritsClassName;
- askForClassName(szClassName,szInheritsClassName,false);
- if(szClassName.isEmpty())return;
- KviClassEditorTreeWidgetItem *it=newItem(szClassName,KviClassEditorTreeWidgetItem::Class);
- QString szClass="class\(";
- szClass+=szClassName+","+szInheritsClassName;
- szClass+="){}\n";
- it->setInheritsClass(szInheritsClassName);
- activateItem(it);
- m_pClasses->insert(szClassName,it);
+ QString szClassName;
+ QString szinheritsClassName;
+ askForClassName(szClassName,szinheritsClassName,false);
+ if(szClassName.isEmpty())
+ return;
+ KviClassEditorTreeWidgetItem * pItem = newItem(szClassName,KviClassEditorTreeWidgetItem::Class);
+
+ QString szClass = "class\(";
+ szClass += szClassName + "," + szinheritsClassName;
+ szClass += "){}\n";
+ pItem->setInheritsClass(szinheritsClassName);
+ activateItem(pItem);
+ m_pClasses->insert(szClassName,pItem);
KviKvsScript::run(szClass,g_pActiveWindow);
}
+
void KviClassEditor::newNamespace()
{
QString szName;
- if(!askForNamespaceName(__tr2qs_ctx("Add Namespace","editor"),__tr2qs_ctx("Please enter the name for the new namespace","editor"),"mynamespace",szName)) return;
- if(szName.isEmpty())return;
- KviClassEditorTreeWidgetItem *it=newItem(szName,KviClassEditorTreeWidgetItem::Namespace);
- activateItem(it);
+ if(!askForNamespaceName(__tr2qs_ctx("Add Namespace","editor"),__tr2qs_ctx("Please enter the name for the new namespace","editor"),"mynamespace",szName))
+ return;
+ if(szName.isEmpty())
+ return;
+ KviClassEditorTreeWidgetItem * pItem = newItem(szName,KviClassEditorTreeWidgetItem::Namespace);
+ activateItem(pItem);
}
void KviClassEditor::newMemberFunction()
{
- QString szFunctionName,szClassName,szReminder;
- if(m_pLastClickedItem->isMethod()) m_pLastClickedItem= (KviClassEditorTreeWidgetItem*)m_pLastClickedItem->parent();
- szClassName=buildFullClassName(m_pLastClickedItem);
- bool bInternal= false;
- if(!askForFunction(szFunctionName, szReminder,&bInternal,szClassName, false)) return;
- if(szFunctionName.isEmpty())return;
- KviClassEditorTreeWidgetItem *it=newItem(szFunctionName,KviClassEditorTreeWidgetItem::Method);
- it->setInternalFunction(bInternal);
- if(!szReminder.isEmpty()) it->setReminder(szReminder);
- activateItem(it);
- ((KviClassEditorTreeWidgetItem*)it->parent())->setClassNotBuilt(true);
+ QString szFunctionName;
+ QString szClassName;
+ QString szReminder;
+
+ if(m_pLastClickedItem->isMethod())
+ m_pLastClickedItem = (KviClassEditorTreeWidgetItem*)m_pLastClickedItem->parent();
+ szClassName = buildFullClassName(m_pLastClickedItem);
+ bool bInternal = false;
+ if(!askForFunction(szFunctionName, szReminder,&bInternal,szClassName,false))
+ return;
+ if(szFunctionName.isEmpty())
+ return;
+
+ KviClassEditorTreeWidgetItem * pItem = newItem(szFunctionName,KviClassEditorTreeWidgetItem::Method);
+ pItem->setInternalFunction(bInternal);
+ if(!szReminder.isEmpty())
+ pItem->setReminder(szReminder);
+ activateItem(pItem);
+ ((KviClassEditorTreeWidgetItem*)pItem->parent())->setClassNotBuilt(true);
}
-KviClassEditorTreeWidgetItem * KviClassEditor::newItem(QString &szName,KviClassEditorTreeWidgetItem::Type eType)
+KviClassEditorTreeWidgetItem * KviClassEditor::newItem(QString & szName, KviClassEditorTreeWidgetItem::Type eType)
{
if(m_pLastClickedItem)
- buildFullItemPath(m_pLastClickedItem,szName);
+ buildFullItemPath(m_pLastClickedItem,szName);
+
QString szTmp;
- if(findItem(szName)) szName.append("1");
- int idx=2;
+ if(findItem(szName))
+ szName.append("1");
+
+ int iIdx = 2;
while(findItem(szName))
{
- szTmp.setNum(idx);
+ szTmp.setNum(iIdx);
szName.chop(szTmp.length());
szName.append(szTmp);
- idx++;
+ iIdx++;
}
- KviClassEditorTreeWidgetItem * it;
- it=createFullItem(szName);
- it->setType(eType);
- return it;
+ KviClassEditorTreeWidgetItem * pItem;
+ pItem = createFullItem(szName);
+ pItem->setType(eType);
+ return pItem;
}
void KviClassEditor::build()
{
saveLastEditedItem();
KviPointerHashTableIterator<QString,KviClassEditorTreeWidgetItem> it (*m_pClasses);
- KviPointerList<KviClassEditorTreeWidgetItem> pLinkedClasses;
- pLinkedClasses.setAutoDelete(false);
- KviPointerList<KviClassEditorTreeWidgetItem> pSkipClasses;
- pSkipClasses.setAutoDelete(false);
- bool bErrorWhilecompiling=false;
+ KviPointerList<KviClassEditorTreeWidgetItem> linkedClasses;
+ linkedClasses.setAutoDelete(false);
+ KviPointerList<KviClassEditorTreeWidgetItem> skipClasses;
+ skipClasses.setAutoDelete(false);
+ bool bErrorWhilecompiling = false;
while(it.current())
{
- KviClassEditorTreeWidgetItem *pClass=it.current();
- if (pSkipClasses.findRef(it.current())!=-1)
+ KviClassEditorTreeWidgetItem * pClass = it.current();
+ if(skipClasses.findRef(it.current()) != -1)
{
++it;
continue;
}
- if (pClass->classNotBuilt())
+ if(pClass->classNotBuilt())
{
- // qDebug("compiling %s",pClass->name().toUtf8().data());
- KviClassEditorTreeWidgetItem *pParentClass=m_pClasses->find(pClass->InheritsClass());
+ //qDebug("compiling %s",pClass->name().toUtf8().data());
+ KviClassEditorTreeWidgetItem * pParentClass = m_pClasses->find(pClass->inheritsClass());
- pLinkedClasses.append(pClass);
+ linkedClasses.append(pClass);
//if (!pParentClass) qDebug("no parent class");
while(pParentClass)
{
- if (pParentClass->classNotBuilt()) pLinkedClasses.append(pParentClass);
- pParentClass=m_pClasses->find(pParentClass->InheritsClass());
+ if(pParentClass->classNotBuilt())
+ linkedClasses.append(pParentClass);
+ pParentClass = m_pClasses->find(pParentClass->inheritsClass());
}
- for(int i=pLinkedClasses.count()-1;i>=0;i--)
+ for(int i = linkedClasses.count()-1; i >= 0; i--)
{
- QString szFullClassName = buildFullClassName(pLinkedClasses.at(i));
- KviKvsObjectClass *pClass = KviKvsKernel::instance()->objectController()->lookupClass(szFullClassName);
- if (pClass) KviKvsKernel::instance()->objectController()->deleteClass(pClass);
+ QString szFullClassName = buildFullClassName(linkedClasses.at(i));
+ KviKvsObjectClass * pClass = KviKvsKernel::instance()->objectController()->lookupClass(szFullClassName);
+ if(pClass)
+ KviKvsKernel::instance()->objectController()->deleteClass(pClass);
QString szClass;
- getExportClassBuffer(szClass, pLinkedClasses.at(i));
+ exportClassBuffer(szClass, linkedClasses.at(i));
KviKvsScript::run(szClass,g_pActiveWindow);
pClass = KviKvsKernel::instance()->objectController()->lookupClass(szFullClassName);
- if (!pClass)
+ if(!pClass)
{
- bErrorWhilecompiling=true;
- QString szError=__tr2qs_ctx("Unable to compile class: ","editor");
- szError+=szFullClassName+"\n";
+ bErrorWhilecompiling = true;
+ QString szError = __tr2qs_ctx("Unable to compile class: ","editor");
+ szError += szFullClassName + "\n";
KviPointerList<KviClassEditorTreeWidgetItem> lInheritedClasses;
lInheritedClasses.setAutoDelete(false);
searchInheritedClasses(szFullClassName,lInheritedClasses);
- if (lInheritedClasses.count())
+ if(lInheritedClasses.count())
{
- szError+=__tr2qs_ctx("These Inherited classes will be not compiled too:","editor");
- szError+="\n";
- for(unsigned int j=0;j<lInheritedClasses.count();j++)
+ szError += __tr2qs_ctx("These inherited classes will be not compiled too:","editor");
+ szError += "\n";
+ for(unsigned int u=0; u < lInheritedClasses.count(); u++)
{
- szError+=buildFullClassName(lInheritedClasses.at(j))+"\n";
- lInheritedClasses.at(j)->setClassNotBuilt(true);
- pSkipClasses.append(lInheritedClasses.at(j));
+ szError += buildFullClassName(lInheritedClasses.at(u)) + "\n";
+ lInheritedClasses.at(u)->setClassNotBuilt(true);
+ skipClasses.append(lInheritedClasses.at(u));
}
}
QMessageBox::critical(this,__tr2qs_ctx("Compilation error - KVIrc","editor"),szError,
@@ -1570,14 +1689,15 @@ void KviClassEditor::build()
break;
}
//else qDebug("class compiled %s :\n",szClass.toUtf8().data());
- pLinkedClasses.at(i)->setClassNotBuilt(false);
+ linkedClasses.at(i)->setClassNotBuilt(false);
m_pEditor->setModified(false);
}
}
++it;
}
- if (bErrorWhilecompiling) saveNotBuiltClasses();
- else{
+ if(bErrorWhilecompiling)
+ saveNotBuiltClasses();
+ else {
QString szFileName = "libkviclasseditortmp.kvc";
QString szBuffer;
g_pApp->getLocalKvircDirectory(szBuffer,KviApp::ConfigPlugins,szFileName);
@@ -1605,13 +1725,13 @@ void KviClassEditor::loadNotBuiltClasses()
++it;
}
- for(QString * s = l.first();s;s = l.next())
+ for(QString * pszTmp = l.first(); pszTmp; pszTmp = l.next())
{
- cfg.setGroup(*s);
- KviClassEditorTreeWidgetItem *pClassItem = createFullItem(*s);
- m_pClasses->insert(*s,pClassItem);
+ cfg.setGroup(*pszTmp);
+ KviClassEditorTreeWidgetItem * pClassItem = createFullItem(*pszTmp);
+ m_pClasses->insert(*pszTmp,pClassItem);
pClassItem->setClassNotBuilt(true);
- KviConfigGroup * pDict = cfg.dict()->find(*s);
+ KviConfigGroup * pDict = cfg.dict()->find(*pszTmp);
if(pDict)
{
KviConfigGroupIterator it(*pDict);
@@ -1622,20 +1742,22 @@ void KviClassEditor::loadNotBuiltClasses()
names.append(new QString(it.currentKey()));
++it;
}
- for(QString * s = names.first(); s; s = names.next())
+ for(QString * pszTmp = names.first(); pszTmp; pszTmp = names.next())
{
- if (KviQString::equalCI(*s,"@Inherits"))
+ if(KviQString::equalCI(*pszTmp,"@Inherits"))
{
- pClassItem->setInheritsClass(cfg.readQStringEntry(*s,""));
+ pClassItem->setInheritsClass(cfg.readQStringEntry(*pszTmp,""));
continue;
}
- if ((*s).left(9)=="@Reminder") continue;
- QString szCode = cfg.readQStringEntry(*s,"");
- KviClassEditorTreeWidgetItem *pFunctionItem=findFunction(*s, pClassItem);
- if(!pFunctionItem) pFunctionItem = new KviClassEditorTreeWidgetItem(pClassItem,KviClassEditorTreeWidgetItem::Method,*s);
+ if((*pszTmp).left(9) == "@Reminder")
+ continue;
+ QString szCode = cfg.readQStringEntry(*pszTmp,"");
+ KviClassEditorTreeWidgetItem * pFunctionItem = findFunction(*pszTmp, pClassItem);
+ if(!pFunctionItem)
+ pFunctionItem = new KviClassEditorTreeWidgetItem(pClassItem,KviClassEditorTreeWidgetItem::Method,*pszTmp);
pFunctionItem->setBuffer(szCode);
- QString szEntry="@Reminder|"+(*s);
+ QString szEntry = "@Reminder|" + (*pszTmp);
QString szReminder = cfg.readQStringEntry(szEntry,"");
pFunctionItem->setReminder(szReminder);
}
@@ -1655,68 +1777,71 @@ void KviClassEditor::saveNotBuiltClasses()
while(it.current())
{
- if (it.current()->classNotBuilt())
+ if(it.current()->classNotBuilt())
{
- KviKvsObjectClass *pClass = KviKvsKernel::instance()->objectController()->lookupClass(it.currentKey());
- if (pClass) KviKvsKernel::instance()->objectController()->deleteClass(pClass);
+ KviKvsObjectClass * pClass = KviKvsKernel::instance()->objectController()->lookupClass(it.currentKey());
+ if(pClass)
+ KviKvsKernel::instance()->objectController()->deleteClass(pClass);
cfg.setGroup(it.currentKey());
- cfg.writeEntry("@Inherits",it.current()->InheritsClass());
- QString szReminderEntry;
- for(int i=0;i<it.current()->childCount();i++){
- if(!((KviClassEditorTreeWidgetItem*)it.current()->child(i))->reminder().isEmpty())
- {
- szReminderEntry="@Reminder|"+((KviClassEditorTreeWidgetItem*)it.current()->child(i))->name();
- cfg.writeEntry(szReminderEntry,((KviClassEditorTreeWidgetItem*)it.current()->child(i))->reminder());
- }
- cfg.writeEntry(((KviClassEditorTreeWidgetItem*)it.current()->child(i))->name(),((KviClassEditorTreeWidgetItem*)it.current()->child(i))->buffer());
- }
- }
+ cfg.writeEntry("@Inherits",it.current()->inheritsClass());
+ QString szReminderEntry;
+ for(int i=0; i < it.current()->childCount(); i++)
+ {
+ if(!((KviClassEditorTreeWidgetItem *)it.current()->child(i))->reminder().isEmpty())
+ {
+ szReminderEntry="@Reminder|"+((KviClassEditorTreeWidgetItem *)it.current()->child(i))->name();
+ cfg.writeEntry(szReminderEntry,((KviClassEditorTreeWidgetItem *)it.current()->child(i))->reminder());
+ }
+ cfg.writeEntry(((KviClassEditorTreeWidgetItem *)it.current()->child(i))->name(),((KviClassEditorTreeWidgetItem *)it.current()->child(i))->buffer());
+ }
+ }
++it;
- }
- cfg.sync();
+ }
+ cfg.sync();
}
-void KviClassEditor::searchInheritedClasses(const QString szClass,KviPointerList<KviClassEditorTreeWidgetItem> & lInheritedClasses)
+void KviClassEditor::searchInheritedClasses(const QString szClass, KviPointerList<KviClassEditorTreeWidgetItem> & lInheritedClasses)
{
KviPointerHashTableIterator<QString,KviClassEditorTreeWidgetItem> it (*m_pClasses);
while(it.current())
{
- if (KviQString::equalCI(szClass,it.current()->InheritsClass())) lInheritedClasses.append(it.current());
+ if(KviQString::equalCI(szClass,it.current()->inheritsClass()))
+ lInheritedClasses.append(it.current());
++it;
}
}
-KviClassEditorWindow::KviClassEditorWindow(KviFrame * lpFrm)
-: KviWindow(KVI_WINDOW_TYPE_SCRIPTEDITOR,lpFrm,"classeditor",0)
+KviClassEditorWindow::KviClassEditorWindow(KviFrame * pFrm)
+: KviWindow(KVI_WINDOW_TYPE_SCRIPTEDITOR,pFrm,"classeditor",0)
{
g_pClassEditorWindow = this;
setFixedCaption(__tr2qs_ctx("Class Editor","editor"));
- QGridLayout * g = new QGridLayout();
+ QGridLayout * pLayout = new QGridLayout();
m_pEditor = new KviClassEditor(this);
- g->addWidget(m_pEditor,0,0,1,4);
+ pLayout->addWidget(m_pEditor,0,0,1,4);
- QPushButton * btn = new QPushButton(__tr2qs_ctx("&Build","editor"),this);
- connect(btn,SIGNAL(clicked()),this,SLOT(buildClicked()));
- btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT)));
- g->addWidget(btn,1,1);
+ QPushButton * pBtn = new QPushButton(__tr2qs_ctx("&Build","editor"),this);
+ pBtn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT)));
+ pLayout->addWidget(pBtn,1,1);
+ connect(pBtn,SIGNAL(clicked()),this,SLOT(buildClicked()));
- btn = new QPushButton(__tr2qs_ctx("&Save","editor"),this);
- connect(btn,SIGNAL(clicked()),this,SLOT(saveClicked()));
- btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT)));
- g->addWidget(btn,1,2);
+ pBtn = new QPushButton(__tr2qs_ctx("&Save","editor"),this);
+ pBtn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT)));
+ pLayout->addWidget(pBtn,1,2);
+ connect(pBtn,SIGNAL(clicked()),this,SLOT(saveClicked()));
- btn = new QPushButton(__tr2qs_ctx("Close","editor"),this);
- connect(btn,SIGNAL(clicked()),this,SLOT(cancelClicked()));
- btn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD)));
- g->addWidget(btn,1,3);
+ pBtn = new QPushButton(__tr2qs_ctx("Close","editor"),this);
+ pBtn->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD)));
+ pLayout->addWidget(pBtn,1,3);
+ connect(pBtn,SIGNAL(clicked()),this,SLOT(cancelClicked()));
- g->setRowStretch(0,1);
- g->setColumnStretch(0,1);
- setLayout(g);
+ pLayout->setRowStretch(0,1);
+ pLayout->setColumnStretch(0,1);
+ setLayout(pLayout);
}
KviClassEditorWindow::~KviClassEditorWindow()
@@ -1744,69 +1869,67 @@ QPixmap * KviClassEditorWindow::myIconPtr()
return g_pIconManager->getSmallIcon(KVI_SMALLICON_CLASSEDITOR);
}
-void KviClassEditorWindow::getConfigGroupName(QString &szName)
+void KviClassEditorWindow::configGroupName(QString &szName)
{
szName = "classeditor";
}
-void KviClassEditorWindow::saveProperties(KviConfig *cfg)
+void KviClassEditorWindow::saveProperties(KviConfig * pCfg)
{
- m_pEditor->saveProperties(cfg);
+ m_pEditor->saveProperties(pCfg);
}
-void KviClassEditorWindow::loadProperties(KviConfig *cfg)
+void KviClassEditorWindow::loadProperties(KviConfig * pCfg)
{
- m_pEditor->loadProperties(cfg);
+ m_pEditor->loadProperties(pCfg);
}
-KviClassEditorDialog::KviClassEditorDialog(QWidget * pParent, const QString & szName,KviPointerHashTable<QString,KviClassEditorTreeWidgetItem> *pClasses,const QString &szClassName, const QString &szInheritsClassName,bool bRenameMode)
+KviClassEditorDialog::KviClassEditorDialog(QWidget * pParent, const QString & szName, KviPointerHashTable<QString,KviClassEditorTreeWidgetItem> * pClasses, const QString & szClassName, const QString & szInheritsClassName, bool bRenameMode)
: QDialog(pParent)
{
setObjectName(szName);
QGridLayout * pLayout = new QGridLayout(this);
- KviTalHBox * hbox = new KviTalHBox(this);
- hbox->setSpacing(0);
- hbox->setMargin(0);
- pLayout->addWidget(hbox,0,0);
+ KviTalHBox * pHBox = new KviTalHBox(this);
+ pHBox->setSpacing(0);
+ pHBox->setMargin(0);
+ pLayout->addWidget(pHBox,0,0);
- QLabel * pClassNameLabel = new QLabel(hbox);
- pClassNameLabel->setObjectName("classnamelabel");
+ QLabel * pLabel = new QLabel(pHBox);
+ pLabel->setObjectName("classnamelabel");
+ pLabel->setText(__tr2qs_ctx("Please enter the name for the class:","editor"));
- pClassNameLabel->setText(__tr2qs_ctx("Please enter the name for the class:","editor"));
-
- m_pClassNameLineEdit = new QLineEdit(hbox);
+ m_pClassNameLineEdit = new QLineEdit(pHBox);
m_pClassNameLineEdit->setObjectName("classnameineedit");
m_pClassNameLineEdit->setText(szClassName);
- if (!bRenameMode)
+ pLabel->setBuddy(m_pClassNameLineEdit);
+ QRegExp re;
+ if(!bRenameMode)
{
// we allow only [\w:]+ class name
- QRegExp re("[\\w]+");
- QRegExpValidator *pValidator=new QRegExpValidator(re,this);
- m_pClassNameLineEdit->setValidator(pValidator);
- m_pClassNameLineEdit->setObjectName("functionameineedit");
+ re.setPattern("[\\w]+");
m_pClassNameLineEdit->setToolTip(__tr2qs_ctx("Class names can contain only letters, digits and underscores","editor"));
- }
- else
- {
+ } else {
// in editor mode we allow [\w:]+ and namespace separator
- QRegExp re("[\\w]+(::[\\w]+)+");
- QRegExpValidator *pValidator=new QRegExpValidator(re,this);
- m_pClassNameLineEdit->setValidator(pValidator);
- m_pClassNameLineEdit->setObjectName("functionameineedit");
+ re.setPattern("[\\w]+(::[\\w]+)+");
m_pClassNameLineEdit->setToolTip(__tr2qs_ctx("In rename mode class names can contain only letters, digits and underscores and namespaces :: separator","editor"));
}
- hbox = new KviTalHBox(this);
- hbox->setSpacing(0);
- hbox->setMargin(0);
- pLayout->addWidget(hbox,1,0);
+ QRegExpValidator * pValidator = new QRegExpValidator(re,this);
+ m_pClassNameLineEdit->setValidator(pValidator);
+ m_pClassNameLineEdit->setObjectName("functionameineedit");
+
+ pHBox = new KviTalHBox(this);
+ pHBox->setSpacing(0);
+ pHBox->setMargin(0);
+ pLayout->addWidget(pHBox,1,0);
- QLabel * pInheritsClassLabel = new QLabel(hbox);
- pInheritsClassLabel->setObjectName("Inheritsclasslabel");
- pInheritsClassLabel->setText(__tr2qs_ctx("Inherits Class:","editor"));
+ pLabel = new QLabel(pHBox);
+ pLabel->setObjectName("Inheritsclasslabel");
+ pLabel->setText(__tr2qs_ctx("Inherits Class:","editor"));
- m_pInheritsClassComboBox=new QComboBox(hbox);
+ m_pInheritsClassComboBox = new QComboBox(pHBox);
+ pLabel->setBuddy(m_pInheritsClassComboBox);
KviPointerHashTableIterator<QString,KviClassEditorTreeWidgetItem> pClassesIt(*pClasses);
@@ -1820,52 +1943,47 @@ KviClassEditorDialog::KviClassEditorDialog(QWidget * pParent, const QString & sz
KviPointerHashTableIterator<QString,KviKvsObjectClass> pBuiltinClasses(*KviKvsKernel::instance()->objectController()->classDict());
while(pBuiltinClasses.current())
{
- if (pBuiltinClasses.current()->isBuiltin())
+ if(pBuiltinClasses.current()->isBuiltin())
szClasses.append(pBuiltinClasses.currentKey());
++pBuiltinClasses;
}
+ int iCurrentIdx;
szClasses.sort();
- for(int i=0;i<szClasses.count();i++)
+ for(int i=0; i < szClasses.count(); i++)
m_pInheritsClassComboBox->addItem(szClasses.at(i));
- if (!szInheritsClassName.isEmpty())
- {
- int iCurrentIdx=m_pInheritsClassComboBox->findText(szInheritsClassName);
- if (iCurrentIdx==-1) iCurrentIdx=m_pInheritsClassComboBox->findText("object");
- m_pInheritsClassComboBox->setCurrentIndex(iCurrentIdx);
- }
- else
- {
- int iCurrentIdx=m_pInheritsClassComboBox->findText("object");
- m_pInheritsClassComboBox->setCurrentIndex(iCurrentIdx);
+ if(szInheritsClassName.isEmpty())
+ iCurrentIdx = m_pInheritsClassComboBox->findText("object");
+ else {
+ iCurrentIdx = m_pInheritsClassComboBox->findText(szInheritsClassName);
+ if(iCurrentIdx == -1)
+ iCurrentIdx = m_pInheritsClassComboBox->findText("object");
}
+ m_pInheritsClassComboBox->setCurrentIndex(iCurrentIdx);
m_pClassNameLineEdit->setFocus();
+ connect(m_pClassNameLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &)));
+ pHBox = new KviTalHBox(this);
+ pHBox->setSpacing(0);
+ pHBox->setMargin(0);
+ pLayout->addWidget(pHBox,2,0);
- hbox = new KviTalHBox(this);
- hbox->setSpacing(0);
- hbox->setMargin(0);
- pLayout->addWidget(hbox,2,0);
-
- m_pNewClassButton = new QPushButton(hbox);
+ m_pNewClassButton = new QPushButton(pHBox);
m_pNewClassButton->setObjectName("newclassbutton");
- if (!bRenameMode)
- {
+ if(bRenameMode)
+ m_pNewClassButton->setText(__tr2qs_ctx("&Rename Class","editor"));
+ else {
m_pNewClassButton->setText(__tr2qs_ctx("&Create Class","editor"));
m_pNewClassButton->setEnabled(false);
}
- else m_pNewClassButton->setText(__tr2qs_ctx("&Rename Class","editor"));
+ connect(m_pNewClassButton, SIGNAL(clicked()), this, SLOT(accept()));
- QPushButton * pCancelButton = new QPushButton(hbox);
+ QPushButton * pCancelButton = new QPushButton(pHBox);
pCancelButton->setObjectName("cancelButton");
pCancelButton->setText(__tr2qs_ctx("&Cancel","editor"));
-
- setLayout(pLayout);
-
- // signals and slots connections
connect(pCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
- connect(m_pNewClassButton, SIGNAL(clicked()), this, SLOT(accept()));
- connect(m_pClassNameLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &)));
+
+ setLayout(pLayout);
}
KviClassEditorDialog::~KviClassEditorDialog()
@@ -1877,94 +1995,97 @@ void KviClassEditorDialog::textChanged(const QString & szText)
m_pNewClassButton->setEnabled(!szText.isEmpty());
}
-KviClassEditorFunctionDialog::KviClassEditorFunctionDialog(QWidget * pParent, const QString & szName, const QString &szClassName, const QString &szFunctionName, const QString &szReminder,bool bIsInternal, bool bRenameMode)
+KviClassEditorFunctionDialog::KviClassEditorFunctionDialog(QWidget * pParent, const QString & szName, const QString & szClassName, const QString & szFunctionName, const QString & szReminder, bool bIsInternal, bool bRenameMode)
: QDialog(pParent)
{
setObjectName(szName);
QGridLayout * pLayout = new QGridLayout(this);
- KviTalHBox * hbox = new KviTalHBox(this);
- hbox->setSpacing(0);
- hbox->setMargin(0);
- pLayout->addWidget(hbox,0,0);
+ KviTalHBox * pHBox = new KviTalHBox(this);
+ pHBox->setSpacing(0);
+ pHBox->setMargin(0);
+ pLayout->addWidget(pHBox,0,0);
- QLabel * pClassNameLabel = new QLabel(hbox);
- pClassNameLabel->setObjectName("classnamelabel");
- pClassNameLabel->setText("Class: <b>"+szClassName+"</b>");
+ QLabel * pLabel = new QLabel(pHBox);
+ pLabel->setObjectName("classnamelabel");
+ pLabel->setText("Class: <b>"+szClassName+"</b>");
- hbox = new KviTalHBox(this);
- hbox->setSpacing(0);
- hbox->setMargin(0);
- pLayout->addWidget(hbox,1,0);
+ pHBox = new KviTalHBox(this);
+ pHBox->setSpacing(0);
+ pHBox->setMargin(0);
+ pLayout->addWidget(pHBox,1,0);
- QLabel * pFunctionNameLabel = new QLabel(hbox);
- pFunctionNameLabel->setObjectName("functionnamelabel");
- pFunctionNameLabel->setText(__tr2qs_ctx("Please enter the name for the member function:","editor"));
+ pLabel = new QLabel(pHBox);
+ pLabel->setObjectName("functionnamelabel");
+ pLabel->setText(__tr2qs_ctx("Please enter the name for the member function:","editor"));
- m_pFunctionNameLineEdit = new QLineEdit(hbox);
+ m_pFunctionNameLineEdit = new QLineEdit(pHBox);
// we allow only [\w:]+ function name
QRegExp re("[\\w]+");
- QRegExpValidator *pValidator=new QRegExpValidator(re,this);
+ QRegExpValidator * pValidator = new QRegExpValidator(re,this);
m_pFunctionNameLineEdit->setValidator(pValidator);
m_pFunctionNameLineEdit->setObjectName("functionameineedit");
m_pFunctionNameLineEdit->setToolTip(__tr2qs_ctx("Function names can contain only letters, digits and underscores","editor"));
m_pFunctionNameLineEdit->setText(szFunctionName);
+ pLabel->setBuddy(m_pFunctionNameLineEdit);
- hbox = new KviTalHBox(this);
- hbox->setSpacing(0);
- hbox->setMargin(0);
- pLayout->addWidget(hbox,2,0);
-
- QLabel * pReminderLabel = new QLabel(hbox);
- pReminderLabel->setObjectName("reminderlabel");
- pReminderLabel->setWordWrap(1);
- pReminderLabel->setText(__tr2qs_ctx("Please enter the optional reminder string for the member function:","editor"));
+ pHBox = new KviTalHBox(this);
+ pHBox->setSpacing(0);
+ pHBox->setMargin(0);
+ pLayout->addWidget(pHBox,2,0);
- m_pReminderLineEdit = new QLineEdit(hbox);
- m_pReminderLineEdit->setText(szReminder);
+ pLabel = new QLabel(pHBox);
+ pLabel->setObjectName("reminderlabel");
+ pLabel->setWordWrap(1);
+ pLabel->setText(__tr2qs_ctx("Please enter the optional reminder string for the member function:","editor"));
- hbox = new KviTalHBox(this);
- hbox->setSpacing(0);
- hbox->setMargin(0);
- pLayout->addWidget(hbox,3,0);
+ m_pReminderLineEdit = new QLineEdit(pHBox);
+ m_pReminderLineEdit->setText(szReminder);
+ pLabel->setBuddy(m_pReminderLineEdit);
+ pHBox = new KviTalHBox(this);
+ pHBox->setSpacing(0);
+ pHBox->setMargin(0);
+ pLayout->addWidget(pHBox,3,0);
- QLabel * pFunctionInternalLabel = new QLabel(hbox);
- pFunctionInternalLabel->setObjectName("functionnamelabel");
- pFunctionInternalLabel->setText(__tr2qs_ctx("Set as <b>Internal</b> Function: ","editor"));
+ pLabel = new QLabel(pHBox);
+ pLabel->setObjectName("functionnamelabel");
+ pLabel->setText(__tr2qs_ctx("Set as <b>Internal</b> Function: ","editor"));
- m_pInternalCheckBox=new QCheckBox(hbox);
+ m_pInternalCheckBox = new QCheckBox(pHBox);
m_pInternalCheckBox->setChecked(bIsInternal);
m_pFunctionNameLineEdit->setFocus();
- hbox->setAlignment(m_pInternalCheckBox,Qt::AlignLeft);
- hbox->setStretchFactor(m_pInternalCheckBox,70);
- hbox->setStretchFactor(pFunctionInternalLabel,30);
-
+ pLabel->setBuddy(m_pInternalCheckBox);
+ connect(m_pFunctionNameLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &)));
+
+ pHBox->setAlignment(m_pInternalCheckBox,Qt::AlignLeft);
+ pHBox->setStretchFactor(m_pInternalCheckBox,70);
+ pHBox->setStretchFactor(pLabel,30);
- hbox = new KviTalHBox(this);
- hbox->setSpacing(0);
- hbox->setMargin(0);
- pLayout->addWidget(hbox,4,0);
+ pHBox = new KviTalHBox(this);
+ pHBox->setSpacing(0);
+ pHBox->setMargin(0);
+ pLayout->addWidget(pHBox,4,0);
- m_pNewFunctionButton = new QPushButton(hbox);
+ m_pNewFunctionButton = new QPushButton(pHBox);
m_pNewFunctionButton->setObjectName("newfunctionbutton");
- if (!bRenameMode) m_pNewFunctionButton->setText(__tr2qs_ctx("&Add","editor"));
- else m_pNewFunctionButton->setText(__tr2qs_ctx("&Rename","editor"));
+ if(!bRenameMode)
+ m_pNewFunctionButton->setText(__tr2qs_ctx("&Add","editor"));
+ else
+ m_pNewFunctionButton->setText(__tr2qs_ctx("&Rename","editor"));
- if (szFunctionName.isEmpty()) m_pNewFunctionButton->setEnabled(false);
+ if(szFunctionName.isEmpty())
+ m_pNewFunctionButton->setEnabled(false);
+ connect(m_pNewFunctionButton, SIGNAL(clicked()), this, SLOT(accept()));
- QPushButton * pCancelButton = new QPushButton(hbox);
+ QPushButton * pCancelButton = new QPushButton(pHBox);
pCancelButton->setObjectName("cancelButton");
pCancelButton->setText(__tr2qs_ctx("&Cancel","editor"));
+ connect(pCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
setLayout(pLayout);
-
- // signals and slots connections
- connect(pCancelButton, SIGNAL(clicked()), this, SLOT(reject()));
- connect(m_pNewFunctionButton, SIGNAL(clicked()), this, SLOT(accept()));
- connect(m_pFunctionNameLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &)));
}
KviClassEditorFunctionDialog::~KviClassEditorFunctionDialog()