diff --git a/harbour-wordbook.pro.user b/harbour-wordbook.pro.user index ae31ae6..1b42f85 100644 --- a/harbour-wordbook.pro.user +++ b/harbour-wordbook.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 94214e2..b17b905 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -10,7 +10,7 @@ Page { contentHeight: parent.height SilicaListView { anchors.fill: parent - spacing: Theme.paddingLarge + spacing: Theme.paddingMedium model: DictModel { id: dict_model } @@ -53,14 +53,15 @@ Page { delegate: Column { width: page.width Label { - text: "This is a test with a longer text.jjjjj jjj jjjjjj jjj jjjjjjjj jjjj jjjjjjjjjj jjjjjj" + id: body + text: msg2usr color: Theme.primaryColor - font.family: Theme.fontFamilyHeading font.pixelSize: Theme.fontSizeLarge wrapMode: Text.WordWrap - maximumLineCount: 10 + //maximumLineCount: 3 anchors { - horizontalCenter: parent.horizontalCenter + left: parent.left + right: parent.right leftMargin: Theme.paddingMedium rightMargin: Theme.paddingMedium } diff --git a/src/dict_model.cpp b/src/dict_model.cpp index d55ac50..9eeccfb 100644 --- a/src/dict_model.cpp +++ b/src/dict_model.cpp @@ -34,8 +34,9 @@ DictModel::DictModel(QObject *parent) : QAbstractListModel(parent) { d_msg = ""; - // Create dictionary + // Create dictionary. d_wordbook = dictcc::creator::create("DESV"); + // Initialise with shared pointer to empty lists, so it actually holds data. d_result = d_wordbook->get_translations(); } @@ -96,9 +97,16 @@ void DictModel::search(QString word) // Perform search try { d_result = d_wordbook->search(word.toStdString()); + d_msg = nullptr; } catch (const dictcc::dict_exception& e) { d_result = d_wordbook->reset_search(); d_msg = e.what(); } endResetModel(); } + +void DictModel::change_language(QString lang) +{ + d_wordbook.reset(); + d_wordbook = dictcc::creator::create(lang.toStdString()); +} diff --git a/src/dict_model.h b/src/dict_model.h index fdf2fde..00a15e9 100644 --- a/src/dict_model.h +++ b/src/dict_model.h @@ -53,6 +53,7 @@ public: //Q_INVOKABLE void activate(const int i); Q_INVOKABLE void search(QString word); + Q_INVOKABLE void change_language(QString lang); private: std::shared_ptr d_wordbook = nullptr;