/** * 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; }
void ThumbView::slCheckForUpdate( KFileItem *kfit ) { if( ! kfit ) return; kdDebug(28000) << "Checking for update of thumbview!" << endl; KURL searchUrl = kfit->url(); bool haveItem = false; /* iterate over all icon items and compare urls. * TODO: Check the parent url to avoid iteration over all */ for ( QIconViewItem *item = m_iconView->firstItem(); item && !haveItem; item = item->nextItem() ) { if( searchUrl == static_cast<ThumbViewItem*>(item)->itemUrl() ) { haveItem = true; } } /* if we still do not have the item, it is not in the thumbview. */ if( ! haveItem ) { KFileItemList kfiList; kfiList.append( kfit ); slNewFileItems( kfiList ); } }
/** * 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); }
void MontageView::drawPoints(const QPointArray& pa, QValueList<int>& corners, int correct) { if(ccv::debug) std::cerr << "MontageView::drawPoints - pa = " << pa.count() << " corners = " << corners.count() << "\n"; QIconViewItem* item = firstItem(); if( !item ) return; m_dirty = true; QImage img = item->pixmap()->convertToImage(); int item_nr = 0; bool failed = corners[item_nr] != correct; for( uint i=0; i<pa.count()+1; ++i ){ if( corners[item_nr] == 0 ) { QPixmap pm(img); item->setPixmap( pm ); item = item->nextItem(); if( !item ) return; img = item->pixmap()->convertToImage(); item_nr++; failed = corners[item_nr] != correct; } if(ccv::debug) std::cerr << " Point: " << i << " Image: " << item_nr << " (" << pa[i].x() << "," << pa[i].y() << ")" << " Corners: " << corners[item_nr] << "\n"; if( !failed ) { img.setPixel( pa[i].x() , pa[i].y()-1, qRgb(255,255,0) ); img.setPixel( pa[i].x()-1, pa[i].y() , qRgb(255,255,0) ); img.setPixel( pa[i].x() , pa[i].y() , qRgb(255,0,0) ); img.setPixel( pa[i].x()+1, pa[i].y() , qRgb(255,255,0) ); img.setPixel( pa[i].x() , pa[i].y()+1, qRgb(255,255,0) ); } else { img.setPixel( pa[i].x() , pa[i].y()-1, qRgb(255,0,0) ); img.setPixel( pa[i].x()-1, pa[i].y() , qRgb(255,0,0) ); img.setPixel( pa[i].x() , pa[i].y() , qRgb(255,255,0) ); img.setPixel( pa[i].x()+1, pa[i].y() , qRgb(255,0,0) ); img.setPixel( pa[i].x() , pa[i].y()+1, qRgb(255,0,0) ); } corners[item_nr]--; } }
void MontageView::resetIcons() { if( !m_dirty ) return; m_dirty = false; // FixMe: This should be optimized by caching the old images instead for( QIconViewItem* item = firstItem(); item; item = item->nextItem() ) { QPixmap pm = *item->pixmap(); QSize size = pm.size(); QImage icon( item->text() ); pm = icon.smoothScale( size ); } }
void IconViewEditor::applyClicked() { QIconViewItem *i = 0; QValueList<PopulateIconViewCommand::Item> items; for ( i = preview->firstItem(); i; i = i->nextItem() ) { PopulateIconViewCommand::Item item; if ( i->pixmap() ) item.pix = *i->pixmap(); item.text = i->text(); items.append( item ); } PopulateIconViewCommand *cmd = new PopulateIconViewCommand( tr( "Edit Items of '%1'" ).arg( iconview->name() ), formwindow, iconview, items ); cmd->execute(); formwindow->commandHistory()->addCommand( cmd ); }
/****************************************************************************** * Public Slots * *****************************************************************************/ void KIconViewSearchLine::updateSearch(const QString &s) { QIconView *iv = d->iconView; if(!iv) return; // disabled QString search = d->search = s.isNull() ? text() : s; QIconViewItemList *hi = &(d->hiddenItems); QIconViewItem *currentItem = iv->currentItem(); QIconViewItem *item = NULL; // Remove Non-Matching items, add them them to hidden list QIconViewItem *i = iv->firstItem(); while(i != NULL) { item = i; i = i->nextItem(); // Point to next, otherwise will loose it. if(!itemMatches(item, search)) { hideItem(item); if(item == currentItem) currentItem = NULL; // It's not in iconView anymore. } } // Add Matching items, remove from hidden list QIconViewItemList::iterator it = hi->begin(); while(it != hi->end()) { item = *it; ++it; if(itemMatches(item, search)) showItem(item); } iv->sort(); if(currentItem != NULL) iv->ensureItemVisible(currentItem); }
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; }
void ThumbView::slImageRenamed( KFileItem *kfit, const KURL& newUrl ) { const KURL url = kfit->url(); if( kfit->isDir() ) { clear(); } for ( QIconViewItem *item = m_iconView->firstItem(); item; item = item->nextItem() ) { ThumbViewItem *it=static_cast<ThumbViewItem*>( item ); if( url == it->itemUrl() ) { it->setItemUrl( newUrl ); break; } } }
IconViewEditor::IconViewEditor( QWidget *parent, QWidget *editWidget, FormWindow *fw ) : IconViewEditorBase( parent, 0, TRUE ), formwindow( fw ) { connect( buttonHelp, SIGNAL( clicked() ), MainWindow::self, SLOT( showDialogHelp() ) ); iconview = (QIconView*)editWidget; itemText->setText( "" ); itemText->setEnabled( FALSE ); itemPixmap->setText( "" ); itemChoosePixmap->setEnabled( FALSE ); itemDeletePixmap->setEnabled( FALSE ); QIconViewItem *i = 0; for ( i = iconview->firstItem(); i; i = i->nextItem() ) { (void)new QIconViewItem( preview, i->text(), *i->pixmap() ); } if ( preview->firstItem() ) preview->setCurrentItem( preview->firstItem() ); }
bool ThumbView::deleteImage( KFileItem *kfit ) { if( ! kfit ) return false; KURL searchUrl = kfit->url(); bool haveItem = false; /* iterate over all icon items and compare urls. * TODO: Check the parent url to avoid iteration over all */ for ( QIconViewItem *item = m_iconView->firstItem(); item && !haveItem; item = item->nextItem() ) { if( searchUrl == static_cast<ThumbViewItem*>(item)->itemUrl() ) { m_iconView->takeItem( item ); haveItem = true; } } kdDebug(28000) << "Deleting image from thumbview, result is " << haveItem << endl; return( haveItem ); }
//We reimplement this method to add automatic change of the grid size void GofunIconView::arrangeItemsInGrid(bool update) { int b_height, b_width = 0; QIconViewItem* item = firstItem(); while(item) { //if(item->height() > b_height) //Outcommented because we currently don't need // b_height = item->height(); //it anyways, but maybe in a later implementation if(item->width() > b_width) b_width = item->width(); item = item->nextItem(); } if(gridX() != b_width && b_width) setGridX(b_width); //if(gridY() != b_width && b_height) //FIXME: If we uncomment this we end up with // setGridY(b_height); //an endless loop and bugs all the way. Not of high priority thought. QIconView::arrangeItemsInGrid(update); }
void ClusterPalette::hideUserClusterInformation() { //update the flag isInUserClusterInfoMode = false; iconView->setItemTextPos(QIconView::Bottom); //Let's go back to normal QFontInfo fontInfo = QFontInfo(QFont()); iconView->setGridX(fontInfo.pixelSize() * 2); iconView->setGridY(15); iconView->arrangeItemsInGrid(); ItemColors& clusterColors = doc->clusterColors(); int clusterId; for(QIconViewItem* item = iconView->firstItem(); item; item = item->nextItem()) { clusterId = clusterColors.itemId(item->index()); item->setText(QString("%1").arg(clusterId)); } iconView->setWordWrapIconText(true); iconView->resize(this->width(),this->height()); }
void GofunWidget::unloadData() { int cats_bg_count = cats_bg->count(); for(int i = 1; i < cats_bg_count+1 && cats_bg_count > 1; ++i) { GofunDirectoryButton* cb = dynamic_cast<GofunDirectoryButton*>(cats_bg->find(i)); if(cb) { for(QIconViewItem* item = cb->iconview->firstItem(); item; 0) { QIconViewItem* next = item->nextItem(); delete item; item = next; } view_ws->removeWidget(cb->iconview); cats_bg->remove(cb); delete cb; } } view_ws->raiseWidget(tools_cat->iconview); }
/** * 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); } } }
void TemplateIconView::addTemplateIcons(KileDocument::Type type) { if(!m_templateManager) return; QString emptyIcon = KGlobal::dirs()->findResource("appdata", "pics/"+ QString(DEFAULT_EMPTY_ICON) + ".png" ); KileTemplate::Info emptyDocumentInfo; emptyDocumentInfo.name = DEFAULT_EMPTY_CAPTION; emptyDocumentInfo.icon = emptyIcon; emptyDocumentInfo.type = type; TemplateItem *emp = new TemplateItem(this, emptyDocumentInfo); setSelected(emp, true); if(type == KileDocument::LaTeX) { // disable non standard templates QMap<QString,bool> map; map["Scrartcl"] = false; map["Scrbook"] = false; map["Scrreprt"] = false; map["Scrlttr2"] = false; map["Beamer"] = false; map["Prosper"] = false; map["HA-prosper"] = false; // split search results and look, which class files are present QStringList list = QStringList::split("\n",m_output); for ( QStringList::Iterator it=list.begin(); it!=list.end(); ++it ) { QString filename = QFileInfo(*it).fileName(); if ( filename=="scrartcl.cls" ) { map["Scrartcl"] = true; map["Scrbook"] = true; map["Scrreprt"] = true; map["Scrlttr2"] = true; } else if ( filename=="beamer.cls" ) map["Beamer"] = true; else if ( filename=="prosper.cls" ) map["Prosper"] = true; else if ( filename=="HA-prosper.sty" ) map["HA-prosper"] = true; } KileTemplate::TemplateList templateList = m_templateManager->getTemplates(KileDocument::LaTeX); // insert all standard templates, all user defined templates // and those templates, which have a present class for (KileTemplate::TemplateListIterator i=templateList.begin(); i != templateList.end(); ++i) { KileTemplate::Info info = *i; QString classname = info.name; if ( !map.contains(classname) || map[classname]==true ) { new TemplateItem(this, info); } } } else { KileTemplate::TemplateList templateList = m_templateManager->getTemplates(type); for (KileTemplate::TemplateListIterator i=templateList.begin(); i != templateList.end(); ++i) { new TemplateItem(this, *i); } } // sort all items (item for 'Empty Document' will always be the first one) sort(); // set the default item, if its given for ( QIconViewItem *item = firstItem(); item; item = item->nextItem() ) { if ( static_cast<TemplateItem*>(item)->name() == m_selicon ) { setSelected(item, true); ensureItemVisible(item); } } }
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; }
void ClusterPalette::showUserClusterInformation(int electrodeGroupId) { //update the flag isInUserClusterInfoMode = true; iconView->setItemTextPos(QIconView::Right); iconView->setGridX(2500); iconView->arrangeItemsInGrid(); QMap<int,ClusterUserInformation> clusterUserInformationMap = QMap<int,ClusterUserInformation>(); doc->data().getClusterUserInformation(electrodeGroupId,clusterUserInformationMap); ItemColors& clusterColors = doc->clusterColors(); int clusterId; ClusterUserInformation currentClusterInformation; for(QIconViewItem* item = iconView->firstItem(); item; item = item->nextItem()) { clusterId = clusterColors.itemId(item->index()); QString clusterText = item->text(); if(clusterId == 0) { clusterText.append(" - ").append("artefact"); } else if(clusterId == 1) { clusterText.append(" - ").append("noise"); } else { currentClusterInformation = clusterUserInformationMap[clusterId]; bool first = true; if(currentClusterInformation.getStructure() != "") { first = false; clusterText.append(" - ").append(currentClusterInformation.getStructure()); } if(currentClusterInformation.getType() != "") { if(!first) { clusterText.append(", ").append(currentClusterInformation.getType()); } else { clusterText.append(" - ").append(currentClusterInformation.getType()); first = false; } } if(currentClusterInformation.getId() != "") { if(!first) { clusterText.append(", ").append(currentClusterInformation.getId()); } else { clusterText.append(" - ").append(currentClusterInformation.getId()); first = false; } } if(currentClusterInformation.getQuality() != "") { if(!first) { clusterText.append(", ").append(currentClusterInformation.getQuality()); } else { clusterText.append(" - ").append(currentClusterInformation.getQuality()); first = false; } } if(currentClusterInformation.getNotes() != "") { if(!first) { clusterText.append(", ").append(currentClusterInformation.getNotes()); } else { clusterText.append(" - ").append(currentClusterInformation.getNotes()); first = false; } } } item->setText(clusterText); } iconView->setWordWrapIconText(false); iconView->adjustSize(); }