Changeset 4874 for extensions/digikam_export/piwigoexport/piwigowindow.cpp
- Timestamp:
- Feb 10, 2010, 10:18:02 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/digikam_export/piwigoexport/piwigowindow.cpp
r4770 r4874 39 39 #include <QTreeWidgetItem> 40 40 #include <QPointer> 41 #include <QHBoxLayout> 42 #include <QVBoxLayout> 41 43 42 44 // KDE includes … … 63 65 // Local includes 64 66 65 #include "albumdlg.h"66 67 #include "piwigos.h" 67 68 #include "piwigoconfig.h" … … 84 85 QTreeWidget* albumView; 85 86 86 QPushButton* newAlbumBtn;87 87 QPushButton* addPhotoBtn; 88 88 … … 111 111 logo = new KUrlLabel; 112 112 logo->setText(QString()); 113 logo->setUrl("http://piwigo. menalto.com");113 logo->setUrl("http://piwigo.org"); 114 114 logo->setPixmap(QPixmap(KStandardDirs::locate("data", "kipiplugin_piwigoexport/pics/piwigo_logo.png"))); 115 115 logo->setAlignment(Qt::AlignLeft); … … 119 119 albumView = new QTreeWidget; 120 120 QStringList labels; 121 labels << i18n("Albums"); // << i18n("ID");121 labels << i18n("Albums"); 122 122 albumView->setHeaderLabels(labels); 123 123 … … 126 126 QFrame *optionFrame = new QFrame; 127 127 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);134 128 135 129 addPhotoBtn = new QPushButton; … … 163 157 thumbDimensionSpinBox = new QSpinBox; 164 158 thumbDimensionSpinBox->setRange(32,800); 165 thumbDimensionSpinBox->setValue(12 0);159 thumbDimensionSpinBox->setValue(128); 166 160 167 161 captTitleCheckBox->setChecked(true); … … 199 193 // --------------------------------------------------------------------------- 200 194 201 vlay->addWidget(newAlbumBtn);202 195 vlay->addWidget(addPhotoBtn); 203 196 vlay->addWidget(optionsBox); … … 226 219 d(new Private(this)) 227 220 { 228 kDebug() << "BEGIN Window\n";229 230 231 221 setWindowTitle( i18n("Piwigo Export") ); 232 222 setButtons( KDialog::Close | KDialog::User1 | KDialog::Help); … … 310 300 group.writeEntry("Set description", d->captDescrCheckBox->isChecked()); 311 301 group.writeEntry("Maximum Width", d->dimensionSpinBox->value()); 302 group.writeEntry("Thumbnail Width", d->thumbDimensionSpinBox->value()); 312 303 313 304 delete m_talker; … … 324 315 this , SLOT( slotAlbumSelected() ) ); 325 316 326 connect(d->newAlbumBtn, SIGNAL(clicked()),327 this, SLOT(slotNewAlbum()));328 329 317 connect(d->addPhotoBtn, SIGNAL(clicked()), 330 318 this, SLOT(slotAddPhoto())); … … 350 338 connect(m_talker, SIGNAL(signalAlbums(const QList<GAlbum>&)), 351 339 this, SLOT(slotAlbums(const QList<GAlbum>&))); 352 353 connect(m_talker, SIGNAL(signalPhotos(const QList<GPhoto>&)),354 this, SLOT(slotPhotos(const QList<GPhoto>&)));355 340 356 341 connect(m_talker, SIGNAL(signalAddPhotoSucceeded()), … … 391 376 d->captDescrCheckBox->setChecked(false); 392 377 378 379 d->thumbDimensionSpinBox->setValue(group.readEntry("Thumbnail Width", 128)); 393 380 } 394 381 … … 443 430 if (val) { 444 431 setCursor(Qt::WaitCursor); 445 d->newAlbumBtn->setEnabled(false);446 432 d->addPhotoBtn->setEnabled(false); 447 433 } else { 448 434 setCursor(Qt::ArrowCursor); 449 435 bool loggedIn = m_talker->loggedIn(); 450 // TODO Enable the button to implement the feature451 //d->newAlbumBtn->setEnabled(loggedIn);452 436 d->addPhotoBtn->setEnabled(loggedIn && d->albumView->currentItem()); 453 437 } … … 492 476 int i = 0; 493 477 494 kDebug() << "Parent : " << parentRefNum << "\n";495 496 478 while ( !found && i < parentItemList.size() ) { 497 479 parentItem = parentItemList.at(i); 498 499 kDebug() << "User : " << parentItem->data(1, Qt::UserRole).toInt() << "\n";500 480 501 481 if (parentItem && (parentItem->data(1, Qt::UserRole).toInt() == parentRefNum)) { … … 505 485 item->setData(1, Qt::UserRole, album.ref_num ); 506 486 item->setText(2, i18n("Album") ); 507 508 kDebug() << "Child : " << album.name << " " << album.ref_num << "\n";509 487 510 488 parentItem->addChild(item); … … 515 493 i++; 516 494 } 517 518 /*if (!found && i == parentItemList.size() )519 {520 workList.append(album);521 }*/522 495 } 523 496 } 524 497 } 525 498 526 // FIXME: avoid duplications527 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 543 499 void PiwigoWindow::slotAlbumSelected() 544 500 { 545 501 QTreeWidgetItem* item = d->albumView->currentItem(); 546 547 kDebug() << "slotAlbumSelected\n";548 502 549 503 // stop loading if user clicked an image 550 504 if ( item->text(2) == i18n("Image") ) 551 505 return; 552 553 kDebug() << "Album\n";554 506 555 507 if (!item) { … … 562 514 if (m_talker->loggedIn() && albumId ) { 563 515 d->addPhotoBtn->setEnabled(true); 564 //m_talker->listPhotos(albumName);565 516 } else { 566 517 d->addPhotoBtn->setEnabled(false); … … 569 520 } 570 521 571 void PiwigoWindow::slot NewAlbum()572 { 573 QPointer<AlbumDlg> dlg = new AlbumDlg(d->widget);574 dlg->titleEdit->setFocus(); 575 if ( dlg->exec() != QDialog::Accepted) {576 delete dlg;522 void 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.")); 577 528 return; 578 529 } 579 530 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: \\ / * ? \" \' & < > | . + # ( ) 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) { 686 532 mpUploadList->append( (*it).path() ); 687 533 } … … 692 538 m_uploadCount = 0; 693 539 slotAddPhotoNext(); 694 #endif695 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();711 540 } 712 541 … … 716 545 m_progressDlg->reset(); 717 546 m_progressDlg->hide(); 718 //slotAlbumSelected(); // ?719 547 return; 720 548 }
Note: See TracChangeset
for help on using the changeset viewer.