Exemplo n.º 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 );
    }
}
Exemplo n.º 2
0
void UploadDialog::loadImagesFromCurrentSelection()
{
#if KIPI_PLUGIN
    /// add selected items to the ImageList
    ImageCollection images = iface()->currentSelection();

    if( images.isValid() )
    {
        KUrl::List selected = images.images();
        for( KUrl::List::Iterator it = selected.begin(); it != selected.end(); ++it )
        {
            addUrlToList( (*it).path() );
        }
    }
#endif
}
Exemplo n.º 3
0
Arquivo: Main.cpp Projeto: Acly/hdrv
int main(int argc, char * argv[])
{
  QGuiApplication app(argc, argv);
  qmlRegisterType<ImageDocument>("Hdrv", 1, 0, "ImageDocument");
  qmlRegisterType<ImageCollection>("Hdrv", 1, 0, "ImageCollection");
  qmlRegisterType<ImageArea>("Hdrv", 1, 0, "ImageArea");
  qmlRegisterType<Settings>("Hdrv", 1, 0, "Settings");
  qmlRegisterType<IPCServer>("Hdrv", 1, 0, "Server");
  qmlRegisterType<IPCClient>("Hdrv", 1, 0, "Client");

  Settings settings;
  IPCServer server;
  IPCClient client;
  ImageCollection images;
  QQmlApplicationEngine engine;
  engine.rootContext()->setContextProperty("settings", &settings);
  engine.rootContext()->setContextProperty("images", &images);
  engine.rootContext()->setContextProperty("server", &server);
  engine.rootContext()->setContextProperty("client", &client);

  QObject::connect(&server, SIGNAL(openFile(QUrl const &)), &images, SLOT(load(QUrl const &)));
  QObject::connect(&server, &IPCServer::openFile, &moveToForeground);

  bool fileOpened = false;
  for (int i = 1; i < app.arguments().count(); ++i) {
    auto url = QUrl::fromLocalFile(app.arguments()[i]);
    if (!client.remoteOpenFile(url)) {
      images.load(url);
      fileOpened = true;
    }
  }

  if (app.arguments().count() > 1 && !fileOpened) {
    return 0;
  }

  if (settings.singleInstance() && !client.isServerAvailable()) {
    server.start();
  }

  engine.load(QUrl("qrc:/hdrv/view/Main.qml"));

  return app.exec();
}
Exemplo n.º 4
0
int main(int argc, char * argv[])
{
  QGuiApplication app(argc, argv);
  qmlRegisterType<ImageDocument>("Hdrv", 1, 0, "ImageDocument");
  qmlRegisterType<ImageCollection>("Hdrv", 1, 0, "ImageCollection");
  qmlRegisterType<ImageArea>("Hdrv", 1, 0, "ImageArea");
  qmlRegisterType<Settings>("Hdrv", 1, 0, "Settings");

  Settings settings;
  ImageCollection images;
  QQmlApplicationEngine engine;
  engine.rootContext()->setContextProperty("settings", &settings);
  engine.rootContext()->setContextProperty("images", &images);

  for (int i = 1; i < app.arguments().count(); ++i) {
    images.load(QUrl::fromLocalFile(app.arguments()[i]));
  }

  engine.load(QUrl("qrc:/hdrv/view/Main.qml"));

  return app.exec();
}
void ImageCollectionTest::testImages()
{
  ImageCollection c;
  
  QCOMPARE( c.getIds( QStringList() ).count(), 0 );
  
  QImage image( "test.png" );
  c.addImage( image, QStringList() );
   
  // Verify that we have one image and get the id for it
  QList<int> ids = c.getIds( QStringList() );
  QCOMPARE( ids.count(), 1 );
  int id = ids[0];
  
  QImage fromDb = c.getImage( id );
  QVERIFY( pixelCompareImages( image, fromDb ) );
  
// Will call qFatal and end the application
//  QTest::ignoreMessage( QtFatalMsg, "Failed to get image id" );
//  fromDb = c.getImage( id+1 );
//  QVERIFY( fromDb.isNull() );
  
  QSqlDatabase::removeDatabase( QLatin1String( QSqlDatabase::defaultConnection ) );
}
void ImageCollectionTest::testTags()
{
  ImageCollection c;
  
  // Make sure that the collection is empty
  QCOMPARE( c.getTags().count(), 0 );
  
  // At least one image is needed to be able to add tags
  c.addImage( QImage( "test.png" ), QStringList() );
  
  // Verify that we have one image and get the id for it
  QList<int> ids = c.getIds( QStringList() );
  QCOMPARE( ids.count(), 1 );
  int id = ids[0];
  
  // Add one tag, total one
  c.addTag( id, "Foo" );
  QCOMPARE( c.getTags().count(), 1 );

  // Add one tag, total two
  c.addTag( id, "Bar" );
  QCOMPARE( c.getTags().count(), 2 );
  
  // Add one tag, total three
  c.addTag( id, "Baz" );
  QCOMPARE( c.getTags().count(), 3 );
  
  // Add a duplicate tag, total three
  c.addTag( id, "Foo" );
  QCOMPARE( c.getTags().count(), 3 );
  
  // Try to add a tag to a nonexisting id
  QEXPECT_FAIL("", "The tag will be added to the non-existing image.", Continue);
  c.addTag( id+1, "Foz" );
  QCOMPARE( c.getTags().count(), 3 );
  
  QSqlDatabase::removeDatabase( QLatin1String( QSqlDatabase::defaultConnection ) );
}
void ImageCollectionTest::testImagesFromTags()
{
  ImageCollection c;
  
  QCOMPARE( c.getIds( QStringList() ).count(), 0 );
  
  QImage image( "test.png" );
  
  QStringList tags;
  tags << "Foo" << "Bar";
  
  c.addImage( image, tags );
  QCOMPARE( c.getTags().count(), 2 );
  QCOMPARE( c.getIds( QStringList() ).count(), 1 );
  QCOMPARE( c.getIds( QStringList() << "Foo" ).count(), 1 );
  QCOMPARE( c.getIds( QStringList() << "Bar" ).count(), 1 );
  QCOMPARE( c.getIds( tags ).count(), 1 );
  QCOMPARE( c.getIds( QStringList() << "Baz" ).count(), 0 );
  
  tags.clear();
  tags << "Baz";
  c.addImage( image, tags );
  QCOMPARE( c.getTags().count(), 3 );
  QCOMPARE( c.getIds( QStringList() ).count(), 2 );
  QCOMPARE( c.getIds( QStringList() << "Foo" ).count(), 1 );
  QCOMPARE( c.getIds( QStringList() << "Bar" ).count(), 1 );
  QCOMPARE( c.getIds( QStringList() << "Baz" ).count(), 1 );

  tags.clear();
  tags << "Bar" << "Baz";
  c.addImage( image, tags );
  QCOMPARE( c.getTags().count(), 3 );
  QCOMPARE( c.getIds( QStringList() ).count(), 3 );
  QCOMPARE( c.getIds( QStringList() << "Foo" ).count(), 1 );
  QCOMPARE( c.getIds( QStringList() << "Bar" ).count(), 2 );
  QCOMPARE( c.getIds( tags ).count(), 3 );
  QCOMPARE( c.getIds( QStringList() << "Baz" ).count(), 2 );
  
  QSqlDatabase::removeDatabase( QLatin1String( QSqlDatabase::defaultConnection ) );
}
Exemplo n.º 8
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();
}