From 6117049617df720fb744a90773a3580b3450b005 Mon Sep 17 00:00:00 2001 From: Jan Darmochwal Date: Sat, 2 Oct 2010 18:50:09 +0200 Subject: Qt port is almost complete (at least it compiles) Major change: * struct DataEntry has become class Session with sub-classes XSession and VSession * functions from addInfo.cpp, addPrinters.cpp, addScanners.cpp, readLinSess.cpp, readXmlDir.cpp, runImage.cpp have been moved to XSession and VSession Several minor changes: * new files globals.h and globals.cpp for global variables (replaces constants.h and paths.h) * replaced (all) libxml2, (much) std:: and (most) boost:: stuff by Qt stuff Things left to do: * remove tons of debug printfs * show error messages on errors * tidy up anyoption stuff in main() * highlight session run previously * readGroupXml stuff * tree view (with "X Sessions" and "Virtual Sessions" sections) instead of list view for session selection --- src/main.cpp | 54 ++++++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 36 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 452bb89..1fa71be 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3,14 +3,11 @@ #include #include -#include "DataEntry.h" -#include "functions.h" +#include "save_restore_session.h" +#include "xsession.h" +#include "vsession.h" #include "anyoption.h" -#include "paths.h" - -#include -#include -#include +#include "globals.h" #include @@ -18,10 +15,9 @@ namespace bfs=boost::filesystem; using namespace std; -// defined in readXmlDir.h -extern DataEntry* get_entry(xmlDoc * doc); - int main(int argc, char *argv[]) { + QApplication a(argc, argv); + string version = "0.0.13"; AnyOption* opt = new AnyOption(); char* xmlpath = NULL; @@ -124,6 +120,7 @@ int main(int argc, char *argv[]) { lsesspath = opt->getValue("lpath"); } if (lsesspath == NULL) { + // TODO: absolute paths as constants lsesspath = (char *) "/usr/share/xsessions/"; } @@ -144,7 +141,7 @@ int main(int argc, char *argv[]) { } else { i = size.find_first_of("x"); - if( i == string::npos) { + if (i == string::npos) { cerr << "Please write x as argument for -s|--size." << endl; return 1; } @@ -154,6 +151,7 @@ int main(int argc, char *argv[]) { // additional xml argument -> start image directly +#if 0 if(opt->getArgc() > 0) { string single_arg = opt->getArgv(0); if(bfs::is_directory(single_arg)) { @@ -176,38 +174,22 @@ int main(int argc, char *argv[]) { return 1; } } +#endif delete opt; /* read xml files */ - std::vector sessions; - std::vector lsessions; -printf("dummy\n"); - sessions = readXmlDir(xmlpath); -printf("dummy2\n"); - lsessions = readLinSess(lsesspath); -printf("dummy3\n"); + QList xsessions(XSession::readSessions(lsesspath)); + QList vsessions(VSession::readXmlDir(xmlpath)); -printf ("%d sessions\n", sessions.size()); -printf ("%d lsessions\n", lsessions.size()); + printf ("%d VSessions\n", vsessions.size()); + printf ("%d XSessions\n", xsessions.size()); - bool lin_entries=false; - bool vm_entries=false; - - if(lsessions.size()) { - //win.set_lin_entries(lsessions); - lin_entries = true; - } - if (sessions.size()) { - //win.set_entries(sessions); - vm_entries = true; - } - - sessions.insert(sessions.begin(), lsessions.begin(), lsessions.end()); - - QApplication a(argc, argv); Dialog w; - w.addItems(sessions); + w.resize(width, height); + + w.addItems(xsessions, "X Sessions"); + w.addItems(vsessions, "Virtual Sessions"); w.show(); return a.exec(); } -- cgit v1.2.3-55-g7522