summaryrefslogtreecommitdiff
path: root/scripts/q_functions
Unidiff
Diffstat (limited to 'scripts/q_functions') (more/less context) (ignore whitespace changes)
-rwxr-xr-xscripts/q_functions232
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
9function print_example_usage
10{
11cat << END
12Example 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
18END
19}
20
21
22function print_copyright_header
23{
24cat << 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**********************************************************************/
44END
45}
46
47
48function print_main_file
49{
50print_copyright_header
51cat << END
52#include <qpeapplication.h>
53#include <qmainwindow.h>
54#include "$NEW_CLASS_HEADER_FILE"
55
56
57int 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}
67END
68}
69
70
71function print_source_file
72{
73print_copyright_header
74cat << 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
86void $NEW_CLASS_NAME::exampleFunction( )
87{
88}
89END
90}
91
92
93function print_header_file
94{
95print_copyright_header
96cat << END
97#ifndef $NEW_CLASS_HEADER_DEFINE
98#define $NEW_CLASS_HEADER_DEFINE
99
100
101#include <qwidget.h>
102
103
104class $NEW_CLASS_NAME : public QWidget
105{
106Q_OBJECT
107public:
108 $NEW_CLASS_NAME( QWidget *parent=0, const char *name=0, WFlags f = 0);
109protected:
110 void exampleFunction( );
111private:
112 int exampleVariable;
113};
114
115
116#endif // $NEW_CLASS_HEADER_DEFINE
117END
118}
119
120
121function print_pro_file
122{
123cat << 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
132LIBS += -lqpe
133 TARGET = $NEW_APP_NAME
134END
135}
136
137
138function print_install_file
139{
140cat << END
141#!/bin/sh
142if [ a\$QPEDIR = a ]
143then
144echo QPEDIR must be set
145exit
146fi
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/
149mv \$QPEDIR/Makefile \$QPEDIR/Makefile.orig
150sed "s/APPS=/&$NEW_APP_NAME \\\\\\\\ \\\\
151 /" \$QPEDIR/Makefile.orig >> \$QPEDIR/Makefile
152echo You may wish to move the desktop file in to
153echo an appropriate subdirectory of the menus.
154END
155}
156
157
158function print_desktop_file
159{
160cat << END
161[Desktop Entry]
162Type=Application
163Exec=$NEW_APP_NAME
164Icon=$NEW_APP_ICON_FILE
165Name=$NEW_APP_MENU_NAME
166Comment=$NEW_APP_DESCRIPTION
167END
168}
169
170
171function print_icon_file
172{
173XPM_NAME="$NEW_APP_NAME"_xpm
174cat << END
175/* XPM */
176static 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" "};
195END
196}
197
198
199function add_class_to_pro_file
200{
201cat << END
202 HEADERS += $NEW_CLASS_HEADER_FILE
203 SOURCES += $NEW_CLASS_SOURCE_FILE
204END
205}
206
207
208function get_number_of_lines
209{
210# Get the number of lines in the file
211LINES=`wc -l $ORIGINAL_CLASS_HEADER_FILE | cut -d " " -f 6`
212}
213
214
215function get_first_line_of_class_definition
216{
217# First look for class definition with Q_OBJECT a few lines below
218LINE=`grep -n -A 3 "class $EXISTING_CLASS_NAME " $ORIGINAL_CLASS_HEADER_FILE | grep "Q_OBJECT" | cut -d "-" -f 1`
219if [ -z "$LINE" ]
220then
221# else look for class definition with open brace on same line
222LINE=`grep -n "class $EXISTING_CLASS_NAME.*[{]" $ORIGINAL_CLASS_HEADER_FILE | cut -d ":" -f 1`
223#elif doesn't work here
224fi;if [ -z "$LINE" ]
225then
226# else look for class with open brace a few lines below
227LINE=`grep -n -A 3 "class $EXISTING_CLASS_NAME " $ORIGINAL_CLASS_HEADER_FILE | grep "\-.*[{]" | cut -d "-" -f 1`
228#elif doesn't work here
229fi
230}
231
232