Go to the documentation of this file.00001 #include "constants.h"
00002
00003 #include "mainwindow.h"
00004
00005 #include <QtPlugin>
00006 #include <QApplication>
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 #if defined(QT_NO_DEBUG) && defined(_WINDOWS)
00089 # define LOGGING_ENABLED
00090 #endif
00091
00092 #ifdef LOGGING_ENABLED
00093 #include <QFile>
00094 #include <QTextStream>
00095 #include <stdlib.h>
00096
00097 QFile gLogFile("automataLog.txt");
00098
00099 void automataMsgHandler(QtMsgType type, const char *msg)
00100 {
00101 gLogFile.open(QIODevice::Append);
00102 QTextStream log(&gLogFile);
00103 switch (type)
00104 {
00105 case QtDebugMsg:
00106 log << "Debug: " << msg << endl;
00107 fprintf(stdout, "Debug: %s\n", msg);
00108 break;
00109 case QtWarningMsg:
00110 log << "Warning: " << msg << endl;
00111 fprintf(stderr, "Warning: %s\n", msg);
00112 break;
00113 case QtCriticalMsg:
00114 log << "Critical: " << msg << endl;
00115 fprintf(stderr, "Critical: %s\n", msg);
00116 break;
00117 case QtFatalMsg:
00118 log << "Fatal: " << msg << endl;
00119 fprintf(stderr, "Fatal: %s\n", msg);
00120 abort();
00121 }
00122 gLogFile.close();
00123 }
00124
00125 #endif
00126
00127 void printHelp()
00128 {
00129 QTextStream out(stdout);
00130
00131 if (out.status() == QTextStream::Ok)
00132 {
00133 out << "AutomataEditor v 2.0" << endl
00134 << "Usage:" << endl
00135 << "\tAutomataEditor filename" << endl
00136 << "\tAutomataEditor [opions] -f|--file filename" << endl
00137 << "Options:" << endl
00138 << "-h,--help\t\tthis help message" << endl
00139 << "-f,--file\t\topen specified file" << endl
00140 << endl
00141 << "Homepage: http://sourceforge.net/projects/automataeditor" << endl
00142 << "Milan Kriz" << endl
00143 << "\tmilan.kriz@centrum.cz" << endl
00144 << "\tkrizmil2@fel.cvut.cz" << endl
00145 << "Jan Zdarek" << endl
00146 << "\tzdarekj@fel.cvut.cz" << endl;
00147 }
00148 else
00149 {
00150 RELLOG("Cannot output standard output!!! (" << out.status() << ")");
00151 }
00152 }
00153
00154 Q_IMPORT_PLUGIN(algorithms)
00155
00156 int main(int argc, char **argv)
00157 {
00158 Q_INIT_RESOURCE(application);
00159 #ifdef LOGGING_ENABLED
00160 gLogFile.open(QIODevice::WriteOnly);
00161 gLogFile.close();
00162 qInstallMsgHandler(automataMsgHandler);
00163 #endif
00164
00165 QString fileName;
00166 if (argc > 1)
00167 {
00168 QStringList args;
00169 for(int i=1; i<argc; ++i)
00170 {
00171 args << argv[i];
00172 }
00173
00174 if (args.contains("-h") || args.contains("--help"))
00175 {
00176 printHelp();
00177 return 0;
00178 }
00179
00180 if (args.count() == 1)
00181 {
00182 fileName = args[0];
00183 }
00184 else if (args.contains("-f") && args.length() > args.indexOf("-f"))
00185 {
00186 fileName = args[args.indexOf("-f")+1];
00187 }
00188 else if (args.contains("-file") && args.length() > args.indexOf("-file"))
00189 {
00190 fileName = args[args.indexOf("-file")+1];
00191 }
00192 else if(!args.isEmpty())
00193 {
00194 printHelp();
00195 return 1;
00196 }
00197 }
00198
00199 QApplication app(argc, argv);
00200
00201 MainWindow window(fileName);
00202 window.show();
00203 return app.exec();
00204 }