]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiIdListModel.h
do what the FIXME suggested
[lyx.git] / src / frontends / qt4 / GuiIdListModel.h
index 48709762e9bee9055027c921f6491bebf28a0b69..1879968d2b14abf1c167e6468c50ea35fcf12740 100644 (file)
 #ifndef GUIIDLISTMODEL_H
 #define GUIIDLISTMODEL_H
 
+#include "support/qstring_helpers.h"
+
 #include <QAbstractListModel>
 #include <vector>
 #include <string>
 
-#include "support/qstring_helpers.h"
-
 namespace lyx {
 namespace frontend {
 
@@ -39,12 +39,14 @@ namespace frontend {
 class GuiIdListModel : public QAbstractListModel {
 public:
        ///
-       explicit GuiIdListModel();
+       GuiIdListModel() {}
        //////////////////////////////////////////////////////////////////////
        // Methods overridden from QAbstractListModel
        //////////////////////////////////////////////////////////////////////
        ///
-       inline int rowCount(QModelIndex const & parent = QModelIndex()) const;
+       int rowCount(QModelIndex const & = QModelIndex()) const
+               { return userData_.size(); }
+
        ///
        virtual QVariant data(QModelIndex const & index, 
                              int role = Qt::DisplayRole) const;
@@ -53,7 +55,7 @@ public:
        ///
        bool removeRows(int row, int count, QModelIndex const & parent = QModelIndex());
        /// 
-       void clear() { removeRows(0, rowCount()); };
+       void clear() { removeRows(0, rowCount()); }
        ///
        virtual bool setData (QModelIndex const & index, 
                        const QVariant & value, int role = Qt::EditRole );
@@ -63,46 +65,54 @@ public:
        // New methods
        //////////////////////////////////////////////////////////////////////
        ///
-       inline void setUIString(QModelIndex const & index, QString const & value)
-                       { setData(index, value); };
+       void setUIString(QModelIndex const & index, QString const & value)
+                       { setData(index, value); }
        ///
-       inline void setUIString(int const i, std::string const & value)
-                       {  setUIString(index(i), toqstr(value));  };
+       void setUIString(int const i, QString const & value)
+                       { setUIString(index(i), value); }
        ///
-       inline void setIDString(QModelIndex const & index, QString const & value)
-                       { setData(index, value, Qt::UserRole); };
+       void setIDString(QModelIndex const & index, QString const & value)
+                       { setData(index, value, Qt::UserRole); }
        ///
-       inline void setIDString(int const i, std::string const & value)
-                       { setIDString(index(i), toqstr(value)); };
+       void setIDString(int const i, std::string const & value)
+                       { setIDString(index(i), toqstr(value)); }
        ///
        virtual QString getIDString(QModelIndex const & index) const
-                       { return data(index, Qt::UserRole).toString(); };
+                       { return data(index, Qt::UserRole).toString(); }
        ///
        virtual std::string getIDString(int const i) const
-                       {  return fromqstr(getIDString(index(i))); };
+                       { return fromqstr(getIDString(index(i))); }
        ///
-       void insertRow(int const i, std::string const & uiString, 
+       void insertRow(int const i, QString const & uiString, 
                        std::string const & idString);
-       /* The following functions are currently unused but are retained here in
-          case they should at some point be useful.
+       /// \return the index of the (first) item with idString
+       /// \return -1 if not found
+       int findIDString(std::string const & idString);
+
+#if 0
+       //The following functions are currently unused but are retained here in
+       //case they should at some point be useful.
        ///
-       void setUIString(int const i, QString const & value)
-                       { setUIString(index(i), value); };
+       void setUIString(int const i, std::string const & value)
+                       { setUIString(index(i), value); }
        ///
        void setIDString(int const i, QString const & value)
-                       { setIDString(index(i), value); };
+                       { setIDString(index(i), value); }
        ///
        QStringList getIDStringList() const;
        ///
        void insertRow(int const i, QString const & uiString, 
                        QString const & idString);
-       /// Returns whether the model contains an item with the given ID
-       bool containsID(QVariant const &) const;
-       */
+       ///
+       void insertRow(int const i, std::string const & uiString, 
+                       std::string const & idString);
+#endif
 private:
        /// noncopyable
        GuiIdListModel(GuiIdListModel const &);
        ///
+       void operator=(GuiIdListModel const &);
+       ///
        struct OurData {
                QVariant uiString;
                QVariant idString;
@@ -110,18 +120,13 @@ private:
        ///
        std::vector<OurData> userData_;
        ///
-       inline bool rowIsValid(int const i) const
+       bool rowIsValid(int const i) const
        {
-               return (i >= 0 && (i <= userData_.size()));
+               return i >= 0 && i <= int(userData_.size());
        }
-;
 };
 
 
-//definition is here to silence a warning
-inline int GuiIdListModel::rowCount(QModelIndex const &) const
-               { return userData_.size(); }
-
 }
 }
 #endif //GUIIDLISTMODEL_H