fix bug with empty dictionary list. Add first version of WordListView (qml)
[mdictionary] / src / mdictionary / gui / DictManagerModel.cpp
index ecb93bd..f2aee34 100644 (file)
@@ -59,11 +59,18 @@ void DictManagerModel::setDictionaries(QHash<CommonDictInterface *, bool> dictio
 
 void DictManagerModel::clear()
 {
-    beginRemoveRows(QModelIndex(), 0, rowCount());
+    bool empty = true;
+    if (!_dictionaries.isEmpty()){
+//        beginRemoveRows(QModelIndex(), 0, rowCount());
+        beginResetModel();
+        empty = false;
+    }
     _dictionaries.clear();
     _dictList.clear();
-    endRemoveRows();
-    Q_EMIT dataChanged(QModelIndex(), QModelIndex());
+
+    if (!empty){
+        endResetModel();
+    }
 }
 
 QVariant DictManagerModel::data(const QModelIndex & index, int role) const
@@ -124,8 +131,6 @@ int DictManagerModel::setDataPriv(int index, const QVariant &value, int role)
         if (value.type() == QVariant::Bool)
         {
             _dictionaries[dictionary] = value.toBool();
-//            if (index == _dictList.count())
-//                emit dataChanged(this->index(index-1), this->index(index));
             Q_EMIT dataChanged(this->index(0), this->index(_dictList.count() - 1));
             return 2;
         }
@@ -164,7 +169,6 @@ bool DictManagerModel::isCurrentDictSelected()
 Qt::ItemFlags DictManagerModel::flags(const QModelIndex &index) const
 {
     Qt::ItemFlags fl = QAbstractItemModel::flags(index);
-    qDebug("lol1");
     return (fl | Qt::ItemIsEditable);
 }