예제 #1
0
void UploadDialog::createIpodAlbum()
{
    QString helper;

#if KIPI_PLUGIN
    ImageCollection album = iface()->currentAlbum();
    if( album.isValid() )
        helper = album.name();
#endif

    bool ok = false;
    QString newAlbum = KInputDialog::getText( i18n("New iPod Photo Album"),
                                              i18n("Create a new album:"),
                                              helper, &ok, this );
    if( ok )
    {
        kDebug() << "creating album " << newAlbum ;

        Itdb_PhotoAlbum* photoAlbum = itdb_photodb_photoalbum_create( m_itdb, QFile::encodeName( newAlbum ), -1/*end*/ );
        // add the new album to the list view
        new IpodAlbumItem( m_ipodAlbumList, photoAlbum );
        m_ipodAlbumList->clearSelection();

        // commit the changes to the iPod
        GError* err = 0;
        itdb_photodb_write( m_itdb, &err );
    }
}
예제 #2
0
/*!
    \fn KmlExport::generate()
 */
void KmlExport::generate()
{
    //! @todo perform a test here before continuing.
    createDir(QString(m_tempDestDir + m_imageDir));

    m_progressDialog->show();
    ImageCollection selection = m_interface->currentSelection();
    ImageCollection album     = m_interface->currentAlbum();

    // create the document, and it's root
    m_kmlDocument                   = new QDomDocument("");
    QDomImplementation impl;
    QDomProcessingInstruction instr = m_kmlDocument->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"");
    m_kmlDocument->appendChild(instr);
    QDomElement kmlRoot             = m_kmlDocument->createElementNS("http://www.opengis.net/kml/2.2", "kml");
    m_kmlDocument->appendChild( kmlRoot );

    QDomElement kmlAlbum            = addKmlElement(kmlRoot, "Document");
    QDomElement kmlName             = addKmlTextElement(kmlAlbum, "name", album.name());
    QDomElement kmlDescription      = addKmlHtmlElement(kmlAlbum, "description",
                                                        "Created with kmlexport <a href=\"http://www.digikam.org/\">kipi-plugin</a>");

    if (m_GPXtracks)
    {
        addTrack(kmlAlbum);
    }

    KPMetadata meta;
    KUrl::List images = selection.images();
    int defectImage   = 0;
    int pos           = 1;
    int count         = images.count();
    KUrl::List::ConstIterator imagesEnd (images.constEnd());

    for( KUrl::List::ConstIterator selIt = images.constBegin(); selIt != imagesEnd; ++selIt, ++pos)
    {
        double alt, lat, lng;
        KUrl url        = *selIt;
        KPImageInfo info(url);
        bool hasGPSInfo = info.hasGeolocationInfo();

        if (hasGPSInfo)
        {
            lat = info.latitude();
            lng = info.longitude();
            alt = info.altitude();
        }
        else
        {
            meta.load(url.path());
            hasGPSInfo = meta.getGPSInfo(alt, lat, lng);
        }

        if ( hasGPSInfo )
        {
            // generation de l'image et de l'icone
            generateImagesthumb(url, kmlAlbum);
        }
        else
        {
            logWarning(i18n("No position data for '%1'", info.name()));
            defectImage++;
        }

        m_progressDialog->progressWidget()->setProgress(pos, count);
        kapp->processEvents();
    }

    if (defectImage)
    {
        /** @todo if defectImage==count there are no pictures exported, does is it worth to continue? */
        KMessageBox::information(kapp->activeWindow(),
                                 i18np("No position data for 1 picture",
                                       "No position data for %1 pictures", defectImage));
    }

    /** @todo change to kml or kmz if compressed */
    QFile file( m_tempDestDir + m_KMLFileName + ".kml");
    /** @todo handle file opening problems */
    file.open( QIODevice::WriteOnly );
    QTextStream stream( &file ); // we will serialize the data into the file
    stream << m_kmlDocument->toString();
    file.close();

    delete m_kmlDocument;
    m_kmlDocument = 0;

    KIO::moveAs(m_tempDestDir, m_baseDestDir, KIO::HideProgressInfo | KIO::Overwrite);
    logInfo(i18n("Move to final directory"));
    m_progressDialog->close();
}