[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kdevelop/3.4/buildtools/custommakefiles
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2007-02-16 17:00:17
Message-ID: 1171645217.508465.15781.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 634223 by apaku:

Make the recursion optional


 M  +49 -7     customprojectpart.cpp  
 M  +4 -0      customprojectpart.h  


--- branches/kdevelop/3.4/buildtools/custommakefiles/customprojectpart.cpp \
#634222:634223 @@ -224,7 +224,15 @@
             int id = popup->insertItem( i18n( "Remove %1 From Project" ).arg( \
                popupstr ),
                                         this, SLOT( slotRemoveFromProject() ) );
             popup->setWhatsThis( id, i18n( "<b>Remove from project</b><p>Removes \
                current file from the list of files in project. "
-                                           "Note that the file should be manually \
excluded from corresponding makefile or build.xml." ) ); +                    "Note \
that the file should be manually excluded from corresponding makefile or build.xml." \
) ); +            if ( URLUtil::isDirectory( url ) )
+            {
+                int id = popup->insertItem( i18n( "Remove %1 From Project \
(recursive)" ).arg( popupstr ), +                                        this, SLOT( \
slotRemoveFromProjectRecursive() ) ); +                popup->setWhatsThis( id, i18n( \
"<b>Remove from project</b><p>Recursively removes files in the current dir from the \
list of files in project. " +                    "Note that the files should be \
manually excluded from corresponding makefile or build.xml." ) ); +
+            }
         }
         else
         {
@@ -232,7 +240,14 @@
             int id = popup->insertItem( i18n( "Add %1 to Project" ).arg( popupstr ),
                                         this, SLOT( slotAddToProject() ) );
             popup->setWhatsThis( id, i18n( "<b>Add to project</b><p>Adds current \
                file to the list of files in project. "
-                                           "Note that the file should be manually \
added to corresponding makefile or build.xml." ) ); +                        "Note \
that the file should be manually added to corresponding makefile or build.xml." ) ); \
+            if ( URLUtil::isDirectory( url ) ) +            {
+                int id = popup->insertItem( i18n( "Add %1 to Project (recursive)" \
).arg( popupstr ), +                                        this, SLOT( \
slotAddToProjectRecursive() ) ); +                popup->setWhatsThis( id, i18n( \
"<b>Add to project</b><p>Recursivly Adds files in the current dir to the list of \
files in project. " +                        "Note that the files should be manually \
added to corresponding makefile or build.xml." ) ); +            }
         }
     }
     else   // more than one file
@@ -272,16 +287,35 @@
 
 void CustomProjectPart::slotAddToProject()
 {
+    m_recursive = false;
+    m_first_recursive = true;
     addFiles( m_contextAddFiles );
 }
 
 
 void CustomProjectPart::slotRemoveFromProject()
 {
+    m_recursive = false;
+    m_first_recursive = true;
     removeFiles( m_contextRemoveFiles );
 }
 
 
+void CustomProjectPart::slotAddToProjectRecursive()
+{
+    m_recursive = true;
+    addFiles( m_contextAddFiles );
+    m_recursive = false;
+}
+
+
+void CustomProjectPart::slotRemoveFromProjectRecursive()
+{
+    m_recursive = true;
+    removeFiles( m_contextRemoveFiles );
+    m_recursive = false;
+}
+
 void CustomProjectPart::slotChooseActiveDirectory()
 {
     QDomDocument &dom = *projectDom();
@@ -568,13 +602,15 @@
         kdDebug( 9025 ) << "Add file: " << *it << endl;
         if ( QDir::isRelativePath( *it ) )
         {
-            if ( QFileInfo( projectDirectory() + "/" + *it ).isDir() )
+            if ( QFileInfo( projectDirectory() + "/" + *it ).isDir() && ( \
m_recursive || m_first_recursive ) )  {
+                m_first_recursive = false;
                 QStringList subentries = QDir( projectDirectory() + "/" + *it \
                ).entryList();
                 for ( QStringList::iterator subit = subentries.begin(); subit != \
subentries.end(); ++subit )  if ( *subit != "." && *subit != ".." )
                         *subit = QDir::cleanDirPath(( *it ) + "/" + ( *subit ) );
                 addFiles( subentries );
+                m_first_recursive = true;
             }
             else
             {
@@ -584,13 +620,15 @@
         }
         else
         {
-            if ( QFileInfo( *it ).isDir() )
+            if ( QFileInfo( *it ).isDir() && ( m_recursive || m_first_recursive ) )
             {
+                m_first_recursive = false;
                 QStringList subentries = QDir( *it ).entryList();
                 for ( QStringList::iterator subit = subentries.begin(); subit != \
subentries.end(); ++subit )  if ( *subit != "." && *subit != ".." )
                         *subit = QDir::cleanDirPath(( *it ) + "/" + ( *subit ) );
                 addFiles( subentries );
+                m_first_recursive = true;
             }
             else
             {
@@ -599,7 +637,7 @@
             }
         }
     }
-
+    m_first_recursive = false;
     saveProject();
 
     kdDebug( 9025 ) << "Emitting addedFilesToProject" << endl;
@@ -627,13 +665,15 @@
             continue;
         if ( QDir::isRelativePath( *it ) )
         {
-            if ( QFileInfo( projectDirectory() + "/" + *it ).isDir() )
+            if ( QFileInfo( projectDirectory() + "/" + *it ).isDir() && ( \
m_recursive || m_first_recursive ) )  {
+                m_first_recursive = false;
                 QStringList subentries = QDir( projectDirectory() + "/" + *it \
                ).entryList();
                 for ( QStringList::iterator subit = subentries.begin(); subit != \
subentries.end(); ++subit )  if ( *subit != "." && *subit != ".." )
                         *subit = QDir::cleanDirPath(( *it ) + "/" + ( *subit ) );
                 removeFiles( subentries );
+                m_first_recursive = true;
             }
             else
             {
@@ -643,13 +683,15 @@
         }
         else
         {
-            if ( QFileInfo( *it ).isDir() )
+            if ( QFileInfo( *it ).isDir() && ( m_recursive || m_first_recursive ) )
             {
+                m_first_recursive = false;
                 QStringList subentries = QDir( *it ).entryList();
                 for ( QStringList::iterator subit = subentries.begin(); subit != \
subentries.end(); ++subit )  if ( *subit != "." && *subit != ".." )
                         *subit = QDir::cleanDirPath(( *it ) + "/" + ( *subit ) );
                 removeFiles( subentries );
+                m_first_recursive = true;
             }
             else
             {
--- branches/kdevelop/3.4/buildtools/custommakefiles/customprojectpart.h \
#634222:634223 @@ -69,6 +69,8 @@
     void contextMenu( QPopupMenu *popup, const Context *context );
     void slotAddToProject();
     void slotRemoveFromProject();
+    void slotAddToProjectRecursive();
+    void slotRemoveFromProjectRecursive();
     void slotChooseActiveDirectory();
     void slotBuild();
     void slotCompileFile();
@@ -116,6 +118,8 @@
     QMap<QString, int> m_parsedMakefiles;
     QValueStack<QString> m_makefilesToParse;
     QMap<QString, QString> m_makefileVars;
+    bool m_recursive;
+    bool m_first_recursive;
 };
 
 #endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic