diff options
author | 2011-10-09 02:41:21 +0300 | |
---|---|---|
committer | 2011-10-09 02:41:21 +0300 | |
commit | 80effa9443f3310f4b668d99837b95c3c2feda78 (patch) | |
tree | ed3912d202d4e24116f25f9a13527982385c0088 | |
parent | Make cpp-portage a shared library, correctly identify which header (diff) | |
download | c-portage-80effa9443f3310f4b668d99837b95c3c2feda78.tar.gz c-portage-80effa9443f3310f4b668d99837b95c3c2feda78.tar.bz2 c-portage-80effa9443f3310f4b668d99837b95c3c2feda78.zip |
Add some helper function used mostly for convertions between datatypes
-rw-r--r-- | src/Qt/helper.cpp | 28 | ||||
-rw-r--r-- | src/Qt/helper.h | 5 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/Qt/helper.cpp b/src/Qt/helper.cpp new file mode 100644 index 0000000..93a00fe --- /dev/null +++ b/src/Qt/helper.cpp @@ -0,0 +1,28 @@ +#include "helper.h" +#include <stringlist.h> + +QStringList CListToQStringList(StringList *clist) +{ + QStringList list; + + for (int i=0; i<stringListCount(clist); i++) { + list << stringListGetAt(clist, i); + } + + return list; +} + +StringList* QStringListToCList(const QStringList &list) +{ + StringList *clist; + + clist = stringListCreate(list.count()); + + if (clist) { // Not null + for (int i=0; i<list.count(); i++) { + stringListInsertAt(clist, i, list.at(i).toUtf8().data()); + } + } + + return clist; +} diff --git a/src/Qt/helper.h b/src/Qt/helper.h new file mode 100644 index 0000000..b45c14a --- /dev/null +++ b/src/Qt/helper.h @@ -0,0 +1,5 @@ +#include <QStringList> +#include <stringlist.h> + +QStringList CListToQStringList(StringList *); +StringList* QStringListToCList(const QStringList&);
\ No newline at end of file |