Index: cppnewclassdlg.cpp
===================================================================
RCS file: /home/kde/kdevelop/languages/cpp/cppnewclassdlg.cpp,v
retrieving revision 1.48
diff -u -3 -p -r1.48 cppnewclassdlg.cpp
--- cppnewclassdlg.cpp	5 Aug 2003 21:41:46 -0000	1.48
+++ cppnewclassdlg.cpp	8 Oct 2003 00:37:36 -0000
@@ -103,22 +103,91 @@ CppNewClassDialog::CppNewClassDialog(KDe
     overMenu->insertItem(i18n("Replace Base Class Method"),
         this, SLOT(replaceFunctionality()), 0, 12);
 
-    comp = basename_edit->completionObject();
-    setCompletion(m_part->codeModel());
+    compBasename = basename_edit->completionObject();
+    setCompletionBasename(m_part->codeModel());
+    compNamespace = namespace_edit->completionObject();
+    setCompletionNamespaceRecursive(m_part->codeModel()->globalNamespace());
     classname_edit->setFocus();
 }
 
 
 CppNewClassDialog::~CppNewClassDialog()
 {
-    delete comp;
+    delete compBasename;
+    delete compNamespace;
 }
 
-void CppNewClassDialog::setCompletion(CodeModel *model)
+void CppNewClassDialog::setCompletionBasename(CodeModel *model)
 {
-    QStringList classNames = sortedNameList( model->globalNamespace()->classList() );
-    for (QStringList::const_iterator it = classNames.begin(); it != classNames.end(); ++it)
-        comp->addItem(*it);
+    compBasename->clear();
+  
+    // Import selected namespace without qualifier
+    NamespaceDom namespaceDom = model->globalNamespace();
+    
+    QStringList::const_iterator it = currNamespace.begin();
+    for ( ; it != currNamespace.end() ; ++it ) {
+	if( ! namespaceDom->hasNamespace(*it) )
+	    break;
+	namespaceDom = namespaceDom->namespaceByName(*it);
+    }
+    
+    if(it == currNamespace.end())
+	// complete namespace has been found (not breaked)
+	compBasename->insertItems(sortedNameList( namespaceDom -> classList() ));
+    
+    addCompletionBasenameNamespacesRecursive(model->globalNamespace());
+    
+    QStringList compItems = compBasename->items();
+    it = compItems.begin();
+    for(int i=0;
+	it != compItems.end(); ++it, ++i) 
+	kdDebug(9007) << "compBasename->items()[" << i << "] = \"" << *it << "\"" << endl;
+ }
+
+void CppNewClassDialog::addCompletionBasenameNamespacesRecursive(const NamespaceDom & namespaceDom,
+								 const QString & namespaceParent = "")
+{
+    // Add classes of this namespace
+    QStringList classList = sortedNameList( namespaceDom -> classList() );
+    
+    if(! namespaceParent.isEmpty() ) {
+	classList.gres( QRegExp("^"), namespaceParent + "::" );
+    }
+    
+    compBasename -> insertItems(classList);
+    
+    
+    // Recursion
+    NamespaceList namespaceList = namespaceDom->namespaceList();
+    NamespaceList::const_iterator it = namespaceList.begin();
+    
+    for( ; it != namespaceList.end() ; ++it ) {
+	QString fullNamespace;
+	
+	if(! namespaceParent.isEmpty() ) 
+	    fullNamespace = namespaceParent+"::";
+	
+	fullNamespace += (*it) -> name();
+	addCompletionBasenameNamespacesRecursive( *it, fullNamespace );
+    }
+}
+
+
+void CppNewClassDialog::setCompletionNamespaceRecursive( const NamespaceDom & namespaceDom, const QString & namespaceParent )
+{
+    NamespaceList namespaceList = namespaceDom->namespaceList();
+    NamespaceList::const_iterator it = namespaceList.begin();
+    for( ; it != namespaceList.end() ; ++it ) {
+	QString fullNamespace;
+	
+	if(! namespaceParent.isEmpty() )
+	    fullNamespace = namespaceParent+"::";
+	
+	fullNamespace += (*it) -> name();
+	kdDebug(9007) << "compNamespace -> addItem( \"" << fullNamespace << "\" )" << endl;
+	compNamespace -> addItem( fullNamespace );
+	setCompletionNamespaceRecursive( *it, fullNamespace );
+    }
 }
 
 void CppNewClassDialog::nameHandlerChanged(const QString &text)
@@ -168,11 +237,23 @@ void CppNewClassDialog::classNameChanged
     }
 }
 
