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

List:       kde-commits
Subject:    branches/work/attica/ocs
From:       Frederik Gladhorn <gladhorn () kde ! org>
Date:       2009-10-18 19:41:39
Message-ID: 1255894899.701551.8653.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1037333 by gladhorn:

implement new post job, make content creation possible

 M  +2 -0      example/CMakeLists.txt  
 A             example/contentcreation.cpp   [License: GPL (v2+)]
 A             example/contentcreation.h   [License: GPL (v2+)]
 A             example/contentcreation.ui  
 M  +1 -1      example/contentdownload.cpp  
 M  +8 -1      example/mainwindow.cpp  
 M  +1 -0      lib/CMakeLists.txt  
 M  +46 -5     lib/content.cpp  
 M  +27 -3     lib/content.h  
 M  +1 -1      lib/contentparser.cpp  
 A             lib/downloaditem.cpp   [License: LGPL (v2)]
 A             lib/downloaditem.h   [License: GPL (v2+)]
 A             lib/downloaditemparser.cpp   [License: LGPL (v2)]
 A             lib/downloaditemparser.h   [License: GPL (v2+)]
 A             lib/getjob.cpp   [License: GPL (v2+)]
 A             lib/getjob.h   [License: GPL (v2+)]
 A             lib/postjobstatus.cpp   [License: GPL (v2+)]
 A             lib/postjobstatus.h   [License: GPL (v2+)]
 A             lib/postjobstatusparser.cpp   [License: LGPL (v2)]
 A             lib/postjobstatusparser.h   [License: GPL (v2+)]
 M  +18 -15    lib/provider.cpp  
 M  +2 -2      lib/provider.h  
 A             lib/providermanager.cpp   [License: UNKNOWN]
 A             lib/providermanager.h   [License: UNKNOWN]
 M  +3 -1      ocsengine.cpp  


--- branches/work/attica/ocs/example/CMakeLists.txt #1037332:1037333
@@ -8,10 +8,12 @@
     mainwindow.cpp
     simplepersonrequest.cpp
     contentdownload.cpp
+    contentcreation.cpp
 )
 
 kde4_add_ui_files(opencollaborationexample_SRCS
     contentdownload.ui
+    contentcreation.ui
 )
 
 kde4_add_executable(opencollaborationexample ${opencollaborationexample_SRCS})
--- branches/work/attica/ocs/example/contentdownload.cpp #1037332:1037333
@@ -114,7 +114,7 @@
     kDebug() << "selection changed";
     if (selectedItem && qVariantCanConvert<Content>(selectedItem->data(0, \
                Qt::UserRole))) {
         Content c = qvariant_cast<Content>(selectedItem->data(0, Qt::UserRole));
-        ui.person->setText(c.extendedAttribute("personid"));
+        ui.person->setText(c.attribute("personid"));
         ui.score->setText(QString::number(c.rating()));
         ui.numberDownloads->setText(QString::number(c.downloads()));
     }
--- branches/work/attica/ocs/example/mainwindow.cpp #1037332:1037333
@@ -5,13 +5,20 @@
 #include <QVBoxLayout>
 #include "simplepersonrequest.h"
 #include "contentdownload.h"
+#include "contentcreation.h"
+#include "providermanager.h"
 
 MainWindow::MainWindow(QWidget *parent) : KXmlGuiWindow(parent)
 {
-    m_provider = Attica::Provider::createProvider("opendesktop");
+    Attica::ProviderManager pm;
+    m_provider = pm.providerById("opendesktop");
+    //m_provider = Attica::Provider::createProvider("opendesktop");
     
     QTabWidget* mainWidget = new QTabWidget(this);
     setCentralWidget(mainWidget);
+ 
+    ContentCreation* contentCreationWidget = new ContentCreation(m_provider, this);
+    mainWidget->addTab(contentCreationWidget, tr("Add Content"));
        
     ContentDownload* contentWidget = new ContentDownload(m_provider, this);
     mainWidget->addTab(contentWidget, tr("Content"));
--- branches/work/attica/ocs/lib/CMakeLists.txt #1037332:1037333
@@ -11,6 +11,7 @@
    personparser.cpp
    personjob.cpp
    provider.cpp
+   providermanager.cpp
    postjob.cpp
    postjobstatus.cpp
    postjobstatusparser.cpp
--- branches/work/attica/ocs/lib/content.cpp #1037332:1037333
@@ -126,22 +126,63 @@
   return d->m_updated;
 }
 
-void Content::addExtendedAttribute( const QString &key, const QString &value )
+void Content::addAttribute( const QString &key, const QString &value )
 {
   d->m_extendedAttributes.insert( key, value );
 }
 
-QString Content::extendedAttribute( const QString &key ) const
+QString Content::attribute( const QString &key ) const
 {
   return d->m_extendedAttributes.value( key );
 }
 
-QMap<QString,QString> Content::extendedAttributes() const
+QMap<QString,QString> Content::attributes() const
 {
   return d->m_extendedAttributes;
 }
 
