Jump to content

IUP ISI/MediaWiki-Silk/coding-style: Difference between revisions

From KDE Community Wiki
No edit summary
Alexandre (talk | contribs)
 
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Introduction =
For the coding style we follow the [http://techbase.kde.org/Policies/Kdelibs_Coding_Style kdelibs coding style].
Artistic Style (astyle) automatic code formatting:
<code c>
astyle --indent=spaces=4 --brackets=linux \
      --indent-labels --pad-oper --unpad-paren \
      --one-line=keep-statements --convert-tabs \
      --indent-preprocessor \
      `find -type f -name '*.cpp'` `find -type f -name '*.cc'` `find -type f -name '*.h'`
</code>
= Class type to return attributes =
= Class type to return attributes =


== attribute.h ==
== attribute.h ==
 
<code cpp>
/*
/*
*  Copyright 2010 by XXXX XXXX <[email protected]>
*  Copyright 2010 by XXXX XXXX <[email protected]>
*
*
*  This program is free software; you can redistribute it and/or modify
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU Library General Public License as
*  it under the terms of the GNU Library General Public License as
*  published by the Free Software Foundation; either version 2, or
*  published by the Free Software Foundation; either version 2, or
*  (at your option) any later version.
*  (at your option) any later version.
*
*
*  This program is distributed in the hope that it will be useful,
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details
*  GNU General Public License for more details
*
*
*  You should have received a copy of the GNU Library General Public
*  You should have received a copy of the GNU Library General Public
*  License along with this program; if not, write to the
*  License along with this program; if not, write to the
*  Free Software Foundation, Inc.,
*  Free Software Foundation, Inc.,
*  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
*/


<nowiki>#</nowiki>ifndef ATTRIBUTE_H
#ifndef ATTRIBUTE_H


<nowiki>#</nowiki>define ATTRIBUTE_H
#define ATTRIBUTE_H


<nowiki>#</nowiki>include <QtCore/QObject>
#include <QtCore/QObject>


<nowiki>#</nowiki>include <kdemacros.h>
#include <kdemacros.h>


class MediaWiki;
class MediaWiki;
Line 43: Line 56:
         @param parent
         @param parent
     */
     */
     explicit Attribute( MediaWiki const & media, /*Put attributes here*/ QObject * parent = 0 );
     explicit Attribute(MediaWiki const & media, /*Put attributes here*/ QObject * parent = 0);


     /**
     /**
Line 56: Line 69:
         @param success true if the request was completed successfully.
         @param success true if the request was completed successfully.
     */
     */
     void finished( bool );
     void finished(bool);


public slots:
public slots:
Line 71: Line 84:
         @param reply
         @param reply
     */
     */
     void onFinished( QNetworkReply *reply );
     void onFinished(QNetworkReply *reply);


private:
private:
Line 78: Line 91:
};
};


<nowiki>#</nowiki>endif // ATTRIBUTE_H
#endif // ATTRIBUTE_H
 
</code>
== attribute.cpp ==
== attribute.cpp ==
 
<code cpp>
/*
/*
*  Copyright 2010 by XXXX XXXX <[email protected]>
*  Copyright 2010 by XXXX XXXX <[email protected]>
*
*
*  This program is free software; you can redistribute it and/or modify
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU Library General Public License as
*  it under the terms of the GNU Library General Public License as
*  published by the Free Software Foundation; either version 2, or
*  published by the Free Software Foundation; either version 2, or
*  (at your option) any later version.
*  (at your option) any later version.
*
*
*  This program is distributed in the hope that it will be useful,
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details
*  GNU General Public License for more details
*
*
*  You should have received a copy of the GNU Library General Public
*  You should have received a copy of the GNU Library General Public
*  License along with this program; if not, write to the
*  License along with this program; if not, write to the
*  Free Software Foundation, Inc.,
*  Free Software Foundation, Inc.,
*  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
*/


<nowiki>#</nowiki>include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkAccessManager>


<nowiki>#</nowiki>include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkRequest>


<nowiki>#</nowiki>include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkReply>


<nowiki>#</nowiki>include <QtCore/QXmlStreamReader>
#include <QtCore/QXmlStreamReader>


<nowiki>#</nowiki>include <QtCore/QTimer>
#include <QtCore/QTimer>


<nowiki>#</nowiki>include <QtCore/QDebug>
#include <QtCore/QDebug>


<nowiki>#</nowiki>include "attribute.h"
#include "attribute.h"
#include "mediawiki.h"


struct AttributePrivate
struct AttributePrivate {
{
     QNetworkAccessManager *manager;
     QNetworkAccessManager *manager;
     QNetworkReply *reply;
     QNetworkReply *reply;
Line 123: Line 136:
};
};


Attribute::Attribute( MediaWiki const & media, /*Put attributes here*/, QObject * parent )
Attribute::Attribute(MediaWiki const & media, /*Put attributes here*/, QObject * parent)
    : QObject( parent )
        : QObject(parent)
    , d( new AttributePrivate )
        , d(new AttributePrivate)
{
{


Line 131: Line 144:
     QUrl url = d->apiUrl;
     QUrl url = d->apiUrl;


     url.addQueryItem( QString("action"), QString("query") );
     url.addQueryItem(QString("action"), QString("query"));


     // Set the request
     // Set the request
     QNetworkRequest request( url );
     QNetworkRequest request(url);
     request.setRawHeader( "User-Agent", "mediawiki-silk" );
     request.setRawHeader("User-Agent", "mediawiki-silk");
     // Send the request
     // Send the request
     d->manager = new QNetworkAccessManager( this );
     d->manager = new QNetworkAccessManager(this);


     connect( d->manager, SIGNAL( onFinished( QNetworkReply* ) ), this, SLOT( onFinished( QNetworkReply * ) ) );
     connect(d->manager, SIGNAL(onFinished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply *)));
     d->reply = d->manager->get( request );
     d->reply = d->manager->get(request);
     QTimer::singleShot( 30 * 1000, this, SLOT( abort() ) );
     QTimer::singleShot(30 * 1000, this, SLOT(abort()));


}
}
Line 153: Line 166:
{
{
     qDebug() << "abort";
     qDebug() << "abort";
     if ( !d->reply )
     if (!d->reply)
         return;
         return;


Line 160: Line 173:
}
}


void Attribute::onFinished( QNetworkReply *reply )
void Attribute::onFinished(QNetworkReply *reply)
{
{
     if ( reply->error() != QNetworkReply::NoError )
     if (reply->error() != QNetworkReply::NoError) {
    {
         qDebug() << "Request failed, " << reply->errorString();
         qDebug() << "Request failed, " << reply->errorString();
         emit onFinished( false );
         emit finished(false);
         return;
         return;
     }
     }


     QXmlStreamReader reader( reply );
     QXmlStreamReader reader(reply);


     while ( !reader.atEnd() && !reader.hasError() )
     while (!reader.atEnd() && !reader.hasError()) {
    {
         QXmlStreamReader::TokenType token = reader.readNext();
         QXmlStreamReader::TokenType token = reader.readNext();
         if ( token == QXmlStreamReader::StartElement )
         if (token == QXmlStreamReader::StartElement) {
        {
             if (reader.name() == QString("goodName")) {
             if ( reader.name() == QString( "goodName" ) )
            {
                 QXmlStreamAttributes attrs = reader.attributes();
                 QXmlStreamAttributes attrs = reader.attributes();
                 if ( attrs.value( QString( "result" ) ).toString() == "goodResult" )
                 if (attrs.value(QString("result")).toString() == "goodResult") {
                {
                     qDebug() << "Request succed, " << reply->errorString();
                     qDebug() << "Request succed, " << reply->errorString();
                     d->lgtoken = attrs.value( QString( "result" ) ).toString() ;
                     d->lgtoken = attrs.value(QString("result")).toString() ;
                     emit onFinished( true );
                     emit finished(true);
                 }
                 }
             }
             }
         }
         } else if (token == QXmlStreamReader::Invalid)
        else if ( token == QXmlStreamReader::Invalid )
             emit finished(false);
             emit onFinished( false );
     }
     }
}
}
</code>


= Class type to return list =
= Class type to return list =


== list.h ==
== list.h ==
 
<code cpp>
/*
/*
*  Copyright 2010 by XXXX XXXX <[email protected]>
*  Copyright 2010 by XXXX XXXX <[email protected]>
*
*
*  This program is free software; you can redistribute it and/or modify
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU Library General Public License as
*  it under the terms of the GNU Library General Public License as
*  published by the Free Software Foundation; either version 2, or
*  published by the Free Software Foundation; either version 2, or
*  (at your option) any later version.
*  (at your option) any later version.
*
*
*  This program is distributed in the hope that it will be useful,
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details
*  GNU General Public License for more details
*
*
*  You should have received a copy of the GNU Library General Public
*  You should have received a copy of the GNU Library General Public
*  License along with this program; if not, write to the
*  License along with this program; if not, write to the
*  Free Software Foundation, Inc.,
*  Free Software Foundation, Inc.,
*  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
*/


<nowiki>#</nowiki>ifndef LIST_H
#ifndef LIST_H


<nowiki>#</nowiki>define LIST_H
#define LIST_H


<nowiki>#</nowiki>include <QtCore/QObject>
#include <QtCore/QObject>


<nowiki>#</nowiki>include <kdemacros.h>
#include <kdemacros.h>


class MediaWiki;
class MediaWiki;
Line 239: Line 247:
         @param parent
         @param parent
     */
     */
     explicit List( MediaWiki const & media, /*Put attributes here*/, QObject * parent = 0 );
     explicit List(MediaWiki const & media, /*Put attributes here*/, QObject * parent = 0);


     /**
     /**
Line 252: Line 260:
         @param success true if the request was completed successfully.
         @param success true if the request was completed successfully.
     */
     */
     void finished( QList<List::Result> list );
     void finished(QList<List::Result> list);


public slots:
public slots:
Line 267: Line 275:
         @param reply
         @param reply
     */
     */
     void onFinished( QNetworkReply *reply );
     void onFinished(QNetworkReply *reply);


private:
private:
Line 274: Line 282:
};
};


<nowiki>#</nowiki>endif // LIST_H
#endif // LIST_H
 
</code>
== list.cpp ==
== list.cpp ==
 
<code cpp>
/*
/*
*  Copyright 2010 by XXXX XXXX <[email protected]>
*  Copyright 2010 by XXXX XXXX <[email protected]>
*
*
*  This program is free software; you can redistribute it and/or modify
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU Library General Public License as
*  it under the terms of the GNU Library General Public License as
*  published by the Free Software Foundation; either version 2, or
*  published by the Free Software Foundation; either version 2, or
*  (at your option) any later version.
*  (at your option) any later version.
*
*
*  This program is distributed in the hope that it will be useful,
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details
*  GNU General Public License for more details
*
*
*  You should have received a copy of the GNU Library General Public
*  You should have received a copy of the GNU Library General Public
*  License along with this program; if not, write to the
*  License along with this program; if not, write to the
*  Free Software Foundation, Inc.,
*  Free Software Foundation, Inc.,
*  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
*/


<nowiki>#</nowiki>include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkAccessManager>


<nowiki>#</nowiki>include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkRequest>


<nowiki>#</nowiki>include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkReply>


<nowiki>#</nowiki>include <QtCore/QXmlStreamReader>
#include <QtCore/QXmlStreamReader>


<nowiki>#</nowiki>include <QtCore/QDebug>
#include <QtCore/QDebug>


<nowiki>#</nowiki>include "list.h"
#include "list.h"
#include "mediawiki.h"


struct ListPrivate
struct ListPrivate {
{
     QNetworkAccessManager *manager;
     QNetworkAccessManager *manager;
     QNetworkReply *reply;
     QNetworkReply *reply;
Line 317: Line 325:
};
};


Attribute::Attribute( MediaWiki const & media, /*Put attributes here*/, QObject * parent )
List::List(MediaWiki const & media, /*Put attributes here*/, QObject * parent)
    : QObject( parent )
        : QObject(parent)
    , d( new ListPrivate )
        , d(new ListPrivate)
{
{


Line 325: Line 333:
     QUrl url = d->apiUrl;
     QUrl url = d->apiUrl;


     url.addQueryItem( QString("action"), QString("query") );
     url.addQueryItem(QString("action"), QString("query"));


     // Set the request
     // Set the request
     QNetworkRequest request( url );
     QNetworkRequest request(url);
     request.setRawHeader( "User-Agent", "mediawiki-silk" );
     request.setRawHeader("User-Agent", "mediawiki-silk");
     // Send the request
     // Send the request
     d->manager = new QNetworkAccessManager( this );
     d->manager = new QNetworkAccessManager(this);


     connect( d->manager, SIGNAL( onFinished( QNetworkReply* ) ), this, SLOT( onFinished( QNetworkReply * ) ) );
     connect(d->manager, SIGNAL(onFinished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply *)));
     d->reply = d->manager->get( request );
     d->reply = d->manager->get(request);


}
}
Line 346: Line 354:
{
{
     qDebug() << "abort";
     qDebug() << "abort";
     if ( !d->reply )
     if (!d->reply)
         return;
         return;


Line 353: Line 361:
}
}


