summaryrefslogtreecommitdiff
path: root/noncore/apps
Unidiff
Diffstat (limited to 'noncore/apps') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-bartender/bartender.cpp2
-rw-r--r--noncore/apps/opie-console/fixit.cpp6
-rw-r--r--noncore/apps/opie-gutenbrowser/LibraryDialog.cpp6
-rw-r--r--noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp2
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp4
-rw-r--r--noncore/apps/opie-gutenbrowser/helpme.cpp2
-rw-r--r--noncore/apps/zsafe/zsafe.cpp10
7 files changed, 16 insertions, 16 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
@@ -20,193 +20,193 @@
20#include <opie2/odebug.h> 20#include <opie2/odebug.h>
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23using namespace Opie::Core; 23using namespace Opie::Core;
24 24
25/* QT */ 25/* QT */
26#include <qlineedit.h> 26#include <qlineedit.h>
27#include <qdir.h> 27#include <qdir.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlistbox.h> 29#include <qlistbox.h>
30#include <qmultilineedit.h> 30#include <qmultilineedit.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qaction.h> 33#include <qaction.h>
34#include <qheader.h> 34#include <qheader.h>
35#include <qlistview.h> 35#include <qlistview.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qtoolbar.h> 37#include <qtoolbar.h>
38#include <qmenubar.h> 38#include <qmenubar.h>
39 39
40/* STD */ 40/* STD */
41#include <fcntl.h> 41#include <fcntl.h>
42#include <unistd.h> 42#include <unistd.h>
43#include <stdlib.h> 43#include <stdlib.h>
44#include <stdio.h> 44#include <stdio.h>
45#include <errno.h> 45#include <errno.h>
46 46
47Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) 47Bartender::Bartender( QWidget* parent, const char* name, WFlags fl )
48 : QMainWindow( parent, name, fl ) { 48 : QMainWindow( parent, name, fl ) {
49 if ( !name ) 49 if ( !name )
50 setName( "Bartender" ); 50 setName( "Bartender" );
51 QGridLayout *layout = new QGridLayout( this ); 51 QGridLayout *layout = new QGridLayout( this );
52 layout->setSpacing( 2); 52 layout->setSpacing( 2);
53 layout->setMargin( 2); 53 layout->setMargin( 2);
54 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 54 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
55 55
56 setCaption( tr( "Bartender" ) ); 56 setCaption( tr( "Bartender" ) );
57 57
58 ToolBar1 = new QToolBar( this, "ToolBar1" ); 58 ToolBar1 = new QToolBar( this, "ToolBar1" );
59 ToolBar1->setFixedHeight(22); 59 ToolBar1->setFixedHeight(22);
60 layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 ); 60 layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 );
61 61
62 QMenuBar *menuBar = new QMenuBar( ToolBar1 ); 62 QMenuBar *menuBar = new QMenuBar( ToolBar1 );
63 QPopupMenu *fileMenu; 63 QPopupMenu *fileMenu;
64 fileMenu = new QPopupMenu( this); 64 fileMenu = new QPopupMenu( this);
65 menuBar->insertItem( tr("File"), fileMenu ); 65 menuBar->insertItem( tr("File"), fileMenu );
66 66
67 fileMenu->insertItem(tr("New Drink")); 67 fileMenu->insertItem(tr("New Drink"));
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
120Bartender::~Bartender() { 120Bartender::~Bartender() {
121} 121}
122 122
123/* 123/*
124this happens right before exit */ 124this happens right before exit */
125void Bartender::cleanUp() { 125void Bartender::cleanUp() {
126 dbFile.close(); 126 dbFile.close();
127 127
128} 128}
129 129
130void Bartender::initDrinkDb() { 130void 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
140void Bartender::fillList() { 140void 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
159void Bartender::fileNew() { 159void 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 );
165 newName = newDrinks->LineEdit1->text(); 165 newName = newDrinks->LineEdit1->text();
166 newIng= newDrinks->MultiLineEdit1->text(); 166 newIng= newDrinks->MultiLineEdit1->text();
167 167
168 if(dbFile.isOpen()) 168 if(dbFile.isOpen())
169 dbFile.close(); 169 dbFile.close();
170 if ( !dbFile.open( IO_WriteOnly| IO_Append)) { 170 if ( !dbFile.open( IO_WriteOnly| IO_Append)) {
171 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); 171 QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) );
172 return; 172 return;
173 } 173 }
174 if(newDrinks ->result() == 1 ) { 174 if(newDrinks ->result() == 1 ) {
175 QString newDrink="\n# "+newName+"\n"; 175 QString newDrink="\n# "+newName+"\n";
176 newDrink.append(newIng+"\n"); 176 newDrink.append(newIng+"\n");
177 odebug << "writing "+newDrink << oendl; 177 odebug << "writing "+newDrink << oendl;
178 dbFile.writeBlock( newDrink.latin1(), newDrink.length()); 178 dbFile.writeBlock( newDrink.latin1(), newDrink.length());
179 clearList(); 179 clearList();
180 dbFile.close(); 180 dbFile.close();
181 181
182 initDrinkDb(); 182 initDrinkDb();
183 } 183 }
184 delete newDrinks; 184 delete newDrinks;
185} 185}
186 186
187void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) { 187void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) {
188 switch (mouse) { 188 switch (mouse) {
189 case 1: 189 case 1:
190// showDrink(item); 190// showDrink(item);
191 break; 191 break;
192 case 2: 192 case 2:
193 showDrink(item); 193 showDrink(item);
194 break; 194 break;
195 } 195 }
196} 196}
197 197
198void Bartender::showDrink( QListViewItem *item) { 198void Bartender::showDrink( QListViewItem *item) {
199 if(item==NULL) return; 199 if(item==NULL) return;
200 dbFile.at(0); 200 dbFile.at(0);
201 Show_Drink *showDrinks; 201 Show_Drink *showDrinks;
202 QString myDrink=item->text(0); 202 QString myDrink=item->text(0);
203 showDrinks = new Show_Drink(this, myDrink, TRUE); 203 showDrinks = new Show_Drink(this, myDrink, TRUE);
204 QTextStream t( &dbFile); 204 QTextStream t( &dbFile);
205 205
206 QString s, s2; 206 QString s, s2;
207 while ( !t.eof()) { 207 while ( !t.eof()) {
208 s = t.readLine(); 208 s = t.readLine();
209 if(s.find( myDrink, 0, TRUE) != -1) { 209 if(s.find( myDrink, 0, TRUE) != -1) {
210 for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) { 210 for(int i=0;s2.find( "#", 0, TRUE) == -1;i++) {
211 s2 = t.readLine(); 211 s2 = t.readLine();
212 if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) { 212 if(s2.find("#",0,TRUE) == -1 || dbFile.atEnd() ) {
diff --git a/noncore/apps/opie-console/fixit.cpp b/noncore/apps/opie-console/fixit.cpp
index 3b0044a..f170074 100644
--- a/noncore/apps/opie-console/fixit.cpp
+++ b/noncore/apps/opie-console/fixit.cpp
@@ -1,94 +1,94 @@
1 1
2#include "fixit.h" 2#include "fixit.h"
3 3
4using namespace Opie::Core; 4using namespace Opie::Core;
5 5
6#ifdef FSCKED_DISTRI 6#ifdef FSCKED_DISTRI
7FixIt::FixIt() { 7FixIt::FixIt() {
8 /* the new inittab */ 8 /* the new inittab */
9 m_file = "#\n# /etc/inittab" 9 m_file = "#\n# /etc/inittab"
10"#" 10"#"
11"" 11""
12"# 0 - halt (Do NOT set initdefault to this)" 12"# 0 - halt (Do NOT set initdefault to this)"
13"# 1 - Single user mode" 13"# 1 - Single user mode"
14"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)" 14"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)"
15"# 3 - Full multiuser mode" 15"# 3 - Full multiuser mode"
16"# 4 - JavaVM(Intent) developer mode" 16"# 4 - JavaVM(Intent) developer mode"
17"# 5 - JavaVM(Intent)" 17"# 5 - JavaVM(Intent)"
18"# 6 - reboot (Do NOT set initdefault to this)" 18"# 6 - reboot (Do NOT set initdefault to this)"
19"#" 19"#"
20"id:5:initdefault:" 20"id:5:initdefault:"
21"" 21""
22"# Specify things to do when starting" 22"# Specify things to do when starting"
23"si::sysinit:/etc/rc.d/rc.sysinit" 23"si::sysinit:/etc/rc.d/rc.sysinit"
24"" 24""
25"l0:0:wait:/root/etc/rc.d/rc 0" 25"l0:0:wait:/root/etc/rc.d/rc 0"
26"l1:1:wait:/etc/rc.d/rc 1" 26"l1:1:wait:/etc/rc.d/rc 1"
27"l2:2:wait:/etc/rc.d/rc 2" 27"l2:2:wait:/etc/rc.d/rc 2"
28"l3:3:wait:/etc/rc.d/rc 3" 28"l3:3:wait:/etc/rc.d/rc 3"
29"l4:4:wait:/etc/rc.d/rc 4" 29"l4:4:wait:/etc/rc.d/rc 4"
30"l5:5:wait:/etc/rc.d/rc 5" 30"l5:5:wait:/etc/rc.d/rc 5"
31"l6:6:wait:/root/etc/rc.d/rc 6" 31"l6:6:wait:/root/etc/rc.d/rc 6"
32"" 32""
33"# Specify things to do before rebooting" 33"# Specify things to do before rebooting"
34"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1" 34"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1"
35"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1" 35"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1"
36"" 36""
37"# Specify program to run on ttyS0" 37"# Specify program to run on ttyS0"
38"s0:24:respawn:/sbin/getty 9600 ttyS0" 38"s0:24:respawn:/sbin/getty 9600 ttyS0"
39"#pd:5:respawn:/etc/sync/serialctl" 39"#pd:5:respawn:/etc/sync/serialctl"
40"" 40""
41"# Specify program to run on tty1" 41"# Specify program to run on tty1"
42"1:2:respawn:/sbin/getty 9600 tty1" 42"1:2:respawn:/sbin/getty 9600 tty1"
43"ln:345:respawn:survive -l 6 /sbin/launch" 43"ln:345:respawn:survive -l 6 /sbin/launch"
44"#qt:5:respawn:/sbin/qt" 44"#qt:5:respawn:/sbin/qt"
45"" 45""
46"# collie sp." 46"# collie sp."
47"sy::respawn:/sbin/shsync\n"; 47"sy::respawn:/sbin/shsync\n";
48} 48}
49 49
50/* 50/*
51 * the retail Zaurus is broken in many ways 51 * the retail Zaurus is broken in many ways
52 * one is that pppd is listening on our port... 52 * one is that pppd is listening on our port...
53 * we've to stop it from that and then do kill(SIGHUP,1); 53 * we've to stop it from that and then do kill(SIGHUP,1);
54 */ 54 */
55void FixIt::fixIt() { 55void FixIt::fixIt() {
56 #ifndef EAST 56 #ifndef EAST
57 ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" ); 57 ::rename("/etc/inittab", QPEApplication::qpeDir() + "etc/inittab" );
58 QFile file( "/etc/inittab" ); 58 QFile file( "/etc/inittab" );
59 if ( file.open(IO_WriteOnly | IO_Raw ) ) { 59 if ( file.open(IO_WriteOnly | IO_Raw ) ) {
60 file.writeBlock(m_file,strlen(m_file) ); 60 file.writeBlock(m_file,strlen(m_file) );
61 } 61 }
62 file.close(); 62 file.close();
63 ::kill( SIGHUP, 1 ); 63 ::kill( SIGHUP, 1 );
64 64
65 #else 65 #else
66 66
67 OProcess m_kill; 67 OProcess m_kill;
68 m_kill << QPEApplication::qpeDir() + "/share/opie-console/sl6000_embedix_kill_0_1.sh"; 68 m_kill << QPEApplication::qpeDir() + "share/opie-console/sl6000_embedix_kill_0_1.sh";
69 69
70 70
71 if ( !m_kill.start(OProcess::DontCare,OProcess::NoCommunication) ) { 71 if ( !m_kill.start(OProcess::DontCare,OProcess::NoCommunication) ) {
72 owarn << "could not execute kill script" << oendl; 72 owarn << "could not execute kill script" << oendl;
73 } else { 73 } else {
74 Global::statusMessage( QObject::tr("Fixing up Embedix")); 74 Global::statusMessage( QObject::tr("Fixing up Embedix"));
75 } 75 }
76 76
77 #endif 77 #endif
78} 78}
79 79
80void FixIt::breakIt() { 80void FixIt::breakIt() {
81 #ifdef EAST 81 #ifdef EAST
82 OProcess m_restart; 82 OProcess m_restart;
83 m_restart << QPEApplication::qpeDir() + "/share/opie-console/sl6000_embedix_restart_0_1.sh"; 83 m_restart << QPEApplication::qpeDir() + "share/opie-console/sl6000_embedix_restart_0_1.sh";
84 84
85 85
86 if ( !m_restart.start(OProcess::DontCare,OProcess::NoCommunication) ) { 86 if ( !m_restart.start(OProcess::DontCare,OProcess::NoCommunication) ) {
87 owarn << "could not execute restart script" << oendl; 87 owarn << "could not execute restart script" << oendl;
88 } 88 }
89 89
90 #endif 90 #endif
91} 91}
92 92
93 93
94#endif 94#endif
diff --git a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
index 020a116..3c096ed 100644
--- a/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
+++ b/noncore/apps/opie-gutenbrowser/LibraryDialog.cpp
@@ -1,153 +1,153 @@
1/*************************************************************************** 1/***************************************************************************
2// LibraryDialog.cpp - description 2// LibraryDialog.cpp - description
3// ------------------- 3// -------------------
4// begin : Sat Aug 19 2000 4// begin : Sat Aug 19 2000
5// copyright : (C) 2000 - 2004 by llornkcor 5// copyright : (C) 2000 - 2004 by llornkcor
6// email : ljp@llornkcor.com 6// email : ljp@llornkcor.com
7// ***************************************************/ 7// ***************************************************/
8// /*************************************************************************** 8// /***************************************************************************
9// * This program is free software; you can redistribute it and/or modify * 9// * This program is free software; you can redistribute it and/or modify *
10// * it under the terms of the GNU General Public License as published by * 10// * it under the terms of the GNU General Public License as published by *
11// * the Free Software Foundation; either version 2 of the License, or * 11// * the Free Software Foundation; either version 2 of the License, or *
12// * (at your option) any later version. * 12// * (at your option) any later version. *
13// ***************************************************************************/ 13// ***************************************************************************/
14//ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL 14//ftp://ibiblio.org/pub/docs/books/gutenberg/GUTINDEX.ALL
15 15
16#include "LibraryDialog.h" 16#include "LibraryDialog.h"
17#include "output.h" 17#include "output.h"
18 18
19/* OPIE */ 19/* OPIE */
20#include <qpe/applnk.h> 20#include <qpe/applnk.h>
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22#include <qpe/qpedialog.h> 22#include <qpe/qpedialog.h>
23#include <opie2/odebug.h> 23#include <opie2/odebug.h>
24 24
25/* QT */ 25/* QT */
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qmultilineedit.h> 27#include <qmultilineedit.h>
28//#include <qlayout.h> 28//#include <qlayout.h>
29 29
30/* STD */ 30/* STD */
31#include <unistd.h> 31#include <unistd.h>
32#include <stdio.h> 32#include <stdio.h>
33#include <stdlib.h> 33#include <stdlib.h>
34 34
35/* 35/*
36 * The dialog will by default be modeless, unless you set 'modal' to 36 * The dialog will by default be modeless, unless you set 'modal' to
37 * TRUE to construct a modal dialog. */ 37 * TRUE to construct a modal dialog. */
38LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*/, WFlags fl ) 38LibraryDialog::LibraryDialog( QWidget* parent, const char* name , bool /*modal*/, WFlags fl )
39 : QDialog( parent, name, true/* modal*/, fl ) 39 : QDialog( parent, name, true/* modal*/, fl )
40{ 40{
41 if ( !name ) 41 if ( !name )
42 setName( "LibraryDialog" ); 42 setName( "LibraryDialog" );
43 indexLoaded=false; 43 indexLoaded=false;
44 initDialog(); 44 initDialog();
45 45
46 // this->setMaximumWidth(240); 46 // this->setMaximumWidth(240);
47 47
48 index = "GUTINDEX.ALL"; 48 index = "GUTINDEX.ALL";
49 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 49 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
50 local_index = local_library + index; 50 local_index = local_library + index;
51 51
52 QString iniFile ; 52 QString iniFile ;
53 iniFile = QPEApplication::qpeDir()+"/etc/gutenbrowser/gutenbrowserrc"; 53 iniFile = QPEApplication::qpeDir()+"etc/gutenbrowser/gutenbrowserrc";
54 54
55 new_index =QPEApplication::qpeDir()+"/etc/gutenbrowser/PGWHOLE.TXT"; 55 new_index =QPEApplication::qpeDir()+"etc/gutenbrowser/PGWHOLE.TXT";
56 56
57 old_index = QPEApplication::qpeDir()+"/etc/gutenbrowser/GUTINDEX.ALL"; 57 old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
58 // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL"; 58 // old_index = QPEApplication::qpeDir()+"etc/gutenbrowser/GUTINDEX.ALL";
59 59
60 // iniFile = local_library+"gutenbrowserrc"; 60 // iniFile = local_library+"gutenbrowserrc";
61 // new_index = local_library + "PGWHOLE.TXT"; 61 // new_index = local_library + "PGWHOLE.TXT";
62 // old_index = local_library + "GUTINDEX.ALL"; 62 // old_index = local_library + "GUTINDEX.ALL";
63 63
64 Config config("Gutenbrowser"); 64 Config config("Gutenbrowser");
65 65
66 config.setGroup( "HttpServer" ); 66 config.setGroup( "HttpServer" );
67 proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org"); 67 proxy_http = config.readEntry("Preferred", "http://sailor.gutenbook.org");
68 68
69 config.setGroup( "FTPsite" ); 69 config.setGroup( "FTPsite" );
70 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org"); 70 ftp_host=config.readEntry("SiteName", "sailor.gutenberg.org");
71 odebug << "Library Dialog: ftp_host is "+ftp_host << oendl; 71 odebug << "Library Dialog: ftp_host is "+ftp_host << oendl;
72 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) ); 72 // ftp_host=ftp_host.right(ftp_host.length()-(ftp_host.find(") ",0,TRUE)+1) );
73 // ftp_host=ftp_host.stripWhiteSpace(); 73 // ftp_host=ftp_host.stripWhiteSpace();
74 ftp_base_dir= config.readEntry("base", "/pub/gutenberg"); 74 ftp_base_dir= config.readEntry("base", "/pub/gutenberg");
75 75
76 i_binary = 0; 76 i_binary = 0;
77 77
78 config.setGroup("SortAuth"); 78 config.setGroup("SortAuth");
79 if( config.readEntry("authSort", "FALSE") == "TRUE") 79 if( config.readEntry("authSort", "FALSE") == "TRUE")
80 authBox->setChecked(TRUE); 80 authBox->setChecked(TRUE);
81 81
82 config.setGroup("General"); 82 config.setGroup("General");
83 downDir =config.readEntry( "DownloadDirectory",local_library); 83 downDir =config.readEntry( "DownloadDirectory",local_library);
84 odebug << "downDir is "+downDir << oendl; 84 odebug << "downDir is "+downDir << oendl;
85 newindexLib.setName( old_index); 85 newindexLib.setName( old_index);
86 indexLib.setName( old_index); 86 indexLib.setName( old_index);
87 87
88 new QPEDialogListener(this); 88 new QPEDialogListener(this);
89 QTimer::singleShot( 1000, this, SLOT( FindLibrary()) ); 89 QTimer::singleShot( 1000, this, SLOT( FindLibrary()) );
90 90
91} 91}
92 92
93LibraryDialog::~LibraryDialog() 93LibraryDialog::~LibraryDialog()
94{ 94{
95// delete QList_Item2; 95// delete QList_Item2;
96// delete QList_Item1; 96// delete QList_Item1;
97// delete QList_Item3; 97// delete QList_Item3;
98// delete QList_Item4; 98// delete QList_Item4;
99// delete QList_Item5; 99// delete QList_Item5;
100 100
101 // saveConfig(); 101 // saveConfig();
102} 102}
103 103
104 /*This groks using PGWHOLE.TXT */ 104 /*This groks using PGWHOLE.TXT */
105void LibraryDialog::Newlibrary() 105void LibraryDialog::Newlibrary()
106{ 106{
107#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files 107#ifndef Q_WS_QWS //sorry embedded gutenbrowser cant use zip files
108 //odebug << "Opening new library index " << newindexLib << "" << oendl; 108 //odebug << "Opening new library index " << newindexLib << "" << oendl;
109 if ( newindexLib.open( IO_ReadOnly) ) { 109 if ( newindexLib.open( IO_ReadOnly) ) {
110 setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully 110 setCaption( tr( "Library Index - using master pg index." ) );// file opened successfully
111 QTextStream indexStream( &newindexLib ); 111 QTextStream indexStream( &newindexLib );
112 QString indexLine; 112 QString indexLine;
113 while ( !indexStream.atEnd() ) { // until end of file.. 113 while ( !indexStream.atEnd() ) { // until end of file..
114 indexLine = indexStream.readLine(); 114 indexLine = indexStream.readLine();
115 if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) { 115 if ( ( indexLine.mid(4,4)).toInt() && !( indexLine.left(3)).toInt()) {
116 year = indexLine.mid(4,4); 116 year = indexLine.mid(4,4);
117 year = year.stripWhiteSpace(); 117 year = year.stripWhiteSpace();
118 file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 ); 118 file = indexLine.mid( indexLine.find( "[", 0, TRUE )+1, 12 );
119 file = file.stripWhiteSpace(); 119 file = file.stripWhiteSpace();
120 number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 ); 120 number = indexLine.mid( indexLine.find( "]", 0, TRUE ) +1, indexLine.find( " ", 0, TRUE )+1 );
121 if( year.toInt() < 1984) 121 if( year.toInt() < 1984)
122 number = number.left( number.length() -1 ); 122 number = number.left( number.length() -1 );
123 number = number.stripWhiteSpace(); 123 number = number.stripWhiteSpace();
124 title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() ); 124 title = indexLine.mid( indexLine.find(" ", 26, TRUE), indexLine.length() );
125 title = title.stripWhiteSpace(); 125 title = title.stripWhiteSpace();
126 126
127 getAuthor(); // groks author 127 getAuthor(); // groks author
128 author = author.stripWhiteSpace(); 128 author = author.stripWhiteSpace();
129 if (authBox->isChecked()) { // this reverses the first name and last name of the author 129 if (authBox->isChecked()) { // this reverses the first name and last name of the author
130 // odebug << "Sorting last name first" << oendl; 130 // odebug << "Sorting last name first" << oendl;
131 QString lastName, firstName=""; 131 QString lastName, firstName="";
132 int finder=author.findRev( ' ', -1, TRUE); 132 int finder=author.findRev( ' ', -1, TRUE);
133 lastName=author.right( author.length()-finder); 133 lastName=author.right( author.length()-finder);
134 firstName=author.left(finder); 134 firstName=author.left(finder);
135 lastName=lastName.stripWhiteSpace(); 135 lastName=lastName.stripWhiteSpace();
136 firstName=firstName.stripWhiteSpace(); 136 firstName=firstName.stripWhiteSpace();
137 137
138 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names 138 if( lastName.find( firstName, 0, true) == -1) // this avoids dup names
139 author=lastName+", "+firstName; 139 author=lastName+", "+firstName;
140 } 140 }
141 141
142 if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) { 142 if( !number.isEmpty() && (title.find( "reserved",0, FALSE) == -1) && (file.find( "]",0, TRUE) == -1) ) {
143 143
144 // fill string list or something to be able to resort the whole library 144 // fill string list or something to be able to resort the whole library
145 if( author.isEmpty() ) 145 if( author.isEmpty() )
146 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file ); 146 QList_Item5 = new QListViewItem( ListView5, /* number,*/ title, author, year, file );
147 else { 147 else {
148 148
149 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) || 149 if( (author.left(1) >= QString("A") && author.left(1) <= QString("F")) ||
150 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) ) 150 (author.left(1) >= QString("a") && author.left(1) <= QString("f")) )
151 QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file ); 151 QList_Item1 = new QListViewItem( ListView1,/* number,*/ title, author, year, file );
152 152
153 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) || 153 else if( (author.left(1) >= QString("G") && author.left(1) <= QString("M")) ||
diff --git a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
index a9c7346..de9c72b 100644
--- a/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
+++ b/noncore/apps/opie-gutenbrowser/ftpsitedlg.cpp
@@ -1,137 +1,137 @@
1/*************************************************************************** 1/***************************************************************************
2 ftpsitedlg.cpp - description 2 ftpsitedlg.cpp - description
3 ------------------- 3 -------------------
4 begin : Tue Jul 25 2000 4 begin : Tue Jul 25 2000
5 copyright : (C) 2000 -2004 by llornkcor 5 copyright : (C) 2000 -2004 by llornkcor
6 email : ljp@llornkcor.com 6 email : ljp@llornkcor.com
7 ***************************************************************************/ 7 ***************************************************************************/
8/*************************************************************************** 8/***************************************************************************
9 * This program is free software; you can redistribute it and/or modify * 9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by * 10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or * 11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. * 12 * (at your option) any later version. *
13 ***************************************************************************/ 13 ***************************************************************************/
14 14
15#include "optionsDialog.h" 15#include "optionsDialog.h"
16#include "gutenbrowser.h" 16#include "gutenbrowser.h"
17//#include "NetworkDialog.h" 17//#include "NetworkDialog.h"
18#include "output.h" 18#include "output.h"
19 19
20/* OPIE */ 20/* OPIE */
21#include <opie2/odebug.h> 21#include <opie2/odebug.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23 23
24/* QT */ 24/* QT */
25#include <qprogressbar.h> 25#include <qprogressbar.h>
26#include <qurloperator.h> 26#include <qurloperator.h>
27#include <qlistbox.h> 27#include <qlistbox.h>
28 28
29/* STD */ 29/* STD */
30#include <stdlib.h> 30#include <stdlib.h>
31#include <unistd.h> 31#include <unistd.h>
32#include <stdio.h> 32#include <stdio.h>
33 33
34// :)~ 34// :)~
35void optionsDialog::ftpSiteDlg( ) 35void optionsDialog::ftpSiteDlg( )
36{ 36{
37//printf( "ftpSiteDlg: ListFile is "+ ListFile +"\n" ); 37//printf( "ftpSiteDlg: ListFile is "+ ListFile +"\n" );
38// initDialog(); 38// initDialog();
39 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 39 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
40// ListFile = local_library + "ftpList"; 40// ListFile = local_library + "ftpList";
41 ListFile = QPEApplication::qpeDir() + "/etc/gutenbrowser"; 41 ListFile = QPEApplication::qpeDir() + "etc/gutenbrowser";
42 QDir dir(ListFile); 42 QDir dir(ListFile);
43 if( !dir.exists()) 43 if( !dir.exists())
44 dir.mkdir(ListFile,true); 44 dir.mkdir(ListFile,true);
45 ListFile+="/ftpList"; 45 ListFile+="/ftpList";
46 odebug << "opening "+ListFile << oendl; 46 odebug << "opening "+ListFile << oendl;
47 if ( QFile(ListFile).exists() ) { 47 if ( QFile(ListFile).exists() ) {
48 openSiteList(); 48 openSiteList();
49 } else { 49 } else {
50 switch( QMessageBox::warning( this, "Gutenbrowser", 50 switch( QMessageBox::warning( this, "Gutenbrowser",
51 "Do you want to download \nan ftp site list?", 51 "Do you want to download \nan ftp site list?",
52 QMessageBox::Yes, QMessageBox::No)) { 52 QMessageBox::Yes, QMessageBox::No)) {
53 case QMessageBox::Yes: // yes 53 case QMessageBox::Yes: // yes
54 getSite(); 54 getSite();
55 break; 55 break;
56 case QMessageBox::No: // No 56 case QMessageBox::No: // No
57 // exit 57 // exit
58 break; 58 break;
59 } 59 }
60 60
61 } 61 }
62} 62}
63 63
64 64
65/* 65/*
66// get ftp list from web- parse it. */ 66// get ftp list from web- parse it. */
67void optionsDialog::getSite() 67void optionsDialog::getSite()
68{ 68{
69 QString file_name; 69 QString file_name;
70 QString ftp_listFileURL; 70 QString ftp_listFileURL;
71 QString outputFile; 71 QString outputFile;
72// outputFile = local_library+ "list.html"; 72// outputFile = local_library+ "list.html";
73 outputFile = ListFile + "list.html"; 73 outputFile = ListFile + "list.html";
74 QString networkUrl= "http://www.gutenberg.org/www/mirror.sites.html"; 74 QString networkUrl= "http://www.gutenberg.org/www/mirror.sites.html";
75//http://www.gutenberg.org/index.html"; 75//http://www.gutenberg.org/index.html";
76// QString networkUrl= "http://llornkcor.com/index.shtml"; 76// QString networkUrl= "http://llornkcor.com/index.shtml";
77// // "http://www.gutenberg.org/index.html" 77// // "http://www.gutenberg.org/index.html"
78// 78//
79//Qhttp stops working at times.... :( 79//Qhttp stops working at times.... :(
80// NetworkDialog *NetworkDlg; 80// NetworkDialog *NetworkDlg;
81// NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile); 81// NetworkDlg = new NetworkDialog( this,"Network Protocol Dialog",TRUE,0,networkUrl,outputFile);
82// if( NetworkDlg->exec() != 0 ) 82// if( NetworkDlg->exec() != 0 )
83// { // use new, improved, *INSTANT* network-dialog-file-getterer 83// { // use new, improved, *INSTANT* network-dialog-file-getterer
84// odebug << "gitcha!" << oendl; 84// odebug << "gitcha!" << oendl;
85// } 85// }
86// delete NetworkDlg; 86// delete NetworkDlg;
87//#ifdef Q_WS_QWS 87//#ifdef Q_WS_QWS
88 88
89// TODO qprocess here 89// TODO qprocess here
90 90
91 QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ; 91 QString cmd="wget -T 15 -O " +outputFile + " " + networkUrl + " 2>&1" ;
92 odebug << "Issuing the command "+cmd << oendl; 92 odebug << "Issuing the command "+cmd << oendl;
93 Output *outDlg; 93 Output *outDlg;
94 outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE); 94 outDlg = new Output( 0, tr("Downloading ftp sites...."),TRUE);
95 outDlg->showMaximized(); 95 outDlg->showMaximized();
96 outDlg->show(); 96 outDlg->show();
97 qApp->processEvents(); 97 qApp->processEvents();
98 FILE *fp; 98 FILE *fp;
99 char line[130]; 99 char line[130];
100 outDlg->OutputEdit->append( tr("Running wget") ); 100 outDlg->OutputEdit->append( tr("Running wget") );
101 sleep(1); 101 sleep(1);
102 fp = popen( (const char *) cmd, "r"); 102 fp = popen( (const char *) cmd, "r");
103 while ( fgets( line, sizeof line, fp)) { 103 while ( fgets( line, sizeof line, fp)) {
104 outDlg->OutputEdit->append(line); 104 outDlg->OutputEdit->append(line);
105 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 105 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
106 } 106 }
107 pclose(fp); 107 pclose(fp);
108 outDlg->close(); 108 outDlg->close();
109 if(outDlg) 109 if(outDlg)
110 delete outDlg; 110 delete outDlg;
111 111
112// outputFile=ListFile; 112// outputFile=ListFile;
113 ftp_QListBox_1->clear(); 113 ftp_QListBox_1->clear();
114 parseFtpList( outputFile); // got the html list, now parse it so we can use it 114 parseFtpList( outputFile); // got the html list, now parse it so we can use it
115} 115}
116 116
117bool optionsDialog::parseFtpList( QString outputFile) 117bool optionsDialog::parseFtpList( QString outputFile)
118{ 118{
119// parse ftplist html and extract just the machine names/directories 119// parse ftplist html and extract just the machine names/directories
120// TODO: add locations!! 120// TODO: add locations!!
121 odebug << "parse ftplist "+outputFile << oendl; 121 odebug << "parse ftplist "+outputFile << oendl;
122 QString ftpList, s_location; 122 QString ftpList, s_location;
123 QFile f( outputFile ); 123 QFile f( outputFile );
124 124
125 if( f.open( IO_ReadWrite )) { 125 if( f.open( IO_ReadWrite )) {
126 QTextStream t( &f); 126 QTextStream t( &f);
127 QString countryName; 127 QString countryName;
128 bool b_gotchTest=false; 128 bool b_gotchTest=false;
129 129
130 while ( !t.eof() ) { 130 while ( !t.eof() ) {
131 QString s = t.readLine(); 131 QString s = t.readLine();
132 int start; 132 int start;
133 int end; 133 int end;
134 if( s.find( "FTP mirror sites for Project Gutenberg:", 0, TRUE) !=-1) { //lower end of this file 134 if( s.find( "FTP mirror sites for Project Gutenberg:", 0, TRUE) !=-1) { //lower end of this file
135 b_gotchTest = true; 135 b_gotchTest = true;
136 } 136 }
137 if( b_gotchTest) { 137 if( b_gotchTest) {
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
index 644fae8..fac21da 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -49,198 +49,198 @@
49#include <qobjectlist.h> 49#include <qobjectlist.h>
50#include <qfontdialog.h> 50#include <qfontdialog.h>
51#include <qtextview.h> 51#include <qtextview.h>
52#include <qbrush.h> 52#include <qbrush.h>
53#include <qfile.h> 53#include <qfile.h>
54#include <qfontinfo.h> 54#include <qfontinfo.h>
55#include <qscrollview.h> 55#include <qscrollview.h>
56#include <qpoint.h> 56#include <qpoint.h>
57 57
58/* STD */ 58/* STD */
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include <unistd.h> 61#include <unistd.h>
62#include <sys/stat.h> 62#include <sys/stat.h>
63#include <fcntl.h> 63#include <fcntl.h>
64#include <errno.h> 64#include <errno.h>
65 65
66static const int nfontsizes = 9; 66static const int nfontsizes = 9;
67static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24}; 67static const int fontsize[nfontsizes] = {8,9,10,11,12,13,14,18,24};
68 68
69#ifdef NOQUICKLAUNCH 69#ifdef NOQUICKLAUNCH
70Gutenbrowser::Gutenbrowser() 70Gutenbrowser::Gutenbrowser()
71 Gutenbrowser(); 71 Gutenbrowser();
72#else 72#else
73Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags ) 73Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
74#endif 74#endif
75 : QMainWindow() 75 : QMainWindow()
76{ 76{
77 // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 77 // QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
78 // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); 78 // QCopEnvelope e("QPE/System", "grabKeyboard(QString)" );
79 // e << ""; 79 // e << "";
80 // QPEApplication::grabKeyboard(); 80 // QPEApplication::grabKeyboard();
81 showMainList=TRUE; 81 showMainList=TRUE;
82 working=false; 82 working=false;
83 this->setUpdatesEnabled(TRUE); 83 this->setUpdatesEnabled(TRUE);
84 // #ifndef Q_WS_QWS 84 // #ifndef Q_WS_QWS
85 QString msg; 85 QString msg;
86 msg="You have now entered unto gutenbrowser,\n"; 86 msg="You have now entered unto gutenbrowser,\n";
87 msg+="make your self at home, sit back, relax and read something great.\n"; 87 msg+="make your self at home, sit back, relax and read something great.\n";
88 88
89 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/"; 89 local_library = (QDir::homeDirPath ()) +"/Applications/gutenbrowser/";
90 setCaption("Gutenbrowser");// Embedded " VERSION); 90 setCaption("Gutenbrowser");// Embedded " VERSION);
91 this->setUpdatesEnabled(TRUE); 91 this->setUpdatesEnabled(TRUE);
92 92
93 // bool firstTime=FALSE; 93 // bool firstTime=FALSE;
94 topLayout = new QVBoxLayout( this, 0, 0, "topLayout"); 94 topLayout = new QVBoxLayout( this, 0, 0, "topLayout");
95 95
96 menu = new QHBoxLayout(-1,"menu"); 96 menu = new QHBoxLayout(-1,"menu");
97 buttons2 = new QHBoxLayout(-1,"buttons2"); 97 buttons2 = new QHBoxLayout(-1,"buttons2");
98 edits = new QHBoxLayout(-1,"edits"); 98 edits = new QHBoxLayout(-1,"edits");
99 99
100 useSplitter=TRUE; 100 useSplitter=TRUE;
101 101
102 initConfig(); 102 initConfig();
103 initMenuBar(); 103 initMenuBar();
104 initButtonBar(); 104 initButtonBar();
105 initStatusBar(); 105 initStatusBar();
106 initView(); 106 initView();
107 initSlots(); 107 initSlots();
108 qDebug("init finished"); 108 qDebug("init finished");
109 QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold); 109 QPEApplication::setStylusOperation( mainList->viewport(),QPEApplication::RightOnHold);
110 110
111 connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)), 111 connect( mainList, SIGNAL( mouseButtonPressed( int, QListBoxItem *, const QPoint &)),
112 this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) ); 112 this, SLOT( mainListPressed(int, QListBoxItem *, const QPoint &)) );
113 if( useIcons) 113 if( useIcons)
114 toggleButtonIcons( TRUE); 114 toggleButtonIcons( TRUE);
115 else 115 else
116 toggleButtonIcons( FALSE); 116 toggleButtonIcons( FALSE);
117 117
118 enableButtons(false); 118 enableButtons(false);
119 119
120 Config config("Gutenbrowser"); // populate menubuttonlist 120 Config config("Gutenbrowser"); // populate menubuttonlist
121 config.setGroup("General"); 121 config.setGroup("General");
122 122
123 config.setGroup( "Files" ); 123 config.setGroup( "Files" );
124 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 124 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
125 int i_numofFiles = s_numofFiles.toInt(); 125 int i_numofFiles = s_numofFiles.toInt();
126 126
127 QString tempFileName; 127 QString tempFileName;
128 128
129 for (int i = 0; i <= i_numofFiles; i++) { 129 for (int i = 0; i <= i_numofFiles; i++) {
130 // tempFileName.setNum(i); 130 // tempFileName.setNum(i);
131 config.setGroup( "Files" ); 131 config.setGroup( "Files" );
132 QString ramble = config.readEntry( QString::number(i), "" ); 132 QString ramble = config.readEntry( QString::number(i), "" );
133 133
134 config.setGroup( "Titles" ); 134 config.setGroup( "Titles" );
135 QString tempTitle = config.readEntry( ramble, ""); 135 QString tempTitle = config.readEntry( ramble, "");
136 config.setGroup( tempTitle); 136 config.setGroup( tempTitle);
137 int index = config.readNumEntry( "LineNumber", -1 ); 137 int index = config.readNumEntry( "LineNumber", -1 );
138 if( index != -1) { 138 if( index != -1) {
139 odebug << tempTitle << oendl; 139 odebug << tempTitle << oendl;
140 if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle); 140 if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle);
141 } 141 }
142 } 142 }
143 143
144 // QString gutenIndex= local_library + "GUTINDEX.ALL"; 144 // QString gutenIndex= local_library + "GUTINDEX.ALL";
145 QString gutenIndex = QPEApplication::qpeDir()+ "/etc/gutenbrowser/GUTINDEX.ALL"; 145 QString gutenIndex = QPEApplication::qpeDir()+ "etc/gutenbrowser/GUTINDEX.ALL";
146 qDebug("gutenindex "+gutenIndex ); 146 qDebug("gutenindex "+gutenIndex );
147 if( QFile( gutenIndex).exists() ) { 147 if( QFile( gutenIndex).exists() ) {
148 indexLib.setName( gutenIndex); 148 indexLib.setName( gutenIndex);
149 } else { 149 } else {
150 QString localLibIndexFile = QPEApplication::qpeDir()+ "/etc/gutenbrowser/PGWHOLE.TXT"; 150 QString localLibIndexFile = QPEApplication::qpeDir()+ "etc/gutenbrowser/PGWHOLE.TXT";
151 // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; 151 // QString localLibIndexFile= local_library + "PGWHOLE.TXT";
152 newindexLib.setName( localLibIndexFile); 152 newindexLib.setName( localLibIndexFile);
153 } 153 }
154 qDebug("attempting new library"); 154 qDebug("attempting new library");
155 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); 155 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */);
156 loadCheck = false; 156 loadCheck = false;
157 chdir(local_library); 157 chdir(local_library);
158 if(!showMainList) { 158 if(!showMainList) {
159 Lview->setFocus(); 159 Lview->setFocus();
160 // if(firstTime) 160 // if(firstTime)
161 // Bookmark(); 161 // Bookmark();
162 for (int i=1;i< qApp->argc();i++) { 162 for (int i=1;i< qApp->argc();i++) {
163 qDebug("Suppose we open somethin"); 163 qDebug("Suppose we open somethin");
164 if(!load(qApp->argv()[i])) return; 164 if(!load(qApp->argv()[i])) return;
165 } 165 }
166 } else { 166 } else {
167 fillWithTitles(); 167 fillWithTitles();
168 mainList->setFocus(); 168 mainList->setFocus();
169 // mainList->setCurrentItem(0); 169 // mainList->setCurrentItem(0);
170 170
171 } 171 }
172 writeConfig(); 172 writeConfig();
173 QTimer::singleShot( 250, this, SLOT(hideView()) ); 173 QTimer::singleShot( 250, this, SLOT(hideView()) );
174} //end init 174} //end init
175 175
176Gutenbrowser::~Gutenbrowser() { 176Gutenbrowser::~Gutenbrowser() {
177 // QPEApplication::grabKeyboard(); 177 // QPEApplication::grabKeyboard();
178 // QPEApplication::ungrabKeyboard(); 178 // QPEApplication::ungrabKeyboard();
179 odebug << "Exit" << oendl; 179 odebug << "Exit" << oendl;
180} 180}
181 181
182 /* 182 /*
183 Google.com search */ 183 Google.com search */
184void Gutenbrowser::InfoBarClick() { 184void Gutenbrowser::InfoBarClick() {
185 QString text; 185 QString text;
186 if( Lview->hasSelectedText()) { 186 if( Lview->hasSelectedText()) {
187 Lview->copy(); 187 Lview->copy();
188 QClipboard *cb = QApplication::clipboard(); 188 QClipboard *cb = QApplication::clipboard();
189 text = cb->text(); 189 text = cb->text();
190 } else { 190 } else {
191 // text=title; 191 // text=title;
192 text=this->caption(); 192 text=this->caption();
193 } 193 }
194 searchGoogle(text); 194 searchGoogle(text);
195} 195}
196 196
197 /* 197 /*
198 download http with wget or preferred browser */ 198 download http with wget or preferred browser */
199void Gutenbrowser::goGetit( const QString &url, bool showMsg) { 199void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
200 // int eexit=0; 200 // int eexit=0;
201 QString cmd; 201 QString cmd;
202 // config.read(); 202 // config.read();
203 qApp->processEvents(); 203 qApp->processEvents();
204 QString filename = QPEApplication::qpeDir(); 204 QString filename = QPEApplication::qpeDir();
205 if(filename.right(1)!="/") 205 if(filename.right(1)!="/")
206 filename+="/etc/gutenbrowser/"; 206 filename+="/etc/gutenbrowser/";
207 else 207 else
208 filename+="etc/gutenbrowser/"; 208 filename+="etc/gutenbrowser/";
209 odebug << "filename "+filename << oendl; 209 odebug << "filename "+filename << oendl;
210 // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/"; 210 // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/";
211 211
212 filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); 212 filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1);
213 213
214 Config config("Gutenbrowser"); 214 Config config("Gutenbrowser");
215 config.setGroup( "Browser" ); 215 config.setGroup( "Browser" );
216 QString brow = config.readEntry("Preferred", "Opera"); 216 QString brow = config.readEntry("Preferred", "Opera");
217 odebug << "Preferred browser is "+brow << oendl; 217 odebug << "Preferred browser is "+brow << oendl;
218 if(!showMsg) { //if we just get the gutenindex.all 218 if(!showMsg) { //if we just get the gutenindex.all
219 cmd="wget -O " + filename +" " + url+" 2>&1" ; 219 cmd="wget -O " + filename +" " + url+" 2>&1" ;
220 chdir(local_library); 220 chdir(local_library);
221 odebug << "Issuing the system command: " << cmd << "" << oendl; 221 odebug << "Issuing the system command: " << cmd << "" << oendl;
222 222
223 Output *outDlg; 223 Output *outDlg;
224 outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE); 224 outDlg = new Output(this, tr("Gutenbrowser Output"),FALSE);
225 outDlg->showMaximized(); 225 outDlg->showMaximized();
226 outDlg->show(); 226 outDlg->show();
227 qApp->processEvents(); 227 qApp->processEvents();
228 FILE *fp; 228 FILE *fp;
229 char line[130]; 229 char line[130];
230 outDlg->OutputEdit->append( tr("Running wget") ); 230 outDlg->OutputEdit->append( tr("Running wget") );
231 sleep(1); 231 sleep(1);
232 fp = popen( (const char *) cmd, "r"); 232 fp = popen( (const char *) cmd, "r");
233 odebug << "Issuing the command\n"+cmd << oendl; 233 odebug << "Issuing the command\n"+cmd << oendl;
234 // system(cmd); 234 // system(cmd);
235 while ( fgets( line, sizeof line, fp)) { 235 while ( fgets( line, sizeof line, fp)) {
236 outDlg->OutputEdit->append(line); 236 outDlg->OutputEdit->append(line);
237// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 237// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
238 } 238 }
239 pclose(fp); 239 pclose(fp);
240 outDlg->close(); 240 outDlg->close();
241 if(outDlg) 241 if(outDlg)
242 delete outDlg; 242 delete outDlg;
243 } else { 243 } else {
244 if( brow == "Konq") { 244 if( brow == "Konq") {
245 cmd = "konqueror "+url+" &"; 245 cmd = "konqueror "+url+" &";
246 } 246 }
diff --git a/noncore/apps/opie-gutenbrowser/helpme.cpp b/noncore/apps/opie-gutenbrowser/helpme.cpp
index 53e0236..0e23114 100644
--- a/noncore/apps/opie-gutenbrowser/helpme.cpp
+++ b/noncore/apps/opie-gutenbrowser/helpme.cpp
@@ -1,127 +1,127 @@
1/*************************************************************************** 1/***************************************************************************
2 helpme.cpp - description 2 helpme.cpp - description
3 ------------------- 3 -------------------
4 begin : Tue Jul 25 2000 4 begin : Tue Jul 25 2000
5 begin : Sat Dec 4 1999 5 begin : Sat Dec 4 1999
6 copyright : (C) 2000 -2004 by llornkcor 6 copyright : (C) 2000 -2004 by llornkcor
7 email : ljp@llornkcor.com 7 email : ljp@llornkcor.com
8 ***************************************************************************/ 8 ***************************************************************************/
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "helpme.h" 18#include "helpme.h"
19#include "helpwindow.h" 19#include "helpwindow.h"
20 20
21/* OPIE */ 21/* OPIE */
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <opie2/odebug.h> 24#include <opie2/odebug.h>
25 25
26/* QT */ 26/* QT */
27#include <qprogressdialog.h> 27#include <qprogressdialog.h>
28#include <qlayout.h> 28#include <qlayout.h>
29 29
30/* STD */ 30/* STD */
31#include <sys/stat.h> 31#include <sys/stat.h>
32#include <unistd.h> 32#include <unistd.h>
33 33
34HelpMe::HelpMe(QWidget *parent, QString name ) : QDialog(parent,name) 34HelpMe::HelpMe(QWidget *parent, QString name ) : QDialog(parent,name)
35{ 35{
36 local_library = ( QDir::homeDirPath ())+"/Applications/gutenbrowser/"; 36 local_library = ( QDir::homeDirPath ())+"/Applications/gutenbrowser/";
37 setCaption(tr("Gutenbrowser About " VERSION)); 37 setCaption(tr("Gutenbrowser About " VERSION));
38 38
39 QGridLayout *layout = new QGridLayout( this ); 39 QGridLayout *layout = new QGridLayout( this );
40 layout->setSpacing( 4 ); 40 layout->setSpacing( 4 );
41 layout->setMargin( 4 ); 41 layout->setMargin( 4 );
42 42
43 Edit = new QMultiLineEdit(this, ""); 43 Edit = new QMultiLineEdit(this, "");
44 Edit->setReadOnly(true); 44 Edit->setReadOnly(true);
45 Edit->append(tr("Based on gutenbook.pl, available from http://www.gutenbook.org")); 45 Edit->append(tr("Based on gutenbook.pl, available from http://www.gutenbook.org"));
46 Edit->append(tr("Much appreciation to Lee Burgess,")); 46 Edit->append(tr("Much appreciation to Lee Burgess,"));
47 Edit->append(tr("for the original idea and concept of gutenbook.\n")); 47 Edit->append(tr("for the original idea and concept of gutenbook.\n"));
48 Edit->append(tr("A list of current Gutenberg ftp sites is at http://promo.net/pg/index.html\n")); 48 Edit->append(tr("A list of current Gutenberg ftp sites is at http://promo.net/pg/index.html\n"));
49 Edit->append(tr("For bug reports, comments or questions about Gutenbrowser, email")); 49 Edit->append(tr("For bug reports, comments or questions about Gutenbrowser, email"));
50 Edit->append(tr("ljp@llornkcor.com\n")); 50 Edit->append(tr("ljp@llornkcor.com\n"));
51 Edit->append(tr("\nMade using Qt, Qt Embedded, and Qtopia, a cross platform development API\nhttp://www.trolltech.com\n\n")); 51 Edit->append(tr("\nMade using Qt, Qt Embedded, and Qtopia, a cross platform development API\nhttp://www.trolltech.com\n\n"));
52 Edit->append(tr("Arnold's Laws of Documentation:")); 52 Edit->append(tr("Arnold's Laws of Documentation:"));
53 Edit->append(tr("(1) If it should exist, it doesn't.")); 53 Edit->append(tr("(1) If it should exist, it doesn't."));
54 Edit->append(tr("(2) If it does exist, it's out of date.")); 54 Edit->append(tr("(2) If it does exist, it's out of date."));
55 Edit->append(tr("(3) Only documentation for")); 55 Edit->append(tr("(3) Only documentation for"));
56 Edit->append(tr("useless programs transcends the")); 56 Edit->append(tr("useless programs transcends the"));
57 Edit->append(tr("first two laws.\n")); 57 Edit->append(tr("first two laws.\n"));
58 Edit->append(tr("Everything is temporary, anyway....\n :o)")); 58 Edit->append(tr("Everything is temporary, anyway....\n :o)"));
59 Edit->setWordWrap(QMultiLineEdit::WidgetWidth); 59 Edit->setWordWrap(QMultiLineEdit::WidgetWidth);
60 QString pixDir; 60 QString pixDir;
61 pixDir=QPEApplication::qpeDir()+"/pics/"; 61 pixDir=QPEApplication::qpeDir()+"pics/";
62 QPushButton *help; 62 QPushButton *help;
63 help = new QPushButton(this); 63 help = new QPushButton(this);
64 help->setPixmap( QPixmap( pixDir+"gutenbrowser/help.png")); 64 help->setPixmap( QPixmap( pixDir+"gutenbrowser/help.png"));
65 help->setText("Help"); 65 help->setText("Help");
66 connect( help,SIGNAL(clicked()),this,SLOT( help() )); 66 connect( help,SIGNAL(clicked()),this,SLOT( help() ));
67 67
68/* QPushButton *ok; 68/* QPushButton *ok;
69 ok = new QPushButton(this); 69 ok = new QPushButton(this);
70 ok->setPixmap( QPixmap( pixDir+"/gutenbrowser/exit.png")); 70 ok->setPixmap( QPixmap( pixDir+"/gutenbrowser/exit.png"));
71 ok->setText("ok"); 71 ok->setText("ok");
72 connect(ok,SIGNAL(clicked()),this,SLOT(accept() )); 72 connect(ok,SIGNAL(clicked()),this,SLOT(accept() ));
73*/ 73*/
74 help->setFixedHeight(25); 74 help->setFixedHeight(25);
75// ok->setFixedHeight(25); 75// ok->setFixedHeight(25);
76 76
77// layout->addMultiCellWidget( ok, 0, 0, 4, 4 ); 77// layout->addMultiCellWidget( ok, 0, 0, 4, 4 );
78 layout->addMultiCellWidget( help, 0, 0, 4, 4 ); 78 layout->addMultiCellWidget( help, 0, 0, 4, 4 );
79 layout->addMultiCellWidget( Edit, 1, 1, 0, 4 ); 79 layout->addMultiCellWidget( Edit, 1, 1, 0, 4 );
80} 80}
81 81
82HelpMe::~HelpMe() 82HelpMe::~HelpMe()
83{ 83{
84//delete Edit; 84//delete Edit;
85 85
86} 86}
87 87
88void HelpMe::goToURL() 88void HelpMe::goToURL()
89{ 89{
90 90
91 url = "http://www.llornkcor.com/"; 91 url = "http://www.llornkcor.com/";
92 goGetit( url); 92 goGetit( url);
93} 93}
94 94
95void HelpMe::goToURL2() 95void HelpMe::goToURL2()
96{ 96{
97 url = "http://www.gutenberg.org"; 97 url = "http://www.gutenberg.org";
98 goGetit( url); 98 goGetit( url);
99} 99}
100 100
101void HelpMe::goToURL3() 101void HelpMe::goToURL3()
102{ 102{
103 url = "http://www.gutenbook.org"; 103 url = "http://www.gutenbook.org";
104 goGetit( url); 104 goGetit( url);
105} 105}
106 106
107void HelpMe::goGetit( QString url) 107void HelpMe::goGetit( QString url)
108{ 108{
109 HelpWindow *help = new HelpWindow( url, ".", 0, "gutenbrowser"); 109 HelpWindow *help = new HelpWindow( url, ".", 0, "gutenbrowser");
110 help->setCaption("Qt Example - Helpviewer"); 110 help->setCaption("Qt Example - Helpviewer");
111 help->showMaximized(); 111 help->showMaximized();
112 help->show(); 112 help->show();
113} 113}
114 114
115void HelpMe::help() 115void HelpMe::help()
116{ 116{
117 QString msg ; 117 QString msg ;
118 msg=QPEApplication::qpeDir()+"help/html/gutenbrowser-index.html"; // or where ever this ends up to be 118 msg=QPEApplication::qpeDir()+"help/html/gutenbrowser-index.html"; // or where ever this ends up to be
119odebug << msg << oendl; 119odebug << msg << oendl;
120 QString url = "file://"+msg; 120 QString url = "file://"+msg;
121 goGetit( url); 121 goGetit( url);
122 122
123// QCopEnvelope e("QPE/Application/helpbrowser", "setDocument(QString)" ); 123// QCopEnvelope e("QPE/Application/helpbrowser", "setDocument(QString)" );
124// e << msg; 124// e << msg;
125 125
126// goGetit( msg); 126// goGetit( msg);
127} 127}
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp
index 6aa6392..1ae3b15 100644
--- a/noncore/apps/zsafe/zsafe.cpp
+++ b/noncore/apps/zsafe/zsafe.cpp
@@ -2683,656 +2683,656 @@ void ZSafe::addCategory()
2683 else 2683 else
2684 { 2684 {
2685 categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); 2685 categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
2686#ifdef Q_WS_WIN 2686#ifdef Q_WS_WIN
2687 categoryDialog->setCaption ("Qt " + tr("Category")); 2687 categoryDialog->setCaption ("Qt " + tr("Category"));
2688#endif 2688#endif
2689 dialog = categoryDialog; 2689 dialog = categoryDialog;
2690 connect( dialog->CategoryField, 2690 connect( dialog->CategoryField,
2691 SIGNAL( activated(const QString&)), 2691 SIGNAL( activated(const QString&)),
2692 this, SLOT( categoryFieldActivated(const QString&) ) ); 2692 this, SLOT( categoryFieldActivated(const QString&) ) );
2693 initIcons = true; 2693 initIcons = true;
2694 } 2694 }
2695 2695
2696#ifdef DESKTOP 2696#ifdef DESKTOP
2697#ifndef Q_WS_WIN 2697#ifndef Q_WS_WIN
2698 QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); 2698 QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
2699#else 2699#else
2700 // read all categories from the config file and store 2700 // read all categories from the config file and store
2701 // into a list 2701 // into a list
2702 QFile f (cfgFile); 2702 QFile f (cfgFile);
2703 QStringList list; 2703 QStringList list;
2704 if ( f.open(IO_ReadOnly) ) { // file opened successfully 2704 if ( f.open(IO_ReadOnly) ) { // file opened successfully
2705 QTextStream t( &f ); // use a text stream 2705 QTextStream t( &f ); // use a text stream
2706 QString s; 2706 QString s;
2707 int n = 1; 2707 int n = 1;
2708 while ( !t.eof() ) { // until end of file... 2708 while ( !t.eof() ) { // until end of file...
2709 s = t.readLine(); // line of text excluding '\n' 2709 s = t.readLine(); // line of text excluding '\n'
2710 list.append(s); 2710 list.append(s);
2711 } 2711 }
2712 f.close(); 2712 f.close();
2713 } 2713 }
2714#endif 2714#endif
2715#else 2715#else
2716 // read all categories from the config file and store 2716 // read all categories from the config file and store
2717 // into a list 2717 // into a list
2718 QFile f (cfgFile); 2718 QFile f (cfgFile);
2719 QStringList list; 2719 QStringList list;
2720 if ( f.open(IO_ReadOnly) ) { // file opened successfully 2720 if ( f.open(IO_ReadOnly) ) { // file opened successfully
2721 QTextStream t( &f ); // use a text stream 2721 QTextStream t( &f ); // use a text stream
2722 QString s; 2722 QString s;
2723 while ( !t.eof() ) { // until end of file... 2723 while ( !t.eof() ) { // until end of file...
2724 s = t.readLine(); // line of text excluding '\n' 2724 s = t.readLine(); // line of text excluding '\n'
2725 list.append(s); 2725 list.append(s);
2726 } 2726 }
2727 f.close(); 2727 f.close();
2728 } 2728 }
2729#endif 2729#endif
2730 QStringList::Iterator it = list.begin(); 2730 QStringList::Iterator it = list.begin();
2731 QString categ; 2731 QString categ;
2732 QString firstCategory; 2732 QString firstCategory;
2733 dialog->CategoryField->clear(); // remove all items 2733 dialog->CategoryField->clear(); // remove all items
2734 while( it != list.end() ) 2734 while( it != list.end() )
2735 { 2735 {
2736 QString *cat = new QString (*it); 2736 QString *cat = new QString (*it);
2737 if (cat->contains("-field1", FALSE)) 2737 if (cat->contains("-field1", FALSE))
2738 { 2738 {
2739#ifdef DESKTOP 2739#ifdef DESKTOP
2740#ifndef Q_WS_WIN 2740#ifndef Q_WS_WIN
2741 categ = cat->section ("-field1", 0, 0); 2741 categ = cat->section ("-field1", 0, 0);
2742#else 2742#else
2743 int pos = cat->find ("-field1"); 2743 int pos = cat->find ("-field1");
2744 categ = cat->left (pos); 2744 categ = cat->left (pos);
2745#endif 2745#endif
2746#else 2746#else
2747 int pos = cat->find ("-field1"); 2747 int pos = cat->find ("-field1");
2748 cat->truncate(pos); 2748 cat->truncate(pos);
2749 categ = *cat; 2749 categ = *cat;
2750#endif 2750#endif
2751 if (!categ.isEmpty()) 2751 if (!categ.isEmpty())
2752 { 2752 {
2753 dialog->CategoryField->insertItem (categ, -1); 2753 dialog->CategoryField->insertItem (categ, -1);
2754 if (firstCategory.isEmpty()) 2754 if (firstCategory.isEmpty())
2755 firstCategory = categ; 2755 firstCategory = categ;
2756 } 2756 }
2757 } 2757 }
2758 ++it; 2758 ++it;
2759 } 2759 }
2760 2760
2761 2761
2762 if (firstCategory.isEmpty()) 2762 if (firstCategory.isEmpty())
2763 setCategoryDialogFields(dialog); 2763 setCategoryDialogFields(dialog);
2764 else 2764 else
2765 setCategoryDialogFields(dialog, firstCategory); 2765 setCategoryDialogFields(dialog, firstCategory);
2766 2766
2767 // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); 2767 // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE);
2768 2768
2769 if (initIcons) 2769 if (initIcons)
2770 { 2770 {
2771 Wait waitDialog(this, tr("Wait dialog")); 2771 Wait waitDialog(this, tr("Wait dialog"));
2772 waitDialog.waitLabel->setText(tr("Gathering icons...")); 2772 waitDialog.waitLabel->setText(tr("Gathering icons..."));
2773 waitDialog.show(); 2773 waitDialog.show();
2774 qApp->processEvents(); 2774 qApp->processEvents();
2775 2775
2776#ifdef DESKTOP 2776#ifdef DESKTOP
2777 QDir d(iconPath); 2777 QDir d(iconPath);
2778#else 2778#else
2779 QDir d(QPEApplication::qpeDir() + "/pics/"); 2779 QDir d(QPEApplication::qpeDir() + "pics/");
2780#endif 2780#endif
2781 d.setFilter( QDir::Files); 2781 d.setFilter( QDir::Files);
2782 2782
2783 const QFileInfoList *list = d.entryInfoList(); 2783 const QFileInfoList *list = d.entryInfoList();
2784 QFileInfoListIterator it( *list ); // create list iterator 2784 QFileInfoListIterator it( *list ); // create list iterator
2785 QFileInfo *fi; // pointer for traversing 2785 QFileInfo *fi; // pointer for traversing
2786 2786
2787 dialog->IconField->insertItem("predefined"); 2787 dialog->IconField->insertItem("predefined");
2788 while ( (fi=it.current()) ) { // for each file... 2788 while ( (fi=it.current()) ) { // for each file...
2789 QString fileName = fi->fileName(); 2789 QString fileName = fi->fileName();
2790 if(fileName.right(4) == ".png"){ 2790 if(fileName.right(4) == ".png"){
2791 fileName = fileName.mid(0,fileName.length()-4); 2791 fileName = fileName.mid(0,fileName.length()-4);
2792#ifdef DESKTOP 2792#ifdef DESKTOP
2793 QPixmap imageOfFile; 2793 QPixmap imageOfFile;
2794 imageOfFile.load(iconPath + fi->fileName()); 2794 imageOfFile.load(iconPath + fi->fileName());
2795#else 2795#else
2796 QPixmap imageOfFile(Resource::loadPixmap(fileName)); 2796 QPixmap imageOfFile(Resource::loadPixmap(fileName));
2797#endif 2797#endif
2798 QImage foo = imageOfFile.convertToImage(); 2798 QImage foo = imageOfFile.convertToImage();
2799 foo = foo.smoothScale(16,16); 2799 foo = foo.smoothScale(16,16);
2800 imageOfFile.convertFromImage(foo); 2800 imageOfFile.convertFromImage(foo);
2801 dialog->IconField->insertItem(imageOfFile,fileName); 2801 dialog->IconField->insertItem(imageOfFile,fileName);
2802 } 2802 }
2803 ++it; 2803 ++it;
2804 } 2804 }
2805 waitDialog.hide(); 2805 waitDialog.hide();
2806 } 2806 }
2807 2807
2808#ifndef Q_WS_WIN 2808#ifndef Q_WS_WIN
2809 dialog->show(); 2809 dialog->show();
2810#endif 2810#endif
2811#ifndef DESKTOP 2811#ifndef DESKTOP
2812 // dialog->move (20, 100); 2812 // dialog->move (20, 100);
2813#endif 2813#endif
2814 DialogCode result = (DialogCode) dialog->exec(); 2814 DialogCode result = (DialogCode) dialog->exec();
2815#ifdef DESKTOP 2815#ifdef DESKTOP
2816 result = Accepted; 2816 result = Accepted;
2817#endif 2817#endif
2818 2818
2819 QString category; 2819 QString category;
2820 QString icon; 2820 QString icon;
2821 QString fullIconPath; 2821 QString fullIconPath;
2822 QPixmap *pix; 2822 QPixmap *pix;
2823 if (result == Accepted) 2823 if (result == Accepted)
2824 { 2824 {
2825 modified = true; 2825 modified = true;
2826 category = dialog->CategoryField->currentText(); 2826 category = dialog->CategoryField->currentText();
2827 icon = dialog->IconField->currentText()+".png"; 2827 icon = dialog->IconField->currentText()+".png";
2828 2828
2829#ifndef NO_OPIE 2829#ifndef NO_OPIE
2830 owarn << category << oendl; 2830 owarn << category << oendl;
2831#endif 2831#endif
2832 2832
2833 QListViewItem *li = new ShadedListItem( 1, ListView ); 2833 QListViewItem *li = new ShadedListItem( 1, ListView );
2834 Category *c1 = new Category(); 2834 Category *c1 = new Category();
2835 c1->setCategoryName(category); 2835 c1->setCategoryName(category);
2836 2836
2837 // if (!icon.isEmpty() && !icon.isNull()) 2837 // if (!icon.isEmpty() && !icon.isNull())
2838 if (icon != "predefined.png") 2838 if (icon != "predefined.png")
2839 { 2839 {
2840 // build the full path 2840 // build the full path
2841 fullIconPath = iconPath + icon; 2841 fullIconPath = iconPath + icon;
2842 pix = new QPixmap (fullIconPath); 2842 pix = new QPixmap (fullIconPath);
2843 // pix->resize(14, 14); 2843 // pix->resize(14, 14);
2844 if (!pix->isNull()) 2844 if (!pix->isNull())
2845 { 2845 {
2846 // save the full pixmap name into the config file 2846 // save the full pixmap name into the config file
2847// #ifndef Q_WS_WIN 2847// #ifndef Q_WS_WIN
2848 conf->writeEntry(APP_KEY+category, icon); 2848 conf->writeEntry(APP_KEY+category, icon);
2849// #endif 2849// #endif
2850 saveConf(); 2850 saveConf();
2851 QImage img = pix->convertToImage(); 2851 QImage img = pix->convertToImage();
2852 pix->convertFromImage(img.smoothScale(14,14)); 2852 pix->convertFromImage(img.smoothScale(14,14));
2853 c1->setIcon (*pix); 2853 c1->setIcon (*pix);
2854 c1->setIconName(icon); 2854 c1->setIconName(icon);
2855 } 2855 }
2856 else 2856 else
2857 { 2857 {
2858 QPixmap folder( ( const char** ) general_data ); 2858 QPixmap folder( ( const char** ) general_data );
2859 c1->setIcon (folder); 2859 c1->setIcon (folder);
2860 } 2860 }
2861 } 2861 }
2862 else 2862 else
2863 { 2863 {
2864 c1->setIcon (*getPredefinedIcon(category)); 2864 c1->setIcon (*getPredefinedIcon(category));
2865 } 2865 }
2866 2866
2867 c1->setListItem (li); 2867 c1->setListItem (li);
2868 c1->initListItem(); 2868 c1->initListItem();
2869 categories.insert (c1->getCategoryName(), c1); 2869 categories.insert (c1->getCategoryName(), c1);
2870 2870
2871 saveCategoryDialogFields(dialog); 2871 saveCategoryDialogFields(dialog);
2872 } 2872 }
2873 else 2873 else
2874 { 2874 {
2875 // delete dialog; 2875 // delete dialog;
2876 dialog->hide(); 2876 dialog->hide();
2877 return; 2877 return;
2878 } 2878 }
2879 2879
2880 } 2880 }
2881 2881
2882} 2882}
2883 2883
2884void ZSafe::delCategory() 2884void ZSafe::delCategory()
2885{ 2885{
2886 if (!selectedItem) 2886 if (!selectedItem)
2887 return; 2887 return;
2888 if (isCategory(selectedItem)) 2888 if (isCategory(selectedItem))
2889 { 2889 {
2890 switch( QMessageBox::information( this, tr("ZSafe"), 2890 switch( QMessageBox::information( this, tr("ZSafe"),
2891 tr("Do you want to delete?"), 2891 tr("Do you want to delete?"),
2892 tr("&Delete"), tr("D&on't Delete"), 2892 tr("&Delete"), tr("D&on't Delete"),
2893 0 // Enter == button 0 2893 0 // Enter == button 0
2894 ) ) { // Escape == button 2 2894 ) ) { // Escape == button 2
2895 case 0: // Delete clicked, Alt-S or Enter pressed. 2895 case 0: // Delete clicked, Alt-S or Enter pressed.
2896 // Delete from the category list 2896 // Delete from the category list
2897 modified = true; 2897 modified = true;
2898 categories.remove (selectedItem->text(0)); 2898 categories.remove (selectedItem->text(0));
2899// #ifndef Q_WS_WIN 2899// #ifndef Q_WS_WIN
2900 conf->removeEntry (selectedItem->text(0)); 2900 conf->removeEntry (selectedItem->text(0));
2901// #endif 2901// #endif
2902 saveConf(); 2902 saveConf();
2903 2903
2904 // Delete the selected item and all subitems 2904 // Delete the selected item and all subitems
2905 // step through all subitems 2905 // step through all subitems
2906 QListViewItem *si; 2906 QListViewItem *si;
2907 for (si = selectedItem->firstChild(); 2907 for (si = selectedItem->firstChild();
2908 si != NULL; ) 2908 si != NULL; )
2909 { 2909 {
2910 QListViewItem *_si = si; 2910 QListViewItem *_si = si;
2911 si = si->nextSibling(); 2911 si = si->nextSibling();
2912 selectedItem->takeItem(_si); // remove from view list 2912 selectedItem->takeItem(_si); // remove from view list
2913 if (_si) delete _si; 2913 if (_si) delete _si;
2914 } 2914 }
2915 ListView->takeItem(selectedItem); 2915 ListView->takeItem(selectedItem);
2916 delete selectedItem; 2916 delete selectedItem;
2917 2917
2918 selectedItem = NULL; 2918 selectedItem = NULL;
2919 break; 2919 break;
2920 case 1: // Don't delete 2920 case 1: // Don't delete
2921 break; 2921 break;
2922 } 2922 }
2923 2923
2924 } 2924 }
2925} 2925}
2926 2926
2927void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) 2927void ZSafe::setCategoryDialogFields(CategoryDialog *dialog)
2928{ 2928{
2929 if (!dialog) 2929 if (!dialog)
2930 return; 2930 return;
2931 2931
2932 QString icon; 2932 QString icon;
2933 if (selectedItem) 2933 if (selectedItem)
2934 { 2934 {
2935 dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); 2935 dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name")));
2936 dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); 2936 dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username")));
2937 dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); 2937 dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password")));
2938 dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); 2938 dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment")));
2939 dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); 2939 dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4")));
2940 dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); 2940 dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5")));
2941 2941
2942 Category *cat= categories.find (selectedItem->text(0)); 2942 Category *cat= categories.find (selectedItem->text(0));
2943 if (cat) 2943 if (cat)
2944 { 2944 {
2945 icon = cat->getIconName(); 2945 icon = cat->getIconName();
2946 } 2946 }
2947 else 2947 else
2948 icon = conf->readEntry(APP_KEY+selectedItem->text(0)); 2948 icon = conf->readEntry(APP_KEY+selectedItem->text(0));
2949 } 2949 }
2950 else 2950 else
2951 { 2951 {
2952 dialog->Field1->setText(tr("Name")); 2952 dialog->Field1->setText(tr("Name"));
2953 dialog->Field2->setText(tr("Username")); 2953 dialog->Field2->setText(tr("Username"));
2954 dialog->Field3->setText(tr("Password")); 2954 dialog->Field3->setText(tr("Password"));
2955 dialog->Field4->setText(tr("Comment")); 2955 dialog->Field4->setText(tr("Comment"));
2956 dialog->Field5->setText(tr("Field 4")); 2956 dialog->Field5->setText(tr("Field 4"));
2957 dialog->Field6->setText(tr("Field 5")); 2957 dialog->Field6->setText(tr("Field 5"));
2958 } 2958 }
2959 2959
2960#ifdef DESKTOP 2960#ifdef DESKTOP
2961 QDir d(iconPath); 2961 QDir d(iconPath);
2962#else 2962#else
2963 QDir d(QPEApplication::qpeDir() + "/pics/"); 2963 QDir d(QPEApplication::qpeDir() + "pics/");
2964#endif 2964#endif
2965 d.setFilter( QDir::Files); 2965 d.setFilter( QDir::Files);
2966 2966
2967 const QFileInfoList *list = d.entryInfoList(); 2967 const QFileInfoList *list = d.entryInfoList();
2968 int i=0; 2968 int i=0;
2969 QFileInfoListIterator it( *list ); // create list iterator 2969 QFileInfoListIterator it( *list ); // create list iterator
2970 QFileInfo *fi; // pointer for traversing 2970 QFileInfo *fi; // pointer for traversing
2971 if (icon.isEmpty() || icon.isNull()) 2971 if (icon.isEmpty() || icon.isNull())
2972 { 2972 {
2973 dialog->IconField->setCurrentItem(0); 2973 dialog->IconField->setCurrentItem(0);
2974 } 2974 }
2975 else 2975 else
2976 { 2976 {
2977 while ( (fi=it.current()) ) 2977 while ( (fi=it.current()) )
2978 { // for each file... 2978 { // for each file...
2979 QString fileName = fi->fileName(); 2979 QString fileName = fi->fileName();
2980 if(fileName.right(4) == ".png") 2980 if(fileName.right(4) == ".png")
2981 { 2981 {
2982 fileName = fileName.mid(0,fileName.length()-4); 2982 fileName = fileName.mid(0,fileName.length()-4);
2983 2983
2984 if(fileName+".png"==icon) 2984 if(fileName+".png"==icon)
2985 { 2985 {
2986 dialog->IconField->setCurrentItem(i+1); 2986 dialog->IconField->setCurrentItem(i+1);
2987 break; 2987 break;
2988 } 2988 }
2989 ++i; 2989 ++i;
2990 } 2990 }
2991 ++it; 2991 ++it;
2992 } 2992 }
2993 } 2993 }
2994} 2994}
2995 2995
2996void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) 2996void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category)
2997{ 2997{
2998 if (!dialog) 2998 if (!dialog)
2999 return; 2999 return;
3000 3000
3001 dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); 3001 dialog->Field1->setText(getFieldLabel (category, "1", tr("Name")));
3002 dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); 3002 dialog->Field2->setText(getFieldLabel (category, "2", tr("Username")));
3003 dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); 3003 dialog->Field3->setText(getFieldLabel (category, "3", tr("Password")));
3004 dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); 3004 dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment")));
3005 dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); 3005 dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4")));
3006 dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); 3006 dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5")));
3007 3007
3008 QString icon; 3008 QString icon;
3009 Category *cat= categories.find (category); 3009 Category *cat= categories.find (category);
3010 if (cat) 3010 if (cat)
3011 { 3011 {
3012 icon = cat->getIconName(); 3012 icon = cat->getIconName();
3013 } 3013 }
3014 else 3014 else
3015 icon = conf->readEntry(APP_KEY+category); 3015 icon = conf->readEntry(APP_KEY+category);
3016 3016
3017#ifdef DESKTOP 3017#ifdef DESKTOP
3018 QDir d(iconPath); 3018 QDir d(iconPath);
3019#else 3019#else
3020 QDir d(QPEApplication::qpeDir() + "/pics/"); 3020 QDir d(QPEApplication::qpeDir() + "pics/");
3021#endif 3021#endif
3022 d.setFilter( QDir::Files); 3022 d.setFilter( QDir::Files);
3023 3023
3024 const QFileInfoList *list = d.entryInfoList(); 3024 const QFileInfoList *list = d.entryInfoList();
3025 int i=0; 3025 int i=0;
3026 QFileInfoListIterator it( *list ); // create list iterator 3026 QFileInfoListIterator it( *list ); // create list iterator
3027 QFileInfo *fi; // pointer for traversing 3027 QFileInfo *fi; // pointer for traversing
3028 if (icon.isEmpty() || icon.isNull()) 3028 if (icon.isEmpty() || icon.isNull())
3029 { 3029 {
3030 dialog->IconField->setCurrentItem(0); 3030 dialog->IconField->setCurrentItem(0);
3031 } 3031 }
3032 else 3032 else
3033 { 3033 {
3034 while ( (fi=it.current()) ) 3034 while ( (fi=it.current()) )
3035 { // for each file... 3035 { // for each file...
3036 QString fileName = fi->fileName(); 3036 QString fileName = fi->fileName();
3037 if(fileName.right(4) == ".png") 3037 if(fileName.right(4) == ".png")
3038 { 3038 {
3039 fileName = fileName.mid(0,fileName.length()-4); 3039 fileName = fileName.mid(0,fileName.length()-4);
3040 3040
3041 if(fileName+".png"==icon) 3041 if(fileName+".png"==icon)
3042 { 3042 {
3043 dialog->IconField->setCurrentItem(i+1); 3043 dialog->IconField->setCurrentItem(i+1);
3044 break; 3044 break;
3045 } 3045 }
3046 ++i; 3046 ++i;
3047 } 3047 }
3048 ++it; 3048 ++it;
3049 } 3049 }
3050 } 3050 }
3051} 3051}
3052 3052
3053void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) 3053void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog)
3054{ 3054{
3055 QString app_key = APP_KEY; 3055 QString app_key = APP_KEY;
3056#ifndef DESKTOP 3056#ifndef DESKTOP
3057 conf->setGroup ("fieldDefs"); 3057 conf->setGroup ("fieldDefs");
3058#else 3058#else
3059#ifndef Q_WS_WIN 3059#ifndef Q_WS_WIN
3060 app_key += "/fieldDefs/"; 3060 app_key += "/fieldDefs/";
3061#endif 3061#endif
3062#endif 3062#endif
3063 QString category = dialog->CategoryField->currentText(); 3063 QString category = dialog->CategoryField->currentText();
3064// #ifndef Q_WS_WIN 3064// #ifndef Q_WS_WIN
3065 conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); 3065 conf->writeEntry(app_key+category+"-field1", dialog->Field1->text());
3066 conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); 3066 conf->writeEntry(app_key+category+"-field2", dialog->Field2->text());
3067 conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); 3067 conf->writeEntry(app_key+category+"-field3", dialog->Field3->text());
3068 conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); 3068 conf->writeEntry(app_key+category+"-field4", dialog->Field4->text());
3069 conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); 3069 conf->writeEntry(app_key+category+"-field5", dialog->Field5->text());
3070 conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); 3070 conf->writeEntry(app_key+category+"-field6", dialog->Field6->text());
3071// #endif 3071// #endif
3072 saveConf(); 3072 saveConf();
3073#ifndef DESKTOP 3073#ifndef DESKTOP
3074 conf->setGroup ("zsafe"); 3074 conf->setGroup ("zsafe");
3075#endif 3075#endif
3076} 3076}
3077 3077
3078void ZSafe::editCategory() 3078void ZSafe::editCategory()
3079{ 3079{
3080 if (!selectedItem) 3080 if (!selectedItem)
3081 return; 3081 return;
3082 if (isCategory(selectedItem)) 3082 if (isCategory(selectedItem))
3083 { 3083 {
3084 QString category = selectedItem->text(0); 3084 QString category = selectedItem->text(0);
3085 bool initIcons = false; 3085 bool initIcons = false;
3086 // open the 'Category' dialog 3086 // open the 'Category' dialog
3087 CategoryDialog *dialog; 3087 CategoryDialog *dialog;
3088 if (categoryDialog) 3088 if (categoryDialog)
3089 { 3089 {
3090 dialog = categoryDialog; 3090 dialog = categoryDialog;
3091 } 3091 }
3092 else 3092 else
3093 { 3093 {
3094 categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); 3094 categoryDialog = new CategoryDialog(this, tr("Category"), TRUE);
3095#ifdef Q_WS_WIN 3095#ifdef Q_WS_WIN
3096 categoryDialog->setCaption ("Qt " + tr("Category")); 3096 categoryDialog->setCaption ("Qt " + tr("Category"));
3097#endif 3097#endif
3098 dialog = categoryDialog; 3098 dialog = categoryDialog;
3099 connect( dialog->CategoryField, 3099 connect( dialog->CategoryField,
3100 SIGNAL( activated(const QString&)), 3100 SIGNAL( activated(const QString&)),
3101 this, SLOT( categoryFieldActivated(const QString&) ) ); 3101 this, SLOT( categoryFieldActivated(const QString&) ) );
3102 initIcons = true; 3102 initIcons = true;
3103 } 3103 }
3104 setCategoryDialogFields(dialog); 3104 setCategoryDialogFields(dialog);
3105 3105
3106#ifdef DESKTOP 3106#ifdef DESKTOP
3107#ifndef Q_WS_WIN 3107#ifndef Q_WS_WIN
3108 QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); 3108 QStringList list = conf->entryList( APP_KEY+"/fieldDefs" );
3109#else 3109#else
3110 // read all categories from the config file and store 3110 // read all categories from the config file and store
3111 // into a list 3111 // into a list
3112 QFile f (cfgFile); 3112 QFile f (cfgFile);
3113 QStringList list; 3113 QStringList list;
3114 if ( f.open(IO_ReadOnly) ) { // file opened successfully 3114 if ( f.open(IO_ReadOnly) ) { // file opened successfully
3115 QTextStream t( &f ); // use a text stream 3115 QTextStream t( &f ); // use a text stream
3116 QString s; 3116 QString s;
3117 int n = 1; 3117 int n = 1;
3118 while ( !t.eof() ) { // until end of file... 3118 while ( !t.eof() ) { // until end of file...
3119 s = t.readLine(); // line of text excluding '\n' 3119 s = t.readLine(); // line of text excluding '\n'
3120 list.append(s); 3120 list.append(s);
3121 } 3121 }
3122 f.close(); 3122 f.close();
3123 } 3123 }
3124#endif 3124#endif
3125#else 3125#else
3126 // read all categories from the config file and store 3126 // read all categories from the config file and store
3127 // into a list 3127 // into a list
3128 QFile f (cfgFile); 3128 QFile f (cfgFile);
3129 QStringList list; 3129 QStringList list;
3130 if ( f.open(IO_ReadOnly) ) { // file opened successfully 3130 if ( f.open(IO_ReadOnly) ) { // file opened successfully
3131 QTextStream t( &f ); // use a text stream 3131 QTextStream t( &f ); // use a text stream
3132 QString s; 3132 QString s;
3133 while ( !t.eof() ) { // until end of file... 3133 while ( !t.eof() ) { // until end of file...
3134 s = t.readLine(); // line of text excluding '\n' 3134 s = t.readLine(); // line of text excluding '\n'
3135 list.append(s); 3135 list.append(s);
3136 } 3136 }
3137 f.close(); 3137 f.close();
3138 } 3138 }
3139#endif 3139#endif
3140 QStringList::Iterator it = list.begin(); 3140 QStringList::Iterator it = list.begin();
3141 QString categ; 3141 QString categ;
3142 dialog->CategoryField->clear(); // remove all items 3142 dialog->CategoryField->clear(); // remove all items
3143 int i=0; 3143 int i=0;
3144 bool foundCategory = false; 3144 bool foundCategory = false;
3145 while( it != list.end() ) 3145 while( it != list.end() )
3146 { 3146 {
3147 QString *cat = new QString (*it); 3147 QString *cat = new QString (*it);
3148 if (cat->contains("-field1", FALSE)) 3148 if (cat->contains("-field1", FALSE))
3149 { 3149 {
3150#ifdef DESKTOP 3150#ifdef DESKTOP
3151#ifndef Q_WS_WIN 3151#ifndef Q_WS_WIN
3152 categ = cat->section ("-field1", 0, 0); 3152 categ = cat->section ("-field1", 0, 0);
3153#else 3153#else
3154 int pos = cat->find ("-field1"); 3154 int pos = cat->find ("-field1");
3155 categ = cat->left (pos); 3155 categ = cat->left (pos);
3156#endif 3156#endif
3157#else 3157#else
3158 int pos = cat->find ("-field1"); 3158 int pos = cat->find ("-field1");
3159 cat->truncate(pos); 3159 cat->truncate(pos);
3160 categ = *cat; 3160 categ = *cat;
3161#endif 3161#endif
3162 if (!categ.isEmpty()) 3162 if (!categ.isEmpty())
3163 { 3163 {
3164 dialog->CategoryField->insertItem (categ, i); 3164 dialog->CategoryField->insertItem (categ, i);
3165 if (category.compare(categ) == 0) 3165 if (category.compare(categ) == 0)
3166 { 3166 {
3167 dialog->CategoryField->setCurrentItem(i); 3167 dialog->CategoryField->setCurrentItem(i);
3168 foundCategory = true; 3168 foundCategory = true;
3169 } 3169 }
3170 i++; 3170 i++;
3171 } 3171 }
3172 } 3172 }
3173 ++it; 3173 ++it;
3174 } 3174 }
3175 if (!foundCategory) 3175 if (!foundCategory)
3176 { 3176 {
3177 dialog->CategoryField->insertItem (category, i); 3177 dialog->CategoryField->insertItem (category, i);
3178 dialog->CategoryField->setCurrentItem(i); 3178 dialog->CategoryField->setCurrentItem(i);
3179 } 3179 }
3180 3180
3181 QString icon; 3181 QString icon;
3182 Category *cat= categories.find (selectedItem->text(0)); 3182 Category *cat= categories.find (selectedItem->text(0));
3183 if (cat) 3183 if (cat)
3184 { 3184 {
3185 icon = cat->getIconName(); 3185 icon = cat->getIconName();
3186 } 3186 }
3187 3187
3188 if (initIcons) 3188 if (initIcons)
3189 { 3189 {
3190 3190
3191 Wait waitDialog(this, tr("Wait dialog")); 3191 Wait waitDialog(this, tr("Wait dialog"));
3192 waitDialog.waitLabel->setText(tr("Gathering icons...")); 3192 waitDialog.waitLabel->setText(tr("Gathering icons..."));
3193 waitDialog.show(); 3193 waitDialog.show();
3194 qApp->processEvents(); 3194 qApp->processEvents();
3195 3195
3196#ifdef DESKTOP 3196#ifdef DESKTOP
3197 QDir d(iconPath); 3197 QDir d(iconPath);
3198#else 3198#else
3199 QDir d(QPEApplication::qpeDir() + "/pics/"); 3199 QDir d(QPEApplication::qpeDir() + "pics/");
3200#endif 3200#endif
3201 d.setFilter( QDir::Files); 3201 d.setFilter( QDir::Files);
3202 3202
3203 const QFileInfoList *list = d.entryInfoList(); 3203 const QFileInfoList *list = d.entryInfoList();
3204 int i=0; 3204 int i=0;
3205 QFileInfoListIterator it( *list ); // create list iterator 3205 QFileInfoListIterator it( *list ); // create list iterator
3206 QFileInfo *fi; // pointer for traversing 3206 QFileInfo *fi; // pointer for traversing
3207 if (icon.isEmpty() || icon.isNull()) 3207 if (icon.isEmpty() || icon.isNull())
3208 { 3208 {
3209 dialog->IconField->setCurrentItem(0); 3209 dialog->IconField->setCurrentItem(0);
3210 } 3210 }
3211 3211
3212 dialog->IconField->insertItem("predefined"); 3212 dialog->IconField->insertItem("predefined");
3213 while ( (fi=it.current()) ) { // for each file... 3213 while ( (fi=it.current()) ) { // for each file...
3214 QString fileName = fi->fileName(); 3214 QString fileName = fi->fileName();
3215 if(fileName.right(4) == ".png") 3215 if(fileName.right(4) == ".png")
3216 { 3216 {
3217 fileName = fileName.mid(0,fileName.length()-4); 3217 fileName = fileName.mid(0,fileName.length()-4);
3218#ifdef DESKTOP 3218#ifdef DESKTOP
3219 QPixmap imageOfFile; 3219 QPixmap imageOfFile;
3220 imageOfFile.load(iconPath + fi->fileName()); 3220 imageOfFile.load(iconPath + fi->fileName());
3221#else 3221#else
3222 QPixmap imageOfFile(Resource::loadPixmap(fileName)); 3222 QPixmap imageOfFile(Resource::loadPixmap(fileName));
3223#endif 3223#endif
3224 QImage foo = imageOfFile.convertToImage(); 3224 QImage foo = imageOfFile.convertToImage();
3225 foo = foo.smoothScale(16,16); 3225 foo = foo.smoothScale(16,16);
3226 imageOfFile.convertFromImage(foo); 3226 imageOfFile.convertFromImage(foo);
3227 dialog->IconField->insertItem(imageOfFile,fileName); 3227 dialog->IconField->insertItem(imageOfFile,fileName);
3228 if(fileName+".png"==icon) 3228 if(fileName+".png"==icon)
3229 dialog->IconField->setCurrentItem(i+1); 3229 dialog->IconField->setCurrentItem(i+1);
3230 ++i; 3230 ++i;
3231 } 3231 }
3232 ++it; 3232 ++it;
3233 } 3233 }
3234 waitDialog.hide(); 3234 waitDialog.hide();
3235 } 3235 }
3236 else 3236 else
3237 { 3237 {
3238#ifdef DESKTOP 3238#ifdef DESKTOP
3239 // QDir d(QDir::homeDirPath() + "/pics/"); 3239 // QDir d(QDir::homeDirPath() + "/pics/");
3240 QDir d(iconPath); 3240 QDir d(iconPath);
3241#else 3241#else
3242 QDir d(QPEApplication::qpeDir() + "/pics/"); 3242 QDir d(QPEApplication::qpeDir() + "pics/");
3243#endif 3243#endif
3244 d.setFilter( QDir::Files); 3244 d.setFilter( QDir::Files);
3245 3245
3246 const QFileInfoList *list = d.entryInfoList(); 3246 const QFileInfoList *list = d.entryInfoList();
3247 int i=0; 3247 int i=0;
3248 QFileInfoListIterator it( *list ); // create list iterator 3248 QFileInfoListIterator it( *list ); // create list iterator
3249 QFileInfo *fi; // pointer for traversing 3249 QFileInfo *fi; // pointer for traversing
3250 if (icon.isEmpty() || icon.isNull()) 3250 if (icon.isEmpty() || icon.isNull())
3251 { 3251 {
3252 dialog->IconField->setCurrentItem(0); 3252 dialog->IconField->setCurrentItem(0);
3253 } 3253 }
3254 else 3254 else
3255 { 3255 {
3256 3256
3257 while ( (fi=it.current()) ) 3257 while ( (fi=it.current()) )
3258 { // for each file... 3258 { // for each file...
3259 QString fileName = fi->fileName(); 3259 QString fileName = fi->fileName();
3260 if(fileName.right(4) == ".png") 3260 if(fileName.right(4) == ".png")
3261 { 3261 {
3262 fileName = fileName.mid(0,fileName.length()-4); 3262 fileName = fileName.mid(0,fileName.length()-4);
3263 3263
3264 3264
3265 if(fileName+".png"==icon) 3265 if(fileName+".png"==icon)
3266 { 3266 {
3267 dialog->IconField->setCurrentItem(i+1); 3267 dialog->IconField->setCurrentItem(i+1);
3268 break; 3268 break;
3269 } 3269 }
3270 ++i; 3270 ++i;
3271 } 3271 }
3272 ++it; 3272 ++it;
3273 } 3273 }
3274 } 3274 }
3275 } 3275 }
3276 3276
3277 // dialog->show(); 3277 // dialog->show();
3278#ifndef DESKTOP 3278#ifndef DESKTOP
3279 // dialog->move (20, 100); 3279 // dialog->move (20, 100);
3280#endif 3280#endif
3281 DialogCode result = (DialogCode) dialog->exec(); 3281 DialogCode result = (DialogCode) dialog->exec();
3282#ifdef DESKTOP 3282#ifdef DESKTOP
3283 result = Accepted; 3283 result = Accepted;
3284#endif 3284#endif
3285 3285
3286 QString fullIconPath; 3286 QString fullIconPath;
3287 QPixmap *pix; 3287 QPixmap *pix;
3288 if (result == Accepted) 3288 if (result == Accepted)
3289 { 3289 {
3290 modified = true; 3290 modified = true;
3291 if (category != dialog->CategoryField->currentText()) 3291 if (category != dialog->CategoryField->currentText())
3292 { 3292 {
3293 categories.remove (category); 3293 categories.remove (category);
3294// #ifndef Q_WS_WIN 3294// #ifndef Q_WS_WIN
3295 conf->removeEntry(category); 3295 conf->removeEntry(category);
3296// #endif 3296// #endif
3297 saveConf(); 3297 saveConf();
3298 } 3298 }
3299 3299
3300 category = dialog->CategoryField->currentText(); 3300 category = dialog->CategoryField->currentText();
3301 icon = dialog->IconField->currentText()+".png"; 3301 icon = dialog->IconField->currentText()+".png";
3302 3302
3303 if (cat) 3303 if (cat)
3304 { 3304 {
3305#ifndef NO_OPIE 3305#ifndef NO_OPIE
3306 owarn << "Category found" << oendl; 3306 owarn << "Category found" << oendl;
3307#else 3307#else
3308 qWarning("Category found"); 3308 qWarning("Category found");
3309#endif 3309#endif
3310 3310
3311 // if (!icon.isEmpty() && !icon.isNull()) 3311 // if (!icon.isEmpty() && !icon.isNull())
3312 if (icon != "predefined.png") 3312 if (icon != "predefined.png")
3313 { 3313 {
3314 // build the full path 3314 // build the full path
3315 fullIconPath = iconPath + icon; 3315 fullIconPath = iconPath + icon;
3316 pix = new QPixmap (fullIconPath); 3316 pix = new QPixmap (fullIconPath);
3317 if (!pix->isNull()) 3317 if (!pix->isNull())
3318 { 3318 {
3319 // save the full pixmap name into the config file 3319 // save the full pixmap name into the config file
3320// #ifndef Q_WS_WIN 3320// #ifndef Q_WS_WIN
3321 conf->writeEntry(APP_KEY+category, icon); 3321 conf->writeEntry(APP_KEY+category, icon);
3322// #endif 3322// #endif
3323 saveConf(); 3323 saveConf();
3324 QImage img = pix->convertToImage(); 3324 QImage img = pix->convertToImage();
3325 pix->convertFromImage(img.smoothScale(14,14)); 3325 pix->convertFromImage(img.smoothScale(14,14));
3326 cat->setIconName (icon); 3326 cat->setIconName (icon);
3327 cat->setIcon (*pix); 3327 cat->setIcon (*pix);
3328 } 3328 }
3329 } 3329 }
3330 else 3330 else
3331 { 3331 {
3332// #ifndef Q_WS_WIN 3332// #ifndef Q_WS_WIN
3333 conf->removeEntry (category); 3333 conf->removeEntry (category);
3334// #endif 3334// #endif
3335 saveConf(); 3335 saveConf();
3336 cat->setIcon (*getPredefinedIcon(category)); 3336 cat->setIcon (*getPredefinedIcon(category));
3337 } 3337 }
3338 3338