return ;
}
QSqlQuery cur(db);
- cur.prepare("delete from bookmarks where key=? and translation=?");
- cur.addBindValue(translation->key());
+ cur.prepare("delete from bookmarks where key=?");
cur.addBindValue(translation->key());
cur.exec();
db.close();
QSqlDatabase db =QSqlDatabase::addDatabase("QSQLITE",
QString((int)QThread::currentThreadId()));
db.setDatabaseName(dbName);
+ qDebug()<<dbName;
if(!db.isOpen() && !db.open()) {
qDebug() << "Database error: " << db.lastError().text() << endl;
return tr;
bookmarkFin = 1;
QList<Translation*> list = _innerBookmarks.result();
qDebug() << "translation bookmarks" << list.size();
+
foreach(Translation* trans, list)
_result.insert(trans->key().toLower(), trans);
}
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);
addWord(i.key(), row++);
}
- qDebug()<<width();
setColumnWidth(0, width()-checkBoxWidth - 20);
setColumnWidth(1, checkBoxWidth);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QModelIndex index = indexAt(event->pos());
+ if(!index.isValid()) return;
int c = index.column();
if(c==0)
wordClicked(index);