void List::onFinished( QNetworkReply *reply )
void List::onFinished(QNetworkReply *reply)
{
{
     if ( reply->error() == QNetworkReply::NoError )
     if (reply->error() == QNetworkReply::NoError) {
    {
         // Parse xml
         // Parse xml
         emit finished( list );
         emit finished(list);
     }
     }
}
}
</code>

Latest revision as of 12:53, 29 October 2010

Introduction

For the coding style we follow the kdelibs coding style.

Artistic Style (astyle) automatic code formatting: astyle --indent=spaces=4 --brackets=linux \

     --indent-labels --pad-oper --unpad-paren \
     --one-line=keep-statements --convert-tabs \
     --indent-preprocessor \
     `find -type f -name '*.cpp'` `find -type f -name '*.cc'` `find -type f -name '*.h'`

Class type to return attributes

attribute.h

/*

  • Copyright 2010 by XXXX XXXX <[email protected]>
  • This program is free software; you can redistribute it and/or modify
  • it under the terms of the GNU Library General Public License as
  • published by the Free Software Foundation; either version 2, or
  • (at your option) any later version.
  • This program is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details
  • You should have received a copy of the GNU Library General Public
  • License along with this program; if not, write to the
  • Free Software Foundation, Inc.,
  • 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  • /
  1. ifndef ATTRIBUTE_H
  1. define ATTRIBUTE_H
  1. include <QtCore/QObject>
  1. include <kdemacros.h>

class MediaWiki; class QNetworkReply;

class KDE_EXPORT Attribute : public QObject {

   Q_OBJECT

public:

   /**
       @brief Create an instance of Attribute and send a request.
       @param media
       @param parent
   */
   explicit Attribute(MediaWiki const & media, /*Put attributes here*/ QObject * parent = 0);
   /**
       @brief Destroy the AttributePrivate pointer.
   */
   virtual ~Attribute();

signals:

   /**
       @brief Emitted when a request has been completed.
       @param success true if the request was completed successfully.
    */
   void finished(bool);

public slots:

   /**
       @brief Aborts the currently running request.
    */
   void abort();

private slots:

   /**
       @brief Reads the xml and build results
       @param reply
    */
   void onFinished(QNetworkReply *reply);

private:

   struct AttributePrivate * const d;

};

  1. endif // ATTRIBUTE_H

attribute.cpp

/*

  • Copyright 2010 by XXXX XXXX <[email protected]>
  • This program is free software; you can redistribute it and/or modify
  • it under the terms of the GNU Library General Public License as
  • published by the Free Software Foundation; either version 2, or
  • (at your option) any later version.
  • This program is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details
  • You should have received a copy of the GNU Library General Public
  • License along with this program; if not, write to the
  • Free Software Foundation, Inc.,
  • 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  • /
  1. include <QtNetwork/QNetworkAccessManager>
  1. include <QtNetwork/QNetworkRequest>
  1. include <QtNetwork/QNetworkReply>
  1. include <QtCore/QXmlStreamReader>
  1. include <QtCore/QTimer>
  1. include <QtCore/QDebug>
  1. include "attribute.h"
  2. include "mediawiki.h"

struct AttributePrivate {

   QNetworkAccessManager *manager;
   QNetworkReply *reply;
   QUrl apiUrl;
   /*Put attributes here*/

};

Attribute::Attribute(MediaWiki const & media, /*Put attributes here*/, QObject * parent)

       : QObject(parent)
       , d(new AttributePrivate)

{

   d->apiUrl = media.url();
   QUrl url = d->apiUrl;
   url.addQueryItem(QString("action"), QString("query"));
   // Set the request
   QNetworkRequest request(url);
   request.setRawHeader("User-Agent", "mediawiki-silk");
   // Send the request
   d->manager = new QNetworkAccessManager(this);
   connect(d->manager, SIGNAL(onFinished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply *)));
   d->reply = d->manager->get(request);
   QTimer::singleShot(30 * 1000, this, SLOT(abort()));

}

Attribute::~Attribute() {

   delete d;

}

