diff options
-rw-r--r-- | src/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/Qt/CMakeLists.txt | 12 | ||||
-rw-r--r-- | src/Qt/README | 3 | ||||
-rw-r--r-- | src/Qt/TODO | 2 | ||||
-rw-r--r-- | src/Qt/qlistconverter.cpp | 40 | ||||
-rw-r--r-- | src/Qt/qlistconverter.h | 30 | ||||
-rw-r--r-- | src/Qt/qpackageproperties.cpp | 52 | ||||
-rw-r--r-- | src/Qt/qpackageproperties.h | 32 | ||||
-rw-r--r-- | src/Qt/qportagesettings.cpp | 89 | ||||
-rw-r--r-- | src/Qt/qportagesettings.h | 43 | ||||
-rw-r--r-- | src/Qt/tests/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/Qt/tests/qlistconverter_test.cpp | 16 | ||||
-rw-r--r-- | src/Qt/tests/qpackageproperties_test.cpp | 27 | ||||
-rw-r--r-- | src/Qt/tests/qportagesettings_test.cpp | 34 | ||||
-rw-r--r-- | src/Qt/tests/test.cpp | 10 |
15 files changed, 336 insertions, 65 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 637e697..3fb5b8b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,8 +8,9 @@ set(c-portage_SRCS dataconnect.c dict.c flag.c interpreter.c packageproperties.c set(c-portage_HDRS dataconnect.h dict.h flag.h internal.h interpreter.h packageproperties.h stringlist.h) add_library(c-portage SHARED ${c-portage_SRCS}) +target_link_libraries(c-portage ${PYTHON_LIBRARY}) add_executable(tester tester.c) -target_link_libraries(tester c-portage ${PYTHON_LIBRARY}) +target_link_libraries(tester c-portage) install(TARGETS c-portage DESTINATION lib) install(FILES ${c-portage_HDRS} DESTINATION include/c-portage) @@ -18,4 +19,4 @@ option(CppPortage "Enable c++ wrapper for c-portage (uses Qt4)") if (CppPortage) add_subdirectory(Qt) -endif(CppPortage)
\ No newline at end of file +endif(CppPortage) diff --git a/src/Qt/CMakeLists.txt b/src/Qt/CMakeLists.txt index 8388c30..d673e61 100644 --- a/src/Qt/CMakeLists.txt +++ b/src/Qt/CMakeLists.txt @@ -2,11 +2,15 @@ find_package(Qt4 REQUIRED) include_directories(${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ..) remove_definitions(-std=c99) -set(cpp-portage_SRCS qportage.cpp qportagesettings.cpp helper.cpp) -set(cpp-portage_HDRS qportage.h qportagesettings.h helper.h) +set(cpp-portage_SRCS helper.cpp qportage.cpp qportagesettings.cpp qpackageproperties.cpp qlistconverter.cpp) +set(cpp-portage_HDRS helper.h qportage.h qportagesettings.h qpackageproperties.h qlistconverter.h) QT4_WRAP_CPP(cpp-portage_MOC_SRCS ${cpp-portage_HDRS}) -add_library(cpp-portage SHARED ${cpp-portage_SRCS} ${cpp-portage_MOC_SRCS}) +add_library(cpp-portage SHARED qportagesettings.cpp ${cpp-portage_MOC_SRCS}) +target_link_libraries(cpp-portage c-portage ${QT_QTCORE_LIBRARY}) + install(TARGETS cpp-portage DESTINATION lib) -install(FILES ${cpp-portage_HDRS} DESTINATION include/cpp-portage)
\ No newline at end of file +install(FILES ${cpp-portage_HDRS} DESTINATION include/cpp-portage) + +add_subdirectory(tests) diff --git a/src/Qt/README b/src/Qt/README new file mode 100644 index 0000000..3059917 --- /dev/null +++ b/src/Qt/README @@ -0,0 +1,3 @@ +Don't use this branch.It is only an interegation branch. +The code is very unstable.I created this branch in order to +avoid breaking the cmake_port branch. diff --git a/src/Qt/TODO b/src/Qt/TODO new file mode 100644 index 0000000..d11d08e --- /dev/null +++ b/src/Qt/TODO @@ -0,0 +1,2 @@ +I need some help with the CMakeLists.txt which is located at +c-portage/src/Qt/tests,in order to create some test files diff --git a/src/Qt/qlistconverter.cpp b/src/Qt/qlistconverter.cpp new file mode 100644 index 0000000..4ce0845 --- /dev/null +++ b/src/Qt/qlistconverter.cpp @@ -0,0 +1,40 @@ +#include "qlistconverter.h" + +#include <QStringList> +#include <QString> + +struct StringList +{ + char **list; + unsigned int count; +}; + +namespace CppPortage{ + +QListConverter::QListConverter(QObject *parent) + :QObject(parent) +{} + +StringList* QListConverter::QStringListToStringList(QStringList qstringList) +{ + StringList *stringList = stringListCreate(qstringList.size());//create a new StringList + + for (int i = 0; i <= qstringList.size(); i++) { + char c = *(qstringList.at(i).toUtf8().data()); + stringListInsertAt(stringList, i, &c); + } + + return stringList; +} + +QStringList QListConverter::StringListToQStringList(StringList *stringList) +{ + QStringList qstringList; + + for (int i = 0; i <= stringList->count; i++) { + qstringList.insert(i, stringListGetAt(stringList, i)); + } + + return qstringList; +} +}//end namespace
\ No newline at end of file diff --git a/src/Qt/qlistconverter.h b/src/Qt/qlistconverter.h new file mode 100644 index 0000000..83f73fc --- /dev/null +++ b/src/Qt/qlistconverter.h @@ -0,0 +1,30 @@ +#ifndef QLISTCONVERTER_H +#define QLISTCONVERTER_H + +#include "../stringlist.h" + +#include <QObject> + +class QString; +class QStringList; + +namespace CppPortage { + +class QListConverter : public QObject +{ + Q_OBJECT +public: + QListConverter(QObject *parent = 0); + + /** + * Converts a StringList to a QStringList + **/ + static QStringList StringListToQStringList(StringList *stringList); + + /** + * Converts a QStringList to a StringList + **/ + static StringList* QStringListToStringList(QStringList 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..8302122 --- /dev/null +++ b/src/Qt/qpackageproperties.cpp @@ -0,0 +1,52 @@ +#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) +{ + StringList *FLAGS = QListConverter::QStringListToStringList(flags); + + StringList *HOMEPAGES = QListConverter::QStringListToStringList(homepages); + + StringList *KEYWORDS = QListConverter::QStringListToStringList(keywords); + + packagePropertiesCreate(slot.toUtf8().data(), KEYWORDS, FLAGS, HOMEPAGES); +} + + +QPackageProperties::~QPackageProperties() +{ + PackageProperties *p; + void Free(PackageProperties *p); +} + +const QString QPackageProperties::Slot() +{ + PackageProperties *p; + return packagePropertiesGetSlot(p); +} + +const QStringList QPackageProperties::Flags() +{ + PackageProperties *p; + return QListConverter::StringListToQStringList(packagePropertiesGetFlags(p)); +} + +const QStringList QPackageProperties::Keywords() +{ + PackageProperties *p; + return QListConverter::StringListToQStringList(packagePropertiesGetKeywords(p)); +} + +const QStringList QPackageProperties::Homepages() +{ + PackageProperties *p; + return QListConverter::StringListToQStringList(packagePropertiesGetHomepages(p)); +} +} diff --git a/src/Qt/qpackageproperties.h b/src/Qt/qpackageproperties.h new file mode 100644 index 0000000..fcda875 --- /dev/null +++ b/src/Qt/qpackageproperties.h @@ -0,0 +1,32 @@ +#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(); +}; +} +#endif
\ No newline at end of file diff --git a/src/Qt/qportagesettings.cpp b/src/Qt/qportagesettings.cpp index f69af6c..21dc7b2 100644 --- a/src/Qt/qportagesettings.cpp +++ b/src/Qt/qportagesettings.cpp @@ -5,77 +5,94 @@ namespace CppPortage{ -PortageSettings::PortageSettings(QObject *parent) +QPortageSettings::QPortageSettings(QObject *parent) :QObject(parent) { - } - -PortageSettings::~PortageSettings() +QPortageSettings::~QPortageSettings() { - + PortageSettings *ps; + portageSettingsFree(ps); } -int PortageSettings::ResetUseFlags() +const int QPortageSettings::resetUseFlags() { - + PortageSettings *ps; + return portageSettingsResetUseFlags(ps); } -int PortageSettings::Reset() -{ -} -int PortageSettings::ReloadConfig() +const int QPortageSettings::reset() { - + PortageSettings *ps; + return portageSettingsResetUseFlags(ps); } -int PortageSettings::ReloadWorld() -{ -} -QStringList PortageSettings::GetWorld() +const int QPortageSettings::reloadConfig() { - + PortageSettings *ps; + return portageSettingsReloadConfig(ps); } -QStringList PortageSettings::GetArchList() -{ -} -QStringList PortageSettings::GetVirtuals() +const int QPortageSettings::reloadWorld() { - + PortageSettings *ps; + return portageSettingsReloadWorld(ps); } - -const QString PortageSettings::AcceptKeywords() +const QStringList QPortageSettings::world() { - + PortageSettings *ps; + return QListConverter::StringListToQStringList(portageSettingsGetWorld(ps)); } -const QStringList PortageSettings::SystemUseFlags() -{ -} -const QString PortageSettings::Arch() +const QStringList QPortageSettings::archList() { + PortageSettings *ps; + return QListConverter::StringListToQStringList(portageSettingsGetArchList(ps)); } -const QString PortageSettings::Portdir() -{ -} -const QString PortageSettings::PortdirOverlay() +const QStringList QPortageSettings::virtuals() { + PortageSettings *ps; + return QListConverter::StringListToQStringList(portageSettingsGetVirtuals(ps)); +} +const QString QPortageSettings::acceptKeywords() +{ + PortageSettings *ps; + return portageSettingsAcceptKeywords(ps); } -const QString PortageSettings::UserConfigDir() + +const QStringList QPortageSettings::systemUseFlags() { + PortageSettings *ps; + return QListConverter::StringListToQStringList(portageSettingsSystemUseFlags(ps)); +} +const QString QPortageSettings::arch() +{ + PortageSettings *ps; + return portageSettingsArch(ps); } +const QString QPortageSettings::portdir() +{ + PortageSettings *ps; + return portageSettingsPortdir(ps); +} -void PortageSettings::Free() +const QString QPortageSettings::portdirOverlay() { + PortageSettings *ps; + return portageSettingsPortdirOverlay(ps); +} +const QString QPortageSettings::userConfigDir() +{ + PortageSettings *ps; + return portageSettingsUserConfigDir(ps); } -}
\ No newline at end of file +}//end namespace diff --git a/src/Qt/qportagesettings.h b/src/Qt/qportagesettings.h index e72af42..652020c 100644 --- a/src/Qt/qportagesettings.h +++ b/src/Qt/qportagesettings.h @@ -4,38 +4,35 @@ #include <QObject> #include "../portagesettings.h" +#include "qlistconverter.h" class QString; class QStringList; +struct PortageSettings; + namespace CppPortage { -class PortageSettings : public QObject +class QPortageSettings : public QObject { Q_OBJECT public: - PortageSettings(QObject *parent = 0); - virtual ~PortageSettings(); - - -int ResetUseFlags(); -int Reset(); -int ReloadConfig(); -int ReloadWorld(); -QStringList GetWorld(); -QStringList GetArchList(); -QStringList GetVirtuals(); - - -const QString AcceptKeywords(); -const QStringList SystemUseFlags(); -const QString Arch(); -const QString Portdir(); -const QString PortdirOverlay(); -const QString UserConfigDir(); - - -void Free(); + QPortageSettings(QObject *parent = 0); + virtual ~QPortageSettings(); + + const int resetUseFlags(); + const int reset(); + const int reloadConfig(); + const int reloadWorld(); + const QStringList world(); + const QStringList archList(); + const QStringList virtuals(); + const QString acceptKeywords(); + const QStringList systemUseFlags(); + const QString arch(); + const QString portdir(); + const QString portdirOverlay(); + const QString userConfigDir(); }; } #endif
\ No newline at end of file diff --git a/src/Qt/tests/CMakeLists.txt b/src/Qt/tests/CMakeLists.txt new file mode 100644 index 0000000..a2b1e28 --- /dev/null +++ b/src/Qt/tests/CMakeLists.txt @@ -0,0 +1,6 @@ +add_executable(QtWrapperTest test.cpp) +target_link_libraries(QtWrapperTest cpp-portage) +add_executable(QPackagepropertiesTest qpackageproperties_test.cpp) +target_link_libraries(QPackagepropertiesTest cpp-portage) +add_executable(QPortagesettingsTest qportagesettings_test.cpp) +target_link_libraries(QPortagesettingsTest cpp-portage) diff --git a/src/Qt/tests/qlistconverter_test.cpp b/src/Qt/tests/qlistconverter_test.cpp new file mode 100644 index 0000000..622b84b --- /dev/null +++ b/src/Qt/tests/qlistconverter_test.cpp @@ -0,0 +1,16 @@ +#include <QApplication> +#include <QDebug> + +#include "../qportagesettings.h" + +void test() { + qDebug() << +} + +int main(int argc, char *argv[]) +{ + QApplication app; + + + return app.exec(); +} diff --git a/src/Qt/tests/qpackageproperties_test.cpp b/src/Qt/tests/qpackageproperties_test.cpp new file mode 100644 index 0000000..b7e99ac --- /dev/null +++ b/src/Qt/tests/qpackageproperties_test.cpp @@ -0,0 +1,27 @@ +#include <QCoreApplication> +#include <QDebug> +#include <QStringList> + +#include "../qpackageproperties.h" +#include "../qlistconverter.h" + +using namespace CppPortage; + +void test(); + +void test() { + + QPackageProperties packPro(QString("slot"),QStringList("keyw"),QStringList("home"),QStringList("flags")); + + qDebug() << "QString Slot()" << packPro.Slot(); + qDebug() << "QStringList Homepages()" << packPro.Homepages(); + qDebug() << "QStringList Flags()" << packPro.Flags(); + qDebug() << "QStringList Keywords" << packPro.Keywords(); +} + +int main(int argc, char *argv[]) +{ + test(); + QCoreApplication app(argc, argv); + return app.exec(); +}
\ No newline at end of file diff --git a/src/Qt/tests/qportagesettings_test.cpp b/src/Qt/tests/qportagesettings_test.cpp new file mode 100644 index 0000000..da02903 --- /dev/null +++ b/src/Qt/tests/qportagesettings_test.cpp @@ -0,0 +1,34 @@ +#include <QCoreApplication> +#include <QDebug> +#include <QStringList> + +#include "../qportagesettings.h" +#include "../qlistconverter.h" + +using namespace CppPortage; + +void test() { + QPortageSettings portSett; + + qDebug() << "int resetUseFlags()" << portSett.resetUseFlags(); + qDebug() << "int reset()" << portSett.reset(); + qDebug() << "int reloadConfig()" << portSett.reloadConfig(); + qDebug() << "int reloadWorld()" << portSett.reloadWorld(); + qDebug() << "QStringList world()" << portSett.world(); + qDebug() << "QStringList archList()" << portSett.archList(); + qDebug() << "QStringList virtuals()" << portSett.virtuals(); + qDebug() << "QString acceptKeywords()" << portSett.acceptKeywords(); + qDebug() << "QStringList systemUseFlags()" << portSett.systemUseFlags(); + qDebug() << "QString arch()" << portSett.arch(); + qDebug() << "QString portdir()" << portSett.portdir(); + qDebug() << "QString portdirOverlay()" << portSett.portdirOverlay(); + qDebug() << "QString userConfigDir()" << portSett.userConfigDir(); +} + +int main(int argc, char *argv[]) +{ + test(); + QCoreApplication app(argc, argv); + + return app.exec(); +} diff --git a/src/Qt/tests/test.cpp b/src/Qt/tests/test.cpp new file mode 100644 index 0000000..c8329b1 --- /dev/null +++ b/src/Qt/tests/test.cpp @@ -0,0 +1,10 @@ +#include <QApplication> +#include <QDebug> + +int main(int argc, char *argv[]) +{ + QApplication app(argc,argv); + + + return app.exec(); +} |