+/*******************************************************************************
+
+ 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) :
{
QHash<int, QByteArray> roles;
roles[TypeRole] = "type";
+ roles[NumberRole] = "number";
setRoleNames(roles);
setDictTypes(plugins);
const CommonDictInterface* plugin = _plugins[index.row()];
if (role == TypeRole)
return plugin->type();
+ if (role == NumberRole)
+ return index.row();
return QVariant();
}
+/*******************************************************************************
+
+ 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);
#include "DictTypeSelectDialog.h"
DictTypeSelectDialog::DictTypeSelectDialog(QList<CommonDictInterface *> plugins, QWidget *parent) :
- QDialog(parent) {
+ QDialog(parent), model(plugins, this) {
setWindowTitle(tr("Select dictionary type"));
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);
connect(pluginsListWidget, SIGNAL(itemActivated(QListWidgetItem*)),
this, SLOT(pluginSelected(QListWidgetItem*)));
+#endif
}
void DictTypeSelectDialog::pluginSelected(QListWidgetItem *item) {
accept();
}
+void DictTypeSelectDialog::pluginSelected(int item) {
+ _selectedPlugin = plugins[item];
+ accept();
+}
+
CommonDictInterface* DictTypeSelectDialog::selectedPlugin() {
return _selectedPlugin;
}
#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
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
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);
#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
QLabel* mainLabel, * licenseLabel, *imageLabel;
QDeclarativeView* qmlView;
- QDeclarativeEngine* engine;
- QDeclarativeContext* context;
+// QDeclarativeEngine* engine;
+// QDeclarativeContext* context;
QWidget* widget;
};
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
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
+++ /dev/null
-import Qt 4.7
-
-Rectangle {
- width: 100
- height: 62
-}
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ width: 100
+ height: 62
+}
+++ /dev/null
-import Qt 4.7
-
-Text {
- text: type
-}
+++ /dev/null
-import Qt 4.7
-
-ElementsListView{
- anchors.fill: parent
- delegate: DictTypeListDelegate{}
- model: dictTypeModel
- focus: true
-}
+/*******************************************************************************
+
+ 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
-// }
-
}
+/*******************************************************************************
+
+ 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
}
+++ /dev/null
-import Qt 4.7
-
-Rectangle {
- width: 100
- height: 62
-}
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ width: 100
+ height: 62
+}