author | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
commit | 15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff) | |
tree | c2fa0399a2c47fda8e2cd0092c73a809d17f68eb /scripts/q_functions | |
download | opie-15318cad33835e4e2dc620d033e43cd930676cdd.zip opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2 |
Initial revision
-rwxr-xr-x | scripts/q_functions | 232 |
1 files changed, 232 insertions, 0 deletions
diff --git a/scripts/q_functions b/scripts/q_functions new file mode 100755 index 0000000..cf2c2e1 --- a/dev/null +++ b/scripts/q_functions | |||
@@ -0,0 +1,232 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Common helper functions used by the other scripts | ||
4 | # | ||
5 | # Copyright 1999-2000 Trolltech AS. All rights reserved. | ||
6 | # | ||
7 | |||
8 | |||
9 | function print_example_usage | ||
10 | { | ||
11 | cat << END | ||
12 | Example of what you do: | ||
13 | ~/qpe$ q_add_application foo Foo MyFooBarApp "A FooBar Application" | ||
14 | ~/qpe$ cd foo | ||
15 | ~/qpe/foo$ q_add_class foo Bar | ||
16 | ~/qpe/foo$ q_add_function public: void Bar::barFoo "( int a, int b )" | ||
17 | ~/qpe/foo$ q_add_variable private: int Bar::fooBarInt | ||
18 | END | ||
19 | } | ||
20 | |||
21 | |||
22 | function print_copyright_header | ||
23 | { | ||
24 | cat << END | ||
25 | /********************************************************************** | ||
26 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
27 | ** | ||
28 | ** This file is part of Qtopia Environment. | ||
29 | ** | ||
30 | ** This file may be distributed and/or modified under the terms of the | ||
31 | ** GNU General Public License version 2 as published by the Free Software | ||
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
33 | ** packaging of this file. | ||
34 | ** | ||
35 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
36 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
37 | ** | ||
38 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
39 | ** | ||
40 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
41 | ** not clear to you. | ||
42 | ** | ||
43 | **********************************************************************/ | ||
44 | END | ||
45 | } | ||
46 | |||
47 | |||
48 | function print_main_file | ||
49 | { | ||
50 | print_copyright_header | ||
51 | cat << END | ||
52 | #include <qpeapplication.h> | ||
53 | #include <qmainwindow.h> | ||
54 | #include "$NEW_CLASS_HEADER_FILE" | ||
55 | |||
56 | |||
57 | int main( int argc, char ** argv ) | ||
58 | { | ||
59 | QPEApplication a( argc, argv ); | ||
60 | |||
61 | $NEW_CLASS_NAME *m = new $NEW_CLASS_NAME(); | ||
62 | a.setMainWidget( m ); | ||
63 | m->show(); | ||
64 | |||
65 | return a.exec(); | ||
66 | } | ||
67 | END | ||
68 | } | ||
69 | |||
70 | |||
71 | function print_source_file | ||
72 | { | ||
73 | print_copyright_header | ||
74 | cat << END | ||
75 | #include <qwidget.h> | ||
76 | #include <pixmaploader.h> | ||
77 | #include "$NEW_CLASS_HEADER_FILE" | ||
78 | |||
79 | |||
80 | $NEW_CLASS_NAME::$NEW_CLASS_NAME( QWidget *parent=0, const char *name=0, WFlags f = 0) : | ||
81 | QWidget( parent, name, f ) | ||
82 | { | ||
83 | } | ||
84 | |||
85 | |||
86 | void $NEW_CLASS_NAME::exampleFunction( ) | ||
87 | { | ||
88 | } | ||
89 | END | ||
90 | } | ||
91 | |||
92 | |||
93 | function print_header_file | ||
94 | { | ||
95 | print_copyright_header | ||
96 | cat << END | ||
97 | #ifndef $NEW_CLASS_HEADER_DEFINE | ||
98 | #define $NEW_CLASS_HEADER_DEFINE | ||
99 | |||
100 | |||
101 | #include <qwidget.h> | ||
102 | |||
103 | |||
104 | class $NEW_CLASS_NAME : public QWidget | ||
105 | { | ||
106 | Q_OBJECT | ||
107 | public: | ||
108 | $NEW_CLASS_NAME( QWidget *parent=0, const char *name=0, WFlags f = 0); | ||
109 | protected: | ||
110 | void exampleFunction( ); | ||
111 | private: | ||
112 | int exampleVariable; | ||
113 | }; | ||
114 | |||
115 | |||
116 | #endif // $NEW_CLASS_HEADER_DEFINE | ||
117 | END | ||
118 | } | ||
119 | |||
120 | |||
121 | function print_pro_file | ||
122 | { | ||
123 | cat << END | ||
124 | TEMPLATE= app | ||
125 | CONFIG = qt warn_on release | ||
126 | DESTDIR = ../bin | ||
127 | HEADERS = $NEW_CLASS_HEADER_FILE | ||
128 | SOURCES = $NEW_CLASS_SOURCE_FILE $NEW_APP_MAIN_FILE | ||
129 | INTERFACES= | ||
130 | INCLUDEPATH+= ../library | ||
131 | DEPENDPATH+= ../library | ||
132 | LIBS += -lqpe | ||
133 | TARGET = $NEW_APP_NAME | ||
134 | END | ||
135 | } | ||
136 | |||
137 | |||
138 | function print_install_file | ||
139 | { | ||
140 | cat << END | ||
141 | #!/bin/sh | ||
142 | if [ a\$QPEDIR = a ] | ||
143 | then | ||
144 | echo QPEDIR must be set | ||
145 | exit | ||
146 | fi | ||
147 | [ -f \$QPEDIR/pics/$NEW_APP_ICON_FILE ] || cp $NEW_APP_ICON_FILE \$QPEDIR/pics/ | ||
148 | [ -f \$QPEDIR/apps/$NEW_APP_DESKTOP_FILE ] || cp $NEW_APP_DESKTOP_FILE \$QPEDIR/apps/ | ||
149 | mv \$QPEDIR/Makefile \$QPEDIR/Makefile.orig | ||
150 | sed "s/APPS=/&$NEW_APP_NAME \\\\\\\\ \\\\ | ||
151 | /" \$QPEDIR/Makefile.orig >> \$QPEDIR/Makefile | ||
152 | echo You may wish to move the desktop file in to | ||
153 | echo an appropriate subdirectory of the menus. | ||
154 | END | ||
155 | } | ||
156 | |||
157 | |||
158 | function print_desktop_file | ||
159 | { | ||
160 | cat << END | ||
161 | [Desktop Entry] | ||
162 | Type=Application | ||
163 | Exec=$NEW_APP_NAME | ||
164 | Icon=$NEW_APP_ICON_FILE | ||
165 | Name=$NEW_APP_MENU_NAME | ||
166 | Comment=$NEW_APP_DESCRIPTION | ||
167 | END | ||
168 | } | ||
169 | |||
170 | |||
171 | function print_icon_file | ||
172 | { | ||
173 | XPM_NAME="$NEW_APP_NAME"_xpm | ||
174 | cat << END | ||
175 | /* XPM */ | ||
176 | static char *$XPM_NAME[] = { | ||
177 | "14 14 3 1", | ||
178 | " c None", | ||
179 | ".c #000000", | ||
180 | "ac #FFFFFF", | ||
181 | " ", | ||
182 | " aaaaaaaaaaaa ", | ||
183 | " a..........a ", | ||
184 | " a..aaaaaa..a ", | ||
185 | " a.a.aaaa.a.a ", | ||
186 | " a.aa.aa.aa.a ", | ||
187 | " a.aaa..aaa.a ", | ||
188 | " a.aaa..aaa.a ", | ||
189 | " a.aa.aa.aa.a ", | ||
190 | " a.a.aaaa.a.a ", | ||
191 | " a..aaaaaa..a ", | ||
192 | " a..........a ", | ||
193 | " aaaaaaaaaaaa ", | ||
194 | " "}; | ||
195 | END | ||
196 | } | ||
197 | |||
198 | |||
199 | function add_class_to_pro_file | ||
200 | { | ||
201 | cat << END | ||
202 | HEADERS += $NEW_CLASS_HEADER_FILE | ||
203 | SOURCES += $NEW_CLASS_SOURCE_FILE | ||
204 | END | ||
205 | } | ||
206 | |||
207 | |||
208 | function get_number_of_lines | ||
209 | { | ||
210 | # Get the number of lines in the file | ||
211 | LINES=`wc -l $ORIGINAL_CLASS_HEADER_FILE | cut -d " " -f 6` | ||
212 | } | ||
213 | |||
214 | |||
215 | function get_first_line_of_class_definition | ||
216 | { | ||
217 | # First look for class definition with Q_OBJECT a few lines below | ||
218 | LINE=`grep -n -A 3 "class $EXISTING_CLASS_NAME " $ORIGINAL_CLASS_HEADER_FILE | grep "Q_OBJECT" | cut -d "-" -f 1` | ||
219 | if [ -z "$LINE" ] | ||
220 | then | ||
221 | # else look for class definition with open brace on same line | ||
222 | LINE=`grep -n "class $EXISTING_CLASS_NAME.*[{]" $ORIGINAL_CLASS_HEADER_FILE | cut -d ":" -f 1` | ||
223 | #elif doesn't work here | ||
224 | fi;if [ -z "$LINE" ] | ||
225 | then | ||
226 | # else look for class with open brace a few lines below | ||
227 | LINE=`grep -n -A 3 "class $EXISTING_CLASS_NAME " $ORIGINAL_CLASS_HEADER_FILE | grep "\-.*[{]" | cut -d "-" -f 1` | ||
228 | #elif doesn't work here | ||
229 | fi | ||
230 | } | ||
231 | |||
232 | |||