~ubuntu-branches/ubuntu/trusty/digikam/trusty

« back to all changes in this revision

Viewing changes to extra/kipi-plugins/mediawiki/wmwidget.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2012-11-26 18:24:20 UTC
  • mfrom: (1.9.1) (3.1.23 experimental)
  • Revision ID: package-import@ubuntu.com-20121126182420-qoy6z0nx4ai0wzcl
Tags: 4:3.0.0~beta3-0ubuntu1
* New upstream release
  - Add build-deps :  libhupnp-dev, libqtgstreamer-dev, libmagickcore-dev
* Merge from debian, remaining changes:
  - Make sure libqt4-opengl-dev, libgl1-mesa-dev and libglu1-mesa-dev only
    install on i386,amd64 and powerpc
  - Depend on libtiff-dev instead of libtiff4-dev
  - Drop digikam breaks/replaces kipi-plugins-common since we're past the
    LTS release now
  - digikam to recommend mplayerthumbs | ffmpegthumbs. We currently only
    have latter in the archives, even though former is also supposed to
    be part of kdemultimedia. (LP: #890059)
  - kipi-plugins to recommend www-browser rather than konqueror directly
    since 2.8 no direct usage of konqueror is present in the flickr
    plugin anymore (LP: #1011211)
  - Keep kubuntu_mysqld_executable_name.diff
  - Don't install libkipi translations
  - Keep deps on libcv-dev, libcvaux-dev
  - Keep split packaging of libraries
  - Replace icons from KDE 3 time in debian/xpm.d/*.xpm with the new
    versions (LP: #658047)
* Update debian/not-installed

Show diffs side-by-side

added added

removed removed

Lines of Context:
200
200
    d->imgList->setControlButtonsPlacement(KPImagesList::ControlButtonsBelow);
201
201
    d->imgList->setAllowRAW(true);
202
202
    d->imgList->loadImagesFromCurrentSelection();
203
 
    d->imgList->listView()->setWhatsThis(i18n("This is the list of images to upload to your Wikimedia account."));
 
203
    d->imgList->listView()->setWhatsThis(i18n("This is the list of images to upload to the wiki."));
204
204
 
205
205
    // --------------------- Upload tab ----------------------------------
206
206
 
230
230
    QVBoxLayout* uploadBoxLayout = new QVBoxLayout(uploadPanel);
231
231
 
232
232
    d->fileBox = new QWidget(uploadBox);
233
 
    d->fileBox->setWhatsThis(i18n("This is the login form to your Wikimedia account."));
 
233
    d->fileBox->setWhatsThis(i18n("This is the login form to your account on the chosen wiki."));
234
234
    QGridLayout* fileBoxLayout = new QGridLayout(d->fileBox);
235
235
 
236
236
    loadImageInfoFirstLoad();
241
241
    d->descEdit     = new KTextEdit(d->fileBox);
242
242
    d->descEdit->setPlainText(d->defaultMessage);
243
243
    d->descEdit->setTabChangesFocus(1);
 
244
    d->descEdit->setAcceptRichText(false);
244
245
    d->categoryEdit = new KTextEdit(d->fileBox);
245
246
    d->categoryEdit->setPlainText(d->defaultMessage);
246
247
    d->categoryEdit->setTabChangesFocus(1);
 
248
    d->categoryEdit->setAcceptRichText(false);
247
249
 
248
250
    d->latitudeEdit  = new KLineEdit(d->defaultMessage, d->fileBox);
249
251
    d->longitudeEdit = new KLineEdit(d->defaultMessage, d->fileBox);
296
298
    QGridLayout* loginBoxLayout = new QGridLayout(d->loginBox);
297
299
 
298
300
    d->wikiSelect = new QComboBox(d->loginBox);
299
 
    KPushButton* newWikiBtn = new KPushButton(KGuiItem(i18n("New"), "list-add", i18n("Create new wiki")), d->loginBox);
 
301
    KPushButton* newWikiBtn = new KPushButton(KGuiItem(i18n("New"), "list-add", i18n("Add a wiki to this list")), d->loginBox);
300
302
    d->nameEdit   = new KLineEdit(d->loginBox);
301
303
    d->passwdEdit = new KLineEdit(d->loginBox);
302
304
    d->passwdEdit->setEchoMode(KLineEdit::Password);
303
305
 
304
 
    d->wikiSelect->addItem(i18n("kamelopedia"),        QString("http://kamelopedia.mormo.org/api.php"));
305
 
    d->wikiSelect->addItem(i18n("MediaWiki"),          QString("http://www.mediawiki.org/w/api.php"));
306
 
    d->wikiSelect->addItem(i18n("Wikia:foto"),         QString("http://foto.wikia.com/api.php"));
307
 
    d->wikiSelect->addItem(i18n("Wikia:uncyclopedia"), QString("http://uncyclopedia.wikia.com/api.php"));
308
 
    d->wikiSelect->addItem(i18n("Wikimedia:commons"),  QString("http://commons.wikimedia.org/w/api.php"));
309
 
    d->wikiSelect->addItem(i18n("Wikimedia:meta"),     QString("http://meta.wikimedia.org/w/api.php"));
 
306
    d->wikiSelect->addItem(i18n("Wikimedia Commons"),  QString("http://commons.wikimedia.org/w/api.php"));
 
307
    d->wikiSelect->addItem(i18n("Wikimedia Meta"),     QString("http://meta.wikimedia.org/w/api.php"));
 
308
    d->wikiSelect->addItem(i18n("Wikipedia"),          QString("http://en.wikipedia.org/w/api.php"));
310
309
    d->wikiSelect->addItem(i18n("Wikibooks"),          QString("http://en.wikibooks.org/w/api.php"));
311
310
    d->wikiSelect->addItem(i18n("Wikinews"),           QString("http://en.wikinews.org/w/api.php"));
312
 
    d->wikiSelect->addItem(i18n("Wikipedia"),          QString("http://en.wikipedia.org/w/api.php"));
313
311
    d->wikiSelect->addItem(i18n("Wikiquote"),          QString("http://en.wikiquote.org/w/api.php"));
314
312
    d->wikiSelect->addItem(i18n("Wikisource"),         QString("http://en.wikinews.org/w/api.php"));
315
313
    d->wikiSelect->addItem(i18n("Wiktionary"),         QString("http://en.wiktionary.org/w/api.php"));
 
314
    d->wikiSelect->addItem(i18n("MediaWiki"),          QString("http://www.mediawiki.org/w/api.php"));
 
315
    d->wikiSelect->addItem(i18n("Wikia Foto"),         QString("http://foto.wikia.com/api.php"));
 
316
    d->wikiSelect->addItem(i18n("Wikia Uncyclopedia"), QString("http://uncyclopedia.wikia.com/api.php"));
316
317
 
317
318
    d->wikiSelect->setEditable(false);
318
319
 
376
377
    loginBoxLayout->setObjectName("d->loginBoxLayout");
377
378
 
378
379
    d->accountBox         = new KHBox(d->userBox);
379
 
    d->accountBox->setWhatsThis(i18n("This is the Wikimedia account that is currently logged in."));
 
380
    d->accountBox->setWhatsThis(i18n("This is the account that is currently logged in."));
380
381
 
381
382
    QLabel* userNameLbl   = new QLabel(d->accountBox);
382
 
    userNameLbl->setText(i18nc("Wikimedia account settings", "Logged as: "));
 
383
    userNameLbl->setText(i18nc("Username which is used to connect to the wiki", "Logged as: "));
383
384
    d->userNameDisplayLbl = new QLabel(d->accountBox);
384
385
    QLabel* space         = new QLabel(d->accountBox);
385
386
    d->changeUserBtn      = new KPushButton(KGuiItem(i18n("Change Account"), "system-switch-user",
386
 
                               i18n("Logout and change Wikimedia Account used for transfer")),
 
387
                               i18n("Logout and change the account used for transfer")),
387
388
                               d->accountBox);
388
389
    d->accountBox->setStretchFactor(space, 10);
389
390
    d->accountBox->hide();
394
395
    // --------------------- Login area ----------------------------------
395
396
 
396
397
    d->textBox                 = new QWidget(panel2);
397
 
    d->textBox->setWhatsThis(i18n("This is the login form to your Wikimedia account."));
 
398
    d->textBox->setWhatsThis(i18n("This is the login form to your account on the chosen wiki."));
398
399
    QGridLayout* textBoxLayout = new QGridLayout(d->textBox);
399
400
 
400
401
    QLabel* authorLbl      = new QLabel(i18n("Author:"), d->textBox);
432
433
    QLabel* genCatLbl      = new QLabel(i18n("Generic categories:"), d->textBox);
433
434
    d->genCatEdit          = new KTextEdit(d->textBox);
434
435
    d->genCatEdit->setTabChangesFocus(1);
 
436
    d->genCatEdit->setWhatsThis(i18n("This is a place to enter categories that will be added to all the files."));
 
437
    d->genCatEdit->setAcceptRichText(false);
435
438
 
436
439
    QLabel* genTxtLbl      = new QLabel(i18n("Generic text:"), d->textBox);
437
440
    d->genTxtEdit          = new KTextEdit(d->textBox);
438
441
    d->genTxtEdit->setTabChangesFocus(1);
 
442
    d->genTxtEdit->setWhatsThis(i18n("This is a place to enter text that will be added to all the files, below the Information template."));
 
443
    d->genTxtEdit->setAcceptRichText(false);
439
444
 
440
445
    textBoxLayout->addWidget(authorLbl,          1, 0, 1, 1);
441
446
    textBoxLayout->addWidget(sourceLbl,          2, 0, 1, 1);
539
544
            this, SLOT(slotAddWikiClicked()));
540
545
 
541
546
    connect(d->titleEdit, SIGNAL(editingFinished()),
 
547
            this, SLOT(slotRestoreExtension()));
 
548
 
 
549
    connect(d->titleEdit, SIGNAL(textEdited(const QString&)),
542
550
            this, SLOT(slotApplyTitle()));
543
551
 
544
 
    connect(d->dateEdit, SIGNAL(editingFinished()),
 
552
    connect(d->dateEdit, SIGNAL(textEdited(const QString&)),
545
553
            this, SLOT(slotApplyDate()));
546
554
 
547
555
    // Problem: textChanged() is also called when the text is changed by setText()
548
 
    // editingFinished() would be better, but KTextEdit does not have this.
 
556
    // textEdited() would be better, but KTextEdit does not have this.
549
557
    // Solution for the moment: we do not setText() when the selection changes
550
558
    connect(d->categoryEdit, SIGNAL(textChanged()),
551
559
            this, SLOT(slotApplyCategories()));
552
560
 
553
561
    // Problem: textChanged() is also called when the text is changed by setText()
554
 
    // editingFinished() would be better, but KTextEdit does not have this.
 
562
    // textEdited() would be better, but KTextEdit does not have this.
555
563
    // Solution for the moment: we do not setText() when the selection changes
556
564
    connect(d->descEdit, SIGNAL(textChanged()),
557
565
            this, SLOT(slotApplyDescription()));
558
566
 
559
 
    connect(d->latitudeEdit, SIGNAL(editingFinished()),
 
567
    connect(d->latitudeEdit, SIGNAL(textEdited(const QString&)),
560
568
            this, SLOT(slotApplyLatitude()));
561
569
 
562
 
    connect(d->longitudeEdit, SIGNAL(editingFinished()),
 
570
    connect(d->longitudeEdit, SIGNAL(textEdited(const QString&)),
563
571
            this, SLOT(slotApplyLongitude()));
564
572
 
565
573
    connect(d->imgList, SIGNAL(signalItemClicked(QTreeWidgetItem*)),
807
815
    }
808
816
}
809
817
 
 
818
void WmWidget::slotRestoreExtension()
 
819
{
 
820
    kDebug() << "RestoreExtension";
 
821
 
 
822
    QString imageTitle;
 
823
    QString originalExtension;
 
824
    QString currentExtension;
 
825
    KUrl::List urls;
 
826
    QMap<QString, QString> imageMetaData;
 
827
    QList<QTreeWidgetItem*> selectedItems = d->imgList->listView()->selectedItems();
 
828
 
 
829
    // Build the list of items to rename
 
830
    for (int i = 0; i < selectedItems.size(); ++i)
 
831
    {
 
832
        KPImagesListViewItem* l_item = dynamic_cast<KPImagesListViewItem*>(selectedItems.at(i));
 
833
        urls.append(l_item->url());
 
834
    }
 
835
 
 
836
    for (int i = 0; i < urls.size(); ++i)
 
837
    {
 
838
        imageMetaData = d->imagesDescInfo[urls.at(i).path()];
 
839
        imageTitle = imageMetaData["title"];
 
840
 
 
841
        // Add original extension if removed
 
842
        currentExtension = imageTitle.split('.').last();
 
843
        originalExtension = urls.at(i).path().split('.').last();
 
844
        if(QString::compare(currentExtension, originalExtension, Qt::CaseInsensitive) != 0)
 
845
        {
 
846
            imageTitle.append(".").append(originalExtension);
 
847
            d->titleEdit->setText(imageTitle);
 
848
        }
 
849
 
 
850
        kDebug() << urls.at(i).path() << "renamed to" << imageTitle;
 
851
        imageMetaData["title"] = imageTitle;
 
852
        d->imagesDescInfo[urls.at(i).path()] = imageMetaData;
 
853
    }
 
854
}
 
855
 
810
856
void WmWidget::slotApplyTitle()
811
857
{
812
858
    kDebug() << "ApplyTitle";
814
860
    QString givenTitle = title();
815
861
    QString imageTitle;
816
862
    QString number;
817
 
    QString originalExtension;
818
 
    QString currentExtension;
819
863
    KUrl::List urls;
820
864
    QMap<QString, QString> imageMetaData;
821
865
    QList<QTreeWidgetItem*> selectedItems = d->imgList->listView()->selectedItems();
848
892
            imageTitle.replace(imageTitle.indexOf("#"), 1, number);
849
893
        }
850
894
 
851
 
        // Add original extension if removed
852
 
        currentExtension = imageTitle.split('.').last();
853
 
        originalExtension = urls.at(i).path().split('.').last();
854
 
        if(QString::compare(currentExtension, originalExtension, Qt::CaseInsensitive) != 0)
855
 
        {
856
 
            imageTitle.append(".").append(originalExtension);
857
 
            d->titleEdit->setText(imageTitle);
858
 
        }
859
 
 
860
895
        kDebug() << urls.at(i).path() << "renamed to" << imageTitle;
861
896
        imageMetaData["title"] = imageTitle;
862
897
        d->imagesDescInfo[urls.at(i).path()] = imageMetaData;
975
1010
 
976
1011
    for (int i = 0; i < urls.size(); ++i)
977
1012
    {
978
 
 
979
1013
        QMap<QString, QString> imageMetaData = d->imagesDescInfo[urls.at(i).path()];
980
1014
        imageMetaData["author"]              = author();
981
1015
        imageMetaData["source"]              = source();