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>();
}
ViewerWidget::ViewerWidget(KIPI::Interface* i)
{
    kipiInterface = i;

    KIPI::ImageCollection selection = kipiInterface->currentSelection();
    KIPI::ImageCollection album = kipiInterface->currentAlbum();

    KUrl::List myfiles; //pics which are displayed in imageviewer
    QString selectedImage; //selected pic in hostapp

    int foundNumber = 0;
    texture         = 0;
    file_idx        = 0; //index of picture to be displayed

    //determine screen size for isReallyFullScreen
    QDesktopWidget dw;
    screen_width = dw.screenGeometry(this).width();

    if ( selection.images().count()==0 )
    {
        kDebug() << "no image selected, load entire album" ;
        myfiles = album.images();
    }
    else if ( selection.images().count()==1 )
    {
        kDebug() << "one image selected, load entire album and start with selected image" ;
        selectedImage = selection.images().first().path();
        myfiles = album.images();
    }
    else if ( selection.images().count()>1 )
    {
        kDebug() << "load " << selection.images().count() << " selected images" ;
        myfiles = selection.images();
    }

    // populate QStringList::files
    for(KUrl::List::Iterator it = myfiles.begin(); it != myfiles.end(); ++it)
    {
        // find selected image in album in order to determine the first displayed image
        // in case one image was selected and the entire album was loaded
        it->cleanPath();
        QString s = (*it).path();

        if ( s == selectedImage )
        {
            kDebug() << "selected img  " << selectedImage << " has idx=" << foundNumber ;
            file_idx = foundNumber;
        }

        // only add images to files
        KMimeType::Ptr type = KMimeType::findByUrl(s);
        bool isImage = type->name().contains("image",Qt::CaseInsensitive);

        if ( isImage )
        {
            files.append(s);
            foundNumber++;  //counter for searching the start image in case one image is selected
            kDebug() << s << " type=" << type->name() ;
        }
    }

    firstImage = true;
    kDebug() << files.count() << "images loaded" ;

    // initialize cache
    for(int i = 0 ; i < CACHESIZE ; ++i)
    {
        cache[i].file_index = EMPTY;
        cache[i].texture    = new Texture(kipiInterface);
    }

    if ( files.isEmpty() )
        return;

    // define zoomfactors for one zoom step
    zoomfactor_scrollwheel = 1.1F;
    zoomfactor_mousemove   = 1.03F;
    zoomfactor_keyboard    = 1.05F;

    // load cursors for zooming and panning
    QString file;
    file       = KStandardDirs::locate( "data", "kipiplugin_imageviewer/pics/zoom.png" );
    zoomCursor = QCursor(QPixmap(file));
    file       = KStandardDirs::locate( "data", "kipiplugin_imageviewer/pics/hand.png" );
    moveCursor = QCursor(QPixmap(file));

    // get path of nullImage in case QImage can't load the image
    nullImage  = KStandardDirs::locate( "data", "kipiplugin_imageviewer/pics/nullImage.png" );

    showFullScreen();

    // let the cursor dissapear after 2sec of inactivity
    connect(&timerMouseMove, SIGNAL(timeout()),
            this, SLOT(timeoutMouseMove()));

    timerMouseMove.start(2000);
    setMouseTracking(true);

    // while zooming is performed, the image is downsampled to zoomsize. This seems to
    // be the optimal way for a PentiumM 1.4G, Nvidia FX5200. For a faster setup, this might
    // not be necessary anymore
    zoomsize    = QSize(1024,768);

    // other initialisations
    wheelAction = changeImage;
}
示例#3
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()));
    }



}