-
-bool Content::isValid() const {
+bool Content::isValid() const
+{
   return !(d->m_id.isEmpty());
 }
+
+QString Content::description() const
+{
+    return attribute("description");
+}
+
+QString Attica::Content::changelog() const
+{
+    return attribute("changelog");
+
+}
+
+QString Attica::Content::depend() const
+{
+    return attribute("depend");
+}
+
+Attica::DownloadUrlDescription Attica::Content::downloadUrlDescription(int number)
+{
+    QString num(QString::number(number));
+    DownloadUrlDescription desc;
+    
+    desc.isDownloadtypLink = true;
+    if (number == 1 && attribute("downloadtyp1") == "0") {
+        desc.isDownloadtypLink = false;
+    }
+
+    desc.distributionType = attribute("downloaddistributiontype" + num);
+    desc.name = name();
+    desc.hasPrice = attribute("downloadbuy" + num) == "1";
+    desc.link = attribute("downloadlink" + num);
+    desc.priceReason = attribute("downloadbuyreason" + num) == "1";
+    desc.priceAmount = attribute("downloadbuyprice" + num) == "1";
+    
+    return desc;
+}
+
+QString Attica::Content::version() const
+{
+    return attribute("version");
+}
--- branches/work/attica/ocs/lib/content.h #1037332:1037333
@@ -22,6 +22,7 @@
 #define ATTICA_CONTENT_H
 
 #include <QtCore/QList>
+#include <QtCore/QString>
 #include <QtCore/QMap>
 #include <QtCore/QSharedDataPointer>
 
@@ -32,6 +33,17 @@
 
 namespace Attica {
 
+    struct DownloadUrlDescription {
+        bool isDownloadtypLink;
+        QString category;
+        QString name;
+        QString link;
+        QString distributionType;
+        bool hasPrice;
+        QString priceReason;
+        QString priceAmount;
+    };
+
 /**
  * Represents a single content
  */
@@ -138,27 +150,39 @@
      */
     QDateTime updated() const;
 
+    QString description() const;
+
+    QString changelog() const;
+    QString version() const;
+    QString depend() const;
+    DownloadUrlDescription downloadUrlDescription(int number);
+
+
+    
     /**
      * Add an attribute that is not included in the basis set of attributes exposed \
                by the Content class.
      * If the attribute already exists it gets overwritten.
      * @param key the key of the attribute
      * @param value the value of the attribute
      */
-    void addExtendedAttribute( const QString &key, const QString &value );
+    void addAttribute( const QString &key, const QString &value );
 
     /**
      * Get an attribute that is not included in the basis set of attributes exposed \
                by the Content class.
      * @param key the key of the attribute
      * @return the value of the attribute with the specified key, or an empty \
                string, if the key has not been found
      */
-    QString extendedAttribute( const QString &key ) const;
+    QString attribute( const QString &key ) const;
 
     /**
      * Get all attributes that are not included in the basis set of attributes \
                exposed by the Content class.
      * @return the attribute mappings
      */
-    QMap<QString,QString> extendedAttributes() const;
+    QMap<QString,QString> attributes() const;
 
+
+    
+    
     /**
      * Checks whether this Content has an id
      * @return @c true if an id has been set, @c false otherwise
--- branches/work/attica/ocs/lib/contentparser.cpp #1037332:1037333
@@ -88,7 +88,7 @@
         content.setUpdated( QDateTime::fromString( xml.readElementText(),
           Qt::ISODate ) );
       } else {
-        content.addExtendedAttribute( xml.name().toString(),
+        content.addAttribute( xml.name().toString(),
           xml.readElementText() );
       }
     }
--- branches/work/attica/ocs/lib/provider.cpp #1037332:1037333
@@ -79,12 +79,11 @@
 };
 
 
-Provider Provider::createProvider(const QString& id)
+QList<Provider> Provider::createProviders()
 {
-    if (id == "opendesktop") {
-        return Provider(id, QUrl("https://api.opendesktop.org/v1/"), \
                "OpenDesktop.org");
-    }
-    return Provider();
+    QList<Provider> providers;
+    providers << Provider("opendesktop", QUrl("https://api.opendesktop.org/v1/"), \
"OpenDesktop.org"); +    return providers;
 }
 
 
@@ -365,17 +364,21 @@
   return job;
 }
 
-PostJob* Provider::addNewContent(const Category& category, const Content& \
newContent) +PostJob* Provider::addNewContent(const Category& category, const \
Content& cont)  {
-  if (!category.isValid() || !newContent.isValid()) {
-    return 0;
-  }
-  
-  QString cat = category.id();
-  
-  
-  // FIXME
-  return 0;
+    if (!category.isValid()) {
+        return 0;
+    }
+
+    QUrl url = createUrl("content/add");
+    StringMap pars(cont.attributes());
+    
+    pars.insert("type", category.id());
+    pars.insert("name", cont.name());
+    
+    qDebug() << "Parameter map: " << pars;
+    
+    return new PostJob(d->m_qnam, createRequest(url), pars);
 }
 
 
--- branches/work/attica/ocs/lib/provider.h #1037332:1037333
@@ -82,7 +82,7 @@
         Downloads
     };
 
-    static Provider createProvider(const QString& id);
+    static QList<Provider> createProviders();
 
     // Person part of OCS
 
@@ -180,7 +180,7 @@
     Provider(const QString& id, const QUrl& baseUrl, const QString& name);
 
     // TODO remove
-    friend class ProviderInitJob;
+    friend class ProviderManager;
 };
 }
 
--- branches/work/attica/ocs/ocsengine.cpp #1037332:1037333
@@ -31,6 +31,7 @@
 
 #include <plasma/datacontainer.h>
 #include <postjobstatus.h>
+#include <providermanager.h>
 
 
 
@@ -580,7 +581,8 @@
 
 void OcsEngine::initializeProvider()
 {
-    m_provider = Provider::createProvider("opendesktop");
+    ProviderManager pm;
+    m_provider = pm.providerById("opendesktop");
     m_providers.insert("opendesktop", QSharedPointer<Provider>(new \
Provider(m_provider)));  m_providerInitialized = true;
 


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

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