]> Git trees. - libqmvoc.git/commitdiff
added converter sources, reads a document, and writes it out
authorJeremy Paul Whiting <jpwhiting@kde.org>
Wed, 1 Aug 2007 05:59:01 +0000 (05:59 +0000)
committerJeremy Paul Whiting <jpwhiting@kde.org>
Wed, 1 Aug 2007 05:59:01 +0000 (05:59 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=695004

kdeeducore/tests/CMakeLists.txt
kdeeducore/tests/converter.cpp [new file with mode: 0644]

index 552c97735c901a80a65714c75284ed114f9b6670..c449b3e45cfd945c51ece25dfcdc4b25f9ec4cf4 100644 (file)
@@ -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 (file)
index 0000000..f68b2ee
--- /dev/null
@@ -0,0 +1,67 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Jeremy Whiting <jeremy@scitools.com>            *
+ *                                                                         *
+ *   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 <jeremy@scitools.com>
+ */
+
+#include "keduvocdocument.h"
+
+#include <QApplication>
+
+#include <KAboutData>
+#include <KCmdLineArgs>
+#include <KCmdLineOptions>
+#include <KDebug>
+#include <KUrl>
+
+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;
+}