table view
authorjakub <jakub.jaszczynski@comarch.com>
Mon, 31 Jan 2011 11:31:51 +0000 (12:31 +0100)
committerjakub <jakub.jaszczynski@comarch.com>
Mon, 31 Jan 2011 11:31:51 +0000 (12:31 +0100)
14 files changed:
mdictionary.pri
src/mdictionary/qml/Button.qml
src/mdictionary/qml/IconButton.qml
src/mdictionary/qml/ScrollBar.qml
src/mdictionary/qml/ScrollBar2.qml [new file with mode: 0644]
src/mdictionary/qml/TableWidget.qml [new file with mode: 0644]
src/mdictionary/qml/TranslationView.qml
src/mdictionary/qml/XdxfDictDownloader.qml
src/plugins/xdxf/DownloadDict.h
src/plugins/xdxf/XdxfDialog.h
src/plugins/xdxf/XdxfDictSelectDialog.cpp
src/plugins/xdxf/XdxfDictSelectDialog.h
src/plugins/xdxf/xdxf.pro
src/plugins/xdxf/xdxf.qrc

index c48f80d..0648729 100644 (file)
@@ -32,3 +32,5 @@ system(echo "ENABLED_SRC = $$ENABLED_SRC" >src/src.pri)
 system(echo "ENABLED_PLUGINS = $$ENABLED_PLUGINS" >src/plugins/plugins.pri)
 
 OTHER_FILES +=
+
+HEADERS +=
index 0491e99..d10edc6 100644 (file)
@@ -33,15 +33,18 @@ BorderImage {
         height: parent.height
         anchors.left: parent.left
         source: "qrc:/button/buttonLeft.png"
+        smooth: true
         fillMode:Image.Stretch
     }
 
     Image {
         id: image3
         smooth: true
-        width: parent.width - ((70*parent.height)/107) +1;
         height: parent.height
-        anchors.horizontalCenter: parent.horizontalCenter
+        anchors.right: image2.left
+        anchors.rightMargin: -1
+        anchors.left: image1.right
+        anchors.leftMargin: -1
         source: "qrc:/button/buttonCenter.png"
         fillMode:Image.Stretch
     }