+void CppNewClassDialog::classNamespaceChanged(const QString &text)
+{  
+    currNamespace = QStringList::split(QString("::"), text);
+    setCompletionBasename(m_part -> codeModel());
+    reloadAdvancedInheritance(true);
+}
+
 void CppNewClassDialog::baseclassname_changed(const QString &text)
 {
     if ( (basename_edit->hasFocus()) && (!baseincludeModified) ) {
-        QString header = text + interface_suffix;
-        switch( gen_config->superCase() )
+        QString header = text;
+	if (header.contains(QRegExp("::")))
+	  header = header.mid(header.findRev(QRegExp("::"))+2);
+        header = header.replace(QRegExp(" *<.*>"), "");
+	header += interface_suffix;
+	
+	switch( gen_config->superCase() )
         {
             case ClassGeneratorConfig::LowerCase:
                 header = header.lower();
@@ -182,9 +263,7 @@ void CppNewClassDialog::baseclassname_ch
                 break;
             default:;
         }
-        if (header.contains(QRegExp("::")))
-            header = header.left(header.find(QRegExp("::"))) + interface_suffix;
-        header = header.replace(QRegExp(" *<.*>"), "");
+	
         baseinclude_edit->setText(header);
     }
 }
@@ -403,6 +482,10 @@ void CppNewClassDialog::remBaseClassOnly
 
 void CppNewClassDialog::remClassFromAdv(QString text)
 {
+    // Strip off namespace qualification
+    if(text.contains("::"))
+        text = text.mid(text.findRev("::")+2);
+     
     removeTemplateParams(text);
     QListViewItem *it = 0;
     if ((it = access_view->findItem(text, 0)))
@@ -657,9 +740,9 @@ void CppNewClassDialog::newTabSelected(Q
 }
 
 
-void CppNewClassDialog::reloadAdvancedInheritance(bool /*clean*/)
+void CppNewClassDialog::reloadAdvancedInheritance(bool clean)
 {
-/*    clearConstructorsList(clean);
+    clearConstructorsList(clean);
     clearMethodsList(clean);
     clearUpgradeList(clean);
 
@@ -671,14 +754,52 @@ void CppNewClassDialog::reloadAdvancedIn
             parseClass(it.current()->text(0), it.current()->text(1));
         }
         ++it;
-    }*/
+    }
 }
 
 void CppNewClassDialog::parseClass(QString clName, QString inheritance)
 {
+    // Determine namespace
+    QStringList clNamespace = currNamespace;
+    bool clFullQualified = false;
+    
+    if(clName.contains("::")) {
+	// Full qualified, override imported namespace
+	clFullQualified = true;
+	int splitpoint = clName.findRev("::");
+	clNamespace = QStringList::split("::", clName.left(splitpoint));
+	clName = clName.mid(splitpoint + 2);
+    }
+  
+    kdDebug(9007) << "clFullQualified = " << clFullQualified << endl;
+    kdDebug(9007) << "clName = " << clName << endl;
+    QString debMsg = "clNamespace = ";
+    for(QStringList::const_iterator it = clNamespace.begin();
+	it != clNamespace.end(); ++it)
+	debMsg += (*it) + "::";
+    kdDebug(9007) << debMsg << endl;
+  
     QString templateAdd = templateActualParamsFormatted(clName);
     removeTemplateParams(clName);
-    ClassList myClasses = m_part->codeModel()->globalNamespace()->classByName(clName);
+
+    ClassList myClasses; // = m_part->codeModel()->globalNamespace()->classByName(clName);
+
+    NamespaceDom namespaceDom = m_part->codeModel()->globalNamespace();
+
+    QStringList::const_iterator namespaceIt = clNamespace.begin();
+    for( ; namespaceIt != clNamespace.end(); ++namespaceIt) {
+	if (! namespaceDom -> hasNamespace(*namespaceIt))
+	    break;
+	namespaceDom = namespaceDom->namespaceByName(*namespaceIt);
+    }
+    if (namespaceIt == clNamespace.end()) {
+	// Found specified namespace
+	myClasses = namespaceDom->classByName(clName);
+	// Fall back to global namespace if class was not fully qualified and is not found in selected namespace
+	if( myClasses.empty() && ! clFullQualified )
+	    myClasses = m_part -> codeModel() -> globalNamespace() -> classByName(clName);
+    }
+    
     for (ClassList::const_iterator classIt = myClasses.begin(); classIt != myClasses.end(); ++classIt)
     {
         PCheckListItem<ClassDom> *it = new PCheckListItem<ClassDom>(*classIt, constructors_view, (*classIt)->name());
@@ -702,10 +823,10 @@ void CppNewClassDialog::parseClass(QStri
             }
             else if ((*methodIt)->isSlot())
             {
-                addToMethodsList(over_slots, *methodIt);
-
                 if ((*methodIt)->access() != CodeModelItem::Private)
                 {
+		    addToMethodsList(over_slots, *methodIt);
+
                     QString inhModifier;
                     //protected inheritance gives protected attributes
                     if (inheritance.contains("protected")) inhModifier = "protected";
@@ -718,12 +839,11 @@ void CppNewClassDialog::parseClass(QStri
             }
             else
             {
-                if (!isDestructor((*classIt)->name(), *methodIt))
-                    addToMethodsList(over_methods, *methodIt);
-
                 // display only public and protected methods of the base class
                 if ( (!isDestructor((*classIt)->name(), *methodIt)) && ((*methodIt)->access() != CodeModelItem::Private) )
                 {
+                    addToMethodsList(over_methods, *methodIt);
+		    
                     // see what modifier is given for the base class
                     QString inhModifier;
                     //protected inheritance gives protected methods
@@ -866,7 +986,7 @@ void CppNewClassDialog::setAccessForBase
                 if ( (curr = dynamic_cast<PListViewItem<VariableDom>* >(it.current())) )
                     setAccessForItem(curr, newAccess, curr->item()->access() == CodeModelItem::Public);
                 else if ( (curr_m = dynamic_cast<PListViewItem<FunctionDom>* >(it.current())) )
-                    setAccessForItem(curr_m, newAccess, curr->item()->access() == CodeModelItem::Public);
+                    setAccessForItem(curr_m, newAccess, curr_m->item()->access() == CodeModelItem::Public);
             }
             ++it;
         }
Index: cppnewclassdlg.h
===================================================================
RCS file: /home/kde/kdevelop/languages/cpp/cppnewclassdlg.h,v
retrieving revision 1.16
diff -u -3 -p -r1.16 cppnewclassdlg.h
--- cppnewclassdlg.h	12 Sep 2003 20:44:28 -0000	1.16
+++ cppnewclassdlg.h	8 Oct 2003 00:37:36 -0000
@@ -106,6 +106,7 @@ public:
 protected:
     virtual void accept();
     virtual void classNameChanged(const QString &text);
+    virtual void classNamespaceChanged(const QString &text);
     virtual void headerChanged();
     virtual void implementationChanged();
     virtual void nameHandlerChanged(const QString &text);
@@ -173,11 +174,15 @@ private:
     QString implementation_url;
     QString interface_suffix;
     QString implementation_suffix;
+    QStringList currNamespace;
     bool lowercase_filenames;
     QStringList currBaseClasses;
-    KCompletion * comp;
+    KCompletion * compBasename;
+    KCompletion * compNamespace;
 
-    void setCompletion(CodeModel *model);
+    void setCompletionBasename(CodeModel *model);
+    void addCompletionBasenameNamespacesRecursive(const NamespaceDom & namespaceDom, const QString & namespaceParent = "");
+    void setCompletionNamespaceRecursive(const NamespaceDom & namespaceDom, const QString & namespaceParent = "");
     void setStateOfInheritanceEditors(bool state, bool hideList = true);
     void setAccessForBase(QString baseclass, QString newAccess);
     void setAccessForItem(QListViewItem *curr, QString newAccess, bool isPublic);
Index: cppnewclassdlgbase.ui
===================================================================
RCS file: /home/kde/kdevelop/languages/cpp/cppnewclassdlgbase.ui,v
retrieving revision 1.28
diff -u -3 -p -r1.28 cppnewclassdlgbase.ui
--- cppnewclassdlgbase.ui	14 Sep 2003 17:06:50 -0000	1.28
+++ cppnewclassdlgbase.ui	8 Oct 2003 00:37:36 -0000
@@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
 <class>CppNewClassDialogBase</class>
 <widget class="QDialog">
     <property name="name">
@@ -205,7 +205,7 @@ template &lt;params&gt; classname</strin
                                     <cstring>namespace_edit</cstring>
                                 </property>
                             </widget>
-                            <widget class="QLineEdit">
+                            <widget class="KLineEdit">
                                 <property name="name">
                                     <cstring>namespace_edit</cstring>
                                 </property>
@@ -1219,6 +1219,12 @@ Namespace1::Namespace2::...::NamespaceN<
         <receiver>CppNewClassDlgBase</receiver>
         <slot>scopeboxActivated(int)</slot>
     </connection>
+    <connection>
+        <sender>namespace_edit</sender>
+        <signal>textChanged(const QString&amp;)</signal>
+        <receiver>CppNewClassDlgBase</receiver>
+        <slot>classNamespaceChanged(const QString&amp;)</slot>
+    </connection>
 </connections>
 <tabstops>
     <tabstop>classname_edit</tabstop>
@@ -1263,27 +1269,27 @@ Namespace1::Namespace2::...::NamespaceN<
 <slots>
     <slot access="protected">updateClassStore()</slot>
     <slot access="protected">access_view_mouseButtonPressed( int button, QListViewItem * item, const QPoint &amp; p, int c )</slot>
-    <slot access="protected">classNameChanged(const QString &amp;text)</slot>
+    <slot access="protected">classNameChanged( const QString &amp; text )</slot>
     <slot access="protected">headerChanged()</slot>
     <slot access="protected">implementationChanged()</slot>
-    <slot access="protected">nameHandlerChanged(const QString &amp;text)</slot>
+    <slot access="protected">nameHandlerChanged( const QString &amp; text )</slot>
     <slot access="protected">addBaseClass()</slot>
     <slot access="protected">remBaseClass()</slot>
-    <slot access="protected">currBaseNameChanged(const QString &amp;text)</slot>
+    <slot access="protected">currBaseNameChanged( const QString &amp; text )</slot>
     <slot access="protected">currBasePrivateSet()</slot>
     <slot access="protected">currBaseProtectedSet()</slot>
     <slot access="protected">currBasePublicSet()</slot>
-    <slot access="protected">currBaseVirtualChanged(int val)</slot>
-    <slot access="protected">currBaseSelected(QListViewItem *it)</slot>
-    <slot access="protected">checkObjCInheritance(int val)</slot>
-    <slot access="protected">checkQWidgetInheritance(int val)</slot>
-    <slot access="protected">newTabSelected(const QString &amp;text)</slot>
+    <slot access="protected">currBaseVirtualChanged( int val )</slot>
+    <slot access="protected">currBaseSelected( QListViewItem * it )</slot>
+    <slot access="protected">checkObjCInheritance( int val )</slot>
+    <slot access="protected">checkQWidgetInheritance( int val )</slot>
+    <slot access="protected">newTabSelected( const QString &amp; text )</slot>
     <slot access="protected">changeToPrivate()</slot>
     <slot access="protected">changeToProtected()</slot>
     <slot access="protected">changeToPublic()</slot>
     <slot access="protected">changeToInherited()</slot>
-    <slot access="protected">methods_view_mouseButtonPressed(int,QListViewItem*,const QPoint&amp;,int)</slot>
-    <slot access="protected">newTabSelected(QWidget *w)</slot>
+    <slot access="protected">methods_view_mouseButtonPressed( int, QListViewItem *, const QPoint &amp;, int )</slot>
+    <slot access="protected">newTabSelected( QWidget * w )</slot>
     <slot access="protected">extendFunctionality()</slot>
     <slot access="protected">replaceFunctionality()</slot>
     <slot access="protected">to_constructors_list_clicked()</slot>
@@ -1294,12 +1300,13 @@ Namespace1::Namespace2::...::NamespaceN<
     <slot access="protected">upbaseclass_button_clicked()</slot>
     <slot access="protected">downbaseclass_button_clicked()</slot>
     <slot access="protected">baseclasses_view_selectionChanged()</slot>
-    <slot access="protected">gtk_box_stateChanged(int)</slot>
-    <slot access="protected">qobject_box_stateChanged(int)</slot>
+    <slot access="protected">gtk_box_stateChanged( int )</slot>
+    <slot access="protected">qobject_box_stateChanged( int )</slot>
     <slot access="protected">selectall_button_clicked()</slot>
-    <slot access="protected">baseclassname_changed(const QString&amp;)</slot>
-    <slot access="protected">baseIncludeChanged(const QString&amp;)</slot>
-    <slot access="protected">scopeboxActivated(int)</slot>
+    <slot access="protected">baseclassname_changed( const QString &amp; )</slot>
+    <slot access="protected">baseIncludeChanged( const QString &amp; )</slot>
+    <slot access="protected">scopeboxActivated( int )</slot>
+    <slot access="protected">classNamespaceChanged( const QString &amp; )</slot>
 </slots>
 <layoutdefaults spacing="6" margin="11"/>
 <layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>





