}
+void DictManagerModel::setModelProperty(int index, QString role)
+{
+ if (role.contains("isSelected"))
+ {
+ if (index < 0 || index > _dictionaries.count() - 1)
+ return;
+
+ setDataPriv(index, !_dictionaries[_dictList[index]], IsSelectedRole);
+ }
+
+}
+
void DictManagerModel::itemSelected(int index)
{
_currentIndex = index;
\param role role name
*/
void setModelProperty(int index, const QVariant value, QString role);
+
+ //! Reverse value at role in index row of data.
+ /*!
+ \param index dictionary position in data list
+ \param role role name
+ */
+ void setModelProperty(int index, QString role);
+
//! Set index of current selected dictionary
/*!
\param index dictionary position in data list
connect(rootObject, SIGNAL(itemActivated(int)),
this, SLOT(settingsButtonClicked()));
+ connect(this, SIGNAL(setFocusOnQML()), rootObject, SLOT(setFocus()));
+
#endif
#ifdef Q_WS_MAEMO_5
model->clear();
model->setDictionaries(dicts);
}
+ setFocusOnElement();
#endif
void DictManagerWidget::addNewDictButtonClicked() {
#ifndef Q_WS_MAEMO_5
- qDebug()<<"1 "<<_changed;
if(!_changed || QMessageBox::question(this,
tr("Save"), tr("Do you want to save changes?"),
QMessageBox::Save, QMessageBox::Cancel) == QMessageBox::Save) {
- qDebug()<<"2";
_save = true;
saveChanges();
_save = false;
#ifndef Q_WS_MAEMO_5
- void DictManagerWidget::save() {
- _save = true;
- hide();
- }
+void DictManagerWidget::save() {
+ _save = true;
+ hide();
+}
+
+void DictManagerWidget::setFocusOnElement(){
+ Q_EMIT setFocusOnQML();
+}
#endif
*/
void removeDictionary(CommonDictInterface*);
+#ifndef Q_WS_MAEMO_5
+ //! emits when dict manager gain focus
+ void setFocusOnQML();
+#endif
+
public Q_SLOTS:
#ifndef Q_WS_MAEMO_5
void save();
+ void setFocusOnElement();
#endif
private Q_SLOTS:
this, SLOT(pluginSelected(int)));
qmlView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+// qmlView->setFocus();
verticalLayout->addWidget(qmlView);
#endif
}
}
+void WordListModel::setModelPropertyByIndex(int index, QString role)
+{
+ if (role.contains("isBookmarked"))
+ {
+ if (index < 0 || index > _translations.count() - 1)
+ return;
+
+ setDataPriv(index, !_wordInBookmarks[_wordList[index]], IsBookmarkedRole);
+ }
+}
+
int WordListModel::setDataPriv(int index, const QVariant &value, int role)
{
if (index < 0 || index > _translations.count() - 1)
{
_isBookmarkModeActive = mode;
}
+
+QString WordListModel::wordOnPosition(int index)
+{
+ return _wordList[index];
+}
//! Clear model data and refresh UI
void clear();
+ QString wordOnPosition(int index);
+
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
signals:
*/
void setModelProperty(int index, const QVariant value, QString role);
+ //! Reverse value at role in index row of data.
+ /*!
+ \param index word position in data list
+ \param role role name
+ */
+ void setModelPropertyByIndex(int index, QString role);
+
private:
int setDataPriv(int index, const QVariant &value, int role);
void addWord(QString word, QList<Translation*> translations, bool isBookmarked);
verticalLayout->addWidget(qmlView);
connect(rootObject, SIGNAL(wordSelected(QString)), this, SLOT(wordClicked(QString)));
+ connect(rootObject, SIGNAL(wordSelectedByIndex(int)), this, SLOT(wordClickedByIndex(int)));
connect(listModel, SIGNAL(addToBookmarks(QString)), this, SLOT(addToBookmarks(QString)));
connect(listModel, SIGNAL(removeFromBookmarks(QString)), this, SLOT(removeFromBookmarks(QString)));
WordListWidget::~WordListWidget() {
+#ifdef Q_WS_MAEMO_5
if(proxyStyle)
delete proxyStyle;
-}
-
-void WordListWidget::setFocusOnElement(){
- setFocus();
- qmlView->setFocus();
- Q_EMIT setFocusOnQML();
- qDebug()<<hasFocus()<<" "<<qmlView->hasFocus();
+#endif
}
void WordListWidget::addWord(QString word, int row) {
}
}
}
-#else
- void WordListWidget::wordClicked(QString word){
- emit showTranslation(searchResult[word]);
- }
-
- void WordListWidget::addToBookmarks(QString word){
- emit addBookmark(searchResult[word]);
- }
-
- void WordListWidget::removeFromBookmarks(QString word){
- emit removeBookmark(searchResult[word]);
- }
-
-#endif
-
-#ifdef Q_WS_MAEMO_5
void WordListWidget::mouseReleaseEvent(QMouseEvent *event) {
//firstly we normally handle this event
wordClicked(selectedIndexes().at(0));
}
}
+#else
+ void WordListWidget::wordClicked(QString word){
+ emit showTranslation(searchResult[word]);
+ }
+
+ void WordListWidget::addToBookmarks(QString word){
+ emit addBookmark(searchResult[word]);
+ }
+
+ void WordListWidget::removeFromBookmarks(QString word){
+ emit removeBookmark(searchResult[word]);
+ }
+
+ void WordListWidget::wordClickedByIndex(int index){
+ emit showTranslation(searchResult[listModel->wordOnPosition(index)]);
+ }
+
+ void WordListWidget::setFocusOnElement(){
+ setFocus();
+ qmlView->setFocus();
+ Q_EMIT setFocusOnQML();
+ }
+
#endif
void WordListWidget::resizeColumns() {
void setWordListState(QVariant state);
void setWordListEmpty(QVariant state);
+
+#ifndef Q_WS_MAEMO_5
void setFocusOnQML();
+#endif
public Q_SLOTS:
void bookmarkModeActive();
+#ifndef Q_WS_MAEMO_5
void setFocusOnElement();
+#endif
protected:
#ifdef Q_WS_MAEMO_5
//! Signal is emitted only when a star was clicked.
void wordChecked(QModelIndex index);
#else
+ //! Emits signal to show translation of clicked item. Signal is emitted
+ //! only when a word was clicked.
void wordClicked(QString word);
+
+ //! Emits signal to show translation of clicked item. Signal is emitted
+ //! only when a word was clicked.
+ void wordClickedByIndex(int index);
+
+ //! Emits signal to show add word from bookmarks.
+ //! Signal is emitted only when a star was clicked.
void addToBookmarks(QString word);
+
+ //! Emits signal to show remove word from bookmarks.
+ //! Signal is emitted only when a star was clicked.
void removeFromBookmarks(QString word);
#endif
rectangle1.setEnableSettings(true)
}
+ function setFocus() {
+ dictList.setFocus()
+ }
+
signal addButtonClicked;
signal removeButtonClicked;
signal settingsButtonClicked;
anchors.bottom: buttonsBox.top
anchors.bottomMargin: buttonsBox.height + buttonsBox.anchors.topMargin
highlightResizeSpeed: 1000
+
+ Keys.onPressed: {
+ if ((event.key == Qt.Key_Return || event.key == Qt.Key_Enter) && currentIndex >= 0){
+ itemActivated(currentIndex)
+ }
+ if ((event.key == Qt.Key_Delete) && currentIndex >= 0){
+ removeButtonClicked()
+ }
+ if (event.key == Qt.Key_S && event.modifiers == Qt.ControlModifier){
+ saveButtonClicked()
+ }
+ if (event.key == Qt.Key_T && event.modifiers == Qt.ControlModifier){
+ addButtonClicked()
+ }
+ if ((event.key == Qt.Key_Space) && currentIndex >= 0){
+ dictModel.setModelProperty(dictList.currentIndex, "isSelected")
+ }
+ }
+
+ onCurrentIndexChanged: {
+ dictModel.itemSelected(dictList.currentIndex)
+ }
+
delegate: Component{
id: dictListDelegate
Item {
dictList.currentIndex = number
rectangle1.setEnableRemove(true)
rectangle1.setEnableSettings(true)
- dictModel.itemSelected(dictList.currentIndex)
}
onDoubleClicked: {
rectangle1.itemActivated(dictList.currentIndex)
Rectangle {
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
signal selectedRow(int nr)
+ function setFocus() {
+ dictTypeList.setFocus()
+ }
id: rectangle1
color: myPalette.base
anchors.fill: parent
ElementsListView{
+ Keys.onPressed: {
+ if ((event.key == Qt.Key_Return || event.key == Qt.Key_Enter) && currentIndex >= 0){
+ selectedRow(currentIndex)
+ }
+ }
+
id: dictTypeList
width: rectangle1.width
height: rectangle1.height
highlightMoveSpeed: 1000
function setFocus() {
- console.log("juhu2")
forceActiveFocus()
-// console.log(focus + " " + activeFocus)
- }
-
- Keys.onPressed: {
- console.log("woooo")
- if (event.key == Qt.Key_Up && currentIndex < count){
- currentIndex = currentIndex + 1
- console.log("woooo222 " + currentIndex)
- } else if (event.key == Qt.Key_Down && currentIndex > 0){
- currentIndex = currentIndex - 1
- console.log("woooo333 " + currentIndex)
- }
}
}
Rectangle {
function changeWordState(nr, state) {
- console.log("LOOOOOL")
wordList.currentIndex = nr
wordModel.setModelProperty(wordList.currentIndex, state, "isBookmarked")
+ }
+ function changeWordStateByIndex() {
+ wordModel.setModelPropertyByIndex(wordList.currentIndex, "isBookmarked")
}
function setEnabled(Boolean) { wordList.enabled = Boolean }
function setWordListEmpty(Boolean) { wordList.empty = Boolean }
function setFocus() {
- console.log("juhu")
wordList.setFocus()
-// activeFocus = true
- console.log(focus + "a " + activeFocus)
- console.log(wordList.focus + "b " + wordList.activeFocus)
}
signal wordSelected(string word);
+ signal wordSelectedByIndex(int nr);
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
highlightResizeSpeed: 1000
property bool empty: false
- onCurrentIndexChanged: {
- console.log("111!!!WTF " + currentIndex)
+ Keys.onPressed: {
+ if (event.key == Qt.Key_Space && currentIndex >= 0){
+ rectangle1.changeWordStateByIndex();
+ } else if ((event.key == Qt.Key_Return || event.key == Qt.Key_Enter) && currentIndex >= 0){
+ rectangle1.wordSelectedByIndex(currentIndex)
+ }
}
delegate: Component{
MouseArea{
anchors.fill: parent
onClicked: {
- wordList.currentIndex = index// number
+ wordList.currentIndex = index
rectangle1.wordSelected(word)
}
}