From: <dhu...@us...> - 2006-12-15 08:09:18
|
Revision: 64 http://svn.sourceforge.net/qcell/?rev=64&view=rev Author: dhubleizh Date: 2006-12-15 00:09:05 -0800 (Fri, 15 Dec 2006) Log Message: ----------- - new StorageInterface (initial) - storage dir, Storage class implementing StorageInterface, some basic setup Modified Paths: -------------- trunk/qcell/visgui/MainWindow.cpp trunk/qcell/visgui/MainWindow.h trunk/qcell/visgui/main.cpp trunk/qcell/visgui/visgui.pro trunk/qcell/visgui/visgui_pl.qm trunk/qcell/visgui/visgui_pl.ts Added Paths: ----------- trunk/qcell/baseheaders/StorageInterface.h trunk/qcell/storage/ trunk/qcell/storage/Storage.cpp trunk/qcell/storage/Storage.h trunk/qcell/storage/storage.pro Added: trunk/qcell/baseheaders/StorageInterface.h =================================================================== --- trunk/qcell/baseheaders/StorageInterface.h (rev 0) +++ trunk/qcell/baseheaders/StorageInterface.h 2006-12-15 08:09:05 UTC (rev 64) @@ -0,0 +1,77 @@ +/**@file StorageInterface.h + * @author czarny + * @version 0.1 + * @date + * Created: pi? 15 gru 2006 08:27:20 CET \n + * Last Update: pi? 15 gru 2006 08:27:20 CET + */ + +#ifndef __STORAGEINTERFACE_H__ +#define __STORAGEINTERFACE_H__ + +#include <QtPlugin> +#include "Neighbourhood.h" +#include "LocalFunction.h" + +class StorageInterface +{ +public: + /** + * @brief Compiler warning stopper + */ + virtual ~StorageInterface(){ }; + + /** + * @brief Get data from Storage + * + * @param request XML describing the request parameters + * + * @return An QByteArray of data correspinding with the request + */ + virtual QByteArray loadData(QString request) = 0; + /** + * @brief Returns the whole block of data + * + * @return A block of data + */ + virtual QByteArray loadWholeData() = 0; + /** + * @brief Saves given data according to the request + * + * @param request Coordinates to save to + * @param data Raw data + */ + virtual void saveData(QString request, QByteArray data) = 0; + /** + * @brief Saves whole data block + * + * @param data Raw data + */ + virtual void saveWholeWhole(QByteArray data) = 0; + + + /** + * @brief Retrievs Neighbourhood given by request + * + * @param request XML identyfing a Neighbourhood + * + * @return Neighbourhood + */ + virtual Neighbourhood loadNeighbourhood(QString request) = 0; + + + /** + * @brief Returns a LocalFunction described by the request + * + * @param request An XML description of the LocalFunction + * + * @return LocalFunction + */ + virtual LocalFunction loadLocalFunction(QString request) = 0; + +}; + +Q_DECLARE_INTERFACE(StorageInterface, + "QCell.StorageInterface/1.0") +#endif + Added: trunk/qcell/storage/Storage.cpp =================================================================== --- trunk/qcell/storage/Storage.cpp (rev 0) +++ trunk/qcell/storage/Storage.cpp 2006-12-15 08:09:05 UTC (rev 64) @@ -0,0 +1,40 @@ +/**@file Storage.cpp + * @author czarny + * @version 0.1 + * @date + * Created: pi? 15 gru 2006 08:54:08 CET \n + * Last Update: pi? 15 gru 2006 08:54:08 CET + */ + +#include "Storage.h" + +QByteArray Storage::loadData(QString request) +{ + +} + +QByteArray Storage::loadWholeData() +{ + +} + +void Storage::saveData(QString request, QByteArray data) +{ + +} + +void Storage::saveWholeWhole(QByteArray data) +{ + +} + +Neighbourhood Storage::loadNeighbourhood(QString request) +{ + +} + +LocalFunction Storage::loadLocalFunction(QString request) +{ + +} + Added: trunk/qcell/storage/Storage.h =================================================================== --- trunk/qcell/storage/Storage.h (rev 0) +++ trunk/qcell/storage/Storage.h 2006-12-15 08:09:05 UTC (rev 64) @@ -0,0 +1,30 @@ +/**@file Storage.h + * @author czarny + * @version 0.1 + * @date + * Created: pi? 15 gru 2006 08:21:33 CET \n + * Last Update: pi? 15 gru 2006 08:21:33 CET + */ + +#ifndef __STORAGE_H__ +#define __STORAGE_H__ + +#include "StorageInterface.h" +#include <QByteArray> + +class Storage : public QObject, public StorageInterface +{ + Q_OBJECT + Q_INTERFACES(StorageInterface) + + QByteArray loadData(QString request); + QByteArray loadWholeData(); + void saveData(QString request, QByteArray data); + void saveWholeWhole(QByteArray data); + Neighbourhood loadNeighbourhood(QString request); + LocalFunction loadLocalFunction(QString request); + +}; + +#endif + Added: trunk/qcell/storage/storage.pro =================================================================== --- trunk/qcell/storage/storage.pro (rev 0) +++ trunk/qcell/storage/storage.pro 2006-12-15 08:09:05 UTC (rev 64) @@ -0,0 +1,14 @@ +TEMPLATE = lib +CONFIG += plugin +QT += xml +INCLUDEPATH = ../baseheaders +DESTDIR = ../../libs +TARGET = storage + +HEADERS = Storage.h + +SOURCES = Storage.cpp + +TRANSLATIONS = Storage_pl.ts + + Modified: trunk/qcell/visgui/MainWindow.cpp =================================================================== --- trunk/qcell/visgui/MainWindow.cpp 2006-12-15 07:31:46 UTC (rev 63) +++ trunk/qcell/visgui/MainWindow.cpp 2006-12-15 08:09:05 UTC (rev 64) @@ -10,9 +10,59 @@ MainWindow::MainWindow(QWidget* parent) { + // GUI setup setupUi(this); + + // Plugin parsing + /// @todo get that code out of here! + ParserInterface* iParser; + QStringList parser_types, file_types; + + // We check each static plugin if it is a parser plugin + // and if it is we register each parsing fucntion + // according to supported types and file extensions + foreach(QObject* plugin, QPluginLoader::staticInstances()) + { + iParser = qobject_cast<ParserInterface *>(plugin); + // If this is a parser plugin + if(iParser) + { + // Get supported parser types + parser_types = iParser->parserTypes(); + // For each type supported by the plugin alocate + // pointers accordingly + foreach(QString type, parser_types) + { + if(type == "Neighbourhood") + { + file_types = iParser->fileTypes("Neighbourhood"); + foreach(QString extension, file_types) + { + neighbourhood_parsers[extension] = iParser; + } + } + if(type == "Function") + { + file_types = iParser->fileTypes("Function"); + foreach(QString extension, file_types) + { + function_parsers[extension] = iParser; + } + } + if(type == "World") + { + file_types = iParser->fileTypes("World"); + foreach(QString extension, file_types) + { + world_parsers[extension] = iParser; + } + } } + } + } +} + void MainWindow::on_action_About_activated() { QDialog* dialog = new QDialog(this); @@ -27,3 +77,115 @@ // TODO: Some saving checking QCoreApplication::exit(); } + +void MainWindow::on_action_Neighbourhood_activated() +{ + if(neighbourhood_parsers.count() == 0) + { + QMessageBox::warning( + /*parent*/ this, + /*title*/ tr("Plugins warning"), + /*message*/ tr("There are no plugins loaded to handle Neighbourhood parsing.") + ); + + return; + + } + + QFileDialog fd( + /*parent*/ this, + /*cation*/ tr("Open Neighbourhood") + ); + + fd.setFileMode(QFileDialog::ExistingFile); + + QStringList filters; + QString filter; + // Add filter in format %{name} files (*.%{name}) + foreach(QString key, neighbourhood_parsers.keys()) + { + // Don't shorten this, as it is made for translations + // purposes + filter = key + " " + tr("files") + " (*." + key + ")"; + filters << filter; + } + fd.setFilters(filters); + + fd.exec(); + +} + +void MainWindow::on_action_Function_activated() +{ + if(function_parsers.count() == 0) + { + QMessageBox::warning( + /*parent*/ this, + /*title*/ tr("Plugins warning"), + /*message*/ tr("There are no plugins loaded to handle Function parsing.") + ); + + return; + + } + + QFileDialog fd( + /*parent*/ this, + /*cation*/ tr("Open Function") + ); + + fd.setFileMode(QFileDialog::ExistingFile); + + QStringList filters; + QString filter; + // Add filter in format %{name} files (*.%{name}) + foreach(QString key, function_parsers.keys()) + { + // Don't shorten this, as it is made for translations + // purposes + filter = key + " " + tr("files") + " (*." + key + ")"; + filters << filter; + } + fd.setFilters(filters); + + fd.exec(); + +} + +void MainWindow::on_action_World_activated() +{ + if(world_parsers.count() == 0) + { + QMessageBox::warning( + /*parent*/ this, + /*title*/ tr("Plugins warning"), + /*message*/ tr("There are no plugins loaded to handle World parsing.") + ); + + return; + + } + + QFileDialog fd( + /*parent*/ this, + /*cation*/ tr("Open World") + ); + + fd.setFileMode(QFileDialog::ExistingFile); + + QStringList filters; + QString filter; + // Add filter in format %{name} files (*.%{name}) + foreach(QString key, world_parsers.keys()) + { + // Don't shorten this, as it is made for translations + // purposes + filter = key + " " + tr("files") + " (*." + key + ")"; + filters << filter; + } + fd.setFilters(filters); + + fd.exec(); + +} + Modified: trunk/qcell/visgui/MainWindow.h =================================================================== --- trunk/qcell/visgui/MainWindow.h 2006-12-15 07:31:46 UTC (rev 63) +++ trunk/qcell/visgui/MainWindow.h 2006-12-15 08:09:05 UTC (rev 64) @@ -11,20 +11,35 @@ #include "ui_MainWindow.h" #include "ui_AboutDialog.h" +#include <QPluginLoader> +#include "GenericParserPlugin.h" +#include <QFileDialog> +#include <QMessageBox> #include <iostream> using namespace std; +typedef QString (*parser_fun)(QByteArray content, QString type, QString subtype); + class MainWindow : public QMainWindow, private Ui::MainWindow { Q_OBJECT public: - MainWindow(QWidget* parent = 0); + MainWindow(QWidget* parent = 0); private slots: - void on_action_About_activated(); - void on_action_Quit_activated(); + void on_action_About_activated(); + void on_action_Quit_activated(); + void on_action_Neighbourhood_activated(); + void on_action_Function_activated(); + void on_action_World_activated(); + +private: + QMap<QString, ParserInterface*> neighbourhood_parsers; + QMap<QString, ParserInterface*> function_parsers; + QMap<QString, ParserInterface*> world_parsers; + }; #endif Modified: trunk/qcell/visgui/main.cpp =================================================================== --- trunk/qcell/visgui/main.cpp 2006-12-15 07:31:46 UTC (rev 63) +++ trunk/qcell/visgui/main.cpp 2006-12-15 08:09:05 UTC (rev 64) @@ -8,6 +8,8 @@ using namespace std; Q_IMPORT_PLUGIN(NFileParser); +//Q_IMPORT_PLUGIN(FQTFileParser); +//Q_IMPORT_PLUGIN(KIFileParser); int main(int argc, char* argv[]) { @@ -17,28 +19,16 @@ if(c.initClient()) { } - QString locale = QLocale::system().name(); QTranslator translator; translator.load(QString("visgui_") + locale); app.installTranslator(&translator); - foreach(QObject* plugin, QPluginLoader::staticInstances()) - { - ParserInterface* iParser = qobject_cast<ParserInterface *>(plugin); - if(iParser) - { - QStringList lista = iParser->fileTypes(); - QString str = lista[0]; - cout << str.toStdString() << endl; - } - } - MainWindow mw; mw.show(); - + return app.exec(); } Modified: trunk/qcell/visgui/visgui.pro =================================================================== --- trunk/qcell/visgui/visgui.pro 2006-12-15 07:31:46 UTC (rev 63) +++ trunk/qcell/visgui/visgui.pro 2006-12-15 08:09:05 UTC (rev 64) @@ -3,16 +3,22 @@ CONFIG += thread warn_on debug QT += network xml +INCLUDEPATH = ../baseheaders + FORMS = MainWindow.ui \ AboutDialog.ui HEADERS = MainWindow.h \ ../baseheaders/Client.h \ ../baseheaders/ClientInfo.h \ - ../baseheaders/interfaces.h -SOURCES = main.cpp \ + ../baseheaders/interfaces.h \ + ../baseheaders/GenericParserPlugin.h \ + ../baseheaders/Neighbourhood.h +SOURCES = ../basesources/GenericParserPlugin.cpp \ + main.cpp \ MainWindow.cpp \ ../basesources/Client.cpp \ - ../basesources/ClientInfo.cpp + ../basesources/ClientInfo.cpp \ + ../basesources/Neighbourhood.cpp LIBS = -L../libs -lN Modified: trunk/qcell/visgui/visgui_pl.qm =================================================================== (Binary files differ) Modified: trunk/qcell/visgui/visgui_pl.ts =================================================================== --- trunk/qcell/visgui/visgui_pl.ts 2006-12-15 07:31:46 UTC (rev 63) +++ trunk/qcell/visgui/visgui_pl.ts 2006-12-15 08:09:05 UTC (rev 64) @@ -14,6 +14,19 @@ </message> </context> <context> + <name>GenericParserPlugin</name> + <message> + <location filename="../baseheaders/GenericParserPlugin.h" line="61"/> + <source>The plugin type %1 is not supported by this plugin.</source> + <translation>Typ wtyczki %1 nie jest wspierany przez te wtyczkę.</translation> + </message> + <message> + <location filename="../basesources/GenericParserPlugin.cpp" line="67"/> + <source>This plugin doesn't support parsing of type %1. It supports %2.</source> + <translation>Ta wtyczka nie obsługuję parsowania typu %1. Wspiera typ %2.</translation> + </message> +</context> +<context> <name>MainWindow</name> <message> <location filename="MainWindow.ui" line="13"/> @@ -121,5 +134,20 @@ <source>Shows info about the program.</source> <translation>Pokazuje informacje o programie.</translation> </message> + <message> + <location filename="MainWindow.cpp" line="71"/> + <source>Open Neighbourhood</source> + <translation>Otwórz Sąsiedztwo</translation> + </message> + <message> + <location filename="MainWindow.cpp" line="80"/> + <source> files (*.</source> + <translation type="obsolete"> pliki</translation> + </message> + <message> + <location filename="MainWindow.cpp" line="82"/> + <source>files</source> + <translation>pliki</translation> + </message> </context> </TS> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |