Fixed removing from bookmarks database
[mdictionary] / trunk / src / base / gui / WordListWidget.cpp
index 360d423..fed3397 100644 (file)
@@ -57,7 +57,20 @@ void WordListWidget::addWord(QString word, int row) {
     QStandardItem* itemCheckBox = new QStandardItem();
     itemCheckBox->setFlags(itemCheckBox->flags() ^ Qt::ItemIsEditable |
                            Qt::ItemIsUserCheckable);
-    itemCheckBox->setCheckState(Qt::Checked);
+
+    bool bookmark = false;
+    Translation* t;
+    foreach(t, searchResult[word]) {
+        if(t->isBookmark()) {
+            bookmark = true;
+            break;
+        }
+    }
+
+    if(bookmark)
+        itemCheckBox->setCheckState(Qt::Checked);
+    else
+        itemCheckBox->setCheckState(Qt::Unchecked);
 
     model->setItem(row,0, item);
     model->setItem(row,1, itemCheckBox);
@@ -79,7 +92,6 @@ void WordListWidget::showSearchResults(
            addWord(i.key(), row++);
     }
 
-    qDebug()<<width();
     setColumnWidth(0, width()-checkBoxWidth - 20);
     setColumnWidth(1, checkBoxWidth);
     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -112,6 +124,7 @@ void WordListWidget::mouseReleaseEvent(QMouseEvent *event) {
 
 
     QModelIndex index = indexAt(event->pos());
+    if(!index.isValid()) return;
     int c = index.column();
     if(c==0)
         wordClicked(index);