/** * Saves the selected pictures. * First pops up a dialog box asking for the target dir. Then pops up * a progress dialog for feedback. */ void MainWindow::saveSelected() { /* Select target */ selectWorkDir(); /* Create a progress dialog */ QProgressDialog* progress = new QProgressDialog( i18n("Downloading ..."), i18n("Cancel"), 100, this, "progress", TRUE); progress->setCaption("Download"); connect(GPMessenger::instance(),SIGNAL(progressChanged(int)), progress,SLOT(setProgress(int))); progress->setAutoReset(false); progress->setAutoClose(false); progress->setProgress(0); KApplication::kApplication()->processEvents(); /* Download all pictures */ for (QIconViewItem *i = iconView->firstItem(); i && !progress->wasCancelled(); i = i->nextItem() ) { if (i->isSelected()) { /* Update progress dialog */ progress->setLabelText(i18n("Downloading ") + i->text() + "..."); /* Download picture */ GPInterface::downloadPicture(i->text(),"/"); } } progress->setProgress(100); delete progress; }
TemplateItem* NewFileWizard::getSelection()const { for(QIconViewItem *item = m_newDocumentWidget->templateIconView->firstItem(); item; item = item->nextItem()) { if(item->isSelected()) { return static_cast<TemplateItem*>(item); } } return NULL; }
/** * Notify that the selection has changed. * Will check if there are still items selected, and will enable * actions based on the result. */ void MainWindow::selectionChanged() { /* Check if there are items selected */ bool selected = false; for (QIconViewItem *i = iconView->firstItem(); i; i = i->nextItem()) selected = selected || i->isSelected(); saveAction->setEnabled(selected); deleteAction->setEnabled(selected); }
QValueList<int> ClusterPalette::selectedClusters() { //Get the list of clusters with their color ItemColors& clusterColors = doc->clusterColors(); QValueList<int> selectedClusters; ClusterPaletteIconViewItem* clusterPaletteItem; for(QIconViewItem* item = iconView->firstItem(); item; item = item->nextItem()) { clusterPaletteItem = static_cast<ClusterPaletteIconViewItem*>(item); if(item->isSelected()) { selectedClusters.append(clusterColors.itemId(item->index())); } } //Selection has just changed isUpToDate = false; return selectedClusters; }
/** * Deletes the selected files (after asking for confirmation). */ void MainWindow::deleteSelected() { if (KMessageBox::questionYesNo(this, i18n("Are you sure you want to delete the selected pictures ?"), i18n("Delete")) == KMessageBox::Yes) { try { for (QIconViewItem *i = iconView->firstItem();i; i=i->nextItem()) { if (i->isSelected()) { statusBar()->message(i18n("Deleting ") + i->text() + " ..."); GPInterface::deletePicture(i->text(),"/"); delete i; iconView->arrangeItemsInGrid(); } } statusBar()->message(i18n("Done")); } catch (QString err) { KMessageBox::error(this, err); statusBar()->message(i18n("Error"), MESSAGE_TIME); } } }