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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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    }
Note: See TracChangeset for help on using the changeset viewer.