summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-bartender/bartender.cpp235
-rw-r--r--noncore/apps/opie-bartender/bartender.h5
-rw-r--r--noncore/apps/opie-bartender/bartender.pro10
-rw-r--r--noncore/apps/opie-bartender/drinkdata.cpp147
-rw-r--r--noncore/apps/opie-bartender/drinkdata.h48
-rw-r--r--noncore/apps/opie-bartender/newDrinks.ui4
-rw-r--r--noncore/apps/opie-bartender/newdrinks.cpp1
-rw-r--r--noncore/apps/opie-bartender/showdrinks.cpp1
-rw-r--r--noncore/apps/opie-bartender/showdrinks.h2
9 files changed, 309 insertions, 144 deletions
diff --git a/noncore/apps/opie-bartender/bartender.cpp b/noncore/apps/opie-bartender/bartender.cpp
index b4958b3..bee164c 100644
--- a/noncore/apps/opie-bartender/bartender.cpp
+++ b/noncore/apps/opie-bartender/bartender.cpp
@@ -1,435 +1,400 @@
1/**************************************************************************** 1/****************************************************************************
2** 2**
3** Created: Sat Jul 20 08:10:53 2002 3** Created: Sat Jul 20 08:10:53 2002
4** by: L.J. Potter <ljp@llornkcor.com> 4** by: L.J. Potter <ljp@llornkcor.com>
5** copyright : (C) 2002 by ljp 5** copyright : (C) 2002 by ljp
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 ***************************************************************************/ 11 ***************************************************************************/
12 12
13#include "bartender.h" 13#include "bartender.h"
14#include "showdrinks.h" 14#include "showdrinks.h"
15#include "inputDialog.h" 15#include "inputDialog.h"
16#include "searchresults.h" 16#include "searchresults.h"
17#include "bac.h" 17#include "bac.h"
18#include "drinkdata.h"
18 19
19/* OPIE */ 20/* OPIE */
20#include <opie2/odebug.h> 21#include <opie2/odebug.h>
21#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
22#include <qpe/resource.h> 23#include <qpe/resource.h>
23using namespace Opie::Core; 24using namespace Opie::Core;
24 25
25/* QT */ 26/* QT */
26#include <qlineedit.h> 27#include <qlineedit.h>
27#include <qdir.h> 28#include <qdir.h>
28#include <qpushbutton.h> 29#include <qpushbutton.h>
29#include <qlistbox.h> 30#include <qlistbox.h>
30#include <qmultilineedit.h> 31#include <qmultilineedit.h>
31#include <qmessagebox.h> 32#include <qmessagebox.h>
32#include <qtextstream.h> 33#include <qtextstream.h>
33#include <qaction.h> 34#include <qaction.h>
34#include <qheader.h> 35#include <qheader.h>
35#include <qlistview.h> 36#include <qlistview.h>
36#include <qlayout.h> 37#include <qlayout.h>
37#include <qtoolbar.h> 38#include <qtoolbar.h>
38#include <qmenubar.h> 39#include <qmenubar.h>
39 40
40/* STD */ 41/* STD */
41#include <fcntl.h> 42#include <fcntl.h>
42#include <unistd.h> 43#include <unistd.h>
43#include <stdlib.h> 44#include <stdlib.h>
44#include <stdio.h> 45#include <stdio.h>
45#include <errno.h> 46#include <errno.h>
46 47
47Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) 48Bartender::Bartender( QWidget* parent, const char* name, WFlags fl )
48 : QMainWindow( parent, name, fl ) { 49 : QMainWindow( parent, name, fl ) {
49 if ( !name ) 50 if ( !name )
50 setName( "Bartender" ); 51 setName( "Bartender" );
51 QGridLayout *layout = new QGridLayout( this ); 52 QGridLayout *layout = new QGridLayout( this );
52 layout->setSpacing( 2); 53 layout->setSpacing( 2);
53 layout->setMargin( 2); 54 layout->setMargin( 2);
54 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 55 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
55 56
56 setCaption( tr( "Bartender" ) ); 57 setCaption( tr( "Bartender" ) );
57 58
59 setToolBarsMovable( FALSE );
60
58 ToolBar1 = new QToolBar( this, "ToolBar1" ); 61 ToolBar1 = new QToolBar( this, "ToolBar1" );
59 ToolBar1->setFixedHeight(22); 62 ToolBar1->setFixedHeight(22);
60 layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 ); 63 layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 );
61 64
62 QMenuBar *menuBar = new QMenuBar( ToolBar1 ); 65 QMenuBar *menuBar = new QMenuBar( ToolBar1 );
63 QPopupMenu *fileMenu; 66 QPopupMenu *fileMenu;
64 fileMenu = new QPopupMenu( this); 67 fileMenu = new QPopupMenu( this);
65 menuBar->insertItem( tr("File"), fileMenu ); 68 menuBar->insertItem( tr("File"), fileMenu );
66 69
67 fileMenu->insertItem(tr("New Drink")); 70 fileMenu->insertItem(tr("New Drink"));
68 fileMenu->insertItem(tr("Open Drink")); 71 fileMenu->insertItem(tr("Open Drink"));
69 fileMenu->insertItem(tr("Find by Drink Name")); 72 fileMenu->insertItem(tr("Find by Drink Name"));
70 fileMenu->insertItem(tr("Find by Alcohol")); 73 fileMenu->insertItem(tr("Find by Ingredient"));
71 74
72 QPopupMenu *editMenu; 75 QPopupMenu *editMenu;
73 editMenu = new QPopupMenu( this); 76 editMenu = new QPopupMenu( this);
74 menuBar->insertItem( tr("Edit"), editMenu ); 77 menuBar->insertItem( tr("Edit"), editMenu );
75 editMenu->insertItem(tr("edit")); 78 editMenu->insertItem(tr("Edit Drink"));
76 79
77 connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); 80 connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) ));
78 connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); 81 connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) ));
79 82
80 83
81 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); 84 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 );
82 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 85 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
83 a->addTo( ToolBar1 ); 86 a->addTo( ToolBar1 );
84 87
85 a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); 88 a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 );
86 connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); 89 connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) );
87 a->addTo( ToolBar1 ); 90 a->addTo( ToolBar1 );
88 91
89 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); 92 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 );
90 connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); 93 connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) );
91 a->addTo( ToolBar1 ); 94 a->addTo( ToolBar1 );
92 95
93 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); 96 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 );
94 connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); 97 connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) );
95 a->addTo( ToolBar1 ); 98 a->addTo( ToolBar1 );
96 99
97 QPushButton *t; 100 QPushButton *t;
98 t= new QPushButton( "BAC", ToolBar1, "bacButtin"); 101 t= new QPushButton( "BAC", ToolBar1, "bacButtin");
99 connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); 102 connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) );
100 103
101 DrinkView = new QListView( this, "DrinkView" ); 104 DrinkView = new QListView( this, "DrinkView" );
102 DrinkView->addColumn( tr( "Name of Drink" ) ); 105 DrinkView->addColumn( tr( "Name of Drink" ) );
103// DrinkView->setRootIsDecorated( TRUE ); 106// DrinkView->setRootIsDecorated( TRUE );
104 DrinkView->header()->hide(); 107 DrinkView->header()->hide();
105 108
106 QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); 109 QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold);
107 110
108 connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*))); 111 connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*)));
109 connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 112 connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
110 this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int))); 113 this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int)));
111 114
112 layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); 115 layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 );
113 if(QDir("db").exists()) { 116 if(QDir("db").exists())
114 dbFile.setName( "db/drinkdb.txt"); 117 drinkDB.setFile("db/drinkdb.txt");
115 } else 118 else
116 dbFile.setName( QPEApplication::qpeDir()+"etc/bartender/drinkdb.txt"); 119 drinkDB.setFile(QPEApplication::qpeDir()+"etc/bartender/drinkdb.txt");
120
117 initDrinkDb(); 121 initDrinkDb();
122
123 DrinkView->setFocus();
118} 124}
119 125
120Bartender::~Bartender() { 126Bartender::~Bartender() {
121} 127}
122 128
123/* 129/*
124this happens right before exit */ 130this happens right before exit */
125void Bartender::cleanUp() { 131void Bartender::cleanUp() {
126 dbFile.close();
127 132
128} 133}
129 134
130void Bartender::initDrinkDb() { 135void Bartender::initDrinkDb() {
131 136 if(drinkDB.read())
132 if(!dbFile.isOpen()) 137 fillList();
133 if ( !dbFile.open( IO_ReadOnly)) { 138 else
134 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); 139 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) );
135 return;
136 }
137 fillList();
138} 140}
139 141
140void Bartender::fillList() { 142void Bartender::fillList() {
141 dbFile.at(1); 143 QString lastName;
144 if( DrinkView->currentItem() != NULL )
145 lastName = DrinkView->currentItem()->text(0);
146 else
147 lastName = "";
148
142 DrinkView->clear(); 149 DrinkView->clear();
143 int i=0; 150 int i=0;
144 QListViewItem * item ; 151 QListViewItem * item ;
145 QTextStream t( &dbFile);
146 QString s; 152 QString s;
147 while ( !t.eof()) { 153
148 s = t.readLine(); 154 DrinkList::Iterator it = drinkDB.getBegin();
149 if(s.find("#",0,TRUE) != -1) { 155 while ( it != drinkDB.getEnd() ) {
150// odebug << s.right(s.length()-2) << oendl; 156 item= new QListViewItem( DrinkView, 0 );
151 item= new QListViewItem( DrinkView, 0 ); 157 item->setText( 0, (*it).getName());
152 item->setText( 0, s.right(s.length()-2)); 158 i++;
153 i++; 159 ++it;
160 }
161
162 if( lastName != "" ) {
163 QListViewItemIterator it( DrinkView );
164 for ( ; it.current(); ++it ) {
165 if ( it.current()->text(0) == lastName ) {
166 DrinkView->setCurrentItem(it.current());
167 break;
168 }
154 } 169 }
155 } 170 }
171 else if( DrinkView->childCount() > 0)
172 DrinkView->setCurrentItem(DrinkView->firstChild());
173
156 odebug << "there are currently " << i << " of drinks" << oendl; 174 odebug << "there are currently " << i << " of drinks" << oendl;
157} 175}
158 176
159void Bartender::fileNew() { 177void Bartender::fileNew() {
160 178
161 New_Drink *newDrinks; 179 New_Drink *newDrinks;
162 newDrinks = new New_Drink(this,"New Drink....", TRUE); 180 newDrinks = new New_Drink(this,"New Drink", TRUE);
163 QString newName, newIng; 181 QString newName, newIng;
164 QPEApplication::execDialog( newDrinks ); 182 QPEApplication::execDialog( newDrinks );
165 newName = newDrinks->LineEdit1->text(); 183 newName = newDrinks->LineEdit1->text();
166 newIng= newDrinks->MultiLineEdit1->text(); 184 newIng= newDrinks->MultiLineEdit1->text();
167 185
168 if(dbFile.isOpen())
169 dbFile.close();
170 if ( !dbFile.open( IO_WriteOnly| IO_Append)) {
171 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) );
172 return;
173 }
174 if(newDrinks ->result() == 1 ) { 186 if(newDrinks ->result() == 1 ) {
175 QString newDrink="\n# "+newName+"\n"; 187 drinkDB.addDrink(newName, newIng);
176 newDrink.append(newIng+"\n"); 188 if(!drinkDB.writeChanges()) {
177 odebug << "writing "+newDrink << oendl; 189 QMessageBox::message( (tr("Note")), (tr("Failed to write to drink database!\n")) );
178 dbFile.writeBlock( newDrink.latin1(), newDrink.length()); 190 }
179 clearList(); 191 fillList();
180 dbFile.close();
181
182 initDrinkDb();
183 } 192 }
184 delete newDrinks; 193 delete newDrinks;
185} 194}
186 195
187void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) { 196void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) {
188 switch (mouse) { 197 switch (mouse) {
189 case 1: 198 case 1:
190// showDrink(item); 199// showDrink(item);
191 break; 200 break;
192 case 2: 201 case 2:
193 showDrink(item); 202 showDrink(item);
194 break; 203 break;
195 } 204 }
196} 205}
197 206
198void Bartender::showDrink( QListViewItem *item) { 207void Bartender::showDrink( QListViewItem *item) {
199 if(item==NULL) return; 208 if(item==NULL) return;
200 dbFile.at(0);
201 Show_Drink *showDrinks; 209 Show_Drink *showDrinks;
202 QString myDrink=item->text(0); 210 QString myDrink=item->text(0);
203 showDrinks = new Show_Drink(this, myDrink, TRUE); 211 showDrinks = new Show_Drink(this, myDrink, TRUE);
204 QTextStream t( &dbFile);
205
206 QString s, s2;
207 while ( !t.eof()) {
208 s = t.readLine();
209 if(s.find( myDrink, 0, TRUE) != -1) {
210 for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) {
211 s2 = t.readLine();
212 if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) {
213// odebug << s2 << oendl;
214 showDrinks->MultiLineEdit1->append(s2);
215 }
216 if( dbFile.atEnd() ) break;
217 }
218 }
219 }
220 QPEApplication::execDialog( showDrinks );
221 212
222 if(showDrinks ->result() ==0) { 213 DrinkList::Iterator it = drinkDB.findDrink(myDrink);
223 doEdit(); 214 if(it != drinkDB.getEnd()) {
215 showDrinks->MultiLineEdit1->setText((*it).getIngredients());
216
217 connect(showDrinks->editDrinkButton, SIGNAL(clicked()), this, SLOT(doEdit()));
218 QPEApplication::execDialog( showDrinks );
224 } 219 }
220
225 delete showDrinks; 221 delete showDrinks;
226} 222}
227 223
228void Bartender::askSearch() { 224void Bartender::askSearch() {
229 switch ( QMessageBox::warning(this,tr("Find"),tr("Search by drink name\n")+ 225 switch ( QMessageBox::warning(this,tr("Find"),tr("Search by drink name\n")+
230 "\nor alcohol ?" 226 "\nor ingredient ?"
231 ,tr("Drink Name"),tr("Alcohol"),0,0,1) ) { 227 ,tr("Drink Name"),tr("Ingredient"),0,0,1) ) {
232 case 0: 228 case 0:
233 doSearchByName(); 229 doSearchByName();
234 break; 230 break;
235 case 1: 231 case 1:
236 doSearchByDrink(); 232 doSearchByIngredient();
237 break; 233 break;
238 }; 234 };
239} 235}
240 236
241/* search by name */ 237/* search by name */
242void Bartender::doSearchByName() { 238void Bartender::doSearchByName() {
243// if( DrinkView->currentItem() == NULL) return; 239// if( DrinkView->currentItem() == NULL) return;
244 QStringList searchList; 240 QStringList searchList;
245 QString searchForDrinkName; 241 QString searchForDrinkName;
246 InputDialog *fileDlg; 242 InputDialog *fileDlg;
247 fileDlg = new InputDialog(this,tr("Find by Drink Name"),TRUE, 0); 243 fileDlg = new InputDialog(this,tr("Find by Drink Name"),TRUE, 0);
248 fileDlg->exec(); 244 fileDlg->exec();
249 if( fileDlg->result() == 1 ) { 245 if( fileDlg->result() == 1 ) {
250 searchForDrinkName = fileDlg->LineEdit1->text(); 246 searchForDrinkName = fileDlg->LineEdit1->text();
251 QListViewItemIterator it( DrinkView ); 247 QListViewItemIterator it( DrinkView );
252 for ( ; it.current(); ++it ) { 248 for ( ; it.current(); ++it ) {
253 if ( it.current()->text(0).find( searchForDrinkName, 0, TRUE) != -1 ) { 249 if ( it.current()->text(0).find( searchForDrinkName, 0, FALSE) != -1 ) {
254// odebug << it.current()->text(0) << oendl; 250// odebug << it.current()->text(0) << oendl;
255 searchList.append(it.current()->text(0)); 251 searchList.append(it.current()->text(0));
256 } 252 }
257 } 253 }
258 if(searchList.count() >0) 254 if(searchList.count() >0)
259 showSearchResult(searchList); 255 showSearchResult(searchList);
260 else 256 else
261 QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+searchForDrinkName); 257 QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+searchForDrinkName);
262 }//end Inputdialog 258 }//end Inputdialog
263 delete fileDlg; 259 delete fileDlg;
264} 260}
265 261
266void Bartender::doSearchByDrink() { 262void Bartender::doSearchByIngredient() {
267// if( DrinkView->currentItem() == NULL) return; 263// if( DrinkView->currentItem() == NULL) return;
268 QStringList searchList; 264 QStringList searchList;
269 QString searchForDrinkName, lastDrinkName, tempName; 265 QString searchForIngredient, lastDrinkName, lastDrinkIngredients;
270 266
271 InputDialog *fileDlg; 267 InputDialog *fileDlg;
272 fileDlg = new InputDialog(this,tr("Find by Alcohol"),TRUE, 0); 268 fileDlg = new InputDialog(this,tr("Find by Ingredient"),TRUE, 0);
273 fileDlg->exec(); 269 fileDlg->exec();
274 if( fileDlg->result() == 1 ) { 270 if( fileDlg->result() == 1 ) {
275 searchForDrinkName = fileDlg->LineEdit1->text(); 271 searchForIngredient = fileDlg->LineEdit1->text();
276 272
277 dbFile.at(0); 273 DrinkList::Iterator it = drinkDB.getBegin();
278 QTextStream t( &dbFile); 274 while ( it != drinkDB.getEnd() ) {
279 275 lastDrinkName = (*it).getName();
280 QString s, s2; 276 lastDrinkIngredients = (*it).getIngredients();
281 while ( !t.eof()) { 277
282 s = t.readLine(); 278 if( lastDrinkIngredients.find( searchForIngredient ,0, FALSE) != -1 )
283 if(s.find("#",0,TRUE) != -1) { 279 searchList.append( lastDrinkName );
284 lastDrinkName=s.right(s.length()-2); 280
285// odebug << "last drink name "+lastDrinkName << oendl; 281 ++it;
286 } 282 }
287 else if( s.find( searchForDrinkName ,0, FALSE) != -1 && lastDrinkName != tempName ) { 283
288// odebug << "appending "+lastDrinkName << oendl;
289 searchList.append( lastDrinkName);
290 tempName=lastDrinkName;
291 }
292// if( dbFile.atEnd() ) break;
293
294 } //oef
295 if(searchList.count() >0) 284 if(searchList.count() >0)
296 showSearchResult(searchList); 285 showSearchResult(searchList);
297 else 286 else
298 QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+ searchForDrinkName); 287 QMessageBox::message(tr("Search"),tr("Sorry no results for\n")+ searchForIngredient);
299 } 288 }
300 delete fileDlg; 289 delete fileDlg;
301} 290}
302 291
303void Bartender::showSearchResult(QStringList &searchList) { 292void Bartender::showSearchResult(QStringList &searchList) {
304 QString result; 293 QString result;
305 Search_Results *searchDlg; 294 Search_Results *searchDlg;
306 295
307 searchList.sort(); 296 searchList.sort();
308 297
309 searchDlg = new Search_Results(this, "Search Results", TRUE); 298 searchDlg = new Search_Results(this, "Search Results", TRUE);
310 searchDlg->ListBox1->insertStringList( searchList,-1); 299 searchDlg->ListBox1->insertStringList( searchList,-1);
311 QPEApplication::execDialog( searchDlg ); 300 QPEApplication::execDialog( searchDlg );
312 301
313 if( searchDlg->result() == 1 ) { 302 if( searchDlg->result() == 1 ) {
314 result= searchDlg->ListBox1->currentText(); 303 result= searchDlg->ListBox1->currentText();
315 } 304 }
316 QListViewItemIterator it2( DrinkView ); 305 QListViewItemIterator it2( DrinkView );
317 for ( ; it2.current(); ++it2 ) { 306 for ( ; it2.current(); ++it2 ) {
318 if ( it2.current()->text(0)== result ) { 307 if ( it2.current()->text(0)== result ) {
319// odebug << it2.current()->text(0) << oendl; 308// odebug << it2.current()->text(0) << oendl;
320 showDrink(it2.current()); 309 showDrink(it2.current());
321 } 310 }
322 } 311 }
323delete searchDlg; 312delete searchDlg;
324} 313}
325 314
326void Bartender::doEdit() { 315void Bartender::doEdit() {
327 if(DrinkView->currentItem() == NULL) { 316 if(DrinkView->currentItem() == NULL) {
328 fileNew(); 317 fileNew();
329 } 318 return;
319 }
330 320
331 QString myDrink; 321 QString myDrink;
332 myDrink= DrinkView->currentItem()->text(0); 322 myDrink= DrinkView->currentItem()->text(0);
333 dbFile.at(0); 323
334 int foundAt=0;
335 New_Drink *newDrinks; 324 New_Drink *newDrinks;
336 newDrinks = new New_Drink(this,"Edit Drink....", TRUE); 325 newDrinks = new New_Drink(this,"Edit Drink", TRUE);
337 QString newName, newIng; 326 QString newName, newIng;
338 QPEApplication::showDialog( newDrinks ); 327 QPEApplication::showDialog( newDrinks );
339 QTextStream t( &dbFile);
340
341 QString s, s2;
342 while ( !t.eof()) {
343 s = t.readLine();
344 if(s.find( myDrink, 0, TRUE) != -1) {
345 foundAt = dbFile.at() - (s.length()+1);
346 for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) {
347 s2 = t.readLine();
348 if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) {
349// odebug << s2 << oendl;
350 newDrinks->MultiLineEdit1->append(s2);
351 newDrinks->LineEdit1->setText(myDrink);
352 }
353 if( dbFile.atEnd() ) break;
354 }
355 }
356 }
357 newDrinks->exec();
358 newName = newDrinks->LineEdit1->text();
359 newIng= newDrinks->MultiLineEdit1->text();
360 328
361 if( newDrinks ->result() == 1 ) { 329 DrinkList::Iterator drinkItem = drinkDB.findDrink(myDrink);
362 if(dbFile.isOpen()) 330 if(drinkItem != drinkDB.getEnd()) {
363 dbFile.close(); 331 newDrinks->LineEdit1->setText((*drinkItem).getName());
364 if ( !dbFile.open( IO_ReadWrite )) { 332 newDrinks->MultiLineEdit1->setText((*drinkItem).getIngredients());
365 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); 333
366 return; 334 newDrinks->exec();
335 newName = newDrinks->LineEdit1->text();
336 newIng= newDrinks->MultiLineEdit1->text();
337
338 if( newDrinks ->result() == 1 ) {
339 (*drinkItem).setName(newName);
340 (*drinkItem).setIngredients(newIng);
341 if(!drinkDB.writeChanges()) {
342 QMessageBox::message( (tr("Note")), (tr("Failed to write to drink database!\n")) );
343 }
344 fillList();
367 } 345 }
368 int fd = dbFile.handle();
369 lseek( fd, foundAt, SEEK_SET);
370
371// dbFile.at( foundAt);
372#warning FIXME problems with editing drinks db
373 ////////// FIXME write to user file
374 QString newDrink="# "+newName+"\n";
375 newDrink.append(newIng+"\n");
376 odebug << "writing "+newDrink << oendl;
377 dbFile.writeBlock( newDrink.latin1(), newDrink.length());
378 clearList();
379
380 dbFile.flush();
381
382 initDrinkDb();
383 } 346 }
347
348 delete newDrinks;
384} 349}
385 350
386void Bartender::clearList() { 351void Bartender::clearList() {
387 DrinkView->clear(); 352 DrinkView->clear();
388} 353}
389 354
390void Bartender::doBac() { 355void Bartender::doBac() {
391 BacDialog *bacDlg; 356 BacDialog *bacDlg;
392 bacDlg = new BacDialog(this,"BAC",TRUE); 357 bacDlg = new BacDialog(this,"BAC",TRUE);
393 QPEApplication::execDialog( bacDlg ); 358 QPEApplication::execDialog( bacDlg );
394 delete bacDlg; 359 delete bacDlg;
395} 360}
396 361
397void Bartender::openCurrentDrink() { 362void Bartender::openCurrentDrink() {
398 if(DrinkView->currentItem() == NULL) return; 363 if(DrinkView->currentItem() == NULL) return;
399 showDrink(DrinkView->currentItem()); 364 showDrink(DrinkView->currentItem());
400} 365}
401 366
402void Bartender::fileMenuActivated( int item) { 367void Bartender::fileMenuActivated( int item) {
403 odebug << "Item " << item << "" << oendl; 368 odebug << "Item " << item << "" << oendl;
404 switch(item) { 369 switch(item) {
405 case -3: // new -3 370 case -3: // new -3
406 fileNew(); 371 fileNew();
407 break; 372 break;
408 case -4:// open -4 373 case -4:// open -4
409 openCurrentDrink(); 374 openCurrentDrink();
410 break; 375 break;
411 case -5:// drink -5 376 case -5:// drink -5
412 doSearchByName(); 377 doSearchByName();
413 378
414 break; 379 break;
415 case -6:// alcohol -6 380 case -6:// alcohol -6
416 doSearchByDrink(); 381 doSearchByIngredient();
417 382
418 break; 383 break;
419 384
420 } 385 }
421} 386}
422 387
423void Bartender::editMenuActivated(int item) { 388void Bartender::editMenuActivated(int item) {
424 odebug << "Item " << item << "" << oendl; 389 odebug << "Item " << item << "" << oendl;
425 /* 390 /*
426 edit -8 391 edit -8
427 */ 392 */
428 switch(item) { 393 switch(item) {
429 case -8: 394 case -8:
430 doEdit() ; 395 doEdit() ;
431 break; 396 break;
432 397
433 } 398 }
434} 399}
435 400
diff --git a/noncore/apps/opie-bartender/bartender.h b/noncore/apps/opie-bartender/bartender.h
index 27362df..9970ef1 100644
--- a/noncore/apps/opie-bartender/bartender.h
+++ b/noncore/apps/opie-bartender/bartender.h
@@ -1,65 +1,66 @@
1/**************************************************************************** 1/****************************************************************************
2** Created: Sat Jul 20 08:10:31 2002 2** Created: Sat Jul 20 08:10:31 2002
3** by: L.J. Potter <ljp@llornkcor.com> 3** by: L.J. Potter <ljp@llornkcor.com>
4** copyright : (C) 2002 by ljp 4** copyright : (C) 2002 by ljp
5 email : ljp@llornkcor.com 5 email : ljp@llornkcor.com
6 * This program is free software; you can redistribute it and/or modify * 6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by * 7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or * 8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. * 9 * (at your option) any later version. *
10 ***************************************************************************/ 10 ***************************************************************************/
11#ifndef BARTENDER_H 11#ifndef BARTENDER_H
12#define BARTENDER_H 12#define BARTENDER_H
13#include "newdrinks.h" 13#include "newdrinks.h"
14#include "drinkdata.h"
14 15
15#include <qvariant.h> 16#include <qvariant.h>
16#include <qwidget.h> 17#include <qwidget.h>
17#include <qmainwindow.h> 18#include <qmainwindow.h>
18#include <qfile.h> 19#include <qfile.h>
19 20
20class QVBoxLayout; 21class QVBoxLayout;
21class QHBoxLayout; 22class QHBoxLayout;
22class QGridLayout; 23class QGridLayout;
23class QListView; 24class QListView;
24class QListViewItem; 25class QListViewItem;
25class QToolBar; 26class QToolBar;
26 27
27class Bartender : public QMainWindow 28class Bartender : public QMainWindow
28{ 29{
29 Q_OBJECT 30 Q_OBJECT
30 31
31public: 32public:
32 Bartender( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 33 Bartender( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
33 ~Bartender(); 34 ~Bartender();
34 35
35 static QString appName() { return QString::fromLatin1("bartender"); } 36 static QString appName() { return QString::fromLatin1("bartender"); }
36 37
37 QToolBar* ToolBar1; 38 QToolBar* ToolBar1;
38 QListView* DrinkView; 39 QListView* DrinkView;
39 QFile dbFile; 40 DrinkData drinkDB;
40public slots: 41public slots:
41 void doEdit(); 42 void doEdit();
42 43
43protected: 44protected:
44 45
45protected slots: 46protected slots:
46 void fileMenuActivated(int); 47 void fileMenuActivated(int);
47 void editMenuActivated(int); 48 void editMenuActivated(int);
48 void cleanUp(); 49 void cleanUp();
49 void fileNew(); 50 void fileNew();
50 void showDrink( QListViewItem *); 51 void showDrink( QListViewItem *);
51 void showDrink(int, QListViewItem *, const QPoint&, int); 52 void showDrink(int, QListViewItem *, const QPoint&, int);
52 void initDrinkDb(); 53 void initDrinkDb();
53 void doSearchByName(); 54 void doSearchByName();
54 void doSearchByDrink(); 55 void doSearchByIngredient();
55 void showSearchResult(QStringList &); 56 void showSearchResult(QStringList &);
56 void doBac(); 57 void doBac();
57 void openCurrentDrink(); 58 void openCurrentDrink();
58 void askSearch(); 59 void askSearch();
59private: 60private:
60 void clearList(); 61 void clearList();
61 void fillList(); 62 void fillList();
62 63
63}; 64};
64 65
65#endif // BARTENDER_H 66#endif // BARTENDER_H
diff --git a/noncore/apps/opie-bartender/bartender.pro b/noncore/apps/opie-bartender/bartender.pro
index cdec93c..b304ae9 100644
--- a/noncore/apps/opie-bartender/bartender.pro
+++ b/noncore/apps/opie-bartender/bartender.pro
@@ -1,9 +1,11 @@
1CONFIG = qt quick-app 1TEMPLATE = app
2HEADERS = bartender.h newdrinks.h showdrinks.h inputDialog.h searchresults.h bac.h 2CONFIG = qt warn_on
3SOURCES = main.cpp bartender.cpp newdrinks.cpp showdrinks.cpp inputDialog.cpp searchresults.cpp bac.cpp 3HEADERS = bartender.h newdrinks.h showdrinks.h inputDialog.h searchresults.h bac.h drinkdata.h
4SOURCES = main.cpp bartender.cpp newdrinks.cpp showdrinks.cpp inputDialog.cpp searchresults.cpp bac.cpp drinkdata.cpp
4INCLUDEPATH += $(OPIEDIR)/include 5INCLUDEPATH += $(OPIEDIR)/include
5DEPENDPATH += $(OPIEDIR)/include 6DEPENDPATH += $(OPIEDIR)/include
6LIBS += -lqpe -lopiecore2 7LIBS += -lqpe -lopiecore2 -lopieui2
8DESTDIR = $(OPIEDIR)/bin
7TARGET = bartender 9TARGET = bartender
8 10
9include( $(OPIEDIR)/include.pro ) 11include( $(OPIEDIR)/include.pro )
diff --git a/noncore/apps/opie-bartender/drinkdata.cpp b/noncore/apps/opie-bartender/drinkdata.cpp
new file mode 100644
index 0000000..8856e46
--- a/dev/null
+++ b/noncore/apps/opie-bartender/drinkdata.cpp
@@ -0,0 +1,147 @@
1/****************************************************************************
2** Created: Sun Dec 26 22:00:00 2004
3** by: Paul Eggleton <bluelightning@bluelightning.org>
4** copyright : (C) 2004 by Paul Eggleton
5 email : bluelightning@bluelightning.org
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 ***************************************************************************/
11
12/* QT */
13#include <qfile.h>
14#include <qtextstream.h>
15#include <qvaluelist.h>
16
17/* STD */
18#include <fcntl.h>
19#include <unistd.h>
20#include <stdlib.h>
21#include <iostream>
22#include <errno.h>
23
24#include "drinkdata.h"
25
26// ----- DrinkData -----
27
28DrinkData::DrinkData() {
29}
30
31void DrinkData::setFile(const QString &filename) {
32 this->filename = filename;
33}
34
35bool DrinkData::read(void) {
36 QFile dbFile;
37
38 dbFile.setName(filename);
39 if ( !dbFile.open( IO_ReadOnly)) {
40 return false;
41 }
42
43 items.clear();
44
45 QTextStream t( &dbFile);
46 QString s, name = "", ingredients = "";
47
48 while ( !t.eof()) {
49 s = t.readLine();
50 if(s.find( "#", 0, TRUE) != -1 || dbFile.atEnd()) {
51 if(name != "")
52 addDrink(name, ingredients);
53 // Start new entry
54 name = s.right(s.length()-2);
55 ingredients = "";
56 }
57 else {
58 if(ingredients != "")
59 ingredients += '\n';
60 ingredients += s;
61 }
62 }
63
64 dbFile.close();
65
66 return true;
67}
68
69void DrinkData::print(void) {
70 DrinkList::Iterator it = items.begin();
71 while ( it != items.end() ) {
72 std::cout << (*it).getName() << '\n';
73 ++it;
74 }
75}
76
77void DrinkData::addDrink(const QString &name, const QString &ingredients) {
78 DrinkItem item(name, ingredients);
79 items.append(item);
80}
81
82DrinkList::Iterator DrinkData::findDrink(const QString &name) {
83 DrinkList::Iterator it = items.begin();
84 while ( it != items.end() ) {
85 if((*it).getName() == name)
86 return it;
87 ++it;
88 }
89 return items.end();
90}
91
92DrinkList::Iterator DrinkData::getBegin(void) {
93 return items.begin();
94}
95
96DrinkList::Iterator DrinkData::getEnd(void) {
97 return items.end();
98}
99
100bool DrinkData::writeChanges(void) {
101 QFile dbFile;
102
103 dbFile.setName(filename);
104 if ( !dbFile.open( IO_WriteOnly | IO_Truncate )) {
105 return false;
106 }
107
108 QTextStream t( &dbFile);
109
110 DrinkList::Iterator it = items.begin();
111 while ( it != items.end() ) {
112 t << "# " << (*it).getName() << '\n';
113 t << (*it).getIngredients() << '\n';
114 ++it;
115 }
116
117 dbFile.close();
118
119 return true;
120}
121
122
123// ----- DrinkItem -----
124
125DrinkItem::DrinkItem(void) {
126}
127
128DrinkItem::DrinkItem(const QString &name, const QString &ingredients) {
129 this->name = name;
130 this->ingredients = ingredients;
131}
132
133const QString &DrinkItem::getName(void) {
134 return name;
135}
136
137const QString &DrinkItem::getIngredients(void) {
138 return ingredients;
139}
140
141void DrinkItem::setName(const QString &name) {
142 this->name = name;
143}
144
145void DrinkItem::setIngredients(const QString &ingredients) {
146 this->ingredients = ingredients;
147}
diff --git a/noncore/apps/opie-bartender/drinkdata.h b/noncore/apps/opie-bartender/drinkdata.h
new file mode 100644
index 0000000..bcc3022
--- a/dev/null
+++ b/noncore/apps/opie-bartender/drinkdata.h
@@ -0,0 +1,48 @@
1/****************************************************************************
2** Created: Sun Dec 26 22:00:00 2004
3** by: Paul Eggleton <bluelightning@bluelightning.org>
4** copyright : (C) 2004 by Paul Eggleton
5 email : bluelightning@bluelightning.org
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 ***************************************************************************/
11
12#ifndef DRINKDATA_H
13#define DRINKDATA_H
14
15class DrinkItem;
16
17typedef QValueList<DrinkItem> DrinkList;
18
19class DrinkData {
20private:
21 DrinkList items;
22 QString filename;
23public:
24 DrinkData(void);
25 void setFile(const QString &filename);
26 bool writeChanges(void);
27 bool read(void);
28 void print(void);
29 void addDrink(const QString &name, const QString &ingredients);
30 DrinkList::Iterator getBegin(void);
31 DrinkList::Iterator getEnd(void);
32 DrinkList::Iterator findDrink(const QString &name);
33};
34
35class DrinkItem {
36private:
37 QString name;
38 QString ingredients;
39public:
40 DrinkItem(void);
41 DrinkItem(const QString &name, const QString &ingredients);
42 const QString &getName(void);
43 const QString &getIngredients(void);
44 void setName(const QString &name);
45 void setIngredients(const QString &ingredients);
46};
47
48#endif // DRINKDATA_H
diff --git a/noncore/apps/opie-bartender/newDrinks.ui b/noncore/apps/opie-bartender/newDrinks.ui
index eccb312..bcf21d2 100644
--- a/noncore/apps/opie-bartender/newDrinks.ui
+++ b/noncore/apps/opie-bartender/newDrinks.ui
@@ -1,38 +1,38 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>New_Drink</class> 2<class>New_Drink</class>
3<widget> 3<widget>
4 <class>QWidget</class> 4 <class>QWidget</class>
5 <property stdset="1"> 5 <property stdset="1">
6 <name>name</name> 6 <name>name</name>
7 <cstring>New_Drink</cstring> 7 <cstring>New_Drink</cstring>
8 </property> 8 </property>
9 <property stdset="1"> 9 <property stdset="1">
10 <name>geometry</name> 10 <name>geometry</name>
11 <rect> 11 <rect>
12 <x>0</x> 12 <x>0</x>
13 <y>0</y> 13 <y>0</y>
14 <width>245</width> 14 <width>241</width>
15 <height>320</height> 15 <height>320</height>
16 </rect> 16 </rect>
17 </property> 17 </property>
18 <property stdset="1"> 18 <property stdset="1">
19 <name>caption</name> 19 <name>caption</name>
20 <string>New Drink</string> 20 <string>New Drink</string>
21 </property> 21 </property>
22 <widget> 22 <widget>
23 <class>QLayoutWidget</class> 23 <class>QLayoutWidget</class>
24 <property stdset="1"> 24 <property stdset="1">
25 <name>name</name> 25 <name>name</name>
26 <cstring>Layout5</cstring> 26 <cstring>Layout5</cstring>
27 </property> 27 </property>
28 <property stdset="1"> 28 <property stdset="1">
29 <name>geometry</name> 29 <name>geometry</name>
30 <rect> 30 <rect>
31 <x>0</x> 31 <x>0</x>
32 <y>15</y> 32 <y>15</y>
33 <width>245</width> 33 <width>245</width>
34 <height>290</height> 34 <height>290</height>
35 </rect> 35 </rect>
36 </property> 36 </property>
37 <grid> 37 <grid>
38 <property stdset="1"> 38 <property stdset="1">
@@ -65,49 +65,49 @@
65 <cstring>TextLabel1</cstring> 65 <cstring>TextLabel1</cstring>
66 </property> 66 </property>
67 <property stdset="1"> 67 <property stdset="1">
68 <name>text</name> 68 <name>text</name>
69 <string>Name</string> 69 <string>Name</string>
70 </property> 70 </property>
71 </widget> 71 </widget>
72 <widget> 72 <widget>
73 <class>QLineEdit</class> 73 <class>QLineEdit</class>
74 <property stdset="1"> 74 <property stdset="1">
75 <name>name</name> 75 <name>name</name>
76 <cstring>LineEdit1</cstring> 76 <cstring>LineEdit1</cstring>
77 </property> 77 </property>
78 </widget> 78 </widget>
79 </hbox> 79 </hbox>
80 </widget> 80 </widget>
81 <widget row="1" column="0" > 81 <widget row="1" column="0" >
82 <class>QLabel</class> 82 <class>QLabel</class>
83 <property stdset="1"> 83 <property stdset="1">
84 <name>name</name> 84 <name>name</name>
85 <cstring>TextLabel2</cstring> 85 <cstring>TextLabel2</cstring>
86 </property> 86 </property>
87 <property stdset="1"> 87 <property stdset="1">
88 <name>text</name> 88 <name>text</name>
89 <string>Ingrediants</string> 89 <string>Ingredients</string>
90 </property> 90 </property>
91 </widget> 91 </widget>
92 <widget row="2" column="0" > 92 <widget row="2" column="0" >
93 <class>QMultiLineEdit</class> 93 <class>QMultiLineEdit</class>
94 <property stdset="1"> 94 <property stdset="1">
95 <name>name</name> 95 <name>name</name>
96 <cstring>MultiLineEdit1</cstring> 96 <cstring>MultiLineEdit1</cstring>
97 </property> 97 </property>
98 </widget> 98 </widget>
99 </grid> 99 </grid>
100 </widget> 100 </widget>
101</widget> 101</widget>
102<customwidgets> 102<customwidgets>
103 <customwidget> 103 <customwidget>
104 <class>QWidget</class> 104 <class>QWidget</class>
105 <header location="global">qwidget.h</header> 105 <header location="global">qwidget.h</header>
106 <sizehint> 106 <sizehint>
107 <width>-1</width> 107 <width>-1</width>
108 <height>-1</height> 108 <height>-1</height>
109 </sizehint> 109 </sizehint>
110 <container>0</container> 110 <container>0</container>
111 <sizepolicy> 111 <sizepolicy>
112 <hordata>5</hordata> 112 <hordata>5</hordata>
113 <verdata>5</verdata> 113 <verdata>5</verdata>
diff --git a/noncore/apps/opie-bartender/newdrinks.cpp b/noncore/apps/opie-bartender/newdrinks.cpp
index a7ada3a..2540fb1 100644
--- a/noncore/apps/opie-bartender/newdrinks.cpp
+++ b/noncore/apps/opie-bartender/newdrinks.cpp
@@ -25,36 +25,37 @@ New_Drink::New_Drink( QWidget* parent, const char* name, bool modal, WFlags fl
25 setCaption( drinkName); 25 setCaption( drinkName);
26 26
27 Layout5 = new QGridLayout( this); 27 Layout5 = new QGridLayout( this);
28 Layout5->setSpacing( 6 ); 28 Layout5->setSpacing( 6 );
29 Layout5->setMargin( 4 ); 29 Layout5->setMargin( 4 );
30 30
31// Layout4 = new QHBoxLayout; 31// Layout4 = new QHBoxLayout;
32// Layout4->setSpacing( 6 ); 32// Layout4->setSpacing( 6 );
33// Layout4->setMargin( 4 ); 33// Layout4->setMargin( 4 );
34 34
35 TextLabel1 = new QLabel( this, "TextLabel1" ); 35 TextLabel1 = new QLabel( this, "TextLabel1" );
36 TextLabel1->setText( tr( "Name" ) ); 36 TextLabel1->setText( tr( "Name" ) );
37 Layout5->addMultiCellWidget( TextLabel1, 0, 0, 0, 0); 37 Layout5->addMultiCellWidget( TextLabel1, 0, 0, 0, 0);
38 38
39 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 39 LineEdit1 = new QLineEdit( this, "LineEdit1" );
40 Layout5->addMultiCellWidget( LineEdit1, 0, 0, 1, 2); 40 Layout5->addMultiCellWidget( LineEdit1, 0, 0, 1, 2);
41 41
42 42
43 TextLabel2 = new QLabel( this, "TextLabel2" ); 43 TextLabel2 = new QLabel( this, "TextLabel2" );
44 TextLabel2->setText( tr( "Ingredients" ) ); 44 TextLabel2->setText( tr( "Ingredients" ) );
45 45
46 Layout5->addMultiCellWidget( TextLabel2, 1, 1, 0, 0); 46 Layout5->addMultiCellWidget( TextLabel2, 1, 1, 0, 0);
47 47
48 MultiLineEdit1 = new QMultiLineEdit( this, "MultiLineEdit1" ); 48 MultiLineEdit1 = new QMultiLineEdit( this, "MultiLineEdit1" );
49 MultiLineEdit1->setWordWrap(QMultiLineEdit::WidgetWidth);
49 50
50 Layout5->addMultiCellWidget( MultiLineEdit1, 2, 2, 0, 2); 51 Layout5->addMultiCellWidget( MultiLineEdit1, 2, 2, 0, 2);
51} 52}
52 53
53/* 54/*
54 * Destroys the object and frees any allocated resources 55 * Destroys the object and frees any allocated resources
55 */ 56 */
56New_Drink::~New_Drink() 57New_Drink::~New_Drink()
57{ 58{
58 // no need to delete child widgets, Qt does it all for us 59 // no need to delete child widgets, Qt does it all for us
59} 60}
60 61
diff --git a/noncore/apps/opie-bartender/showdrinks.cpp b/noncore/apps/opie-bartender/showdrinks.cpp
index dcfce16..9f679f0 100644
--- a/noncore/apps/opie-bartender/showdrinks.cpp
+++ b/noncore/apps/opie-bartender/showdrinks.cpp
@@ -15,33 +15,34 @@
15#include <qpushbutton.h> 15#include <qpushbutton.h>
16#include <qlayout.h> 16#include <qlayout.h>
17 17
18//extern Bartender *bart; 18//extern Bartender *bart;
19 19
20Show_Drink::Show_Drink( QWidget* parent, const char* name, bool modal, WFlags fl ) 20Show_Drink::Show_Drink( QWidget* parent, const char* name, bool modal, WFlags fl )
21 : QDialog( parent, name, modal, fl ) { 21 : QDialog( parent, name, modal, fl ) {
22 if ( !name ) 22 if ( !name )
23 setName( drinkName); 23 setName( drinkName);
24 24
25 drinkName = name; 25 drinkName = name;
26 setCaption( drinkName ); 26 setCaption( drinkName );
27 27
28 Layout5 = new QGridLayout( this); 28 Layout5 = new QGridLayout( this);
29 Layout5->setSpacing( 6 ); 29 Layout5->setSpacing( 6 );
30 Layout5->setMargin( 4 ); 30 Layout5->setMargin( 4 );
31 31
32 32
33 editDrinkButton = new QPushButton( tr("Edit"), this,"editBtn"); 33 editDrinkButton = new QPushButton( tr("Edit"), this,"editBtn");
34 Layout5->addMultiCellWidget( editDrinkButton, 0, 0, 0, 0 ); 34 Layout5->addMultiCellWidget( editDrinkButton, 0, 0, 0, 0 );
35 connect(editDrinkButton, SIGNAL(clicked()), this, SLOT(slotEditDrink())); 35 connect(editDrinkButton, SIGNAL(clicked()), this, SLOT(slotEditDrink()));
36 36
37 MultiLineEdit1 = new QMultiLineEdit( this, "MultiLineEdit1" ); 37 MultiLineEdit1 = new QMultiLineEdit( this, "MultiLineEdit1" );
38 MultiLineEdit1->setWordWrap(QMultiLineEdit::WidgetWidth); 38 MultiLineEdit1->setWordWrap(QMultiLineEdit::WidgetWidth);
39 MultiLineEdit1->setReadOnly(true);
39 Layout5->addMultiCellWidget( MultiLineEdit1, 1, 3, 0, 3 ); 40 Layout5->addMultiCellWidget( MultiLineEdit1, 1, 3, 0, 3 );
40} 41}
41 42
42Show_Drink::~Show_Drink() { 43Show_Drink::~Show_Drink() {
43} 44}
44 45
45void Show_Drink::slotEditDrink() { 46void Show_Drink::slotEditDrink() {
46 reject(); 47 reject();
47} 48}
diff --git a/noncore/apps/opie-bartender/showdrinks.h b/noncore/apps/opie-bartender/showdrinks.h
index 11a0cc1..f892c18 100644
--- a/noncore/apps/opie-bartender/showdrinks.h
+++ b/noncore/apps/opie-bartender/showdrinks.h
@@ -12,33 +12,33 @@
12#define SHOW_DRINK_H 12#define SHOW_DRINK_H
13 13
14#include <qvariant.h> 14#include <qvariant.h>
15#include <qwidget.h> 15#include <qwidget.h>
16#include <qdialog.h> 16#include <qdialog.h>
17 17
18class QVBoxLayout; 18class QVBoxLayout;
19class QHBoxLayout; 19class QHBoxLayout;
20class QGridLayout; 20class QGridLayout;
21class QLabel; 21class QLabel;
22class QLineEdit; 22class QLineEdit;
23class QMultiLineEdit; 23class QMultiLineEdit;
24class QString; 24class QString;
25class QPushButton; 25class QPushButton;
26 26
27class Show_Drink : public QDialog 27class Show_Drink : public QDialog
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30 30
31public: 31public:
32 Show_Drink( QWidget* parent = 0, const char* name = 0, bool modal=TRUE, WFlags fl = 0 ); 32 Show_Drink( QWidget* parent = 0, const char* name = 0, bool modal=TRUE, WFlags fl = 0 );
33 ~Show_Drink(); 33 ~Show_Drink();
34 34
35 QMultiLineEdit* MultiLineEdit1; 35 QMultiLineEdit* MultiLineEdit1;
36 QPushButton *editDrinkButton;
36public slots: 37public slots:
37 void slotEditDrink(); 38 void slotEditDrink();
38protected: 39protected:
39 QGridLayout* Layout5; 40 QGridLayout* Layout5;
40 QString drinkName; 41 QString drinkName;
41 QPushButton *editDrinkButton;
42}; 42};
43 43
44#endif // SHOW_DRINK_H 44#endif // SHOW_DRINK_H