#include "GuiIdListModel.h"
+#include "support/lassert.h"
+
using std::vector;
namespace lyx {
}
-bool GuiIdListModel::setData (QModelIndex const & index,
+bool GuiIdListModel::setData (QModelIndex const & index,
const QVariant & value, int role)
{
int const row = index.row();
dataChanged(index, index);
return true;
}
+ // If we assert here, it's because we're trying to set an
+ // unrecognized role.
+ LATTEST(false);
return false;
}
-bool GuiIdListModel::insertRows(int row, int count,
+bool GuiIdListModel::insertRows(int row, int count,
QModelIndex const & /*parent*/)
{
if (!rowIsValid(row))
return false;
vector<OurData>::iterator it = userData_.begin() + row;
- OurData const v;
beginInsertRows(QModelIndex(), row, row + count - 1);
- userData_.insert(it, count, v);
+ userData_.insert(it, count, OurData());
endInsertRows();
return true;
}
-bool GuiIdListModel::removeRows(int row, int count,
+bool GuiIdListModel::removeRows(int row, int count,
QModelIndex const & /*parent*/)
{
if (!rowIsValid(row) || row + count > int(userData_.size()) ||
return true;
vector<OurData>::iterator it = userData_.begin() + row;
beginRemoveRows(QModelIndex(), row, row + count - 1);
- userData_.erase(it, it + count);
+ userData_.erase(it, it + count);
endRemoveRows();
return true;
}
-void GuiIdListModel::insertRow(int const i, QString const & uiString,
+void GuiIdListModel::insertRow(int const i, QString const & uiString,
std::string const & idString)
{
insertRow(i, uiString, idString, uiString);
}
-void GuiIdListModel::insertRow(int const i, QString const & uiString,
+void GuiIdListModel::insertRow(int const i, QString const & uiString,
std::string const & idString, QString const & ttString)
{
insertRows(i, 1);
}
-int GuiIdListModel::findIDString(std::string const & idString)
+int GuiIdListModel::findIDString(std::string const & idString)
{
vector<OurData>::const_iterator it = userData_.begin();
vector<OurData>::const_iterator end = userData_.end();
return -1;
}
-
-#if 0
-// The following function is currently unused but is retained here in
-// case it should at some point be useful.
-QStringList GuiIdListModel::getIDStringList() const
-{
- QStringList qsl;
- vector<OurData>::const_iterator it = userData_.begin();
- vector<OurData>::const_iterator end = userData_.end();
- for (; it != end; ++it)
- qsl.append(it->idString.toString());
- return qsl;
-}
-#endif
} // namespace frontend
} // namespace lyx