void PropertyWidget_Distance::setDoc(ScribusDoc *d) { if(d == (ScribusDoc*) m_doc) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = d; m_item = NULL; if (m_doc.isNull()) { disconnectSignals(); return; } m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); columns->setDecimals(0); columnGap->setDecimals(2); topDistance->setDecimals(2); leftDistance->setDecimals(2); bottomDistance->setDecimals(2); rightDistance->setDecimals(2); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
void PropertyWidget_PathText::setDoc(ScribusDoc *d) { if(d == (ScribusDoc*) m_doc) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = d; m_item = NULL; if (m_doc.isNull()) { disconnectSignals(); return; } m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); startOffset->setMaximum( 30000 ); startOffset->setMinimum( 0 ); startOffset->setSingleStep(10); distFromCurve->setMaximum( 300 ); distFromCurve->setMinimum( -300 ); distFromCurve->setSingleStep(10); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
void PropertiesPalette_Line::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = d; m_item = NULL; m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); int precision = unitGetPrecisionFromIndex(m_unitIndex); m_haveDoc = true; m_haveItem = false; lineWidth->setMaximum( 300 ); lineWidth->setMinimum( 0 ); updateLineStyles(m_doc); startArrow->rebuildList(&m_doc->arrowStyles()); endArrow->rebuildList(&m_doc->arrowStyles()); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
void PropertyWidget_ParEffect::setDoc(ScribusDoc *doc) { if(doc == (ScribusDoc*) m_doc) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = doc; peCharStyleCombo->setDoc(doc); if (m_doc.isNull()) { disconnectSignals(); return; } m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); fillNumerationsCombo(); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); // Handle properties update when switching document handleSelectionChanged(); }
void PropertyWidget_TextColor::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = d; m_item = NULL; if (m_doc.isNull()) { disconnectSignals(); return; } updateColorList(); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
void PropertyWidget_Advanced::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = d; m_item = NULL; if (m_doc.isNull()) { disconnectSignals(); return; } m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); tracking->setValues( -300, 300, 2, 0); minWordTrackingSpinBox->setValues(1, 100, 2, 100); normWordTrackingSpinBox->setValues(1, 2000, 2, 100); minGlyphExtSpinBox->setValues(90, 110, 2, 100); maxGlyphExtSpinBox->setValues(90, 110, 2, 100); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
void PropertiesPalette_Shadow::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = d; m_item = NULL; m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); int precision = unitGetPrecisionFromIndex(m_unitIndex); double maxXYWHVal = 200 * m_unitRatio; double minXYVal = -200 * m_unitRatio; m_haveDoc = true; m_haveItem = false; softShadowXOffset->setUnitValue(m_unitIndex); softShadowXOffset->setDecimalsValue(precision); softShadowXOffset->setMinMaxValues(minXYVal, maxXYWHVal); softShadowXOffset->setDoubleValue(minXYVal); softShadowYOffset->setUnitValue(m_unitIndex); softShadowYOffset->setDecimalsValue(precision); softShadowYOffset->setMinMaxValues(minXYVal, maxXYWHVal); softShadowYOffset->setDoubleValue(minXYVal); softShadowBlurRadius->setUnitValue(m_unitIndex); softShadowBlurRadius->setDecimalsValue(1); softShadowBlurRadius->setMinMaxValues(0.0, 20.0); softShadowBlurRadius->setDoubleValue(5); softShadowShade->setDecimalsValue(0); softShadowShade->setMinMaxValues(0, 100); softShadowShade->setIntValue(100); softShadowOpacity->setDecimalsValue(0); softShadowOpacity->setMinMaxValues(0, 100); softShadowOpacity->setIntValue(100); updateColorList(); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
void PropertiesPalette_XYZ::unsetDoc() { if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_haveDoc = false; m_haveItem = false; m_doc = NULL; m_item = NULL; xposSpin->setConstants(NULL); yposSpin->setConstants(NULL); widthSpin->setConstants(NULL); heightSpin->setConstants(NULL); doGroup->setEnabled(false); doUnGroup->setEnabled(false); flipH->setEnabled(false); flipV->setEnabled(false); xposLabel->setText( tr( "&X-Pos:" ) ); widthLabel->setText( tr( "&Width" ) ); yposLabel->setText( tr( "&Y-Pos:" ) ); heightLabel->setText( tr( "&Height:" ) ); xposSpin->showValue(0); yposSpin->showValue(0); widthSpin->showValue(0); heightSpin->showValue(0); rotationSpin->showValue(0); setEnabled(false); }
void CanvasMode_EditArc::activate(bool fromGesture) { VectorDialog = new ArcVectorDialog(m_ScMW); m_canvas->m_viewMode.m_MouseButtonPressed = false; m_canvas->resetRenderMode(); m_doc->DragP = false; m_doc->leaveDrag = false; m_canvas->m_viewMode.operItemMoving = false; m_canvas->m_viewMode.operItemResizing = false; m_view->MidButt = false; Mxp = Myp = -1; PageItem *currItem = m_doc->m_Selection->itemAt(0); PageItem_Arc* item = currItem->asArc(); centerPoint = currItem->PoLine.pointQF(0); startPoint = currItem->PoLine.pointQF(3); endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 4); widthPoint = QPointF(centerPoint.x() - item->arcWidth / 2.0, centerPoint.y()); heightPoint = QPointF(centerPoint.x(), centerPoint.y() - item->arcHeight / 2.0); startAngle = item->arcStartAngle; endAngle = startAngle + item->arcSweepAngle; QLineF res = QLineF(centerPoint, startPoint); QLineF swe = QLineF(centerPoint, endPoint); VectorDialog->setValues(res.angle(), swe.angle(), item->arcHeight, item->arcWidth); VectorDialog->show(); setModeCursor(); if (fromGesture) { m_view->update(); } connect(VectorDialog, SIGNAL(NewVectors(double, double, double, double)), this, SLOT(applyValues(double, double, double, double))); connect(VectorDialog, SIGNAL(endEdit()), this, SLOT(endEditing())); connect(VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool))); connect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem())); }
void QXsldbgDoc::slotResult( KIO::Job *job ) { if ( job->error() != 0 ){ }else{ } emit docChanged(); }
void PropertiesPalette_Text::unsetDoc() { if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_haveDoc = false; m_haveItem = false; m_doc = NULL; m_item = NULL; paraStyleCombo->setDoc(0); charStyleCombo->setDoc(0); advancedWidgets->setDoc(0); colorWidgets->setDoc(0); distanceWidgets->setDoc(0); flopBox->setDoc(0); optMargins->setDoc(0); orphanBox->setDoc(0); parEffectWidgets->setDoc(0); pathTextWidgets->setDoc(0); m_haveItem = false; setEnabled(false); }
void CanvasMode_EditSpiral::activate(bool fromGesture) { m_VectorDialog = new SpiralVectorDialog(m_ScMW); m_canvas->m_viewMode.m_MouseButtonPressed = false; m_canvas->resetRenderMode(); m_doc->DragP = false; m_doc->leaveDrag = false; m_canvas->m_viewMode.operItemMoving = false; m_canvas->m_viewMode.operItemResizing = false; m_view->MidButt = false; m_Mxp = m_Myp = -1; PageItem *currItem = m_doc->m_Selection->itemAt(0); PageItem_Spiral* item = currItem->asSpiral(); m_startPoint = currItem->PoLine.pointQF(0); m_endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 2); m_startAngle = item->spiralStartAngle; m_endAngle = item->spiralEndAngle; m_VectorDialog->setValues(computeRealAngle(m_startAngle, false), computeRealAngle(m_endAngle, false), item->spiralFactor); m_VectorDialog->show(); setModeCursor(); if (fromGesture) { m_view->update(); } connect(m_VectorDialog, SIGNAL(NewVectors(double, double, double)), this, SLOT(applyValues(double, double, double))); connect(m_VectorDialog, SIGNAL(endEdit()), this, SLOT(endEditing())); connect(m_VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool))); connect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem())); }
void PropertyWidget_ParEffect::handleChanges(PageItem *item, ParagraphStyle &newStyle) { if (m_doc->appMode == modeEditTable) item = item->asTable()->activeCell().textFrame(); if (item != NULL) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); Selection tempSelection(this, false); tempSelection.addItem(item, true); m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection); m_doc->updateNumbers(); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } }
void CanvasMode_EditPolygon::deactivate(bool forGesture) { disconnect(VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool))); VectorDialog->close(); VectorDialog->deleteLater(); m_view->setRedrawMarkerShown(false); m_polygonPoint = noPointDefined; disconnect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem())); }
void CanvasMode_EditArc::deactivate(bool forGesture) { disconnect(VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool))); VectorDialog->close(); delete VectorDialog; m_view->redrawMarker->hide(); m_arcPoint = noPointDefined; disconnect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem())); }
void JavaDocs::slotEdit() { QString nam = Scripts->currentItem()->text(); Editor* dia2 = new Editor(this, Doc->JavaScripts[nam], View); if (dia2->exec()) { Doc->JavaScripts[nam] = dia2->EditTex->toPlainText(); emit docChanged(false); } delete dia2; }
void PropertiesPalette_Text::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = d; m_item = NULL; m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); m_haveDoc = true; m_haveItem = false; fontSize->setValues( 0.5, 2048, 2, 1); lineSpacing->setValues( 1, 2048, 2, 1); advancedWidgets->setDoc(m_doc); fontfeaturesWidget->setDoc(m_doc); colorWidgets->setDoc(m_doc); distanceWidgets->setDoc(m_doc); parEffectWidgets->setDoc(m_doc); flopBox->setDoc(m_doc); hyphenationWidget->setDoc(m_doc); optMargins->setDoc(m_doc); orphanBox->setDoc(m_doc); pathTextWidgets->setDoc(m_doc); fonts->RebuildList(m_doc); paraStyleCombo->setDoc(m_doc); charStyleCombo->setDoc(m_doc); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
void PropertiesPalette_XYZ::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_doc = d; m_item = NULL; m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); int precision = unitGetPrecisionFromIndex(m_unitIndex); //qt4 FIXME here double maxXYWHVal = 16777215 * m_unitRatio; double minXYVal = -16777215 * m_unitRatio; m_haveDoc = true; m_haveItem = false; QMap<QString, double>* docConstants = m_doc? &m_doc->constants() : NULL; xposSpin->setValues( minXYVal, maxXYWHVal, precision, minXYVal); xposSpin->setConstants(docConstants); yposSpin->setValues( minXYVal, maxXYWHVal, precision, minXYVal); yposSpin->setConstants(docConstants); widthSpin->setValues( m_unitRatio, maxXYWHVal, precision, m_unitRatio); widthSpin->setConstants(docConstants); heightSpin->setValues( m_unitRatio, maxXYWHVal, precision, m_unitRatio); heightSpin->setConstants(docConstants); rotationSpin->setValues( 0, 359.99, 1, 0); updateSpinBoxConstants(); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
void PropertiesPalette_Shadow::unsetDoc() { if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_haveDoc = false; m_haveItem = false; m_doc = NULL; m_item = NULL; setEnabled(false); }
void PropertiesPalette_Group::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) return; if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } disconnect(this->transPalWidget, SIGNAL(NewTrans(double)), 0, 0); disconnect(this->transPalWidget, SIGNAL(NewBlend(int)), 0, 0); disconnect(this->transPalWidget, SIGNAL(NewGradient(int)), 0, 0); disconnect(this->transPalWidget, SIGNAL(NewPattern(QString)), 0, 0); disconnect(this->transPalWidget, SIGNAL(NewPatternProps(double, double, double, double, double, double, double, bool, bool)), 0, 0); m_doc = d; m_item = NULL; m_unitRatio = m_doc->unitRatio(); m_unitIndex = m_doc->unitIndex(); transPalWidget->setDocument(m_doc); transPalWidget->setCurrentItem(NULL); m_haveDoc = true; m_haveItem = false; connect(this->transPalWidget, SIGNAL(NewTrans(double)) , this, SLOT(handleGroupTransparency(double))); connect(this->transPalWidget, SIGNAL(NewBlend(int)) , this, SLOT(handleGroupBlending(int))); connect(this->transPalWidget, SIGNAL(NewGradient(int)) , this, SLOT(handleGroupGradMask(int))); connect(this->transPalWidget, SIGNAL(NewPattern(QString)), this, SLOT(handleGroupPatternMask(QString))); connect(this->transPalWidget, SIGNAL(NewPatternProps(double, double, double, double, double, double, double, bool, bool)), this, SLOT(handleGroupPatternMaskProps(double, double, double, double, double, double, double, bool, bool))); connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); }
void PropertiesPalette_Group::unsetDoc() { if (m_doc) { disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } m_haveDoc = false; m_haveItem = false; m_doc = NULL; m_item = NULL; transPalWidget->setDocument(NULL); transPalWidget->setCurrentItem(NULL); setEnabled(false); }
void CanvasMode_EditPolygon::activate(bool fromGesture) { m_polygonPoint = noPointDefined; m_canvas->m_viewMode.m_MouseButtonPressed = false; m_canvas->resetRenderMode(); m_doc->DragP = false; m_doc->leaveDrag = false; m_canvas->m_viewMode.operItemMoving = false; m_canvas->m_viewMode.operItemResizing = false; m_view->MidButt = false; Mxp = Myp = -1; PageItem *currItem = m_doc->m_Selection->itemAt(0); PageItem_RegularPolygon* item = currItem->asRegularPolygon(); centerPoint = QPointF(currItem->width() / 2.0, currItem->height() / 2.0); startPoint = currItem->PoLine.pointQF(0); endPoint = currItem->PoLine.pointQF(2); polyCorners = item->polyCorners; polyUseFactor = item->polyUseFactor; polyFactor = item->polyFactor; polyRotation = item->polyRotation; polyCurvature = item->polyCurvature; polyInnerRot = item->polyInnerRot; polyOuterCurvature = item->polyOuterCurvature; VectorDialog = new PolyVectorDialog(m_ScMW, polyCorners, polyFactor, polyUseFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature); VectorDialog->show(); uint cx = polyUseFactor ? polyCorners * 2 : polyCorners; double seg = 360.0 / cx; double trueLength = sqrt(pow(sin(seg / 180.0 * M_PI) * (item->width() / 2.0), 2) + pow(cos(seg / 180.0 * M_PI) * (item->height() / 2.0) + (item->height()/2.0) - item->height(), 2)); QLineF innerLine = QLineF(endPoint, centerPoint); innerLine.setAngle(innerLine.angle() + 90); innerLine.setLength(trueLength * polyCurvature); innerCPoint = innerLine.p2(); QLineF outerLine = QLineF(startPoint, currItem->PoLine.pointQF(6)); outerLine.setLength(outerLine.length() * polyOuterCurvature); outerCPoint = outerLine.p2(); setModeCursor(); if (fromGesture) m_view->update(); connect(m_doc, SIGNAL(docChanged()), this, SLOT(updateFromItem())); connect(VectorDialog, SIGNAL(NewVectors(int, double, bool, double, double, double, double)), this, SLOT(applyValues(int, double, bool, double, double, double, double))); connect(VectorDialog, SIGNAL(endEdit()), this, SLOT(endEditing())); connect(VectorDialog, SIGNAL(paletteShown(bool)), this, SLOT(endEditing(bool))); }
void KstChangeFileDialogI::applyFileChange() { KstDataSourcePtr file; KstRVectorPtr vector; KstWriteLocker ml(&KST::dataSourceList.lock()); /* if there is not an active KstFile, create one */ KstDataSourceList::Iterator it; for (it = KST::dataSourceList.begin(); it != KST::dataSourceList.end(); ++it) { if ((*it)->fileName() == ChangeFileName->currentText()) { file = *it; break; } } if (it == KST::dataSourceList.end()) { file = KstDataSource::loadSource(ChangeFileName->currentText()); if (!file || !file->isValid()) { KMessageBox::sorry(0L, i18n("%1: Unable to open file.").arg(ChangeFileName->currentText())); return; } if (file->frameCount() < 1) { KMessageBox::sorry(0L, i18n("%1: File does not contain data. Operation canceled.").arg(ChangeFileName->currentText())); return; } KST::dataSourceList.append(file); } KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList); for (int i = 0; i < (int)ChangeFileCurveList->count(); i++) { if (ChangeFileCurveList->isSelected(i)) { vector = rvl[i]; if (!file->isValidField(vector->getField())) { KMessageBox::sorry(0L, i18n("%1: Field is not defined for the requested file.").arg(vector->getField())); } else { vector->changeFile(file); } } } /** purge unused files */ //KST::fileList.Purge(); emit docChanged(); }
void JavaDocs::slotDelete() { int exit = QMessageBox::warning(this, CommonStrings::trWarning, tr("Do you really want to delete this script?"), QMessageBox::Yes | QMessageBox::No); if (exit == QMessageBox::Yes) { QString nam = Scripts->currentItem()->text(); Doc->JavaScripts.remove(nam); Scripts->clear(); QMap<QString,QString>::Iterator it; for (it = Doc->JavaScripts.begin(); it != Doc->JavaScripts.end(); ++it) Scripts->addItem(it.key()); if (Doc->JavaScripts.count() == 0) { EditScript->setEnabled(false); DeleteScript->setEnabled(false); } emit docChanged(false); } }
void JavaDocs::slotAdd() { QString nam; Query *dia = new Query(this, "tt", 1, 0, tr("&New Script:"), tr("New Script")); dia->setEditText( tr("New Script"), false ); dia->setTestList(Doc->JavaScripts.keys()); if (dia->exec()) { nam = dia->getEditText(); nam.replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_" ); Editor* dia2 = new Editor(this, "", View); dia2->EditTex->setText("function "+nam+"()\n{\n}"); if (dia2->exec()) { EditScript->setEnabled(true); DeleteScript->setEnabled(true); Doc->JavaScripts[nam] = dia2->EditTex->toPlainText(); Scripts->addItem(nam); emit docChanged(false); } delete dia2; } delete dia; }
KstApp::KstApp(QWidget *parent, const char* name) : KMainWindow(parent, name) { clearWFlags(WDestructiveClose); stopping = false; config = kapp->config(); initStatusBar(); initDocument(); initView(); /* create dialogs */ debugDialog = new KstDebugDialogI(this); plotDialog = new KstPlotDialogI(doc, this); dataManager = new KstDataManagerI(doc, this); filterListEditor = new FilterListEditor(this); viewScalarsDialog = new KstViewScalarsDialogI(this); viewVectorsDialog = new KstViewVectorsDialogI(this); changeFileDialog = new KstChangeFileDialogI(this); changeNptsDialog = new KstChangeNptsDialogI(this); quickCurvesDialog = new KstQuickCurvesDialogI(this); quickPSDDialog = new KstQuickPSDDialogI(this); graphFileDialog = new KstGraphFileDialogI(this); vectorSaveDialog = new VectorSaveDialog(this); connect(KstVectorDialogI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified())); connect(KstCurveDialogI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified())); connect(KstEqDialogI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified())); connect(KstHsDialogI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified())); connect(KstPsdDialogI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified())); connect(KstPluginDialogI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified())); connect(KstEventMonitorI::globalInstance(), SIGNAL(modified()), doc, SLOT(wasModified())); initActions(); readOptions(); _updateThread = new UpdateThread(doc); _updateThread->setUpdateTime(KstSettings::globalSettings()->plotUpdateTimer); _updateThread->start(); connect(doc, SIGNAL(newFrameMsg(int)), this, SLOT(slotUpdateFrameMsg(int))); connect(view, SIGNAL(newStatusMsg(const QString &)), this, SLOT(slotUpdateStatusMsg(const QString &))); connect(view, SIGNAL(newDataMsg(const QString &)), this, SLOT(slotUpdateDataMsg(const QString &))); /*** Plot Dialog signals */ connect(changeFileDialog, SIGNAL(docChanged()), this, SLOT(registerDocChange())); connect(changeNptsDialog, SIGNAL(docChanged()), this, SLOT(registerDocChange())); connect(quickCurvesDialog,SIGNAL(docChanged()), this, SLOT(registerDocChange())); connect(quickPSDDialog, SIGNAL(docChanged()), this, SLOT(registerDocChange())); connect(filterListEditor, SIGNAL(docChanged()), this, SLOT(registerDocChange())); connect(graphFileDialog, SIGNAL(graphFileReq(const QString &,int,int)), view, SLOT(printToGraphicsFile(const QString &,int,int))); /*** label dialog ***/ connect(view->labelDialog, SIGNAL(applied()), this, SLOT(registerDocChange())); /*** plot dialog ***/ connect(plotDialog, SIGNAL(docChanged()), this, SLOT(registerDocChange())); /*** ***/ connect(doc, SIGNAL(dataChanged()), this, SLOT(updateDialogs())); connect(dataManager, SIGNAL(editDataVector(const QString &)), KstVectorDialogI::globalInstance(), SLOT(show_I(const QString &))); connect(dataManager->OpenPlotDialog, SIGNAL(clicked()), this, SLOT(showPlotDialog())); setAutoSaveSettings("KST-KMainWindow", true); _dcopIface = new KstIfaceImpl(doc, this); view->forceUpdate(); connect(this, SIGNAL(settingsChanged()), this, SLOT(slotSettingsChanged())); QTimer::singleShot(0, this, SLOT(updateActions())); // Load any extensions ExtensionMgr *mgr = ExtensionMgr::self(); mgr->setWindow(this); KService::List sl = KServiceType::offers("Kst Extension"); for (KService::List::ConstIterator it = sl.begin(); it != sl.end(); ++it) { KService::Ptr service = *it; QString name = service->property("Name").toString(); if (!mgr->enabled(name) && !service->property("X-Kst-Enabled").toBool()) { continue; } mgr->loadExtension(service); } }
void KstChangeNptsDialogI::emitDocChanged() { emit docChanged(); }
void KstQuickPSDDialogI::apply(bool autolabel) { KstDataSourcePtr file; KstVectorPtr vx; KstRVectorPtr trv; KstPlot *plot; int i_v; QString v_name, c_name; bool x_is_new; KstPSDCurvePtr curve; double new_freq; int new_len; if (KST::plotList.count() < 1) { addPlot(); return; } if (SourceVector->isChecked()) { // set vx from existing vectors i_v = Vectors->currentItem(); KstReadLocker ml(&KST::vectorList.lock()); if (i_v >= (int)KST::vectorList.count()) { return; } vx = KST::vectorList[i_v]; } else { // set vx from data file specification KstReadLocker ml(&KST::dataSourceList.lock()); /* generate or find the kstfile */ KstDataSourceList::Iterator it = KST::dataSourceList.findFileName(FileName->url()); if (it == KST::dataSourceList.end()) { file = KstDataSource::loadSource(FileName->url()); if (!file || !file->isValid()) { KMessageBox::sorry(0L, i18n("The file could not be loaded.")); return; } if (file->frameCount() < 1) { KMessageBox::sorry(0L, i18n("The file does not contain data.")); return; } KST::dataSourceList.append(file); } else { file = *it; } KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList); x_is_new = true; /**** Build the XVector ***/ /* make sure there are no vectors with the current vectors props */ for (i_v = 0; unsigned(i_v) < rvl.count(); i_v++) { trv = rvl[i_v]; if ((trv->filename() == FileName->url()) && (trv->getField() == Field->text()) && (trv->reqStartFrame() == F0->value()) && (trv->reqNumFrames() == N->value()) && (trv->skip() == Skip->value()) && (trv->doSkip() == DoSkip->isChecked()) && (trv->doAve() == DoFilter->isChecked()) && (trv->readToEOF() == ReadToEnd->isChecked()) && (trv->countFromEOF() == CountFromEnd->isChecked())) { x_is_new = false; i_v = rvl.count(); vx = trv; } } if (x_is_new) { KST::vectorList.lock().readLock(); /* If not, Generate a unique vector name */ v_name = "V" + QString::number(KST::vectorList.count()+1)+"-" + Field->text(); while (KST::vectorList.findTag(v_name) != KST::vectorList.end()) { v_name += "'"; } KST::vectorList.lock().readUnlock(); KST::dataObjectList.lock().readLock(); while (KST::dataObjectList.findTag(v_name) != KST::dataObjectList.end()) { v_name += "'"; } KST::dataObjectList.lock().readUnlock(); if (!file->isValidField(Field->text())) { KMessageBox::sorry(0L, i18n("The requested field is not defined for the requested file.")); return; } /* generate and append the vector */ trv = new KstRVector(file, Field->text(), v_name, (CountFromEnd->isChecked() ? -1 : F0->value()), (ReadToEnd->isChecked() ? -1 : N->value()), Skip->value(), DoSkip->isChecked(), DoFilter->isChecked()); KST::addVectorToList(KstVectorPtr(trv)); vx = trv; } } /**** Build the PSD ***/ /* find new_freq */ new_freq = PSDSampRate->text().toDouble(); if (new_freq <= 0) { KMessageBox::sorry(0L, i18n("The sample rate must be greater than 0.")); return; } /* find new_len */ new_len = PSDFFTLen->text().toInt(); if (new_len < 2) { KMessageBox::sorry(0L, i18n("The FFT length must be greater than 2^2.")); return; } /* create the psd curve name */ KST::dataObjectList.lock().writeLock(); c_name = "PSD"+QString::number(KST::dataObjectList.count()+1) + "-" + vx->tagName(); while (KST::dataObjectList.findTag(c_name) != KST::dataObjectList.end()) { c_name+="'"; } KST::vectorList.lock().readLock(); while (KST::vectorList.findTag(c_name) != KST::vectorList.end()) { c_name+="'"; } KST::vectorList.lock().readUnlock(); /* create the psd curve */ curve = new KstPSDCurve(c_name, vx, new_freq, new_len, PSDVectorUnits->text(), PSDRateUnits->text(), _curveAppearance->color()); curve->setHasPoints(_curveAppearance->showPoints()); curve->setHasLines(_curveAppearance->showLines()); curve->setLineWidth(_curveAppearance->lineWidth()); curve->setLineStyle(_curveAppearance->lineStyle()); curve->Point.setType(_curveAppearance->pointType()); KST::dataObjectList.append(curve.data()); KST::dataObjectList.lock().writeUnlock(); /* assign curve to plot */ plot = KST::plotList.FindKstPlot(PlotList->currentText()); plot->addCurve(curve); if (autolabel) plot->GenerateDefaultLabels(); close(); emit docChanged(); update(); }
bool KstChangeFileDialogI::applyFileChange() { KstDataSourcePtr file; KST::dataSourceList.lock().writeLock(); KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(_dataFile->url()); QString invalidSources; int invalid = 0; if (it == KST::dataSourceList.end()) { file = KstDataSource::loadSource(_dataFile->url()); if (!file || !file->isValid()) { KST::dataSourceList.lock().unlock(); KMessageBox::sorry(this, i18n("The file could not be loaded.")); return false; } if (file->isEmpty()) { KST::dataSourceList.lock().unlock(); KMessageBox::sorry(this, i18n("The file does not contain data.")); return false; } KST::dataSourceList.append(file); } else { file = *it; } KST::dataSourceList.lock().unlock(); KstApp *app = KstApp::inst(); KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList); KstRMatrixList rml = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList); int selected = 0; int handled = 0; int count = (int)ChangeFileCurveList->count(); for (int i = 0; i < count; i++) { if (ChangeFileCurveList->isSelected(i)) { ++selected; } } // a map to keep track of which objects have been duplicated, and mapping // old object -> new object KstDataObjectDataObjectMap duplicatedMap; QMap<KstVectorPtr, KstVectorPtr> duplicatedVectors; QMap<KstMatrixPtr, KstMatrixPtr> duplicatedMatrices; KstDataSourceList oldSources; // go through the vectors for (int i = 0; i < (int)rvl.count(); i++) { if (ChangeFileCurveList->isSelected(i)) { KstRVectorPtr vector = rvl[i]; vector->writeLock(); file->readLock(); bool valid = file->isValidField(vector->field()); file->unlock(); if (!valid) { if (invalid > 0) { // FIXME: invalid list construction for i18n invalidSources = i18n("%1, %2").arg(invalidSources).arg(vector->field()); } else { invalidSources = vector->field(); } ++invalid; } else { if (_duplicateSelected->isChecked()) { // block vector updates until vector is setup properly KST::vectorList.lock().writeLock(); // create a new vector KstRVectorPtr newVector = vector->makeDuplicate(); if (!oldSources.contains(newVector->dataSource())) { oldSources << newVector->dataSource(); } newVector->changeFile(file); KST::vectorList.lock().unlock(); // duplicate dependents if (_duplicateDependents->isChecked()) { duplicatedVectors.insert(KstVectorPtr(vector), KstVectorPtr(newVector)); KST::duplicateDependents(KstVectorPtr(vector), duplicatedMap, duplicatedVectors); } } else { if (!oldSources.contains(vector->dataSource())) { oldSources << vector->dataSource(); } vector->changeFile(file); } } vector->unlock(); app->slotUpdateProgress(selected, ++handled, i18n("Updating vectors...")); } } // go through the matrices for (int i = (int)rvl.count(); i < (int)ChangeFileCurveList->count(); i++) { if (ChangeFileCurveList->isSelected(i)) { KstRMatrixPtr matrix = rml[i-rvl.count()]; matrix->writeLock(); file->readLock(); bool valid = file->isValidMatrix(matrix->field()); file->unlock(); if (!valid) { if (invalid > 0) { // FIXME: invalid list construction for i18n invalidSources = i18n("%1, %2").arg(invalidSources).arg(matrix->field()); } else { invalidSources = matrix->field(); } ++invalid; } else { if (_duplicateSelected->isChecked()) { // block matrix updates until matrix is setup properly KST::matrixList.lock().writeLock(); // create a new matrix KstRMatrixPtr newMatrix = matrix->makeDuplicate(); if (!oldSources.contains(newMatrix->dataSource())) { oldSources << newMatrix->dataSource(); } newMatrix->changeFile(file); KST::matrixList.lock().unlock(); // duplicate dependents if (_duplicateDependents->isChecked()) { duplicatedMatrices.insert(KstMatrixPtr(matrix), KstMatrixPtr(newMatrix)); KST::duplicateDependents(KstMatrixPtr(matrix), duplicatedMap, duplicatedMatrices); } } else { if (!oldSources.contains(matrix->dataSource())) { oldSources << matrix->dataSource(); } matrix->changeFile(file); } } matrix->unlock(); app->slotUpdateProgress(selected, ++handled, i18n("Updating matrices...")); } } app->slotUpdateProgress(0, 0, QString::null); file = 0L; // now add any curves and images to plots if they were duplicated if (_duplicateSelected->isChecked() && _duplicateDependents->isChecked()) { KstApp *app = KstApp::inst(); KMdiIterator<KMdiChildView*> *it = app->createIterator(); while (it->currentItem()) { KstViewWindow *w = dynamic_cast<KstViewWindow*>(it->currentItem()); if (w) { KstTopLevelViewPtr view = kst_cast<KstTopLevelView>(w->view()); if (view) { Kst2DPlotList plots = view->findChildrenType<Kst2DPlot>(true); for (Kst2DPlotList::Iterator plotIter = plots.begin(); plotIter != plots.end(); ++plotIter) { for (KstDataObjectDataObjectMap::ConstIterator iter = duplicatedMap.begin(); iter != duplicatedMap.end(); ++iter) { if (KstBaseCurvePtr curve = kst_cast<KstBaseCurve>(iter.data())) { if ((*plotIter)->Curves.contains(kst_cast<KstBaseCurve>(iter.key())) && !(*plotIter)->Curves.contains(kst_cast<KstBaseCurve>(curve))) { (*plotIter)->addCurve(curve); } } } } } } it->next(); } app->deleteIterator(it); } // clean up unused data sources // kstdDebug() << "cleaning up data sources" << endl; KST::dataSourceList.lock().writeLock(); for (KstDataSourceList::Iterator it = oldSources.begin(); it != oldSources.end(); ++it) { // kstdDebug() << "DATA SOURCE: " << (*it)->tag().displayString() << " (" << (void*)(*it) << ") USAGE: " << (*it)->getUsage() << endl; if ((*it)->getUsage() == 1) { // kstdDebug() << " -> REMOVED" << endl; KST::dataSourceList.remove((*it).data()); } } KST::dataSourceList.lock().unlock(); if (!invalidSources.isEmpty()) { if (invalid == 1) { KMessageBox::sorry(this, i18n("The following field is not defined for the requested file:\n%1").arg(invalidSources)); } else { KMessageBox::sorry(this, i18n("The following fields are not defined for the requested file:\n%1").arg(invalidSources)); } } emit docChanged(); // force an update in case we're in paused mode KstApp::inst()->forceUpdate(); return true; }