DictTypeSelectDialog ported to qml. Remove empty qml files.
authorMarcin Kaźmierczak <marcin@marcin-desktop.(none)>
Thu, 16 Dec 2010 15:30:47 +0000 (16:30 +0100)
committerMarcin Kaźmierczak <marcin@marcin-desktop.(none)>
Thu, 16 Dec 2010 15:30:47 +0000 (16:30 +0100)
15 files changed:
src/mdictionary/gui/DictTypeModel.cpp
src/mdictionary/gui/DictTypeModel.h
src/mdictionary/gui/DictTypeSelectDialog.cpp
src/mdictionary/gui/DictTypeSelectDialog.h
src/mdictionary/gui/WelcomeScreenWidget.cpp
src/mdictionary/gui/WelcomeScreenWidget.h
src/mdictionary/mdictionary.pro
src/mdictionary/qml/DictListDelegate.qml [deleted file]
src/mdictionary/qml/DictManagerWidget.qml [new file with mode: 0644]
src/mdictionary/qml/DictTypeListDelegate.qml [deleted file]
src/mdictionary/qml/DictTypeListView.qml [deleted file]
src/mdictionary/qml/DictTypeSelectDialog.qml
src/mdictionary/qml/ElementsListView.qml
src/mdictionary/qml/WordListDelegate.qml [deleted file]
src/mdictionary/qml/WordListWidget.qml [new file with mode: 0644]

index 5823829..b2d09b2 100644 (file)
@@ -1,3 +1,30 @@
+/*******************************************************************************
+
+    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.
+
+*******************************************************************************/
+
+/*! \file DictTypeModel.cpp
+    \brief Implements plugin data for list model
+
+    \author Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
 #include "DictTypeModel.h"
 
 DictTypeModel::DictTypeModel(QList<CommonDictInterface *> plugins, QObject *parent) :
@@ -5,6 +32,7 @@ DictTypeModel::DictTypeModel(QList<CommonDictInterface *> plugins, QObject *pare
 {
     QHash<int, QByteArray> roles;
     roles[TypeRole] = "type";
+    roles[NumberRole] = "number";
     setRoleNames(roles);
 
     setDictTypes(plugins);
@@ -31,6 +59,8 @@ QVariant DictTypeModel::data(const QModelIndex & index, int role) const
     const CommonDictInterface* plugin = _plugins[index.row()];
     if (role == TypeRole)
         return plugin->type();
+    if (role == NumberRole)
+        return index.row();
     return QVariant();
 }
 
index 1b24aff..3a35e91 100644 (file)
@@ -1,3 +1,30 @@
+/*******************************************************************************
+
+    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.
+
+*******************************************************************************/
+
+/*! \file DictTypeModel.h
+    \brief Implements plugin data for list model
+
+    \author Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
 #ifndef DICTTYPEMODEL_H
 #define DICTTYPEMODEL_H
 
 #include <QHash>
 #include "../../include/GUIInterface.h"
 
+/*!
+  Contains a list of plugin types.
+  Data source for qml list view.
+*/
 class DictTypeModel : public QAbstractListModel
 {
     Q_OBJECT
 public:
     enum DictTypeRoles
     {
-        TypeRole = Qt::UserRole + 1
+        TypeRole = Qt::UserRole + 1,
+        NumberRole
     };
 
+    //! Constructor
+    /*!
+      \param plugins list of plugin types
+      \param parent parent of this class.
+    */
     explicit DictTypeModel(QList<CommonDictInterface*> plugins, QObject *parent = 0);
 
-    void setDictTypes(QList<CommonDictInterface*> plugins);
-
     int rowCount(const QModelIndex & parent = QModelIndex()) const;
 
     QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
 
 private:
+    void setDictTypes(QList<CommonDictInterface*> plugins);
     QList<CommonDictInterface*> _plugins;
 
     void addType(CommonDictInterface* plugin);
index 62c7f42..8e26c14 100644 (file)
@@ -28,7 +28,7 @@
 #include "DictTypeSelectDialog.h"
 
 DictTypeSelectDialog::DictTypeSelectDialog(QList<CommonDictInterface *> plugins, QWidget *parent) :
-    QDialog(parent) {
+    QDialog(parent), model(plugins, this) {
 
     setWindowTitle(tr("Select dictionary type"));
 
@@ -37,6 +37,26 @@ DictTypeSelectDialog::DictTypeSelectDialog(QList<CommonDictInterface *> plugins,
     verticalLayout = new QVBoxLayout(this);
     setLayout(verticalLayout);
 
+#ifndef Q_WS_MAEMO_5
+    qmlView = new QDeclarativeView(this);
+    qmlView->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/DictTypeSelectDialog.qml"));
+    ctxt = qmlView->rootContext();
+
+//    model = new DictTypeModel(plugins, this);
+    ctxt->setContextProperty("dictTypeModel", &model);
+
+    _selectedPlugin = 0;
+
+    QGraphicsObject *rootObject = qmlView->rootObject();
+    connect(rootObject, SIGNAL(selectedRow(int)),
+            this, SLOT(pluginSelected(int)));
+
+    qmlView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+    verticalLayout->addWidget(qmlView);
+
+#endif
+#ifdef Q_WS_MAEMO_5
+
     pluginsListWidget = new QListWidget(this);
 
     verticalLayout->addWidget(pluginsListWidget);
@@ -51,6 +71,7 @@ DictTypeSelectDialog::DictTypeSelectDialog(QList<CommonDictInterface *> plugins,
 
     connect(pluginsListWidget, SIGNAL(itemActivated(QListWidgetItem*)),
             this, SLOT(pluginSelected(QListWidgetItem*)));
+#endif
 }
 
 void DictTypeSelectDialog::pluginSelected(QListWidgetItem *item) {
@@ -58,6 +79,11 @@ void DictTypeSelectDialog::pluginSelected(QListWidgetItem *item) {
     accept();
 }
 
+void DictTypeSelectDialog::pluginSelected(int item) {
+    _selectedPlugin = plugins[item];
+    accept();
+}
+
 CommonDictInterface* DictTypeSelectDialog::selectedPlugin() {
     return _selectedPlugin;
 }
index 34b0847..84f8545 100644 (file)
@@ -31,6 +31,9 @@
 #include <QtGui>
 #include "../../include/settings.h"
 #include "../../include/CommonDictInterface.h"
+#include "DictTypeModel.h"
+#include <QtDeclarative/QDeclarativeView>
+#include <QtDeclarative/QDeclarativeContext>
 
 #define PLUGIN_ROW_ROLE 99      //TODO remove this
 
@@ -60,12 +63,17 @@ protected:
                                   QWidget *parent = 0);
 private Q_SLOTS:
     void pluginSelected(QListWidgetItem* item);
+    void pluginSelected(int item);
 
 private:
     QListWidget* pluginsListWidget;
     QList<CommonDictInterface*> plugins;
     QVBoxLayout* verticalLayout;
     CommonDictInterface* _selectedPlugin;
+
+    QDeclarativeView* qmlView;
+    QDeclarativeContext* ctxt;
+    DictTypeModel model;
 };
 
 #endif // DICTTYPESELECTDIALOG_H
index f2ec62c..47a2ac3 100644 (file)
@@ -37,27 +37,30 @@ WelcomeScreenWidget::WelcomeScreenWidget(QWidget *parent) :
     mainLayout = new QVBoxLayout(this);
     setLayout(mainLayout);
 
-    qmlView = new QDeclarativeView;
+    #ifndef Q_WS_MAEMO_5
+    qmlView = new QDeclarativeView(this);
     qmlView->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/WelcomeScreenWidget.qml"));
 
     mainLayout->addWidget(qmlView, 0, Qt::AlignCenter);
 
-    //stary kod:
-    //imageLabel = new QLabel(this);
-    //mainLabel = new QLabel(infoNote, this);
+    #endif
+    #ifdef Q_WS_MAEMO_5
 
-    //mainLayout->addStretch(0);
-    //mainLayout->addWidget(imageLabel, 0, Qt::AlignCenter);
-    //mainLayout->addWidget(mainLabel, 0, Qt::AlignCenter);
-    //mainLayout->addStretch(0);
+    imageLabel = new QLabel(this);
+    mainLabel = new QLabel(infoNote, this);
 
-    //QImage img(":/icons/logo/mdictionary.png");
-    //imageLabel->setPixmap(QPixmap::fromImage(img));
-    //imageLabel->resize(imageLabel->pixmap()->size());
+    mainLayout->addStretch(0);
+    mainLayout->addWidget(imageLabel, 0, Qt::AlignCenter);
+    mainLayout->addWidget(mainLabel, 0, Qt::AlignCenter);
+    mainLayout->addStretch(0);
 
+    QImage img(":/icons/logo/mdictionary.png");
+    imageLabel->setPixmap(QPixmap::fromImage(img));
+    imageLabel->resize(imageLabel->pixmap()->size());
 
-    //mainLabel->setWordWrap(true);
-    //koniec kodu
+
+    mainLabel->setWordWrap(true);
+    #endif
 
     #ifdef Q_WS_MAEMO_5
         //mainLayout->addSpacing(20);
index 6e82a87..5c596d3 100644 (file)
@@ -31,8 +31,8 @@
 #include <QScrollArea>
 #include <QtGui>
 #include <QtDeclarative/QDeclarativeView>
-#include <QtDeclarative/QDeclarativeEngine>
-#include <QtDeclarative/QDeclarativeContext>
+//#include <QtDeclarative/QDeclarativeEngine>
+//#include <QtDeclarative/QDeclarativeContext>
 
 //! Displays welcome screen with logo and name of application
 class WelcomeScreenWidget : public QScrollArea
@@ -46,8 +46,8 @@ private:
     QLabel* mainLabel, * licenseLabel, *imageLabel;
 
     QDeclarativeView* qmlView;
-    QDeclarativeEngine* engine;
-    QDeclarativeContext* context;
+//    QDeclarativeEngine* engine;
+//    QDeclarativeContext* context;
     QWidget* widget;
 };
 
index 08d3050..5101211 100644 (file)
@@ -85,12 +85,10 @@ OTHER_FILES += \
     qml/SearchBarWidget.qml \
     qml/IconButton.qml \
     qml/MyTextLineEdit.qml \
-    qml/DictListDelegate.qml \
-    qml/DictTypeListDelegate.qml \
-    qml/WordListDelegate.qml \
     qml/ElementsListView.qml \
-    qml/DictTypeListView.qml \
-    qml/DictTypeSelectDialog.qml
+    qml/DictTypeSelectDialog.qml \
+    qml/DictManagerWidget.qml \
+    qml/WordListWidget.qml
 
 target.path = $$BIN_DIR
 INSTALLS += target
@@ -185,12 +183,10 @@ unix {
        qmls.files += ./qml/SearchBarWidget.qml
        qmls.files += ./qml/IconButton.qml
        qmls.files += ./qml/MyTextLineEdit.qml
-        qmls.files += ./qml/DictListDelegate.qml
-        qmls.files += ./qml/DictTypeListDelegate.qml
-        qmls.files += ./qml/WordListDelegate.qml
         qmls.files += ./qml/ElementsListView.qml
-        qmls.files += ./qml/DictTypeListView.qml
         qmls.files += ./qml/DictTypeSelectDialog.qml
+        qmls.files += ./qml/DictManagerWidget.qml
+        qmls.files += ./qml/WordListWidget.qml
     }
        
     INSTALLS += desktop icon64 shared service css css_images qmls
diff --git a/src/mdictionary/qml/DictListDelegate.qml b/src/mdictionary/qml/DictListDelegate.qml
deleted file mode 100644 (file)
index 15b01c6..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-import Qt 4.7
-
-Rectangle {
-    width: 100
-    height: 62
-}
diff --git a/src/mdictionary/qml/DictManagerWidget.qml b/src/mdictionary/qml/DictManagerWidget.qml
new file mode 100644 (file)
index 0000000..15b01c6
--- /dev/null
@@ -0,0 +1,6 @@
+import Qt 4.7
+
+Rectangle {
+    width: 100
+    height: 62
+}
diff --git a/src/mdictionary/qml/DictTypeListDelegate.qml b/src/mdictionary/qml/DictTypeListDelegate.qml
deleted file mode 100644 (file)
index e2ebbe9..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-import Qt 4.7
-
-Text {
-    text: type
-}
diff --git a/src/mdictionary/qml/DictTypeListView.qml b/src/mdictionary/qml/DictTypeListView.qml
deleted file mode 100644 (file)
index 9d83416..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-import Qt 4.7
-
-ElementsListView{
-    anchors.fill: parent
-    delegate: DictTypeListDelegate{}
-    model: dictTypeModel
-    focus: true
-}
index 5bf3b73..e57069a 100644 (file)
@@ -1,33 +1,67 @@
+/*******************************************************************************
+
+    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.
+
+*******************************************************************************/
+/*!
+    author: Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
 import Qt 4.7
 
 Rectangle {
     SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+    signal selectedRow(int nr)
 
     id: rectangle1
-    //width: (helloText.width > logo.width) ? (helloText.width) : (logo.width)
-    //height: logo.height + helloText.height
-    color: myPalette.window
+    color: myPalette.base
     anchors.fill: parent
 
-    DictTypeListView{
+    ElementsListView{
         id: dictTypeList
+        width: rectangle1.width
+        height: rectangle1.height
+        highlightResizeSpeed: 1000
+        delegate: Component{
+            id: dictTypeListDelegate
+            Item {
+                width: rectangle1.width
+                height: typeText.height
+                MouseArea{
+                    anchors.fill: parent
+                    onClicked: {
+                        dictTypeList.currentIndex = number
+                    }
+                    onDoubleClicked: {
+                        selectedRow(number)
+                    }
+                }
+                Row {
+                    Text {
+                        id: typeText
+                        text: type
+                        width: rectangle1.width
+                    }
+                }
+            }
 
+        }
+        model: dictTypeModel
     }
 
-//        Image {
-//            id: logo
-//            source: "qrc:/icons/logo/mdictionary.png"
-//            width: 240
-//            height: 200
-//            anchors.horizontalCenter: parent.horizontalCenter
-//            fillMode: Image.PreserveAspectFit
-//            anchors.top: parent.top
-//        }
-
-//        Text {
-//            id: helloText
-//            text: qsTr("<center><h1>Welcome in mDictionary!</h1></center>")
-//            anchors.bottom: parent.bottom
-//        }
-
 }
index d365763..c9a7561 100644 (file)
@@ -1,6 +1,33 @@
+/*******************************************************************************
+
+    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.
+
+*******************************************************************************/
+/*!
+    author: Marcin Kaźmierczak <marcin.kazmierczak@comarch.pl>
+*/
+
 import Qt 4.7
 
 ListView {
-    property int selectedElement: -1
-
+    anchors.fill: parent
+    focus: true
+    currentIndex: 0
+    highlight: Rectangle { color: "lightsteelblue"; radius: 5; width: parent.parent.width }
+    highlightMoveSpeed: 1000
 }
diff --git a/src/mdictionary/qml/WordListDelegate.qml b/src/mdictionary/qml/WordListDelegate.qml
deleted file mode 100644 (file)
index 15b01c6..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-import Qt 4.7
-
-Rectangle {
-    width: 100
-    height: 62
-}
diff --git a/src/mdictionary/qml/WordListWidget.qml b/src/mdictionary/qml/WordListWidget.qml
new file mode 100644 (file)
index 0000000..15b01c6
--- /dev/null
@@ -0,0 +1,6 @@
+import Qt 4.7
+
+Rectangle {
+    width: 100
+    height: 62
+}