//------------------------------------------------------------------------- void MainWindow::setupNAddItem(QLanguageItem* guidoItemContainer) { GraphicsSceneMainWindow::setupNAddItem( guidoItemContainer ); if ( dynamic_cast<QGuidoItemContainer*> (guidoItemContainer) ) { connect( guidoItemContainer , SIGNAL(exportItem()) , this, SLOT(exportItem()) ); ((QGuidoItemContainer*)guidoItemContainer)->setMinMaxScale( mSettings.mMinScale , mSettings.mMaxScale ); } }
void ExportThread::exportItems( const QString& name, ItemList& items, quint32& currentItem, QTime& time ) { if( !items.isEmpty() ) { QDir dir( m_directory ); if( dir.exists() ) { if( !dir.cd( name ) ) dir.mkdir( name ); dir.cd( name ); QTime rate; rate.start(); quint32 count = 0; foreach( TibiaItem* item, items ) { if( isCanceled() ) break; if( exportItem( dir, item ) ) { emit valueChanged( currentItem ); currentItem++; if( ( float )( rate.elapsed() / 1000 ) >= 1 ) { emit labelText( tr( "%1\n\nElapsed Time: %2\nTime left: %3" ).arg( m_labelText ).arg( QTime().addMSecs( time.elapsed() ).toString( "hh:mm:ss" ) ).arg( QTime().addMSecs( ( int )( ( ( float )( m_maximum - currentItem ) / count ) * ( float )1000 ) ).toString( "hh:mm:ss" ) ) ); //emit rateChanged( count, libraryFile->getCount() - i, time.elapsed() ); // Items/sec, Items remaining rate.restart(); count = 0; } count++; } } } }
void FeatureExporter::exportItem(QIODevice &device, const DataProxy::FeatureList &featureList) const { // early out if (!device.isWritable()) { return; } QTextStream otxt(&device); // prepend header if (m_detailLevel.testFlag(FeatureExporter::Extended)) { // identifying comment if (m_detailLevel.testFlag(FeatureExporter::Comments)) { otxt << QString("# %1").arg("ST Viewer export: feature list") << endl; } // prepend data with application version const QString version = QCoreApplication::applicationVersion(); if (m_detailLevel.testFlag(FeatureExporter::Comments)) { otxt << QString("# %1").arg("version") << endl; } otxt << (version.isEmpty() ? QString("0.0.0") : version) << endl; // prepend ISO 8601 compliant timestamp if (m_detailLevel.testFlag(FeatureExporter::Comments)) { otxt << QString("# %1 (UTC)").arg("date") << endl; } otxt << QDateTime::currentDateTimeUtc().toString(Qt::ISODate) << endl; } exportItem(otxt, featureList); }
void QTodoExportPluginCSV::exportBody( ) { for(; listIterator().current(); ++listIterator()) { if(QTodoItem* item = listIterator().item()) exportItem(*item); } }
void QTodoExportPluginHTML::exportBody( ) { for(; listIterator().current(); ++listIterator()) { if(QTodoItem* item = listIterator().item()) exportItem(*item); } addLine("</body></html>"); }
//------------------------------------------------------------------------- void MainWindow::exportFirstItem() { QList<QLanguageItem*> selectedItems = selectedLanguageItems(); if ( selectedItems.size() > 0 ) { //Export the first (and only) selected item, if it is a QGuidoItemContainer. //(do nothing for other types of items) if ( dynamic_cast<QGuidoItemContainer*>(mFirstSelectedItem) ) exportItem( (QGuidoItemContainer*)mFirstSelectedItem ); else QMessageBox::warning( this , "Export item" , "Item not exported : only Guido items can be exported." ); } }
void FeatureExporter::exportItem(QTextStream &otxt, const DataProxy::FeatureList &featureList) const { // prepend header if (m_detailLevel.testFlag(FeatureExporter::Comments)) { QStringList list; list << "gene_name" << "x" << "y" << "reads_count"; otxt << QString("# "); exportStrings(otxt, list); } for (const auto &feature : featureList) { exportItem(otxt, *feature); } }
//------------------------------------------------------------------------- QMenu * QGuidoItemContainer::buildContextMenu() { QMenu * menu = QLanguageItem::buildContextMenu(); QAction * exportAct = new QAction( "Export" , this ); connect( exportAct , SIGNAL( triggered() ) , this , SIGNAL( exportItem() ) ); menu->addAction( exportAct ); QMenu * layoutMenu = menu->addMenu( CONTEXT_MENU_LAYOUT ); layoutMenu->setObjectName( CONTEXT_MENU_LAYOUT ); //Layout actions :Proportional layout QString layoutProportionalMsg = QString("Switch ") + ( mIsProportionalOn ? "OFF" : "ON" ) + " Proportionnal layout"; QAction * layoutProportionalSwitch = new QAction( layoutProportionalMsg , layoutMenu ); connect( layoutProportionalSwitch , SIGNAL(triggered()) , this , SLOT(switchProportional()) ); layoutMenu->addAction(layoutProportionalSwitch); //Layout actions : Optimal page fill QString layoutOptimalPageFillMsg = QString("Switch ") + ( mIsOptimalPageFillOn ? "OFF" : "ON" ) + " Optimal page fill"; QAction * layoutOptimalPageFillSwitch = new QAction( layoutOptimalPageFillMsg , layoutMenu ); connect( layoutOptimalPageFillSwitch , SIGNAL(triggered()) , this , SLOT(switchOptimalPageFill()) ); layoutMenu->addAction(layoutOptimalPageFillSwitch); //Layout actions : Auto-resizePageToMusic QString layoutResizePageMsg = QString("Switch ") + ( mGuidoItem->isResizePageToMusic() ? "OFF" : "ON" ) + " Auto Resize-Page"; QAction * layoutResizePageSwitch = new QAction( layoutResizePageMsg , layoutMenu ); connect( layoutResizePageSwitch , SIGNAL(triggered()) , this , SLOT(switchResizePage()) ); layoutMenu->addAction(layoutResizePageSwitch); //"Change the current page" actions. QAction * firstPage = new QAction( "First page" , this ); QAction * previousPage = new QAction( "Previous page" , this ); QAction * nextPage = new QAction( "Next page" , this ); QAction * lastPage = new QAction( "Last page" , this ); connect(firstPage , SIGNAL(triggered()) , this , SLOT(firstPage()) ); connect(previousPage , SIGNAL(triggered()) , this , SLOT(previousPage()) ); connect(nextPage , SIGNAL(triggered()) , this , SLOT(nextPage()) ); connect(lastPage , SIGNAL(triggered()) , this , SLOT(lastPage()) ); layoutMenu->addAction( newSeparator(this) ); layoutMenu->addAction(firstPage); layoutMenu->addAction(previousPage); layoutMenu->addAction(nextPage); layoutMenu->addAction(lastPage); /* bool onceOnly = false; for ( int i = 0 ; i < menu->actions().size() ; i++ ) { if ( menu->actions()[i]->data().toString() == CONTEXT_MENU_LAYOUT ) { if ( !onceOnly ) { layoutMenu->addSeparator(); onceOnly = true; } // qDebug("QGuidoItemContainer::buildContextMenu() : action removed from menu and added to "); layoutMenu->addAction( menu->actions()[i] ); menu->actions()[i]->setParent( layoutMenu ); menu->removeAction( menu->actions()[i] ); i--; } } */ return menu; }
void TupItemManager::mousePressEvent(QMouseEvent *event) { parentNode = ""; QTreeWidgetItem *item = itemAt(event->pos()); if (item) { setCurrentItem(item); emit itemSelected(item); if (event->buttons() == Qt::RightButton) { QMenu *menu = new QMenu(tr("Options")); if (isFolder(item)) { QAction *rename = new QAction(tr("Rename"), this); connect(rename, SIGNAL(triggered()), this, SLOT(renameItem())); QAction *remove = new QAction(tr("Delete"), this); connect(remove, SIGNAL(triggered()), this, SIGNAL(itemRemoved())); menu->addAction(rename); menu->addAction(remove); } else { QString extension = item->text(2); bool isSound = false; bool isNative = false; if ((extension.compare("OGG") == 0) || (extension.compare("MP3") == 0) || (extension.compare("WAV") == 0)) isSound = true; if (extension.compare("OBJ") == 0) isNative = true; if (extension.compare("SVG") == 0) { QAction *edit = new QAction(tr("Edit with Inkscape"), this); connect(edit, SIGNAL(triggered()), this, SLOT(callInkscapeToEdit())); #ifdef Q_OS_UNIX if (!QFile::exists("/usr/bin/inkscape")) edit->setDisabled(true); #else edit->setDisabled(true); #endif menu->addAction(edit); } else if ((extension.compare("OBJ") != 0) && !isSound) { QAction *gimpEdit = new QAction(tr("Edit with Gimp"), this); connect(gimpEdit, SIGNAL(triggered()), this, SLOT(callGimpToEdit())); #ifdef Q_OS_UNIX if (!QFile::exists("/usr/bin/gimp")) gimpEdit->setDisabled(true); #else gimpEdit->setDisabled(true); #endif menu->addAction(gimpEdit); QAction *kritaEdit = new QAction(tr("Edit with Krita"), this); connect(kritaEdit, SIGNAL(triggered()), this, SLOT(callKritaToEdit())); #ifdef Q_OS_UNIX if (!QFile::exists("/usr/bin/krita")) kritaEdit->setDisabled(true); #else kritaEdit->setDisabled(true); #endif menu->addAction(kritaEdit); QAction *myPaintEdit = new QAction(tr("Edit with MyPaint"), this); connect(myPaintEdit, SIGNAL(triggered()), this, SLOT(callMyPaintToEdit())); #ifdef Q_OS_UNIX if (!QFile::exists("/usr/bin/mypaint")) myPaintEdit->setDisabled(true); #else myPaintEdit->setDisabled(true); #endif menu->addAction(myPaintEdit); } if (!isSound && !isNative) { QAction *clone = new QAction(tr("Clone"), this); connect(clone, SIGNAL(triggered()), this, SLOT(cloneItem())); menu->addAction(clone); } QAction *exportObject = new QAction(tr("Export"), this); connect(exportObject, SIGNAL(triggered()), this, SLOT(exportItem())); QAction *rename = new QAction(tr("Rename"), this); connect(rename, SIGNAL(triggered()), this, SLOT(renameItem())); QAction *remove = new QAction(tr("Delete"), this); connect(remove, SIGNAL(triggered()), this, SIGNAL(itemRemoved())); menu->addAction(exportObject); menu->addAction(rename); menu->addAction(remove); menu->addSeparator(); #ifdef Q_OS_UNIX if (!isSound) { if (QFile::exists("/usr/bin/gimp") || QFile::exists("/usr/bin/krita") || QFile::exists("/usr/bin/mypaint")) { QAction *raster = new QAction(tr("Create new raster item"), this); connect(raster, SIGNAL(triggered()), this, SLOT(createNewRaster())); menu->addAction(raster); } if (QFile::exists("/usr/bin/inkscape")) { QAction *svg = new QAction(tr("Create new svg item"), this); connect(svg, SIGNAL(triggered()), this, SLOT(createNewSVG())); menu->addAction(svg); } } #endif } menu->exec(event->globalPos()); } else if (event->buttons() == Qt::LeftButton) { // SQA: This code doesn't work well at all. Reengineering is urgently required right here! // If the node has a parent, get the parent's name QTreeWidgetItem *top = item->parent(); if (top) parentNode = top->text(1); // For directories, get the children nodeChildren.clear(); if (item->text(2).length()==0 && item->childCount() > 0) { for (int i=0;i<item->childCount();i++) { QTreeWidgetItem *node = item->child(i); nodeChildren << node; } } QPixmap pixmap = item->icon(0).pixmap(15, 15); QByteArray itemData; QDataStream dataStream(&itemData, QIODevice::WriteOnly); dataStream << pixmap << item->text(1) << item->text(2) << item->text(3); QMimeData *mimeData = new QMimeData; mimeData->setData("application/x-dnditemdata", itemData); QDrag *drag = new QDrag(this); drag->setMimeData(mimeData); drag->setPixmap(pixmap); if (drag->start(Qt::MoveAction) == Qt::MoveAction) delete takeTopLevelItem(indexOfTopLevelItem(item)); } } else { if (event->buttons() == Qt::RightButton) { QMenu *menu = new QMenu(tr("Options")); #ifdef Q_OS_UNIX if (QFile::exists("/usr/bin/gimp") || QFile::exists("/usr/bin/krita") || QFile::exists("/usr/bin/mypaint")) { QAction *raster = new QAction(tr("Create new raster item"), this); connect(raster, SIGNAL(triggered()), this, SLOT(createNewRaster())); menu->addAction(raster); } if (QFile::exists("/usr/bin/inkscape")) { QAction *svg = new QAction(tr("Create new svg item"), this); connect(svg, SIGNAL(triggered()), this, SLOT(createNewSVG())); menu->addAction(svg); } #endif menu->exec(event->globalPos()); } } }
//------------------------------------------------------------------------- void MainWindow::exportItem() { QGuidoItemContainer * item = (QGuidoItemContainer *)sender(); exportItem( item ); }