--- /dev/null
+/*******************************************************************************
+
+ 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) :
+ QAbstractListModel(parent)
+{
+ QHash<int, QByteArray> roles;
+ roles[TypeRole] = "type";
+ roles[NumberRole] = "number";
+ setRoleNames(roles);
+
+ setDictTypes(plugins);
+}
+
+int DictTypeModel::rowCount(const QModelIndex &parent) const
+{
+ return _plugins.count();
+}
+
+void DictTypeModel::setDictTypes(QList<CommonDictInterface *> plugins)
+{
+ for(int i = 0; i < plugins.count(); i++)
+ {
+ addType(plugins[i]);
+ }
+}
+
+QVariant DictTypeModel::data(const QModelIndex & index, int role) const
+{
+ if (index.row() < 0 || index.row() > _plugins.count())
+ return QVariant();
+
+ const CommonDictInterface* plugin = _plugins[index.row()];
+ if (role == TypeRole)
+ return plugin->type();
+ if (role == NumberRole)
+ return index.row();
+ return QVariant();
+}
+
+void DictTypeModel::addType(CommonDictInterface *plugin)
+{
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ _plugins << plugin;
+ endInsertRows();
+}
--- /dev/null
+/*******************************************************************************
+
+ 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 <QAbstractListModel>
+#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,
+ NumberRole
+ };
+
+ //! Constructor
+ /*!
+ \param plugins list of plugin types
+ \param parent parent of this class.
+ */
+ explicit DictTypeModel(QList<CommonDictInterface*> plugins, QObject *parent = 0);
+
+ 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);
+};
+
+#endif // DICTTYPEMODEL_H
#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;
};
gui/TranslationView.cpp \
gui/DBusAdapter.cpp \
gui/NotifyManager.cpp \
- gui/SpinBox.cpp
+ gui/SpinBox.cpp \
+ gui/DictTypeModel.cpp
HEADERS += gui/MainWindow.h \
backbone/ConfigGenerator.h \
../include/DictDialog.h \
gui/DBusAdapter.h \
gui/NotifyManager.h \
- gui/SpinBox.h
+ gui/SpinBox.h \
+ gui/DictTypeModel.h
RESOURCES += ../../data/gui.qrc
qml/SearchBarWidget.qml \
qml/IconButton.qml \
qml/MyTextLineEdit.qml \
- qml/ProgressBar.qml
+ qml/ProgressBar.qml \
+ qml/ElementsListView.qml \
+ qml/DictTypeSelectDialog.qml \
+ qml/DictManagerWidget.qml \
+ qml/WordListWidget.qml
target.path = $$BIN_DIR
INSTALLS += target
qmls.files += ./qml/IconButton.qml
qmls.files += ./qml/MyTextLineEdit.qml
qmls.files += ./qml/ProgressBar.qml
+ qmls.files += ./qml/ElementsListView.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
+/*******************************************************************************
+
+ 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
+ color: myPalette.base
+ anchors.fill: parent
+
+ 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
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+
+ 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 {
+ 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
+}