QList<KIPI::ImageCollection> Plugins::ImageCollectionSelector::selectedImageCollections() const
{
    if ( m_interface ) {
        KIPI::ImageCollection collection = m_interface->currentSelection();
        if (!collection.isValid()) {
            collection = m_interface->currentAlbum();
        }
        if (collection.isValid()) {
            QList<KIPI::ImageCollection> res;
            res.append(collection);
            return res;
        }
        // probably never happens:
        return m_interface->allAlbums();
    }
    return QList<KIPI::ImageCollection>();
}
Beispiel #2
0
void WSWindow::slotRefreshUI()
{

  if (!service || !service->isLoggedIn())
    {
      widget->existingAlbum->setEnabled(false);
      widget->newAlbum->setEnabled(false);
      widget->addToAlbum->setEnabled(false);
      widget->uploadAlbums->setEnabled(false);
      widget->uploadAllAlbums->setEnabled(false);
      widget->album->setEnabled(false);
      widget->addPhotosToNewAlbumName->setEnabled(false);
      widget->configuration->setEnabled(false);
      widget->category->setEnabled(false);
      widget->subcategory->setEnabled(false);
      widget->matchCategories->setEnabled(false);
      widget->privateMode->setEnabled(false);

      return;
    }

  widget->existingAlbum->setEnabled(true);
  widget->newAlbum->setEnabled(true);




  widget->matchCategories->setEnabled(true);
  widget->privateMode->setEnabled(true);





  // Update lists of albums we can upload to
  replaceContents(widget->album,service->availableAlbums());



  // Fix count in upload all albums
  if(service->availableAlbums().size())
    {
      Q3ValueList<KIPI::ImageCollection> ic = interface->allAlbums();
      int newAlbums=0;

      if (service->availableAlbums().size() && ic.size())
	{	  
	  for (unsigned int i=0; i<ic.size(); i++)
	    if (service->name(ic[i]).length() &&
		!service->albumExists(service->name(ic[i])))
	      
	      newAlbums++;
	}

      if (newAlbums)
	{
	  widget->uploadAllAlbums->setEnabled(true);
	  widget->uploadAllAlbums->setText(tr(
					      "Upload all (%1) albums " 
					      "that do not exist already").
					   arg(newAlbums));
	}
      else
	{
	  widget->uploadAllAlbums->setEnabled(false);
	  widget->uploadAllAlbums->setText(tr("Upload all albums "
					      "that do not exist already"));
	}
    }  /* Albums available? */

    

  // Update list of possible configurations if applicable

  if(service->supportsConfigurations() && 
     service->availableConfigurations().size())
    {
    replaceContents(widget->configuration,
		    service->availableConfigurations());
    widget->configuration->setEnabled(true);
    }
  else
    widget->configuration->setEnabled(false);

  // Update list of possible categories  
  if(service->supportsCategories() && service->availableCategories().size())
    {
      replaceContents(widget->category,
		      service->availableCategories());
      widget->category->setEnabled(true);
    }
  else
    widget->category->setEnabled(false);
  
  if(service->supportsSubcategories() && 
     service->availableSubcategories().size())
    {
    replaceContents(widget->subcategory,
		    service->availableSubcategories());
    widget->subcategory->setEnabled(true);
    }
  else
    widget->subcategory->setEnabled(false);



  KIPI::ImageCollection ic = interface->currentSelection();

  if (!ic.isValid() || !ic.images().size() || 
      !service->availableAlbums().size() )
    // No selection, or at least not any images.
    {
    widget->addToAlbum->setEnabled(false);
    widget->album->setEnabled(false);
    widget->addPhotosToNewAlbumName->setEnabled(false);
    }
  else
    {
      widget->addToAlbum->setEnabled(true);
      widget->addToAlbum->setText(tr("Add %1 selected images to")
				  .arg(ic.images().size()));
      widget->album->setEnabled(true);
      widget->addPhotosToNewAlbumName->setEnabled(true);
    }


  ic = interface->currentAlbum();

  if (!ic.isValid() || !ic.images().size())
    // No selection, or at least not any images.
    widget->uploadAlbums->setEnabled(false);
  else
    {
      widget->uploadAlbums->setEnabled(true);
      widget->uploadAlbums->setText(tr(
				       "Upload selected album \"%1\"")
				    .arg(service->name(ic).utf8()));
    }



}