[Kst] branches/work/kst/kst1kde4/kst/src/libkstapp
Andrew Walker
arwalker at sumusltd.com
Tue Apr 6 23:03:46 CEST 2010
SVN commit 1111870 by arwalker:
continue kst1kde4
M +2 -2 CMakeLists.txt
M +0 -4 kstdoc.cpp
M +65 -63 kstviewwindow.cpp
--- branches/work/kst/kst1kde4/kst/src/libkstapp/CMakeLists.txt #1111869:1111870
@@ -69,8 +69,6 @@
kstalignment.cpp
kstcurvedialog.cpp
kstbasicdialog.cpp
- kstdatawizard.cpp
- kstdoc.cpp
kstviewwindow.cpp
ktimezonecombo.cpp
kstdebugnotifier.cpp
@@ -100,6 +98,8 @@
kstchangefiledialog.cpp
kstmatrixdialog.cpp
ksteventmonitorentry.cpp
+ kstdatawizard.cpp
+ kstdoc.cpp
kst.cpp)
#KDE3_ADD_DCOP_SKELS(kstapp_LIB_SRCS
--- branches/work/kst/kst1kde4/kst/src/libkstapp/kstdoc.cpp #1111869:1111870
@@ -27,15 +27,12 @@
#include <unistd.h>
#include <math.h>
-// include files for Qt
#include <qdeepcopy.h>
#include <QEventLoop>
#include <QStyleSheet>
#include <QMessageBox>
-// include files for KDE
#include <dcopclient.h>
-#include "ksdebug.h"
#include <kdeversion.h>
#include <kfiledialog.h>
#include <kio/netaccess.h>
@@ -45,7 +42,6 @@
#include <kstandarddirs.h>
#include <ktempfile.h>
-// application specific includes
#include "kst2dplot.h"
#include "kstcsd.h"
#include "kstdataobjectcollection.h"
--- branches/work/kst/kst1kde4/kst/src/libkstapp/kstviewwindow.cpp #1111869:1111870
@@ -15,17 +15,13 @@
* *
***************************************************************************/
-// include files for Qt
#include <QFile>
+#include <QMessageBox>
#include <QPainter>
-#include <QPaintDeviceMetrics>
-#include <QStyleSheet>
-#include <QMessageBox>
+#include <QPrinter>
+#include <QTextDocument>
+#include <QVBoxLayout>
-// include files for KDE
-#include <kprinter.h>
-
-// application specific includes
#include "kst2dplot.h"
#include "kstplotlabel.h"
#include "kstdoc.h"
@@ -37,7 +33,7 @@
#define KST_STATUSBAR_STATUS 2
KstViewWindow::KstViewWindow(QWidget *parent, const char* name)
-: QMdiSubWindow(QString::null, parent, name) {
+: QMdiSubWindow(parent) {
commonConstructor();
_view = new KstTopLevelView(this, name);
_view->applyDefaults();
@@ -45,7 +41,7 @@
KstViewWindow::KstViewWindow(const QDomElement& e, QWidget* parent, const char* name)
-: QMdiSubWindow(QString::null, parent, name) {
+: QMdiSubWindow(parent) {
QString in_tag;
QRect rectRestore;
QRect rectInternal;
@@ -54,29 +50,31 @@
_view = new KstTopLevelView(e, this);
QDomNode n = e.firstChild();
+
while (!n.isNull()) {
QDomElement e = n.toElement(); // try to convert the node to an element.
+
if( !e.isNull()) { // the node was really an element.
if (e.tagName() == "tag") {
in_tag = e.text();
setCaption(in_tag);
- setTabCaption(in_tag);
+// xxx setTabCaption(in_tag);
} else if (e.tagName() == "restore") {
rectRestore.setX( e.attribute( "x", "0" ).toInt() );
rectRestore.setY( e.attribute( "y", "0" ).toInt() );
rectRestore.setWidth( e.attribute( "w", "100" ).toInt() );
rectRestore.setHeight( e.attribute( "h", "100" ).toInt() );
- setRestoreGeometry( rectRestore );
+// xxx setRestoreGeometry( rectRestore );
} else if (e.tagName() == "internal") {
rectInternal.setX( e.attribute( "x", "0" ).toInt() );
rectInternal.setY( e.attribute( "y", "0" ).toInt() );
rectInternal.setWidth( e.attribute( "w", "100" ).toInt() );
rectInternal.setHeight( e.attribute( "h", "100" ).toInt() );
- setInternalGeometry( rectInternal );
+// xxx setInternalGeometry( rectInternal );
} else if (e.tagName() == "minimize") {
- minimize(false);
+// xxx minimize(false);
} else if (e.tagName() == "maximize") {
- maximize(false);
+// xxx maximize(false);
}
}
n = n.nextSibling();
@@ -85,14 +83,14 @@
void KstViewWindow::commonConstructor() {
- config = kapp->config();
+// xxx config = kapp->config();
connect(this, SIGNAL(focusInEventOccurs( QMdiSubWindow*)), this, SLOT(slotActivated(QMdiSubWindow*)));
QTimer::singleShot(0, this, SLOT(updateActions()));
QVBoxLayout *vb = new QVBoxLayout(this);
- vb->setAutoAdd(true);
+// xxx vb->setAutoAdd(true);
}
@@ -157,6 +155,7 @@
void KstViewWindow::immediatePrintToFile(const QString &filename) {
+/* xxx
KPrinter printer(true, QPrinter::HighResolution);
printer.setPageSize(KPrinter::Letter);
printer.setOrientation(KPrinter::Landscape);
@@ -172,6 +171,7 @@
view()->paint(p, QRegion());
view()->revertForPrint();
p.end();
+*/
}
@@ -179,23 +179,12 @@
if (!view()->children().isEmpty()) {
QPixmap pixmap(size);
KstPainter paint(KstPainter::P_EXPORT);
+
if (paint.begin(&pixmap)) {
const QSize sizeOld(view()->size());
view()->resizeForPrint(size);
view()->paint(paint, QRegion());
-#if QT_VERSION >= 0x030200
pixmap.save(dataStream->device(), format.toLatin1());
-#else
- Q_UNUSED(format)
-
- QByteArray bytes;
- QDataStream tempStream(bytes, IO_ReadWrite);
-
- tempStream << pixmap;
- if (bytes.count() > 4) {
- dataStream->writeRawBytes(bytes.data()+4, bytes.count()-4);
- }
-#endif
view()->revertForPrint();
paint.end();
}
@@ -211,12 +200,12 @@
if (paint.begin(&pixmap)) {
QString dotFormat = QString(".") + format;
QString filenameNew;
- const int pos = filename.findRev(dotFormat, -1, false);
+ const int pos = filename.lastIndexOf(dotFormat, -1, Qt::CaseInsensitive);
if (pos != -1 && pos == int(filename.length() - dotFormat.length())) {
filenameNew = filename;
} else {
- filenameNew = filename + "." + format.lower();
+ filenameNew = filename + "." + format.toLower();
}
view()->resizeForPrint(size);
@@ -241,7 +230,7 @@
{
QPrinter printer(QPrinter::HighResolution);
QString dotFormat = QString(".eps");
- const int pos = filename.findRev(dotFormat, -1, false);
+ const int pos = filename.lastIndexOf(dotFormat, -1, Qt::CaseInsensitive);
if (pos != -1 && pos == int(filename.length() - dotFormat.length())) {
filenameNewEps = filename;
@@ -257,17 +246,16 @@
right = ( 72 * size.height() ) / resolution;
bottom = ( 72 * size.width() ) / resolution;
- printer.setMargins(0, 0, 0, 0);
+ printer.setPageMargins(0.0, 0.0, 0.0, 0.0, QPrinter::Point);
printer.setResolution(resolution);
printer.setPageSize(QPrinter::Letter);
printer.setOrientation(QPrinter::Landscape);
- printer.setOutputToFile(true);
printer.setOutputFileName(filenameNew);
printer.setColorMode(QPrinter::Color);
KstPainter paint(KstPainter::P_PRINT);
paint.begin(&printer);
- QPaintDeviceMetrics metrics(&printer);
+// xxx QPaintDeviceMetrics metrics(&printer);
view()->resizeForPrint(size);
view()->paint(paint, QRegion());
@@ -278,12 +266,13 @@
//
// now try to open the .ps file and convert it to an .eps...
//
+
QFile filePS(filenameNew);
QFile fileEPS(filenameNewEps);
QString line;
- if (filePS.open(IO_ReadOnly)) {
- if (fileEPS.open(IO_WriteOnly | IO_Truncate)) {
+ if (filePS.open(QIODevice::ReadOnly)) {
+ if (fileEPS.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
QTextStream streamPS(&filePS);
QTextStream streamEPS(&fileEPS);
@@ -316,9 +305,10 @@
void KstViewWindow::print(KstPainter& paint, const QSize& size, int pages, int lineAdjust, bool monochrome, bool enhanceReadability, bool datetimeFooter, bool maintainAspectRatio, int pointStyleOrder, int lineStyleOrder, int lineWidthOrder, int maxLineWidth, int pointDensity) {
- KstTopLevelViewPtr tlv = kst_cast<KstTopLevelView>(view());
+ KstTopLevelViewPtr tlv;
QSize sizeNew = size;
+ tlv = kst_cast<KstTopLevelView>(view());
if (tlv) {
if (lineAdjust != 0) {
tlv->forEachChild(&Kst2DPlot::pushAdjustLineWidth, lineAdjust, false);
@@ -328,7 +318,9 @@
tlv->forEachChild<const QColor&>(&Kst2DPlot::pushCurveColor, Qt::black, false);
// additional pushes for enhanced readability
if (enhanceReadability) {
- Kst2DPlotList plotList = tlv->findChildrenType<Kst2DPlot>(false);
+ Kst2DPlotList plotList;
+
+// xxx plotList = tlv->findChildrenType<Kst2DPlot>(false);
for (Kst2DPlotList::Iterator it = plotList.begin(); it != plotList.end(); ++it ) {
(*it)->changeToMonochrome(pointStyleOrder, lineStyleOrder, lineWidthOrder, maxLineWidth, pointDensity);
}
@@ -337,7 +329,7 @@
if (datetimeFooter) {
QDateTime dateTime = QDateTime::currentDateTime();
- QString title = i18n("Page: %1 Name: %2 Date: %3").arg(pages).arg(caption()).arg(dateTime.toString(Qt::ISODate));
+ QString title = i18n("Page: %1 Name: %2 Date: %3").arg(pages).arg(windowTitle()).arg(dateTime.toString(Qt::ISODate));
QRect rect(0, 0, sizeNew.width(), sizeNew.height());
QRect rectBounding;
@@ -369,8 +361,11 @@
tlv->forEachChild2(&Kst2DPlot::popCurveColor);
// additional pops to undo enhanced readability
if (enhanceReadability) {
- Kst2DPlotList plotList = tlv->findChildrenType<Kst2DPlot>(false);
- for (Kst2DPlotList::Iterator it = plotList.begin(); it != plotList.end(); ++it ) {
+ Kst2DPlotList plotList;
+ Kst2DPlotList::iterator it;
+
+// xxx plostList = tlv->findChildrenType<Kst2DPlot>(false);
+ for (it = plotList.begin(); it != plotList.end(); ++it ) {
(*it)->undoChangeToMonochrome(pointStyleOrder, lineStyleOrder, lineWidthOrder);
}
}
@@ -382,10 +377,10 @@
void KstViewWindow::save(QTextStream& ts, const QString& indent) {
- const QRect restoreGeom(restoreGeometry());
- const QRect internalGeom(internalGeometry());
+ const QRect restoreGeom;// xxx restoreGeometry());
+ const QRect internalGeom;// xxx internalGeometry());
- ts << indent << "<tag>" << QStyleSheet::escape(caption()) << "</tag>" << endl;
+ ts << indent << "<tag>" << Qt::escape(windowTitle()) << "</tag>" << endl;
ts << indent << "<restore" << " x=\"" << restoreGeom.x()
<< "\" y=\"" << restoreGeom.y()
@@ -414,18 +409,20 @@
void KstViewWindow::setCaption(const QString& caption) {
- QMdiSubWindow::setCaption(caption);
+ QMdiSubWindow::setWindowTitle(caption);
_view->setTagName(KstObjectTag(caption, KstObjectTag::globalTagContext)); // FIXME: global tag context?
}
void KstViewWindow::closeEvent(QCloseEvent *e) {
if (KstSettings::globalSettings()->promptWindowClose && !view()->children().isEmpty()) {
- if (QMessageBox::warning(this, i18n("Kst"), i18n("Are you sure you want to close window '%1'?\nClosing a window deletes all plots in the window.").arg(caption()), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
+ if (QMessageBox::warning(this, tr("Kst"), tr("Are you sure you want to close window '%1'?\nClosing a window deletes all plots in the window.").arg(windowTitle()), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
e->ignore();
+
return;
}
}
+
QMdiSubWindow::closeEvent(e);
}
@@ -436,6 +433,8 @@
bool duplicate = true;
while (duplicate) {
+ QList<QMdiSubWindow*> windows;
+ QList<QMdiSubWindow*>::const_iterator i;
KstViewObjectPtr rc;
//
@@ -443,15 +442,10 @@
//
duplicate = false;
- iter = app->createIterator();
+ windows = app->subWindowList(QMdiArea::CreationOrder);
+ for (i = windows.constBegin(); i != windows.constEnd() && !duplicate; ++i) {
+ KstViewWindow *viewWindow = dynamic_cast<KstViewWindow*>(*i);
- QList<QMdiSubWindow*> windows;
- QList<QMdiSubWindow*>::const_iterator i;
-
- windows = app->subWindowList(QMdiArea::CreationOrder);
-
- for (i = windows.constBegin(); i != windows.constEnd() && !duplicate; ++i)
- KstViewWindow *viewWindow = dynamic_cast<KstViewWindow*>(*i);
if (viewWindow) {
rc = viewWindow->view()->findChild(name);
if (rc) {
@@ -482,8 +476,10 @@
windows = app->subWindowList(QMdiArea::CreationOrder);
- for (i = windows.constBegin(); i != windows.constEnd() && !duplicate; ++i)
- KstViewWindow *viewWindow = dynamic_cast<KstViewWindow*>(*i);
+ for (i = windows.constBegin(); i != windows.constEnd() && !duplicate; ++i) {
+ KstViewWindow *viewWindow;
+
+ viewWindow = dynamic_cast<KstViewWindow*>(*i);
if (viewWindow) {
rc = viewWindow->view()->findChild(name);
if (rc) {
@@ -514,13 +510,20 @@
QString KstViewWindow::createPlot(const QString& suggestedName, bool prompt) {
- Kst2DPlotList plotList = view()->findChildrenType<Kst2DPlot>(false);
- QString name = createPlotObject(suggestedName, prompt);
- Kst2DPlotPtr plot = kst_cast<Kst2DPlot>(view()->findChild(name));
+ Kst2DPlotList plotList;
+ Kst2DPlotPtr plot;
+ QString name;
- // if there are already plots in the window, use the the first one's font size.
+// xxx plotList = view()->findChildrenType<Kst2DPlot>(false);
+ name = createPlotObject(suggestedName, prompt);
+ plot = kst_cast<Kst2DPlot>(view()->findChild(name));
+
+ //
+ // if there are already plots in the window, use the the first one's font size...
+ //
+
if (!plotList.isEmpty()) {
- plot->setPlotLabelFontSizes(plotList[0]->xTickLabel()->fontSize());
+ plot->setPlotLabelFontSizes(plotList.first()->xTickLabel()->fontSize());
}
return (name);
@@ -528,4 +531,3 @@
#include "kstviewwindow.moc"
-
More information about the Kst
mailing list