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

List:       kde-commits
Subject:    branches/work/kdevelop/rework_svnplugin
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2007-09-30 22:56:37
Message-ID: 1191192997.271109.14867.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 719336 by apaku:

Implement add action

 M  +1 -1      CMakeLists.txt  
 M  +65 -44    kdevsvnplugin.cpp  
 A             svnaddjob.cpp   [License: LGPL (v2+)]
 A             svnaddjob.h   [License: LGPL (v2+)]
 A             svnaddjob_p.h   [License: LGPL (v2+)]
 M  +1 -1      svncommitjob.cpp  
 M  +1 -1      svnstatusjob.cpp  


--- branches/work/kdevelop/rework_svnplugin/CMakeLists.txt #719335:719336
@@ -38,7 +38,7 @@
     svncommitdialog.cpp
     svnoutputmodel.cpp
     svnoutputdelegate.cpp
-
+    svnaddjob.cpp
 #     svnstatusdialog.cpp
 #     svnview.cpp
 #    svncore.cpp
--- branches/work/kdevelop/rework_svnplugin/kdevsvnplugin.cpp #719335:719336
@@ -31,6 +31,7 @@
 
 #include "svncommitjob.h"
 #include "svnstatusjob.h"
+#include "svnaddjob.h"
 #include "svnoutputdelegate.h"
 #include "svnoutputmodel.h"
 
@@ -99,9 +100,13 @@
     return job;
 }
 
-KDevelop::VcsJob* KDevSvnPlugin::add( const KUrl::List& /*localLocations*/, \
KDevelop::IBasicVersionControl::RecursionMode /*recursion*/ ) +KDevelop::VcsJob* KDevSvnPlugin::add( \
const KUrl::List& localLocations, +                                      \
KDevelop::IBasicVersionControl::RecursionMode recursion )  {
-    return 0;
+    SvnAddJob* job = new SvnAddJob( this );
+    job->setLocations( localLocations );
+    job->setRecursive( ( recursion == KDevelop::IBasicVersionControl::Recursive ) );
+    return job;
 }
 
 KDevelop::VcsJob* KDevSvnPlugin::remove( const KUrl::List& /*localLocations*/ )
