From: Jeremy Paul Whiting Date: Wed, 1 Aug 2007 05:59:01 +0000 (+0000) Subject: added converter sources, reads a document, and writes it out X-Git-Tag: v3.93.0~108 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=7e1bdf2c27d925f6feba302cdfcf91eadec8a755;p=libqmvoc.git added converter sources, reads a document, and writes it out svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=695004 --- diff --git a/kdeeducore/tests/CMakeLists.txt b/kdeeducore/tests/CMakeLists.txt index 552c977..c449b3e 100644 --- a/kdeeducore/tests/CMakeLists.txt +++ b/kdeeducore/tests/CMakeLists.txt @@ -1,12 +1,14 @@ -include_directories( ${CMAKE_SOURCE_DIR}/kdeeducore ) +include_directories( ${CMAKE_SOURCE_DIR}/libkdeedu/kdeeducore/ ) ########### next target ############### -set(loader_SRCS loader.cpp ) +set(converter_SRCS + converter.cpp ) -kde4_add_test_executable(loader ${loader_SRCS}) -target_link_libraries(loader ${KDE4_KDECORE_LIBS} kdeeducore ) +kde4_add_executable(converter ${converter_SRCS}) + +target_link_libraries(converter kdeeducore ) diff --git a/kdeeducore/tests/converter.cpp b/kdeeducore/tests/converter.cpp new file mode 100644 index 0000000..f68b2ee --- /dev/null +++ b/kdeeducore/tests/converter.cpp @@ -0,0 +1,67 @@ +/*************************************************************************** + * Copyright (C) 2007 by Jeremy Whiting * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +/** @file + * \brief kvtml document reader/writer + * partly to test the document class, partly to convert + * old kvtml files to the new format + * @author Jeremy Whiting + */ + +#include "keduvocdocument.h" + +#include + +#include +#include +#include +#include +#include + +int main (int argc, char ** argv) +{ + KAboutData about("converter", 0, ki18n("Converter"), "0.1", ki18n("kvtml file converter"), KAboutData::License_GPL, ki18n("© 2007 Jeremy Whiting")); + KCmdLineOptions options; + options.add("+infile"); + options.add("+outfile"); + + KCmdLineArgs::init(argc, argv, &about); + KCmdLineArgs::addCmdLineOptions(options); + QCoreApplication app(KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv()); + + KCmdLineArgs * arguments = KCmdLineArgs::parsedArgs(); + if (arguments != NULL && arguments->count() > 0) + { + KUrl infile(arguments->url(0)); + if (arguments->count() > 1) + { + KUrl outfile(arguments->url(1)); + + KEduVocDocument document; + kDebug() << "Reading " << infile << endl; + document.open(infile); + kDebug() << "Writing to " << outfile << endl; + document.saveAs(outfile, KEduVocDocument::kvtml, "converter"); + } + } + + arguments->clear(); + + return 0; +}