Esempio 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 );
    }
}
Esempio n. 2
0
void UploadDialog::renameIpodAlbum()
{
    QList<QTreeWidgetItem*> selectedItems = m_ipodAlbumList->selectedItems();

    // only allow renaming of 1 album item
    if( selectedItems.size() != 1 )
        return;

    IpodAlbumItem* selected = dynamic_cast<IpodAlbumItem*>( selectedItems.first() );
    if( !selected )
        return;


    bool ok         = false;
    QString newName = KInputDialog::getText( i18n("Rename iPod Photo Album"),
                                             i18n("New album title:"),
                                             selected->text(0), &ok, this );
    if( ok )
    {
        // change the name on the ipod, and rename the listviewitem
        selected->setName( newName );
        // commit changes to the iPod
        GError* err = 0;
        itdb_photodb_write( m_itdb, &err );
    }
}
Esempio n. 3
0
void UploadDialog::startTransfer()
{
    if( !m_itdb || !m_uploadList->model()->hasChildren() )
        return;

    QTreeWidgetItem* selected = m_ipodAlbumList->currentItem();
    IpodAlbumItem* ipodAlbum  = dynamic_cast<IpodAlbumItem*>( selected );

    if( !selected || !ipodAlbum )
        return;

    m_transferring         = true;
    Itdb_PhotoAlbum* album = ipodAlbum->photoAlbum();

    enableButton(User1, false);
    enableButton(Close, false);

    GError* err = 0;

    while( QTreeWidgetItem* item = m_uploadList->takeTopLevelItem(0) )
    {
#define item static_cast<ImageListItem*>(item)
        kDebug() << "Uploading "      << item->pathSrc()
                 << " to ipod album " << album->name ;

        Itdb_Artwork* art = itdb_photodb_add_photo( m_itdb, QFile::encodeName( item->pathSrc() ), 0, 0, &err );

        if( !art )
        {
            if( err )
            {
                kDebug() << "Error adding photo " << item->pathSrc() << " to database:"
                              << err->message ;
                err = 0;
            }
        }
        else
        {
            itdb_photodb_photoalbum_add_photo( m_itdb, album, art, 0 );
        }

        delete item;
#undef item
    }

    itdb_photodb_write( m_itdb, &err );
    if( err ) kDebug() << "Failed with error: " << err->message ;

    reloadIpodAlbum( ipodAlbum, album );

    IpodAlbumItem* library = static_cast<IpodAlbumItem*>( m_ipodAlbumList->topLevelItem(0) );
    reloadIpodAlbum( library, library->photoAlbum() );

    m_transferring = false;

    enableButtons();
}
Esempio n. 4
0
static int do_remove (int argc, char **argv)
{
    GError *error = NULL;
    Itdb_PhotoDB *db;
    Itdb_PhotoAlbum *album = NULL;

    if (argc < 4)
    {
	g_print (_("Insufficient number of command line arguments.\n"));
	usage (argc, argv);
	return 1;
    }

    db = itdb_photodb_parse (argv[2], &error);
    if (db == NULL)
    {
	if (error)
	{
	    g_print (_("Error reading iPod photo database (%s).\n"),
		     error->message);
	    g_error_free (error);
	    error = NULL;
	}
	else
	{
	    g_print (_("Error reading iPod photo database.\n"));
	}
	return 1;
    }

    /* Find specified photoalbum */
    if (strcmp (argv[3], "NULL") != 0)
    {
	album = itdb_photodb_photoalbum_by_name (db, argv[3]);
	if (!album)
	{
	    g_print (_("Specified album '%s' not found. Aborting.\n"),
		     argv[3]);
	    itdb_photodb_free (db);
	    return 1;
	}
    }

    if (argc == 4)
    {
	/* Remove photoalbum altogether, but preserve pics */
	if (album == NULL)
	{
	    g_print (_("Cannot remove Photo Library playlist. Aborting.\n"));
	    itdb_photodb_free (db);
	    return 1;
	}
	itdb_photodb_photoalbum_remove (db, album, FALSE);
    }
    else
    {
	/* Remove specified pictures */
	int i;
	for (i=4; i<argc; ++i)
	{
	    Itdb_Artwork *photo;
	    guint32 id;

	    id = g_strtod (argv[i], NULL);

	    photo = get_photo_by_id (db, id);

	    if (photo == NULL)
	    {
		g_print (_("Warning: could not find photo with ID <%d>. Skipping...\n"),
			 id);
	    }
	    else
	    {
		itdb_photodb_remove_photo (db, album, photo);
	    }
	}
    }

    itdb_photodb_write (db, NULL);
    itdb_photodb_free (db);
    return 0;
}
Esempio n. 5
0
static int do_add (int argc, char **argv)
{
    GError *error = NULL;
    Itdb_PhotoAlbum *album = NULL;
    Itdb_PhotoDB *db;
    gint i; 

    if (argc < 4)
    {
	g_print (_("Insufficient number of command line arguments.\n"));
	usage (argc, argv);
	return 1;
    }

    db = itdb_photodb_parse (argv[2], &error);
    if (db == NULL)
    {
	if (error)
	{
	    g_print (_("Error reading iPod photo database (%s).\nWill attempt to create a new database.\n"), error->message);
	    g_error_free (error);
	    error = NULL;
	}
	else
	{
	    g_print (_("Error reading iPod photo database, will attempt to create a new database\n"));
	}
	db = itdb_photodb_create (argv[2]);
    }

    /* Find or create specified photoalbum */
    if (strcmp (argv[3], "NULL") != 0)
    {
	album = itdb_photodb_photoalbum_by_name (db, argv[3]);
	if (!album)
	{
	    album = itdb_photodb_photoalbum_create (db, argv[3], -1);
	}
    }

    for (i=4; i<argc; ++i)
    {
	Itdb_Artwork *photo;
	
	photo = itdb_photodb_add_photo (db, argv[i],
					-1, GDK_PIXBUF_ROTATE_NONE, &error);
	if (photo == NULL)
	{
	    if (error)
	    {
		g_print (_("Error adding photo (%s) to photo database: %s\n"),
			 argv[i], error->message);
		g_error_free (error);
		error = NULL;
	    }
	}
	else
	{
	    if (album)
	    {
		itdb_photodb_photoalbum_add_photo (db, album, photo, -1);
	    }
	}
    }

    itdb_photodb_write (db, NULL);
    itdb_photodb_free (db);
    return 0;
}