--- /dev/null
+#include "DictTypeModel.h"
+
+DictTypeModel::DictTypeModel(QList<CommonDictInterface *> plugins, QObject *parent) :
+ QAbstractListModel(parent)
+{
+ QHash<int, QByteArray> roles;
+ roles[TypeRole] = "type";
+ 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();
+ return QVariant();
+}
+
+void DictTypeModel::addType(CommonDictInterface *plugin)
+{
+ beginInsertRows(QModelIndex(), rowCount(), rowCount());
+ _plugins << plugin;
+ endInsertRows();
+}
--- /dev/null
+#ifndef DICTTYPEMODEL_H
+#define DICTTYPEMODEL_H
+
+#include <QAbstractListModel>
+#include <QHash>
+#include "../../include/GUIInterface.h"
+
+class DictTypeModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum DictTypeRoles
+ {
+ TypeRole = Qt::UserRole + 1
+ };
+
+ 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:
+ QList<CommonDictInterface*> _plugins;
+
+ void addType(CommonDictInterface* plugin);
+};
+
+#endif // DICTTYPEMODEL_H
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/AboutWidget.qml \
qml/SearchBarWidget.qml \
qml/IconButton.qml \
- qml/MyTextLineEdit.qml
+ qml/MyTextLineEdit.qml \
+ qml/DictListDelegate.qml \
+ qml/DictTypeListDelegate.qml \
+ qml/WordListDelegate.qml \
+ qml/ElementsListView.qml \
+ qml/DictTypeListView.qml \
+ qml/DictTypeSelectDialog.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
}
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
+
+Text {
+ text: type
+}
--- /dev/null
+import Qt 4.7
+
+ElementsListView{
+ anchors.fill: parent
+ delegate: DictTypeListDelegate{}
+ model: dictTypeModel
+ focus: true
+}
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
+
+ id: rectangle1
+ //width: (helloText.width > logo.width) ? (helloText.width) : (logo.width)
+ //height: logo.height + helloText.height
+ color: myPalette.window
+ anchors.fill: parent
+
+ DictTypeListView{
+ id: dictTypeList
+
+ }
+
+// 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
+// }
+
+}
--- /dev/null
+import Qt 4.7
+
+ListView {
+ property int selectedElement: -1
+
+}
--- /dev/null
+import Qt 4.7
+
+Rectangle {
+ width: 100
+ height: 62
+}