diff options
Diffstat (limited to 'src/modules/classeditor')
| -rw-r--r-- | src/modules/classeditor/ClassEditorWindow.cpp | 86 | ||||
| -rw-r--r-- | src/modules/classeditor/ClassEditorWindow.h | 92 |
2 files changed, 89 insertions, 89 deletions
diff --git a/src/modules/classeditor/ClassEditorWindow.cpp b/src/modules/classeditor/ClassEditorWindow.cpp index 8484b267c..cc7c71818 100644 --- a/src/modules/classeditor/ClassEditorWindow.cpp +++ b/src/modules/classeditor/ClassEditorWindow.cpp @@ -102,7 +102,7 @@ ClassEditorTreeWidgetItem::ClassEditorTreeWidgetItem(QTreeWidget * pTreeWidget, m_bInternal = false; m_bClassModified = false; QPixmap * pIcon = 0; - + if(eType == ClassEditorTreeWidgetItem::Namespace) pIcon = g_pIconManager->getSmallIcon(KviIconManager::NameSpace); else @@ -121,14 +121,14 @@ ClassEditorTreeWidgetItem::ClassEditorTreeWidgetItem(ClassEditorTreeWidgetItem * m_iPos = 0; m_bClassModified = false; QPixmap * pIcon = 0; - + if(eType == ClassEditorTreeWidgetItem::Namespace) pIcon = g_pIconManager->getSmallIcon(KviIconManager::NameSpace); else if(eType == ClassEditorTreeWidgetItem::Class) pIcon = g_pIconManager->getSmallIcon(KviIconManager::Class); else pIcon = g_pIconManager->getSmallIcon(KviIconManager::Function); - + setIcon(0,QIcon(*pIcon)); } @@ -136,12 +136,12 @@ void ClassEditorTreeWidgetItem::setClassNotBuilt(bool bModified) { m_bClassModified = bModified; QPixmap * pIcon = 0; - + if(bModified) pIcon = g_pIconManager->getSmallIcon(KviIconManager::ClassNotBuilt); else pIcon = g_pIconManager->getSmallIcon(KviIconManager::Class); - + setIcon(0,QIcon(*pIcon)); } @@ -155,14 +155,14 @@ void ClassEditorTreeWidgetItem::setType(Type eType) { m_eType = eType; QPixmap * pIcon = 0; - + if(eType == ClassEditorTreeWidgetItem::Namespace) pIcon = g_pIconManager->getSmallIcon(KviIconManager::NameSpace); else if(eType == ClassEditorTreeWidgetItem::Class) pIcon = g_pIconManager->getSmallIcon(KviIconManager::Class); else pIcon = g_pIconManager->getSmallIcon(KviIconManager::Function); - + setIcon(0,QIcon(*pIcon)); } @@ -290,7 +290,7 @@ ClassEditorTreeWidgetItem * ClassEditorWidget::findItem(const QString & szFullNa ClassEditorTreeWidgetItem * pItem = findTopLevelItem(lNamespaces.at(0)); if(!pItem) return 0; - + for(int i=1; i < lNamespaces.count(); i++) { bFound = false; @@ -313,7 +313,7 @@ ClassEditorTreeWidgetItem * ClassEditorWidget::createFullItem(const QString & sz { bool bFound; int i; - + QStringList lNamespaces = szFullName.split("::"); if(lNamespaces.count() == 0) return 0; @@ -350,7 +350,7 @@ ClassEditorTreeWidgetItem * ClassEditorWidget::createFullNamespace(const QString { bool bFound; int i; - + QStringList lNamespaces = szFullName.split("::"); if(lNamespaces.count() == 0) return 0; @@ -385,13 +385,13 @@ void ClassEditorWidget::oneTimeSetup() QString szPath; g_pApp->getLocalKvircDirectory(szPath,KviApplication::Classes); QDir d(szPath); - + 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()); - + KviKvsObjectClass * pClass = 0; ClassEditorTreeWidgetItem * pClassItem = 0; while(KviKvsObjectClass * pClass = it.current()) @@ -546,13 +546,13 @@ void ClassEditorWidget::renameFunction() return; } } - + pFunction->setName(szNewFunctionName); pFunction->setReminder(szNewReminder); currentItemChanged(pFunction,pFunction); pFunction->setInternalFunction(bInternal); pParentClass->setClassNotBuilt(true); - + KviPointerList<ClassEditorTreeWidgetItem> lInheritedClasses; lInheritedClasses.setAutoDelete(false); searchInheritedClasses(szClassName,lInheritedClasses); @@ -633,7 +633,7 @@ void ClassEditorWidget::renameClass(ClassEditorTreeWidgetItem * pClassItem) m_pClasses->insert(szNewClassName,pClassItem); pClassItem->setInheritsClass(szNewInheritsClassName); pClassItem->setClassNotBuilt(true); - + KviPointerList<ClassEditorTreeWidgetItem> lInheritedClasses; lInheritedClasses.setAutoDelete(false); searchInheritedClasses(szClassName,lInheritedClasses); @@ -643,7 +643,7 @@ void ClassEditorWidget::renameClass(ClassEditorTreeWidgetItem * pClassItem) lInheritedClasses.at(i)->setExpanded(true); lInheritedClasses.at(i)->setInheritsClass(szNewClassName); } - + if(pNewItem) { activateItem(pNewItem); @@ -652,7 +652,7 @@ void ClassEditorWidget::renameClass(ClassEditorTreeWidgetItem * pClassItem) activateItem(pClassItem); pClassItem->setExpanded(true); } - + qDebug("delete class %s caused by rename",szClassName.toUtf8().data()); KviKvsObjectClass * pClass = KviKvsKernel::instance()->objectController()->lookupClass(szClassName); if(pClass) @@ -773,15 +773,15 @@ void ClassEditorWidget::currentItemChanged(QTreeWidgetItem * pTree, QTreeWidgetI m_pEditor->setEnabled(false); return; } - + ClassEditorTreeWidgetItem * pClassItem = 0; if(m_pLastEditedItem->isMethod()) pClassItem = (ClassEditorTreeWidgetItem *)m_pLastEditedItem->parent(); else pClassItem = m_pLastEditedItem; - + QString szClassName = buildFullClassName(pClassItem); - + if(m_pLastEditedItem->isNamespace()) { QString szLabelText = __tr2qs_ctx("Namespace","editor"); @@ -798,7 +798,7 @@ void ClassEditorWidget::currentItemChanged(QTreeWidgetItem * pTree, QTreeWidgetI m_pTreeWidget->setFocus(); return; } - + QString szLabelText = __tr2qs_ctx("Class","editor"); szLabelText += ": <b>"; szLabelText += szClassName; @@ -826,7 +826,7 @@ void ClassEditorWidget::currentItemChanged(QTreeWidgetItem * pTree, QTreeWidgetI m_pReminderLabel->setText(szReminderText); m_pReminderLabel->show(); } - + m_pFunctionNameLabel->setText(szLabelText); m_pFunctionNameLabel->show(); m_pFunctionNameRenameButton->show(); @@ -846,7 +846,7 @@ void ClassEditorWidget::currentItemChanged(QTreeWidgetItem * pTree, QTreeWidgetI QStringList szFunctionsList; KviPointerHashTable<QString,ClassEditorTreeWidgetItem> lFunctions; lFunctions.setAutoDelete(false); - + ClassEditorTreeWidgetItem * pItem = 0; for(int i=0; i < pTree->childCount(); i++) { @@ -1103,7 +1103,7 @@ void ClassEditorWidget::exportSelected() void ClassEditorWidget::exportSelectionInSinglesFiles(KviPointerList<ClassEditorTreeWidgetItem> * pList) { bool bReplaceAll = false; - + if(!m_szDir.endsWith(QString(KVI_PATH_SEPARATOR))) m_szDir += KVI_PATH_SEPARATOR; if(!pList->first()) @@ -1155,7 +1155,7 @@ void ClassEditorWidget::exportClasses(bool bSelectedOnly, bool bSingleFiles) QString szNameFile; QString szFile; int iCount = 0; - + saveLastEditedItem(); KviPointerList<ClassEditorTreeWidgetItem> list; @@ -1165,13 +1165,13 @@ void ClassEditorWidget::exportClasses(bool bSelectedOnly, bool bSingleFiles) appendSelectedClassItems(&list); else appendAllClassItems(&list); - + if(bSingleFiles) { exportSelectionInSinglesFiles(&list); return; } - + ClassEditorTreeWidgetItem * pTempItem = 0; KviPointerList<ClassEditorTreeWidgetItem> skiplist; skiplist.setAutoDelete(false); @@ -1200,7 +1200,7 @@ void ClassEditorWidget::exportClasses(bool bSelectedOnly, bool bSingleFiles) szOut += "\n"; } } - + if(szOut.isEmpty()) { g_pClassEditorModule->lock(); @@ -1213,7 +1213,7 @@ void ClassEditorWidget::exportClasses(bool bSelectedOnly, bool bSingleFiles) if(!szName.endsWith(QString(KVI_PATH_SEPARATOR))) szName += KVI_PATH_SEPARATOR; - + g_pClassEditorModule->lock(); if(iCount != 1) @@ -1222,7 +1222,7 @@ void ClassEditorWidget::exportClasses(bool bSelectedOnly, bool bSingleFiles) QString szTmp = buildFullClassName(pTempItem); szNameFile = szTmp.replace("::","_"); } - + szName += szNameFile; szName += ".kvs"; if(!KviFileDialog::askForSaveFileName(szFile,__tr2qs_ctx("Choose a Filename - KVIrc","editor"),szName,KVI_FILTER_SCRIPT,false,true,true)) @@ -1321,7 +1321,7 @@ void ClassEditorWidget::removeItemChildren(ClassEditorTreeWidgetItem * pItem, Kv lInheritedClasses.at(u)->setInheritsClass("object"); } } - + while(pItem->childCount() > 0) { ClassEditorTreeWidgetItem * pChild = (ClassEditorTreeWidgetItem *)(pItem->child(0)); @@ -1363,7 +1363,7 @@ bool ClassEditorWidget::removeItem(ClassEditorTreeWidgetItem * pItem, KviPointer { szMsg = QString(__tr2qs_ctx("Do you really want to remove the function \"%1\"?","editor")).arg(szName); } - + g_pClassEditorModule->lock(); 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(); @@ -1577,7 +1577,7 @@ void ClassEditorWidget::newClass() if(szClassName.isEmpty()) return; ClassEditorTreeWidgetItem * pItem = newItem(szClassName,ClassEditorTreeWidgetItem::Class); - + KviQString::escapeKvs(&szClassName, KviQString::EscapeSpace); KviQString::escapeKvs(&szinheritsClassName, KviQString::EscapeSpace); @@ -1606,7 +1606,7 @@ void ClassEditorWidget::newMemberFunction() QString szFunctionName; QString szClassName; QString szReminder; - + if(m_pLastClickedItem->isMethod()) m_pLastClickedItem = (ClassEditorTreeWidgetItem*)m_pLastClickedItem->parent(); szClassName = buildFullClassName(m_pLastClickedItem); @@ -1615,7 +1615,7 @@ void ClassEditorWidget::newMemberFunction() return; if(szFunctionName.isEmpty()) return; - + ClassEditorTreeWidgetItem * pItem = newItem(szFunctionName,ClassEditorTreeWidgetItem::Method); pItem->setInternalFunction(bInternal); if(!szReminder.isEmpty()) @@ -1628,11 +1628,11 @@ ClassEditorTreeWidgetItem * ClassEditorWidget::newItem(QString & szName, ClassEd { if(m_pLastClickedItem) buildFullItemPath(m_pLastClickedItem,szName); - + QString szTmp; if(findItem(szName)) szName.append("1"); - + int iIdx = 2; while(findItem(szName)) { @@ -1940,7 +1940,7 @@ KviClassEditorDialog::KviClassEditorDialog(QWidget * pParent, const QString & sz QRegExpValidator * pValidator = new QRegExpValidator(re,this); m_pClassNameLineEdit->setValidator(pValidator); m_pClassNameLineEdit->setObjectName("functionameineedit"); - + pHBox = new KviTalHBox(this); pHBox->setSpacing(0); pHBox->setMargin(0); @@ -1969,7 +1969,7 @@ KviClassEditorDialog::KviClassEditorDialog(QWidget * pParent, const QString & sz szClasses.append(pBuiltinClasses.currentKey()); ++pBuiltinClasses; } - + int iCurrentIdx; szClasses.sort(); for(int i=0; i < szClasses.count(); i++) @@ -2004,7 +2004,7 @@ KviClassEditorDialog::KviClassEditorDialog(QWidget * pParent, const QString & sz pCancelButton->setObjectName("cancelButton"); pCancelButton->setText(__tr2qs_ctx("&Cancel","editor")); connect(pCancelButton, SIGNAL(clicked()), this, SLOT(reject())); - + setLayout(pLayout); } @@ -2081,7 +2081,7 @@ KviClassEditorFunctionDialog::KviClassEditorFunctionDialog(QWidget * pParent, co m_pFunctionNameLineEdit->setFocus(); 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); @@ -2097,7 +2097,7 @@ KviClassEditorFunctionDialog::KviClassEditorFunctionDialog(QWidget * pParent, co m_pNewFunctionButton->setText(__tr2qs_ctx("&Add","editor")); else m_pNewFunctionButton->setText(__tr2qs_ctx("&Rename","editor")); - + if(szFunctionName.isEmpty()) m_pNewFunctionButton->setEnabled(false); connect(m_pNewFunctionButton, SIGNAL(clicked()), this, SLOT(accept())); diff --git a/src/modules/classeditor/ClassEditorWindow.h b/src/modules/classeditor/ClassEditorWindow.h index d9eca0cb9..3982fe7f1 100644 --- a/src/modules/classeditor/ClassEditorWindow.h +++ b/src/modules/classeditor/ClassEditorWindow.h @@ -66,7 +66,7 @@ public: * \return ClassEditorTreeWidget */ ClassEditorTreeWidget(QWidget * pParent); - + /** * \brief Destroys the tree widget */ @@ -109,7 +109,7 @@ public: * \return ClassEditorTreeWidgetItem */ ClassEditorTreeWidgetItem(QTreeWidget * pTreeWidget, Type eType, const QString & szName); - + /** * \brief Constructs the class editor tree widget item * \param pParentItem The parent tree widget item @@ -118,7 +118,7 @@ public: * \return ClassEditorTreeWidgetItem */ ClassEditorTreeWidgetItem(ClassEditorTreeWidgetItem * pParentItem, Type eType, const QString & szName); - + /** * \brief Destroys the class editor tree widget item */ @@ -139,33 +139,33 @@ public: * \return void */ void setInheritsClass(QString szInheritsClassName){ m_szInheritsClassName = szInheritsClassName; }; - + /** * \brief Returns the class name of the classes we inherit from * \return QString */ QString inheritsClass(){ return m_szInheritsClassName; }; - + /** * \brief Returns the name of the item * \return const QString & */ const QString & name(){ return m_szName; }; - + /** * \brief Sets the name of the item * \param szName The name of the item :P * \return void */ void setName(const QString & szName); - + /** * \brief Sets the list of parameters the function accept * \param szRem The parameters' list * \return void */ void setReminder(const QString & szRem){ m_szReminder = szRem; }; - + /** * \brief Returns the parameters list * \return QString @@ -178,70 +178,70 @@ public: * \return void */ void setClassNotBuilt(bool bModified); - + /** * \brief Returns true if we class is not built yet, false otherwise * \return bool */ bool classNotBuilt(){ return m_bClassModified; }; - + /** * \brief Sets the function as internal * \param bInternal Whether the function is internal or not * \return void */ void setInternalFunction(bool bInternal){ m_bInternal = bInternal; }; - + /** * \brief Returns true if the function is set as internal, false otherwise * \return bool */ bool isInternalFunction(){ return m_bInternal; }; - + /** * \brief Returns the type of the item * \return Type */ Type type(){ return m_eType; }; - + /** * \brief Sets the type of the item * \param eType The type! * \return void */ void setType(Type eType); - + /** * \brief Returns true if the item is a class, false otherwise * \return bool */ bool isClass(){ return m_eType == Class; }; - + /** * \brief Returns true if the item is a namespace, false otherwise * \return bool */ bool isNamespace(){ return m_eType == Namespace; }; - + /** * \brief Returns true if the item is a member function, false otherwise * \return bool */ bool isMethod(){ return m_eType == Method; }; - + /** * \brief Saves the code of the item in a buffer * \param szBuffer The buffer ;) * \return void */ void setBuffer(const QString & szBuffer){ m_szBuffer = szBuffer; }; - + /** * \brief Returns the buffer containing the code of the item * \return const QString & */ const QString & buffer(){ return m_szBuffer; }; - + /** * \brief Returns the cursor's position * \return const int & @@ -270,7 +270,7 @@ public: * \return ClassEditorWidget */ ClassEditorWidget(QWidget * pParent); - + /** * \brief Destroys the class editor object */ @@ -299,32 +299,32 @@ public: * \return void */ virtual void saveProperties(KviConfigurationFile * pCfg); - + /** * \brief Called to load the window properties * \param pCfg The configuration file * \return void */ virtual void loadProperties(KviConfigurationFile * pCfg); - + /** * \brief Builds the class! * \return void */ void build(); - + /** * \brief Saves non-built classes to a file * \return void */ void saveNotBuiltClasses(); - + /** * \brief Loads non-built classes to a file * \return void */ void loadNotBuiltClasses(); - + /** * \brief Searches a function * \param szFunctionName The name of the function @@ -340,14 +340,14 @@ public: * \return void */ void exportClasses(bool bSelectedOnly, bool bSingleFiles = false); - + /** * \brief Exports the current selection to single files * \param pList The list of file to export * \return void */ void exportSelectionInSinglesFiles(KviPointerList<ClassEditorTreeWidgetItem> * pList); - + /** * \brief Removes the item from the tree * \param pItem The item to remove @@ -376,21 +376,21 @@ protected: bool askForNamespaceName(const QString & szAction, const QString & szText, const QString & szInitialText, QString & szNameBuffer); bool askForFunction(QString & szFunctionName, QString & szReminder, bool * pbInternal, const QString & szClassName, bool bRenameMode); void searchInheritedClasses(const QString szClass, KviPointerList<ClassEditorTreeWidgetItem> & lInheritsedClasses); - + /** * \brief Returns true if the class exists, false otherwise * \param szName The name of the class * \return bool */ bool classExists(QString & szName); - + /** * \brief Renames a class * \param pClass The class to rename * \return void */ void renameClass(ClassEditorTreeWidgetItem * pClass); - + /** * \brief Renames a namespace * \param pNamespace The namespace to rename @@ -413,9 +413,9 @@ protected: * \return ClassEditorTreeWidgetItem * */ ClassEditorTreeWidgetItem * findItem(const QString & szName); - - - + + + ClassEditorTreeWidgetItem * findTopLevelItem(const QString & szName); ClassEditorTreeWidgetItem * createFullItemRecursive(QTreeWidgetItem * pCurrent, QStringList & lNameSpaces, int & iLevel, bool bCreateNameSpace = 0); protected slots: @@ -435,13 +435,13 @@ protected slots: void slotFind(); void slotFindWord(const QString &); void searchReplace(const QString & szSearch, bool bReplace = false, const QString & szReplace = "n"); - + /** * \brief Called when we collapse an item * \return void */ void slotCollapseItems(); - + /** * \brief Called when we collapse an item recursively * \param pItem The starting item to collapse @@ -454,7 +454,7 @@ protected slots: * \return void */ void removeSelectedItems(); - + /** * \brief Called when we replace text everywhere * \param szBefore The text before the replace @@ -477,7 +477,7 @@ public: * \return ClassEditorWindow */ ClassEditorWindow(); - + /** * \brief Destroys the class editor window */ @@ -490,21 +490,21 @@ protected: * \return QPixmap * */ virtual QPixmap * myIconPtr(); - + /** * \brief Sets the configuration group name as classeditor * \param szName The name of the group * \return void */ virtual void configGroupName(QString & szName); - + /** * \brief Called to save the window properties * \param pCfg The configuration file * \return void */ virtual void saveProperties(KviConfigurationFile * pCfg); - + /** * \brief Called to load the window properties * \param pCfg The configuration file @@ -517,13 +517,13 @@ protected slots: * \return void */ void cancelClicked(); - + /** * \brief Called when we want to build the class * \return void */ void buildClicked(); - + /** * \brief Called when we want to save the class * \return void @@ -550,7 +550,7 @@ public: * \return KviClassEditorDialog */ KviClassEditorDialog(QWidget * pParent, const QString & szName, KviPointerHashTable<QString,ClassEditorTreeWidgetItem> * pClasses, const QString & szClassName, const QString & szInheritsClassName, bool bRenameMode = false); - + /** * \brief Destroys the class dialog */ @@ -565,7 +565,7 @@ public: * \return QString */ QString className(){ return m_pClassNameLineEdit->text(); }; - + /** * \brief Returns the class name of the parent classes * \return QString @@ -599,7 +599,7 @@ public: * \return KviClassEditorFunctionDialog */ KviClassEditorFunctionDialog(QWidget * pParent, const QString & szName, const QString & szClassName, const QString & szFunctionName, const QString & szReminder, bool bIsInternal, bool bRenameMode = false); - + /** * \brief Destroys the function dialog */ @@ -615,7 +615,7 @@ public: * \return QString */ QString functionName(){ return m_pFunctionNameLineEdit->text(); }; - + /** * \brief Returns the parameters of the function * \return QString |
