File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,6 +93,29 @@ void convertVector(QVector<TYPE1>& dest, const QVector<TYPE2>& src)
9393 dest.append (type);
9494}
9595
96+ /* Functions for safe insert that allow and index < 0 and > size + 1 */
97+ template <typename TYPE >
98+ void insertInto (QList<TYPE >& list, int index, const TYPE & type)
99+ {
100+ if (index < 0 )
101+ list.prepend (type);
102+ else if (index > list.size ())
103+ list.append (type);
104+ else
105+ list.insert (index, type);
106+ }
107+
108+ template <typename TYPE >
109+ void insertInto (QVector<TYPE >& list, int index, const TYPE & type)
110+ {
111+ if (index < 0 )
112+ list.prepend (type);
113+ else if (index > list.size ())
114+ list.append (type);
115+ else
116+ list.insert (index, type);
117+ }
118+
96119/* Read whole file into a string */
97120QString strFromFile (const QString& filename);
98121
You can’t perform that action at this time.
0 commit comments