@@ -255,55 +260,67 @@
 
 QPair<QString,QList<QAction*> > KDevSvnPlugin::requestContextMenuActions( KDevelop::Context* context )
 {
-    if( context->type() == KDevelop::Context::ProjectItemContext ){
+    if( context->type() == KDevelop::Context::ProjectItemContext )
+    {
         KDevelop::ProjectItemContext *itemCtx = dynamic_cast<KDevelop::ProjectItemContext*>(context);
-        QList<KDevelop::ProjectBaseItem *> baseItemList = itemCtx->items();
+        if( itemCtx )
+        {
+            QList<KDevelop::ProjectBaseItem *> baseItemList = itemCtx->items();
 
-        // hook special case -- just one item was requested for folder context menu.
-//         if( baseItemList.count() == 1 && baseItemList.first()->folder() ){
-//             KDevelop::ProjectFolderItem *folderItem =
-//                     dynamic_cast<KDevelop::ProjectFolderItem*>( baseItemList.first()->folder() );
-//
-//             if( !isVersionControlled( folderItem->url() ) ){
-//                 // checkout only can be done under the non-vcs dir.
-//                 m_ctxUrlList << folderItem->url();
-//                 QList<QAction*> actions;
-//                 QAction *action = new QAction(i18n("Checkout.."), this);
-//                 connect( action, SIGNAL(triggered()), this, SLOT(ctxCheckout()) );
-//                 actions << action;
-//                 return qMakePair( QString("Subversion"), actions );
-//             }
-//         }
+            // hook special case -- just one item was requested for folder context menu.
+    //         if( baseItemList.count() == 1 && baseItemList.first()->folder() ){
+    //             KDevelop::ProjectFolderItem *folderItem =
+    //                     dynamic_cast<KDevelop::ProjectFolderItem*>( baseItemList.first()->folder() );
+    //
+    //             if( !isVersionControlled( folderItem->url() ) ){
+    //                 // checkout only can be done under the non-vcs dir.
+    //                 m_ctxUrlList << folderItem->url();
+    //                 QList<QAction*> actions;
+    //                 QAction *action = new QAction(i18n("Checkout.."), this);
+    //                 connect( action, SIGNAL(triggered()), this, SLOT(ctxCheckout()) );
+    //                 actions << action;
+    //                 return qMakePair( QString("Subversion"), actions );
+    //             }
+    //         }
 
-        // now general case
-        KUrl::List ctxUrlList;
-        foreach( KDevelop::ProjectBaseItem* _item, baseItemList )
-        {
-            if( _item->folder() ){
-                KDevelop::ProjectFolderItem *folderItem = \
                dynamic_cast<KDevelop::ProjectFolderItem*>(_item);
-                ctxUrlList << folderItem->url();
+            // now general case
+            KUrl::List ctxUrlList;
+            foreach( KDevelop::ProjectBaseItem* _item, baseItemList )
+            {
+                if( _item->folder() ){
+                    KDevelop::ProjectFolderItem *folderItem = \
dynamic_cast<KDevelop::ProjectFolderItem*>(_item); +                    ctxUrlList << folderItem->url();
+                }
+                else if( _item->file() ){
+                    KDevelop::ProjectFileItem *fileItem = \
dynamic_cast<KDevelop::ProjectFileItem*>(_item); +                    ctxUrlList << fileItem->url();
+                }
             }
-            else if( _item->file() ){
-                KDevelop::ProjectFileItem *fileItem = dynamic_cast<KDevelop::ProjectFileItem*>(_item);
-                ctxUrlList << fileItem->url();
-            }
-        }
 
-        if( ctxUrlList.isEmpty() )
-            return KDevelop::IPlugin::requestContextMenuActions( context );
+            if( ctxUrlList.isEmpty() )
+                return KDevelop::IPlugin::requestContextMenuActions( context );
 
-        m_ctxUrlList = ctxUrlList;
+            m_ctxUrlList = ctxUrlList;
+        }
+    }else if( context->type() == KDevelop::Context::EditorContext )
+    {
+        KDevelop::EditorContext *itemCtx = dynamic_cast<KDevelop::EditorContext*>(context);
+        m_ctxUrlList << itemCtx->url();
+    }else if( context->type() == KDevelop::Context::FileContext )
+    {
+        KDevelop::FileContext *itemCtx = dynamic_cast<KDevelop::FileContext*>(context);
+        m_ctxUrlList += itemCtx->urls();
+    }
+    QList<QAction*> actions;
+    QAction *action;
 
-        QList<QAction*> actions;
-        QAction *action;
+    action = new QAction(i18n("Commit..."), this);
+    connect( action, SIGNAL(triggered()), this, SLOT(ctxCommit()) );
+    actions << action;
 
-        action = new QAction(i18n("Commit..."), this);
-        connect( action, SIGNAL(triggered()), this, SLOT(ctxCommit()) );
-        actions << action;
-
-//         action = new QAction(i18n("Add to SVN"), this);
-//         connect( action, SIGNAL(triggered()), this, SLOT(ctxAdd()) );
-//         actions << action;
+    action = new QAction(i18n("Add to Repository"), this);
+    connect( action, SIGNAL(triggered()), this, SLOT(ctxAdd()) );
+    actions << action;
 //
 //         action = new QAction(i18n("Remove from SVN"), this);
 //         connect( action, SIGNAL(triggered()), this, SLOT(ctxRemove()) );
@@ -357,8 +374,9 @@
 //         connect( action, SIGNAL(triggered()), this, SLOT(ctxMove()) );
 //         actions << action;
 
+    if( !m_ctxUrlList.isEmpty() )
+    {
         return qMakePair( QString("Subversion"), actions );
-
     }
 
     return KDevelop::IPlugin::requestContextMenuActions( context );
@@ -390,6 +408,9 @@
 }
 void KDevSvnPlugin::ctxAdd()
 {
+    KDevelop::VcsJob* job = add( m_ctxUrlList );
+    job->exec();
+    delete job;
 }
 void KDevSvnPlugin::ctxRemove()
 {
--- branches/work/kdevelop/rework_svnplugin/svncommitjob.cpp #719335:719336
@@ -109,7 +109,7 @@
         svn_revnum_t rev = cli.commit( svn::Targets(targets), ba.data(), recursive(), keepLock() );
     }catch( svn::ClientException clientex )
     {
-        std::cerr << clientex.message() << std::endl;
+        kDebug(9510) << "Couldn't commit:" << QString::fromUtf8( clientex.message() );
         m_success = false;
     }
 }
--- branches/work/kdevelop/rework_svnplugin/svnstatusjob.cpp #719335:719336
@@ -134,7 +134,7 @@
             }
         }catch( svn::ClientException clientex )
         {
-            std::cerr << clientex.message() << std::endl;
+            kDebug(9510) << "Couldn't get status: " << url << QString::fromUtf8( clientex.message() );
             m_success = false;
         }
     }


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

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