Ignore:
Timestamp:
Feb 10, 2010, 10:18:02 PM (14 years ago)
Author:
fcoiffie
Message:

[digikam_export] Removal of all useless and commented code

  • Temporary files are removed
  • Warnings correction
  • Selected 'thumbnail size' is stored in the configuration file
Location:
extensions/digikam_export/piwigoexport
Files:
4 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • extensions/digikam_export/piwigoexport/CMakeLists.txt

    r4770 r4874  
    33SET(kipiplugin_piwigoexport_PART_SRCS
    44    plugin_piwigoexport.cpp
    5     albumdlg.cpp
    65    piwigos.cpp
    76    piwigoconfig.cpp
     
    98    piwigotalker.cpp
    109   )
    11 
    12 KDE4_ADD_UI_FILES(kipiplugin_piwigoexport_PART_SRCS piwigoalbumwidget.ui)
    1310
    1411KDE4_ADD_PLUGIN(kipiplugin_piwigoexport ${kipiplugin_piwigoexport_PART_SRCS})
  • extensions/digikam_export/piwigoexport/piwigoitem.h

    r4770 r4874  
    3535{
    3636
    37 class GPhoto
    38 {
    39 public:
    40 
    41     GPhoto() {
    42         ref_num = -1;
    43     }
    44 
    45     int     ref_num;
    46     int     album_num;
    47 
    48     QString name;
    49     QString caption;
    50     QString thumbName;
    51     QString albumURL;
    52 };
    53 
    54 // ------------------------------------------------------------------------
    55 
    5637class GAlbum
    5738{
     
    7051    }
    7152
    72     // permissions
    7353    int                ref_num;         // album reference number
    7454    int                parent_ref_num;  // parent's album reference number
    7555
    76     QString            name;            // ?
    77     /*QString            parentName;      // ?
    78     QString            title;           // album title*/
    79     //QString            summary;         // album summary
     56    QString            name;            // Album name
    8057    QString            baseurl;         // album partial (gallery) URL
    8158};
    8259
    83 //category id="3" nb_images="80" total_nb_images="80" date_last="2010-01-03 22:06:29" max_date_last="2010-01-03 22:06:29" nb_categories="0" url="http://fcoiffie.free.fr/piwigo-2.0.7/index.php?/category/3"
    8460} // namespace KIPIPiwigoExportPlugin
    8561
  • extensions/digikam_export/piwigoexport/piwigos.cpp

    r4770 r4874  
    7171}
    7272
    73 unsigned int Piwigo::galleryId() const
    74 {
    75     return mPiwigoId;
    76 }
    77 
    7873// -------------------------------------
    7974
     
    9691{
    9792    mPassword = password;
    98 }
    99 
    100 void Piwigo::setPiwigoId(unsigned int galleryId)
    101 {
    102     mPiwigoId = galleryId;
    10393}
    10494
  • extensions/digikam_export/piwigoexport/piwigos.h

    r4770 r4874  
    5252    QString username()       const;
    5353    QString password()       const;
    54     unsigned int version()   const;
    55     unsigned int galleryId() const;
    5654
    5755    void setName(const QString& name);
     
    5957    void setUsername(const QString& username);
    6058    void setPassword(const QString& password);
    61     void setPiwigoId(unsigned int galleryId);
    6259
    6360public:
     
    7067
    7168private:
    72 
    73     unsigned int     mPiwigoId;
    7469
    7570    QString          mName;
  • extensions/digikam_export/piwigoexport/piwigotalker.cpp

    r4770 r4874  
    2828#include "piwigotalker.moc"
    2929
    30 // C++ includes
    31 
    32 #include <cstring>
    33 #include <cstdio>
    34 
    3530// Qt includes
    3631
     
    7267        : m_parent(parent),  m_job(0),  m_loggedIn(false)
    7368{
    74     kDebug() << "BEGIN\n";
    7569}
    7670
     
    143137    m_job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded" );
    144138    m_job->addMetaData("customHTTPHeader", "Authorization: " + s_authToken );
    145     /*    m_job->addMetaData("cookies", "manual");
    146         m_job->addMetaData("setcookies", m_cookie);*/
    147139
    148140    connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)),
     
    153145
    154146    emit signalBusy(true);
    155 }
    156 
    157 void PiwigoTalker::listPhotos(const QString& albumName)
    158 {
    159     m_job   = 0;
    160     m_state = GE_LISTPHOTOS;
    161     m_talker_buffer.resize(0);
    162 #if 0
    163     PiwigoMPForm form;
    164     form.addPair("cmd", "fetch-album-images");
    165     form.addPair("protocol_version", "2.11");
    166     form.addPair("set_albumName", albumName);
    167     form.finish();
    168 
    169     m_job = KIO::http_post(m_url, form.formData(), KIO::HideProgressInfo);
    170     m_job->addMetaData("content-type", form.contentType());
    171     m_job->addMetaData("cookies", "manual");
    172     m_job->addMetaData("setcookies", m_cookie);
    173 
    174     connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)),
    175             this, SLOT(slotTalkerData(KIO::Job*, const QByteArray&)));
    176 
    177     connect(m_job, SIGNAL(result(KJob *)),
    178             this, SLOT(slotResult(KJob *)));
    179 
    180     emit signalBusy(true);
    181 #endif
    182 }
    183 
    184 void PiwigoTalker::createAlbum(const QString& parentAlbumName,
    185                                const QString& albumName,
    186                                const QString& albumTitle,
    187                                const QString& albumCaption)
    188 {
    189     m_job   = 0;
    190     m_state = GE_CREATEALBUM;
    191     m_talker_buffer.resize(0);
    192 #if 0
    193     PiwigoMPForm form;
    194     form.addPair("cmd", "new-album");
    195     form.addPair("protocol_version", "2.11");
    196     form.addPair("set_albumName", parentAlbumName);
    197 
    198     if (!albumName.isEmpty())
    199         form.addPair("newAlbumName", albumName);
    200 
    201     if (!albumTitle.isEmpty())
    202         form.addPair("newAlbumTitle", albumTitle);
    203 
    204     if (!albumCaption.isEmpty())
    205         form.addPair("newAlbumDesc", albumCaption);
    206 
    207     form.finish();
    208 
    209     m_job = KIO::http_post(m_url, form.formData(), KIO::HideProgressInfo);
    210     m_job->addMetaData("content-type", form.contentType());
    211     m_job->addMetaData("cookies", "manual");
    212     m_job->addMetaData("setcookies", m_cookie);
    213 
    214     connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)),
    215             this, SLOT(slotTalkerData(KIO::Job*, const QByteArray&)));
    216 
    217     connect(m_job, SIGNAL(result(KJob*)),
    218             this, SLOT(slotResult(KJob*)));
    219 
    220     emit signalBusy(true);
    221 #endif
    222147}
    223148
     
    269194
    270195        // Complete name and comment for summary sending
    271         m_comment = m_name = KUrl(photoPath).fileName();
     196        m_comment = m_name = caption;
    272197        m_date = fi.created();
    273198
     
    301226    buffer.append(dataParameters.toUtf8());
    302227
    303     //kDebug() << "Request " << m_url << buffer << "\n";
    304 
    305228    m_job = KIO::http_post(m_url, buffer, KIO::HideProgressInfo);
    306229    m_job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded" );
    307230    m_job->addMetaData("customHTTPHeader", "Authorization: " + s_authToken );
    308     /*    m_job->addMetaData("cookies", "manual");
    309         m_job->addMetaData("setcookies", m_cookie);*/
    310231
    311232    connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)),
     
    336257    m_talker_buffer.resize(oldSize + data.size());
    337258    memcpy(m_talker_buffer.data() + oldSize, data.data(), data.size());
    338 
    339     kDebug() << data;
    340259}
    341260
     
    349268            kDebug() << tempjob->errorString();
    350269        } else {
    351             if (m_state == GE_CHECKPHOTOEXIST || m_state == GE_ADDPHOTO) {
     270            if (m_state == GE_CHECKPHOTOEXIST || m_state == GE_ADDPHOTO || m_state == GE_ADDTHUMB || m_state == GE_ADDPHOTOSUMMARY) {
    352271                emit signalAddPhotoFailed(tempjob->errorString());
    353272            } else {
     
    366285    case(GE_LISTALBUMS):
    367286        parseResponseListAlbums(m_talker_buffer);
    368         break;
    369     case(GE_LISTPHOTOS):
    370         parseResponseListPhotos(m_talker_buffer);
    371         break;
    372     case(GE_CREATEALBUM):
    373         parseResponseCreateAlbum(m_talker_buffer);
    374287        break;
    375288    case(GE_CHECKPHOTOEXIST):
     
    391304
    392305    if (m_state == GE_LOGIN && m_loggedIn) {
    393         /*
    394                         const QStringList cookielist = (tempjob->queryMetaData("setcookies")).split('\n');
    395                 m_cookie = "Cookie:";
    396 
    397 
    398                 if(!cookielist.isEmpty())
    399                 {
    400                     QRegExp rx("^PIWIGOSID=.+");
    401                     QString app;
    402                     foreach(const QString &str, cookielist)
    403                     {
    404                         if(str.contains("Set-Cookie: "))
    405                         {
    406                             const QStringList cl = str.split(' ');
    407                             int n = cl.lastIndexOf(rx);
    408                             if(n!= -1)
    409                             {
    410                                 app = cl.at(n);
    411                             }
    412                         }
    413                     }
    414                     m_cookie += app;
    415                 }
    416         */
    417306        listAlbums();
    418307    }
     
    427316    bool foundResponse = false;
    428317    m_loggedIn         = false;
     318
     319    kDebug() << "parseResponseLogin: " << QString(data);
    429320
    430321    while (!ts.atEnd()) {
     
    461352    GAlbumList::iterator iter = albumList.begin();
    462353
    463     kDebug() << QString(data);
     354    kDebug() << "parseResponseListAlbums: " << QString(data);
    464355
    465356    while (!ts.atEnd()) {
     
    517408}
    518409
    519 void PiwigoTalker::parseResponseListPhotos(const QByteArray &data)
    520 {
    521     QString str = QString::fromUtf8(data);
    522     QTextStream ts(&str, QIODevice::ReadOnly);
    523     QString line;
    524     bool foundResponse = false;
    525     bool success       = false;
    526 
    527     typedef QList<GPhoto> GPhotoList;
    528     GPhotoList photoList;
    529     GPhotoList::iterator iter = photoList.begin();
    530 
    531     QString albumURL;
    532 
    533     while (!ts.atEnd()) {
    534         line = ts.readLine();
    535 
    536         if (!foundResponse) {
    537             foundResponse = line.startsWith(QLatin1String(("#__GR2PROTO__")));
    538         } else {
    539             QStringList strlist = line.split('=');
    540             if (strlist.count() == 2) {
    541                 QString key   = strlist[0];
    542                 QString value = strlist[1];
    543 
    544                 if (key == "status") {
    545                     success = (value == "0");
    546                 } else if (key.startsWith(QLatin1String(("image.name")))) {
    547                     GPhoto photo;
    548                     photo.name    = value;
    549                     photo.ref_num = key.section('.', 2, 2).toInt();
    550                     iter = photoList.insert(iter, photo);
    551                 } else if (key.startsWith(QLatin1String(("image.caption")))) {
    552                     (*iter).caption = value;
    553                 } else if (key.startsWith(QLatin1String(("image.thumbName")))) {
    554                     (*iter).thumbName = value;
    555                 } else if (key.startsWith(QLatin1String(("baseurl")))) {
    556                     albumURL = value.replace("\\", "");     // doesn't compile fixing EBN Krazy issue!!
    557                 }
    558             }
    559         }
    560     }
    561 
    562     if (!foundResponse) {
    563         emit signalError(i18n("Invalid response received from remote Piwigo"));
    564         return;
    565     }
    566 
    567     if (!success) {
    568         emit signalError(i18n("Failed to list photos"));
    569         return;
    570     }
    571 
    572     emit signalPhotos(photoList);
    573 }
    574 
    575 void PiwigoTalker::parseResponseCreateAlbum(const QByteArray& data)
    576 {
    577     QString str = QString::fromUtf8(data);
    578     QTextStream ts(&str, QIODevice::ReadOnly);
    579     QString line;
    580     bool foundResponse = false;
    581     bool success       = false;
    582 
    583     while (!ts.atEnd()) {
    584         line = ts.readLine();
    585 
    586         if (!foundResponse) {
    587             foundResponse = line.startsWith(QLatin1String(("#__GR2PROTO__")));
    588         } else {
    589             QStringList strlist = line.split('=');
    590             if (strlist.count() == 2) {
    591                 QString key   = strlist[0];
    592                 QString value = strlist[1];
    593                 if (key == "status") {    // key == "status" NOT FOUND!!!
    594                     success = (value == "0");
    595                     kWarning() << "Create Album. success: " << success ;
    596                 } else if (key.startsWith(QLatin1String(("status_text")))) {
    597                     kDebug() << "STATUS: Create Album: " << value ;
    598                 }
    599             }
    600         }
    601     }
    602 
    603     if (!foundResponse) {
    604         emit signalError(i18n("Invalid response received from remote Piwigo"));
    605         return;
    606     }
    607 
    608     if (!success) {
    609         emit signalError(i18n("Failed to create new album"));
    610         return;
    611     }
    612 
    613     listAlbums();
    614 }
    615 
    616410void PiwigoTalker::parseResponseDoesPhotoExist(const QByteArray& data)
    617411{
     
    622416    bool success       = false;
    623417
    624 //    typedef QList<GAlbum> GAlbumList;
    625 //    GAlbumList albumList;
    626 //    GAlbumList::iterator iter = albumList.begin();
    627 
    628     kDebug() << QString(data);
     418    kDebug() << "parseResponseDoesPhotoExist: " << QString(data);
    629419
    630420    while (!ts.atEnd()) {
     
    667457    imagefile.close();
    668458
    669     //kDebug() << "Request " << m_url << buffer << "\n";
    670 
    671459    m_job = KIO::http_post(m_url, buffer, KIO::HideProgressInfo);
    672460    m_job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded" );
    673461    m_job->addMetaData("customHTTPHeader", "Authorization: " + s_authToken );
    674     /*    m_job->addMetaData("cookies", "manual");
    675         m_job->addMetaData("setcookies", m_cookie);*/
    676462
    677463    connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)),
     
    680466    connect(m_job, SIGNAL(result(KJob *)),
    681467            this, SLOT(slotResult(KJob *)));
    682 
    683 #if 0
    684     QString str = QString::fromUtf8(data);
    685     QTextStream ts(&str, QIODevice::ReadOnly);
    686     QString line;
    687     bool foundResponse = false;
    688     bool success       = false;
    689 
    690     while (!ts.atEnd()) {
    691         line = ts.readLine();
    692 
    693         if (!foundResponse) {
    694             // Piwigo1 sends resizing debug code sometimes so we
    695             // have to detect things slightly differently
    696             foundResponse = (line.startsWith(QLatin1String(("#__GR2PROTO__")))
    697                              || (line.startsWith(QLatin1String(("<br>- Resizing")))
    698                                  && line.endsWith(QLatin1String(("#__GR2PROTO__")))));
    699         } else {
    700             QStringList strlist = line.split('=');
    701             if (strlist.count() == 2) {
    702                 QString key   = strlist[0];
    703                 QString value = strlist[1];
    704 
    705                 if (key == "status") {
    706                     success = (value == "0");
    707                     kWarning() << "Add photo. success: " << success ;
    708                 } else if (key.startsWith(QLatin1String(("status_text")))) {
    709                     kDebug() << "STATUS: Add Photo: " << value ;
    710                 }
    711             }
    712         }
    713     }
    714 
    715     if (!foundResponse) {
    716         emit signalAddPhotoFailed(i18n("Invalid response received from remote Piwigo"));
    717         return;
    718     }
    719 
    720     if (!success) {
    721         emit signalAddPhotoFailed(i18n("Failed to upload photo"));
    722     } else {
    723         emit signalAddPhotoSucceeded();
    724     }
    725 #endif
    726468}
    727469
     
    735477    bool success       = false;
    736478
    737     kDebug() << QString(data);
     479    kDebug() << "parseResponseAddPhoto: " << QString(data);
    738480
    739481    while (!ts.atEnd()) {
     
    776518    imagefile.close();
    777519
    778     //kDebug() << "Request " << m_url << buffer << "\n";
    779 
    780520    m_job = KIO::http_post(m_url, buffer, KIO::HideProgressInfo);
    781521    m_job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded" );
    782522    m_job->addMetaData("customHTTPHeader", "Authorization: " + s_authToken );
    783     /*    m_job->addMetaData("cookies", "manual");
    784         m_job->addMetaData("setcookies", m_cookie);*/
    785523
    786524    connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)),
     
    800538    bool success       = false;
    801539
    802     kDebug() << QString(data);
     540    kDebug() << "parseResponseAddThumbnail: " << QString(data);
    803541
    804542    while (!ts.atEnd()) {
     
    826564    m_state = GE_ADDPHOTOSUMMARY;
    827565
    828     //name=img_9738&author=Fr%E9d%E9ric+COIFFIER&categories=12&file_sum=8aa81afb8f15a5dbcf463e210e0cc6f2&thumbnail_sum=8d30dd047bd8d44ea099c461bd87ff7c&original_sum=278d66d52b278fbf531a4c7a74a0dd21&date_creation=2009%3A06%3A16&tag_ids=&comment=&mthod=pwg.images.add
    829 
    830 
    831566    QFile imagefile(m_thumbpath);
    832567    imagefile.open(QIODevice::ReadOnly);
     
    836571    qsl.append("original_sum=" + m_md5sum.toHex());
    837572    qsl.append("name=" + m_name.toUtf8().toPercentEncoding());
    838     qsl.append("author="); // TODO
     573    qsl.append("author="); // TODO Retrieve author name from EXIF/IPTC tags
    839574    qsl.append("categories=" + QString::number(m_albumId));
    840575    qsl.append("file_sum=" + computeMD5Sum(m_path).toHex());
    841576    qsl.append("thumbnail_sum=" + computeMD5Sum(m_thumbpath).toHex());
    842     qsl.append("date_creation=" + m_date.toString("yyyy:MM:dd").toUtf8().toPercentEncoding()); // 2007%3A06%3A23
     577    qsl.append("date_creation=" + m_date.toString("yyyy:MM:dd").toUtf8().toPercentEncoding());
    843578    qsl.append("tag_ids=");
    844579    qsl.append("comment=" + m_comment.toUtf8().toPercentEncoding());
     
    849584    imagefile.close();
    850585
    851     kDebug() << "Request " << m_url << buffer << "\n";
    852 
    853586    m_job = KIO::http_post(m_url, buffer, KIO::HideProgressInfo);
    854587    m_job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded" );
    855588    m_job->addMetaData("customHTTPHeader", "Authorization: " + s_authToken );
    856     /*    m_job->addMetaData("cookies", "manual");
    857         m_job->addMetaData("setcookies", m_cookie);*/
    858589
    859590    connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)),
     
    872603    bool success       = false;
    873604
    874     kDebug() << QString(data);
     605    kDebug() << "parseResponseAddPhotoSummary: " << QString(data);
    875606
    876607    while (!ts.atEnd()) {
     
    896627    }
    897628
    898 #if 0
    899     while (!ts.atEnd()) {
    900         line = ts.readLine();
    901 
    902         if (!foundResponse) {
    903             // Piwigo1 sends resizing debug code sometimes so we
    904             // have to detect things slightly differently
    905             foundResponse = (line.startsWith(QLatin1String(("#__GR2PROTO__")))
    906                              || (line.startsWith(QLatin1String(("<br>- Resizing")))
    907                                  && line.endsWith(QLatin1String(("#__GR2PROTO__")))));
    908         } else {
    909             QStringList strlist = line.split('=');
    910             if (strlist.count() == 2) {
    911                 QString key   = strlist[0];
    912                 QString value = strlist[1];
    913 
    914                 if (key == "status") {
    915                     success = (value == "0");
    916                     kWarning() << "Add photo. success: " << success ;
    917                 } else if (key.startsWith(QLatin1String(("status_text")))) {
    918                     kDebug() << "STATUS: Add Photo: " << value ;
    919                 }
    920             }
    921         }
    922     }
    923 #endif
    924629    if (!foundResponse) {
    925630        emit signalAddPhotoFailed(i18n("Invalid response received from remote Piwigo"));
    926631        return;
    927632    }
     633
     634    if (m_path.size())
     635        QFile(m_path).remove();
     636    if (m_thumbpath.size())
     637        QFile(m_thumbpath).remove();
     638
     639    m_path = "";
     640    m_thumbpath = "";
    928641
    929642    if (!success) {
  • extensions/digikam_export/piwigoexport/piwigotalker.h

    r4770 r4874  
    6565        GE_LOGIN = 0,
    6666        GE_LISTALBUMS,
    67         GE_LISTPHOTOS,
    68         GE_CREATEALBUM,
    6967        GE_CHECKPHOTOEXIST,
    7068        GE_ADDPHOTO,
     
    9795                  const QString& caption = QString(),
    9896                  bool  captionIsTitle = true, bool captionIsDescription = false,
    99                   bool rescale = false, int maxDim = 600, int thumbDim = 120);
     97                  bool rescale = false, int maxDim = 600, int thumbDim = 128);
    10098
    10199    void cancel();
     
    107105    void signalBusy(bool val);
    108106    void signalAlbums(const QList<GAlbum>& albumList);
    109     void signalPhotos(const QList<GPhoto>& photoList);
    110107    void signalAddPhotoSucceeded();
    111108    void signalAddPhotoFailed(const QString& msg);
     
    115112    void parseResponseLogin(const QByteArray& data);
    116113    void parseResponseListAlbums(const QByteArray& data);
    117     void parseResponseListPhotos(const QByteArray& data);
    118     void parseResponseCreateAlbum(const QByteArray& data);
    119114    void parseResponseDoesPhotoExist(const QByteArray& data);
    120115    void parseResponseAddPhoto(const QByteArray& data);
  • extensions/digikam_export/piwigoexport/piwigowindow.cpp

    r4770 r4874  
    3939#include <QTreeWidgetItem>
    4040#include <QPointer>
     41#include <QHBoxLayout>
     42#include <QVBoxLayout>
    4143
    4244// KDE includes
     
    6365// Local includes
    6466
    65 #include "albumdlg.h"
    6667#include "piwigos.h"
    6768#include "piwigoconfig.h"
     
    8485    QTreeWidget*           albumView;
    8586
    86     QPushButton*           newAlbumBtn;
    8787    QPushButton*           addPhotoBtn;
    8888
     
    111111    logo = new KUrlLabel;
    112112    logo->setText(QString());
    113     logo->setUrl("http://piwigo.menalto.com");
     113    logo->setUrl("http://piwigo.org");
    114114    logo->setPixmap(QPixmap(KStandardDirs::locate("data", "kipiplugin_piwigoexport/pics/piwigo_logo.png")));
    115115    logo->setAlignment(Qt::AlignLeft);
     
    119119    albumView = new QTreeWidget;
    120120    QStringList labels;
    121     labels << i18n("Albums"); // << i18n("ID");
     121    labels << i18n("Albums");
    122122    albumView->setHeaderLabels(labels);
    123123
     
    126126    QFrame *optionFrame = new QFrame;
    127127    QVBoxLayout *vlay   = new QVBoxLayout();
    128 
    129     newAlbumBtn = new QPushButton;
    130     newAlbumBtn->setText(i18n("&New Album"));
    131     newAlbumBtn->setIcon(KIcon("folder-new"));
    132     newAlbumBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    133     newAlbumBtn->setEnabled(false);
    134128
    135129    addPhotoBtn = new QPushButton;
     
    163157    thumbDimensionSpinBox = new QSpinBox;
    164158    thumbDimensionSpinBox->setRange(32,800);
    165     thumbDimensionSpinBox->setValue(120);
     159    thumbDimensionSpinBox->setValue(128);
    166160
    167161    captTitleCheckBox->setChecked(true);
     
    199193    // ---------------------------------------------------------------------------
    200194
    201     vlay->addWidget(newAlbumBtn);
    202195    vlay->addWidget(addPhotoBtn);
    203196    vlay->addWidget(optionsBox);
     
    226219        d(new Private(this))
    227220{
    228     kDebug() << "BEGIN Window\n";
    229 
    230 
    231221    setWindowTitle( i18n("Piwigo Export") );
    232222    setButtons( KDialog::Close | KDialog::User1 | KDialog::Help);
     
    310300    group.writeEntry("Set description", d->captDescrCheckBox->isChecked());
    311301    group.writeEntry("Maximum Width",   d->dimensionSpinBox->value());
     302    group.writeEntry("Thumbnail Width", d->thumbDimensionSpinBox->value());
    312303
    313304    delete m_talker;
     
    324315            this , SLOT( slotAlbumSelected() ) );
    325316
    326     connect(d->newAlbumBtn, SIGNAL(clicked()),
    327             this, SLOT(slotNewAlbum()));
    328 
    329317    connect(d->addPhotoBtn, SIGNAL(clicked()),
    330318            this, SLOT(slotAddPhoto()));
     
    350338    connect(m_talker, SIGNAL(signalAlbums(const QList<GAlbum>&)),
    351339            this, SLOT(slotAlbums(const QList<GAlbum>&)));
    352 
    353     connect(m_talker, SIGNAL(signalPhotos(const QList<GPhoto>&)),
    354             this, SLOT(slotPhotos(const QList<GPhoto>&)));
    355340
    356341    connect(m_talker, SIGNAL(signalAddPhotoSucceeded()),
     
    391376        d->captDescrCheckBox->setChecked(false);
    392377
     378
     379    d->thumbDimensionSpinBox->setValue(group.readEntry("Thumbnail Width", 128));
    393380}
    394381
     
    443430    if (val) {
    444431        setCursor(Qt::WaitCursor);
    445         d->newAlbumBtn->setEnabled(false);
    446432        d->addPhotoBtn->setEnabled(false);
    447433    } else {
    448434        setCursor(Qt::ArrowCursor);
    449435        bool loggedIn = m_talker->loggedIn();
    450 // TODO Enable the button to implement the feature
    451         //d->newAlbumBtn->setEnabled(loggedIn);
    452436        d->addPhotoBtn->setEnabled(loggedIn && d->albumView->currentItem());
    453437    }
     
    492476            int i                       = 0;
    493477
    494             kDebug() << "Parent : " << parentRefNum << "\n";
    495 
    496478            while ( !found && i < parentItemList.size() ) {
    497479                parentItem = parentItemList.at(i);
    498 
    499                 kDebug() << "User : " << parentItem->data(1, Qt::UserRole).toInt() << "\n";
    500480
    501481                if (parentItem && (parentItem->data(1, Qt::UserRole).toInt() == parentRefNum)) {
     
    505485                    item->setData(1, Qt::UserRole, album.ref_num );
    506486                    item->setText(2, i18n("Album") );
    507 
    508                     kDebug() << "Child : " << album.name << " " << album.ref_num << "\n";
    509487
    510488                    parentItem->addChild(item);
     
    515493                i++;
    516494            }
    517 
    518             /*if (!found && i == parentItemList.size() )
    519             {
    520                 workList.append(album);
    521             }*/
    522495        }
    523496    }
    524497}
    525498
    526 // FIXME: avoid duplications
    527 void PiwigoWindow::slotPhotos(const QList<GPhoto>& photoList)
    528 {
    529     QTreeWidgetItem* parentItem = d->albumView->currentItem();
    530 
    531     typedef QList<GPhoto> GPhotoList;
    532     GPhotoList::const_iterator iterator;
    533     for (iterator = photoList.begin(); iterator != photoList.end(); ++iterator) {
    534         QString plain = (*iterator).caption;
    535         QTreeWidgetItem *item = new QTreeWidgetItem(parentItem);
    536         item->setText(0, cleanName(plain) );
    537         item->setIcon(0, KIcon("image-x-generic") );
    538         item->setText(1, (*iterator).name);
    539         item->setText(2, i18n("Image") );
    540     }
    541 }
    542 
    543499void PiwigoWindow::slotAlbumSelected()
    544500{
    545501    QTreeWidgetItem* item = d->albumView->currentItem();
    546 
    547     kDebug() << "slotAlbumSelected\n";
    548502
    549503    // stop loading if user clicked an image
    550504    if ( item->text(2) == i18n("Image") )
    551505        return;
    552 
    553     kDebug() << "Album\n";
    554506
    555507    if (!item) {
     
    562514        if (m_talker->loggedIn() && albumId ) {
    563515            d->addPhotoBtn->setEnabled(true);
    564             //m_talker->listPhotos(albumName);
    565516        } else {
    566517            d->addPhotoBtn->setEnabled(false);
     
    569520}
    570521
    571 void PiwigoWindow::slotNewAlbum()
    572 {
    573     QPointer<AlbumDlg> dlg = new AlbumDlg(d->widget);
    574     dlg->titleEdit->setFocus();
    575     if ( dlg->exec() != QDialog::Accepted ) {
    576         delete dlg;
     522void PiwigoWindow::slotAddPhoto()
     523{
     524    KUrl::List *urls = new KUrl::List(m_interface->currentSelection().images());
     525
     526    if (urls == NULL || urls->isEmpty()) {
     527        KMessageBox::error(this, i18n("Nothing to upload - please select photos to upload."));
    577528        return;
    578529    }
    579530
    580     QString name    = dlg->nameEdit->text();
    581     QString title   = dlg->titleEdit->text();
    582     QString caption = dlg->captionEdit->text();
    583 
    584     delete dlg;
    585 
    586     // check for prohibited chars in the album name
    587     // \ / * ? " ' & < > | . + # ( ) or spaces
    588     // TODO: Change this to a QRegExp check.
    589     QChar ch;
    590     bool  clean = true;
    591 
    592     for (int i = 0; i < name.length(); ++i) {
    593         ch = name[i];
    594         if (ch == '\\') {
    595             clean = false;
    596             break;
    597         } else if (ch == '/') {
    598             clean = false;
    599             break;
    600         } else if (ch == '*') {
    601             clean = false;
    602             break;
    603         } else if (ch == '?') {
    604             clean = false;
    605             break;
    606         } else if (ch == '"') {
    607             clean = false;
    608             break;
    609         } else if (ch == '\'') {
    610             clean = false;
    611             break;
    612         } else if (ch == '&') {
    613             clean = false;
    614             break;
    615         } else if (ch == '<') {
    616             clean = false;
    617             break;
    618         } else if (ch == '>') {
    619             clean = false;
    620             break;
    621         } else if (ch == '|') {
    622             clean = false;
    623             break;
    624         } else if (ch == '.') {
    625             clean = false;
    626             break;
    627         } else if (ch == '+') {
    628             clean = false;
    629             break;
    630         } else if (ch == '#') {
    631             clean = false;
    632             break;
    633         } else if (ch == '(') {
    634             clean = false;
    635             break;
    636         } else if (ch == ')') {
    637             clean = false;
    638             break;
    639         }
    640         /*
    641         else if (ch == ' ')
    642         {
    643             clean = false;
    644             break;
    645         }
    646         */
    647     }
    648 
    649     if (!clean) {
    650         KMessageBox::error(this, i18n("Sorry, these characters are not allowed in album name: \\ / * ? \" \' & &lt; &gt; | . + # ( ) or spaces"));
    651         return;
    652     }
    653 
    654     QString parentAlbumName;
    655 
    656     QTreeWidgetItem* item = d->albumView->currentItem();
    657     int column            = d->albumView->currentColumn();
    658     if (item) {
    659         const GAlbum& album = d->albumDict.value( item->text(column) );
    660         parentAlbumName     = album.name;
    661         m_talker->createAlbum( parentAlbumName, name, title, caption);
    662     } else {
    663         m_talker->createAlbum( firstAlbumName, name, title, caption );
    664     }
    665 }
    666 
    667 void PiwigoWindow::slotAddPhoto()
    668 {
    669 #if 0
    670     QTreeWidgetItem* item = d->albumView->currentItem();
    671     int column            = d->albumView->currentColumn();
    672     if (!item)
    673         return;     // NO album selected: FIXME: do something
    674 
    675     // albumName
    676     QString albumTitle = item->text(column);
    677     if (!d->albumDict.contains(albumTitle))
    678         return;     // NO album name found: FIXME: do something
    679 
    680     // photoPath
    681     KUrl::List urls = KIPIPlugins::ImageDialog::getImageUrls(this, m_interface);
    682     if (urls.isEmpty())
    683         return; // NO photo selected: FIXME: do something
    684 
    685     for (KUrl::List::iterator it = urls.begin(); it != urls.end(); ++it) {
     531    for (KUrl::List::iterator it = urls->begin(); it != urls->end(); ++it) {
    686532        mpUploadList->append( (*it).path() );
    687533    }
     
    692538    m_uploadCount = 0;
    693539    slotAddPhotoNext();
    694 #endif
    695     KUrl::List *urls = new KUrl::List(m_interface->currentSelection().images());
    696 
    697     if (urls == NULL || urls->isEmpty()) {
    698         KMessageBox::error(this, i18n("Nothing to upload - please select photos to upload."));
    699         return;
    700     }
    701 
    702     for (KUrl::List::iterator it = urls->begin(); it != urls->end(); ++it) {
    703         mpUploadList->append( (*it).path() );
    704     }
    705 
    706     m_uploadTotal = mpUploadList->count();
    707     m_progressDlg->reset();
    708     m_progressDlg->setMaximum(m_uploadTotal);
    709     m_uploadCount = 0;
    710     slotAddPhotoNext();
    711540}
    712541
     
    716545        m_progressDlg->reset();
    717546        m_progressDlg->hide();
    718         //slotAlbumSelected();        // ?
    719547        return;
    720548    }
  • extensions/digikam_export/piwigoexport/piwigowindow.h

    r4770 r4874  
    8080    void slotError(const QString& msg);
    8181    void slotAlbums(const QList<GAlbum>& albumList);
    82     void slotPhotos(const QList<GPhoto>& photoList);
    8382    void slotAlbumSelected();
    84 //    void slotOpenPhoto(const KUrl& url);      // DISABLED for NOW!
    85     void slotNewAlbum();
    8683    void slotAddPhoto();
    8784    void slotAddPhotoNext();
  • extensions/digikam_export/piwigoexport/plugin_piwigoexport.cpp

    r4770 r4874  
    125125    if (action == m_action)
    126126        return KIPI::ExportPlugin;
    127 //     if (action == m_action_configure)
    128 //         return KIPI::ToolsPlugin;
    129 //
     127
    130128    kWarning() << "Unrecognized action for plugin category identification";
    131129    return KIPI::ExportPlugin;
Note: See TracChangeset for help on using the changeset viewer.