diff options
author | 2011-10-10 10:41:25 +0300 | |
---|---|---|
committer | 2011-10-10 10:41:25 +0300 | |
commit | e739706c965d98dd30ab05b73f12ec367d27ac4c (patch) | |
tree | b7e9d65720d4951fe5f7ff45caf266bb882f55df | |
parent | Reorganise CMakeLists so that the proper header files are installed for the a... (diff) | |
download | c-portage-e739706c965d98dd30ab05b73f12ec367d27ac4c.tar.gz c-portage-e739706c965d98dd30ab05b73f12ec367d27ac4c.tar.bz2 c-portage-e739706c965d98dd30ab05b73f12ec367d27ac4c.zip |
init the terietor_interegation branch
-rw-r--r-- | src/Qt/qlistconverter.cpp | 45 | ||||
-rw-r--r-- | src/Qt/qlistconverter.h | 43 | ||||
-rw-r--r-- | src/Qt/qpackageproperties.cpp | 66 | ||||
-rw-r--r-- | src/Qt/qpackageproperties.h | 35 |
4 files changed, 189 insertions, 0 deletions
diff --git a/src/Qt/qlistconverter.cpp b/src/Qt/qlistconverter.cpp new file mode 100644 index 0000000..4f3855c --- /dev/null +++ b/src/Qt/qlistconverter.cpp @@ -0,0 +1,45 @@ +#include "qlistconverter.h" + +#include <QStringList> +#include <QString> + +namespace CppPortage{ + +QListConverter::QListConverter(StringList *stringList, QObject *parent) + :QObject(parent) +{ + m_stringlist = stringList; +} + +QListConverter::QListConverter(QStringList *stringList, QObject* parent) + : QObject(parent) +{ + m_qstringlist = stringList; +} + + + +QListConverter::~QListConverter() +{ +} + +StringList* QListConverter::QStringListToStringList() +{ + for (int i = 0; i <= m_qstringlist->size(); i++) { + char c = m_qstringlist->at(i).data()->toAscii(); + stringListInsertAt(m_stringlist, i, &c); + } + + return m_stringlist; +} + +QStringList QListConverter::StringListToQStringList() +{ + for (int i = 0; i <= m_stringlist->count(); i++) { + m_qstringlist->insert(i, stringListGetAt(m_stringlist, i)); + } + + return *m_qstringlist; +} + +}
\ No newline at end of file diff --git a/src/Qt/qlistconverter.h b/src/Qt/qlistconverter.h new file mode 100644 index 0000000..44090bd --- /dev/null +++ b/src/Qt/qlistconverter.h @@ -0,0 +1,43 @@ +#ifndef QLISTCONVERTER_H +#define QLISTCONVERTER_H + +#include "../stringlist.h" + +#include <QObject> + +struct StringList; + +class QString; +class QStringList; + +namespace CppPortage { + +class QListConverter : public QObject +{ + Q_OBJECT +public: + QListConverter(StringList *stringList, QObject *parent = 0); + QListConverter(QStringList *stringList, QObject* parent = 0); + virtual ~QListConverter(); + + /** + * Converts a StringList to a QStringList + **/ + QStringList StringListToQStringList(); + + /** + * Converts a QStringList to a StringList + **/ + StringList* QStringListToStringList(); + + /** + * This methed performs a check at the obj.If the object exists then it is dealloc. + * We need this method,because we don't want to check "manually" if the obj exists and + * if it exists to dealloc it with delete. + **/ +private: + StringList *m_stringlist; + QStringList *m_qstringlist; +}; +} +#endif
\ No newline at end of file diff --git a/src/Qt/qpackageproperties.cpp b/src/Qt/qpackageproperties.cpp new file mode 100644 index 0000000..f42b54d --- /dev/null +++ b/src/Qt/qpackageproperties.cpp @@ -0,0 +1,66 @@ +#include "qpackageproperties.h" +#include "qlistconverter.h" + +#include <QStringList> +#include <QString> + +namespace CppPortage{ + +QPackageProperties::QPackageProperties(QString slot, QStringList keywords, + QStringList flags, QStringList homepages, QObject *parent) + :QObject(parent) +{ + m_listConverter = new QListConverter(&flags, this); + StringList *FLAGS = m_listConverter->QStringListToStringList(); + m_listConverter->checkList(); + + m_listConverter = new QListConverter(&homepages, this); + StringList *HOMEPAGES = m_listConverter->QStringListToStringList(); + m_listConverter->checkList(); + + m_listConverter = new QListConverter(&keywords, this); + StringList *KEYWORDS = m_listConverter->QStringListToStringList(); + m_listConverter->checkList(); + + packagePropertiesCreate(slot.toAscii().data(), KEYWORDS, FLAGS, HOMEPAGES); +} + + +QPackageProperties::~QPackageProperties() +{ + PackageProperties *p; + void Free(PackageProperties *p); +} + +const QString QPackageProperties::Slot() +{ + m_listConverter->checkList(); + PackageProperties *p; + return packagePropertiesGetSlot(p); +} + +const QStringList QPackageProperties::Flags() +{ + m_listConverter->checkList(); + PackageProperties *p; + m_listConverter = new QListConverter(packagePropertiesGetFlags(p), this); + return m_listConverter->StringListToQStringList(); +} + +const QStringList QPackageProperties::Keywords() +{ + m_listConverter->checkList(); + PackageProperties *p; + m_listConverter = new QListConverter(packagePropertiesGetKeywords(p), this); + return m_listConverter->StringListToQStringList(); +} + +const QStringList QPackageProperties::Homepages() +{ + m_listConverter->checkList(); + PackageProperties *p; + m_listConverter = new QListConverter(packagePropertiesGetHomepages(p), this); + + return m_listConverter->StringListToQStringList(); +} +} diff --git a/src/Qt/qpackageproperties.h b/src/Qt/qpackageproperties.h new file mode 100644 index 0000000..31db033 --- /dev/null +++ b/src/Qt/qpackageproperties.h @@ -0,0 +1,35 @@ +#ifndef QPACKAGEPROPERTIES_H +#define QPACKAGEPROPERTIES_H + + +#include <QObject> +#include "../packageproperties.h" + + +class QString; +class QStringList; + +struct PackageProperties; +struct StringList; + +namespace CppPortage { + +class QListConverter; + +class QPackageProperties : public QObject +{ + Q_OBJECT +public: + QPackageProperties(QString slot, const QStringList keywords, const QStringList flags, + QStringList homepages,QObject *parent = 0); + virtual ~QPackageProperties(); + + const QString Slot(); + const QStringList Keywords(); + const QStringList Flags(); + const QStringList Homepages(); +private: + QListConverter *m_listConverter; +}; +} +#endif
\ No newline at end of file |