summaryrefslogtreecommitdiff
authordrw <drw>2005-05-17 23:02:25 (UTC)
committer drw <drw>2005-05-17 23:02:25 (UTC)
commitf37c642f417a58ee489ab5a8bab56e5efb59bada (patch) (unidiff)
treea3cf08e41dc605906ec08ce5e47d29776d461410
parent0892a9d473bfeacc921d586266e6889153654737 (diff)
downloadopie-f37c642f417a58ee489ab5a8bab56e5efb59bada.zip
opie-f37c642f417a58ee489ab5a8bab56e5efb59bada.tar.gz
opie-f37c642f417a58ee489ab5a8bab56e5efb59bada.tar.bz2
Resource -> OResource
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-bartender/bartender.cpp36
1 files changed, 19 insertions, 17 deletions
diff --git a/noncore/apps/opie-bartender/bartender.cpp b/noncore/apps/opie-bartender/bartender.cpp
index bee164c..57b28d4 100644
--- a/noncore/apps/opie-bartender/bartender.cpp
+++ b/noncore/apps/opie-bartender/bartender.cpp
@@ -1,147 +1,149 @@
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#include "drinkdata.h"
19 19
20/* OPIE */ 20/* OPIE */
21#include <opie2/odebug.h> 21#include <opie2/odebug.h>
22#include <opie2/oresource.h>
22#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
23#include <qpe/resource.h>
24using namespace Opie::Core; 24using namespace Opie::Core;
25 25
26/* QT */ 26/* QT */
27#include <qlineedit.h> 27#include <qlineedit.h>
28#include <qdir.h> 28#include <qdir.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qlistbox.h> 30#include <qlistbox.h>
31#include <qmultilineedit.h> 31#include <qmultilineedit.h>
32#include <qmessagebox.h> 32#include <qmessagebox.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qaction.h> 34#include <qaction.h>
35#include <qheader.h> 35#include <qheader.h>
36#include <qlistview.h> 36#include <qlistview.h>
37#include <qlayout.h> 37#include <qlayout.h>
38#include <qtoolbar.h> 38#include <qtoolbar.h>
39#include <qmenubar.h> 39#include <qmenubar.h>
40 40
41/* STD */ 41/* STD */
42#include <fcntl.h> 42#include <fcntl.h>
43#include <unistd.h> 43#include <unistd.h>
44#include <stdlib.h> 44#include <stdlib.h>
45#include <stdio.h> 45#include <stdio.h>
46#include <errno.h> 46#include <errno.h>
47 47
48Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) 48Bartender::Bartender( QWidget* parent, const char* name, WFlags fl )
49 : QMainWindow( parent, name, fl ) { 49 : QMainWindow( parent, name, fl ) {
50 if ( !name ) 50 if ( !name )
51 setName( "Bartender" ); 51 setName( "Bartender" );
52 QGridLayout *layout = new QGridLayout( this ); 52
53 layout->setSpacing( 2);
54 layout->setMargin( 2);
55 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 53 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
56 54
57 setCaption( tr( "Bartender" ) ); 55 setCaption( tr( "Bartender" ) );
58 56
59 setToolBarsMovable( FALSE ); 57 setToolBarsMovable( false );
60 58 QToolBar *dock = new QToolBar( this );
61 ToolBar1 = new QToolBar( this, "ToolBar1" ); 59 dock->setHorizontalStretchable( true );
62 ToolBar1->setFixedHeight(22);
63 layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 );
64 60
65 QMenuBar *menuBar = new QMenuBar( ToolBar1 ); 61 QMenuBar *menuBar = new QMenuBar( dock );
62 menuBar->setMargin( 0 );
66 QPopupMenu *fileMenu; 63 QPopupMenu *fileMenu;
67 fileMenu = new QPopupMenu( this); 64 fileMenu = new QPopupMenu( this);
68 menuBar->insertItem( tr("File"), fileMenu ); 65 menuBar->insertItem( tr("File"), fileMenu );
69 66
70 fileMenu->insertItem(tr("New Drink")); 67 fileMenu->insertItem(tr("New Drink"));
71 fileMenu->insertItem(tr("Open Drink")); 68 fileMenu->insertItem(tr("Open Drink"));
72 fileMenu->insertItem(tr("Find by Drink Name")); 69 fileMenu->insertItem(tr("Find by Drink Name"));
73 fileMenu->insertItem(tr("Find by Ingredient")); 70 fileMenu->insertItem(tr("Find by Ingredient"));
74 71
75 QPopupMenu *editMenu; 72 QPopupMenu *editMenu;
76 editMenu = new QPopupMenu( this); 73 editMenu = new QPopupMenu( this);
77 menuBar->insertItem( tr("Edit"), editMenu ); 74 menuBar->insertItem( tr("Edit"), editMenu );
78 editMenu->insertItem(tr("Edit Drink")); 75 editMenu->insertItem(tr("Edit Drink"));
79 76
80 connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); 77 connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) ));
81 connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); 78 connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) ));
82 79
80 ToolBar1 = new QToolBar( this );
83 81
84 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); 82 QAction *a = new QAction( tr( "New" ), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
83 "New", 0, this, 0 );
85 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 84 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
86 a->addTo( ToolBar1 ); 85 a->addTo( ToolBar1 );
87 86
88 a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); 87 a = new QAction( tr( "Open" ), Opie::Core::OResource::loadPixmap( "bartender/bartender_sm", Opie::Core::OResource::SmallIcon ),
88 "open", 0, this, 0 );
89 connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); 89 connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) );
90 a->addTo( ToolBar1 ); 90 a->addTo( ToolBar1 );
91 91
92 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); 92 a = new QAction( tr( "Find" ), Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ),
93 "Find", 0, this, 0 );
93 connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); 94 connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) );
94 a->addTo( ToolBar1 ); 95 a->addTo( ToolBar1 );
95 96
96 a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); 97 a = new QAction( tr( "Edit" ), Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ),
98 "Edit", 0, this, 0 );
97 connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); 99 connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) );
98 a->addTo( ToolBar1 ); 100 a->addTo( ToolBar1 );
99 101
100 QPushButton *t; 102 QPushButton *t;
101 t= new QPushButton( "BAC", ToolBar1, "bacButtin"); 103 t= new QPushButton( "BAC", ToolBar1, "bacButtin");
102 connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); 104 connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) );
103 105
104 DrinkView = new QListView( this, "DrinkView" ); 106 DrinkView = new QListView( this, "DrinkView" );
105 DrinkView->addColumn( tr( "Name of Drink" ) ); 107 DrinkView->addColumn( tr( "Name of Drink" ) );
106// DrinkView->setRootIsDecorated( TRUE );
107 DrinkView->header()->hide(); 108 DrinkView->header()->hide();
108 109
109 QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); 110 QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold);
110 111
111 connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*))); 112 connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*)));
112 connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), 113 connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),
113 this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int))); 114 this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int)));
114 115
115 layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 );
116 if(QDir("db").exists()) 116 if(QDir("db").exists())
117 drinkDB.setFile("db/drinkdb.txt"); 117 drinkDB.setFile("db/drinkdb.txt");
118 else 118 else
119 drinkDB.setFile(QPEApplication::qpeDir()+"etc/bartender/drinkdb.txt"); 119 drinkDB.setFile(QPEApplication::qpeDir()+"etc/bartender/drinkdb.txt");
120 120
121 initDrinkDb(); 121 initDrinkDb();
122 122
123 DrinkView->setFocus(); 123 DrinkView->setFocus();
124
125 setCentralWidget( DrinkView );
124} 126}
125 127
126Bartender::~Bartender() { 128Bartender::~Bartender() {
127} 129}
128 130
129/* 131/*
130this happens right before exit */ 132this happens right before exit */
131void Bartender::cleanUp() { 133void Bartender::cleanUp() {
132 134
133} 135}
134 136
135void Bartender::initDrinkDb() { 137void Bartender::initDrinkDb() {
136 if(drinkDB.read()) 138 if(drinkDB.read())
137 fillList(); 139 fillList();
138 else 140 else
139 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); 141 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) );
140} 142}
141 143
142void Bartender::fillList() { 144void Bartender::fillList() {
143 QString lastName; 145 QString lastName;
144 if( DrinkView->currentItem() != NULL ) 146 if( DrinkView->currentItem() != NULL )
145 lastName = DrinkView->currentItem()->text(0); 147 lastName = DrinkView->currentItem()->text(0);
146 else 148 else
147 lastName = ""; 149 lastName = "";