index dc749a4..19d3d70 100644 (file)
@@ -23,6 +23,7 @@ Rectangle {
     Image {
         id: image
         z:4;
+        smooth: true
         anchors.centerIn: parent
         width: iconWidth;
         height: iconHeight;
@@ -42,9 +43,11 @@ Rectangle {
         id: image3
         z: 1
         smooth: true
-        width: parent.width - (70*parent.height)/107 +1
         height: parent.height
-        anchors.horizontalCenter: parent.horizontalCenter
+        anchors.right: image2.left
+        anchors.rightMargin: -1
+        anchors.left: image1.right
+        anchors.leftMargin: -1
         source: "qrc:/button/buttonCenter.png"
 
     }
index cf216d2..5fba8af 100644 (file)
@@ -1,44 +1,3 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial Usage
-** Licensees holding valid Qt Commercial licenses may use this file in
-** accordance with the Qt Commercial License Agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Nokia.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights.  These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file.  Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
 import Qt 4.7
 
 Item {
@@ -56,7 +15,10 @@ Item {
             ny = scrollArea.visibleArea.yPosition * container.height;
         else
             ny = scrollArea.visibleArea.xPosition * container.width;
-        if (ny > 2) return ny; else return 2;
+        if (ny > 2)
+            return ny;
+        else
+            return 2;
     }
 
     function size()
@@ -80,7 +42,8 @@ Item {
             else
                 t = Math.ceil(container.width - 3 - ny);
             if (nh > t) return t; else return nh;
-        } else return nh + ny;
+        } else
+            return nh + ny;
     }
 
  //Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.5 }
diff --git a/src/mdictionary/qml/ScrollBar2.qml b/src/mdictionary/qml/ScrollBar2.qml
new file mode 100644 (file)
index 0000000..4147362
--- /dev/null
@@ -0,0 +1,52 @@
+import Qt 4.7
+
+Item {
+    id: scrollBar
+
+    // The properties that define the scrollbar's state.
+    // position and pageSize are in the range 0.0 - 1.0.  They are relative to the
+    // height of the page, i.e. a pageSize of 0.5 means that you can see 50%
+    // of the height of the view.
+    // orientation can be either Qt.Vertical or Qt.Horizontal
+    property variant orientation : Qt.Vertical
+    property int windowHeight :100
+    property alias position: slider.x
+
+    signal changeCursor
+
+    // Size the bar to the required size, depending upon the orientation.
+    Rectangle {
+        id: slider;
+        width:  1;
+        height: windowHeight;
+        radius: height/2 - 1
+        color: "black"
+        opacity: 0.7
+    }
+
+    MouseArea {
+            property variant lastPresX;
+            anchors.rightMargin: 5
+            anchors.leftMargin: 5
+            id: mouse_area1
+            anchors.fill: slider
+            onEntered: {
+
+            }
+
+            onMousePositionChanged:{
+                var num=0;
+                if(Qt.LeftButton) {
+                    num= slider.x+(mouseX-lastPresX);
+
+                    if(num>(scrollBar.width-slider.width))
+                        slider.x=scrollBar.width-slider.width
+                    else if(num<0)
+                        slider.x=0;
+                    else
+                        slider.x=num ;
+                }
+            }
+            onPressed: lastPresX=mouseX;
+        }
+}
diff --git a/src/mdictionary/qml/TableWidget.qml b/src/mdictionary/qml/TableWidget.qml
new file mode 100644 (file)
index 0000000..c07d8a5
--- /dev/null
@@ -0,0 +1,169 @@
+import Qt 4.7
+
+Rectangle {
+    SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+    color : myPalette.window;
+
+    id: rectangle1
+    width: 400;
+    height: 400;
+    anchors.fill: parent
+
+    signal dictLink(string link);
+
+    ScrollBar2 {
+        id: horizontalScrollBar1
+        z:2;
+        width: parent.width-12;
+        windowHeight: parent.height
+        anchors.left: parent.left
+        orientation: Qt.Horizontal
+        position: 100
+    }
+    ScrollBar2 {
+        id: horizontalScrollBar2
+        z:2;
+        width: parent.width-12;
+        windowHeight: parent.height
+        anchors.left: horizontalScrollBar1.left
+        anchors.leftMargin: horizontalScrollBar1.position
+        orientation: Qt.Horizontal
+        position: 100
+    }
+    ScrollBar2 {
+        id: horizontalScrollBar3
+        z:2;
+        width: parent.width-12;
+        windowHeight: parent.height
+        anchors.left: horizontalScrollBar2.left
+        anchors.leftMargin: horizontalScrollBar2.position
+        orientation: Qt.Horizontal
+        position: 100
+    }
+
+    ElementsListView{
+        id: dictList
+        width: rectangle1.width
+        anchors.top: parent.top
+        anchors.bottom: parent.bottom
+        highlightResizeSpeed: 1000
+
+        header: Component{
+            id: dictListHeader
+            Item {
+                width: rectangle1.width
+                height: 20
+                Row {
+                    anchors.fill: parent
+                    Rectangle {
+                        id: fromRecHeader
+                        width: horizontalScrollBar1.position
+                        height: parent.height
+                        radius: 1
+                        gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
+
+                        Text {
+                            id: fromTextHeader
+                            text: qsTr("From");
+                            elide: Text.ElideRight
+                            font.pixelSize: 12
+                            anchors.centerIn: parent
+                        }
+                    }
+                    Rectangle {
+                        id: toRecHeader
+                        width: horizontalScrollBar2.position
+                        height: parent.height
+                        radius: 1
+                        gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
+
+                        Text {
+                            id: toTextHeader
+                            text: qsTr("To");
+                            elide: Text.ElideRight
+                            font.pixelSize: 12
+                            anchors.centerIn: parent
+                        }
+                    }
+                    Rectangle {
+                        id: nameRecHeader
+                        width: horizontalScrollBar3.position
+                        height: parent.height
+                        radius: 1
+                        gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
+
+                        Text {
+                            id: nameTextHeader
+                            text: qsTr("Title");
+                            elide: Text.ElideRight
+                            font.pixelSize: 12
+                            anchors.centerIn: parent
+                        }
+                    }
+                    Rectangle {
+                        id: sizeRecHeader
+                        width: 100;
+                        height: parent.height
+                        radius: 1
+                        gradient: Gradient { GradientStop { position: 0.3; color: "#a0cbec" } GradientStop { position: 0.99; color: "#35a0f1" } }
+
+                        Text {
+                            id: sizeTextHeader
+                            text: qsTr("Size");
+                            elide: Text.ElideRight
+                            font.pixelSize: 12
+                            anchors.centerIn: parent
+                        }
+                    }
+                }
+            }
+        }
+
+        delegate: Component{
+            id: dictListDelegate
+            Item {
+                width: rectangle1.width
+                height:nameText.height
+                MouseArea{
+                    anchors.fill: parent
+                    onClicked: {
+                        dictList.currentIndex = index
+                    }
+                    onDoubleClicked: {
+                        rectangle1.dictLink(link)
+                    }
+                }
+                Row {
+                    anchors.fill: parent
+                    Text {
+                        id: fromText
+                        text: " "+from+" ";
+                        width:  horizontalScrollBar1.position
+                        elide: Text.ElideRight
+                    }
+
+                    Text {
+                        id: toText
+                        text: " "+to+" ";
+                        width:  horizontalScrollBar2.position
+                        elide: Text.ElideRight
+                    }
+
+                    Text {
+                        id: nameText
+                        text: " "+name+" ";
+                        width:  horizontalScrollBar3.position
+                        elide: Text.ElideRight
+                    }
+                    Text {
+                        id: sizeText
+                        text: " "+size+" ";
+                        width:  100
+                        elide: Text.ElideRight
+                    }
+                }
+            }
+        }
+        model: dictModel
+    }
+}
index f161c4d..c0a546a 100644 (file)
@@ -24,12 +24,14 @@ Rectangle {
     Item { id: headerSpace; width: parent.width; height: 1}
 
     ScrollBar {
-        scrollArea: webView; width: 8
+        scrollArea: webView;
+        width: 8
         anchors { right: parent.right; top: parent.bottom; bottom: parent.bottom }
     }
 
     ScrollBar {
-        scrollArea: webView; height: 8; orientation: Qt.Horizontal
+        scrollArea: webView;
+        height: 8; orientation: Qt.Horizontal
         anchors { right: parent.right; rightMargin: 8; left: parent.left; bottom: parent.bottom }
     }
 
index 6973147..074f880 100644 (file)
@@ -10,15 +10,12 @@ Rectangle {
     color : myPalette.window;
 
     function setValue(intiger){
-        console.log("ala value " +intiger);
         progressbar1.setValue(intiger);
     }
     function setText(string){
-        console.log("ala text " +string);
         text.text=string;
     }
     function setMaximumValue(intiger){
-        console.log("ala max " +intiger);
         if(intiger==0){
             timerUp.running=true;
             setValue(-1);
@@ -56,7 +53,6 @@ Rectangle {
         anchors.right: parent.right
         anchors.left: parent.left
         onClicked: {
-            console.log("click");
             rectangle1.cancelDownloading();
         }
     }
index bf50c17..c5e3d11 100644 (file)
@@ -72,6 +72,14 @@ public:
         _link = lreg.capturedTexts().at(1);
     }
 
+    DownloadDict(const DownloadDict &dict) {
+       _from = dict.fromLang();
+       _to = dict.toLang();
+       _title = dict.title();
+       _size = dict.size();
+       _link  = dict.link();
+    }
+
     //! \return dictionary source language
     QString fromLang() const {return _from;}
 
@@ -92,10 +100,14 @@ public:
         \return 1 if this is before other
     */
     bool operator <(DownloadDict other) const {
-        if(_from < other.fromLang()) return true;
-        if(_from > other.fromLang()) return false;
-        if(_to < other.toLang()) return true;
-        return false;
+        if(_from < other.fromLang())
+            return true;
+        else if(_from > other.fromLang())
+            return false;
+        else if(_to < other.toLang())
+            return true;
+        else
+            return false;
     }
 
 private:
index d1775da..706c949 100644 (file)
 #define XDXFDIALOG_H
 
 #include <QDialog>
-#include "../../include/settings.h"
 #include <QtGui>
 #include <QDeclarativeView>
 
 #include "xdxfplugin.h"
-
+#include "../../include/settings.h"
 
 /*!
     This class can create dialogs for adding a new dictionary or changing settings
index fdb7cdd..d1575e4 100644 (file)
 XdxfDictSelectDialog::XdxfDictSelectDialog(QList<DownloadDict> dicts,
                                            QWidget *parent) :
                     QDialog(parent) {
+
+
     setWindowTitle(tr("Select dictionary"));
 
+    //here removing already added dictionary
+    for (int i = 0; i < dicts.size(); i++){
+        if(QFile::exists(QDir::homePath() + "/.mdictionary/" + dicts[i].title() + ".xdxf")){
+            dicts.removeAt(i);
+            i--;
+        }
+    }
+
+#ifndef Q_WS_MAEMO_5
+    model2 = new DictsListModel(dicts, this);
+    proxyModel2 = new DictsProxyListModel;
+    proxyModel2->setSourceModel(model2);
+    proxyModel2->setTo("Polish");
+    view= new QDeclarativeView();
+    QDeclarativeContext* ctxt=view->rootContext();
+    ctxt->setContextProperty("dictModel", proxyModel2);
+    view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/TableWidget.qml"));
+    view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+    view->setAlignment(Qt::AlignCenter);
+
+    mainLayout = new QVBoxLayout;
+    mainLayout->addWidget(view);
+    this->setLayout(mainLayout);
+    proxyModel2->setTo("English");
+
+    QGraphicsObject *rootObject = view->rootObject();
+
+    connect(rootObject,SIGNAL(dictLink(QString)),
+            this,SLOT(itemClicked(QString)));
+#else
+
     layout = new QVBoxLayout;
     setLayout(layout);
 
@@ -53,15 +86,6 @@ XdxfDictSelectDialog::XdxfDictSelectDialog(QList<DownloadDict> dicts,
     checkBoxLayout->addWidget(langToLabel);
     checkBoxLayout->addWidget(langTo, 10);
 
-    //here removing already added dictionary
-
-    for (int i = 0; i < dicts.size(); i++){
-        if(QFile::exists(QDir::homePath() + "/.mdictionary/" + dicts[i].title() + ".xdxf")){
-            dicts.removeAt(i);
-            i--;
-        }
-    }
-
     model = new DictsModel(dicts, this);
 
     proxyModel = new DictsProxyModel;
@@ -108,6 +132,7 @@ XdxfDictSelectDialog::XdxfDictSelectDialog(QList<DownloadDict> dicts,
     #endif
 
     initializeDicts();
+    #endif
 }
 
 
@@ -149,6 +174,11 @@ void XdxfDictSelectDialog::initializeDicts() {
 
 
 void XdxfDictSelectDialog::refreshDictList() {
+#ifndef Q_WS_MAEMO_5
+
+
+#else
+
     //if selected language is "Any"(index 0), from filter string is set to empty string, proxy model uses empty string as special case and don't filter by this field.
     if(langTo->currentIndex() == 0)
         proxyModel->setTo(QString());
@@ -159,10 +189,21 @@ void XdxfDictSelectDialog::refreshDictList() {
         proxyModel->setFrom(QString());
     else
         proxyModel->setFrom(langFrom->currentText());
+
+#endif
 }
 
 
+void XdxfDictSelectDialog::itemClicked(QString link) {
+#ifndef Q_WS_MAEMO_5
+    _link = link;
+    accept();
+#endif
+}
+
 void XdxfDictSelectDialog::itemClicked(QModelIndex index) {
+#ifdef Q_WS_MAEMO_5
     _link = index.model()->data(index, Qt::UserRole).toString();
     accept();
+#endif
 }
index 7ac546d..cbf0d04 100644 (file)
 #include <QtGui>
 #include <QFile>
 #include <QDir>
+#include <QDeclarativeView>
+#include <QDeclarativeContext>
+
 #include "DownloadDict.h"
+#include "DictsListModel.h"
 #include "DictsModel.h"
 #include "DictsProxyModel.h"
+#include "DictsProxyListModel.h"
 
 
 /*!
@@ -70,7 +75,14 @@ private Q_SLOTS:
     //! accept dialog and sets download link of clicked dictionary
     void itemClicked(QModelIndex);
 
+    void itemClicked(QString link);
+
 private:
+    QVBoxLayout* mainLayout;
+    QDeclarativeView *view;
+    DictsListModel* model2;
+    DictsProxyListModel *proxyModel2;
+
     QTreeView* treeView;
     DictsModel* model;
     DictsProxyModel *proxyModel; //used by treeView to allow filtering and sorti
index 929060c..d285b44 100644 (file)
@@ -28,7 +28,8 @@ SOURCES += xdxfplugin.cpp \
     XdxfDictSelectDialog.cpp \
     XdxfDictDownloadProgressDialog.cpp \
     DictsModel.cpp \
-    HttpDownloader.cpp
+    HttpDownloader.cpp \
+    DictsListModel.cpp
 
 HEADERS += xdxfplugin.h \
     TranslationXdxf.h \
@@ -45,7 +46,9 @@ HEADERS += xdxfplugin.h \
     DownloadDict.h \
     DictsModel.h \
     DictsProxyModel.h \
-    HttpDownloader.h
+    HttpDownloader.h \
+    DictsListModel.h \
+    DictsProxyListModel.h
 
 RESOURCES += xdxf.qrc
 
@@ -53,7 +56,9 @@ TRANSLATIONS += pl_PL.ts \
                 en_US.ts
 
 OTHER_FILES += ../../mdictionary/qml/XdxfDialog.qml \
-    ../../mdictionary/qml/XdxfDictDownloader.qml
+    ../../mdictionary/qml/XdxfDictDownloader.qml \
+    ../../mdictionary/qml/TableWidget.qml \
+    ../../mdictionary/qml/ScrollBar2.qml
 
 unix {
     dicts.path = $$PLUGINS_DIR
@@ -74,6 +79,9 @@ unix {
         qmls.path = $$DATA_DIR/qml
         qmls.files += ../../mdictionary/qml/XdxfDialog.qml
         qmls.files += ../../mdictionary/qml/XdxfDictDownloader.qml
+        qmls.files += ../../mdictionary/qml/TableWidget.qml
+        qmls.files += ../../mdictionary/qml/ScrollBar2.qml
+
     }
 
     INSTALLS += dicts \
index 0642344..fa729df 100644 (file)
@@ -2,5 +2,6 @@
     <qresource prefix="/xdxf">
         <file>translations/pl_PL.qm</file>
         <file>translations/en_US.qm</file>
+        <file>scrollbar.png</file>
     </qresource>
 </RCC>