]> Git trees. - qtvoc.git/commitdiff
add trainer
authorReto Zingg <g.d0b3rm4n@gmail.com>
Tue, 16 Mar 2010 21:27:34 +0000 (23:27 +0200)
committerReto Zingg <g.d0b3rm4n@gmail.com>
Tue, 16 Mar 2010 21:27:34 +0000 (23:27 +0200)
trainer/main.cpp [new file with mode: 0644]
trainer/trainer.cpp [new file with mode: 0644]
trainer/trainer.h [new file with mode: 0644]
trainer/trainer.pro [new file with mode: 0644]

diff --git a/trainer/main.cpp b/trainer/main.cpp
new file mode 100644 (file)
index 0000000..b5c04e5
--- /dev/null
@@ -0,0 +1,10 @@
+#include <QtGui/QApplication>
+#include "trainer.h"
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    Trainer w;
+    w.show();
+    return a.exec();
+}
diff --git a/trainer/trainer.cpp b/trainer/trainer.cpp
new file mode 100644 (file)
index 0000000..dcfca6f
--- /dev/null
@@ -0,0 +1,64 @@
+#include "trainer.h"
+
+#include <QApplication>
+#include <QtDebug>
+#include <QTableWidget>
+#include <QHBoxLayout>
+#include <QList>
+
+Trainer::Trainer(QWidget *parent)
+    : QWidget(parent)
+{
+    QTableWidget *tableWidget = new QTableWidget(this);
+
+
+    QStringList args = QApplication::arguments();
+    args.removeFirst();
+
+    KEduVocDocument docRead;
+    docRead.open(args.at(0));
+
+    QList<KEduVocContainer *>  lessons = docRead.lesson()->childContainers();
+
+    KEduVocLesson *m_lesson;
+
+    foreach(KEduVocContainer * c, lessons) {
+        if (c->containerType() == KEduVocLesson::Lesson) {
+                m_lesson = static_cast<KEduVocLesson *>(c);
+                qDebug () << "Lesson: " << m_lesson->name();
+                for(int i = 0; i < m_lesson->entries().size(); ++i)
+                {
+                    tableWidget->insertRow(i);
+                    for( int j = 0; j < m_lesson->entry(i)->translationIndices().size(); ++j )
+                    {
+                        qDebug() << "columnCount: " << tableWidget->columnCount() << "j: " << j;
+                        if (tableWidget->columnCount() <= j)
+                        {
+                            tableWidget->insertColumn(j);
+                        }
+                        qDebug() << "Entry: " << m_lesson->entry(i)->translation(j)->text() << "Identifier: " << docRead.identifier(j).name();
+                        QTableWidgetItem *newItem = new QTableWidgetItem(m_lesson->entry(i)->translation(j)->text());
+                        tableWidget->setItem(i, j, newItem);
+                    }
+                }
+        }
+    }
+
+    QList<QString> labels;
+    for( int i = 0; i < docRead.identifierCount(); ++i )
+    {
+        qDebug() << "Identifier: " << docRead.identifier(i).name() << " i: " << i;
+        labels.insert(i, docRead.identifier(i).name());
+    }
+
+    tableWidget->setHorizontalHeaderLabels(labels);
+
+    QHBoxLayout *layout = new QHBoxLayout;
+    layout->addWidget(tableWidget);
+    setLayout(layout);
+}
+
+Trainer::~Trainer()
+{
+
+}
diff --git a/trainer/trainer.h b/trainer/trainer.h
new file mode 100644 (file)
index 0000000..a6c7850
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef TRAINER_H
+#define TRAINER_H
+
+#include <QtGui/QWidget>
+
+#include "keduvocdocument.h"
+#include "keduvoclesson.h"
+#include "keduvocexpression.h"
+#include "keduvocleitnerbox.h"
+
+class Trainer : public QWidget
+{
+    Q_OBJECT
+
+public:
+    Trainer(QWidget *parent = 0);
+    ~Trainer();
+};
+
+#endif // TRAINER_H
diff --git a/trainer/trainer.pro b/trainer/trainer.pro
new file mode 100644 (file)
index 0000000..274ddf5
--- /dev/null
@@ -0,0 +1,16 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2010-03-16T20:41:35
+#
+#-------------------------------------------------
+
+TARGET = trainer
+TEMPLATE = app
+LIBS += -L/home/rzingg/kedu/git/lib -lkeduvocdocument
+DEPENDPATH += . /home/rzingg/kedu/git/lib
+INCLUDEPATH += . /home/rzingg/kedu/git/lib
+
+SOURCES += main.cpp\
+        trainer.cpp
+
+HEADERS  += trainer.h