Added WordListWidget and TranslationWidget classes. Added switching views between...
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Tue, 3 Aug 2010 10:10:17 +0000 (12:10 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Tue, 3 Aug 2010 10:10:17 +0000 (12:10 +0200)
trunk/src/base/mDictionary/MainWindow.cpp
trunk/src/base/mDictionary/MainWindow.h
trunk/src/base/mDictionary/MainWindow.ui
trunk/src/base/mDictionary/gui/TranslationWidget.cpp [new file with mode: 0644]
trunk/src/base/mDictionary/gui/TranslationWidget.h [new file with mode: 0644]
trunk/src/base/mDictionary/gui/WordListWidget.cpp [new file with mode: 0644]
trunk/src/base/mDictionary/gui/WordListWidget.h [new file with mode: 0644]
trunk/src/base/mDictionary/mDictionary.pro

index 7cc8e85..51de694 100644 (file)
@@ -6,6 +6,18 @@ MainWindow::MainWindow(QWidget *parent) :
     ui(new Ui::MainWindow)
 {
     ui->setupUi(this);
+    setAttribute(Qt::WA_Maemo5StackedWindow);
+
+    searchBarWidget = new SearchBarWidget();
+    wordListWidget = new WordListWidget();
+    translationWidget = new TranslationWidget(this);
+
+    connect(wordListWidget, SIGNAL(clicked(QModelIndex)), translationWidget, SLOT(show(QModelIndex)));
+
+    ui->centralWidget->layout()->addWidget(wordListWidget);
+    ui->centralWidget->layout()->addWidget(searchBarWidget);
+
+
 }
 
 MainWindow::~MainWindow()
index c9fd6a9..b746d5e 100644 (file)
@@ -2,6 +2,9 @@
 #define MAINWINDOW_H
 
 #include <QMainWindow>
+#include "gui/TranslationWidget.h"
+#include "gui/WordListWidget.h"
+#include "gui/SearchBarWidget.h"
 
 namespace Ui {
     class MainWindow;
@@ -17,6 +20,9 @@ public:
 
 private:
     Ui::MainWindow *ui;
+    SearchBarWidget* searchBarWidget;
+    TranslationWidget* translationWidget;
+    WordListWidget* wordListWidget;
 };
 
 #endif // MAINWINDOW_H
index 1de7966..a9ee0be 100644 (file)
    <property name="autoFillBackground">
     <bool>true</bool>
    </property>
-   <layout class="QVBoxLayout" name="verticalLayout">
-    <item>
-     <spacer name="verticalSpacer">
-      <property name="orientation">
-       <enum>Qt::Vertical</enum>
-      </property>
-      <property name="sizeHint" stdset="0">
-       <size>
-        <width>20</width>
-        <height>800</height>
-       </size>
-      </property>
-     </spacer>
-    </item>
-    <item>
-     <widget class="SearchBarWidget" name="widget" native="true">
-      <property name="enabled">
-       <bool>true</bool>
-      </property>
-     </widget>
-    </item>
-   </layout>
+   <layout class="QVBoxLayout" name="verticalLayout"/>
   </widget>
   <widget class="QMenuBar" name="menuBar">
    <property name="geometry">
   </widget>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
- <customwidgets>
-  <customwidget>
-   <class>SearchBarWidget</class>
-   <extends>QWidget</extends>
-   <header>gui/SearchBarWidget.h</header>
-   <container>1</container>
-  </customwidget>
- </customwidgets>
  <resources/>
  <connections/>
 </ui>
diff --git a/trunk/src/base/mDictionary/gui/TranslationWidget.cpp b/trunk/src/base/mDictionary/gui/TranslationWidget.cpp
new file mode 100644 (file)
index 0000000..562e55e
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#include "TranslationWidget.h"
+#include <QDebug>
+
+TranslationWidget::TranslationWidget(QWidget *parent) :
+    QWidget(parent) {
+    setAttribute(Qt::WA_Maemo5StackedWindow);
+    setWindowFlags(windowFlags() | Qt::Window);
+}
+
+void TranslationWidget::show(QModelIndex index) {
+    QWidget::show();
+
+    qDebug()<<index.model()->data(index);
+}
diff --git a/trunk/src/base/mDictionary/gui/TranslationWidget.h b/trunk/src/base/mDictionary/gui/TranslationWidget.h
new file mode 100644 (file)
index 0000000..8e089c8
--- /dev/null
@@ -0,0 +1,42 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#ifndef TRANSLATIONWIDGET_H
+#define TRANSLATIONWIDGET_H
+
+#include <QWidget>
+#include <QModelIndex>
+
+class TranslationWidget : public QWidget {
+    Q_OBJECT
+public:
+    explicit TranslationWidget(QWidget *parent = 0);
+
+Q_SIGNALS:
+
+public Q_SLOTS:
+    void show(QModelIndex);
+
+};
+
+#endif // TRANSLATIONWIDGET_H
diff --git a/trunk/src/base/mDictionary/gui/WordListWidget.cpp b/trunk/src/base/mDictionary/gui/WordListWidget.cpp
new file mode 100644 (file)
index 0000000..104b480
--- /dev/null
@@ -0,0 +1,68 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#include "WordListWidget.h"
+#include <QDebug>
+
+WordListWidget::WordListWidget(QWidget *parent) :
+    QListView(parent) {
+    wordListModel = new QStringListModel();
+
+    setModel(wordListModel);
+
+    addWord("ala");
+    addWord("ma");
+    addWord("kota");
+    addWord("ala");
+    addWord("ma");
+    addWord("kota");
+    addWord("ala");
+    addWord("ma");
+    addWord("kota");
+    addWord("ala");
+    addWord("ma");
+    addWord("kota");
+    addWord("ala");
+    addWord("ma");
+    addWord("kota");
+
+    setAttribute(Qt::WA_Maemo5StackedWindow);
+}
+
+void WordListWidget::addWord(QString word) {
+    int wordsCount = wordListModel->rowCount();
+
+    wordListModel->insertRow(wordsCount);
+
+    QModelIndex newWordIndex = wordListModel->index(wordsCount);
+
+    wordListModel->setData(newWordIndex, word);
+}
+
+void WordListWidget::clear() {
+    int wordsCount = wordListModel->rowCount();
+
+    for(int i = 0; i < wordsCount; i++) {
+        wordListModel->removeRow(0);
+    }
+}
diff --git a/trunk/src/base/mDictionary/gui/WordListWidget.h b/trunk/src/base/mDictionary/gui/WordListWidget.h
new file mode 100644 (file)
index 0000000..d2451b9
--- /dev/null
@@ -0,0 +1,46 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#ifndef WORDLISTWIDGET_H
+#define WORDLISTWIDGET_H
+
+#include <QWidget>
+#include <QtGui>
+#include <QStringListModel>
+
+class WordListWidget : public QListView {
+    Q_OBJECT
+public:
+    explicit WordListWidget(QWidget *parent = 0);
+
+Q_SIGNALS:
+
+private Q_SLOTS:
+
+private:
+    QStringListModel *wordListModel;
+    void addWord(QString word);
+    void clear();
+};
+
+#endif // WORDLISTWIDGET_H
index fd1e6d9..9cdbc53 100644 (file)
@@ -12,9 +12,13 @@ TEMPLATE = app
 
 SOURCES += main.cpp\
         MainWindow.cpp \
-    gui/SearchBarWidget.cpp
+    gui/SearchBarWidget.cpp \
+    gui/WordListWidget.cpp \
+    gui/TranslationWidget.cpp
 
 HEADERS  += MainWindow.h \
-    gui/SearchBarWidget.h
+    gui/SearchBarWidget.h \
+    gui/WordListWidget.h \
+    gui/TranslationWidget.h
 
 FORMS    += MainWindow.ui