Diffstat (limited to 'noncore/apps/opie-bartender/bartender.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-bartender/bartender.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/opie-bartender/bartender.cpp b/noncore/apps/opie-bartender/bartender.cpp index 59fc242..b4958b3 100644 --- a/noncore/apps/opie-bartender/bartender.cpp +++ b/noncore/apps/opie-bartender/bartender.cpp | |||
@@ -68,97 +68,97 @@ Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) | |||
68 | fileMenu->insertItem(tr("Open Drink")); | 68 | fileMenu->insertItem(tr("Open Drink")); |
69 | fileMenu->insertItem(tr("Find by Drink Name")); | 69 | fileMenu->insertItem(tr("Find by Drink Name")); |
70 | fileMenu->insertItem(tr("Find by Alcohol")); | 70 | fileMenu->insertItem(tr("Find by Alcohol")); |
71 | 71 | ||
72 | QPopupMenu *editMenu; | 72 | QPopupMenu *editMenu; |
73 | editMenu = new QPopupMenu( this); | 73 | editMenu = new QPopupMenu( this); |
74 | menuBar->insertItem( tr("Edit"), editMenu ); | 74 | menuBar->insertItem( tr("Edit"), editMenu ); |
75 | editMenu->insertItem(tr("edit")); | 75 | editMenu->insertItem(tr("edit")); |
76 | 76 | ||
77 | connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); | 77 | connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); |
78 | connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); | 78 | connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); |
79 | 79 | ||
80 | 80 | ||
81 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); | 81 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); |
82 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 82 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
83 | a->addTo( ToolBar1 ); | 83 | a->addTo( ToolBar1 ); |
84 | 84 | ||
85 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); | 85 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); |
86 | connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); | 86 | connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); |
87 | a->addTo( ToolBar1 ); | 87 | a->addTo( ToolBar1 ); |
88 | 88 | ||
89 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); | 89 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); |
90 | connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); | 90 | connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); |
91 | a->addTo( ToolBar1 ); | 91 | a->addTo( ToolBar1 ); |
92 | 92 | ||
93 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); | 93 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); |
94 | connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); | 94 | connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); |
95 | a->addTo( ToolBar1 ); | 95 | a->addTo( ToolBar1 ); |
96 | 96 | ||
97 | QPushButton *t; | 97 | QPushButton *t; |
98 | t= new QPushButton( "BAC", ToolBar1, "bacButtin"); | 98 | t= new QPushButton( "BAC", ToolBar1, "bacButtin"); |
99 | connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); | 99 | connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); |
100 | 100 | ||
101 | DrinkView = new QListView( this, "DrinkView" ); | 101 | DrinkView = new QListView( this, "DrinkView" ); |
102 | DrinkView->addColumn( tr( "Name of Drink" ) ); | 102 | DrinkView->addColumn( tr( "Name of Drink" ) ); |
103 | // DrinkView->setRootIsDecorated( TRUE ); | 103 | // DrinkView->setRootIsDecorated( TRUE ); |
104 | DrinkView->header()->hide(); | 104 | DrinkView->header()->hide(); |
105 | 105 | ||
106 | QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); | 106 | QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); |
107 | 107 | ||
108 | connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*))); | 108 | connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*))); |
109 | connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), | 109 | connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
110 | this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int))); | 110 | this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int))); |
111 | 111 | ||
112 | layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); | 112 | layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); |
113 | if(QDir("db").exists()) { | 113 | if(QDir("db").exists()) { |
114 | dbFile.setName( "db/drinkdb.txt"); | 114 | dbFile.setName( "db/drinkdb.txt"); |
115 | } else | 115 | } else |
116 | dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt"); | 116 | dbFile.setName( QPEApplication::qpeDir()+"etc/bartender/drinkdb.txt"); |
117 | initDrinkDb(); | 117 | initDrinkDb(); |
118 | } | 118 | } |
119 | 119 | ||
120 | Bartender::~Bartender() { | 120 | Bartender::~Bartender() { |
121 | } | 121 | } |
122 | 122 | ||
123 | /* | 123 | /* |
124 | this happens right before exit */ | 124 | this happens right before exit */ |
125 | void Bartender::cleanUp() { | 125 | void Bartender::cleanUp() { |
126 | dbFile.close(); | 126 | dbFile.close(); |
127 | 127 | ||
128 | } | 128 | } |
129 | 129 | ||
130 | void Bartender::initDrinkDb() { | 130 | void Bartender::initDrinkDb() { |
131 | 131 | ||
132 | if(!dbFile.isOpen()) | 132 | if(!dbFile.isOpen()) |
133 | if ( !dbFile.open( IO_ReadOnly)) { | 133 | if ( !dbFile.open( IO_ReadOnly)) { |
134 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); | 134 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); |
135 | return; | 135 | return; |
136 | } | 136 | } |
137 | fillList(); | 137 | fillList(); |
138 | } | 138 | } |
139 | 139 | ||
140 | void Bartender::fillList() { | 140 | void Bartender::fillList() { |
141 | dbFile.at(1); | 141 | dbFile.at(1); |
142 | DrinkView->clear(); | 142 | DrinkView->clear(); |
143 | int i=0; | 143 | int i=0; |
144 | QListViewItem * item ; | 144 | QListViewItem * item ; |
145 | QTextStream t( &dbFile); | 145 | QTextStream t( &dbFile); |
146 | QString s; | 146 | QString s; |
147 | while ( !t.eof()) { | 147 | while ( !t.eof()) { |
148 | s = t.readLine(); | 148 | s = t.readLine(); |
149 | if(s.find("#",0,TRUE) != -1) { | 149 | if(s.find("#",0,TRUE) != -1) { |
150 | // odebug << s.right(s.length()-2) << oendl; | 150 | // odebug << s.right(s.length()-2) << oendl; |
151 | item= new QListViewItem( DrinkView, 0 ); | 151 | item= new QListViewItem( DrinkView, 0 ); |
152 | item->setText( 0, s.right(s.length()-2)); | 152 | item->setText( 0, s.right(s.length()-2)); |
153 | i++; | 153 | i++; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | odebug << "there are currently " << i << " of drinks" << oendl; | 156 | odebug << "there are currently " << i << " of drinks" << oendl; |
157 | } | 157 | } |
158 | 158 | ||
159 | void Bartender::fileNew() { | 159 | void Bartender::fileNew() { |
160 | 160 | ||
161 | New_Drink *newDrinks; | 161 | New_Drink *newDrinks; |
162 | newDrinks = new New_Drink(this,"New Drink....", TRUE); | 162 | newDrinks = new New_Drink(this,"New Drink....", TRUE); |
163 | QString newName, newIng; | 163 | QString newName, newIng; |
164 | QPEApplication::execDialog( newDrinks ); | 164 | QPEApplication::execDialog( newDrinks ); |