[Uml-devel] branches/work/soc-umbrello/umbrello

Andi Fischer andi.fischer at hispeed.ch
Sat Apr 9 07:30:26 UTC 2011


SVN commit 1227456 by fischer:

Integration of code import wizard. Not yet working.

 M  +34 -29    codeimport/classimport.cpp  
 M  +6 -5      codeimport/classimport.h  
 M  +9 -8      codeimport/nativeimportbase.cpp  
 M  +1 -0      umbrelloui.rc  
 M  +18 -2     uml.cpp  
 M  +2 -0      uml.h  


--- branches/work/soc-umbrello/umbrello/codeimport/classimport.cpp #1227455:1227456
@@ -28,44 +28,22 @@
 #endif
 
 /**
- * Import files.
- *
- * @param fileList  List of files to import.
- */
-void ClassImport::importFiles(const QStringList &fileList)
-{
-    initialize();
-    UMLDoc *umldoc = UMLApp::app()->document();
-    uint processedFilesCount = 0;
-    for (QStringList::const_iterator fileIT = fileList.begin();
-            fileIT != fileList.end(); ++fileIT) {
-        QString fileName = (*fileIT);
-        umldoc->writeToStatusBar(i18n("Importing file: %1 Progress: %2/%3",
-                                 fileName, processedFilesCount, fileList.size()));
-        parseFile(fileName);
-        processedFilesCount++;
-    }
-    umldoc->writeToStatusBar(i18nc("ready to status bar", "Ready."));
-}
-
-/**
  * Factory method.
- * @param filename  name of imported file
+ * @param fileName  name of imported file
  * @return the class import object
  */
-ClassImport *ClassImport::createImporterByFileExt(const QString &filename) 
+ClassImport *ClassImport::createImporterByFileExt(const QString &fileName)
 {
     ClassImport *classImporter;
-    if (filename.endsWith(QLatin1String(".idl")))
+    if (fileName.endsWith(QLatin1String(".idl")))
         classImporter = new IDLImport();
-    else if (filename.endsWith(QLatin1String(".py")) ||
-             filename.endsWith(QLatin1String(".pyw")))
+    else if (fileName.contains(QRegExp("\\.pyw?$")))
         classImporter = new PythonImport();
-    else if (filename.endsWith(QLatin1String(".java")))
+    else if (fileName.endsWith(QLatin1String(".java")))
         classImporter = new JavaImport();
-    else if (filename.contains( QRegExp("\\.ad[sba]$") ))
+    else if (fileName.contains(QRegExp("\\.ad[sba]$")))
         classImporter = new AdaImport();
-    else if (filename.endsWith(QLatin1String(".pas")))
+    else if (fileName.endsWith(QLatin1String(".pas")))
         classImporter = new PascalImport();
 #ifndef DISABLE_CPP_IMPORT
     else
@@ -77,3 +55,30 @@
     return classImporter;
 }
 
+/**
+ * Import files.  :TODO: can be deleted
+ * @param fileNames  List of files to import.
+ */
+void ClassImport::importFiles(const QStringList &fileNames)
+{
+    initialize();
+    UMLDoc *umldoc = UMLApp::app()->document();
+    uint processedFilesCount = 0;
+    foreach (const QString& fileName, fileNames) {
+        umldoc->writeToStatusBar(i18n("Importing file: %1 Progress: %2/%3",
+                                 fileName, processedFilesCount, fileNames.size()));
+        parseFile(fileName);
+        processedFilesCount++;
+    }
+    umldoc->writeToStatusBar(i18nc("ready to status bar", "Ready."));
+}
+
+/**
+ * Import files.
+ * @param files  List of files to import.
+ */
+void ClassImport::importFile(const QString& fileName)
+{
+    initialize();
+    parseFile(fileName);
+}
--- branches/work/soc-umbrello/umbrello/codeimport/classimport.h #1227455:1227456
@@ -4,7 +4,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *  copyright (C) 2005-2009                                                *
+ *  copyright (C) 2005-2010                                                *
  *  Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                   *
  ***************************************************************************/
 
@@ -26,9 +26,10 @@
     ClassImport() {}
     virtual ~ClassImport() {}
 
-    void importFiles(const QStringList &files);
+    void importFiles(const QStringList &fileNames);
+    void importFile(const QString& fileName);
 
-    static ClassImport *createImporterByFileExt(const QString &filename);
+    static ClassImport *createImporterByFileExt(const QString &fileName);
 
 protected:
 
@@ -44,9 +45,9 @@
      * Import a single file.
      * To be implemented by inheriting classes.
      *