void Attribute::abort() {

   qDebug() << "abort";
   if (!d->reply)
       return;
   d->reply->abort();
   d->reply = 0;

}

void Attribute::onFinished(QNetworkReply *reply) {

   if (reply->error() != QNetworkReply::NoError) {
       qDebug() << "Request failed, " << reply->errorString();
       emit finished(false);
       return;
   }
   QXmlStreamReader reader(reply);
   while (!reader.atEnd() && !reader.hasError()) {
       QXmlStreamReader::TokenType token = reader.readNext();
       if (token == QXmlStreamReader::StartElement) {
           if (reader.name() == QString("goodName")) {
               QXmlStreamAttributes attrs = reader.attributes();
               if (attrs.value(QString("result")).toString() == "goodResult") {
                   qDebug() << "Request succed, " << reply->errorString();
                   d->lgtoken = attrs.value(QString("result")).toString() ;
                   emit finished(true);
               }
           }
       } else if (token == QXmlStreamReader::Invalid)
           emit finished(false);
   }

}

Class type to return list

list.h

/*

  • Copyright 2010 by XXXX XXXX <[email protected]>
  • This program is free software; you can redistribute it and/or modify
  • it under the terms of the GNU Library General Public License as
  • published by the Free Software Foundation; either version 2, or
  • (at your option) any later version.
  • This program is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details
  • You should have received a copy of the GNU Library General Public
  • License along with this program; if not, write to the
  • Free Software Foundation, Inc.,
  • 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  • /
  1. ifndef LIST_H
  1. define LIST_H
  1. include <QtCore/QObject>
  1. include <kdemacros.h>

class MediaWiki; class QNetworkReply;

class KDE_EXPORT List : public QObject {

   Q_OBJECT

public:

   struct Result {
       /* Attribute result */
   };
   /**
       @brief Create an instance of List and send a request.
       @param media
       @param parent
   */
   explicit List(MediaWiki const & media, /*Put attributes here*/, QObject * parent = 0);
   /**
       @brief Destroy the ListPrivate pointer.
   */
   virtual ~List();

signals:

   /**
       @brief Emitted when a request has been completed.
       @param success true if the request was completed successfully.
    */
   void finished(QList<List::Result> list);

public slots:

   /**
       @brief Aborts the currently running request.
    */
   void abort();

private slots:

   /**
       @brief Reads the xml and build results
       @param reply
    */
   void onFinished(QNetworkReply *reply);

private:

   struct ListPrivate *const d;

};

  1. endif // LIST_H

list.cpp

/*

  • Copyright 2010 by XXXX XXXX <[email protected]>
  • This program is free software; you can redistribute it and/or modify
  • it under the terms of the GNU Library General Public License as
  • published by the Free Software Foundation; either version 2, or
  • (at your option) any later version.
  • This program is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  • GNU General Public License for more details
  • You should have received a copy of the GNU Library General Public
  • License along with this program; if not, write to the
  • Free Software Foundation, Inc.,
  • 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  • /
  1. include <QtNetwork/QNetworkAccessManager>
  1. include <QtNetwork/QNetworkRequest>
  1. include <QtNetwork/QNetworkReply>
  1. include <QtCore/QXmlStreamReader>
  1. include <QtCore/QDebug>
  1. include "list.h"
  2. include "mediawiki.h"

struct ListPrivate {

   QNetworkAccessManager *manager;
   QNetworkReply *reply;
   QUrl apiUrl;
   /*Put attributes here*/

};

List::List(MediaWiki const & media, /*Put attributes here*/, QObject * parent)

       : QObject(parent)
       , d(new ListPrivate)

{

   d->apiUrl = media.url();
   QUrl url = d->apiUrl;
   url.addQueryItem(QString("action"), QString("query"));
   // Set the request
   QNetworkRequest request(url);
   request.setRawHeader("User-Agent", "mediawiki-silk");
   // Send the request
   d->manager = new QNetworkAccessManager(this);
   connect(d->manager, SIGNAL(onFinished(QNetworkReply*)), this, SLOT(onFinished(QNetworkReply *)));
   d->reply = d->manager->get(request);

}

List::~List() {

   delete d;

}

void List::abort() {

   qDebug() << "abort";
   if (!d->reply)
       return;
   d->reply->abort();
   d->reply = 0;

}

void List::onFinished(QNetworkReply *reply) {

   if (reply->error() == QNetworkReply::NoError) {
       // Parse xml
       emit finished(list);
   }

}