void selectedDictionaries(QList<CommonDictInterface* >);
void addToBookmarks(QList<Translation*>);
+
+ void bookmarkMode();
};
#endif // GUIINTERFACE_H
_innerBookmarks = QtConcurrent::run(_bookmarks,
&Bookmarks::list);
_bookmarkSearchWatcher.setFuture(_innerBookmarks);
+
+ Q_EMIT bookmarkMode();
+ qDebug()<<"1";
}
/*! Sets settings for backbone: history_size, search_limit,
void bookmarkReady();
+ void bookmarkMode();
+
private Q_SLOTS:
void bookmarksListReady();
int DictManagerModel::setDataPriv(int index, const QVariant &value, int role)
{
- if (index < 0 || index > _dictList.count())
+ if (index < 0 || index > _dictList.count() - 1)
return 0;
CommonDictInterface* dictionary = _dictList[index];
connect(backbone, SIGNAL(closeOk()),
this, SLOT(close()));
+ connect(backbone, SIGNAL(bookmarkMode()),
+ this, SIGNAL(bookmarkMode()));
+
//connect(wordListWidget, SIGNAL(addBookmark(QList<Translation*>)),
// this, SIGNAL(setBusy()));
connect(this, SIGNAL(setIdle()),
wordListWidget, SLOT(unlockList()));
+ connect(this, SIGNAL(bookmarkMode()),
+ wordListWidget, SLOT(bookmarkModeActive()));
+
connect(wordListWidget, SIGNAL(addBookmark(QList<Translation*>)),
backbone, SLOT(addBookmark(QList<Translation*>)));
roles[IsBookmarkedRole] = "isBookmarked";
roles[NumberRole] = "number";
setRoleNames(roles);
-
+ isBookmarkModeActive = false;
}
if (!empty){
endResetModel();
}
+ isBookmarkModeActive = false;
}
QVariant WordListModel::data(const QModelIndex &index, int role) const
int WordListModel::setDataPriv(int index, const QVariant &value, int role)
{
- bool bookmarksOnly = false;
- if (_wordInBookmarks.values().count(false) == 0){
- bookmarksOnly = true;
- }
-
- if (index < 0 || index > _translations.count())
+ if (index < 0 || index > _translations.count() - 1)
return 0;
QString word = _wordList[index];
if (value.type() == QVariant::Bool)
{
_wordInBookmarks[word] = value.toBool();
- Q_EMIT dataChanged(this->index(0), this->index(_translations.count() - 1));
if (_wordInBookmarks[word] == true){
Q_EMIT addToBookmarks(word);
} else {
Q_EMIT removeFromBookmarks(word);
- if (bookmarksOnly == true){
+ if (isBookmarkModeActive == true){
beginRemoveRows(QModelIndex(), index, index + 1);
this->_translations.remove(_wordList[index]);
this->_wordInBookmarks.remove(_wordList[index]);
endRemoveRows();
}
}
+ Q_EMIT dataChanged(this->index(0), this->index(_translations.count() - 1));
return 2;
}
else
}
return 0;
}
+
+void WordListModel::setBookmarkModeActive(bool mode)
+{
+ isBookmarkModeActive = mode;
+}
explicit WordListModel(QObject *parent = 0);
int rowCount(const QModelIndex & parent = QModelIndex()) const;
+ void setBookmarkModeActive(bool mode);
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
QHash<QString, bool > _wordInBookmarks;
QList<QString> _wordList;
+ bool isBookmarkModeActive;
+
};
#endif // WORDLISTMODEL_H
WordListWidget::WordListWidget(QWidget *parent):
QTreeView(parent) {
+ isBookmarkModeActive = false;
+
//creating new model to store words and stars
#ifdef Q_WS_MAEMO_5
model = new QStandardItemModel(this);
if (listModel == 0){
listModel = new WordListModel(this);
}
+
+ listModel->setBookmarkModeActive(isBookmarkModeActive);
+ isBookmarkModeActive = false;
listModel->setTranslations(result, wordsInBookmarks);
#endif
}
searchResult.clear();
}
+
+void WordListWidget::bookmarkModeActive(){
+ isBookmarkModeActive = true;
+}
//! clears list
void clear();
+ void bookmarkModeActive();
+
protected:
#ifdef Q_WS_MAEMO_5
//! Reimplemented standard mouseReleaseEvent to check if user clicked on
QHash<QString, QList<Translation*> > searchResult;
WordListProxyStyle* proxyStyle;
+ bool isBookmarkModeActive;
+
#ifndef Q_WS_MAEMO_5
QVBoxLayout* verticalLayout;
QDeclarativeView* qmlView;
}
- function setEnabled(Boolean) { wordList.enabled = Boolean } // slot
+ function setEnabled(Boolean) { wordList.enabled = Boolean }
signal wordSelected(string word);
-
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
id: rectangle1