-     * @param filename  The file to import.
+     * @param fileName  The file to import.
      */
-    virtual void parseFile(const QString& filename) = 0;
+    virtual void parseFile(const QString& fileName) = 0;
 
 };
 
--- branches/work/soc-umbrello/umbrello/codeimport/nativeimportbase.cpp #1227455:1227456
@@ -28,14 +28,14 @@
  * @param singleLineCommentIntro  "//" for IDL and Java, "--" for Ada
  */
 NativeImportBase::NativeImportBase(const QString &singleLineCommentIntro)
+  : m_singleLineCommentIntro(singleLineCommentIntro),
+    m_srcIndex(0),
+    m_scopeIndex(0),  // index 0 is reserved for global scope
+    m_klass(0),
+    m_currentAccess(Uml::Visibility::Public),
+    m_inComment(false),
+    m_isAbstract(false)
 {
-    m_singleLineCommentIntro = singleLineCommentIntro;
-    m_srcIndex = 0;
-    m_scopeIndex = 0;  // index 0 is reserved for global scope
-    m_klass = NULL;
-    m_currentAccess = Uml::Visibility::Public;
-    m_isAbstract = false;
-    m_inComment = false;
 }
 
 /**
@@ -140,7 +140,8 @@
 QString NativeImportBase::advance()
 {
     while (m_srcIndex < m_source.count() - 1) {
-        if (m_source[++m_srcIndex].startsWith(m_singleLineCommentIntro))
+        m_srcIndex++;
+        if (m_source[m_srcIndex].startsWith(m_singleLineCommentIntro))
             m_comment += m_source[m_srcIndex];
         else
             break;
--- branches/work/soc-umbrello/umbrello/umbrelloui.rc #1227455:1227456
@@ -51,6 +51,7 @@
   <Menu name="code"><text>&Code</text>
     <Action name="import_class"/>
     <Action name="import_project"/>
+    <Action name="importing_wizard"/>
     <Action name="generation_wizard"/>
     <Action name="generate_all"/>
     <Menu name="active_lang_menu"><text>Active &Language</text>
--- branches/work/soc-umbrello/umbrello/uml.cpp #1227455:1227456
@@ -37,6 +37,7 @@
 // dialogs
 #include "classwizard.h"
 #include "codegenerationwizard.h"
+#include "codeimportingwizard.h"
 #include "codeviewerdialog.h"
 #include "diagramprintpage.h"
 #include "importprojectdlg.h"
@@ -256,14 +257,19 @@
 
     QAction* preferences = KStandardAction::preferences(this,  SLOT( slotPrefs() ), actionCollection());
 
+    QAction* impWizard = actionCollection()->addAction("importing_wizard");
+    impWizard->setIcon(Icon_Utils::SmallIcon(Icon_Utils::it_Import_Class));
+    impWizard->setText(i18n("NEW Code &Importing Wizard..."));
+    connect(impWizard, SIGNAL( triggered( bool ) ), this, SLOT( importingWizard() ));
+
     QAction* importClasses = actionCollection()->addAction("import_class");
     importClasses->setIcon(Icon_Utils::SmallIcon(Icon_Utils::it_Import_Class));
-    importClasses->setText(i18n("&Import Classes..."));
+    importClasses->setText(i18n("OLD &Import Classes..."));
     connect(importClasses, SIGNAL( triggered( bool ) ), this, SLOT( slotImportClasses() ));
 
     QAction* importProject = actionCollection()->addAction("import_project");
     importProject->setIcon(Icon_Utils::SmallIcon(Icon_Utils::it_Import_Project));
-    importProject->setText(i18n("Import &Project..."));
+    importProject->setText(i18n("OLD Import &Project..."));
     connect(importProject, SIGNAL( triggered( bool ) ), this, SLOT( slotImportProject() ));
 
     QAction* genWizard = actionCollection()->addAction("generation_wizard");
@@ -2316,6 +2322,16 @@
 }
 
 /**
+ * Runs the code importing wizard.
+ */
+void UMLApp::importingWizard()
+{
+    QPointer<CodeImportingWizard> wizard = new CodeImportingWizard();
+    wizard->exec();
+    delete wizard;
+}
+
+/**
  * Class wizard menu selection.
  */
 void UMLApp::slotClassWizard()
--- branches/work/soc-umbrello/umbrello/uml.h #1227455:1227456
@@ -186,6 +186,8 @@
 public slots:
     void slotExecGenerationWizard();
 
+    void importingWizard();
+
     void slotFileNew();
     void slotFileOpen();
     void slotFileOpenRecent(const KUrl& url);




More information about the umbrello-devel mailing list