Changeset 330

Show
Ignore:
Timestamp:
06/06/08 09:48:42 (3 months ago)
Author:
geiseri
Message:

added table parser and tables to pages

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • projects/MyPoint/src/page.cpp

    r324 r330  
    100100        m_preText.clear(); 
    101101        m_background.clear(); 
     102        m_table.clear(); 
    102103} 
    103104 
     
    123124} 
    124125 
     126 
     127 
     128QList< QStringList > Page::table() const 
     129{ 
     130        return m_table; 
     131} 
     132 
     133 
     134void Page::setTable ( const QList< QStringList >& theValue ) 
     135{ 
     136        m_table = theValue; 
     137} 
     138 
     139void Page::addTableRow(const QStringList & row) 
     140{ 
     141        m_table << row; 
     142} 
  • projects/MyPoint/src/page.h

    r287 r330  
    2424#include <QImage> 
    2525#include <QList> 
     26#include <QStringList> 
     27 
    2628#include  "point.h" 
    2729/** 
     
    5860        QString background( ) const; 
    5961 
     62        void addTableRow( const QStringList &row ); 
     63        void setTable ( const QList< QStringList >& theValue ); 
     64        QList< QStringList > table() const; 
    6065 
    6166private: 
    6267        QString m_title; 
    6368        QImage m_image; 
     69        QList<QStringList> m_table; 
    6470        QString m_footer; 
    6571        QList<Point*> m_points; 
  • projects/MyPoint/src/pdfslidereporter.cpp

    r324 r330  
    2222#include "presentation.h" 
    2323#include "point.h" 
     24#include "simpleparser.h" 
    2425 
    2526#include <QTextDocument> 
     
    3435#include <QDesktopServices> 
    3536#include <QUrl> 
     37#include <QStringList> 
    3638 
    3739#include  "qdebug.h" 
    3840extern int qt_defaultDpi(); 
    3941 
    40 PDFSlideReporter::PDFSlideReporter() : m_painter(0) 
     42PDFSlideReporter::PDFSlideReporter() : m_painter(0), m_debugTemplates(false) 
    4143{ 
    4244 
     
    8789        text->setPageSize( QSizeF(box.size().width() * (dpiScaleX) / textScaleX,box.size().height() * (dpiScaleY) / textScaleY ) ); 
    8890 
    89 //      painter->drawRect( box );  // Debug templates... 
     91        painter->setPen(Qt::red); 
     92        if( m_debugTemplates ) 
     93                painter->drawRect( box );  // Debug templates... 
    9094        painter->save(); 
    9195        painter->translate( box.x(), box.y() ); 
     
    9397        painter->scale( textScaleX, textScaleY); 
    9498        painter->setPen(Qt::blue); 
    95 //      painter->drawRect( QRectF( QPointF(0,0), text->pageSize() ) ); 
     99        if( m_debugTemplates ) 
     100                painter->drawRect( QRectF( QPointF(0,0), text->pageSize() ) ); 
    96101        text->drawContents(painter); 
    97102        painter->restore(); 
     
    228233                footnoteText = presentation->footer(); 
    229234        printTextBox( 
    230                                generatePageRect( size, footer ), 
    231                                footnoteText, 
    232                                m_painter, "second.footer" ); 
    233  
    234         printTextBox( 
    235                                generatePageRect( size, title), 
    236                                block->title(), 
    237                                painter, "second.title"); 
    238  
    239         printTextBox( 
    240                                generatePageRect( size, pgnumber), 
    241                                QString::number(presentation->pages().indexOf(*block) + 1), 
    242                                painter, "second.pgNumber" ); 
     235                generatePageRect( size, footer ), 
     236                footnoteText, 
     237                m_painter, "second.footer" ); 
     238 
     239        printTextBox( 
     240                generatePageRect( size, title), 
     241                block->title(), 
     242                painter, "second.title"); 
     243 
     244        printTextBox( 
     245                generatePageRect( size, pgnumber), 
     246                QString::number(presentation->pages().indexOf(*block) + 1), 
     247                painter, "second.pgNumber" ); 
    243248 
    244249        QTextDocument doc; 
    245250        doc.setDefaultStyleSheet("p, li { white-space: pre-wrap; }"); 
     251 
     252        QString htmlTable = generateTableContent( block ); 
     253        qDebug() << "Table" << htmlTable; 
    246254 
    247255        QString htmlList; 
     
    307315} 
    308316 
     317 
     318 
    309319QString PDFSlideReporter::openFont( const QString &fontName, const QString &color ) const 
    310320{ 
     
    365375        return fileName; 
    366376} 
     377 
     378 
     379bool PDFSlideReporter::debugTemplates() const 
     380{ 
     381        return m_debugTemplates; 
     382} 
     383 
     384 
     385void PDFSlideReporter::setDebugTemplates ( bool theValue ) 
     386{ 
     387        m_debugTemplates = theValue; 
     388} 
     389 
     390QString PDFSlideReporter::generateTableContent(Page * block) 
     391{ 
     392        QString table; 
     393 
     394        if( !block->table().isEmpty() ) 
     395        { 
     396                table += "<table>"; 
     397                foreach( QStringList line, block->table() ) 
     398                { 
     399                        table += "<tr>"; 
     400                        foreach( QString cell, line ) 
     401                                table += "<td>" + SimpleParser::formatWikiText( cell ) + "</td>"; 
     402                        table += "</tr>"; 
     403                } 
     404         
     405                table += "</table>"; 
     406        } 
     407        return table; 
     408} 
  • projects/MyPoint/src/pdfslidereporter.h

    r303 r330  
    6565                QString readDefaultBackground( const QString &templateFile, const QString &page, const QString &defaultValue = QString() ) const; 
    6666 
     67        void setDebugTemplates ( bool theValue ); 
     68         
     69 
     70        bool debugTemplates() const; 
     71         
     72 
    6773 
    6874        private: 
    6975                void generateTitlePage( Presentation *block, const QSizeF &size ); 
    7076                void generateContentPage( Presentation *presentation, Page *block, QPainter *painter, const QSizeF &size ); // generate the page itself (title, body, etc...) 
     77                QString generateTableContent( Page *block ); 
    7178                void generateContentPageList( Point *block, QString *writer ); // generate the outline html for the page 
    7279                QString openFont( const QString &fontName = "sans-serif", const QString &color = "#000000" ) const; 
     
    9198                QPainter *m_painter; 
    9299                QString m_templateName; 
     100                bool m_debugTemplates; 
    93101}; 
    94102 
  • projects/MyPoint/src/simpleparser.cpp

    r329 r330  
    114114                { 
    115115                        QStringList cells = line.split( "||" , QString::SkipEmptyParts); 
    116                         qDebug() << cells
     116                        newPage.addTableRow( cells )
    117117                } 
    118118                else if( direction( line, &captureText ) ) 
  • projects/MyPoint/src/src.pro

    r324 r330  
    1212          thread \ 
    1313          qt \ 
    14           release      
     14          debug        
    1515TARGET = ../bin/mypoint 
    1616 
     
    3232target.path += /usr/bin 
    3333INSTALLS += target 
    34 CONFIG -= debug 
    3534 
    3635QT += xml \ 
  • projects/MyPoint/src/wikirpc.cpp

    r328 r330  
    7373        return m_method->invoke( "wiki.wikiToHtml", wikiText ).toString(); 
    7474} 
     75 
     76WikiRPC::PageInfo WikiRPC::getPageInfo(const QString & pagename) const 
     77{ 
     78        QVariantMap map = m_method->invoke( "wiki.getPageInfo", pagename ).toMap(); 
     79        PageInfo pageInfo = {   map["name"].toString(), 
     80                                map["lastModified"].toDateTime(), 
     81                                map["author"].toString(), 
     82                                map["version"].toInt() }; 
     83        return pageInfo; 
     84} 
     85 
     86bool WikiRPC::putPage(const QString & pagename, const QString & content, const PageAttributes & attributes) const 
     87{ 
     88        QMap<QString,QVariant> map; 
     89        map["author"] = attributes.author; 
     90        map["readOnly"] = attributes.readOnly; 
     91        map["minoredit"] = attributes.minoredit; 
     92        map["comment"] = attributes.comment; 
     93 
     94        return m_method->invoke( "wiki.putPage", pagename, content, map ).toBool(); 
     95} 
     96 
     97bool WikiRPC::deleteAttachment(const QString & attachmentName) const 
     98{ 
     99        return m_method->invoke( "wiki.deleteAttachment", attachmentName ).toBool(); 
     100} 
     101 
     102bool WikiRPC::putAttachment(const QString & attachmentName, const QByteArray & data) const 
     103{ 
     104        return m_method->invoke( "wiki.putAttachment", attachmentName, data ).toBool(); 
     105} 
     106 
     107QList< WikiRPC::PageInfo > WikiRPC::getRecentChanges(const QDateTime & timestamp) const 
     108{ 
     109        QList<PageInfo> pageInfos; 
     110        QVariantList infos = m_method->invoke( "wiki.getRecentChanges", timestamp ).toList(); 
     111        foreach( QVariant info, infos ) 
     112        { 
     113                QVariantMap map = info.toMap(); 
     114                PageInfo pageInfo = {   map["name"].toString(), 
     115                                        map["lastModified"].toDateTime(), 
     116                                        map["author"].toString(), 
     117                                        map["version"].toInt() }; 
     118                pageInfos << pageInfo; 
     119        } 
     120 
     121        return pageInfos; 
     122} 
  • projects/MyPoint/src/wikirpc.h

    r328 r330  
    2323#include <QObject> 
    2424#include <QUrl> 
     25#include <QMap> 
     26#include <QDateTime> 
    2527 
    2628namespace KRPC 
     
    3739                Q_OBJECT 
    3840        public: 
     41 
     42                struct PageInfo 
     43                { 
     44                        QString name; 
     45                        QDateTime lastModified; 
     46                        QString author; 
     47                        int version; 
     48                }; 
     49 
     50                struct PageAttributes  
     51                { 
     52                        QString comment; 
     53                        bool minoredit; 
     54                        bool readOnly; 
     55                        QString author; 
     56                }; 
     57 
    3958                WikiRPC( const QString &rpcUrl, QObject *parent = 0 ); 
    40  
    4159                ~WikiRPC(); 
    4260 
     61                QStringList getAllPages() const; 
     62                QList<PageInfo> getRecentChanges( const QDateTime & timestamp ) const; 
    4363                QString getPage( const QString &pagename ) const; 
    4464                QString getPageHTML( const QString &pagename ) const; 
    4565                QString wikiToHtml(const QString &wikiText ) const; 
     66                PageInfo getPageInfo(const QString &pagename ) const; 
     67                bool putPage(const QString &pagename, const QString &content, const PageAttributes  &attributes) const; 
     68 
    4669                QStringList listAttachments( const QString &pagename ) const; 
    4770                QByteArray getAttachment( const QString &attachmentName ) const; 
    48                 QStringList getAllPages() const; 
     71                bool deleteAttachment(const QString &attachmentName) const; 
     72                bool putAttachment(const QString &attachmentName, const QByteArray &data ) const; 
    4973 
    5074        private slots: