[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/kexi/webforms/view/default
From:       Lorenzo Villani <lvillani () binaryhelix ! net>
Date:       2008-08-07 14:13:27
Message-ID: 1218118407.773884.2939.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 843657 by villani:

* cleanup

 M  +4 -95     Read.cpp  


--- trunk/koffice/kexi/webforms/view/default/Read.cpp #843656:843657
@@ -18,6 +18,8 @@
    Boston, MA 02110-1301, USA.
 */
 
+#include <QMap>
+#include <QPair>
 #include <QHash>
 #include <QString>
 
@@ -25,9 +27,7 @@
 
 #include <KDebug>
 
-#include <kexidb/cursor.h>
-#include <kexidb/connection.h>
-#include <kexidb/indexschema.h>
+#include <kexidb/tableschema.h>
 
 #include "../../model/Database.h"
 #include "../../model/DataProvider.h"
@@ -42,10 +42,9 @@
     void Read::view(const QHash<QString, QString>& d, \
pion::net::HTTPResponseWriterPtr writer) {  QString requestedTable(d["uri-table"]);
 
-        QString tableData;
-
         QPair< KexiDB::TableSchema, QMap<uint, QList<QString> > > pair = \
KexiWebForms::Model::Database::readTable(requestedTable);  
+        QString tableData;
         uint totalRecords = pair.second.count();
         QString primaryKey(pair.first.primaryKey()->field(0)->name());
 
@@ -78,97 +77,7 @@
         }
 
         setValue("TABLEDATA", tableData);
-
-        /*bool readOnly = (querySchema.connection() && \
                querySchema.connection()->isReadOnly());
-        if (readOnly) {
-            setValue("TABLENAME", requestedTable.append(" (read only)"));
-        } else {
-            setValue("TABLENAME", requestedTable);
-        }
-
-        /* awful 
-        int recordsTotal = 0;
-        while (cursor->moveNext())
-            recordsTotal++;
-        gConnection->deleteCursor(cursor);
-
-        /* even more awful 
-        cursor = gConnection->executeQuery(querySchema);
-
-        if (!cursor) {
-            setValue("ERROR", "Unable to execute the query (" __FILE__ ")");
-        } else if (tableSchema->primaryKey()->fields()->isEmpty()) {
-            setValue("ERROR", "This table has no primary key!");
-        } else {
-            KexiDB::Field* primaryKey = tableSchema->primaryKey()->field(0);
-
-            // Create labels with field name
-            tableData.append("<tr>\t<th scope=\"col\">Record</th>\n");
-            for (uint i = 0; i < cursor->fieldCount(); i++) {
-                tableData.append(QString("\t<th scope=\"col\">%1</th>\n")
-                    .arg(querySchema.field(i)->captionOrName()));
-            }
-            tableData.append("</tr>\n");
-
-
-            // Create labels with fields data
-            int currentRecord = 0;
-            QString totalRecords(QVariant(recordsTotal).toString());
-            while (cursor->moveNext()) {
-                currentRecord++;
-
-                tableData.append(QString("<tr><td>%1 of \
                %2</td>").arg(QVariant(currentRecord).toString())
-                    .arg(totalRecords));
-
-                QString \
                pkeyVal(cursor->value(tableSchema->indexOf(primaryKey)).toString());
-
-                for (uint i = 0; i < cursor->fieldCount(); i++) {
-                    tableData.append("<td>");
-
-                    //
-                    // Use Kexi functions to retrieve and represent the Value
-                    //! @todo use Kexi the same functions for rendering values as \
                Kexi table and form view
-                    //
-                    KexiDB::Field* field = querySchema.field(i);
-                    const KexiDB::Field::Type type = field->type();
-                    QString valueString;
-                    if (type == KexiDB::Field::BLOB) {
-                        valueString = QString("<img src=\"/blob/%1/%2/%3/%4\" \
                alt=\"Image\"/>")
-                            \
                .arg(requestedTable).arg(field->name()).arg(primaryKey->name())
-                            .arg(pkeyVal);
-                    }
-                    else if (field->isTextType()) {
-                        valueString = Qt::escape( cursor->value(i).toString() );
-                    }
-                    else {
-                        valueString = Qt::escape( cursor->value(i).toString() );
-                    }
-                    tableData.append(valueString);
-                    tableData.append("</td>");
-                }
-                // Toolbox
-                if (!readOnly) {
-                    // Edit
-                    tableData.append(QString("<td><a href=\"/update/%1/%2/%3\">"
-                        "<img src=\"/f/toolbox/draw-freehand.png\" \
                alt=\"Edit\"/></a></td>")
-                        .arg(requestedTable).arg(primaryKey->name()).arg(pkeyVal));
-                    // Delete
-                    tableData.append(QString("<td><a href=\"/delete/%1/%2/%3\">"
-                        "<img src=\"/f/toolbox/draw-eraser.png\" \
                alt=\"Edit\"/></a></td>")
-                        .arg(requestedTable).arg(primaryKey->name()).arg(pkeyVal));
-                    // End row
-                }
-                tableData.append("</tr>\n");
-            }
-
-            setValue("TABLEDATA", tableData);
-
-            kDebug() << "Deleting cursor..." << endl;
-            gConnection->deleteCursor(cursor);
-        }*/
-
         renderTemplate(m_dict, writer);
-
     }
     
 }    


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic