author | mickeyl <mickeyl> | 2005-08-23 10:06:07 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-08-23 10:06:07 (UTC) |
commit | d6e8e6bf49bb176ec54efed5eb0d012098f056d7 (patch) (unidiff) | |
tree | 7fc70f3d3b41ee05ddb2ea559c7339a18ef0464b /noncore/tools/calc2/main/calc.cpp | |
parent | ce5b18efcb27c853ed4af2b603a82d3f89097764 (diff) | |
download | opie-d6e8e6bf49bb176ec54efed5eb0d012098f056d7.zip opie-d6e8e6bf49bb176ec54efed5eb0d012098f056d7.tar.gz opie-d6e8e6bf49bb176ec54efed5eb0d012098f056d7.tar.bz2 |
make calc2 a subdir project
Diffstat (limited to 'noncore/tools/calc2/main/calc.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/tools/calc2/main/calc.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/noncore/tools/calc2/main/calc.cpp b/noncore/tools/calc2/main/calc.cpp new file mode 100644 index 0000000..8c50c2c --- a/dev/null +++ b/noncore/tools/calc2/main/calc.cpp | |||
@@ -0,0 +1,103 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include <qvaluelist.h> | ||
22 | #include <qpe/qpeapplication.h> | ||
23 | #include <qdir.h> | ||
24 | #include <qwidgetstack.h> | ||
25 | |||
26 | #include "calc.h" | ||
27 | #include "plugininterface.h" | ||
28 | |||
29 | calc::calc (QWidget * p, const char *n):QWidget (p, n) | ||
30 | { | ||
31 | setCaption (tr ("Calculator")); | ||
32 | |||
33 | // widgets | ||
34 | LCD = new QLCDNumber (this); | ||
35 | LCD->setMaximumSize (QSize (240, 30)); | ||
36 | LCD->setNumDigits(12); | ||
37 | LCD->setSegmentStyle(QLCDNumber::Filled); | ||
38 | pluginWidgetStack = new QWidgetStack (this); | ||
39 | |||
40 | // layout widgets | ||
41 | calculatorLayout = new QVBoxLayout (this); | ||
42 | calculatorLayout->addWidget (LCD); | ||
43 | calculatorLayout->addWidget (pluginWidgetStack); | ||
44 | |||
45 | // no formatting of display for now | ||
46 | connect (&engine, SIGNAL(display(double)), LCD, SLOT(display(double))); | ||
47 | connect (&engine, SIGNAL(display(const QString&)), LCD, SLOT(display(const QString&))); | ||
48 | connect (&engine, SIGNAL(setBinMode()), LCD, SLOT(setBinMode())); | ||
49 | connect (&engine, SIGNAL(setOctMode()), LCD, SLOT(setOctMode())); | ||
50 | connect (&engine, SIGNAL(setDecMode()), LCD, SLOT(setDecMode())); | ||
51 | connect (&engine, SIGNAL(setHexMode()), LCD, SLOT(setHexMode())); | ||
52 | |||
53 | #ifndef NO_PLUGINS | ||
54 | // load plugins | ||
55 | QValueList < Plugin >::Iterator mit; | ||
56 | for (mit = pluginList.begin (); mit != pluginList.end (); ++mit) { | ||
57 | (*mit).interface->release (); | ||
58 | (*mit).library->unload (); | ||
59 | delete (*mit).library; | ||
60 | } | ||
61 | pluginList.clear (); | ||
62 | |||
63 | QString path = QPEApplication::qpeDir() + "plugins/calculator"; | ||
64 | QDir dir (path, "lib*.so"); | ||
65 | QStringList list = dir.entryList (); | ||
66 | |||
67 | QStringList::Iterator it; | ||
68 | for (it = list.begin (); it != list.end (); ++it) { | ||
69 | CalcInterface *iface = 0; | ||
70 | QLibrary *lib = new QLibrary (path + "/" + *it); | ||
71 | Plugin plugin; | ||
72 | plugin.pluginWidget = 0; | ||
73 | |||
74 | if (lib->queryInterface (IID_Calc, (QUnknownInterface **) & iface) == | ||
75 | QS_OK) { | ||
76 | plugin.library = lib; | ||
77 | plugin.interface = iface; | ||
78 | plugin.pluginWidget = plugin.interface->getPlugin(&engine,pluginWidgetStack); | ||
79 | if (plugin.pluginWidget) | ||
80 | pluginWidgetStack->addWidget (plugin.pluginWidget, pluginList.count()); | ||
81 | pluginList.append (plugin); | ||
82 | } else { | ||
83 | delete lib; | ||
84 | } | ||
85 | } | ||
86 | setMode (1); | ||
87 | #else | ||
88 | // load simple interface | ||
89 | #endif | ||
90 | } | ||
91 | |||
92 | calc::~calc () | ||
93 | { | ||
94 | #ifndef NO_PLUGINS | ||
95 | QValueList < Plugin >::Iterator mit; | ||
96 | for (mit = pluginList.begin (); mit != pluginList.end (); ++mit) { | ||
97 | (*mit).interface->release (); | ||
98 | (*mit).library->unload (); | ||
99 | delete (*mit).library; | ||
100 | } | ||
101 | #endif | ||
102 | } | ||
103 | |||