[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 20:04:27
Message-ID: 20110710200427.66B08AC84E () svn ! kde ! org
[Download RAW message or body]
SVN commit 1240861 by freitag:
Create a proper TOC
M +4 -3 graphwidget.cpp
M +1 -1 zippl.xml
M +7 -2 zipplcontroler.cpp
M +1 -0 zipplcontroler.h
M +61 -4 zipplxmlreader.cpp
M +9 -0 zipplxmlreader.h
--- trunk/playground/office/zippl/graphwidget.cpp #1240860:1240861
@@ -42,9 +42,7 @@
#include "graphwidget.h"
#include <QDebug>
-#include <QGraphicsScene>
-#include <QWheelEvent>
-
+#include <QtGui>
#include <math.h>
GraphWidget::GraphWidget()
@@ -65,6 +63,9 @@
// scale(qreal(0.8), qreal(0.8));
setMinimumSize(600, 400);
setWindowTitle(tr("Elastic Nodes"));
+
+ setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
+ setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
}
void GraphWidget::itemMoved()
--- trunk/playground/office/zippl/zippl.xml #1240860:1240861
@@ -1,7 +1,7 @@
<zippl version="0.1">
<meta>
<title>A test Zippl presentation</title>
- <description>This demonstration will show what Zippl can</description>
+ <description>This demonstration shows what Zippl can do for you</description>
<date>2010-05-21</date>
<author>
<name>Klaas Freitag</name>
--- trunk/playground/office/zippl/zipplcontroler.cpp #1240860:1240861
@@ -6,7 +6,7 @@
ZipplControler::ZipplControler( GraphWidget *graphWidget )
:QObject(),
mGraphWidget( graphWidget ),
- mCurrSpotNo(0),
+ mCurrSpotNo(-1),
mCurrStationNo(0),
mWatcher( new QFileSystemWatcher(this))
{
@@ -37,7 +37,7 @@
mSpotList = xmlReader.spotItems();
mHiddenItems = xmlReader.hiddenItems();
mWatcher->addPath( filePath );
-
+ mTocItem = xmlReader.toc();
} else {
qDebug() << "Failed to read zippl in file!";
}
@@ -64,6 +64,11 @@
{
qDebug() << "Move to next spot, current spot no is " << mCurrSpotNo;
+ if( mCurrSpotNo < 0 ) {
+ // Currently the toc is shown. Hide it and move on.
+ qDebug() << "HIDING the TOC";
+ mTocItem->hide();
+ }
mCurrSpotNo++;
QGraphicsItem *currItem = currentSpot();
--- trunk/playground/office/zippl/zipplcontroler.h #1240860:1240861
@@ -32,6 +32,7 @@
int mCurrSpotNo;
int mCurrStationNo;
QFileSystemWatcher *mWatcher;
+ QGraphicsItem *mTocItem;
};
#endif // ZIPPLCONTROLER_H
--- trunk/playground/office/zippl/zipplxmlreader.cpp #1240860:1240861
@@ -76,6 +76,7 @@
{
setDevice( dev );
bool res = true;
+ bool metaMode = false;
mCurrParent = 0;
mCurrSpot = 0;
@@ -97,6 +98,18 @@
qreal dy = qrealAttrib("height") / -2.0;
QRectF rect( dx, dy, -2.0*dx, -2.0*dy );
scene->setSceneRect( rect );
+ } else if( name() == "meta" ) {
+ metaMode = true;
+ } else if( name() == "title" && metaMode ) {
+ mPresentationTitle = readElementText();
+ } else if( name() == "description" && metaMode ) {
+ mPresentationDescr = readElementText();
+ } else if( name() == "date" && metaMode ) {
+ mPresentationDate = readElementText();
+ } else if( name() == "name" && metaMode ) {
+ mAuthorName = readElementText();
+ } else if( name() == "email" && metaMode ) {
+ mAuthorEmail = readElementText();
} else if( name() == "tocentry" ) {
if( mCurrSpot ) {
mCurrSpot->setData( TOCENTRY, readElementText() );
@@ -217,22 +230,61 @@
} else if( name() == "hidden") {
mCurrParent->setOpacity( 0.0 );
mCurrParent = mCurrParent->parentItem();
+ } else if( name() == "meta" ) {
+ metaMode = false;
}
}
}
+ createToc( scene );
+
+ return res;
+}
+
+void ZipplXmlReader::createToc( QGraphicsScene *scene )
+{
// now create the toc entry.
- QString tocHtml = "<ol>";
+ QString tocHtml;
+ if( !mPresentationTitle.isEmpty() ) tocHtml += QString("<h1>%1</h1>").arg( mPresentationTitle );
+ if( !mPresentationDescr.isEmpty() ) tocHtml += QString("<h2>%1</h2>").arg( mPresentationDescr);
+
+ tocHtml += "<p>Table of Contents:</p>";
+ tocHtml += "<ol>";
foreach( QGraphicsItem *spot, mSpots ) {
QString tocString = spot->data(TOCENTRY).toString();
- tocHtml += "<li>"+tocString+"</li>";
+ tocHtml += QString( "<li>%1</li>").arg( tocString );
}
tocHtml += "</ol>";
- QGraphicsTextItem *tocItem = new QGraphicsTextItem( 0, scene );
+ if( !mAuthorName.isEmpty() ) {
+ tocHtml += QString( "<p>%1" ).arg( mAuthorName );
+ if( !mAuthorEmail.isEmpty() ) {
+ tocHtml += QString( " <%1>" ).arg( mAuthorEmail );
+ }
+ if( !mPresentationDate.isEmpty() ) tocHtml += QString(" - %1").arg( mPresentationDate );
+ tocHtml += "</p>";
+ }
+
+ QGraphicsRectItem *tocRectItem = new QGraphicsRectItem( );
+ tocRectItem->setPen( pen( tocRectItem->pen(), QColor("#aeaeae") ));
+
+ QBrush brush( tocRectItem->brush() );
+ brush.setColor( QColor( 255,255,255 ));
+ brush.setStyle( Qt::Dense1Pattern );
+ tocRectItem->setBrush( brush );
+
+ int margin = 20;
+ QGraphicsTextItem *tocItem = new QGraphicsTextItem( tocRectItem, scene );
tocItem->setHtml( tocHtml );
+ QRectF r = tocRectItem->childrenBoundingRect();
+ r.setWidth( r.width() + margin );
+ r.setHeight( r.height() + margin );
+ tocRectItem->setRect( r );
+ tocItem->moveBy( margin/2, margin/2 );
- return res;
+ mToc = tocRectItem;
+ mToc->moveBy( r.width() /-2, r.height() / -2 );
+ scene->addItem( mToc );
}
bool ZipplXmlReader::handleImg( QGraphicsScene *scene )
@@ -273,6 +325,11 @@
return mMode;
}
+QGraphicsItem* ZipplXmlReader::toc()
+{
+ return mToc;
+}
+
QList<QGraphicsItem*> ZipplXmlReader::spotItems()
{
return mSpots;
--- trunk/playground/office/zippl/zipplxmlreader.h #1240860:1240861
@@ -26,6 +26,8 @@
QMap<QGraphicsItem*, GraphicsItemList> hiddenItems();
QString mode();
+ QGraphicsItem *toc();
+
private:
QPointF position();
qreal qrealAttrib( const QString& );
@@ -33,6 +35,7 @@
QColor color( const QColor& defaultCol = QColor("#000000") );
QBrush brush( const QBrush& );
+ void createToc( QGraphicsScene* );
bool handleImg( QGraphicsScene* );
QGraphicsItem *mCurrParent;
QGraphicsItem *mCurrSpot;
@@ -43,6 +46,12 @@
QList<QGraphicsItem*> mSpots;
QMap<QGraphicsItem*, GraphicsItemList> mHiddenItems;
QString mMode;
+ QString mPresentationTitle;
+ QString mPresentationDescr;
+ QString mPresentationDate;
+ QString mAuthorName;
+ QString mAuthorEmail;
+
};
#endif // ZIPPLXMLREADER_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic