replaced DeletePoint with DeletePoint_2
[engrid.git] / main.cpp
blob46711d10decd9953faa65ea13f68db0d255a6cbd
1 //
2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 // + +
4 // + This file is part of enGrid. +
5 // + +
6 // + Copyright 2008,2009 Oliver Gloth +
7 // + +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
12 // + +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
17 // + +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
20 // + +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #include <QtCore>
24 #include <QtGui>
25 #include <QApplication>
26 #include <QFile>
27 #include <QTextStream>
28 #include <QDate>
30 #include "guimainwindow.h"
32 void makeDistribution()
36 int main( int argc, char ** argv )
38 if (argc > 1) {
39 if (QString(argv[1]) == QString("-appendlic")) {
40 int first_year = 2008;
41 QString first_year_text;
42 first_year_text.setNum(first_year);
43 int year = QDate::currentDate().year();
44 QString year_text;
45 year_text.setNum(year);
46 if (year-first_year == 1) {
47 year_text = first_year_text + "," + year_text;
49 if (year-first_year > 1) {
50 year_text = first_year_text + "-" + year_text;
52 QString year_end_text = " +\n";
53 if (year == first_year) {
54 year_end_text = " " + year_end_text;
56 for (int i = 2; i < argc; ++i) {
57 QString filename(argv[i]);
58 QString buffer = "//\n";
59 buffer += "// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
60 buffer += "// + +\n";
61 buffer += "// + This file is part of enGrid. +\n";
62 buffer += "// + +\n";
63 buffer += "// + Copyright " + year_text + " Oliver Gloth" + year_end_text;
64 buffer += "// + +\n";
65 buffer += "// + enGrid is free software: you can redistribute it and/or modify +\n";
66 buffer += "// + it under the terms of the GNU General Public License as published by +\n";
67 buffer += "// + the Free Software Foundation, either version 3 of the License, or +\n";
68 buffer += "// + (at your option) any later version. +\n";
69 buffer += "// + +\n";
70 buffer += "// + enGrid is distributed in the hope that it will be useful, +\n";
71 buffer += "// + but WITHOUT ANY WARRANTY; without even the implied warranty of +\n";
72 buffer += "// + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +\n";
73 buffer += "// + GNU General Public License for more details. +\n";
74 buffer += "// + +\n";
75 buffer += "// + You should have received a copy of the GNU General Public License +\n";
76 buffer += "// + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +\n";
77 buffer += "// + +\n";
78 buffer += "// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
79 buffer += "//\n";
81 bool src_code = false;
82 QFile file(filename);
83 file.open(QIODevice::ReadOnly);
84 QTextStream f(&file);
85 while (!f.atEnd()) {
86 QString line = f.readLine();
87 if (!src_code) {
88 if (line.size() >= 2) {
89 if (line.left(2) != "//") {
90 src_code = true;
92 } else {
93 src_code = true;
96 if (src_code) {
97 buffer += line + "\n";
102 QFile file(filename);
103 file.open(QIODevice::WriteOnly);
104 QTextStream f(&file);
105 f << buffer;
109 if (QString(argv[1]) == QString("-distbin")) {
110 system ("ldd ./engrid > ldd.out");
111 system ("mkdir enGrid");
112 system ("cp engrid enGrid");
113 system ("cp start_engrid enGrid");
115 QFile file("ldd.out");
116 file.open(QIODevice::ReadOnly);
117 QTextStream f(&file);
118 while (!f.atEnd()) {
119 QString line = f.readLine();
120 QTextStream l(&line, QIODevice::ReadOnly);
121 QString word;
122 l >> word;
123 if (word.left(1) != "/") {
124 l >> word;
125 l >> word;
127 QString cmd = "cp " + word + " enGrid";
128 system(cmd.toAscii().data());
129 cout << cmd.toAscii().data() << endl;
132 system ("tar czf enGrid_bin.tar.gz enGrid/*");
133 system ("rm -rf enGrid");
134 system ("rm ldd.out");
136 } else {
137 QApplication a( argc, argv );
138 GuiMainWindow w;
139 w.show();
140 a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
141 a.exec();