[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/office/zippl
From: Klaas Freitag <freitag () suse ! de>
Date: 2011-07-10 7:16:14
Message-ID: 20110710071614.34AD9AC854 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1240781 by freitag:
- First steps to a proper toc
- removed qtcreator user file
- fixed file open on startup
_M . (directory)
M +1 -0 graphwidget.cpp
M +15 -2 mainwindow.cpp
M +2 -0 mainwindow.h
D zippl.pro.user
M +3 -2 zipplcontroler.cpp
M +13 -18 zipplxmlreader.cpp
M +2 -0 zipplxmlreader.h
--- trunk/playground/office/zippl/graphwidget.cpp #1240780:1240781
@@ -51,6 +51,7 @@
:QGraphicsView(),
timerId(0),
mCurrSpotNo(0)
+
{
QGraphicsScene *scene = new QGraphicsScene(this);
scene->setItemIndexMethod(QGraphicsScene::NoIndex);
--- trunk/playground/office/zippl/mainwindow.cpp #1240780:1240781
@@ -21,16 +21,29 @@
bool res = false;
if( argc > 1 ) {
file = argv[1];
+ } else {
+ file = autoFile();
+ qDebug() << "Auto-File found: " << file;
+ }
res = mController->loadFile( file );
- }
- while( ! res ) {
+ if( ! res ) {
file = QFileDialog::getOpenFileName( this, tr("Pick a Zippl file to Open"),
QDir::homePath(), tr("Zippl Files (*xml)"));
res = mController->loadFile( file );
}
+ if( ! res ) exit;
}
+QString MainWindow::autoFile() const
+{
+ QFileInfo info( "zippl.xml" );
+ if( info.exists() ) {
+ return info.absoluteFilePath();
+ }
+ return QString();
+}
+
MainWindow::~MainWindow()
{
--- trunk/playground/office/zippl/mainwindow.h #1240780:1240781
@@ -15,6 +15,8 @@
~MainWindow();
void openFile( int argc, char *argv[] );
private:
+ QString autoFile() const;
+
GraphWidget *mGraphWidget;
ZipplControler *mController;
};
--- trunk/playground/office/zippl/zipplcontroler.cpp #1240780:1240781
@@ -6,7 +6,7 @@
ZipplControler::ZipplControler( GraphWidget *graphWidget )
:QObject(),
mGraphWidget( graphWidget ),
- mCurrSpotNo(-1),
+ mCurrSpotNo(0),
mCurrStationNo(0),
mWatcher( new QFileSystemWatcher(this))
{
@@ -61,8 +61,9 @@
void ZipplControler::slotNextSpot()
{
qDebug() << "Move to next spot, current spot no is " << mCurrSpotNo;
+
+ QGraphicsItem *currItem = currentSpot();
mCurrSpotNo++;
- QGraphicsItem *currItem = currentSpot();
// turn to next Spot.
centerOnItem( currItem );
--- trunk/playground/office/zippl/zipplxmlreader.cpp #1240780:1240781
@@ -81,7 +81,6 @@
QGraphicsScene *scene = mGraphWidget->scene();
int spotID = 0;
- int tocCount = 0;
while (!atEnd()) {
readNext();
@@ -98,24 +97,9 @@
qreal dy = qrealAttrib("height") / -2.0;
QRectF rect( dx, dy, -2.0*dx, -2.0*dy );
scene->setSceneRect( rect );
-
- } else if( name() == "toc" ) {
- QGraphicsRectItem *rect = new QGraphicsRectItem();
- rect->setPen( pen( rect->pen(),QColor("#aeaeae") ) );
- rect->setBrush( brush( rect->brush() ) );
- rect->setPos( position() );
- mToc = rect;
- tocCount = 0;
- mCurrParent = mToc;
- scene->addItem( mCurrParent );
-
} else if( name() == "tocentry" ) {
- if( mToc ) {
- QGraphicsSimpleTextItem *textItem = new QGraphicsSimpleTextItem( mToc, scene );
- QString toccy = QString("%1. %2").arg( 1+tocCount ).arg( readElementText() );
-
- textItem->setText( toccy );
- textItem->setPos( QPointF( 5.0, tocCount++ * 18.0 ) );
+ if( mCurrSpot ) {
+ mCurrSpot->setData( TOCENTRY, readElementText() );
}
} else if( name() == "spot" ) {
if( mCurrParent != 0 ) {
@@ -237,6 +221,17 @@
}
}
+ // now create the toc entry.
+ QString tocHtml = "<ol>";
+ foreach( QGraphicsItem *spot, mSpots ) {
+ QString tocString = spot->data(TOCENTRY).toString();
+ tocHtml += "<li>"+tocString+"</li>";
+ }
+ tocHtml += "</ol>";
+
+ QGraphicsTextItem *tocItem = new QGraphicsTextItem( 0, scene );
+ tocItem->setHtml( tocHtml );
+
return res;
}
--- trunk/playground/office/zippl/zipplxmlreader.h #1240780:1240781
@@ -5,7 +5,9 @@
#include <QIODevice>
#include <QList>
#include <QMap>
+
#define ID 0
+#define TOCENTRY 1
class GraphWidget;
class QGraphicsItem;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic