54 files changed, 260 insertions, 260 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index c44d387..2ba3dca 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,149 +1,149 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #define DEVELOPERS_VERSION | 12 | #define DEVELOPERS_VERSION |
13 | #include "advancedfm.h" | 13 | #include "advancedfm.h" |
14 | 14 | ||
15 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
16 | #include <qpe/config.h> | 16 | #include <qpe/config.h> |
17 | #include <qpe/mimetype.h> | 17 | #include <qpe/mimetype.h> |
18 | #include <qpe/applnk.h> | 18 | #include <qpe/applnk.h> |
19 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | #include <qpe/menubutton.h> | 20 | #include <qpe/menubutton.h> |
21 | 21 | ||
22 | #include <qcombobox.h> | 22 | #include <qcombobox.h> |
23 | #include <qpopupmenu.h> | 23 | #include <qpopupmenu.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
26 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
27 | 27 | ||
28 | 28 | ||
29 | #include <sys/stat.h> | 29 | #include <sys/stat.h> |
30 | #include <time.h> | 30 | #include <time.h> |
31 | #include <dirent.h> | 31 | #include <dirent.h> |
32 | #include <fcntl.h> | 32 | #include <fcntl.h> |
33 | #include <sys/vfs.h> | 33 | #include <sys/vfs.h> |
34 | #include <mntent.h> | 34 | #include <mntent.h> |
35 | 35 | ||
36 | #ifdef NOQUICKLAUNCH | 36 | #ifdef NOQUICKLAUNCH |
37 | AdvancedFm::AdvancedFm( ) | 37 | AdvancedFm::AdvancedFm( ) |
38 | #else | 38 | #else |
39 | AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) | 39 | AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) |
40 | #endif | 40 | #endif |
41 | : QMainWindow( ) { | 41 | : QMainWindow( ) { |
42 | init(); | 42 | init(); |
43 | renameBox = 0; | 43 | renameBox = 0; |
44 | 44 | ||
45 | unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 45 | unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
46 | 46 | ||
47 | initConnections(); | 47 | initConnections(); |
48 | whichTab=1; | 48 | whichTab=1; |
49 | rePopulate(); | 49 | rePopulate(); |
50 | currentPathCombo->setFocus(); | 50 | currentPathCombo->setFocus(); |
51 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); | 51 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); |
52 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 52 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
53 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); | 53 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); |
54 | } | 54 | } |
55 | 55 | ||
56 | AdvancedFm::~AdvancedFm() { | 56 | AdvancedFm::~AdvancedFm() { |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | ||
60 | void AdvancedFm::cleanUp() { | 60 | void AdvancedFm::cleanUp() { |
61 | QString sfile=QDir::homeDirPath(); | 61 | QString sfile=QDir::homeDirPath(); |
62 | if(sfile.right(1) != "/") | 62 | if(sfile.right(1) != "/") |
63 | sfile+="/._temp"; | 63 | sfile+="/._temp"; |
64 | else | 64 | else |
65 | sfile+="._temp"; | 65 | sfile+="._temp"; |
66 | QFile file( sfile); | 66 | QFile file( sfile); |
67 | if(file.exists()) | 67 | if(file.exists()) |
68 | file.remove(); | 68 | file.remove(); |
69 | } | 69 | } |
70 | 70 | ||
71 | void AdvancedFm::tabChanged(QWidget *) { | 71 | void AdvancedFm::tabChanged(QWidget *) { |
72 | // qWarning("tab changed"); | 72 | // qWarning("tab changed"); |
73 | QString path = CurrentDir()->canonicalPath(); | 73 | QString path = CurrentDir()->canonicalPath(); |
74 | currentPathCombo->lineEdit()->setText( path ); | 74 | currentPathCombo->lineEdit()->setText( path ); |
75 | 75 | ||
76 | if(whichTab == 1) { | 76 | if(whichTab == 1) { |
77 | viewMenu->setItemChecked(viewMenu->idAt(0), true); | 77 | viewMenu->setItemChecked(viewMenu->idAt(0), true); |
78 | viewMenu->setItemChecked(viewMenu->idAt(1), false); | 78 | viewMenu->setItemChecked(viewMenu->idAt(1), false); |
79 | } else { | 79 | } else { |
80 | viewMenu->setItemChecked(viewMenu->idAt(0), false); | 80 | viewMenu->setItemChecked(viewMenu->idAt(0), false); |
81 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | 81 | viewMenu->setItemChecked(viewMenu->idAt(1), true); |
82 | } | 82 | } |
83 | 83 | ||
84 | QString fs= getFileSystemType( (const QString &) path); | 84 | QString fs= getFileSystemType( (const QString &) path); |
85 | 85 | ||
86 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 86 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
87 | +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); | 87 | +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); |
88 | chdir( path.latin1()); | 88 | chdir( path.latin1()); |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void AdvancedFm::populateView() { | 92 | void AdvancedFm::populateView() { |
93 | 93 | ||
94 | // qWarning("PopulateView"); | 94 | // qWarning("PopulateView"); |
95 | QPixmap pm; | 95 | QPixmap pm; |
96 | QListView *thisView = CurrentView(); | 96 | QListView *thisView = CurrentView(); |
97 | QDir *thisDir = CurrentDir(); | 97 | QDir *thisDir = CurrentDir(); |
98 | QString path = thisDir->canonicalPath(); | 98 | QString path = thisDir->canonicalPath(); |
99 | 99 | ||
100 | //qWarning("path is "+path); | 100 | //qWarning("path is "+path); |
101 | thisView->clear(); | 101 | thisView->clear(); |
102 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 102 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
103 | thisDir->setMatchAllDirs(TRUE); | 103 | thisDir->setMatchAllDirs(TRUE); |
104 | thisDir->setNameFilter(filterStr); | 104 | thisDir->setNameFilter(filterStr); |
105 | QString fileL, fileS, fileDate; | 105 | QString fileL, fileS, fileDate; |
106 | QString fs= getFileSystemType((const QString &) path); | 106 | QString fs= getFileSystemType((const QString &) path); |
107 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 107 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
108 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); | 108 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); |
109 | bool isDir=FALSE; | 109 | bool isDir=FALSE; |
110 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 110 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
111 | QFileInfoListIterator it(*list); | 111 | QFileInfoListIterator it(*list); |
112 | QFileInfo *fi; | 112 | QFileInfo *fi; |
113 | while ( (fi=it.current()) ) { | 113 | while ( (fi=it.current()) ) { |
114 | if (fi->isSymLink() ) { | 114 | if (fi->isSymLink() ) { |
115 | QString symLink=fi->readLink(); | 115 | QString symLink=fi->readLink(); |
116 | QFileInfo sym( symLink); | 116 | QFileInfo sym( symLink); |
117 | fileS.sprintf( "%10i", sym.size() ); | 117 | fileS.sprintf( "%10i", sym.size() ); |
118 | fileL = fi->fileName() +" -> " + sym.filePath().data(); | 118 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
119 | fileDate = sym.lastModified().toString(); | 119 | fileDate = sym.lastModified().toString(); |
120 | } else { | 120 | } else { |
121 | fileS.sprintf( "%10i", fi->size() ); | 121 | fileS.sprintf( "%10i", fi->size() ); |
122 | fileL = fi->fileName(); | 122 | fileL = fi->fileName(); |
123 | fileDate= fi->lastModified().toString(); | 123 | fileDate= fi->lastModified().toString(); |
124 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { | 124 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
125 | // if(fileL == "..") | 125 | // if(fileL == "..") |
126 | fileL += "/"; | 126 | fileL += "/"; |
127 | isDir=TRUE; | 127 | isDir=TRUE; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | QFileInfo fileInfo( path + "/" + fileL); | 130 | QFileInfo fileInfo( path + "/" + fileL); |
131 | 131 | ||
132 | if(fileL !="./" && fi->exists()) { | 132 | if(fileL !="./" && fi->exists()) { |
133 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | 133 | item = new QListViewItem( thisView, fileL, fileS , fileDate); |
134 | 134 | ||
135 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 135 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
136 | 136 | ||
137 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 137 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
138 | pm = Resource::loadPixmap( "lockedfolder" ); | 138 | pm = Resource::loadPixmap( "lockedfolder" ); |
139 | else | 139 | else |
140 | pm= Resource::loadPixmap( "folder" ); | 140 | pm= Resource::loadPixmap( "folder" ); |
141 | } | 141 | } |
142 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 142 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
143 | pm = Resource::loadPixmap( "exec"); | 143 | pm = Resource::loadPixmap( "exec"); |
144 | } | 144 | } |
145 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 145 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
146 | | fileInfo.permission( QFileInfo::ExeGroup) | 146 | | fileInfo.permission( QFileInfo::ExeGroup) |
147 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 147 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
148 | pm = Resource::loadPixmap( "exec"); | 148 | pm = Resource::loadPixmap( "exec"); |
149 | } | 149 | } |
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index 763ae34..f791c77 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp | |||
@@ -160,127 +160,127 @@ void AdvancedFm::init() { | |||
160 | // TabWidget->insertTab( tab, tr("1")); | 160 | // TabWidget->insertTab( tab, tr("1")); |
161 | 161 | ||
162 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 162 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
163 | tabLayout_2 = new QGridLayout( tab_2 ); | 163 | tabLayout_2 = new QGridLayout( tab_2 ); |
164 | tabLayout_2->setSpacing( 2); | 164 | tabLayout_2->setSpacing( 2); |
165 | tabLayout_2->setMargin( 2); | 165 | tabLayout_2->setMargin( 2); |
166 | 166 | ||
167 | Remote_View = new QListView( tab_2, "Remote_View" ); | 167 | Remote_View = new QListView( tab_2, "Remote_View" ); |
168 | Remote_View->addColumn( tr("File"),130); | 168 | Remote_View->addColumn( tr("File"),130); |
169 | Remote_View->addColumn( tr("Size"),-1); | 169 | Remote_View->addColumn( tr("Size"),-1); |
170 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 170 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
171 | Remote_View->addColumn( tr("Date"),-1); | 171 | Remote_View->addColumn( tr("Date"),-1); |
172 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 172 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
173 | Remote_View->setAllColumnsShowFocus(TRUE); | 173 | Remote_View->setAllColumnsShowFocus(TRUE); |
174 | Remote_View->setMultiSelection( TRUE ); | 174 | Remote_View->setMultiSelection( TRUE ); |
175 | Remote_View->setSelectionMode(QListView::Extended); | 175 | Remote_View->setSelectionMode(QListView::Extended); |
176 | Remote_View->setFocusPolicy(StrongFocus); | 176 | Remote_View->setFocusPolicy(StrongFocus); |
177 | Remote_View->installEventFilter( this ); | 177 | Remote_View->installEventFilter( this ); |
178 | 178 | ||
179 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 179 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
180 | 180 | ||
181 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 181 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
182 | 182 | ||
183 | TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); | 183 | TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); |
184 | TabWidget->setSizeChange( 370 ); | 184 | TabWidget->setSizeChange( 370 ); |
185 | // TabWidget->insertTab( tab_2, tr( "2")); | 185 | // TabWidget->insertTab( tab_2, tr( "2")); |
186 | 186 | ||
187 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); | 187 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); |
188 | tabLayout_3 = new QGridLayout( tab_3 ); | 188 | tabLayout_3 = new QGridLayout( tab_3 ); |
189 | tabLayout_3->setSpacing( 2); | 189 | tabLayout_3->setSpacing( 2); |
190 | tabLayout_3->setMargin( 2); | 190 | tabLayout_3->setMargin( 2); |
191 | 191 | ||
192 | 192 | ||
193 | // OFileDialog fileDialog; | 193 | // OFileDialog fileDialog; |
194 | // fileDialog; | 194 | // fileDialog; |
195 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy | 195 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy |
196 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); | 196 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); |
197 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); | 197 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); |
198 | 198 | ||
199 | QListView *fileTree; | 199 | QListView *fileTree; |
200 | fileTree = new QListView( tab_3, "tree" ); | 200 | fileTree = new QListView( tab_3, "tree" ); |
201 | 201 | ||
202 | 202 | ||
203 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); | 203 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); |
204 | 204 | ||
205 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); | 205 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); |
206 | */ | 206 | */ |
207 | 207 | ||
208 | /////////////// | 208 | /////////////// |
209 | 209 | ||
210 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 210 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
211 | zaurusDevice=TRUE; | 211 | zaurusDevice=TRUE; |
212 | else | 212 | else |
213 | zaurusDevice=FALSE; | 213 | zaurusDevice=FALSE; |
214 | 214 | ||
215 | 215 | ||
216 | if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { | 216 | if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { |
217 | qDebug("not have sd"); | 217 | qDebug("not have sd"); |
218 | sdButton->hide(); | 218 | sdButton->hide(); |
219 | } | 219 | } |
220 | if( !StorageInfo::hasCf() ) { | 220 | if( !StorageInfo::hasCf() ) { |
221 | qDebug("not have cf"); | 221 | qDebug("not have cf"); |
222 | cfButton->hide(); | 222 | cfButton->hide(); |
223 | } | 223 | } |
224 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 224 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
225 | currentDir.setPath( QDir::currentDirPath()); | 225 | currentDir.setPath( QDir::currentDirPath()); |
226 | 226 | ||
227 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 227 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
228 | currentRemoteDir.setPath( QDir::currentDirPath()); | 228 | currentRemoteDir.setPath( QDir::currentDirPath()); |
229 | 229 | ||
230 | // b = TRUE; | 230 | // b = TRUE; |
231 | 231 | ||
232 | filterStr="*"; | 232 | filterStr="*"; |
233 | b=FALSE; | 233 | b=FALSE; |
234 | showMenuHidden(); | 234 | showMenuHidden(); |
235 | TabWidget->setCurrentWidget(0); | 235 | TabWidget->setCurrentWidget(0); |
236 | 236 | ||
237 | } | 237 | } |
238 | 238 | ||
239 | void AdvancedFm::initConnections() | 239 | void AdvancedFm::initConnections() |
240 | { | 240 | { |
241 | 241 | ||
242 | connect( qApp,SIGNAL( aboutToQuit()), | 242 | connect( qApp,SIGNAL( aboutToQuit()), |
243 | this, SLOT( cleanUp()) ); | 243 | this, SLOT( cleanUp()) ); |
244 | connect( qpeDirButton ,SIGNAL(released()), | 244 | connect( qpeDirButton ,SIGNAL(released()), |
245 | this,SLOT( QPEButtonPushed()) ); | 245 | this,SLOT( QPEButtonPushed()) ); |
246 | connect( cfButton ,SIGNAL(released()), | 246 | connect( cfButton ,SIGNAL(released()), |
247 | this,SLOT( CFButtonPushed()) ); | 247 | this,SLOT( CFButtonPushed()) ); |
248 | connect( sdButton ,SIGNAL(released()), | 248 | connect( sdButton ,SIGNAL(released()), |
249 | this,SLOT( SDButtonPushed()) ); | 249 | this,SLOT( SDButtonPushed()) ); |
250 | connect( cdUpButton ,SIGNAL(released()), | 250 | connect( cdUpButton ,SIGNAL(released()), |
251 | this,SLOT( upDir()) ); | 251 | this,SLOT( upDir()) ); |
252 | connect( docButton,SIGNAL(released()), | 252 | connect( docButton,SIGNAL(released()), |
253 | this,SLOT( docButtonPushed()) ); | 253 | this,SLOT( docButtonPushed()) ); |
254 | connect( homeButton,SIGNAL(released()), | 254 | connect( homeButton,SIGNAL(released()), |
255 | this,SLOT( homeButtonPushed()) ); | 255 | this,SLOT( homeButtonPushed()) ); |
256 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 256 | connect( currentPathCombo, SIGNAL( activated(const QString&) ), |
257 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 257 | this, SLOT( currentPathComboActivated(const QString&) ) ); |
258 | 258 | ||
259 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 259 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
260 | this,SLOT(currentPathComboChanged())); | 260 | this,SLOT(currentPathComboChanged())); |
261 | 261 | ||
262 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 262 | connect( Local_View, SIGNAL( clicked(QListViewItem*)), |
263 | this,SLOT( ListClicked(QListViewItem *)) ); | 263 | this,SLOT( ListClicked(QListViewItem*)) ); |
264 | 264 | ||
265 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 265 | connect( Local_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
266 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 266 | this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) ); |
267 | 267 | ||
268 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); | 268 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); |
269 | 269 | ||
270 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 270 | connect( Remote_View, SIGNAL( clicked(QListViewItem*)), |
271 | this,SLOT( ListClicked(QListViewItem *)) ); | 271 | this,SLOT( ListClicked(QListViewItem*)) ); |
272 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 272 | connect( Remote_View, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
273 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 273 | this,SLOT( ListPressed(int,QListViewItem*,const QPoint&,int)) ); |
274 | 274 | ||
275 | connect( TabWidget,SIGNAL(currentChanged(QWidget *)), | 275 | connect( TabWidget,SIGNAL(currentChanged(QWidget*)), |
276 | this,SLOT(tabChanged(QWidget*))); | 276 | this,SLOT(tabChanged(QWidget*))); |
277 | 277 | ||
278 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); | 278 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); |
279 | 279 | ||
280 | connect( menuButton, SIGNAL( selected(const QString &)), SLOT(gotoCustomDir(const QString&))); | 280 | connect( menuButton, SIGNAL( selected(const QString&)), SLOT(gotoCustomDir(const QString&))); |
281 | // connect( menuButton, SIGNAL( selected( int)), SLOT( dirMenuSelected(int))); | 281 | // connect( menuButton, SIGNAL( selected(int)), SLOT( dirMenuSelected(int))); |
282 | connect( viewMenu, SIGNAL( activated(int )), this, SLOT(slotSwitchMenu(int ))); | 282 | connect( viewMenu, SIGNAL( activated(int)), this, SLOT(slotSwitchMenu(int))); |
283 | // connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int))); | 283 | // connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int))); |
284 | 284 | ||
285 | } | 285 | } |
286 | 286 | ||
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 9ad1146..9e740d0 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -588,218 +588,218 @@ void AdvancedFm::runCommand() { | |||
588 | QPEApplication::execDialog( outDlg ); | 588 | QPEApplication::execDialog( outDlg ); |
589 | qApp->processEvents(); | 589 | qApp->processEvents(); |
590 | 590 | ||
591 | } | 591 | } |
592 | } | 592 | } |
593 | 593 | ||
594 | void AdvancedFm::runCommandStd() { | 594 | void AdvancedFm::runCommandStd() { |
595 | if( !CurrentView()->currentItem()) return; | 595 | if( !CurrentView()->currentItem()) return; |
596 | QString curFile; | 596 | QString curFile; |
597 | QDir *thisDir = CurrentDir(); | 597 | QDir *thisDir = CurrentDir(); |
598 | QListView *thisView = CurrentView(); | 598 | QListView *thisView = CurrentView(); |
599 | if( thisView->currentItem()) | 599 | if( thisView->currentItem()) |
600 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 600 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
601 | 601 | ||
602 | InputDialog *fileDlg; | 602 | InputDialog *fileDlg; |
603 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 603 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
604 | fileDlg->setInputText(curFile); | 604 | fileDlg->setInputText(curFile); |
605 | fileDlg->exec(); | 605 | fileDlg->exec(); |
606 | 606 | ||
607 | if( fileDlg->result() == 1 ) { | 607 | if( fileDlg->result() == 1 ) { |
608 | qApp->processEvents(); | 608 | qApp->processEvents(); |
609 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 609 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
610 | } | 610 | } |
611 | } | 611 | } |
612 | 612 | ||
613 | void AdvancedFm::fileStatus() { | 613 | void AdvancedFm::fileStatus() { |
614 | if( !CurrentView()->currentItem()) return; | 614 | if( !CurrentView()->currentItem()) return; |
615 | QString curFile; | 615 | QString curFile; |
616 | curFile = CurrentView()->currentItem()->text(0); | 616 | curFile = CurrentView()->currentItem()->text(0); |
617 | 617 | ||
618 | QStringList command; | 618 | QStringList command; |
619 | command << "/bin/sh"; | 619 | command << "/bin/sh"; |
620 | command << "-c"; | 620 | command << "-c"; |
621 | command << "stat -l "+ curFile; | 621 | command << "stat -l "+ curFile; |
622 | 622 | ||
623 | Output *outDlg; | 623 | Output *outDlg; |
624 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 624 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
625 | QPEApplication::execDialog( outDlg ); | 625 | QPEApplication::execDialog( outDlg ); |
626 | qApp->processEvents(); | 626 | qApp->processEvents(); |
627 | } | 627 | } |
628 | 628 | ||
629 | 629 | ||
630 | void AdvancedFm::mkDir() { | 630 | void AdvancedFm::mkDir() { |
631 | makeDir(); | 631 | makeDir(); |
632 | } | 632 | } |
633 | 633 | ||
634 | void AdvancedFm::rn() { | 634 | void AdvancedFm::rn() { |
635 | renameIt(); | 635 | renameIt(); |
636 | } | 636 | } |
637 | 637 | ||
638 | void AdvancedFm::del() { | 638 | void AdvancedFm::del() { |
639 | doDelete(); | 639 | doDelete(); |
640 | } | 640 | } |
641 | 641 | ||
642 | void AdvancedFm::mkSym() { | 642 | void AdvancedFm::mkSym() { |
643 | QString cmd; | 643 | QString cmd; |
644 | QStringList curFileList = getPath(); | 644 | QStringList curFileList = getPath(); |
645 | if( curFileList.count() > 0) { | 645 | if( curFileList.count() > 0) { |
646 | QDir *thisDir = CurrentDir(); | 646 | QDir *thisDir = CurrentDir(); |
647 | QDir * thatDir = OtherDir(); | 647 | QDir * thatDir = OtherDir(); |
648 | 648 | ||
649 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 649 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
650 | 650 | ||
651 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 651 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
652 | if(destName.right(1) == "/") { | 652 | if(destName.right(1) == "/") { |
653 | destName = destName.left( destName.length() -1); | 653 | destName = destName.left( destName.length() -1); |
654 | } | 654 | } |
655 | 655 | ||
656 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 656 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
657 | 657 | ||
658 | if( curFile.right(1) == "/") { | 658 | if( curFile.right(1) == "/") { |
659 | curFile = curFile.left( curFile.length() -1); | 659 | curFile = curFile.left( curFile.length() -1); |
660 | } | 660 | } |
661 | 661 | ||
662 | cmd = "ln -s "+curFile+" "+destName; | 662 | cmd = "ln -s "+curFile+" "+destName; |
663 | // qDebug(cmd); | 663 | // qDebug(cmd); |
664 | startProcess( (const QString)cmd ); | 664 | startProcess( (const QString)cmd ); |
665 | } | 665 | } |
666 | rePopulate(); | 666 | rePopulate(); |
667 | setOtherTabCurrent(); | 667 | setOtherTabCurrent(); |
668 | } | 668 | } |
669 | } | 669 | } |
670 | 670 | ||
671 | void AdvancedFm::doBeam() { | 671 | void AdvancedFm::doBeam() { |
672 | Ir ir; | 672 | Ir ir; |
673 | if(!ir.supported()) { | 673 | if(!ir.supported()) { |
674 | } else { | 674 | } else { |
675 | QStringList curFileList = getPath(); | 675 | QStringList curFileList = getPath(); |
676 | if( curFileList.count() > 0) { | 676 | if( curFileList.count() > 0) { |
677 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 677 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
678 | QString curFile = (*it); | 678 | QString curFile = (*it); |
679 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; | 679 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
680 | if( curFilePath.right(1) == "/") { | 680 | if( curFilePath.right(1) == "/") { |
681 | curFilePath = curFilePath.left( curFilePath.length() -1); | 681 | curFilePath = curFilePath.left( curFilePath.length() -1); |
682 | } | 682 | } |
683 | Ir *file = new Ir(this, "IR"); | 683 | Ir *file = new Ir(this, "IR"); |
684 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 684 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); |
685 | file->send( curFilePath, curFile ); | 685 | file->send( curFilePath, curFile ); |
686 | } | 686 | } |
687 | } | 687 | } |
688 | } | 688 | } |
689 | } | 689 | } |
690 | 690 | ||
691 | void AdvancedFm::fileBeamFinished( Ir *) { | 691 | void AdvancedFm::fileBeamFinished( Ir *) { |
692 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 692 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
693 | } | 693 | } |
694 | 694 | ||
695 | void AdvancedFm::selectAll() { | 695 | void AdvancedFm::selectAll() { |
696 | QListView *thisView = CurrentView(); | 696 | QListView *thisView = CurrentView(); |
697 | thisView->selectAll(true); | 697 | thisView->selectAll(true); |
698 | thisView->setSelected( thisView->firstChild(),false); | 698 | thisView->setSelected( thisView->firstChild(),false); |
699 | } | 699 | } |
700 | 700 | ||
701 | void AdvancedFm::startProcess(const QString & cmd) { | 701 | void AdvancedFm::startProcess(const QString & cmd) { |
702 | QStringList command; | 702 | QStringList command; |
703 | OProcess *process; | 703 | OProcess *process; |
704 | process = new OProcess(); | 704 | process = new OProcess(); |
705 | connect(process, SIGNAL(processExited(OProcess *)), | 705 | connect(process, SIGNAL(processExited(OProcess*)), |
706 | this, SLOT( processEnded(OProcess *))); | 706 | this, SLOT( processEnded(OProcess*))); |
707 | 707 | ||
708 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), | 708 | connect(process, SIGNAL( receivedStderr(OProcess*,char*,int)), |
709 | this, SLOT( oprocessStderr(OProcess *, char *, int))); | 709 | this, SLOT( oprocessStderr(OProcess*,char*,int))); |
710 | 710 | ||
711 | command << "/bin/sh"; | 711 | command << "/bin/sh"; |
712 | command << "-c"; | 712 | command << "-c"; |
713 | command << cmd.latin1(); | 713 | command << cmd.latin1(); |
714 | *process << command; | 714 | *process << command; |
715 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 715 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
716 | qDebug("could not start process"); | 716 | qDebug("could not start process"); |
717 | } | 717 | } |
718 | 718 | ||
719 | void AdvancedFm::processEnded(OProcess *) { | 719 | void AdvancedFm::processEnded(OProcess *) { |
720 | rePopulate(); | 720 | rePopulate(); |
721 | } | 721 | } |
722 | 722 | ||
723 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 723 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
724 | // qWarning("received stderrt %d bytes", buflen); | 724 | // qWarning("received stderrt %d bytes", buflen); |
725 | 725 | ||
726 | QString lineStr = buffer; | 726 | QString lineStr = buffer; |
727 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 727 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
728 | } | 728 | } |
729 | 729 | ||
730 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 730 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
731 | if ( o->inherits( "QLineEdit" ) ) { | 731 | if ( o->inherits( "QLineEdit" ) ) { |
732 | if ( e->type() == QEvent::KeyPress ) { | 732 | if ( e->type() == QEvent::KeyPress ) { |
733 | QKeyEvent *ke = (QKeyEvent*)e; | 733 | QKeyEvent *ke = (QKeyEvent*)e; |
734 | if ( ke->key() == Key_Return || | 734 | if ( ke->key() == Key_Return || |
735 | ke->key() == Key_Enter ) { | 735 | ke->key() == Key_Enter ) { |
736 | okRename(); | 736 | okRename(); |
737 | return true; | 737 | return true; |
738 | } | 738 | } |
739 | else if ( ke->key() == Key_Escape ) { | 739 | else if ( ke->key() == Key_Escape ) { |
740 | cancelRename(); | 740 | cancelRename(); |
741 | return true; | 741 | return true; |
742 | } | 742 | } |
743 | } | 743 | } |
744 | else if ( e->type() == QEvent::FocusOut ) { | 744 | else if ( e->type() == QEvent::FocusOut ) { |
745 | cancelRename(); | 745 | cancelRename(); |
746 | return true; | 746 | return true; |
747 | } | 747 | } |
748 | } | 748 | } |
749 | if ( o->inherits( "QListView" ) ) { | 749 | if ( o->inherits( "QListView" ) ) { |
750 | if ( e->type() == QEvent::FocusIn ) { | 750 | if ( e->type() == QEvent::FocusIn ) { |
751 | if( o == Local_View) { //keep track of which view | 751 | if( o == Local_View) { //keep track of which view |
752 | whichTab=1; | 752 | whichTab=1; |
753 | } | 753 | } |
754 | else { | 754 | else { |
755 | whichTab=2; | 755 | whichTab=2; |
756 | } | 756 | } |
757 | } | 757 | } |
758 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | 758 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection |
759 | } | 759 | } |
760 | 760 | ||
761 | return QWidget::eventFilter( o, e ); | 761 | return QWidget::eventFilter( o, e ); |
762 | } | 762 | } |
763 | 763 | ||
764 | 764 | ||
765 | void AdvancedFm::cancelRename() { | 765 | void AdvancedFm::cancelRename() { |
766 | // qDebug("cancel rename"); | 766 | // qDebug("cancel rename"); |
767 | QListView * view; | 767 | QListView * view; |
768 | view = CurrentView(); | 768 | view = CurrentView(); |
769 | 769 | ||
770 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 770 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
771 | delete renameBox; | 771 | delete renameBox; |
772 | renameBox = 0; | 772 | renameBox = 0; |
773 | if ( resetFocus ) { | 773 | if ( resetFocus ) { |
774 | view->viewport()->setFocusProxy( view); | 774 | view->viewport()->setFocusProxy( view); |
775 | view->setFocus(); | 775 | view->setFocus(); |
776 | } | 776 | } |
777 | } | 777 | } |
778 | 778 | ||
779 | void AdvancedFm::doRename(QListView * view) { | 779 | void AdvancedFm::doRename(QListView * view) { |
780 | if( !CurrentView()->currentItem()) return; | 780 | if( !CurrentView()->currentItem()) return; |
781 | 781 | ||
782 | QRect r = view->itemRect( view->currentItem( )); | 782 | QRect r = view->itemRect( view->currentItem( )); |
783 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 783 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
784 | r.setX( view->contentsX() ); | 784 | r.setX( view->contentsX() ); |
785 | 785 | ||
786 | if ( r.width() > view->visibleWidth() ) | 786 | if ( r.width() > view->visibleWidth() ) |
787 | r.setWidth( view->visibleWidth() ); | 787 | r.setWidth( view->visibleWidth() ); |
788 | 788 | ||
789 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 789 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
790 | renameBox->setFrame(true); | 790 | renameBox->setFrame(true); |
791 | 791 | ||
792 | renameBox->setText( view->currentItem()->text(0) ); | 792 | renameBox->setText( view->currentItem()->text(0) ); |
793 | 793 | ||
794 | renameBox->selectAll(); | 794 | renameBox->selectAll(); |
795 | renameBox->installEventFilter( this ); | 795 | renameBox->installEventFilter( this ); |
796 | 796 | ||
797 | view->addChild( renameBox, r.x(), r.y() ); | 797 | view->addChild( renameBox, r.x(), r.y() ); |
798 | 798 | ||
799 | renameBox->resize( r.size() ); | 799 | renameBox->resize( r.size() ); |
800 | 800 | ||
801 | view->viewport()->setFocusProxy( renameBox ); | 801 | view->viewport()->setFocusProxy( renameBox ); |
802 | 802 | ||
803 | renameBox->setFocus(); | 803 | renameBox->setFocus(); |
804 | renameBox->show(); | 804 | renameBox->show(); |
805 | } | 805 | } |
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp index 7dc2416..0bba1d8 100644 --- a/noncore/apps/advancedfm/output.cpp +++ b/noncore/apps/advancedfm/output.cpp | |||
@@ -48,229 +48,229 @@ static char * filesave_xpm[] = { | |||
48 | "} c #777777", | 48 | "} c #777777", |
49 | "| c #616161", | 49 | "| c #616161", |
50 | "1 c #3A3A3A", | 50 | "1 c #3A3A3A", |
51 | "2 c #BEBEBE", | 51 | "2 c #BEBEBE", |
52 | "3 c #2C2C2C", | 52 | "3 c #2C2C2C", |
53 | "4 c #7C7C7C", | 53 | "4 c #7C7C7C", |
54 | "5 c #F6F6F6", | 54 | "5 c #F6F6F6", |
55 | "6 c #FCFCFC", | 55 | "6 c #FCFCFC", |
56 | "7 c #6B6B6B", | 56 | "7 c #6B6B6B", |
57 | "8 c #959595", | 57 | "8 c #959595", |
58 | "9 c #4F4F4F", | 58 | "9 c #4F4F4F", |
59 | "0 c #808080", | 59 | "0 c #808080", |
60 | "a c #767676", | 60 | "a c #767676", |
61 | "b c #818181", | 61 | "b c #818181", |
62 | "c c #B8B8B8", | 62 | "c c #B8B8B8", |
63 | "d c #FBFBFB", | 63 | "d c #FBFBFB", |
64 | "e c #F9F9F9", | 64 | "e c #F9F9F9", |
65 | "f c #CCCCCC", | 65 | "f c #CCCCCC", |
66 | "g c #030303", | 66 | "g c #030303", |
67 | "h c #737373", | 67 | "h c #737373", |
68 | "i c #7A7A7A", | 68 | "i c #7A7A7A", |
69 | "j c #7E7E7E", | 69 | "j c #7E7E7E", |
70 | "k c #6A6A6A", | 70 | "k c #6A6A6A", |
71 | "l c #FAFAFA", | 71 | "l c #FAFAFA", |
72 | "m c #505050", | 72 | "m c #505050", |
73 | "n c #9D9D9D", | 73 | "n c #9D9D9D", |
74 | "o c #333333", | 74 | "o c #333333", |
75 | "p c #7B7B7B", | 75 | "p c #7B7B7B", |
76 | "q c #787878", | 76 | "q c #787878", |
77 | "r c #696969", | 77 | "r c #696969", |
78 | "s c #494949", | 78 | "s c #494949", |
79 | "t c #555555", | 79 | "t c #555555", |
80 | "u c #949494", | 80 | "u c #949494", |
81 | "v c #E6E6E6", | 81 | "v c #E6E6E6", |
82 | "w c #424242", | 82 | "w c #424242", |
83 | "x c #515151", | 83 | "x c #515151", |
84 | "y c #535353", | 84 | "y c #535353", |
85 | "z c #3E3E3E", | 85 | "z c #3E3E3E", |
86 | "A c #D4D4D4", | 86 | "A c #D4D4D4", |
87 | "B c #0C0C0C", | 87 | "B c #0C0C0C", |
88 | "C c #353535", | 88 | "C c #353535", |
89 | "D c #474747", | 89 | "D c #474747", |
90 | "E c #ECECEC", | 90 | "E c #ECECEC", |
91 | "F c #919191", | 91 | "F c #919191", |
92 | "G c #7D7D7D", | 92 | "G c #7D7D7D", |
93 | "H c #000000", | 93 | "H c #000000", |
94 | "I c #404040", | 94 | "I c #404040", |
95 | "J c #858585", | 95 | "J c #858585", |
96 | "K c #323232", | 96 | "K c #323232", |
97 | "L c #D0D0D0", | 97 | "L c #D0D0D0", |
98 | "M c #1C1C1C", | 98 | "M c #1C1C1C", |
99 | " ...+ ", | 99 | " ...+ ", |
100 | " @#$%&..+ ", | 100 | " @#$%&..+ ", |
101 | " .*=-;;>,..+ ", | 101 | " .*=-;;>,..+ ", |
102 | " ')!~;;;;;;{]..", | 102 | " ')!~;;;;;;{]..", |
103 | " ^/(-;;;;;;;_:<", | 103 | " ^/(-;;;;;;;_:<", |
104 | " [}|;;;;;;;{12$", | 104 | " [}|;;;;;;;{12$", |
105 | " #34-55;;;;678$+", | 105 | " #34-55;;;;678$+", |
106 | " 90ab=c;dd;e1fg ", | 106 | " 90ab=c;dd;e1fg ", |
107 | " [ahij((kbl0mn$ ", | 107 | " [ahij((kbl0mn$ ", |
108 | " op^q^^7r&]s/$+ ", | 108 | " op^q^^7r&]s/$+ ", |
109 | "@btu;vbwxy]zAB ", | 109 | "@btu;vbwxy]zAB ", |
110 | "CzDEvEv;;DssF$ ", | 110 | "CzDEvEv;;DssF$ ", |
111 | "G.H{E{E{IxsJ$+ ", | 111 | "G.H{E{E{IxsJ$+ ", |
112 | " +...vEKxzLM ", | 112 | " +...vEKxzLM ", |
113 | " +...z]n$ ", | 113 | " +...z]n$ ", |
114 | " +... "}; | 114 | " +... "}; |
115 | 115 | ||
116 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) | 116 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) |
117 | : QDialog( parent, name, modal, fl ) | 117 | : QDialog( parent, name, modal, fl ) |
118 | { | 118 | { |
119 | QStringList cmmds; | 119 | QStringList cmmds; |
120 | // cmmds=QStringList::split( " ", commands, false); | 120 | // cmmds=QStringList::split( " ", commands, false); |
121 | cmmds=commands; | 121 | cmmds=commands; |
122 | // qDebug("count %d", cmmds.count()); | 122 | // qDebug("count %d", cmmds.count()); |
123 | if ( !name ) | 123 | if ( !name ) |
124 | setName( tr("Output")); | 124 | setName( tr("Output")); |
125 | resize( 196, 269 ); | 125 | resize( 196, 269 ); |
126 | setCaption( name ); | 126 | setCaption( name ); |
127 | 127 | ||
128 | OutputLayout = new QGridLayout( this ); | 128 | OutputLayout = new QGridLayout( this ); |
129 | OutputLayout->setSpacing( 2); | 129 | OutputLayout->setSpacing( 2); |
130 | OutputLayout->setMargin( 2); | 130 | OutputLayout->setMargin( 2); |
131 | 131 | ||
132 | QPushButton *docButton; | 132 | QPushButton *docButton; |
133 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); | 133 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); |
134 | docButton->setFixedSize( QSize( 20, 20 ) ); | 134 | docButton->setFixedSize( QSize( 20, 20 ) ); |
135 | connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); | 135 | connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); |
136 | // docButton->setFlat(TRUE); | 136 | // docButton->setFlat(TRUE); |
137 | OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); | 137 | OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); |
138 | 138 | ||
139 | OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); | 139 | OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); |
140 | OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); | 140 | OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); |
141 | 141 | ||
142 | proc = new OProcess(); | 142 | proc = new OProcess(); |
143 | 143 | ||
144 | connect(proc, SIGNAL(processExited(OProcess *)), | 144 | connect(proc, SIGNAL(processExited(OProcess*)), |
145 | this, SLOT( processFinished())); | 145 | this, SLOT( processFinished())); |
146 | 146 | ||
147 | connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), | 147 | connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)), |
148 | this, SLOT(commandStdout(OProcess *, char *, int))); | 148 | this, SLOT(commandStdout(OProcess*,char*,int))); |
149 | 149 | ||
150 | connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), | 150 | connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)), |
151 | this, SLOT(commandStderr(OProcess *, char *, int))); | 151 | this, SLOT(commandStderr(OProcess*,char*,int))); |
152 | 152 | ||
153 | // connect( , SIGNAL(received(const QByteArray &)), | 153 | // connect( , SIGNAL(received(const QByteArray&)), |
154 | // this, SLOT(commandStdin(const QByteArray &))); | 154 | // this, SLOT(commandStdin(const QByteArray&))); |
155 | 155 | ||
156 | // * proc << commands.latin1(); | 156 | // * proc << commands.latin1(); |
157 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { | 157 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { |
158 | qDebug( "%s", (*it).latin1() ); | 158 | qDebug( "%s", (*it).latin1() ); |
159 | * proc << (*it).latin1(); | 159 | * proc << (*it).latin1(); |
160 | } | 160 | } |
161 | 161 | ||
162 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { | 162 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { |
163 | 163 | ||
164 | OutputEdit->append(tr("Process could not start") ); | 164 | OutputEdit->append(tr("Process could not start") ); |
165 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 165 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
166 | perror("Error: "); | 166 | perror("Error: "); |
167 | QString errorMsg=tr("Error\n")+(QString)strerror(errno); | 167 | QString errorMsg=tr("Error\n")+(QString)strerror(errno); |
168 | OutputEdit->append( errorMsg); | 168 | OutputEdit->append( errorMsg); |
169 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 169 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | Output::~Output() { | 173 | Output::~Output() { |
174 | } | 174 | } |
175 | 175 | ||
176 | void Output::saveOutput() { | 176 | void Output::saveOutput() { |
177 | 177 | ||
178 | InputDialog *fileDlg; | 178 | InputDialog *fileDlg; |
179 | fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); | 179 | fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); |
180 | fileDlg->exec(); | 180 | fileDlg->exec(); |
181 | if( fileDlg->result() == 1 ) { | 181 | if( fileDlg->result() == 1 ) { |
182 | QString filename = QPEApplication::documentDir(); | 182 | QString filename = QPEApplication::documentDir(); |
183 | if(filename.right(1).find('/') == -1) | 183 | if(filename.right(1).find('/') == -1) |
184 | filename+="/"; | 184 | filename+="/"; |
185 | QString name = fileDlg->LineEdit1->text(); | 185 | QString name = fileDlg->LineEdit1->text(); |
186 | filename+="text/plain/"+name; | 186 | filename+="text/plain/"+name; |
187 | qDebug(filename); | 187 | qDebug(filename); |
188 | 188 | ||
189 | QFile f(filename); | 189 | QFile f(filename); |
190 | f.open( IO_WriteOnly); | 190 | f.open( IO_WriteOnly); |
191 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { | 191 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { |
192 | DocLnk lnk; | 192 | DocLnk lnk; |
193 | lnk.setName(name); //sets file name | 193 | lnk.setName(name); //sets file name |
194 | lnk.setFile(filename); //sets File property | 194 | lnk.setFile(filename); //sets File property |
195 | lnk.setType("text/plain"); | 195 | lnk.setType("text/plain"); |
196 | if(!lnk.writeLink()) { | 196 | if(!lnk.writeLink()) { |
197 | qDebug("Writing doclink did not work"); | 197 | qDebug("Writing doclink did not work"); |
198 | } | 198 | } |
199 | } else | 199 | } else |
200 | qWarning("Could not write file"); | 200 | qWarning("Could not write file"); |
201 | f.close(); | 201 | f.close(); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | void Output::commandStdout(OProcess*, char *buffer, int buflen) { | 205 | void Output::commandStdout(OProcess*, char *buffer, int buflen) { |
206 | qWarning("received stdout %d bytes", buflen); | 206 | qWarning("received stdout %d bytes", buflen); |
207 | 207 | ||
208 | // QByteArray data(buflen); | 208 | // QByteArray data(buflen); |
209 | // data.fill(*buffer, buflen); | 209 | // data.fill(*buffer, buflen); |
210 | // for (uint i = 0; i < data.count(); i++ ) { | 210 | // for (uint i = 0; i < data.count(); i++ ) { |
211 | // printf("%c", buffer[i] ); | 211 | // printf("%c", buffer[i] ); |
212 | // } | 212 | // } |
213 | // printf("\n"); | 213 | // printf("\n"); |
214 | 214 | ||
215 | QString lineStr = buffer; | 215 | QString lineStr = buffer; |
216 | lineStr=lineStr.left(lineStr.length()-1); | 216 | lineStr=lineStr.left(lineStr.length()-1); |
217 | OutputEdit->append(lineStr); | 217 | OutputEdit->append(lineStr); |
218 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 218 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | void Output::commandStdin( const QByteArray &data) { | 222 | void Output::commandStdin( const QByteArray &data) { |
223 | qWarning("received stdin %d bytes", data.size()); | 223 | qWarning("received stdin %d bytes", data.size()); |
224 | // recieved data from the io layer goes to sz | 224 | // recieved data from the io layer goes to sz |
225 | proc->writeStdin(data.data(), data.size()); | 225 | proc->writeStdin(data.data(), data.size()); |
226 | } | 226 | } |
227 | 227 | ||
228 | void Output::commandStderr(OProcess*, char *buffer, int buflen) { | 228 | void Output::commandStderr(OProcess*, char *buffer, int buflen) { |
229 | qWarning("received stderrt %d bytes", buflen); | 229 | qWarning("received stderrt %d bytes", buflen); |
230 | 230 | ||
231 | QString lineStr = buffer; | 231 | QString lineStr = buffer; |
232 | // lineStr=lineStr.left(lineStr.length()-1); | 232 | // lineStr=lineStr.left(lineStr.length()-1); |
233 | OutputEdit->append(lineStr); | 233 | OutputEdit->append(lineStr); |
234 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 234 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
235 | } | 235 | } |
236 | 236 | ||
237 | void Output::processFinished() { | 237 | void Output::processFinished() { |
238 | 238 | ||
239 | delete proc; | 239 | delete proc; |
240 | OutputEdit->append( tr("\nFinished\n") ); | 240 | OutputEdit->append( tr("\nFinished\n") ); |
241 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 241 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
242 | // close(); | 242 | // close(); |
243 | // disconnect( layer(), SIGNAL(received(const QByteArray &)), | 243 | // disconnect( layer(), SIGNAL(received(const QByteArray&)), |
244 | // this, SLOT(commandStdin(const QByteArray &))); | 244 | // this, SLOT(commandStdin(const QByteArray&))); |
245 | } | 245 | } |
246 | 246 | ||
247 | //============================== | 247 | //============================== |
248 | 248 | ||
249 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 249 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
250 | : QDialog( parent, name, modal, fl ) | 250 | : QDialog( parent, name, modal, fl ) |
251 | { | 251 | { |
252 | if ( !name ) | 252 | if ( !name ) |
253 | setName( "InputDialog" ); | 253 | setName( "InputDialog" ); |
254 | resize( 234, 50 ); | 254 | resize( 234, 50 ); |
255 | setMaximumSize( QSize( 240, 50 ) ); | 255 | setMaximumSize( QSize( 240, 50 ) ); |
256 | setCaption( tr(name ) ); | 256 | setCaption( tr(name ) ); |
257 | 257 | ||
258 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 258 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
259 | LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); | 259 | LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); |
260 | LineEdit1->setFocus(); | 260 | LineEdit1->setFocus(); |
261 | LineEdit1->setFocus(); | 261 | LineEdit1->setFocus(); |
262 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); | 262 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); |
263 | } | 263 | } |
264 | 264 | ||
265 | InputDialog::~InputDialog() { | 265 | InputDialog::~InputDialog() { |
266 | inputText = LineEdit1->text(); | 266 | inputText = LineEdit1->text(); |
267 | } | 267 | } |
268 | 268 | ||
269 | void InputDialog::setInputText(const QString &string) { | 269 | void InputDialog::setInputText(const QString &string) { |
270 | LineEdit1->setText( string); | 270 | LineEdit1->setText( string); |
271 | } | 271 | } |
272 | 272 | ||
273 | void InputDialog::returned() { | 273 | void InputDialog::returned() { |
274 | inputText = LineEdit1->text(); | 274 | inputText = LineEdit1->text(); |
275 | this->accept(); | 275 | this->accept(); |
276 | } | 276 | } |
diff --git a/noncore/apps/checkbook/checkbook.cpp b/noncore/apps/checkbook/checkbook.cpp index 26b2533..1b933f2 100644 --- a/noncore/apps/checkbook/checkbook.cpp +++ b/noncore/apps/checkbook/checkbook.cpp | |||
@@ -1,340 +1,340 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "checkbook.h" | 29 | #include "checkbook.h" |
30 | #include "cbinfo.h" | 30 | #include "cbinfo.h" |
31 | #include "transaction.h" | 31 | #include "transaction.h" |
32 | #include "traninfo.h" | 32 | #include "traninfo.h" |
33 | #include "graph.h" | 33 | #include "graph.h" |
34 | #include "graphinfo.h" | 34 | #include "graphinfo.h" |
35 | #include "password.h" | 35 | #include "password.h" |
36 | #include "cfg.h" | 36 | #include "cfg.h" |
37 | 37 | ||
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include <qpe/qpemessagebox.h> | 39 | #include <qpe/qpemessagebox.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | 41 | ||
42 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
43 | #include <qcombobox.h> | 43 | #include <qcombobox.h> |
44 | #include <qlabel.h> | 44 | #include <qlabel.h> |
45 | #include <qlayout.h> | 45 | #include <qlayout.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qmultilineedit.h> | 47 | #include <qmultilineedit.h> |
48 | #include <qpushbutton.h> | 48 | #include <qpushbutton.h> |
49 | #include <qwhatsthis.h> | 49 | #include <qwhatsthis.h> |
50 | #include <qpopupmenu.h> | 50 | #include <qpopupmenu.h> |
51 | 51 | ||
52 | #define COL_ID 0 | 52 | #define COL_ID 0 |
53 | #define COL_SORTDATE 1 | 53 | #define COL_SORTDATE 1 |
54 | #define COL_NUM 2 | 54 | #define COL_NUM 2 |
55 | #define COL_DATE 3 | 55 | #define COL_DATE 3 |
56 | #define COL_DESC 4 | 56 | #define COL_DESC 4 |
57 | #define COL_AMOUNT 5 | 57 | #define COL_AMOUNT 5 |
58 | #define COL_BAL 6 | 58 | #define COL_BAL 6 |
59 | 59 | ||
60 | // --- Checkbook -------------------------------------------------------------- | 60 | // --- Checkbook -------------------------------------------------------------- |
61 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) | 61 | Checkbook::Checkbook( QWidget *parent, CBInfo *i, Cfg *cfg ) |
62 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 62 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
63 | { | 63 | { |
64 | info = i; | 64 | info = i; |
65 | _pCfg=cfg; | 65 | _pCfg=cfg; |
66 | 66 | ||
67 | // Title bar | 67 | // Title bar |
68 | if ( info->name() != "" ) | 68 | if ( info->name() != "" ) |
69 | { | 69 | { |
70 | QString tempstr = info->name(); | 70 | QString tempstr = info->name(); |
71 | tempstr.append( " - " ); | 71 | tempstr.append( " - " ); |
72 | tempstr.append( tr( "Checkbook" ) ); | 72 | tempstr.append( tr( "Checkbook" ) ); |
73 | setCaption( tempstr ); | 73 | setCaption( tempstr ); |
74 | } | 74 | } |
75 | else | 75 | else |
76 | { | 76 | { |
77 | setCaption( tr( "New checkbook" ) ); | 77 | setCaption( tr( "New checkbook" ) ); |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | // Setup layout to make everything pretty | 81 | // Setup layout to make everything pretty |
82 | QVBoxLayout *layout = new QVBoxLayout( this ); | 82 | QVBoxLayout *layout = new QVBoxLayout( this ); |
83 | layout->setMargin( 2 ); | 83 | layout->setMargin( 2 ); |
84 | layout->setSpacing( 4 ); | 84 | layout->setSpacing( 4 ); |
85 | 85 | ||
86 | // Setup tabs for all info | 86 | // Setup tabs for all info |
87 | mainWidget = new OTabWidget( this ); | 87 | mainWidget = new OTabWidget( this ); |
88 | layout->addWidget( mainWidget ); | 88 | layout->addWidget( mainWidget ); |
89 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); | 89 | mainWidget->addTab( initInfo(), "checkbook/infotab", tr( "Info" ) ); |
90 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); | 90 | mainWidget->addTab( initTransactions(), "checkbook/trantab", tr( "Transactions" ) ); |
91 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); | 91 | mainWidget->addTab( initCharts(), "checkbook/charttab", tr( "Charts" ) ); |
92 | if( _pCfg->isShowLastTab() ) | 92 | if( _pCfg->isShowLastTab() ) |
93 | mainWidget->setCurrentTab( info->getLastTab() ); | 93 | mainWidget->setCurrentTab( info->getLastTab() ); |
94 | else | 94 | else |
95 | mainWidget->setCurrentTab( tr( "Info" ) ); | 95 | mainWidget->setCurrentTab( tr( "Info" ) ); |
96 | connect( mainWidget, SIGNAL( currentChanged(QWidget *) ), this, SLOT( slotTab(QWidget *) ) ); | 96 | connect( mainWidget, SIGNAL( currentChanged(QWidget*) ), this, SLOT( slotTab(QWidget*) ) ); |
97 | 97 | ||
98 | // Load checkbook information | 98 | // Load checkbook information |
99 | loadCheckbook(); | 99 | loadCheckbook(); |
100 | } | 100 | } |
101 | 101 | ||
102 | Checkbook::~Checkbook() | 102 | Checkbook::~Checkbook() |
103 | { | 103 | { |
104 | } | 104 | } |
105 | 105 | ||
106 | // --- initInfo --------------------------------------------------------------- | 106 | // --- initInfo --------------------------------------------------------------- |
107 | QWidget *Checkbook::initInfo() | 107 | QWidget *Checkbook::initInfo() |
108 | { | 108 | { |
109 | QWidget *control = new QWidget( mainWidget, tr("Info") ); | 109 | QWidget *control = new QWidget( mainWidget, tr("Info") ); |
110 | 110 | ||
111 | QVBoxLayout *vb = new QVBoxLayout( control ); | 111 | QVBoxLayout *vb = new QVBoxLayout( control ); |
112 | 112 | ||
113 | QScrollView *sv = new QScrollView( control ); | 113 | QScrollView *sv = new QScrollView( control ); |
114 | vb->addWidget( sv, 0, 0 ); | 114 | vb->addWidget( sv, 0, 0 ); |
115 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 115 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
116 | sv->setFrameStyle( QFrame::NoFrame ); | 116 | sv->setFrameStyle( QFrame::NoFrame ); |
117 | 117 | ||
118 | QWidget *container = new QWidget( sv->viewport() ); | 118 | QWidget *container = new QWidget( sv->viewport() ); |
119 | sv->addChild( container ); | 119 | sv->addChild( container ); |
120 | 120 | ||
121 | QGridLayout *layout = new QGridLayout( container ); | 121 | QGridLayout *layout = new QGridLayout( container ); |
122 | layout->setSpacing( 2 ); | 122 | layout->setSpacing( 2 ); |
123 | layout->setMargin( 4 ); | 123 | layout->setMargin( 4 ); |
124 | 124 | ||
125 | // Password protection | 125 | // Password protection |
126 | passwordCB = new QCheckBox( tr( "Password protect" ), container ); | 126 | passwordCB = new QCheckBox( tr( "Password protect" ), container ); |
127 | QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); | 127 | QWhatsThis::add( passwordCB, tr( "Click here to enable/disable password protection of this checkbook." ) ); |
128 | connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); | 128 | connect( passwordCB, SIGNAL( clicked() ), this, SLOT( slotPasswordClicked() ) ); |
129 | layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); | 129 | layout->addMultiCellWidget( passwordCB, 0, 0, 0, 1 ); |
130 | 130 | ||
131 | // Account name | 131 | // Account name |
132 | QLabel *label = new QLabel( tr( "Name:" ), container ); | 132 | QLabel *label = new QLabel( tr( "Name:" ), container ); |
133 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); | 133 | QWhatsThis::add( label, tr( "Enter name of checkbook here." ) ); |
134 | layout->addWidget( label, 1, 0 ); | 134 | layout->addWidget( label, 1, 0 ); |
135 | nameEdit = new QLineEdit( container ); | 135 | nameEdit = new QLineEdit( container ); |
136 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); | 136 | QWhatsThis::add( nameEdit, tr( "Enter name of checkbook here." ) ); |
137 | connect( nameEdit, SIGNAL( textChanged( const QString & ) ), | 137 | connect( nameEdit, SIGNAL( textChanged(const QString&) ), |
138 | this, SLOT( slotNameChanged( const QString & ) ) ); | 138 | this, SLOT( slotNameChanged(const QString&) ) ); |
139 | layout->addWidget( nameEdit, 1, 1 ); | 139 | layout->addWidget( nameEdit, 1, 1 ); |
140 | 140 | ||
141 | // Type of account | 141 | // Type of account |
142 | label = new QLabel( tr( "Type:" ), container ); | 142 | label = new QLabel( tr( "Type:" ), container ); |
143 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); | 143 | QWhatsThis::add( label, tr( "Select type of checkbook here." ) ); |
144 | layout->addWidget( label, 2, 0 ); | 144 | layout->addWidget( label, 2, 0 ); |
145 | typeList = new QComboBox( container ); | 145 | typeList = new QComboBox( container ); |
146 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); | 146 | QWhatsThis::add( typeList, tr( "Select type of checkbook here." ) ); |
147 | typeList->insertStringList( _pCfg->getAccountTypes() ); | 147 | typeList->insertStringList( _pCfg->getAccountTypes() ); |
148 | layout->addWidget( typeList, 2, 1 ); | 148 | layout->addWidget( typeList, 2, 1 ); |
149 | 149 | ||
150 | // Bank/institution name | 150 | // Bank/institution name |
151 | label = new QLabel( tr( "Bank:" ), container ); | 151 | label = new QLabel( tr( "Bank:" ), container ); |
152 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); | 152 | QWhatsThis::add( label, tr( "Enter name of the bank for this checkbook here." ) ); |
153 | layout->addWidget( label, 3, 0 ); | 153 | layout->addWidget( label, 3, 0 ); |
154 | bankEdit = new QLineEdit( container ); | 154 | bankEdit = new QLineEdit( container ); |
155 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); | 155 | QWhatsThis::add( bankEdit, tr( "Enter name of the bank for this checkbook here." ) ); |
156 | layout->addWidget( bankEdit, 3, 1 ); | 156 | layout->addWidget( bankEdit, 3, 1 ); |
157 | 157 | ||
158 | // Account number | 158 | // Account number |
159 | label = new QLabel( tr( "Account number:" ), container ); | 159 | label = new QLabel( tr( "Account number:" ), container ); |
160 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); | 160 | QWhatsThis::add( label, tr( "Enter account number for this checkbook here." ) ); |
161 | layout->addWidget( label, 4, 0 ); | 161 | layout->addWidget( label, 4, 0 ); |
162 | acctNumEdit = new QLineEdit( container ); | 162 | acctNumEdit = new QLineEdit( container ); |
163 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); | 163 | QWhatsThis::add( acctNumEdit, tr( "Enter account number for this checkbook here." ) ); |
164 | layout->addWidget( acctNumEdit, 4, 1 ); | 164 | layout->addWidget( acctNumEdit, 4, 1 ); |
165 | 165 | ||
166 | // PIN number | 166 | // PIN number |
167 | label = new QLabel( tr( "PIN number:" ), container ); | 167 | label = new QLabel( tr( "PIN number:" ), container ); |
168 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); | 168 | QWhatsThis::add( label, tr( "Enter PIN number for this checkbook here." ) ); |
169 | layout->addWidget( label, 5, 0 ); | 169 | layout->addWidget( label, 5, 0 ); |
170 | pinNumEdit = new QLineEdit( container ); | 170 | pinNumEdit = new QLineEdit( container ); |
171 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); | 171 | QWhatsThis::add( pinNumEdit, tr( "Enter PIN number for this checkbook here." ) ); |
172 | layout->addWidget( pinNumEdit, 5, 1 ); | 172 | layout->addWidget( pinNumEdit, 5, 1 ); |
173 | 173 | ||
174 | // Starting balance | 174 | // Starting balance |
175 | label = new QLabel( tr( "Starting balance:" ), container ); | 175 | label = new QLabel( tr( "Starting balance:" ), container ); |
176 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); | 176 | QWhatsThis::add( label, tr( "Enter the initial balance for this checkbook here." ) ); |
177 | layout->addWidget( label, 6, 0 ); | 177 | layout->addWidget( label, 6, 0 ); |
178 | balanceEdit = new QLineEdit( container ); | 178 | balanceEdit = new QLineEdit( container ); |
179 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); | 179 | QWhatsThis::add( balanceEdit, tr( "Enter the initial balance for this checkbook here." ) ); |
180 | connect( balanceEdit, SIGNAL( textChanged( const QString & ) ), | 180 | connect( balanceEdit, SIGNAL( textChanged(const QString&) ), |
181 | this, SLOT( slotStartingBalanceChanged( const QString & ) ) ); | 181 | this, SLOT( slotStartingBalanceChanged(const QString&) ) ); |
182 | layout->addWidget( balanceEdit, 6, 1 ); | 182 | layout->addWidget( balanceEdit, 6, 1 ); |
183 | 183 | ||
184 | // Notes | 184 | // Notes |
185 | label = new QLabel( tr( "Notes:" ), container ); | 185 | label = new QLabel( tr( "Notes:" ), container ); |
186 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); | 186 | QWhatsThis::add( label, tr( "Enter any additional information for this checkbook here." ) ); |
187 | layout->addWidget( label, 7, 0 ); | 187 | layout->addWidget( label, 7, 0 ); |
188 | notesEdit = new QMultiLineEdit( container ); | 188 | notesEdit = new QMultiLineEdit( container ); |
189 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); | 189 | QWhatsThis::add( notesEdit, tr( "Enter any additional information for this checkbook here." ) ); |
190 | notesEdit->setMinimumHeight( 25 ); | 190 | notesEdit->setMinimumHeight( 25 ); |
191 | notesEdit->setMaximumHeight( 65 ); | 191 | notesEdit->setMaximumHeight( 65 ); |
192 | layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); | 192 | layout->addMultiCellWidget( notesEdit, 8, 8, 0, 1 ); |
193 | 193 | ||
194 | return control; | 194 | return control; |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | // --- initTransactions ------------------------------------------------------- | 198 | // --- initTransactions ------------------------------------------------------- |
199 | QWidget *Checkbook::initTransactions() | 199 | QWidget *Checkbook::initTransactions() |
200 | { | 200 | { |
201 | QWidget *control = new QWidget( mainWidget, tr("Transactions") ); | 201 | QWidget *control = new QWidget( mainWidget, tr("Transactions") ); |
202 | 202 | ||
203 | QGridLayout *layout = new QGridLayout( control ); | 203 | QGridLayout *layout = new QGridLayout( control ); |
204 | layout->setSpacing( 2 ); | 204 | layout->setSpacing( 2 ); |
205 | layout->setMargin( 4 ); | 205 | layout->setMargin( 4 ); |
206 | 206 | ||
207 | // Sort selector | 207 | // Sort selector |
208 | QLabel *label = new QLabel( tr( "Sort by:" ), control ); | 208 | QLabel *label = new QLabel( tr( "Sort by:" ), control ); |
209 | QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); | 209 | QWhatsThis::add( label, tr( "Select checkbook sorting here." ) ); |
210 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); | 210 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); |
211 | _cbSortType=new QComboBox( control ); | 211 | _cbSortType=new QComboBox( control ); |
212 | _cbSortType->insertItem( tr("Entry Order") ); | 212 | _cbSortType->insertItem( tr("Entry Order") ); |
213 | _cbSortType->insertItem( tr("Date") ); | 213 | _cbSortType->insertItem( tr("Date") ); |
214 | _cbSortType->insertItem( tr("Number") ); | 214 | _cbSortType->insertItem( tr("Number") ); |
215 | layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 ); | 215 | layout->addMultiCellWidget( _cbSortType, 0, 0, 1, 2 ); |
216 | connect( _cbSortType, SIGNAL( activated(const QString &) ), this, SLOT( slotSortChanged( const QString & ) ) ); | 216 | connect( _cbSortType, SIGNAL( activated(const QString&) ), this, SLOT( slotSortChanged(const QString&) ) ); |
217 | 217 | ||
218 | // Table | 218 | // Table |
219 | tranTable = new QListView( control ); | 219 | tranTable = new QListView( control ); |
220 | QFont fnt(QPEApplication::font()); | 220 | QFont fnt(QPEApplication::font()); |
221 | fnt.setPointSize( fnt.pointSize()-1 ); | 221 | fnt.setPointSize( fnt.pointSize()-1 ); |
222 | tranTable->setFont( fnt ); | 222 | tranTable->setFont( fnt ); |
223 | QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); | 223 | QWhatsThis::add( tranTable, tr( "This is a listing of all transactions entered for this checkbook.\n\nTo sort entries by a specific field, click on the column name." ) ); |
224 | tranTable->addColumn( tr( "Id" ) ); | 224 | tranTable->addColumn( tr( "Id" ) ); |
225 | tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); | 225 | tranTable->setColumnWidthMode( COL_ID, QListView::Manual ); |
226 | tranTable->setColumnWidth( COL_ID, 0); | 226 | tranTable->setColumnWidth( COL_ID, 0); |
227 | tranTable->addColumn( tr( "SortDate" ) ); | 227 | tranTable->addColumn( tr( "SortDate" ) ); |
228 | tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual ); | 228 | tranTable->setColumnWidthMode( COL_SORTDATE, QListView::Manual ); |
229 | tranTable->setColumnWidth( COL_SORTDATE, 0); | 229 | tranTable->setColumnWidth( COL_SORTDATE, 0); |
230 | tranTable->addColumn( tr( "Num" ) ); | 230 | tranTable->addColumn( tr( "Num" ) ); |
231 | tranTable->addColumn( tr( "Date" ) ); | 231 | tranTable->addColumn( tr( "Date" ) ); |
232 | //tranTable->addColumn( tr( "Cleared" ) ); | 232 | //tranTable->addColumn( tr( "Cleared" ) ); |
233 | tranTable->addColumn( tr( "Description" ) ); | 233 | tranTable->addColumn( tr( "Description" ) ); |
234 | int column = tranTable->addColumn( tr( "Amount" ) ); | 234 | int column = tranTable->addColumn( tr( "Amount" ) ); |
235 | tranTable->setColumnAlignment( column, Qt::AlignRight ); | 235 | tranTable->setColumnAlignment( column, Qt::AlignRight ); |
236 | column=tranTable->addColumn( tr("Balance") ); | 236 | column=tranTable->addColumn( tr("Balance") ); |
237 | tranTable->setColumnAlignment( column, Qt::AlignRight ); | 237 | tranTable->setColumnAlignment( column, Qt::AlignRight ); |
238 | tranTable->setAllColumnsShowFocus( TRUE ); | 238 | tranTable->setAllColumnsShowFocus( TRUE ); |
239 | tranTable->setSorting( -1 ); | 239 | tranTable->setSorting( -1 ); |
240 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); | 240 | layout->addMultiCellWidget( tranTable, 1, 1, 0, 2 ); |
241 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); | 241 | QPEApplication::setStylusOperation( tranTable->viewport(), QPEApplication::RightOnHold ); |
242 | connect( tranTable, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 242 | connect( tranTable, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
243 | this, SLOT( slotMenuTran(QListViewItem *, const QPoint &) ) ); | 243 | this, SLOT( slotMenuTran(QListViewItem*,const QPoint&) ) ); |
244 | connect( tranTable, SIGNAL( doubleClicked( QListViewItem * ) ), | 244 | connect( tranTable, SIGNAL( doubleClicked(QListViewItem*) ), |
245 | this, SLOT( slotEditTran() ) ); | 245 | this, SLOT( slotEditTran() ) ); |
246 | _sortCol=COL_ID; | 246 | _sortCol=COL_ID; |
247 | 247 | ||
248 | // Buttons | 248 | // Buttons |
249 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); | 249 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), control ); |
250 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); | 250 | QWhatsThis::add( btn, tr( "Click here to add a new transaction." ) ); |
251 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); | 251 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotNewTran() ) ); |
252 | layout->addWidget( btn, 2, 0 ); | 252 | layout->addWidget( btn, 2, 0 ); |
253 | 253 | ||
254 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); | 254 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), control ); |
255 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); | 255 | QWhatsThis::add( btn, tr( "Select a transaction and then click here to edit it." ) ); |
256 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); | 256 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotEditTran() ) ); |
257 | layout->addWidget( btn, 2, 1 ); | 257 | layout->addWidget( btn, 2, 1 ); |
258 | 258 | ||
259 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); | 259 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), control ); |
260 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); | 260 | QWhatsThis::add( btn, tr( "Select a checkbook and then click here to delete it." ) ); |
261 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); | 261 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDeleteTran() ) ); |
262 | layout->addWidget( btn, 2, 2 ); | 262 | layout->addWidget( btn, 2, 2 ); |
263 | 263 | ||
264 | return( control ); | 264 | return( control ); |
265 | } | 265 | } |
266 | 266 | ||
267 | 267 | ||
268 | // --- initCharts ------------------------------------------------------------- | 268 | // --- initCharts ------------------------------------------------------------- |
269 | QWidget *Checkbook::initCharts() | 269 | QWidget *Checkbook::initCharts() |
270 | { | 270 | { |
271 | graphInfo = 0x0; | 271 | graphInfo = 0x0; |
272 | 272 | ||
273 | QWidget *control = new QWidget( mainWidget, tr("Charts") ); | 273 | QWidget *control = new QWidget( mainWidget, tr("Charts") ); |
274 | 274 | ||
275 | QGridLayout *layout = new QGridLayout( control ); | 275 | QGridLayout *layout = new QGridLayout( control ); |
276 | layout->setSpacing( 2 ); | 276 | layout->setSpacing( 2 ); |
277 | layout->setMargin( 4 ); | 277 | layout->setMargin( 4 ); |
278 | 278 | ||
279 | graphWidget = new Graph( control ); | 279 | graphWidget = new Graph( control ); |
280 | QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); | 280 | QWhatsThis::add( graphWidget, tr( "Select the desired chart below and then click on the Draw button." ) ); |
281 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); | 281 | layout->addMultiCellWidget( graphWidget, 0, 0, 0, 2 ); |
282 | 282 | ||
283 | graphList = new QComboBox( control ); | 283 | graphList = new QComboBox( control ); |
284 | QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); | 284 | QWhatsThis::add( graphList, tr( "Click here to select the desired chart type." ) ); |
285 | graphList->insertItem( tr( "Account balance" ) ); | 285 | graphList->insertItem( tr( "Account balance" ) ); |
286 | graphList->insertItem( tr( "Withdrawals by category" ) ); | 286 | graphList->insertItem( tr( "Withdrawals by category" ) ); |
287 | graphList->insertItem( tr( "Deposits by category" ) ); | 287 | graphList->insertItem( tr( "Deposits by category" ) ); |
288 | 288 | ||
289 | layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); | 289 | layout->addMultiCellWidget( graphList, 1, 1, 0, 1 ); |
290 | 290 | ||
291 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); | 291 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/drawbtn" ), tr( "Draw" ), control ); |
292 | QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); | 292 | QWhatsThis::add( btn, tr( "Click here to draw the selected chart." ) ); |
293 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); | 293 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDrawGraph() ) ); |
294 | layout->addWidget( btn, 1, 2 ); | 294 | layout->addWidget( btn, 1, 2 ); |
295 | 295 | ||
296 | return control; | 296 | return control; |
297 | } | 297 | } |
298 | 298 | ||
299 | // --- loadCheckbook ---------------------------------------------------------- | 299 | // --- loadCheckbook ---------------------------------------------------------- |
300 | void Checkbook::loadCheckbook() | 300 | void Checkbook::loadCheckbook() |
301 | { | 301 | { |
302 | if ( !info ) | 302 | if ( !info ) |
303 | { | 303 | { |
304 | return; | 304 | return; |
305 | } | 305 | } |
306 | 306 | ||
307 | tranList = info->transactions(); | 307 | tranList = info->transactions(); |
308 | 308 | ||
309 | passwordCB->setChecked( !info->password().isNull() ); | 309 | passwordCB->setChecked( !info->password().isNull() ); |
310 | nameEdit->setText( info->name() ); | 310 | nameEdit->setText( info->name() ); |
311 | QString temptext = info->type(); | 311 | QString temptext = info->type(); |
312 | int i = typeList->count(); | 312 | int i = typeList->count(); |
313 | while ( i > 0 ) | 313 | while ( i > 0 ) |
314 | { | 314 | { |
315 | i--; | 315 | i--; |
316 | typeList->setCurrentItem( i ); | 316 | typeList->setCurrentItem( i ); |
317 | if ( typeList->currentText() == temptext ) | 317 | if ( typeList->currentText() == temptext ) |
318 | { | 318 | { |
319 | break; | 319 | break; |
320 | } | 320 | } |
321 | } | 321 | } |
322 | if( i<=0 ) { | 322 | if( i<=0 ) { |
323 | typeList->insertItem( temptext, 0 ); | 323 | typeList->insertItem( temptext, 0 ); |
324 | typeList->setCurrentItem(0); | 324 | typeList->setCurrentItem(0); |
325 | } | 325 | } |
326 | bankEdit->setText( info->bank() ); | 326 | bankEdit->setText( info->bank() ); |
327 | acctNumEdit->setText( info->account() ); | 327 | acctNumEdit->setText( info->account() ); |
328 | pinNumEdit->setText( info->pin() ); | 328 | pinNumEdit->setText( info->pin() ); |
329 | temptext.setNum( info->startingBalance(), 'f', 2 ); | 329 | temptext.setNum( info->startingBalance(), 'f', 2 ); |
330 | balanceEdit->setText( temptext ); | 330 | balanceEdit->setText( temptext ); |
331 | notesEdit->setText( info->notes() ); | 331 | notesEdit->setText( info->notes() ); |
332 | 332 | ||
333 | // Load transactions | 333 | // Load transactions |
334 | float amount; | 334 | float amount; |
335 | QString stramount; | 335 | QString stramount; |
336 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) | 336 | for ( TranInfo *tran = tranList->first(); tran; tran = tranList->next() ) |
337 | { | 337 | { |
338 | amount = tran->amount(); | 338 | amount = tran->amount(); |
339 | if ( tran->withdrawal() ) | 339 | if ( tran->withdrawal() ) |
340 | { | 340 | { |
diff --git a/noncore/apps/checkbook/listedit.cpp b/noncore/apps/checkbook/listedit.cpp index 37f05f0..d00e305 100644 --- a/noncore/apps/checkbook/listedit.cpp +++ b/noncore/apps/checkbook/listedit.cpp | |||
@@ -1,168 +1,168 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "listedit.h" | 29 | #include "listedit.h" |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qlistview.h> | 32 | #include <qlistview.h> |
33 | #include <qwidgetstack.h> | 33 | #include <qwidgetstack.h> |
34 | #include <qcombobox.h> | 34 | #include <qcombobox.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
37 | 37 | ||
38 | 38 | ||
39 | // --- ListEdit --------------------------------------------------------------- | 39 | // --- ListEdit --------------------------------------------------------------- |
40 | ListEdit::ListEdit( QWidget *parent, const char *sName ) | 40 | ListEdit::ListEdit( QWidget *parent, const char *sName ) |
41 | : QWidget(parent, sName), TableDef(sName) | 41 | : QWidget(parent, sName), TableDef(sName) |
42 | { | 42 | { |
43 | // get font height | 43 | // get font height |
44 | int fh = fontMetrics().height(); | 44 | int fh = fontMetrics().height(); |
45 | 45 | ||
46 | // create layout | 46 | // create layout |
47 | QGridLayout *layout=new QGridLayout(this); | 47 | QGridLayout *layout=new QGridLayout(this); |
48 | layout->setSpacing( 2 ); | 48 | layout->setSpacing( 2 ); |
49 | layout->setMargin( 4 ); | 49 | layout->setMargin( 4 ); |
50 | 50 | ||
51 | // type table | 51 | // type table |
52 | _typeTable = new QListView( this ); | 52 | _typeTable = new QListView( this ); |
53 | ColumnDef *def=first(); | 53 | ColumnDef *def=first(); |
54 | while( def ) { | 54 | while( def ) { |
55 | _typeTable->addColumn( def->getName() ); | 55 | _typeTable->addColumn( def->getName() ); |
56 | def=next(); | 56 | def=next(); |
57 | } | 57 | } |
58 | connect( _typeTable, SIGNAL( clicked(QListViewItem *, const QPoint &, int) ), this, SLOT( slotClick(QListViewItem *, const QPoint &, int ) ) ); | 58 | connect( _typeTable, SIGNAL( clicked(QListViewItem*,const QPoint&,int) ), this, SLOT( slotClick(QListViewItem*,const QPoint&,int) ) ); |
59 | layout->addMultiCellWidget(_typeTable, 0,4,0,4); | 59 | layout->addMultiCellWidget(_typeTable, 0,4,0,4); |
60 | _currentItem=NULL; | 60 | _currentItem=NULL; |
61 | 61 | ||
62 | // edit field | 62 | // edit field |
63 | _stack=new QWidgetStack( this ); | 63 | _stack=new QWidgetStack( this ); |
64 | _stack->setMaximumHeight(fh+5); | 64 | _stack->setMaximumHeight(fh+5); |
65 | layout->addMultiCellWidget(_stack, 5,5,0,2); | 65 | layout->addMultiCellWidget(_stack, 5,5,0,2); |
66 | _typeEdit = new QLineEdit( _stack ); | 66 | _typeEdit = new QLineEdit( _stack ); |
67 | _stack->raiseWidget(_typeEdit ); | 67 | _stack->raiseWidget(_typeEdit ); |
68 | connect( _typeEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( slotEditChanged(const QString &) ) ); | 68 | connect( _typeEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotEditChanged(const QString&) ) ); |
69 | 69 | ||
70 | // combo box | 70 | // combo box |
71 | _box=new QComboBox( _stack ); | 71 | _box=new QComboBox( _stack ); |
72 | connect( _box, SIGNAL( activated(const QString &) ), this, SLOT( slotActivated(const QString &) ) ); | 72 | connect( _box, SIGNAL( activated(const QString&) ), this, SLOT( slotActivated(const QString&) ) ); |
73 | 73 | ||
74 | 74 | ||
75 | // add button | 75 | // add button |
76 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this ); | 76 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "checkbook/add" ), tr( "Add" ), this ); |
77 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) ); | 77 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotAdd() ) ); |
78 | layout->addWidget( btn, 5, 3 ); | 78 | layout->addWidget( btn, 5, 3 ); |
79 | 79 | ||
80 | // delete button | 80 | // delete button |
81 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); | 81 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), this ); |
82 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) ); | 82 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotDel() ) ); |
83 | layout->addWidget( btn, 5, 4 ); | 83 | layout->addWidget( btn, 5, 4 ); |
84 | } | 84 | } |
85 | 85 | ||
86 | // --- ~ListEdit -------------------------------------------------------------- | 86 | // --- ~ListEdit -------------------------------------------------------------- |
87 | ListEdit::~ListEdit() | 87 | ListEdit::~ListEdit() |
88 | { | 88 | { |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | // --- slotEditTypeChanged ---------------------------------------------------- | 92 | // --- slotEditTypeChanged ---------------------------------------------------- |
93 | void ListEdit::slotEditChanged(const QString &str) | 93 | void ListEdit::slotEditChanged(const QString &str) |
94 | { | 94 | { |
95 | if( !_currentItem || _currentColumn<0 ) return; | 95 | if( !_currentItem || _currentColumn<0 ) return; |
96 | _currentItem->setText(_currentColumn, str); | 96 | _currentItem->setText(_currentColumn, str); |
97 | } | 97 | } |
98 | 98 | ||
99 | // --- slotAddType ------------------------------------------------------------ | 99 | // --- slotAddType ------------------------------------------------------------ |
100 | void ListEdit::slotAdd() | 100 | void ListEdit::slotAdd() |
101 | { | 101 | { |
102 | // construct new row | 102 | // construct new row |
103 | QString args[8]; | 103 | QString args[8]; |
104 | ColumnDef *pCol=this->first(); | 104 | ColumnDef *pCol=this->first(); |
105 | int i=0; | 105 | int i=0; |
106 | while( pCol && i<8 ) { | 106 | while( pCol && i<8 ) { |
107 | args[i++]=pCol->getNewValue(); | 107 | args[i++]=pCol->getNewValue(); |
108 | pCol=this->next(); | 108 | pCol=this->next(); |
109 | } | 109 | } |
110 | _currentItem=new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] ); | 110 | _currentItem=new QListViewItem(_typeTable, args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7] ); |
111 | 111 | ||
112 | // fix uniques | 112 | // fix uniques |
113 | fixTypes(); | 113 | fixTypes(); |
114 | 114 | ||
115 | // display col 0 of new value | 115 | // display col 0 of new value |
116 | QPoint pnt; | 116 | QPoint pnt; |
117 | slotClick(_currentItem, pnt, 0); | 117 | slotClick(_currentItem, pnt, 0); |
118 | _typeTable->setSelected( _currentItem, true ); | 118 | _typeTable->setSelected( _currentItem, true ); |
119 | 119 | ||
120 | // make it selected | 120 | // make it selected |
121 | _typeEdit->setCursorPosition(0); | 121 | _typeEdit->setCursorPosition(0); |
122 | _typeEdit->setSelection(0, _typeEdit->text().length() ); | 122 | _typeEdit->setSelection(0, _typeEdit->text().length() ); |
123 | } | 123 | } |
124 | 124 | ||
125 | // --- slotDel ------------------------------------------------------------- | 125 | // --- slotDel ------------------------------------------------------------- |
126 | void ListEdit::slotDel() | 126 | void ListEdit::slotDel() |
127 | { | 127 | { |
128 | if( !_currentItem ) return; | 128 | if( !_currentItem ) return; |
129 | delete _currentItem; | 129 | delete _currentItem; |
130 | _currentItem=NULL; | 130 | _currentItem=NULL; |
131 | _typeEdit->setText(""); | 131 | _typeEdit->setText(""); |
132 | _stack->raiseWidget(_typeEdit); | 132 | _stack->raiseWidget(_typeEdit); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | // --- fixTypes ---------------------------------------------------------------- | 136 | // --- fixTypes ---------------------------------------------------------------- |
137 | // Makes sure all entries have a unique name and empty entries are replaced | 137 | // Makes sure all entries have a unique name and empty entries are replaced |
138 | // by a generic string. The first version performs the operation on a particular | 138 | // by a generic string. The first version performs the operation on a particular |
139 | // column, whereas the 2nd does it for all unique columns. | 139 | // column, whereas the 2nd does it for all unique columns. |
140 | class ColMap { | 140 | class ColMap { |
141 | public: | 141 | public: |
142 | ColMap(QString sValue, QListViewItem *pEntry) { | 142 | ColMap(QString sValue, QListViewItem *pEntry) { |
143 | _sValue=sValue; | 143 | _sValue=sValue; |
144 | _pEntry=pEntry; | 144 | _pEntry=pEntry; |
145 | } | 145 | } |
146 | QString &getValue() { return(_sValue); } | 146 | QString &getValue() { return(_sValue); } |
147 | QListViewItem *getItem() { return(_pEntry); } | 147 | QListViewItem *getItem() { return(_pEntry); } |
148 | 148 | ||
149 | protected: | 149 | protected: |
150 | QString _sValue; | 150 | QString _sValue; |
151 | QListViewItem *_pEntry; | 151 | QListViewItem *_pEntry; |
152 | }; | 152 | }; |
153 | 153 | ||
154 | class ColList : public QList<QString> | 154 | class ColList : public QList<QString> |
155 | { | 155 | { |
156 | public: | 156 | public: |
157 | ColList() : QList<QString>() { } | 157 | ColList() : QList<QString>() { } |
158 | 158 | ||
159 | protected: | 159 | protected: |
160 | int compareItems(QCollection::Item, QCollection::Item); | 160 | int compareItems(QCollection::Item, QCollection::Item); |
161 | }; | 161 | }; |
162 | 162 | ||
163 | int ColList::compareItems(QCollection::Item i1, QCollection::Item i2) { | 163 | int ColList::compareItems(QCollection::Item i1, QCollection::Item i2) { |
164 | return( ((QString *)i1)->compare(*(QString *)i2) ); | 164 | return( ((QString *)i1)->compare(*(QString *)i2) ); |
165 | } | 165 | } |
166 | 166 | ||
167 | void ListEdit::fixTypes(int iColumn) | 167 | void ListEdit::fixTypes(int iColumn) |
168 | { | 168 | { |
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index d0fac3b..254ce6a 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp | |||
@@ -79,193 +79,193 @@ MainWindow::MainWindow( QWidget* parent, const char* name, WFlags /*fl*/ ) | |||
79 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); | 79 | connect( actionOpen, SIGNAL( activated() ), this, SLOT( slotEdit() ) ); |
80 | actionOpen->addTo( popup ); | 80 | actionOpen->addTo( popup ); |
81 | actionOpen->addTo( bar ); | 81 | actionOpen->addTo( bar ); |
82 | 82 | ||
83 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 83 | actionDelete = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
84 | 0, this, 0 ); | 84 | 0, this, 0 ); |
85 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); | 85 | actionDelete->setWhatsThis( tr( "Select a checkbook and then click here delete it.\n\nYou also can select Delete from the Checkbook menu." ) ); |
86 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); | 86 | connect( actionDelete, SIGNAL( activated() ), this, SLOT( slotDelete() ) ); |
87 | actionDelete->addTo( popup ); | 87 | actionDelete->addTo( popup ); |
88 | actionDelete->addTo( bar ); | 88 | actionDelete->addTo( bar ); |
89 | 89 | ||
90 | popup->insertSeparator(); | 90 | popup->insertSeparator(); |
91 | 91 | ||
92 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 92 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
93 | a->setWhatsThis( tr( "Click here to configure this app." ) ); | 93 | a->setWhatsThis( tr( "Click here to configure this app." ) ); |
94 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); | 94 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfigure() ) ); |
95 | a->addTo( popup ); | 95 | a->addTo( popup ); |
96 | a->addTo( bar ); | 96 | a->addTo( bar ); |
97 | 97 | ||
98 | mb->insertItem( tr( "Checkbook" ), popup ); | 98 | mb->insertItem( tr( "Checkbook" ), popup ); |
99 | 99 | ||
100 | // Load Checkbook selection list | 100 | // Load Checkbook selection list |
101 | checkbooks = new CBInfoList(); | 101 | checkbooks = new CBInfoList(); |
102 | 102 | ||
103 | QDir checkdir( cbDir ); | 103 | QDir checkdir( cbDir ); |
104 | if (checkdir.exists() == true) | 104 | if (checkdir.exists() == true) |
105 | { | 105 | { |
106 | QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, | 106 | QStringList cblist = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, |
107 | QDir::Time ); | 107 | QDir::Time ); |
108 | CBInfo *cb = 0x0; | 108 | CBInfo *cb = 0x0; |
109 | QString filename; | 109 | QString filename; |
110 | 110 | ||
111 | for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) | 111 | for ( QStringList::Iterator it = cblist.begin(); it != cblist.end(); it++ ) |
112 | { | 112 | { |
113 | filename = cbDir; | 113 | filename = cbDir; |
114 | filename.append( (*it) ); | 114 | filename.append( (*it) ); |
115 | 115 | ||
116 | cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); | 116 | cb = new CBInfo( (*it).remove( (*it).find('.'), (*it).length() ), filename ); |
117 | checkbooks->inSort( cb ); | 117 | checkbooks->inSort( cb ); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | // Build Checkbook selection list control | 121 | // Build Checkbook selection list control |
122 | cbList = 0x0; | 122 | cbList = 0x0; |
123 | buildList(); | 123 | buildList(); |
124 | 124 | ||
125 | // open last book? | 125 | // open last book? |
126 | if( _cfg.isOpenLastBook() ) { | 126 | if( _cfg.isOpenLastBook() ) { |
127 | this->show(); | 127 | this->show(); |
128 | this->showMaximized(); | 128 | this->showMaximized(); |
129 | QListViewItem *itm=cbList->firstChild(); | 129 | QListViewItem *itm=cbList->firstChild(); |
130 | while( itm ) { | 130 | while( itm ) { |
131 | if( itm->text(posName)==_cfg.getLastBook() ) { | 131 | if( itm->text(posName)==_cfg.getLastBook() ) { |
132 | openBook( itm ); | 132 | openBook( itm ); |
133 | break; | 133 | break; |
134 | } | 134 | } |
135 | itm=itm->nextSibling(); | 135 | itm=itm->nextSibling(); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | // --- ~MainWindow ------------------------------------------------------------ | 141 | // --- ~MainWindow ------------------------------------------------------------ |
142 | MainWindow::~MainWindow() | 142 | MainWindow::~MainWindow() |
143 | { | 143 | { |
144 | writeConfig(); | 144 | writeConfig(); |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | // --- buildList -------------------------------------------------------------- | 148 | // --- buildList -------------------------------------------------------------- |
149 | void MainWindow::buildList() | 149 | void MainWindow::buildList() |
150 | { | 150 | { |
151 | if ( cbList ) | 151 | if ( cbList ) |
152 | delete cbList; | 152 | delete cbList; |
153 | 153 | ||
154 | cbList = new QListView( this ); | 154 | cbList = new QListView( this ); |
155 | QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); | 155 | QWhatsThis::add( cbList, tr( "This is a listing of all checkbooks currently available." ) ); |
156 | 156 | ||
157 | if ( _cfg.getShowLocks() ) | 157 | if ( _cfg.getShowLocks() ) |
158 | { | 158 | { |
159 | cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); | 159 | cbList->addColumn( Resource::loadIconSet( "locked" ), "", 24 ); |
160 | posName = 1; | 160 | posName = 1; |
161 | } | 161 | } |
162 | else | 162 | else |
163 | { | 163 | { |
164 | posName = 0; | 164 | posName = 0; |
165 | } | 165 | } |
166 | cbList->addColumn( tr( "Checkbook Name" ) ); | 166 | cbList->addColumn( tr( "Checkbook Name" ) ); |
167 | if ( _cfg.getShowBalances() ) | 167 | if ( _cfg.getShowBalances() ) |
168 | { | 168 | { |
169 | int colnum = cbList->addColumn( tr( "Balance" ) ); | 169 | int colnum = cbList->addColumn( tr( "Balance" ) ); |
170 | cbList->setColumnAlignment( colnum, Qt::AlignRight ); | 170 | cbList->setColumnAlignment( colnum, Qt::AlignRight ); |
171 | } | 171 | } |
172 | cbList->setAllColumnsShowFocus( TRUE ); | 172 | cbList->setAllColumnsShowFocus( TRUE ); |
173 | cbList->setSorting( posName ); | 173 | cbList->setSorting( posName ); |
174 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); | 174 | QPEApplication::setStylusOperation( cbList->viewport(), QPEApplication::RightOnHold ); |
175 | connect( cbList, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 175 | connect( cbList, SIGNAL( rightButtonPressed(QListViewItem*,const QPoint&,int) ), |
176 | this, SLOT( slotEdit() ) ); | 176 | this, SLOT( slotEdit() ) ); |
177 | setCentralWidget( cbList ); | 177 | setCentralWidget( cbList ); |
178 | 178 | ||
179 | for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) | 179 | for ( CBInfo *cb = checkbooks->first(); cb; cb = checkbooks->next() ) |
180 | { | 180 | { |
181 | addCheckbook( cb ); | 181 | addCheckbook( cb ); |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | void MainWindow::addCheckbook( CBInfo *cb ) | 185 | void MainWindow::addCheckbook( CBInfo *cb ) |
186 | { | 186 | { |
187 | QListViewItem *lvi = new QListViewItem( cbList ); | 187 | QListViewItem *lvi = new QListViewItem( cbList ); |
188 | if ( _cfg.getShowLocks() && !cb->password().isNull() ) | 188 | if ( _cfg.getShowLocks() && !cb->password().isNull() ) |
189 | { | 189 | { |
190 | lvi->setPixmap( 0, lockIcon ); | 190 | lvi->setPixmap( 0, lockIcon ); |
191 | } | 191 | } |
192 | lvi->setText( posName, cb->name() ); | 192 | lvi->setText( posName, cb->name() ); |
193 | if ( _cfg.getShowBalances() ) | 193 | if ( _cfg.getShowBalances() ) |
194 | { | 194 | { |
195 | QString balance; | 195 | QString balance; |
196 | balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); | 196 | balance.sprintf( "%s%.2f", _cfg.getCurrencySymbol().latin1(), cb->balance() ); |
197 | lvi->setText( posName + 1, balance ); | 197 | lvi->setText( posName + 1, balance ); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | void MainWindow::buildFilename( const QString &name ) | 201 | void MainWindow::buildFilename( const QString &name ) |
202 | { | 202 | { |
203 | tempFilename = cbDir; | 203 | tempFilename = cbDir; |
204 | tempFilename.append( name ); | 204 | tempFilename.append( name ); |
205 | tempFilename.append( ".qcb" ); | 205 | tempFilename.append( ".qcb" ); |
206 | } | 206 | } |
207 | 207 | ||
208 | void MainWindow::slotNew() | 208 | void MainWindow::slotNew() |
209 | { | 209 | { |
210 | CBInfo *cb = new CBInfo(); | 210 | CBInfo *cb = new CBInfo(); |
211 | 211 | ||
212 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); | 212 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); |
213 | if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) | 213 | if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) |
214 | { | 214 | { |
215 | // Save new checkbook | 215 | // Save new checkbook |
216 | buildFilename( cb->name() ); | 216 | buildFilename( cb->name() ); |
217 | _cfg.setLastBook( cb->name() ); | 217 | _cfg.setLastBook( cb->name() ); |
218 | cb->setFilename( tempFilename ); | 218 | cb->setFilename( tempFilename ); |
219 | cb->write(); | 219 | cb->write(); |
220 | 220 | ||
221 | // Add to listbox | 221 | // Add to listbox |
222 | checkbooks->inSort( cb ); | 222 | checkbooks->inSort( cb ); |
223 | addCheckbook( cb ); | 223 | addCheckbook( cb ); |
224 | } | 224 | } |
225 | delete currcb; | 225 | delete currcb; |
226 | } | 226 | } |
227 | 227 | ||
228 | // --- slotEdit --------------------------------------------------------------- | 228 | // --- slotEdit --------------------------------------------------------------- |
229 | void MainWindow::slotEdit() | 229 | void MainWindow::slotEdit() |
230 | { | 230 | { |
231 | // get name and open it | 231 | // get name and open it |
232 | QListViewItem *curritem = cbList->currentItem(); | 232 | QListViewItem *curritem = cbList->currentItem(); |
233 | if ( !curritem ) | 233 | if ( !curritem ) |
234 | return; | 234 | return; |
235 | openBook( curritem ); | 235 | openBook( curritem ); |
236 | } | 236 | } |
237 | 237 | ||
238 | 238 | ||
239 | // --- openBook --------------------------------------------------------------- | 239 | // --- openBook --------------------------------------------------------------- |
240 | void MainWindow::openBook(QListViewItem *curritem) | 240 | void MainWindow::openBook(QListViewItem *curritem) |
241 | { | 241 | { |
242 | // find book in List | 242 | // find book in List |
243 | QString currname=curritem->text(posName); | 243 | QString currname=curritem->text(posName); |
244 | CBInfo *cb = checkbooks->first(); | 244 | CBInfo *cb = checkbooks->first(); |
245 | while ( cb ) { | 245 | while ( cb ) { |
246 | if ( cb->name() == currname ) | 246 | if ( cb->name() == currname ) |
247 | break; | 247 | break; |
248 | cb = checkbooks->next(); | 248 | cb = checkbooks->next(); |
249 | } | 249 | } |
250 | if ( !cb ) return; | 250 | if ( !cb ) return; |
251 | 251 | ||
252 | // | 252 | // |
253 | buildFilename( currname ); | 253 | buildFilename( currname ); |
254 | float currbalance = cb->balance(); | 254 | float currbalance = cb->balance(); |
255 | bool currlock = !cb->password().isNull(); | 255 | bool currlock = !cb->password().isNull(); |
256 | 256 | ||
257 | if ( currlock ) | 257 | if ( currlock ) |
258 | { | 258 | { |
259 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | 259 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); |
260 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) | 260 | if ( pw->exec() != QDialog::Accepted || pw->password != cb->password() ) |
261 | { | 261 | { |
262 | delete pw; | 262 | delete pw; |
263 | return; | 263 | return; |
264 | } | 264 | } |
265 | delete pw; | 265 | delete pw; |
266 | } | 266 | } |
267 | 267 | ||
268 | _cfg.setLastBook( currname ); | 268 | _cfg.setLastBook( currname ); |
269 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); | 269 | Checkbook *currcb = new Checkbook( this, cb, &_cfg ); |
270 | if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) | 270 | if ( QPEApplication::execDialog( currcb ) == QDialog::Accepted ) |
271 | { | 271 | { |
diff --git a/noncore/apps/checkbook/password.cpp b/noncore/apps/checkbook/password.cpp index f381271..89a6bc6 100644 --- a/noncore/apps/checkbook/password.cpp +++ b/noncore/apps/checkbook/password.cpp | |||
@@ -1,97 +1,97 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> | 4 | .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "password.h" | 29 | #include "password.h" |
30 | 30 | ||
31 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qlayout.h> | 32 | #include <qlayout.h> |
33 | #include <qlineedit.h> | 33 | #include <qlineedit.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | 35 | ||
36 | static const char* const showhideimage_data[] = { | 36 | static const char* const showhideimage_data[] = { |
37 | "16 16 2 1", | 37 | "16 16 2 1", |
38 | ". c None", | 38 | ". c None", |
39 | "# c #000000", | 39 | "# c #000000", |
40 | "................", | 40 | "................", |
41 | "...#...###...##.", | 41 | "...#...###...##.", |
42 | "..#.#..#..#.##..", | 42 | "..#.#..#..#.##..", |
43 | "..###..###.##...", | 43 | "..###..###.##...", |
44 | ".#...#.#..##....", | 44 | ".#...#.#..##....", |
45 | ".#...#.#.##.....", | 45 | ".#...#.#.##.....", |
46 | "........##.#..#.", | 46 | "........##.#..#.", |
47 | "..##...##...##..", | 47 | "..##...##...##..", |
48 | ".#..#.###...##..", | 48 | ".#..#.###...##..", |
49 | ".#...##..#.#..#.", | 49 | ".#...##..#.#..#.", |
50 | ".#..##..........", | 50 | ".#..##..........", |
51 | ".#.##.#..#.#..#.", | 51 | ".#.##.#..#.#..#.", |
52 | "..##...##...##..", | 52 | "..##...##...##..", |
53 | ".##....##...##..", | 53 | ".##....##...##..", |
54 | ".#....#..#.#..#.", | 54 | ".#....#..#.#..#.", |
55 | "................"}; | 55 | "................"}; |
56 | 56 | ||
57 | Password::Password( QWidget *parent, const char *caption, const char *prompt ) | 57 | Password::Password( QWidget *parent, const char *caption, const char *prompt ) |
58 | : QDialog( parent, 0x0, TRUE, 0x0 ) | 58 | : QDialog( parent, 0x0, TRUE, 0x0 ) |
59 | { | 59 | { |
60 | setCaption( caption ); | 60 | setCaption( caption ); |
61 | 61 | ||
62 | QGridLayout *layout = new QGridLayout( this ); | 62 | QGridLayout *layout = new QGridLayout( this ); |
63 | layout->setSpacing( 2 ); | 63 | layout->setSpacing( 2 ); |
64 | layout->setMargin( 4 ); | 64 | layout->setMargin( 4 ); |
65 | 65 | ||
66 | QLabel *label = new QLabel( prompt, this ); | 66 | QLabel *label = new QLabel( prompt, this ); |
67 | label->setAlignment( AlignLeft | AlignTop | WordBreak ); | 67 | label->setAlignment( AlignLeft | AlignTop | WordBreak ); |
68 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); | 68 | layout->addMultiCellWidget( label, 0, 0, 0, 1 ); |
69 | 69 | ||
70 | pw = new QLineEdit( this ); | 70 | pw = new QLineEdit( this ); |
71 | pw->setEchoMode( QLineEdit::Password ); | 71 | pw->setEchoMode( QLineEdit::Password ); |
72 | layout->addWidget( pw, 1, 0 ); | 72 | layout->addWidget( pw, 1, 0 ); |
73 | 73 | ||
74 | QPixmap *pic = new QPixmap( ( const char** ) showhideimage_data ); | 74 | QPixmap *pic = new QPixmap( ( const char** ) showhideimage_data ); |
75 | QPushButton *btn = new QPushButton( ( QIconSet ) *pic, QString::null, this ); | 75 | QPushButton *btn = new QPushButton( ( QIconSet ) *pic, QString::null, this ); |
76 | btn->setMaximumSize( pic->width() + 10, pic->height() + 10 ); | 76 | btn->setMaximumSize( pic->width() + 10, pic->height() + 10 ); |
77 | btn->setToggleButton( TRUE ); | 77 | btn->setToggleButton( TRUE ); |
78 | connect( btn, SIGNAL( toggled( bool ) ), this, SLOT( slotTogglePassword( bool ) ) ); | 78 | connect( btn, SIGNAL( toggled(bool) ), this, SLOT( slotTogglePassword(bool) ) ); |
79 | layout->addWidget( btn, 1, 1 ); | 79 | layout->addWidget( btn, 1, 1 ); |
80 | 80 | ||
81 | password == ""; | 81 | password == ""; |
82 | } | 82 | } |
83 | 83 | ||
84 | Password::~Password() | 84 | Password::~Password() |
85 | { | 85 | { |
86 | } | 86 | } |
87 | 87 | ||
88 | void Password::accept() | 88 | void Password::accept() |
89 | { | 89 | { |
90 | password = pw->text(); | 90 | password = pw->text(); |
91 | QDialog::accept(); | 91 | QDialog::accept(); |
92 | } | 92 | } |
93 | 93 | ||
94 | void Password::slotTogglePassword( bool showPW ) | 94 | void Password::slotTogglePassword( bool showPW ) |
95 | { | 95 | { |
96 | showPW ? pw->setEchoMode( QLineEdit::Normal ) : pw->setEchoMode( QLineEdit::Password ); | 96 | showPW ? pw->setEchoMode( QLineEdit::Normal ) : pw->setEchoMode( QLineEdit::Password ); |
97 | } | 97 | } |
diff --git a/noncore/apps/checkbook/transaction.cpp b/noncore/apps/checkbook/transaction.cpp index a72a48b..1b08b24 100644 --- a/noncore/apps/checkbook/transaction.cpp +++ b/noncore/apps/checkbook/transaction.cpp | |||
@@ -6,267 +6,267 @@ | |||
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "transaction.h" | 29 | #include "transaction.h" |
30 | #include "traninfo.h" | 30 | #include "traninfo.h" |
31 | #include "cfg.h" | 31 | #include "cfg.h" |
32 | #include "checkbook.h" | 32 | #include "checkbook.h" |
33 | 33 | ||
34 | #include <qpe/datebookmonth.h> | 34 | #include <qpe/datebookmonth.h> |
35 | 35 | ||
36 | #include <qbuttongroup.h> | 36 | #include <qbuttongroup.h> |
37 | #include <qcombobox.h> | 37 | #include <qcombobox.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qlayout.h> | 39 | #include <qlayout.h> |
40 | #include <qlineedit.h> | 40 | #include <qlineedit.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qradiobutton.h> | 42 | #include <qradiobutton.h> |
43 | #include <qwhatsthis.h> | 43 | #include <qwhatsthis.h> |
44 | 44 | ||
45 | Transaction::Transaction( QWidget *parent, bool bNew, const QString &acctname, | 45 | Transaction::Transaction( QWidget *parent, bool bNew, const QString &acctname, |
46 | TranInfo *info, Cfg *pCfg ) | 46 | TranInfo *info, Cfg *pCfg ) |
47 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) | 47 | : QDialog( parent, 0, TRUE, WStyle_ContextHelp ) |
48 | { | 48 | { |
49 | QString tempstr = tr( "Transaction for " ); | 49 | QString tempstr = tr( "Transaction for " ); |
50 | tempstr.append( acctname ); | 50 | tempstr.append( acctname ); |
51 | setCaption( tempstr ); | 51 | setCaption( tempstr ); |
52 | 52 | ||
53 | _bNew=bNew; | 53 | _bNew=bNew; |
54 | tran = info; | 54 | tran = info; |
55 | _pCfg=pCfg; | 55 | _pCfg=pCfg; |
56 | 56 | ||
57 | QVBoxLayout *vb = new QVBoxLayout( this ); | 57 | QVBoxLayout *vb = new QVBoxLayout( this ); |
58 | 58 | ||
59 | QScrollView *sv = new QScrollView( this ); | 59 | QScrollView *sv = new QScrollView( this ); |
60 | vb->addWidget( sv, 0, 0 ); | 60 | vb->addWidget( sv, 0, 0 ); |
61 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 61 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
62 | sv->setFrameStyle( QFrame::NoFrame ); | 62 | sv->setFrameStyle( QFrame::NoFrame ); |
63 | 63 | ||
64 | QWidget *container = new QWidget( sv->viewport() ); | 64 | QWidget *container = new QWidget( sv->viewport() ); |
65 | sv->addChild( container ); | 65 | sv->addChild( container ); |
66 | 66 | ||
67 | QGridLayout *layout = new QGridLayout( container ); | 67 | QGridLayout *layout = new QGridLayout( container ); |
68 | layout->setSpacing( 2 ); | 68 | layout->setSpacing( 2 ); |
69 | layout->setMargin( 4 ); | 69 | layout->setMargin( 4 ); |
70 | 70 | ||
71 | // Withdrawal/Deposit | 71 | // Withdrawal/Deposit |
72 | QButtonGroup *btngrp = new QButtonGroup( container ); | 72 | QButtonGroup *btngrp = new QButtonGroup( container ); |
73 | btngrp->setColumnLayout(0, Qt::Vertical ); | 73 | btngrp->setColumnLayout(0, Qt::Vertical ); |
74 | btngrp->layout()->setSpacing( 0 ); | 74 | btngrp->layout()->setSpacing( 0 ); |
75 | btngrp->layout()->setMargin( 0 ); | 75 | btngrp->layout()->setMargin( 0 ); |
76 | btngrp->setMaximumWidth( 220 ); | 76 | btngrp->setMaximumWidth( 220 ); |
77 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); | 77 | QGridLayout *layout2 = new QGridLayout( btngrp->layout() ); |
78 | layout2->setSpacing( 2 ); | 78 | layout2->setSpacing( 2 ); |
79 | layout2->setMargin( 2 ); | 79 | layout2->setMargin( 2 ); |
80 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); | 80 | withBtn = new QRadioButton( tr( "Withdrawal" ), btngrp ); |
81 | QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | 81 | QWhatsThis::add( withBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); |
82 | layout2->addWidget( withBtn, 0, 0 ); | 82 | layout2->addWidget( withBtn, 0, 0 ); |
83 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); | 83 | connect( withBtn, SIGNAL( clicked() ), this, SLOT( slotWithdrawalClicked() ) ); |
84 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); | 84 | depBtn = new QRadioButton( tr( "Deposit" ), btngrp ); |
85 | QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); | 85 | QWhatsThis::add( depBtn, tr( "Select whether the transaction is a withdrawal or deposit here." ) ); |
86 | layout2->addWidget( depBtn, 0, 1 ); | 86 | layout2->addWidget( depBtn, 0, 1 ); |
87 | btngrp->setMaximumSize( 320, withBtn->height() ); | 87 | btngrp->setMaximumSize( 320, withBtn->height() ); |
88 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); | 88 | connect( depBtn, SIGNAL( clicked() ), this, SLOT( slotDepositClicked() ) ); |
89 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); | 89 | layout->addMultiCellWidget( btngrp, 0, 0, 0, 3 ); |
90 | 90 | ||
91 | // Date | 91 | // Date |
92 | QLabel *label = new QLabel( tr( "Date:" ), container ); | 92 | QLabel *label = new QLabel( tr( "Date:" ), container ); |
93 | QWhatsThis::add( label, tr( "Select date of transaction here." ) ); | 93 | QWhatsThis::add( label, tr( "Select date of transaction here." ) ); |
94 | layout->addWidget( label, 1, 0 ); | 94 | layout->addWidget( label, 1, 0 ); |
95 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), | 95 | dateBtn = new QPushButton( TimeString::shortDate( QDate::currentDate() ), |
96 | container ); | 96 | container ); |
97 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); | 97 | QWhatsThis::add( dateBtn, tr( "Select date of transaction here." ) ); |
98 | QPopupMenu *m1 = new QPopupMenu( container ); | 98 | QPopupMenu *m1 = new QPopupMenu( container ); |
99 | datePicker = new DateBookMonth( m1, 0, TRUE ); | 99 | datePicker = new DateBookMonth( m1, 0, TRUE ); |
100 | m1->insertItem( datePicker ); | 100 | m1->insertItem( datePicker ); |
101 | dateBtn->setPopup( m1 ); | 101 | dateBtn->setPopup( m1 ); |
102 | connect( datePicker, SIGNAL( dateClicked( int, int, int ) ), | 102 | connect( datePicker, SIGNAL( dateClicked(int,int,int) ), |
103 | this, SLOT( slotDateChanged( int, int, int ) ) ); | 103 | this, SLOT( slotDateChanged(int,int,int) ) ); |
104 | layout->addWidget( dateBtn, 1, 1 ); | 104 | layout->addWidget( dateBtn, 1, 1 ); |
105 | 105 | ||
106 | // Check number | 106 | // Check number |
107 | label = new QLabel( tr( "Number:" ), container ); | 107 | label = new QLabel( tr( "Number:" ), container ); |
108 | QWhatsThis::add( label, tr( "Enter check number here." ) ); | 108 | QWhatsThis::add( label, tr( "Enter check number here." ) ); |
109 | layout->addWidget( label, 1, 2 ); | 109 | layout->addWidget( label, 1, 2 ); |
110 | numEdit = new QLineEdit( container ); | 110 | numEdit = new QLineEdit( container ); |
111 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); | 111 | QWhatsThis::add( numEdit, tr( "Enter check number here." ) ); |
112 | numEdit->setMaximumWidth( 40 ); | 112 | numEdit->setMaximumWidth( 40 ); |
113 | layout->addWidget( numEdit, 1, 3 ); | 113 | layout->addWidget( numEdit, 1, 3 ); |
114 | 114 | ||
115 | // Description | 115 | // Description |
116 | label = new QLabel( tr( "Description:" ), container ); | 116 | label = new QLabel( tr( "Description:" ), container ); |
117 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); | 117 | QWhatsThis::add( label, tr( "Enter description of transaction here." ) ); |
118 | layout->addWidget( label, 2, 0 ); | 118 | layout->addWidget( label, 2, 0 ); |
119 | _cbDesc=new QComboBox( true, container ); | 119 | _cbDesc=new QComboBox( true, container ); |
120 | _cbDesc->insertStringList( _pCfg->getPayees() ); | 120 | _cbDesc->insertStringList( _pCfg->getPayees() ); |
121 | QWhatsThis::add( _cbDesc, tr( "Enter description of transaction here." ) ); | 121 | QWhatsThis::add( _cbDesc, tr( "Enter description of transaction here." ) ); |
122 | layout->addMultiCellWidget( _cbDesc, 2, 2, 1, 3 ); | 122 | layout->addMultiCellWidget( _cbDesc, 2, 2, 1, 3 ); |
123 | connect( _cbDesc, SIGNAL( activated(const QString &) ), this, SLOT( slotActivated(const QString &) ) ); | 123 | connect( _cbDesc, SIGNAL( activated(const QString&) ), this, SLOT( slotActivated(const QString&) ) ); |
124 | 124 | ||
125 | 125 | ||
126 | // Category | 126 | // Category |
127 | label = new QLabel( tr( "Category:" ), container ); | 127 | label = new QLabel( tr( "Category:" ), container ); |
128 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); | 128 | QWhatsThis::add( label, tr( "Select transaction category here." ) ); |
129 | layout->addWidget( label, 3, 0 ); | 129 | layout->addWidget( label, 3, 0 ); |
130 | catList = new QComboBox( container ); | 130 | catList = new QComboBox( container ); |
131 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); | 131 | QWhatsThis::add( catList, tr( "Select transaction category here." ) ); |
132 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); | 132 | layout->addMultiCellWidget( catList, 3, 3, 1, 3 ); |
133 | 133 | ||
134 | // Type | 134 | // Type |
135 | label = new QLabel( tr( "Type:" ), container ); | 135 | label = new QLabel( tr( "Type:" ), container ); |
136 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | 136 | QWhatsThis::add( label, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
137 | layout->addWidget( label, 4, 0 ); | 137 | layout->addWidget( label, 4, 0 ); |
138 | typeList = new QComboBox( container ); | 138 | typeList = new QComboBox( container ); |
139 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); | 139 | QWhatsThis::add( typeList, tr( "Select transaction type here.\n\nThe options available vary based on whether the transaction is a deposit or withdrawal." ) ); |
140 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); | 140 | layout->addMultiCellWidget( typeList, 4, 4, 1, 3 ); |
141 | 141 | ||
142 | 142 | ||
143 | // Amount | 143 | // Amount |
144 | label = new QLabel( tr( "Amount:" ), container ); | 144 | label = new QLabel( tr( "Amount:" ), container ); |
145 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 145 | QWhatsThis::add( label, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
146 | layout->addWidget( label, 5, 0 ); | 146 | layout->addWidget( label, 5, 0 ); |
147 | amtEdit = new QLineEdit( container ); | 147 | amtEdit = new QLineEdit( container ); |
148 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); | 148 | QWhatsThis::add( amtEdit, tr( "Enter the amount of transaction here.\n\nThe value entered should always be positive." ) ); |
149 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); | 149 | layout->addMultiCellWidget( amtEdit, 5, 5, 1, 3 ); |
150 | 150 | ||
151 | // Fee | 151 | // Fee |
152 | label = new QLabel( tr( "Fee:" ), container ); | 152 | label = new QLabel( tr( "Fee:" ), container ); |
153 | QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); | 153 | QWhatsThis::add( label, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); |
154 | layout->addWidget( label, 6, 0 ); | 154 | layout->addWidget( label, 6, 0 ); |
155 | feeEdit = new QLineEdit( container ); | 155 | feeEdit = new QLineEdit( container ); |
156 | QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); | 156 | QWhatsThis::add( feeEdit, tr( "Enter any fee amount assoiciated with this transaction.\n\nThe value entered should always be positive." ) ); |
157 | layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); | 157 | layout->addMultiCellWidget( feeEdit, 6, 6, 1, 3 ); |
158 | 158 | ||
159 | // Notes | 159 | // Notes |
160 | label = new QLabel( tr( "Notes:" ), container ); | 160 | label = new QLabel( tr( "Notes:" ), container ); |
161 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); | 161 | QWhatsThis::add( label, tr( "Enter any additional information for this transaction here." ) ); |
162 | layout->addWidget( label, 7, 0 ); | 162 | layout->addWidget( label, 7, 0 ); |
163 | noteEdit = new QMultiLineEdit( container ); | 163 | noteEdit = new QMultiLineEdit( container ); |
164 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); | 164 | QWhatsThis::add( noteEdit, tr( "Enter any additional information for this transaction here." ) ); |
165 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); | 165 | layout->addMultiCellWidget( noteEdit, 8, 8, 0, 3 ); |
166 | 166 | ||
167 | // init date | 167 | // init date |
168 | initFromInfo( info ); | 168 | initFromInfo( info ); |
169 | 169 | ||
170 | // not new handlers | 170 | // not new handlers |
171 | connect( withBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) ); | 171 | connect( withBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) ); |
172 | connect( depBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) ); | 172 | connect( depBtn, SIGNAL( toggled(bool) ), this, SLOT( slotNotNew() ) ); |
173 | connect( catList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) ); | 173 | connect( catList, SIGNAL(activated(const QString&)), this, SLOT( slotNotNew() ) ); |
174 | connect( typeList, SIGNAL(activated(const QString &)), this, SLOT( slotNotNew() ) ); | 174 | connect( typeList, SIGNAL(activated(const QString&)), this, SLOT( slotNotNew() ) ); |
175 | connect( amtEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) ); | 175 | connect( amtEdit, SIGNAL(textChanged(const QString&)), this, SLOT( slotNotNew() ) ); |
176 | connect( feeEdit, SIGNAL(textChanged(const QString &)), this, SLOT( slotNotNew() ) ); | 176 | connect( feeEdit, SIGNAL(textChanged(const QString&)), this, SLOT( slotNotNew() ) ); |
177 | connect( noteEdit, SIGNAL(textChanged()), this, SLOT( slotNotNew() ) ); | 177 | connect( noteEdit, SIGNAL(textChanged()), this, SLOT( slotNotNew() ) ); |
178 | } | 178 | } |
179 | 179 | ||
180 | // --- initFromInfo ----------------------------------------------------------- | 180 | // --- initFromInfo ----------------------------------------------------------- |
181 | void Transaction::initFromInfo(TranInfo *info, bool bPopulateOld) | 181 | void Transaction::initFromInfo(TranInfo *info, bool bPopulateOld) |
182 | { | 182 | { |
183 | // Populate current values if provided | 183 | // Populate current values if provided |
184 | if ( info ) | 184 | if ( info ) |
185 | { | 185 | { |
186 | if ( info->withdrawal() ) | 186 | if ( info->withdrawal() ) |
187 | { | 187 | { |
188 | withBtn->setChecked( TRUE ); | 188 | withBtn->setChecked( TRUE ); |
189 | slotWithdrawalClicked(); | 189 | slotWithdrawalClicked(); |
190 | } | 190 | } |
191 | else | 191 | else |
192 | { | 192 | { |
193 | depBtn->setChecked( TRUE ); | 193 | depBtn->setChecked( TRUE ); |
194 | slotDepositClicked(); | 194 | slotDepositClicked(); |
195 | } | 195 | } |
196 | 196 | ||
197 | if( !bPopulateOld ) { | 197 | if( !bPopulateOld ) { |
198 | QDate dt = info->date(); | 198 | QDate dt = info->date(); |
199 | slotDateChanged( dt.year(), dt.month(), dt.day() ); | 199 | slotDateChanged( dt.year(), dt.month(), dt.day() ); |
200 | datePicker->setDate( dt ); | 200 | datePicker->setDate( dt ); |
201 | numEdit->setText( info->number() ); | 201 | numEdit->setText( info->number() ); |
202 | } | 202 | } |
203 | QString temptext = info->category(); | 203 | QString temptext = info->category(); |
204 | 204 | ||
205 | // set description field | 205 | // set description field |
206 | int i; | 206 | int i; |
207 | for(i=_cbDesc->count()-1; i>=0; i--) { | 207 | for(i=_cbDesc->count()-1; i>=0; i--) { |
208 | if( _cbDesc->text(i)==info->desc() ) { | 208 | if( _cbDesc->text(i)==info->desc() ) { |
209 | _cbDesc->setCurrentItem(i); | 209 | _cbDesc->setCurrentItem(i); |
210 | break; | 210 | break; |
211 | } | 211 | } |
212 | } | 212 | } |
213 | if( i<=0 ) | 213 | if( i<=0 ) |
214 | _cbDesc->setEditText( info->desc() ); | 214 | _cbDesc->setEditText( info->desc() ); |
215 | 215 | ||
216 | i = catList->count(); | 216 | i = catList->count(); |
217 | while ( i > 0 ) | 217 | while ( i > 0 ) |
218 | { | 218 | { |
219 | i--; | 219 | i--; |
220 | catList->setCurrentItem( i ); | 220 | catList->setCurrentItem( i ); |
221 | if ( catList->currentText() == temptext ) | 221 | if ( catList->currentText() == temptext ) |
222 | { | 222 | { |
223 | break; | 223 | break; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | temptext = info->type(); | 226 | temptext = info->type(); |
227 | i = typeList->count(); | 227 | i = typeList->count(); |
228 | while ( i > 0 ) | 228 | while ( i > 0 ) |
229 | { | 229 | { |
230 | i--; | 230 | i--; |
231 | typeList->setCurrentItem( i ); | 231 | typeList->setCurrentItem( i ); |
232 | if ( typeList->currentText() == temptext ) | 232 | if ( typeList->currentText() == temptext ) |
233 | { | 233 | { |
234 | break; | 234 | break; |
235 | } | 235 | } |
236 | } | 236 | } |
237 | amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); | 237 | amtEdit->setText( QString( "%1" ).arg( info->amount(), 0, 'f', 2 ) ); |
238 | feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); | 238 | feeEdit->setText( QString( "%1" ).arg( info->fee(), 0, 'f', 2 ) ); |
239 | noteEdit->setText( info->notes() ); | 239 | noteEdit->setText( info->notes() ); |
240 | } | 240 | } |
241 | else | 241 | else |
242 | { | 242 | { |
243 | withBtn->setChecked( TRUE ); | 243 | withBtn->setChecked( TRUE ); |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | // --- ~Transaction ----------------------------------------------------------- | 248 | // --- ~Transaction ----------------------------------------------------------- |
249 | Transaction::~Transaction() | 249 | Transaction::~Transaction() |
250 | { | 250 | { |
251 | } | 251 | } |
252 | 252 | ||
253 | // --- accept ----------------------------------------------------------------- | 253 | // --- accept ----------------------------------------------------------------- |
254 | void Transaction::accept() | 254 | void Transaction::accept() |
255 | { | 255 | { |
256 | tran->setDesc( _cbDesc->currentText() ); | 256 | tran->setDesc( _cbDesc->currentText() ); |
257 | tran->setDate( datePicker->selectedDate() ); | 257 | tran->setDate( datePicker->selectedDate() ); |
258 | tran->setWithdrawal( withBtn->isChecked() ); | 258 | tran->setWithdrawal( withBtn->isChecked() ); |
259 | tran->setType( typeList->currentText() ); | 259 | tran->setType( typeList->currentText() ); |
260 | tran->setCategory( catList->currentText() ); | 260 | tran->setCategory( catList->currentText() ); |
261 | bool ok; | 261 | bool ok; |
262 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); | 262 | tran->setAmount( amtEdit->text().toFloat( &ok ) ); |
263 | tran->setFee( feeEdit->text().toFloat( &ok ) ); | 263 | tran->setFee( feeEdit->text().toFloat( &ok ) ); |
264 | tran->setNumber( numEdit->text() ); | 264 | tran->setNumber( numEdit->text() ); |
265 | tran->setNotes( noteEdit->text() ); | 265 | tran->setNotes( noteEdit->text() ); |
266 | 266 | ||
267 | QDialog::accept(); | 267 | QDialog::accept(); |
268 | } | 268 | } |
269 | 269 | ||
270 | void Transaction::slotWithdrawalClicked() | 270 | void Transaction::slotWithdrawalClicked() |
271 | { | 271 | { |
272 | catList->clear(); | 272 | catList->clear(); |
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp index 5f7ad50..6ef1043 100644 --- a/noncore/apps/confedit/mainwindow.cpp +++ b/noncore/apps/confedit/mainwindow.cpp | |||
@@ -1,148 +1,148 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
11 | 11 | ||
12 | 12 | ||
13 | #include "mainwindow.h" | 13 | #include "mainwindow.h" |
14 | 14 | ||
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qlayout.h> | 16 | #include <qlayout.h> |
17 | #include <qlineedit.h> | 17 | #include <qlineedit.h> |
18 | 18 | ||
19 | #include "listviewconfdir.h" | 19 | #include "listviewconfdir.h" |
20 | #include "listviewitemconfigentry.h" | 20 | #include "listviewitemconfigentry.h" |
21 | 21 | ||
22 | 22 | ||
23 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | 23 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : |
24 | QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) | 24 | QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0) |
25 | { | 25 | { |
26 | setCaption( tr("Conf File Editor") ); | 26 | setCaption( tr("Conf File Editor") ); |
27 | 27 | ||
28 | //setBaseSize( qApp->globalStrut() ); | 28 | //setBaseSize( qApp->globalStrut() ); |
29 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); | 29 | setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); |
30 | 30 | ||
31 | mainLayout = new QVBoxLayout( this ); | 31 | mainLayout = new QVBoxLayout( this ); |
32 | mainLayout->setSpacing( 0 ); | 32 | mainLayout->setSpacing( 0 ); |
33 | mainLayout->setMargin( 0 ); | 33 | mainLayout->setMargin( 0 ); |
34 | 34 | ||
35 | 35 | ||
36 | qDebug("creating settingList"); | 36 | qDebug("creating settingList"); |
37 | settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist"); | 37 | settingList = new ListViewConfDir( QDir::homeDirPath() + "/Settings", this, "settingslist"); |
38 | settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); | 38 | settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) ); |
39 | mainLayout->addWidget( settingList, 0); | 39 | mainLayout->addWidget( settingList, 0); |
40 | 40 | ||
41 | qDebug("creating editor"); | 41 | qDebug("creating editor"); |
42 | editor = new EditWidget(this); | 42 | editor = new EditWidget(this); |
43 | editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); | 43 | editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) ); |
44 | mainLayout->addWidget( editor, 1 ); | 44 | mainLayout->addWidget( editor, 1 ); |
45 | editor->layoutType( ListViewItemConf::File ); | 45 | editor->layoutType( ListViewItemConf::File ); |
46 | 46 | ||
47 | makeMenu(); | 47 | makeMenu(); |
48 | 48 | ||
49 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), | 49 | connect(settingList, SIGNAL( pressed(QListViewItem*) ), |
50 | this, SLOT(setCurrent(QListViewItem*))); | 50 | this, SLOT(setCurrent(QListViewItem*))); |
51 | connect( settingList, SIGNAL( clicked( QListViewItem* ) ), | 51 | connect( settingList, SIGNAL( clicked(QListViewItem*) ), |
52 | this, SLOT( stopTimer( QListViewItem* ) ) ); | 52 | this, SLOT( stopTimer(QListViewItem*) ) ); |
53 | 53 | ||
54 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), | 54 | connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ), |
55 | SLOT( groupChanged(const QString&) ) ); | 55 | SLOT( groupChanged(const QString&) ) ); |
56 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), | 56 | connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ), |
57 | SLOT( keyChanged(const QString&) ) ); | 57 | SLOT( keyChanged(const QString&) ) ); |
58 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), | 58 | connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ), |
59 | SLOT( valueChanged(const QString&) ) ); | 59 | SLOT( valueChanged(const QString&) ) ); |
60 | 60 | ||
61 | setCurrent(0); | 61 | setCurrent(0); |
62 | editor->layoutType(EditWidget::File); | 62 | editor->layoutType(EditWidget::File); |
63 | } | 63 | } |
64 | 64 | ||
65 | void MainWindow::makeMenu() | 65 | void MainWindow::makeMenu() |
66 | { | 66 | { |
67 | popupTimer = new QTimer(this); | 67 | popupTimer = new QTimer(this); |
68 | popupMenuFile = new QPopupMenu(this); | 68 | popupMenuFile = new QPopupMenu(this); |
69 | popupMenuEntry = new QPopupMenu(this); | 69 | popupMenuEntry = new QPopupMenu(this); |
70 | 70 | ||
71 | popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); | 71 | popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 ); |
72 | popupActionSave->addTo( popupMenuFile ); | 72 | popupActionSave->addTo( popupMenuFile ); |
73 | // popupActionSave->addTo( popupMenuEntry ); | 73 | // popupActionSave->addTo( popupMenuEntry ); |
74 | connect( popupActionSave, SIGNAL( activated() ), | 74 | connect( popupActionSave, SIGNAL( activated() ), |
75 | this , SLOT( saveConfFile() ) ); | 75 | this , SLOT( saveConfFile() ) ); |
76 | 76 | ||
77 | popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); | 77 | popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 ); |
78 | popupActionRevert->addTo( popupMenuFile ); | 78 | popupActionRevert->addTo( popupMenuFile ); |
79 | popupActionRevert->addTo( popupMenuEntry ); | 79 | popupActionRevert->addTo( popupMenuEntry ); |
80 | connect( popupActionRevert, SIGNAL( activated() ), | 80 | connect( popupActionRevert, SIGNAL( activated() ), |
81 | this , SLOT( revertConfFile() ) ); | 81 | this , SLOT( revertConfFile() ) ); |
82 | 82 | ||
83 | popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); | 83 | popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 ); |
84 | popupActionDelete->addTo( popupMenuFile ); | 84 | popupActionDelete->addTo( popupMenuFile ); |
85 | popupActionDelete->addTo( popupMenuEntry ); | 85 | popupActionDelete->addTo( popupMenuEntry ); |
86 | connect( popupActionDelete, SIGNAL( activated() ), | 86 | connect( popupActionDelete, SIGNAL( activated() ), |
87 | this , SLOT( removeConfFile() ) ); | 87 | this , SLOT( removeConfFile() ) ); |
88 | 88 | ||
89 | connect( popupTimer, SIGNAL(timeout()), | 89 | connect( popupTimer, SIGNAL(timeout()), |
90 | this, SLOT(showPopup()) ); | 90 | this, SLOT(showPopup()) ); |
91 | } | 91 | } |
92 | 92 | ||
93 | MainWindow::~MainWindow() | 93 | MainWindow::~MainWindow() |
94 | { | 94 | { |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | 98 | ||
99 | void MainWindow::setCurrent(QListViewItem *item) | 99 | void MainWindow::setCurrent(QListViewItem *item) |
100 | { | 100 | { |
101 | //qDebug("MainWindow::setCurrent"); | 101 | //qDebug("MainWindow::setCurrent"); |
102 | if (!item) return; | 102 | if (!item) return; |
103 | _item = (ListViewItemConf*) item; | 103 | _item = (ListViewItemConf*) item; |
104 | if (!_item) return; | 104 | if (!_item) return; |
105 | popupTimer->start( 750, true ); | 105 | popupTimer->start( 750, true ); |
106 | if (_item->getType() == ListViewItemConf::File) | 106 | if (_item->getType() == ListViewItemConf::File) |
107 | { | 107 | { |
108 | editor->layoutType(EditWidget::File); | 108 | editor->layoutType(EditWidget::File); |
109 | _currentItem=0; | 109 | _currentItem=0; |
110 | _fileItem = (ListViewItemConfFile*)item; | 110 | _fileItem = (ListViewItemConfFile*)item; |
111 | return; | 111 | return; |
112 | } | 112 | } |
113 | _fileItem = 0; | 113 | _fileItem = 0; |
114 | _currentItem = (ListViewItemConfigEntry*)item; | 114 | _currentItem = (ListViewItemConfigEntry*)item; |
115 | if (!_currentItem) return; | 115 | if (!_currentItem) return; |
116 | QString file = _currentItem->getFile(); | 116 | QString file = _currentItem->getFile(); |
117 | QString group = _currentItem->getGroup(); | 117 | QString group = _currentItem->getGroup(); |
118 | QString key = _currentItem->getKey(); | 118 | QString key = _currentItem->getKey(); |
119 | QString val = _currentItem->getValue(); | 119 | QString val = _currentItem->getValue(); |
120 | editor->TextFileName->setText(file); | 120 | editor->TextFileName->setText(file); |
121 | editor->LineEditGroup->setText(group); | 121 | editor->LineEditGroup->setText(group); |
122 | if (!key.isEmpty()) | 122 | if (!key.isEmpty()) |
123 | { | 123 | { |
124 | editor->layoutType(EditWidget::Entry); | 124 | editor->layoutType(EditWidget::Entry); |
125 | editor->LineEditKey->setText(key); | 125 | editor->LineEditKey->setText(key); |
126 | editor->LineEditValue->setText(val); | 126 | editor->LineEditValue->setText(val); |
127 | }else{ | 127 | }else{ |
128 | editor->layoutType(EditWidget::Group); | 128 | editor->layoutType(EditWidget::Group); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | void MainWindow::groupChanged(const QString &g) | 133 | void MainWindow::groupChanged(const QString &g) |
134 | { | 134 | { |
135 | if (!_currentItem) return; | 135 | if (!_currentItem) return; |
136 | _currentItem->setGroup(g); | 136 | _currentItem->setGroup(g); |
137 | } | 137 | } |
138 | 138 | ||
139 | void MainWindow::keyChanged(const QString &k) | 139 | void MainWindow::keyChanged(const QString &k) |
140 | { | 140 | { |
141 | if (!_currentItem) return; | 141 | if (!_currentItem) return; |
142 | _currentItem->keyChanged(k); | 142 | _currentItem->keyChanged(k); |
143 | } | 143 | } |
144 | 144 | ||
145 | void MainWindow::valueChanged(const QString &v) | 145 | void MainWindow::valueChanged(const QString &v) |
146 | { | 146 | { |
147 | if (!_currentItem) return; | 147 | if (!_currentItem) return; |
148 | _currentItem->valueChanged(v); | 148 | _currentItem->valueChanged(v); |
diff --git a/noncore/apps/odict/odict.cpp b/noncore/apps/odict/odict.cpp index d5c6d75..4c99964 100644 --- a/noncore/apps/odict/odict.cpp +++ b/noncore/apps/odict/odict.cpp | |||
@@ -113,103 +113,103 @@ void ODict::lookupLanguageNames( QString dictname ) | |||
113 | Config cfg ( "odict" ); | 113 | Config cfg ( "odict" ); |
114 | cfg.setGroup( "Method_"+dictname ); | 114 | cfg.setGroup( "Method_"+dictname ); |
115 | top_name_content = cfg.readEntry( "Lang1" ); | 115 | top_name_content = cfg.readEntry( "Lang1" ); |
116 | bottom_name_content = cfg.readEntry( "Lang2" ); | 116 | bottom_name_content = cfg.readEntry( "Lang2" ); |
117 | } | 117 | } |
118 | 118 | ||
119 | void ODict::saveConfig() | 119 | void ODict::saveConfig() |
120 | { | 120 | { |
121 | Config cfg ( "odict" ); | 121 | Config cfg ( "odict" ); |
122 | cfg.setGroup( "generalsettings" ); | 122 | cfg.setGroup( "generalsettings" ); |
123 | cfg.writeEntry( "casesens" , casesens ); | 123 | cfg.writeEntry( "casesens" , casesens ); |
124 | cfg.writeEntry( "lastdict" , query_co->currentText() ); | 124 | cfg.writeEntry( "lastdict" , query_co->currentText() ); |
125 | } | 125 | } |
126 | 126 | ||
127 | void ODict::slotStartQuery() | 127 | void ODict::slotStartQuery() |
128 | { | 128 | { |
129 | QString querystring = query_le->text(); | 129 | QString querystring = query_le->text(); |
130 | if ( !querystring.isEmpty() ) | 130 | if ( !querystring.isEmpty() ) |
131 | { | 131 | { |
132 | /* | 132 | /* |
133 | * if the user has not yet defined a dictionary | 133 | * if the user has not yet defined a dictionary |
134 | */ | 134 | */ |
135 | if ( !query_co->currentText() ) | 135 | if ( !query_co->currentText() ) |
136 | { | 136 | { |
137 | switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ), | 137 | switch ( QMessageBox::information( this, tr( "OPIE-Dictionary" ), |
138 | tr( "No dictionary defined" ), | 138 | tr( "No dictionary defined" ), |
139 | tr( "&Define one" ), | 139 | tr( "&Define one" ), |
140 | tr( "&Cancel" ), | 140 | tr( "&Cancel" ), |
141 | 0, // Define a dict | 141 | 0, // Define a dict |
142 | 1 ) ) // Cancel choosen | 142 | 1 ) ) // Cancel choosen |
143 | { | 143 | { |
144 | case 0: | 144 | case 0: |
145 | slotSettings(); | 145 | slotSettings(); |
146 | break; | 146 | break; |
147 | case 1: // stop here | 147 | case 1: // stop here |
148 | return; | 148 | return; |
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | /* | 152 | /* |
153 | * ok, the user has defined a dict | 153 | * ok, the user has defined a dict |
154 | */ | 154 | */ |
155 | ding->setCaseSensitive( casesens ); | 155 | ding->setCaseSensitive( casesens ); |
156 | 156 | ||
157 | BroswerContent test = ding->setText( querystring ); | 157 | BroswerContent test = ding->setText( querystring ); |
158 | 158 | ||
159 | browser_top->setText( test.top ); | 159 | browser_top->setText( test.top ); |
160 | browser_bottom->setText( test.bottom ); | 160 | browser_bottom->setText( test.bottom ); |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | void ODict::slotSettings() | 164 | void ODict::slotSettings() |
165 | { | 165 | { |
166 | ConfigDlg dlg( this, "Config" , true); | 166 | ConfigDlg dlg( this, "Config" , true); |
167 | if ( dlg.exec() == QDialog::Accepted ) | 167 | if ( dlg.exec() == QDialog::Accepted ) |
168 | saveConfig(); | 168 | saveConfig(); |
169 | } | 169 | } |
170 | 170 | ||
171 | void ODict::slotSetParameter( int count ) | 171 | void ODict::slotSetParameter( int count ) |
172 | { | 172 | { |
173 | if ( count == 0 ) | 173 | if ( count == 0 ) |
174 | { | 174 | { |
175 | if ( casesens ) | 175 | if ( casesens ) |
176 | casesens = false; | 176 | casesens = false; |
177 | else | 177 | else |
178 | casesens = true; | 178 | casesens = true; |
179 | } | 179 | } |
180 | 180 | ||
181 | saveConfig(); | 181 | saveConfig(); |
182 | } | 182 | } |
183 | 183 | ||
184 | void ODict::slotMethodChanged( const QString& methodnumber ) | 184 | void ODict::slotMethodChanged( const QString& methodnumber ) |
185 | { | 185 | { |
186 | activated_name = methodnumber; | 186 | activated_name = methodnumber; |
187 | 187 | ||
188 | if ( activated_name != ding->loadedDict() ) | 188 | if ( activated_name != ding->loadedDict() ) |
189 | { | 189 | { |
190 | ding->loadDict(activated_name); | 190 | ding->loadDict(activated_name); |
191 | 191 | ||
192 | lookupLanguageNames( activated_name ); | 192 | lookupLanguageNames( activated_name ); |
193 | top_name->setText( top_name_content ); | 193 | top_name->setText( top_name_content ); |
194 | bottom_name->setText( bottom_name_content ); | 194 | bottom_name->setText( bottom_name_content ); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | void ODict::setupMenus() | 198 | void ODict::setupMenus() |
199 | { | 199 | { |
200 | menu = new QMenuBar( this ); | 200 | menu = new QMenuBar( this ); |
201 | 201 | ||
202 | settings = new QPopupMenu( menu ); | 202 | settings = new QPopupMenu( menu ); |
203 | setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 203 | setting_a = new QAction(tr( "Configuration" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
204 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); | 204 | connect( setting_a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); |
205 | setting_a->addTo( settings ); | 205 | setting_a->addTo( settings ); |
206 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); | 206 | setting_b = new QAction(tr( "Searchmethods" ), Resource::loadPixmap( "edit" ), QString::null, 0, this, 0 ); |
207 | 207 | ||
208 | parameter = new QPopupMenu( menu ); | 208 | parameter = new QPopupMenu( menu ); |
209 | connect( parameter, SIGNAL( activated( int ) ), this, SLOT( slotSetParameter( int ) ) ); | 209 | connect( parameter, SIGNAL( activated(int) ), this, SLOT( slotSetParameter(int) ) ); |
210 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); | 210 | parameter->insertItem( tr( "C&ase sensitive" ), 0 ,0 ); |
211 | parameter->insertSeparator(); | 211 | parameter->insertSeparator(); |
212 | 212 | ||
213 | menu->insertItem( tr( "Settings" ) , settings ); | 213 | menu->insertItem( tr( "Settings" ) , settings ); |
214 | menu->insertItem( tr( "Parameter" ) , parameter ); | 214 | menu->insertItem( tr( "Parameter" ) , parameter ); |
215 | } | 215 | } |
diff --git a/noncore/apps/opie-bartender/bartender.cpp b/noncore/apps/opie-bartender/bartender.cpp index 3c010e9..b6401ed 100644 --- a/noncore/apps/opie-bartender/bartender.cpp +++ b/noncore/apps/opie-bartender/bartender.cpp | |||
@@ -9,195 +9,195 @@ | |||
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | 12 | ||
13 | #include "bartender.h" | 13 | #include "bartender.h" |
14 | #include "showdrinks.h" | 14 | #include "showdrinks.h" |
15 | #include "inputDialog.h" | 15 | #include "inputDialog.h" |
16 | #include "searchresults.h" | 16 | #include "searchresults.h" |
17 | #include "bac.h" | 17 | #include "bac.h" |
18 | 18 | ||
19 | #include <qpe/qpetoolbar.h> | 19 | #include <qpe/qpetoolbar.h> |
20 | #include <qmenubar.h> | 20 | #include <qmenubar.h> |
21 | //#include <opie2/colorpopupmenu.h> | 21 | //#include <opie2/colorpopupmenu.h> |
22 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | 24 | ||
25 | #include <qlineedit.h> | 25 | #include <qlineedit.h> |
26 | #include <qdir.h> | 26 | #include <qdir.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qlistbox.h> | 28 | #include <qlistbox.h> |
29 | #include <qmultilineedit.h> | 29 | #include <qmultilineedit.h> |
30 | #include <qmessagebox.h> | 30 | #include <qmessagebox.h> |
31 | #include <qtextstream.h> | 31 | #include <qtextstream.h> |
32 | #include <qaction.h> | 32 | #include <qaction.h> |
33 | #include <qheader.h> | 33 | #include <qheader.h> |
34 | #include <qlistview.h> | 34 | #include <qlistview.h> |
35 | #include <qlayout.h> | 35 | #include <qlayout.h> |
36 | 36 | ||
37 | #include <fcntl.h> | 37 | #include <fcntl.h> |
38 | #include <unistd.h> | 38 | #include <unistd.h> |
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | #include <stdio.h> | 40 | #include <stdio.h> |
41 | #include <errno.h> | 41 | #include <errno.h> |
42 | 42 | ||
43 | 43 | ||
44 | Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) | 44 | Bartender::Bartender( QWidget* parent, const char* name, WFlags fl ) |
45 | : QMainWindow( parent, name, fl ) { | 45 | : QMainWindow( parent, name, fl ) { |
46 | if ( !name ) | 46 | if ( !name ) |
47 | setName( "Bartender" ); | 47 | setName( "Bartender" ); |
48 | QGridLayout *layout = new QGridLayout( this ); | 48 | QGridLayout *layout = new QGridLayout( this ); |
49 | layout->setSpacing( 2); | 49 | layout->setSpacing( 2); |
50 | layout->setMargin( 2); | 50 | layout->setMargin( 2); |
51 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 51 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
52 | 52 | ||
53 | setCaption( tr( "Bartender" ) ); | 53 | setCaption( tr( "Bartender" ) ); |
54 | 54 | ||
55 | ToolBar1 = new QToolBar( this, "ToolBar1" ); | 55 | ToolBar1 = new QToolBar( this, "ToolBar1" ); |
56 | ToolBar1->setFixedHeight(22); | 56 | ToolBar1->setFixedHeight(22); |
57 | layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 ); | 57 | layout->addMultiCellWidget( ToolBar1, 0, 0, 0, 4 ); |
58 | 58 | ||
59 | QMenuBar *menuBar = new QMenuBar( ToolBar1 ); | 59 | QMenuBar *menuBar = new QMenuBar( ToolBar1 ); |
60 | QPopupMenu *fileMenu; | 60 | QPopupMenu *fileMenu; |
61 | fileMenu = new QPopupMenu( this); | 61 | fileMenu = new QPopupMenu( this); |
62 | menuBar->insertItem( tr("File"), fileMenu ); | 62 | menuBar->insertItem( tr("File"), fileMenu ); |
63 | 63 | ||
64 | fileMenu->insertItem(tr("New Drink")); | 64 | fileMenu->insertItem(tr("New Drink")); |
65 | fileMenu->insertItem(tr("Open Drink")); | 65 | fileMenu->insertItem(tr("Open Drink")); |
66 | fileMenu->insertItem(tr("Find by Drink Name")); | 66 | fileMenu->insertItem(tr("Find by Drink Name")); |
67 | fileMenu->insertItem(tr("Find by Alcohol")); | 67 | fileMenu->insertItem(tr("Find by Alcohol")); |
68 | 68 | ||
69 | QPopupMenu *editMenu; | 69 | QPopupMenu *editMenu; |
70 | editMenu = new QPopupMenu( this); | 70 | editMenu = new QPopupMenu( this); |
71 | menuBar->insertItem( tr("Edit"), editMenu ); | 71 | menuBar->insertItem( tr("Edit"), editMenu ); |
72 | editMenu->insertItem(tr("edit")); | 72 | editMenu->insertItem(tr("edit")); |
73 | 73 | ||
74 | connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); | 74 | connect( fileMenu, SIGNAL( activated(int) ), this, SLOT( fileMenuActivated(int) )); |
75 | connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); | 75 | connect( editMenu, SIGNAL( activated(int) ), this, SLOT( editMenuActivated(int) )); |
76 | 76 | ||
77 | 77 | ||
78 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); | 78 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), "New", 0, this, 0 ); |
79 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 79 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
80 | a->addTo( ToolBar1 ); | 80 | a->addTo( ToolBar1 ); |
81 | 81 | ||
82 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); | 82 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "bartender/bartender_sm" ), "open", 0, this, 0 ); |
83 | connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); | 83 | connect( a, SIGNAL( activated() ), this, SLOT( openCurrentDrink() ) ); |
84 | a->addTo( ToolBar1 ); | 84 | a->addTo( ToolBar1 ); |
85 | 85 | ||
86 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); | 86 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), "Find", 0, this, 0 ); |
87 | connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); | 87 | connect( a, SIGNAL( activated() ), this, SLOT( askSearch() ) ); |
88 | a->addTo( ToolBar1 ); | 88 | a->addTo( ToolBar1 ); |
89 | 89 | ||
90 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); | 90 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ),"Edit", 0, this, 0 ); |
91 | connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); | 91 | connect( a, SIGNAL( activated() ), this, SLOT( doEdit() ) ); |
92 | a->addTo( ToolBar1 ); | 92 | a->addTo( ToolBar1 ); |
93 | 93 | ||
94 | QPushButton *t; | 94 | QPushButton *t; |
95 | t= new QPushButton( "BAC", ToolBar1, "bacButtin"); | 95 | t= new QPushButton( "BAC", ToolBar1, "bacButtin"); |
96 | connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); | 96 | connect( t, SIGNAL( clicked() ), this, SLOT( doBac() ) ); |
97 | 97 | ||
98 | DrinkView = new QListView( this, "DrinkView" ); | 98 | DrinkView = new QListView( this, "DrinkView" ); |
99 | DrinkView->addColumn( tr( "Name of Drink" ) ); | 99 | DrinkView->addColumn( tr( "Name of Drink" ) ); |
100 | // DrinkView->setRootIsDecorated( TRUE ); | 100 | // DrinkView->setRootIsDecorated( TRUE ); |
101 | DrinkView->header()->hide(); | 101 | DrinkView->header()->hide(); |
102 | 102 | ||
103 | QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); | 103 | QPEApplication::setStylusOperation( DrinkView->viewport(),QPEApplication::RightOnHold); |
104 | 104 | ||
105 | connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink( QListViewItem*))); | 105 | connect(DrinkView, SIGNAL( doubleClicked(QListViewItem*)),this,SLOT(showDrink(QListViewItem*))); |
106 | connect(DrinkView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 106 | connect(DrinkView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int)), |
107 | this,SLOT( showDrink(int, QListViewItem *, const QPoint&, int))); | 107 | this,SLOT( showDrink(int,QListViewItem*,const QPoint&,int))); |
108 | 108 | ||
109 | layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); | 109 | layout->addMultiCellWidget( DrinkView, 1, 2, 0, 4 ); |
110 | if(QDir("db").exists()) { | 110 | if(QDir("db").exists()) { |
111 | dbFile.setName( "db/drinkdb.txt"); | 111 | dbFile.setName( "db/drinkdb.txt"); |
112 | } else | 112 | } else |
113 | dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt"); | 113 | dbFile.setName( QPEApplication::qpeDir()+"/etc/bartender/drinkdb.txt"); |
114 | initDrinkDb(); | 114 | initDrinkDb(); |
115 | } | 115 | } |
116 | 116 | ||
117 | Bartender::~Bartender() { | 117 | Bartender::~Bartender() { |
118 | } | 118 | } |
119 | 119 | ||
120 | /* | 120 | /* |
121 | this happens right before exit */ | 121 | this happens right before exit */ |
122 | void Bartender::cleanUp() { | 122 | void Bartender::cleanUp() { |
123 | dbFile.close(); | 123 | dbFile.close(); |
124 | 124 | ||
125 | } | 125 | } |
126 | 126 | ||
127 | void Bartender::initDrinkDb() { | 127 | void Bartender::initDrinkDb() { |
128 | 128 | ||
129 | if(!dbFile.isOpen()) | 129 | if(!dbFile.isOpen()) |
130 | if ( !dbFile.open( IO_ReadOnly)) { | 130 | if ( !dbFile.open( IO_ReadOnly)) { |
131 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); | 131 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); |
132 | return; | 132 | return; |
133 | } | 133 | } |
134 | fillList(); | 134 | fillList(); |
135 | } | 135 | } |
136 | 136 | ||
137 | void Bartender::fillList() { | 137 | void Bartender::fillList() { |
138 | dbFile.at(1); | 138 | dbFile.at(1); |
139 | DrinkView->clear(); | 139 | DrinkView->clear(); |
140 | int i=0; | 140 | int i=0; |
141 | QListViewItem * item ; | 141 | QListViewItem * item ; |
142 | QTextStream t( &dbFile); | 142 | QTextStream t( &dbFile); |
143 | QString s; | 143 | QString s; |
144 | while ( !t.eof()) { | 144 | while ( !t.eof()) { |
145 | s = t.readLine(); | 145 | s = t.readLine(); |
146 | if(s.find("#",0,TRUE) != -1) { | 146 | if(s.find("#",0,TRUE) != -1) { |
147 | // qDebug(s.right(s.length()-2)); | 147 | // qDebug(s.right(s.length()-2)); |
148 | item= new QListViewItem( DrinkView, 0 ); | 148 | item= new QListViewItem( DrinkView, 0 ); |
149 | item->setText( 0, s.right(s.length()-2)); | 149 | item->setText( 0, s.right(s.length()-2)); |
150 | i++; | 150 | i++; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | qDebug("there are currently %d of drinks", i); | 153 | qDebug("there are currently %d of drinks", i); |
154 | } | 154 | } |
155 | 155 | ||
156 | void Bartender::fileNew() { | 156 | void Bartender::fileNew() { |
157 | 157 | ||
158 | New_Drink *newDrinks; | 158 | New_Drink *newDrinks; |
159 | newDrinks = new New_Drink(this,"New Drink....", TRUE); | 159 | newDrinks = new New_Drink(this,"New Drink....", TRUE); |
160 | QString newName, newIng; | 160 | QString newName, newIng; |
161 | QPEApplication::execDialog( newDrinks ); | 161 | QPEApplication::execDialog( newDrinks ); |
162 | newName = newDrinks->LineEdit1->text(); | 162 | newName = newDrinks->LineEdit1->text(); |
163 | newIng= newDrinks->MultiLineEdit1->text(); | 163 | newIng= newDrinks->MultiLineEdit1->text(); |
164 | 164 | ||
165 | if(dbFile.isOpen()) | 165 | if(dbFile.isOpen()) |
166 | dbFile.close(); | 166 | dbFile.close(); |
167 | if ( !dbFile.open( IO_WriteOnly| IO_Append)) { | 167 | if ( !dbFile.open( IO_WriteOnly| IO_Append)) { |
168 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); | 168 | QMessageBox::message( (tr("Note")), (tr("Drink database not opened sucessfully.\n")) ); |
169 | return; | 169 | return; |
170 | } | 170 | } |
171 | if(newDrinks ->result() == 1 ) { | 171 | if(newDrinks ->result() == 1 ) { |
172 | QString newDrink="\n# "+newName+"\n"; | 172 | QString newDrink="\n# "+newName+"\n"; |
173 | newDrink.append(newIng+"\n"); | 173 | newDrink.append(newIng+"\n"); |
174 | qDebug("writing "+newDrink); | 174 | qDebug("writing "+newDrink); |
175 | dbFile.writeBlock( newDrink.latin1(), newDrink.length()); | 175 | dbFile.writeBlock( newDrink.latin1(), newDrink.length()); |
176 | clearList(); | 176 | clearList(); |
177 | dbFile.close(); | 177 | dbFile.close(); |
178 | 178 | ||
179 | initDrinkDb(); | 179 | initDrinkDb(); |
180 | } | 180 | } |
181 | delete newDrinks; | 181 | delete newDrinks; |
182 | } | 182 | } |
183 | 183 | ||
184 | void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) { | 184 | void Bartender::showDrink(int mouse, QListViewItem * item, const QPoint&, int) { |
185 | switch (mouse) { | 185 | switch (mouse) { |
186 | case 1: | 186 | case 1: |
187 | // showDrink(item); | 187 | // showDrink(item); |
188 | break; | 188 | break; |
189 | case 2: | 189 | case 2: |
190 | showDrink(item); | 190 | showDrink(item); |
191 | break; | 191 | break; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | void Bartender::showDrink( QListViewItem *item) { | 195 | void Bartender::showDrink( QListViewItem *item) { |
196 | if(item==NULL) return; | 196 | if(item==NULL) return; |
197 | dbFile.at(0); | 197 | dbFile.at(0); |
198 | Show_Drink *showDrinks; | 198 | Show_Drink *showDrinks; |
199 | QString myDrink=item->text(0); | 199 | QString myDrink=item->text(0); |
200 | showDrinks = new Show_Drink(this, myDrink, TRUE); | 200 | showDrinks = new Show_Drink(this, myDrink, TRUE); |
201 | QTextStream t( &dbFile); | 201 | QTextStream t( &dbFile); |
202 | 202 | ||
203 | QString s, s2; | 203 | QString s, s2; |
diff --git a/noncore/apps/opie-bartender/searchresults.cpp b/noncore/apps/opie-bartender/searchresults.cpp index 4900d1f..a511a57 100644 --- a/noncore/apps/opie-bartender/searchresults.cpp +++ b/noncore/apps/opie-bartender/searchresults.cpp | |||
@@ -1,43 +1,43 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Created: Sat Jul 20 08:23:27 2002 | 2 | ** Created: Sat Jul 20 08:23:27 2002 |
3 | ** by: L.J. Potter <ljp@llornkcor.com> | 3 | ** by: L.J. Potter <ljp@llornkcor.com> |
4 | ** copyright : (C) 2002 by ljp | 4 | ** copyright : (C) 2002 by ljp |
5 | email : ljp@llornkcor.com | 5 | email : ljp@llornkcor.com |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * | 7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License, or * | 8 | * the Free Software Foundation; either version 2 of the License, or * |
9 | * (at your option) any later version. * | 9 | * (at your option) any later version. * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | #include "searchresults.h" | 11 | #include "searchresults.h" |
12 | 12 | ||
13 | 13 | ||
14 | #include <qlistbox.h> | 14 | #include <qlistbox.h> |
15 | #include <qlayout.h> | 15 | #include <qlayout.h> |
16 | 16 | ||
17 | Search_Results::Search_Results( QWidget* parent, const char* name, bool modal, WFlags fl ) | 17 | Search_Results::Search_Results( QWidget* parent, const char* name, bool modal, WFlags fl ) |
18 | : QDialog( parent, name, modal, fl ) { | 18 | : QDialog( parent, name, modal, fl ) { |
19 | if ( !name ) | 19 | if ( !name ) |
20 | setName( drinkName); | 20 | setName( drinkName); |
21 | 21 | ||
22 | drinkName = name; | 22 | drinkName = name; |
23 | setCaption( drinkName ); | 23 | setCaption( drinkName ); |
24 | 24 | ||
25 | Layout5 = new QGridLayout( this ); | 25 | Layout5 = new QGridLayout( this ); |
26 | Layout5->setSpacing( 6 ); | 26 | Layout5->setSpacing( 6 ); |
27 | Layout5->setMargin( 4 ); | 27 | Layout5->setMargin( 4 ); |
28 | 28 | ||
29 | ListBox1 = new QListBox( this, "ListBox1" ); | 29 | ListBox1 = new QListBox( this, "ListBox1" ); |
30 | 30 | ||
31 | Layout5->addMultiCellWidget( ListBox1, 0, 1, 0, 3 ); | 31 | Layout5->addMultiCellWidget( ListBox1, 0, 1, 0, 3 ); |
32 | connect( ListBox1, SIGNAL( clicked( QListBoxItem *)), SLOT( listSelected( QListBoxItem *)) ); | 32 | connect( ListBox1, SIGNAL( clicked(QListBoxItem*)), SLOT( listSelected(QListBoxItem*)) ); |
33 | } | 33 | } |
34 | 34 | ||
35 | Search_Results::~Search_Results() { | 35 | Search_Results::~Search_Results() { |
36 | } | 36 | } |
37 | 37 | ||
38 | 38 | ||
39 | void Search_Results::listSelected(QListBoxItem *) { | 39 | void Search_Results::listSelected(QListBoxItem *) { |
40 | 40 | ||
41 | QDialog::accept(); | 41 | QDialog::accept(); |
42 | } | 42 | } |
43 | 43 | ||
diff --git a/noncore/apps/opie-console/btconfigwidget.cpp b/noncore/apps/opie-console/btconfigwidget.cpp index 64046d8..0ac337f 100644 --- a/noncore/apps/opie-console/btconfigwidget.cpp +++ b/noncore/apps/opie-console/btconfigwidget.cpp | |||
@@ -1,139 +1,139 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <qlineedit.h> | 3 | #include <qlineedit.h> |
4 | #include <qcombobox.h> | 4 | #include <qcombobox.h> |
5 | #include <qhbox.h> | 5 | #include <qhbox.h> |
6 | #include <qradiobutton.h> | 6 | #include <qradiobutton.h> |
7 | 7 | ||
8 | #include "iolayerbase.h" | 8 | #include "iolayerbase.h" |
9 | #include "btconfigwidget.h" | 9 | #include "btconfigwidget.h" |
10 | 10 | ||
11 | namespace { | 11 | namespace { |
12 | void setCurrent( const QString& str, QComboBox* bo ) { | 12 | void setCurrent( const QString& str, QComboBox* bo ) { |
13 | uint b = bo->count(); | 13 | uint b = bo->count(); |
14 | for (int i = 0; i < bo->count(); i++ ) { | 14 | for (int i = 0; i < bo->count(); i++ ) { |
15 | if ( bo->text(i) == str ) { | 15 | if ( bo->text(i) == str ) { |
16 | bo->setCurrentItem( i ); | 16 | bo->setCurrentItem( i ); |
17 | return; | 17 | return; |
18 | } | 18 | } |
19 | } | 19 | } |
20 | bo->insertItem( str ); | 20 | bo->insertItem( str ); |
21 | bo->setCurrentItem( b ); | 21 | bo->setCurrentItem( b ); |
22 | } | 22 | } |
23 | } | 23 | } |
24 | 24 | ||
25 | BTConfigWidget::BTConfigWidget( const QString& name, | 25 | BTConfigWidget::BTConfigWidget( const QString& name, |
26 | QWidget* parent, | 26 | QWidget* parent, |
27 | const char* na ) | 27 | const char* na ) |
28 | : ProfileDialogConnectionWidget( name, parent, na ) { | 28 | : ProfileDialogConnectionWidget( name, parent, na ) { |
29 | 29 | ||
30 | m_lay = new QVBoxLayout( this ); | 30 | m_lay = new QVBoxLayout( this ); |
31 | 31 | ||
32 | m_device = new QLabel( tr( "Device" ), this ); | 32 | m_device = new QLabel( tr( "Device" ), this ); |
33 | QHBox *deviceBox = new QHBox( this ); | 33 | QHBox *deviceBox = new QHBox( this ); |
34 | m_devRadio = new QRadioButton( deviceBox ); | 34 | m_devRadio = new QRadioButton( deviceBox ); |
35 | connect( m_devRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotDevRadio( bool ) ) ); | 35 | connect( m_devRadio, SIGNAL( toggled(bool) ), this, SLOT( slotDevRadio(bool) ) ); |
36 | m_deviceCmb = new QComboBox( deviceBox ); | 36 | m_deviceCmb = new QComboBox( deviceBox ); |
37 | m_deviceCmb->setEditable( TRUE ); | 37 | m_deviceCmb->setEditable( TRUE ); |
38 | 38 | ||
39 | QLabel *macLabel = new QLabel( this ); | 39 | QLabel *macLabel = new QLabel( this ); |
40 | macLabel->setText( tr( "Or peer mac address" ) ); | 40 | macLabel->setText( tr( "Or peer mac address" ) ); |
41 | QHBox *macBox = new QHBox( this ); | 41 | QHBox *macBox = new QHBox( this ); |
42 | m_macRadio = new QRadioButton( macBox ); | 42 | m_macRadio = new QRadioButton( macBox ); |
43 | connect( m_macRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotMacRadio( bool ) ) ); | 43 | connect( m_macRadio, SIGNAL( toggled(bool) ), this, SLOT( slotMacRadio(bool) ) ); |
44 | m_mac = new QLineEdit( macBox ); | 44 | m_mac = new QLineEdit( macBox ); |
45 | 45 | ||
46 | m_base = new IOLayerBase(this, "base"); | 46 | m_base = new IOLayerBase(this, "base"); |
47 | 47 | ||
48 | m_lay->addWidget( m_device ); | 48 | m_lay->addWidget( m_device ); |
49 | m_lay->addWidget( deviceBox ); | 49 | m_lay->addWidget( deviceBox ); |
50 | m_lay->addWidget( macLabel ); | 50 | m_lay->addWidget( macLabel ); |
51 | m_lay->addWidget( macBox ); | 51 | m_lay->addWidget( macBox ); |
52 | m_lay->addWidget( m_base ); | 52 | m_lay->addWidget( m_base ); |
53 | 53 | ||
54 | m_deviceCmb->insertItem( "/dev/ttyU0" ); | 54 | m_deviceCmb->insertItem( "/dev/ttyU0" ); |
55 | m_deviceCmb->insertItem( "/dev/ttyU1" ); | 55 | m_deviceCmb->insertItem( "/dev/ttyU1" ); |
56 | } | 56 | } |
57 | 57 | ||
58 | BTConfigWidget::~BTConfigWidget() { | 58 | BTConfigWidget::~BTConfigWidget() { |
59 | 59 | ||
60 | } | 60 | } |
61 | void BTConfigWidget::load( const Profile& prof ) { | 61 | void BTConfigWidget::load( const Profile& prof ) { |
62 | int rad_flow = prof.readNumEntry("Flow"); | 62 | int rad_flow = prof.readNumEntry("Flow"); |
63 | int rad_parity = prof.readNumEntry("Parity"); | 63 | int rad_parity = prof.readNumEntry("Parity"); |
64 | int speed = prof.readNumEntry("Speed"); | 64 | int speed = prof.readNumEntry("Speed"); |
65 | QString mac = prof.readEntry("Mac"); | 65 | QString mac = prof.readEntry("Mac"); |
66 | 66 | ||
67 | if (!mac.isEmpty() ) { | 67 | if (!mac.isEmpty() ) { |
68 | m_mac->setText( mac ); | 68 | m_mac->setText( mac ); |
69 | } else { | 69 | } else { |
70 | m_devRadio->setChecked( true ); | 70 | m_devRadio->setChecked( true ); |
71 | } | 71 | } |
72 | 72 | ||
73 | if (rad_flow == 1) { | 73 | if (rad_flow == 1) { |
74 | m_base->setFlow( IOLayerBase::Hardware ); | 74 | m_base->setFlow( IOLayerBase::Hardware ); |
75 | } else if (rad_flow == 2) { | 75 | } else if (rad_flow == 2) { |
76 | m_base->setFlow( IOLayerBase::Software ); | 76 | m_base->setFlow( IOLayerBase::Software ); |
77 | } else if (rad_flow == 0) { | 77 | } else if (rad_flow == 0) { |
78 | m_base->setFlow( IOLayerBase::None ); | 78 | m_base->setFlow( IOLayerBase::None ); |
79 | } | 79 | } |
80 | 80 | ||
81 | if (rad_parity == 1) { | 81 | if (rad_parity == 1) { |
82 | m_base->setParity( IOLayerBase::Even ); | 82 | m_base->setParity( IOLayerBase::Even ); |
83 | } else if ( rad_parity == 2 ) { | 83 | } else if ( rad_parity == 2 ) { |
84 | m_base->setParity( IOLayerBase::Odd ); | 84 | m_base->setParity( IOLayerBase::Odd ); |
85 | } else { | 85 | } else { |
86 | m_base->setParity( IOLayerBase::NonePar ); | 86 | m_base->setParity( IOLayerBase::NonePar ); |
87 | } | 87 | } |
88 | 88 | ||
89 | switch( speed ) { | 89 | switch( speed ) { |
90 | case 115200: | 90 | case 115200: |
91 | m_base->setSpeed(IOLayerBase::Baud_115200 ); | 91 | m_base->setSpeed(IOLayerBase::Baud_115200 ); |
92 | break; | 92 | break; |
93 | case 57600: | 93 | case 57600: |
94 | m_base->setSpeed( IOLayerBase::Baud_57600 ); | 94 | m_base->setSpeed( IOLayerBase::Baud_57600 ); |
95 | break; | 95 | break; |
96 | case 38400: | 96 | case 38400: |
97 | m_base->setSpeed(IOLayerBase::Baud_38400 ); | 97 | m_base->setSpeed(IOLayerBase::Baud_38400 ); |
98 | break; | 98 | break; |
99 | case 19200: | 99 | case 19200: |
100 | m_base->setSpeed( IOLayerBase::Baud_19200 ); | 100 | m_base->setSpeed( IOLayerBase::Baud_19200 ); |
101 | break; | 101 | break; |
102 | case 9600: | 102 | case 9600: |
103 | default: | 103 | default: |
104 | m_base->setSpeed(IOLayerBase::Baud_9600 ); | 104 | m_base->setSpeed(IOLayerBase::Baud_9600 ); |
105 | break; | 105 | break; |
106 | } | 106 | } |
107 | 107 | ||
108 | if ( prof.readEntry("Device").isEmpty() ) return; | 108 | if ( prof.readEntry("Device").isEmpty() ) return; |
109 | setCurrent( prof.readEntry("Device"), m_deviceCmb ); | 109 | setCurrent( prof.readEntry("Device"), m_deviceCmb ); |
110 | 110 | ||
111 | } | 111 | } |
112 | /* | 112 | /* |
113 | * save speed, | 113 | * save speed, |
114 | * flow, | 114 | * flow, |
115 | * parity | 115 | * parity |
116 | */ | 116 | */ |
117 | void BTConfigWidget::save( Profile& prof ) { | 117 | void BTConfigWidget::save( Profile& prof ) { |
118 | int flow, parity, speed; | 118 | int flow, parity, speed; |
119 | flow = parity = speed = 0; | 119 | flow = parity = speed = 0; |
120 | prof.writeEntry("Device", m_deviceCmb->currentText() ); | 120 | prof.writeEntry("Device", m_deviceCmb->currentText() ); |
121 | 121 | ||
122 | 122 | ||
123 | switch( m_base->flow() ) { | 123 | switch( m_base->flow() ) { |
124 | case IOLayerBase::None: | 124 | case IOLayerBase::None: |
125 | flow = 0; | 125 | flow = 0; |
126 | break; | 126 | break; |
127 | case IOLayerBase::Software: | 127 | case IOLayerBase::Software: |
128 | flow = 2; | 128 | flow = 2; |
129 | break; | 129 | break; |
130 | case IOLayerBase::Hardware: | 130 | case IOLayerBase::Hardware: |
131 | flow = 1; | 131 | flow = 1; |
132 | break; | 132 | break; |
133 | } | 133 | } |
134 | 134 | ||
135 | switch( m_base->parity() ) { | 135 | switch( m_base->parity() ) { |
136 | case IOLayerBase::Odd: | 136 | case IOLayerBase::Odd: |
137 | parity = 2; | 137 | parity = 2; |
138 | break; | 138 | break; |
139 | case IOLayerBase::Even: | 139 | case IOLayerBase::Even: |
diff --git a/noncore/apps/opie-console/dialdialog.cpp b/noncore/apps/opie-console/dialdialog.cpp index 6bc1240..526d55e 100644 --- a/noncore/apps/opie-console/dialdialog.cpp +++ b/noncore/apps/opie-console/dialdialog.cpp | |||
@@ -1,98 +1,98 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <qlayout.h> | 3 | #include <qlayout.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qpushbutton.h> | 5 | #include <qpushbutton.h> |
6 | #include <qbuttongroup.h> | 6 | #include <qbuttongroup.h> |
7 | 7 | ||
8 | #include "dialdialog.h" | 8 | #include "dialdialog.h" |
9 | 9 | ||
10 | 10 | ||
11 | 11 | ||
12 | DialDialog::DialDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 12 | DialDialog::DialDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
13 | : QDialog( parent, name, modal, fl ) { | 13 | : QDialog( parent, name, modal, fl ) { |
14 | 14 | ||
15 | setCaption( tr( "Enter number" ) ); | 15 | setCaption( tr( "Enter number" ) ); |
16 | 16 | ||
17 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); | 17 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); |
18 | 18 | ||
19 | QLabel *textLabel = new QLabel( this ); | 19 | QLabel *textLabel = new QLabel( this ); |
20 | textLabel->setTextFormat( QLabel::RichText ); | 20 | textLabel->setTextFormat( QLabel::RichText ); |
21 | textLabel->setText( tr("Enter the number you want to dial. When finished, press ok") ); | 21 | textLabel->setText( tr("Enter the number you want to dial. When finished, press ok") ); |
22 | 22 | ||
23 | m_dialLine = new QLineEdit( this ); | 23 | m_dialLine = new QLineEdit( this ); |
24 | m_dialLine->setReadOnly( true ); | 24 | m_dialLine->setReadOnly( true ); |
25 | m_dialLine->setFrame( false ); | 25 | m_dialLine->setFrame( false ); |
26 | m_dialLine->setAlignment( Qt::AlignLeft ); | 26 | m_dialLine->setAlignment( Qt::AlignLeft ); |
27 | QFont dialLine_font( m_dialLine->font() ); | 27 | QFont dialLine_font( m_dialLine->font() ); |
28 | dialLine_font.setBold( TRUE ); | 28 | dialLine_font.setBold( TRUE ); |
29 | dialLine_font.setPointSize( 18 ); | 29 | dialLine_font.setPointSize( 18 ); |
30 | m_dialLine->setFont( dialLine_font ); | 30 | m_dialLine->setFont( dialLine_font ); |
31 | 31 | ||
32 | QWidget* dialWidget = new QWidget( this ); | 32 | QWidget* dialWidget = new QWidget( this ); |
33 | QGridLayout *layout = new QGridLayout( dialWidget , 4, 3 ); | 33 | QGridLayout *layout = new QGridLayout( dialWidget , 4, 3 ); |
34 | 34 | ||
35 | QButtonGroup *dialButtons = new QButtonGroup( ); | 35 | QButtonGroup *dialButtons = new QButtonGroup( ); |
36 | 36 | ||
37 | QPushButton *number0 = new QPushButton( dialWidget ); | 37 | QPushButton *number0 = new QPushButton( dialWidget ); |
38 | number0->setText( QString( "0" ) ); | 38 | number0->setText( QString( "0" ) ); |
39 | QFont number0_font( number0->font() ); | 39 | QFont number0_font( number0->font() ); |
40 | number0_font.setBold( TRUE ); | 40 | number0_font.setBold( TRUE ); |
41 | number0->setFont( number0_font ); | 41 | number0->setFont( number0_font ); |
42 | layout->addWidget( number0, 4, 1 ); | 42 | layout->addWidget( number0, 4, 1 ); |
43 | dialButtons->insert( number0 ); | 43 | dialButtons->insert( number0 ); |
44 | 44 | ||
45 | int x = 0, y = 0; | 45 | int x = 0, y = 0; |
46 | for ( int i = 0 ; i < 9; i++ ) { | 46 | for ( int i = 0 ; i < 9; i++ ) { |
47 | QPushButton *number = new QPushButton( dialWidget ); | 47 | QPushButton *number = new QPushButton( dialWidget ); |
48 | number->setText( QString( "%1" ).arg( i + 1 ) ); | 48 | number->setText( QString( "%1" ).arg( i + 1 ) ); |
49 | QFont number_font( number->font() ); | 49 | QFont number_font( number->font() ); |
50 | number_font.setBold( TRUE ); | 50 | number_font.setBold( TRUE ); |
51 | number->setFont( number_font ); | 51 | number->setFont( number_font ); |
52 | 52 | ||
53 | dialButtons->insert( number ); | 53 | dialButtons->insert( number ); |
54 | 54 | ||
55 | layout->addWidget( number, x, y ); | 55 | layout->addWidget( number, x, y ); |
56 | 56 | ||
57 | if ( y < 2 ) { | 57 | if ( y < 2 ) { |
58 | y++; | 58 | y++; |
59 | } else { | 59 | } else { |
60 | x++; | 60 | x++; |
61 | y = 0; | 61 | y = 0; |
62 | } | 62 | } |
63 | } | 63 | } |
64 | 64 | ||
65 | connect( dialButtons, SIGNAL( clicked( int ) ), this, SLOT( slotEnterNumber( int ) ) ); | 65 | connect( dialButtons, SIGNAL( clicked(int) ), this, SLOT( slotEnterNumber(int) ) ); |
66 | 66 | ||
67 | mainLayout->addStretch( 2 ); | 67 | mainLayout->addStretch( 2 ); |
68 | mainLayout->addWidget( textLabel ); | 68 | mainLayout->addWidget( textLabel ); |
69 | mainLayout->addStretch( 1 ); | 69 | mainLayout->addStretch( 1 ); |
70 | mainLayout->addWidget( m_dialLine ); | 70 | mainLayout->addWidget( m_dialLine ); |
71 | mainLayout->addStretch( 2 ); | 71 | mainLayout->addStretch( 2 ); |
72 | mainLayout->addWidget( dialWidget ); | 72 | mainLayout->addWidget( dialWidget ); |
73 | mainLayout->addStretch( 4 ); | 73 | mainLayout->addStretch( 4 ); |
74 | } | 74 | } |
75 | 75 | ||
76 | 76 | ||
77 | void DialDialog::slotEnterNumber( int number ) { | 77 | void DialDialog::slotEnterNumber( int number ) { |
78 | 78 | ||
79 | // pretty stupid, just for testing .-) | 79 | // pretty stupid, just for testing .-) |
80 | 80 | ||
81 | m_number.append(QString("%1").arg(number)); | 81 | m_number.append(QString("%1").arg(number)); |
82 | 82 | ||
83 | setNumber(m_number); | 83 | setNumber(m_number); |
84 | } | 84 | } |
85 | 85 | ||
86 | DialDialog::~DialDialog() { | 86 | DialDialog::~DialDialog() { |
87 | } | 87 | } |
88 | 88 | ||
89 | QString DialDialog::number() { | 89 | QString DialDialog::number() { |
90 | return m_number; | 90 | return m_number; |
91 | 91 | ||
92 | } | 92 | } |
93 | 93 | ||
94 | void DialDialog::setNumber( QString number ) | 94 | void DialDialog::setNumber( QString number ) |
95 | { | 95 | { |
96 | m_dialLine->setText( QString("%1").arg( number ) ); | 96 | m_dialLine->setText( QString("%1").arg( number ) ); |
97 | } | 97 | } |
98 | 98 | ||
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index 2c1d888..99d069f 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp | |||
@@ -1,119 +1,119 @@ | |||
1 | 1 | ||
2 | #include "TEmuVt102.h" | 2 | #include "TEmuVt102.h" |
3 | 3 | ||
4 | #include "profile.h" | 4 | #include "profile.h" |
5 | #include "emulation_handler.h" | 5 | #include "emulation_handler.h" |
6 | #include "script.h" | 6 | #include "script.h" |
7 | 7 | ||
8 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) | 8 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) |
9 | : QObject(0, name ) | 9 | : QObject(0, name ) |
10 | { | 10 | { |
11 | m_teWid = new TEWidget( parent, "TerminalMain"); | 11 | m_teWid = new TEWidget( parent, "TerminalMain"); |
12 | // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) | 12 | // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) |
13 | // use setWrapAt(80) for normal console with scrollbar | 13 | // use setWrapAt(80) for normal console with scrollbar |
14 | setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80); | 14 | setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80); |
15 | m_teWid->setMinimumSize(150, 70 ); | 15 | m_teWid->setMinimumSize(150, 70 ); |
16 | m_script = 0; | 16 | m_script = 0; |
17 | parent->resize( m_teWid->calcSize(80, 24 ) ); | 17 | parent->resize( m_teWid->calcSize(80, 24 ) ); |
18 | m_teEmu = new TEmuVt102(m_teWid ); | 18 | m_teEmu = new TEmuVt102(m_teWid ); |
19 | 19 | ||
20 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), | 20 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ), |
21 | this, SIGNAL(changeSize(int, int) ) ); | 21 | this, SIGNAL(changeSize(int,int) ) ); |
22 | connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), | 22 | connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ), |
23 | this, SLOT(recvEmulation(const char*, int) ) ); | 23 | this, SLOT(recvEmulation(const char*,int) ) ); |
24 | m_teEmu->setConnect( true ); | 24 | m_teEmu->setConnect( true ); |
25 | m_teEmu->setHistory( TRUE ); | 25 | m_teEmu->setHistory( TRUE ); |
26 | load( prof ); | 26 | load( prof ); |
27 | 27 | ||
28 | 28 | ||
29 | 29 | ||
30 | } | 30 | } |
31 | TEmulation* EmulationHandler::emulation() { | 31 | TEmulation* EmulationHandler::emulation() { |
32 | return m_teEmu; | 32 | return m_teEmu; |
33 | } | 33 | } |
34 | EmulationHandler::~EmulationHandler() { | 34 | EmulationHandler::~EmulationHandler() { |
35 | if (isRecording()) | 35 | if (isRecording()) |
36 | clearScript(); | 36 | clearScript(); |
37 | delete m_teEmu; | 37 | delete m_teEmu; |
38 | delete m_teWid; | 38 | delete m_teWid; |
39 | } | 39 | } |
40 | 40 | ||
41 | void EmulationHandler::load( const Profile& prof) { | 41 | void EmulationHandler::load( const Profile& prof) { |
42 | m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); | 42 | m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); |
43 | int num = prof.readNumEntry("Color"); | 43 | int num = prof.readNumEntry("Color"); |
44 | setColor( foreColor(num), backColor(num) ); | 44 | setColor( foreColor(num), backColor(num) ); |
45 | m_teWid->setBackgroundColor(backColor(num) ); | 45 | m_teWid->setBackgroundColor(backColor(num) ); |
46 | 46 | ||
47 | int term = prof.readNumEntry("Terminal", 0) ; | 47 | int term = prof.readNumEntry("Terminal", 0) ; |
48 | switch(term) { | 48 | switch(term) { |
49 | default: | 49 | default: |
50 | case Profile::VT102: | 50 | case Profile::VT102: |
51 | case Profile::VT100: | 51 | case Profile::VT100: |
52 | m_teEmu->setKeytrans("vt100.keytab"); | 52 | m_teEmu->setKeytrans("vt100.keytab"); |
53 | break; | 53 | break; |
54 | case Profile::Linux: | 54 | case Profile::Linux: |
55 | m_teEmu->setKeytrans("linux.keytab"); | 55 | m_teEmu->setKeytrans("linux.keytab"); |
56 | break; | 56 | break; |
57 | case Profile::XTerm: | 57 | case Profile::XTerm: |
58 | m_teEmu->setKeytrans("default.Keytab"); | 58 | m_teEmu->setKeytrans("default.Keytab"); |
59 | break; | 59 | break; |
60 | } | 60 | } |
61 | } | 61 | } |
62 | void EmulationHandler::recv( const QByteArray& ar) { | 62 | void EmulationHandler::recv( const QByteArray& ar) { |
63 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); | 63 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); |
64 | } | 64 | } |
65 | void EmulationHandler::recvEmulation(const char* src, int len ) { | 65 | void EmulationHandler::recvEmulation(const char* src, int len ) { |
66 | QByteArray ar(len); | 66 | QByteArray ar(len); |
67 | 67 | ||
68 | memcpy(ar.data(), src, sizeof(char) * len ); | 68 | memcpy(ar.data(), src, sizeof(char) * len ); |
69 | if (isRecording()) | 69 | if (isRecording()) |
70 | m_script->append(ar); | 70 | m_script->append(ar); |
71 | emit send(ar); | 71 | emit send(ar); |
72 | } | 72 | } |
73 | QWidget* EmulationHandler::widget() { | 73 | QWidget* EmulationHandler::widget() { |
74 | return m_teWid; | 74 | return m_teWid; |
75 | } | 75 | } |
76 | /* | 76 | /* |
77 | * allocate a new table of colors | 77 | * allocate a new table of colors |
78 | */ | 78 | */ |
79 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { | 79 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { |
80 | ColorEntry table[TABLE_COLORS]; | 80 | ColorEntry table[TABLE_COLORS]; |
81 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); | 81 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); |
82 | 82 | ||
83 | for (int i = 0; i < TABLE_COLORS; i++ ) { | 83 | for (int i = 0; i < TABLE_COLORS; i++ ) { |
84 | if ( i == 0 || i == 10 ) { | 84 | if ( i == 0 || i == 10 ) { |
85 | table[i].color = fore; | 85 | table[i].color = fore; |
86 | }else if ( i == 1 || i == 11 ) { | 86 | }else if ( i == 1 || i == 11 ) { |
87 | table[i].color = back; | 87 | table[i].color = back; |
88 | table[i].transparent = 0; | 88 | table[i].transparent = 0; |
89 | }else { | 89 | }else { |
90 | table[i].color = defaultCt[i].color; | 90 | table[i].color = defaultCt[i].color; |
91 | } | 91 | } |
92 | } | 92 | } |
93 | m_teWid->setColorTable(table ); | 93 | m_teWid->setColorTable(table ); |
94 | m_teWid->update(); | 94 | m_teWid->update(); |
95 | } | 95 | } |
96 | QFont EmulationHandler::font( int id ) { | 96 | QFont EmulationHandler::font( int id ) { |
97 | QString name; | 97 | QString name; |
98 | int size = 0; | 98 | int size = 0; |
99 | switch(id ) { | 99 | switch(id ) { |
100 | default: // fall through | 100 | default: // fall through |
101 | case 0: | 101 | case 0: |
102 | name = QString::fromLatin1("Micro"); | 102 | name = QString::fromLatin1("Micro"); |
103 | size = 4; | 103 | size = 4; |
104 | break; | 104 | break; |
105 | case 1: | 105 | case 1: |
106 | name = QString::fromLatin1("Fixed"); | 106 | name = QString::fromLatin1("Fixed"); |
107 | size = 7; | 107 | size = 7; |
108 | break; | 108 | break; |
109 | case 2: | 109 | case 2: |
110 | name = QString::fromLatin1("Fixed"); | 110 | name = QString::fromLatin1("Fixed"); |
111 | size = 12; | 111 | size = 12; |
112 | break; | 112 | break; |
113 | } | 113 | } |
114 | QFont font(name, size, QFont::Normal ); | 114 | QFont font(name, size, QFont::Normal ); |
115 | font.setFixedPitch(TRUE ); | 115 | font.setFixedPitch(TRUE ); |
116 | return font; | 116 | return font; |
117 | } | 117 | } |
118 | QColor EmulationHandler::foreColor(int col) { | 118 | QColor EmulationHandler::foreColor(int col) { |
119 | QColor co; | 119 | QColor co; |
diff --git a/noncore/apps/opie-console/emulation_layer.cpp b/noncore/apps/opie-console/emulation_layer.cpp index 2bef801..fd30ad7 100644 --- a/noncore/apps/opie-console/emulation_layer.cpp +++ b/noncore/apps/opie-console/emulation_layer.cpp | |||
@@ -13,204 +13,204 @@ | |||
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | /* */ | 18 | /* */ |
19 | /* Modified to suit opie-console */ | 19 | /* Modified to suit opie-console */ |
20 | /* */ | 20 | /* */ |
21 | /* Copyright (C) 2002 by opie developers <opie@handhelds.org> */ | 21 | /* Copyright (C) 2002 by opie developers <opie@handhelds.org> */ |
22 | /* */ | 22 | /* */ |
23 | /* -------------------------------------------------------------------------- */ | 23 | /* -------------------------------------------------------------------------- */ |
24 | 24 | ||
25 | /*! \class EmulationLayer | 25 | /*! \class EmulationLayer |
26 | 26 | ||
27 | \brief Mediator between Widget and Screen. | 27 | \brief Mediator between Widget and Screen. |
28 | 28 | ||
29 | This class is responsible to scan the escapes sequences of the terminal | 29 | This class is responsible to scan the escapes sequences of the terminal |
30 | emulation and to map it to their corresponding semantic complements. | 30 | emulation and to map it to their corresponding semantic complements. |
31 | Thus this module knows mainly about decoding escapes sequences and | 31 | Thus this module knows mainly about decoding escapes sequences and |
32 | is a stateless device w.r.t. the semantics. | 32 | is a stateless device w.r.t. the semantics. |
33 | 33 | ||
34 | It is also responsible to refresh the Widget by certain rules. | 34 | It is also responsible to refresh the Widget by certain rules. |
35 | 35 | ||
36 | \sa Widget \sa Screen | 36 | \sa Widget \sa Screen |
37 | 37 | ||
38 | \par A note on refreshing | 38 | \par A note on refreshing |
39 | 39 | ||
40 | Although the modifications to the current screen image could immediately | 40 | Although the modifications to the current screen image could immediately |
41 | be propagated via `Widget' to the graphical surface, we have chosen | 41 | be propagated via `Widget' to the graphical surface, we have chosen |
42 | another way here. | 42 | another way here. |
43 | 43 | ||
44 | The reason for doing so is twofold. | 44 | The reason for doing so is twofold. |
45 | 45 | ||
46 | First, experiments show that directly displaying the operation results | 46 | First, experiments show that directly displaying the operation results |
47 | in slowing down the overall performance of emulations. Displaying | 47 | in slowing down the overall performance of emulations. Displaying |
48 | individual characters using X11 creates a lot of overhead. | 48 | individual characters using X11 creates a lot of overhead. |
49 | 49 | ||
50 | Second, by using the following refreshing method, the screen operations | 50 | Second, by using the following refreshing method, the screen operations |
51 | can be completely separated from the displaying. This greatly simplifies | 51 | can be completely separated from the displaying. This greatly simplifies |
52 | the programmer's task of coding and maintaining the screen operations, | 52 | the programmer's task of coding and maintaining the screen operations, |
53 | since one need not worry about differential modifications on the | 53 | since one need not worry about differential modifications on the |
54 | display affecting the operation of concern. | 54 | display affecting the operation of concern. |
55 | 55 | ||
56 | We use a refreshing algorithm here that has been adoped from rxvt/kvt. | 56 | We use a refreshing algorithm here that has been adoped from rxvt/kvt. |
57 | 57 | ||
58 | By this, refreshing is driven by a timer, which is (re)started whenever | 58 | By this, refreshing is driven by a timer, which is (re)started whenever |
59 | a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'. | 59 | a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'. |
60 | As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger | 60 | As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger |
61 | refresh. This rule suits both bulk display operation as done by curses as | 61 | refresh. This rule suits both bulk display operation as done by curses as |
62 | well as individual characters typed. | 62 | well as individual characters typed. |
63 | (BULK_TIMEOUT < 1000 / max characters received from keyboard per second). | 63 | (BULK_TIMEOUT < 1000 / max characters received from keyboard per second). |
64 | 64 | ||
65 | Additionally, we trigger refreshing by newlines comming in to make visual | 65 | Additionally, we trigger refreshing by newlines comming in to make visual |
66 | snapshots of lists as produced by `cat', `ls' and likely programs, thereby | 66 | snapshots of lists as produced by `cat', `ls' and likely programs, thereby |
67 | producing the illusion of a permanent and immediate display operation. | 67 | producing the illusion of a permanent and immediate display operation. |
68 | 68 | ||
69 | As a sort of catch-all needed for cases where none of the above | 69 | As a sort of catch-all needed for cases where none of the above |
70 | conditions catch, the screen refresh is also triggered by a count | 70 | conditions catch, the screen refresh is also triggered by a count |
71 | of incoming bulks (`bulk_incnt'). | 71 | of incoming bulks (`bulk_incnt'). |
72 | */ | 72 | */ |
73 | 73 | ||
74 | /* FIXME | 74 | /* FIXME |
75 | - evtl. the bulk operations could be made more transparent. | 75 | - evtl. the bulk operations could be made more transparent. |
76 | */ | 76 | */ |
77 | 77 | ||
78 | #include "emulation_layer.h" | 78 | #include "emulation_layer.h" |
79 | #include <stdio.h> | 79 | #include <stdio.h> |
80 | #include <stdlib.h> | 80 | #include <stdlib.h> |
81 | #include <unistd.h> | 81 | #include <unistd.h> |
82 | 82 | ||
83 | 83 | ||
84 | /* ------------------------------------------------------------------------- */ | 84 | /* ------------------------------------------------------------------------- */ |
85 | /* */ | 85 | /* */ |
86 | /* EmulationLayer */ | 86 | /* EmulationLayer */ |
87 | /* */ | 87 | /* */ |
88 | /* ------------------------------------------------------------------------- */ | 88 | /* ------------------------------------------------------------------------- */ |
89 | 89 | ||
90 | #define CNTL(c) ((c)-'@') | 90 | #define CNTL(c) ((c)-'@') |
91 | 91 | ||
92 | /*! | 92 | /*! |
93 | */ | 93 | */ |
94 | 94 | ||
95 | EmulationLayer::EmulationLayer( WidgetLayer* gui ) | 95 | EmulationLayer::EmulationLayer( WidgetLayer* gui ) |
96 | : decoder((QTextDecoder*)NULL) | 96 | : decoder((QTextDecoder*)NULL) |
97 | { | 97 | { |
98 | this->gui = gui; | 98 | this->gui = gui; |
99 | 99 | ||
100 | screen[0] = new Screen(gui->lines(),gui->columns()); | 100 | screen[0] = new Screen(gui->lines(),gui->columns()); |
101 | screen[1] = new Screen(gui->lines(),gui->columns()); | 101 | screen[1] = new Screen(gui->lines(),gui->columns()); |
102 | scr = screen[0]; | 102 | scr = screen[0]; |
103 | 103 | ||
104 | bulk_nlcnt = 0; // reset bulk newline counter | 104 | bulk_nlcnt = 0; // reset bulk newline counter |
105 | bulk_incnt = 0; // reset bulk counter | 105 | bulk_incnt = 0; // reset bulk counter |
106 | connected = FALSE; | 106 | connected = FALSE; |
107 | 107 | ||
108 | QObject::connect(&bulk_timer, SIGNAL( timeout() ), this, SLOT( showBulk() ) ); | 108 | QObject::connect(&bulk_timer, SIGNAL( timeout() ), this, SLOT( showBulk() ) ); |
109 | QObject::connect(gui,SIGNAL( imageSizeChanged( int, int ) ), | 109 | QObject::connect(gui,SIGNAL( imageSizeChanged(int,int) ), |
110 | this,SLOT( onImageSizeChange( int, int ) ) ); | 110 | this,SLOT( onImageSizeChange(int,int) ) ); |
111 | QObject::connect(gui,SIGNAL( changedHistoryCursor( int ) ), | 111 | QObject::connect(gui,SIGNAL( changedHistoryCursor(int) ), |
112 | this,SLOT( historyCursorChange( int ) ) ); | 112 | this,SLOT( historyCursorChange(int) ) ); |
113 | QObject::connect(gui,SIGNAL( keyPressed( QKeyEvent* ) ), | 113 | QObject::connect(gui,SIGNAL( keyPressed(QKeyEvent*) ), |
114 | this,SLOT( onKeyPress( QKeyEvent* ) ) ); | 114 | this,SLOT( onKeyPress(QKeyEvent*) ) ); |
115 | QObject::connect(gui,SIGNAL( selectionBegin( const int, const int) ), | 115 | QObject::connect(gui,SIGNAL( selectionBegin(const int,const int) ), |
116 | this,SLOT( onSelectionBegin( const int, const int ) ) ); | 116 | this,SLOT( onSelectionBegin(const int,const int) ) ); |
117 | QObject::connect(gui,SIGNAL( selectionExtended( const int, const int ) ), | 117 | QObject::connect(gui,SIGNAL( selectionExtended(const int,const int) ), |
118 | this,SLOT( onSelectionExtend( const int,const int ) ) ); | 118 | this,SLOT( onSelectionExtend(const int,const int) ) ); |
119 | QObject::connect(gui,SIGNAL( selectionEnd( const bool ) ), | 119 | QObject::connect(gui,SIGNAL( selectionEnd(const bool) ), |
120 | this,SLOT( setSelection( const bool ) ) ); | 120 | this,SLOT( setSelection(const bool) ) ); |
121 | QObject::connect(gui,SIGNAL( selectionCleared() ), | 121 | QObject::connect(gui,SIGNAL( selectionCleared() ), |
122 | this,SLOT( clearSelection() ) ); | 122 | this,SLOT( clearSelection() ) ); |
123 | } | 123 | } |
124 | 124 | ||
125 | /*! | 125 | /*! |
126 | */ | 126 | */ |
127 | 127 | ||
128 | EmulationLayer::~EmulationLayer() | 128 | EmulationLayer::~EmulationLayer() |
129 | { | 129 | { |
130 | delete screen[0]; | 130 | delete screen[0]; |
131 | delete screen[1]; | 131 | delete screen[1]; |
132 | bulk_timer.stop(); | 132 | bulk_timer.stop(); |
133 | } | 133 | } |
134 | 134 | ||
135 | /*! change between primary and alternate screen | 135 | /*! change between primary and alternate screen |
136 | */ | 136 | */ |
137 | 137 | ||
138 | void EmulationLayer::setScreen(int n) | 138 | void EmulationLayer::setScreen(int n) |
139 | { | 139 | { |
140 | scr = screen[n&1]; | 140 | scr = screen[n&1]; |
141 | } | 141 | } |
142 | 142 | ||
143 | void EmulationLayer::setHistory(bool on) | 143 | void EmulationLayer::setHistory(bool on) |
144 | { | 144 | { |
145 | screen[0]->setScroll(on); | 145 | screen[0]->setScroll(on); |
146 | if (!connected) return; | 146 | if (!connected) return; |
147 | showBulk(); | 147 | showBulk(); |
148 | } | 148 | } |
149 | 149 | ||
150 | bool EmulationLayer::history() | 150 | bool EmulationLayer::history() |
151 | { | 151 | { |
152 | return screen[0]->hasScroll(); | 152 | return screen[0]->hasScroll(); |
153 | } | 153 | } |
154 | 154 | ||
155 | void EmulationLayer::setCodec(int c) | 155 | void EmulationLayer::setCodec(int c) |
156 | { | 156 | { |
157 | //FIXME: check whether we have to free codec | 157 | //FIXME: check whether we have to free codec |
158 | codec = c ? QTextCodec::codecForName("utf8") | 158 | codec = c ? QTextCodec::codecForName("utf8") |
159 | : QTextCodec::codecForLocale(); | 159 | : QTextCodec::codecForLocale(); |
160 | if (decoder) delete decoder; | 160 | if (decoder) delete decoder; |
161 | decoder = codec->makeDecoder(); | 161 | decoder = codec->makeDecoder(); |
162 | } | 162 | } |
163 | 163 | ||
164 | void EmulationLayer::setKeytrans(int no) | 164 | void EmulationLayer::setKeytrans(int no) |
165 | { | 165 | { |
166 | keytrans = KeyTrans::find(no); | 166 | keytrans = KeyTrans::find(no); |
167 | } | 167 | } |
168 | 168 | ||
169 | void EmulationLayer::setKeytrans(const char * no) | 169 | void EmulationLayer::setKeytrans(const char * no) |
170 | { | 170 | { |
171 | keytrans = KeyTrans::find(no); | 171 | keytrans = KeyTrans::find(no); |
172 | } | 172 | } |
173 | 173 | ||
174 | // Interpreting Codes --------------------------------------------------------- | 174 | // Interpreting Codes --------------------------------------------------------- |
175 | 175 | ||
176 | /* | 176 | /* |
177 | This section deals with decoding the incoming character stream. | 177 | This section deals with decoding the incoming character stream. |
178 | Decoding means here, that the stream is first seperated into `tokens' | 178 | Decoding means here, that the stream is first seperated into `tokens' |
179 | which are then mapped to a `meaning' provided as operations by the | 179 | which are then mapped to a `meaning' provided as operations by the |
180 | `Screen' class. | 180 | `Screen' class. |
181 | */ | 181 | */ |
182 | 182 | ||
183 | /*! | 183 | /*! |
184 | */ | 184 | */ |
185 | 185 | ||
186 | void EmulationLayer::onRcvChar(int c) | 186 | void EmulationLayer::onRcvChar(int c) |
187 | // process application unicode input to terminal | 187 | // process application unicode input to terminal |
188 | // this is a trivial scanner | 188 | // this is a trivial scanner |
189 | { | 189 | { |
190 | c &= 0xff; | 190 | c &= 0xff; |
191 | switch (c) | 191 | switch (c) |
192 | { | 192 | { |
193 | case '\b' : scr->BackSpace(); break; | 193 | case '\b' : scr->BackSpace(); break; |
194 | case '\t' : scr->Tabulate(); break; | 194 | case '\t' : scr->Tabulate(); break; |
195 | case '\n' : scr->NewLine(); break; | 195 | case '\n' : scr->NewLine(); break; |
196 | case '\r' : scr->Return(); break; | 196 | case '\r' : scr->Return(); break; |
197 | case 0x07 : gui->bell(); break; | 197 | case 0x07 : gui->bell(); break; |
198 | default : scr->ShowCharacter(c); break; | 198 | default : scr->ShowCharacter(c); break; |
199 | }; | 199 | }; |
200 | } | 200 | } |
201 | 201 | ||
202 | /* ------------------------------------------------------------------------- */ | 202 | /* ------------------------------------------------------------------------- */ |
203 | /* */ | 203 | /* */ |
204 | /* Keyboard Handling */ | 204 | /* Keyboard Handling */ |
205 | /* */ | 205 | /* */ |
206 | /* ------------------------------------------------------------------------- */ | 206 | /* ------------------------------------------------------------------------- */ |
207 | 207 | ||
208 | /*! | 208 | /*! |
209 | */ | 209 | */ |
210 | 210 | ||
211 | void EmulationLayer::onKeyPress( QKeyEvent* ev ) | 211 | void EmulationLayer::onKeyPress( QKeyEvent* ev ) |
212 | { | 212 | { |
213 | if (!connected) return; // someone else gets the keys | 213 | if (!connected) return; // someone else gets the keys |
214 | if (scr->getHistCursor() != scr->getHistLines()); | 214 | if (scr->getHistCursor() != scr->getHistLines()); |
215 | scr->setHistCursor(scr->getHistLines()); | 215 | scr->setHistCursor(scr->getHistLines()); |
216 | if (!ev->text().isEmpty()) | 216 | if (!ev->text().isEmpty()) |
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index c232d89..eb32551 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp | |||
@@ -167,231 +167,231 @@ void FunctionKeyboard::paintKey(uint row, uint col) { | |||
167 | 167 | ||
168 | // sometimes it doesnt draw the last line | 168 | // sometimes it doesnt draw the last line |
169 | 169 | ||
170 | p.drawLine((col+1) * keyWidth -1, row * keyHeight, | 170 | p.drawLine((col+1) * keyWidth -1, row * keyHeight, |
171 | (col+1) * keyWidth -1, (row + 1) * keyHeight | 171 | (col+1) * keyWidth -1, (row + 1) * keyHeight |
172 | ); | 172 | ); |
173 | } | 173 | } |
174 | 174 | ||
175 | } | 175 | } |
176 | 176 | ||
177 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { | 177 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { |
178 | 178 | ||
179 | pressedRow = e->y() / keyHeight; | 179 | pressedRow = e->y() / keyHeight; |
180 | pressedCol = (int) (e->x() / keyWidth); | 180 | pressedCol = (int) (e->x() / keyWidth); |
181 | 181 | ||
182 | paintKey(pressedRow, pressedCol); | 182 | paintKey(pressedRow, pressedCol); |
183 | 183 | ||
184 | // emit that sucker! | 184 | // emit that sucker! |
185 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; | 185 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; |
186 | emit keyPressed(k, pressedRow, pressedCol, 1); | 186 | emit keyPressed(k, pressedRow, pressedCol, 1); |
187 | 187 | ||
188 | } | 188 | } |
189 | 189 | ||
190 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { | 190 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { |
191 | 191 | ||
192 | if (pressedRow != -1 && pressedRow != -1) { | 192 | if (pressedRow != -1 && pressedRow != -1) { |
193 | 193 | ||
194 | int row = pressedRow; pressedRow = -1; | 194 | int row = pressedRow; pressedRow = -1; |
195 | int col = pressedCol; pressedCol = -1; | 195 | int col = pressedCol; pressedCol = -1; |
196 | paintKey(row, col); | 196 | paintKey(row, col); |
197 | 197 | ||
198 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; | 198 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; |
199 | emit keyPressed(k, row, col, 0); | 199 | emit keyPressed(k, row, col, 0); |
200 | } | 200 | } |
201 | 201 | ||
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { | 205 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { |
206 | 206 | ||
207 | /* set he default font height/width */ | 207 | /* set he default font height/width */ |
208 | QFontMetrics fm=fontMetrics(); | 208 | QFontMetrics fm=fontMetrics(); |
209 | keyHeight = fm.lineSpacing() + 2; | 209 | keyHeight = fm.lineSpacing() + 2; |
210 | keyWidth = (double)width()/numCols; | 210 | keyWidth = (double)width()/numCols; |
211 | 211 | ||
212 | } | 212 | } |
213 | 213 | ||
214 | QSize FunctionKeyboard::sizeHint() const { | 214 | QSize FunctionKeyboard::sizeHint() const { |
215 | 215 | ||
216 | return QSize(width(), keyHeight * numRows + 1); | 216 | return QSize(width(), keyHeight * numRows + 1); |
217 | } | 217 | } |
218 | 218 | ||
219 | void FunctionKeyboard::loadDefaults() { | 219 | void FunctionKeyboard::loadDefaults() { |
220 | 220 | ||
221 | numRows = DEFAULT_ROWS; | 221 | numRows = DEFAULT_ROWS; |
222 | numCols = DEFAULT_COLS; | 222 | numCols = DEFAULT_COLS; |
223 | keyWidth = (double)width()/numCols; // have to reset this thing too | 223 | keyWidth = (double)width()/numCols; // have to reset this thing too |
224 | 224 | ||
225 | keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); | 225 | keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); |
226 | keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); | 226 | keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); |
227 | keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); | 227 | keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); |
228 | keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); | 228 | keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); |
229 | keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); | 229 | keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); |
230 | 230 | ||
231 | keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0)); | 231 | keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0)); |
232 | keys.insert( "r0c8", FKey ("End", 0, 4113, 0)); | 232 | keys.insert( "r0c8", FKey ("End", 0, 4113, 0)); |
233 | keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0)); | 233 | keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0)); |
234 | keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0)); | 234 | keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0)); |
235 | keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff)); | 235 | keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff)); |
236 | 236 | ||
237 | keys.insert( "r1c0", FKey ("F1", 0, 4144, 0)); | 237 | keys.insert( "r1c0", FKey ("F1", 0, 4144, 0)); |
238 | keys.insert( "r1c1", FKey ("F2", 0, 4145, 0)); | 238 | keys.insert( "r1c1", FKey ("F2", 0, 4145, 0)); |
239 | keys.insert( "r1c2", FKey ("F3", 0, 4146, 0)); | 239 | keys.insert( "r1c2", FKey ("F3", 0, 4146, 0)); |
240 | keys.insert( "r1c3", FKey ("F4", 0, 4147, 0)); | 240 | keys.insert( "r1c3", FKey ("F4", 0, 4147, 0)); |
241 | keys.insert( "r1c4", FKey ("F5", 0, 4148, 0)); | 241 | keys.insert( "r1c4", FKey ("F5", 0, 4148, 0)); |
242 | keys.insert( "r1c5", FKey ("F6", 0, 4149, 0)); | 242 | keys.insert( "r1c5", FKey ("F6", 0, 4149, 0)); |
243 | keys.insert( "r1c6", FKey ("F7", 0, 4150, 0)); | 243 | keys.insert( "r1c6", FKey ("F7", 0, 4150, 0)); |
244 | keys.insert( "r1c7", FKey ("F8", 0, 4151, 0)); | 244 | keys.insert( "r1c7", FKey ("F8", 0, 4151, 0)); |
245 | keys.insert( "r1c8", FKey ("F9", 0, 4152, 0)); | 245 | keys.insert( "r1c8", FKey ("F9", 0, 4152, 0)); |
246 | keys.insert( "r1c9", FKey ("F10", 0, 4153, 0)); | 246 | keys.insert( "r1c9", FKey ("F10", 0, 4153, 0)); |
247 | keys.insert( "r1c10", FKey ("F11", 0, 4154, 0)); | 247 | keys.insert( "r1c10", FKey ("F11", 0, 4154, 0)); |
248 | keys.insert( "r1c11", FKey ("F12", 0, 4155, 0)); | 248 | keys.insert( "r1c11", FKey ("F12", 0, 4155, 0)); |
249 | 249 | ||
250 | 250 | ||
251 | } | 251 | } |
252 | 252 | ||
253 | /* FunctionKeyboardConfig {{{1 */ | 253 | /* FunctionKeyboardConfig {{{1 */ |
254 | 254 | ||
255 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) | 255 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) |
256 | : ProfileDialogKeyWidget(name, parent, na), | 256 | : ProfileDialogKeyWidget(name, parent, na), |
257 | selectedRow(0), selectedCol(0) | 257 | selectedRow(0), selectedCol(0) |
258 | { | 258 | { |
259 | qWarning("FunctionKeyboardConfig"); | 259 | qWarning("FunctionKeyboardConfig"); |
260 | 260 | ||
261 | 261 | ||
262 | kb = new FunctionKeyboard(this); | 262 | kb = new FunctionKeyboard(this); |
263 | connect (kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 263 | connect (kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), |
264 | this, SLOT(slotKeyPressed(FKey, ushort, ushort, bool))); | 264 | this, SLOT(slotKeyPressed(FKey,ushort,ushort,bool))); |
265 | 265 | ||
266 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this); | 266 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this); |
267 | QLabel *l = new QLabel("Rows", dimentions); | 267 | QLabel *l = new QLabel("Rows", dimentions); |
268 | m_rowBox = new QSpinBox(1, 15, 1, dimentions); | 268 | m_rowBox = new QSpinBox(1, 15, 1, dimentions); |
269 | connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); | 269 | connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); |
270 | l = new QLabel("Columns", dimentions); | 270 | l = new QLabel("Columns", dimentions); |
271 | m_colBox = new QSpinBox(1, 15, 1, dimentions); | 271 | m_colBox = new QSpinBox(1, 15, 1, dimentions); |
272 | connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); | 272 | connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); |
273 | 273 | ||
274 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); | 274 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); |
275 | l = new QLabel("Label", editKey); | 275 | l = new QLabel("Label", editKey); |
276 | m_labels = new QComboBox(true, editKey); | 276 | m_labels = new QComboBox(true, editKey); |
277 | m_labels->setInsertionPolicy(QComboBox::AtCurrent); | 277 | m_labels->setInsertionPolicy(QComboBox::AtCurrent); |
278 | m_labels->insertItem(""); | 278 | m_labels->insertItem(""); |
279 | 279 | ||
280 | QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); | 280 | QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); |
281 | 281 | ||
282 | for (uint i = 0; i < files.count(); i++) { | 282 | for (uint i = 0; i < files.count(); i++) { |
283 | 283 | ||
284 | m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]); | 284 | m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]); |
285 | } | 285 | } |
286 | connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); | 286 | connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); |
287 | connect (m_labels, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeLabelText(const QString&))); | 287 | connect (m_labels, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeLabelText(const QString&))); |
288 | 288 | ||
289 | l = new QLabel("Q Keycode", editKey); | 289 | l = new QLabel("Q Keycode", editKey); |
290 | m_qvalues = new QComboBox(true, editKey); | 290 | m_qvalues = new QComboBox(true, editKey); |
291 | m_qvalues->setInsertionPolicy(QComboBox::AtTop); | 291 | m_qvalues->setInsertionPolicy(QComboBox::AtTop); |
292 | m_qvalues->setDuplicatesEnabled(false); | 292 | m_qvalues->setDuplicatesEnabled(false); |
293 | m_qvalues->insertItem(""); | 293 | m_qvalues->insertItem(""); |
294 | connect (m_qvalues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeQCode(const QString&))); | 294 | connect (m_qvalues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeQCode(const QString&))); |
295 | 295 | ||
296 | l = new QLabel("Unicode Value", editKey); | 296 | l = new QLabel("Unicode Value", editKey); |
297 | m_uniValues = new QComboBox(true, editKey); | 297 | m_uniValues = new QComboBox(true, editKey); |
298 | m_uniValues->setInsertionPolicy(QComboBox::AtTop); | 298 | m_uniValues->setInsertionPolicy(QComboBox::AtTop); |
299 | m_uniValues->setDuplicatesEnabled(false); | 299 | m_uniValues->setDuplicatesEnabled(false); |
300 | m_uniValues->insertItem(""); | 300 | m_uniValues->insertItem(""); |
301 | connect (m_uniValues, SIGNAL(textChanged(const QString &)), this, SLOT(slotChangeUnicode(const QString&))); | 301 | connect (m_uniValues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeUnicode(const QString&))); |
302 | 302 | ||
303 | QVBoxLayout *root = new QVBoxLayout(this, 2); | 303 | QVBoxLayout *root = new QVBoxLayout(this, 2); |
304 | root->addWidget(kb); | 304 | root->addWidget(kb); |
305 | root->addWidget(dimentions); | 305 | root->addWidget(dimentions); |
306 | root->addWidget(editKey); | 306 | root->addWidget(editKey); |
307 | } | 307 | } |
308 | FunctionKeyboardConfig::~FunctionKeyboardConfig() { | 308 | FunctionKeyboardConfig::~FunctionKeyboardConfig() { |
309 | 309 | ||
310 | } | 310 | } |
311 | void FunctionKeyboardConfig::load (const Profile& prof) { | 311 | void FunctionKeyboardConfig::load (const Profile& prof) { |
312 | 312 | ||
313 | kb->keys.clear(); | 313 | kb->keys.clear(); |
314 | kb->loadDefaults(); | 314 | kb->loadDefaults(); |
315 | 315 | ||
316 | m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); | 316 | m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); |
317 | m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); | 317 | m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); |
318 | 318 | ||
319 | /* load all the keys to the keyboard */ | 319 | /* load all the keys to the keyboard */ |
320 | for (int i = 0; i <= m_rowBox->value() -1; i++) | 320 | for (int i = 0; i <= m_rowBox->value() -1; i++) |
321 | for (int j = 0; j <= m_colBox->value() -1; j++) { | 321 | for (int j = 0; j <= m_colBox->value() -1; j++) { |
322 | 322 | ||
323 | QString h = "r" + QString::number(i) + "c" + QString::number(j); | 323 | QString h = "r" + QString::number(i) + "c" + QString::number(j); |
324 | QString values = prof.readEntry("keb_" + h); | 324 | QString values = prof.readEntry("keb_" + h); |
325 | 325 | ||
326 | if (!values.isEmpty()) { | 326 | if (!values.isEmpty()) { |
327 | 327 | ||
328 | QStringList l = QStringList::split(QChar('|'), values, TRUE); | 328 | QStringList l = QStringList::split(QChar('|'), values, TRUE); |
329 | kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); | 329 | kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); |
330 | 330 | ||
331 | // load pixmap if used | 331 | // load pixmap if used |
332 | if (!l[1].isEmpty()) { | 332 | if (!l[1].isEmpty()) { |
333 | 333 | ||
334 | kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); | 334 | kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); |
335 | } | 335 | } |
336 | } | 336 | } |
337 | } | 337 | } |
338 | 338 | ||
339 | } | 339 | } |
340 | void FunctionKeyboardConfig::save (Profile& prof) { | 340 | void FunctionKeyboardConfig::save (Profile& prof) { |
341 | 341 | ||
342 | prof.writeEntry("keb_rows", m_rowBox->value()); | 342 | prof.writeEntry("keb_rows", m_rowBox->value()); |
343 | prof.writeEntry("keb_cols", m_colBox->value()); | 343 | prof.writeEntry("keb_cols", m_colBox->value()); |
344 | 344 | ||
345 | QMap<QString, FKey>::Iterator it; | 345 | QMap<QString, FKey>::Iterator it; |
346 | for ( it = kb->keys.begin(); it != kb->keys.end(); it++) { | 346 | for ( it = kb->keys.begin(); it != kb->keys.end(); it++) { |
347 | 347 | ||
348 | FKey k = it.data(); | 348 | FKey k = it.data(); |
349 | QString entry = k.label + "|" | 349 | QString entry = k.label + "|" |
350 | + k.pixFile + "|" | 350 | + k.pixFile + "|" |
351 | + QString::number(k.qcode) + "|" | 351 | + QString::number(k.qcode) + "|" |
352 | + QString::number(k.unicode); | 352 | + QString::number(k.unicode); |
353 | 353 | ||
354 | prof.writeEntry("keb_" + it.key(), entry); | 354 | prof.writeEntry("keb_" + it.key(), entry); |
355 | 355 | ||
356 | } | 356 | } |
357 | 357 | ||
358 | } | 358 | } |
359 | void FunctionKeyboardConfig::slotChangeRows(int r) { | 359 | void FunctionKeyboardConfig::slotChangeRows(int r) { |
360 | 360 | ||
361 | kb->changeRows(r); | 361 | kb->changeRows(r); |
362 | 362 | ||
363 | } | 363 | } |
364 | void FunctionKeyboardConfig::slotChangeCols(int c) { | 364 | void FunctionKeyboardConfig::slotChangeCols(int c) { |
365 | 365 | ||
366 | kb->changeCols(c); | 366 | kb->changeCols(c); |
367 | } | 367 | } |
368 | void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { | 368 | void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { |
369 | 369 | ||
370 | if (!pressed) return; | 370 | if (!pressed) return; |
371 | 371 | ||
372 | selectedHandle = "r" + QString::number(r) + | 372 | selectedHandle = "r" + QString::number(r) + |
373 | "c" + QString::number(c); | 373 | "c" + QString::number(c); |
374 | selectedRow = r; | 374 | selectedRow = r; |
375 | selectedCol = c; | 375 | selectedCol = c; |
376 | 376 | ||
377 | if (k.pixFile.isEmpty()) { | 377 | if (k.pixFile.isEmpty()) { |
378 | 378 | ||
379 | m_labels->setEditable(true); | 379 | m_labels->setEditable(true); |
380 | m_labels->setCurrentItem(0); | 380 | m_labels->setCurrentItem(0); |
381 | m_labels->changeItem(k.label, 0); | 381 | m_labels->changeItem(k.label, 0); |
382 | 382 | ||
383 | } else { | 383 | } else { |
384 | 384 | ||
385 | // any better way to select the pixmap? | 385 | // any better way to select the pixmap? |
386 | m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile))); | 386 | m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile))); |
387 | m_labels->setEditable(false); | 387 | m_labels->setEditable(false); |
388 | } | 388 | } |
389 | m_qvalues->changeItem(QString::number(k.qcode), 0); | 389 | m_qvalues->changeItem(QString::number(k.qcode), 0); |
390 | m_uniValues->changeItem(QString::number(k.unicode), 0); | 390 | m_uniValues->changeItem(QString::number(k.unicode), 0); |
391 | } | 391 | } |
392 | void FunctionKeyboardConfig::slotChangeIcon(int index) { | 392 | void FunctionKeyboardConfig::slotChangeIcon(int index) { |
393 | 393 | ||
394 | if (index == 0) { | 394 | if (index == 0) { |
395 | 395 | ||
396 | // is text | 396 | // is text |
397 | m_labels->setEditable(true); | 397 | m_labels->setEditable(true); |
diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp index 37bf797..1a8c979 100644 --- a/noncore/apps/opie-console/io_bt.cpp +++ b/noncore/apps/opie-console/io_bt.cpp | |||
@@ -1,92 +1,92 @@ | |||
1 | 1 | ||
2 | #include "io_bt.h" | 2 | #include "io_bt.h" |
3 | 3 | ||
4 | IOBt::IOBt( const Profile &config ) : IOSerial( config ) { | 4 | IOBt::IOBt( const Profile &config ) : IOSerial( config ) { |
5 | m_attach = 0; | 5 | m_attach = 0; |
6 | } | 6 | } |
7 | 7 | ||
8 | 8 | ||
9 | IOBt::~IOBt() { | 9 | IOBt::~IOBt() { |
10 | if ( m_attach ) { | 10 | if ( m_attach ) { |
11 | delete m_attach; | 11 | delete m_attach; |
12 | } | 12 | } |
13 | } | 13 | } |
14 | 14 | ||
15 | 15 | ||
16 | void IOBt::close() { | 16 | void IOBt::close() { |
17 | 17 | ||
18 | IOSerial::close(); | 18 | IOSerial::close(); |
19 | // still need error handling | 19 | // still need error handling |
20 | if ( m_attach ) { | 20 | if ( m_attach ) { |
21 | delete m_attach; | 21 | delete m_attach; |
22 | m_attach = 0; | 22 | m_attach = 0; |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | bool IOBt::open() { | 26 | bool IOBt::open() { |
27 | bool ret = false; | 27 | bool ret = false; |
28 | 28 | ||
29 | // only set up bt stuff if mac address was set, otherwise use the device set | 29 | // only set up bt stuff if mac address was set, otherwise use the device set |
30 | if ( !m_mac.isEmpty() ) { | 30 | if ( !m_mac.isEmpty() ) { |
31 | 31 | ||
32 | // now it should also be checked, if there is a connection to the device with that mac allready | 32 | // now it should also be checked, if there is a connection to the device with that mac allready |
33 | // hciattach here | 33 | // hciattach here |
34 | m_attach = new OProcess(); | 34 | m_attach = new OProcess(); |
35 | *m_attach << "hciattach /dev/ttyS2 any 57600"; | 35 | *m_attach << "hciattach /dev/ttyS2 any 57600"; |
36 | 36 | ||
37 | // then start hcid, then rcfomm handling (m_mac) | 37 | // then start hcid, then rcfomm handling (m_mac) |
38 | 38 | ||
39 | connect( m_attach, SIGNAL( processExited( OProcess* ) ), | 39 | connect( m_attach, SIGNAL( processExited(OProcess*) ), |
40 | this, SLOT( slotExited( OProcess* ) ) ); | 40 | this, SLOT( slotExited(OProcess*) ) ); |
41 | 41 | ||
42 | if ( m_attach->start() ) { | 42 | if ( m_attach->start() ) { |
43 | ret = IOSerial::open(); | 43 | ret = IOSerial::open(); |
44 | } else { | 44 | } else { |
45 | qWarning("could not attach to device"); | 45 | qWarning("could not attach to device"); |
46 | delete m_attach; | 46 | delete m_attach; |
47 | m_attach = 0; | 47 | m_attach = 0; |
48 | } | 48 | } |
49 | } else { | 49 | } else { |
50 | // directly to the normal serial | 50 | // directly to the normal serial |
51 | // TODO: look first if the connection really exists. ( is set up ) | 51 | // TODO: look first if the connection really exists. ( is set up ) |
52 | 52 | ||
53 | ret =IOSerial::open(); | 53 | ret =IOSerial::open(); |
54 | } | 54 | } |
55 | return ret; | 55 | return ret; |
56 | } | 56 | } |
57 | 57 | ||
58 | void IOBt::reload( const Profile &config ) { | 58 | void IOBt::reload( const Profile &config ) { |
59 | m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); | 59 | m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); |
60 | m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); | 60 | m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); |
61 | m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); | 61 | m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); |
62 | m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); | 62 | m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); |
63 | m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); | 63 | m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); |
64 | m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); | 64 | m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); |
65 | m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); | 65 | m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | QString IOBt::identifier() const { | 69 | QString IOBt::identifier() const { |
70 | return "bluetooth"; | 70 | return "bluetooth"; |
71 | } | 71 | } |
72 | 72 | ||
73 | QString IOBt::name() const { | 73 | QString IOBt::name() const { |
74 | return "BLuetooth IO Layer"; | 74 | return "BLuetooth IO Layer"; |
75 | } | 75 | } |
76 | 76 | ||
77 | void IOBt::slotExited( OProcess* proc ){ | 77 | void IOBt::slotExited( OProcess* proc ){ |
78 | close(); | 78 | close(); |
79 | delete proc; | 79 | delete proc; |
80 | } | 80 | } |
81 | 81 | ||
82 | QBitArray IOBt::supports() const { | 82 | QBitArray IOBt::supports() const { |
83 | return QBitArray( 3 ); | 83 | return QBitArray( 3 ); |
84 | } | 84 | } |
85 | 85 | ||
86 | bool IOBt::isConnected() { | 86 | bool IOBt::isConnected() { |
87 | return false; | 87 | return false; |
88 | } | 88 | } |
89 | 89 | ||
90 | void IOBt::send(const QByteArray &data) { | 90 | void IOBt::send(const QByteArray &data) { |
91 | qDebug( "Please overload me..." ); | 91 | qDebug( "Please overload me..." ); |
92 | } | 92 | } |
diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp index e360fb4..b281b7d 100644 --- a/noncore/apps/opie-console/io_irda.cpp +++ b/noncore/apps/opie-console/io_irda.cpp | |||
@@ -1,77 +1,77 @@ | |||
1 | 1 | ||
2 | #include "io_irda.h" | 2 | #include "io_irda.h" |
3 | 3 | ||
4 | IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { | 4 | IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { |
5 | m_attach = 0; | 5 | m_attach = 0; |
6 | } | 6 | } |
7 | 7 | ||
8 | 8 | ||
9 | IOIrda::~IOIrda() { | 9 | IOIrda::~IOIrda() { |
10 | if ( m_attach ) { | 10 | if ( m_attach ) { |
11 | delete m_attach; | 11 | delete m_attach; |
12 | } | 12 | } |
13 | } | 13 | } |
14 | 14 | ||
15 | 15 | ||
16 | void IOIrda::close() { | 16 | void IOIrda::close() { |
17 | 17 | ||
18 | IOSerial::close(); | 18 | IOSerial::close(); |
19 | // still need error handling | 19 | // still need error handling |
20 | delete m_attach; | 20 | delete m_attach; |
21 | } | 21 | } |
22 | 22 | ||
23 | bool IOIrda::open() { | 23 | bool IOIrda::open() { |
24 | bool ret; | 24 | bool ret; |
25 | 25 | ||
26 | // irdaattach here | 26 | // irdaattach here |
27 | m_attach = new OProcess(); | 27 | m_attach = new OProcess(); |
28 | *m_attach << "irattach /dev/ttyS2 -s"; | 28 | *m_attach << "irattach /dev/ttyS2 -s"; |
29 | 29 | ||
30 | connect( m_attach, SIGNAL( processExited( OProcess* ) ), | 30 | connect( m_attach, SIGNAL( processExited(OProcess*) ), |
31 | this, SLOT( slotExited( OProcess* ) ) ); | 31 | this, SLOT( slotExited(OProcess*) ) ); |
32 | 32 | ||
33 | if ( m_attach->start() ) { | 33 | if ( m_attach->start() ) { |
34 | ret= IOSerial::open(); | 34 | ret= IOSerial::open(); |
35 | } else { | 35 | } else { |
36 | // emit error!!! | 36 | // emit error!!! |
37 | qWarning("could not attach to device"); | 37 | qWarning("could not attach to device"); |
38 | delete m_attach; | 38 | delete m_attach; |
39 | m_attach = 0l; | 39 | m_attach = 0l; |
40 | } | 40 | } |
41 | return ret; | 41 | return ret; |
42 | } | 42 | } |
43 | 43 | ||
44 | void IOIrda::reload( const Profile &config ) { | 44 | void IOIrda::reload( const Profile &config ) { |
45 | m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); | 45 | m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); |
46 | m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); | 46 | m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); |
47 | m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); | 47 | m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); |
48 | m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); | 48 | m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); |
49 | m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); | 49 | m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); |
50 | m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); | 50 | m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); |
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | QString IOIrda::identifier() const { | 54 | QString IOIrda::identifier() const { |
55 | return "irda"; | 55 | return "irda"; |
56 | } | 56 | } |
57 | 57 | ||
58 | QString IOIrda::name() const { | 58 | QString IOIrda::name() const { |
59 | return "Irda IO Layer"; | 59 | return "Irda IO Layer"; |
60 | } | 60 | } |
61 | 61 | ||
62 | void IOIrda::slotExited(OProcess* proc ){ | 62 | void IOIrda::slotExited(OProcess* proc ){ |
63 | close(); | 63 | close(); |
64 | delete proc; | 64 | delete proc; |
65 | } | 65 | } |
66 | 66 | ||
67 | QBitArray IOIrda::supports()const { | 67 | QBitArray IOIrda::supports()const { |
68 | return QBitArray( 3 ); | 68 | return QBitArray( 3 ); |
69 | } | 69 | } |
70 | 70 | ||
71 | bool IOIrda::isConnected() { | 71 | bool IOIrda::isConnected() { |
72 | return false; | 72 | return false; |
73 | } | 73 | } |
74 | 74 | ||
75 | void IOIrda::send(const QByteArray &data) { | 75 | void IOIrda::send(const QByteArray &data) { |
76 | qDebug( "Please overload me..." ); | 76 | qDebug( "Please overload me..." ); |
77 | } | 77 | } |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 1d2385f..197f799 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -117,232 +117,232 @@ void MainWindow::initUI() { | |||
117 | connect( m_quickLaunch, SIGNAL( activated() ), | 117 | connect( m_quickLaunch, SIGNAL( activated() ), |
118 | this, SLOT( slotQuickLaunch() ) ); | 118 | this, SLOT( slotQuickLaunch() ) ); |
119 | 119 | ||
120 | QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); | 120 | QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); |
121 | 121 | ||
122 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, | 122 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, |
123 | 0, this, 0 ); | 123 | 0, this, 0 ); |
124 | m_transfer->addTo( m_console ); | 124 | m_transfer->addTo( m_console ); |
125 | connect(m_transfer, SIGNAL(activated() ), | 125 | connect(m_transfer, SIGNAL(activated() ), |
126 | this, SLOT(slotTransfer() ) ); | 126 | this, SLOT(slotTransfer() ) ); |
127 | 127 | ||
128 | 128 | ||
129 | 129 | ||
130 | /* | 130 | /* |
131 | * immediate change of line wrap policy | 131 | * immediate change of line wrap policy |
132 | */ | 132 | */ |
133 | m_isWrapped = false; | 133 | m_isWrapped = false; |
134 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); | 134 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 ); |
135 | m_wrap->addTo( m_console ); | 135 | m_wrap->addTo( m_console ); |
136 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); | 136 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); |
137 | 137 | ||
138 | /* | 138 | /* |
139 | * fullscreen | 139 | * fullscreen |
140 | */ | 140 | */ |
141 | m_isFullscreen = false; | 141 | m_isFullscreen = false; |
142 | 142 | ||
143 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 143 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
144 | , QString::null, 0, this, 0); | 144 | , QString::null, 0, this, 0); |
145 | m_fullscreen->addTo( m_console ); | 145 | m_fullscreen->addTo( m_console ); |
146 | connect( m_fullscreen, SIGNAL( activated() ), | 146 | connect( m_fullscreen, SIGNAL( activated() ), |
147 | this, SLOT( slotFullscreen() ) ); | 147 | this, SLOT( slotFullscreen() ) ); |
148 | 148 | ||
149 | m_console->insertSeparator(); | 149 | m_console->insertSeparator(); |
150 | 150 | ||
151 | QAction *a = new QAction(); | 151 | QAction *a = new QAction(); |
152 | a->setText( tr("Save history") ); | 152 | a->setText( tr("Save history") ); |
153 | a->addTo( m_console ); | 153 | a->addTo( m_console ); |
154 | connect(a, SIGNAL(activated() ), | 154 | connect(a, SIGNAL(activated() ), |
155 | this, SLOT(slotSaveHistory() ) ); | 155 | this, SLOT(slotSaveHistory() ) ); |
156 | /* | 156 | /* |
157 | * terminate action | 157 | * terminate action |
158 | */ | 158 | */ |
159 | m_terminate = new QAction(); | 159 | m_terminate = new QAction(); |
160 | m_terminate->setText( tr("Terminate") ); | 160 | m_terminate->setText( tr("Terminate") ); |
161 | m_terminate->addTo( m_console ); | 161 | m_terminate->addTo( m_console ); |
162 | connect(m_terminate, SIGNAL(activated() ), | 162 | connect(m_terminate, SIGNAL(activated() ), |
163 | this, SLOT(slotTerminate() ) ); | 163 | this, SLOT(slotTerminate() ) ); |
164 | 164 | ||
165 | m_closewindow = new QAction(); | 165 | m_closewindow = new QAction(); |
166 | m_closewindow->setText( tr("Close Window") ); | 166 | m_closewindow->setText( tr("Close Window") ); |
167 | m_closewindow->addTo( m_console ); | 167 | m_closewindow->addTo( m_console ); |
168 | connect( m_closewindow, SIGNAL(activated() ), | 168 | connect( m_closewindow, SIGNAL(activated() ), |
169 | this, SLOT(slotClose() ) ); | 169 | this, SLOT(slotClose() ) ); |
170 | 170 | ||
171 | 171 | ||
172 | /* | 172 | /* |
173 | * script actions | 173 | * script actions |
174 | */ | 174 | */ |
175 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | 175 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); |
176 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | 176 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); |
177 | 177 | ||
178 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 178 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
179 | m_recordScript->addTo(m_scripts); | 179 | m_recordScript->addTo(m_scripts); |
180 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 180 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
181 | 181 | ||
182 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 182 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
183 | m_saveScript->addTo(m_scripts); | 183 | m_saveScript->addTo(m_scripts); |
184 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 184 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
185 | 185 | ||
186 | 186 | ||
187 | /* | 187 | /* |
188 | * action that open/closes the keyboard | 188 | * action that open/closes the keyboard |
189 | */ | 189 | */ |
190 | m_openKeys = new QAction (tr("Open Keyboard..."), | 190 | m_openKeys = new QAction (tr("Open Keyboard..."), |
191 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 191 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
192 | QString::null, 0, this, 0); | 192 | QString::null, 0, this, 0); |
193 | m_openKeys->setToggleAction(true); | 193 | m_openKeys->setToggleAction(true); |
194 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 194 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
195 | 195 | ||
196 | /* insert the submenu */ | 196 | /* insert the submenu */ |
197 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 197 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
198 | -1, 0); | 198 | -1, 0); |
199 | 199 | ||
200 | /* insert the connection menu */ | 200 | /* insert the connection menu */ |
201 | m_bar->insertItem( tr("Connection"), m_console ); | 201 | m_bar->insertItem( tr("Connection"), m_console ); |
202 | 202 | ||
203 | /* the scripts menu */ | 203 | /* the scripts menu */ |
204 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 204 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
205 | 205 | ||
206 | /* and the keyboard */ | 206 | /* and the keyboard */ |
207 | m_keyBar = new QToolBar(this); | 207 | m_keyBar = new QToolBar(this); |
208 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 208 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
209 | m_keyBar->setHorizontalStretchable( TRUE ); | 209 | m_keyBar->setHorizontalStretchable( TRUE ); |
210 | m_keyBar->hide(); | 210 | m_keyBar->hide(); |
211 | 211 | ||
212 | m_kb = new FunctionKeyboard(m_keyBar); | 212 | m_kb = new FunctionKeyboard(m_keyBar); |
213 | connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), | 213 | connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), |
214 | this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); | 214 | this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); |
215 | 215 | ||
216 | 216 | ||
217 | a = new QAction(tr("Copy"), | 217 | a = new QAction(tr("Copy"), |
218 | Resource::loadPixmap("copy"), QString::null, | 218 | Resource::loadPixmap("copy"), QString::null, |
219 | 0, this, 0 ); | 219 | 0, this, 0 ); |
220 | //a->addTo( m_icons ); | 220 | //a->addTo( m_icons ); |
221 | connect( a, SIGNAL(activated() ), | 221 | connect( a, SIGNAL(activated() ), |
222 | this, SLOT(slotCopy() ) ); | 222 | this, SLOT(slotCopy() ) ); |
223 | 223 | ||
224 | QAction *paste = new QAction(tr("Paste"), | 224 | QAction *paste = new QAction(tr("Paste"), |
225 | Resource::loadPixmap("paste"), QString::null, | 225 | Resource::loadPixmap("paste"), QString::null, |
226 | 0, this, 0 ); | 226 | 0, this, 0 ); |
227 | connect( paste, SIGNAL(activated() ), | 227 | connect( paste, SIGNAL(activated() ), |
228 | this, SLOT(slotPaste() ) ); | 228 | this, SLOT(slotPaste() ) ); |
229 | 229 | ||
230 | 230 | ||
231 | newCon->addTo( m_icons ); | 231 | newCon->addTo( m_icons ); |
232 | //m_setProfiles->addTo( m_icons ); | 232 | //m_setProfiles->addTo( m_icons ); |
233 | paste->addTo( m_icons ); | 233 | paste->addTo( m_icons ); |
234 | m_openKeys->addTo(m_icons); | 234 | m_openKeys->addTo(m_icons); |
235 | m_fullscreen->addTo( m_icons ); | 235 | m_fullscreen->addTo( m_icons ); |
236 | 236 | ||
237 | m_connect->setEnabled( false ); | 237 | m_connect->setEnabled( false ); |
238 | m_disconnect->setEnabled( false ); | 238 | m_disconnect->setEnabled( false ); |
239 | m_terminate->setEnabled( false ); | 239 | m_terminate->setEnabled( false ); |
240 | m_transfer->setEnabled( false ); | 240 | m_transfer->setEnabled( false ); |
241 | m_scripts->setItemEnabled(m_runScript_id, false); | 241 | m_scripts->setItemEnabled(m_runScript_id, false); |
242 | m_recordScript->setEnabled( false ); | 242 | m_recordScript->setEnabled( false ); |
243 | m_saveScript->setEnabled( false ); | 243 | m_saveScript->setEnabled( false ); |
244 | m_fullscreen->setEnabled( false ); | 244 | m_fullscreen->setEnabled( false ); |
245 | m_closewindow->setEnabled( false ); | 245 | m_closewindow->setEnabled( false ); |
246 | m_wrap->setEnabled( false ); | 246 | m_wrap->setEnabled( false ); |
247 | 247 | ||
248 | /* | 248 | /* |
249 | * connect to the menu activation | 249 | * connect to the menu activation |
250 | */ | 250 | */ |
251 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 251 | connect( m_sessionsPop, SIGNAL(activated(int) ), |
252 | this, SLOT(slotProfile( int ) ) ); | 252 | this, SLOT(slotProfile(int) ) ); |
253 | 253 | ||
254 | m_consoleWindow = new TabWidget( this, "blah"); | 254 | m_consoleWindow = new TabWidget( this, "blah"); |
255 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 255 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
256 | this, SLOT(slotSessionChanged(Session*) ) ); | 256 | this, SLOT(slotSessionChanged(Session*) ) ); |
257 | setCentralWidget( m_consoleWindow ); | 257 | setCentralWidget( m_consoleWindow ); |
258 | 258 | ||
259 | slotQuickLaunch(); | 259 | slotQuickLaunch(); |
260 | } | 260 | } |
261 | 261 | ||
262 | ProfileManager* MainWindow::manager() { | 262 | ProfileManager* MainWindow::manager() { |
263 | return m_manager; | 263 | return m_manager; |
264 | } | 264 | } |
265 | TabWidget* MainWindow::tabWidget() { | 265 | TabWidget* MainWindow::tabWidget() { |
266 | return m_consoleWindow; | 266 | return m_consoleWindow; |
267 | } | 267 | } |
268 | void MainWindow::populateProfiles() { | 268 | void MainWindow::populateProfiles() { |
269 | m_sessionsPop->clear(); | 269 | m_sessionsPop->clear(); |
270 | Profile::ValueList list = manager()->all(); | 270 | Profile::ValueList list = manager()->all(); |
271 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 271 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
272 | m_sessionsPop->insertItem( (*it).name() ); | 272 | m_sessionsPop->insertItem( (*it).name() ); |
273 | } | 273 | } |
274 | 274 | ||
275 | } | 275 | } |
276 | 276 | ||
277 | void MainWindow::populateScripts() { | 277 | void MainWindow::populateScripts() { |
278 | m_scriptsPop->clear(); | 278 | m_scriptsPop->clear(); |
279 | m_scriptsData.clear(); | 279 | m_scriptsData.clear(); |
280 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | 280 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); |
281 | QListIterator<DocLnk> dit(files.children()); | 281 | QListIterator<DocLnk> dit(files.children()); |
282 | for (; dit.current(); ++dit) { | 282 | for (; dit.current(); ++dit) { |
283 | if (*dit && (*dit)->name().length()>0) { | 283 | if (*dit && (*dit)->name().length()>0) { |
284 | QFileInfo info((*dit)->file()); | 284 | QFileInfo info((*dit)->file()); |
285 | if (info.extension(false) == "script") { | 285 | if (info.extension(false) == "script") { |
286 | m_scriptsData.append(new DocLnk(**dit)); | 286 | m_scriptsData.append(new DocLnk(**dit)); |
287 | m_scriptsPop->insertItem((*dit)->name()); | 287 | m_scriptsPop->insertItem((*dit)->name()); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | } | 290 | } |
291 | 291 | ||
292 | } | 292 | } |
293 | 293 | ||
294 | MainWindow::~MainWindow() { | 294 | MainWindow::~MainWindow() { |
295 | delete m_factory; | 295 | delete m_factory; |
296 | manager()->save(); | 296 | manager()->save(); |
297 | } | 297 | } |
298 | 298 | ||
299 | MetaFactory* MainWindow::factory() { | 299 | MetaFactory* MainWindow::factory() { |
300 | return m_factory; | 300 | return m_factory; |
301 | } | 301 | } |
302 | 302 | ||
303 | Session* MainWindow::currentSession() { | 303 | Session* MainWindow::currentSession() { |
304 | return m_curSession; | 304 | return m_curSession; |
305 | } | 305 | } |
306 | 306 | ||
307 | QList<Session> MainWindow::sessions() { | 307 | QList<Session> MainWindow::sessions() { |
308 | return m_sessions; | 308 | return m_sessions; |
309 | } | 309 | } |
310 | 310 | ||
311 | void MainWindow::slotNew() { | 311 | void MainWindow::slotNew() { |
312 | ProfileEditorDialog dlg(factory() ); | 312 | ProfileEditorDialog dlg(factory() ); |
313 | dlg.setCaption( tr("New Connection") ); | 313 | dlg.setCaption( tr("New Connection") ); |
314 | int ret = QPEApplication::execDialog( &dlg ); | 314 | int ret = QPEApplication::execDialog( &dlg ); |
315 | 315 | ||
316 | if ( ret == QDialog::Accepted ) { | 316 | if ( ret == QDialog::Accepted ) { |
317 | create( dlg.profile() ); | 317 | create( dlg.profile() ); |
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | void MainWindow::slotRecordScript() { | 321 | void MainWindow::slotRecordScript() { |
322 | if (currentSession()) { | 322 | if (currentSession()) { |
323 | currentSession()->emulationHandler()->startRecording(); | 323 | currentSession()->emulationHandler()->startRecording(); |
324 | m_saveScript->setEnabled(true); | 324 | m_saveScript->setEnabled(true); |
325 | m_recordScript->setEnabled(false); | 325 | m_recordScript->setEnabled(false); |
326 | } | 326 | } |
327 | } | 327 | } |
328 | 328 | ||
329 | void MainWindow::slotSaveScript() { | 329 | void MainWindow::slotSaveScript() { |
330 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 330 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
331 | QMap<QString, QStringList> map; | 331 | QMap<QString, QStringList> map; |
332 | QStringList text; | 332 | QStringList text; |
333 | text << "text/plain"; | 333 | text << "text/plain"; |
334 | map.insert(tr("Script"), text ); | 334 | map.insert(tr("Script"), text ); |
335 | QString filename = Opie::OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 335 | QString filename = Opie::OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
336 | if (!filename.isEmpty()) { | 336 | if (!filename.isEmpty()) { |
337 | QFileInfo info(filename); | 337 | QFileInfo info(filename); |
338 | if (info.extension(FALSE) != "script") | 338 | if (info.extension(FALSE) != "script") |
339 | filename += ".script"; | 339 | filename += ".script"; |
340 | DocLnk nf; | 340 | DocLnk nf; |
341 | nf.setType("text/plain"); | 341 | nf.setType("text/plain"); |
342 | nf.setFile(filename); | 342 | nf.setFile(filename); |
343 | nf.setName(info.fileName()); | 343 | nf.setName(info.fileName()); |
344 | FileManager fm; | 344 | FileManager fm; |
345 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 345 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
346 | currentSession()->emulationHandler()->clearScript(); | 346 | currentSession()->emulationHandler()->clearScript(); |
347 | m_saveScript->setEnabled(false); | 347 | m_saveScript->setEnabled(false); |
348 | m_recordScript->setEnabled(true); | 348 | m_recordScript->setEnabled(true); |
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index 979e89d..6e1e23e 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp | |||
@@ -38,196 +38,196 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | |||
38 | 38 | ||
39 | initUI(); | 39 | initUI(); |
40 | 40 | ||
41 | // Apply current profile | 41 | // Apply current profile |
42 | // plugin_plugin->load(profile); | 42 | // plugin_plugin->load(profile); |
43 | } | 43 | } |
44 | 44 | ||
45 | Profile ProfileEditorDialog::profile() const | 45 | Profile ProfileEditorDialog::profile() const |
46 | { | 46 | { |
47 | return m_prof; | 47 | return m_prof; |
48 | } | 48 | } |
49 | 49 | ||
50 | void ProfileEditorDialog::initUI() | 50 | void ProfileEditorDialog::initUI() |
51 | { | 51 | { |
52 | m_con = m_term = m_key = 0l; | 52 | m_con = m_term = m_key = 0l; |
53 | 53 | ||
54 | 54 | ||
55 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); | 55 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); |
56 | tabWidget = new OTabWidget( this ); | 56 | tabWidget = new OTabWidget( this ); |
57 | tabWidget->setTabStyle(OTabWidget::TextTab); | 57 | tabWidget->setTabStyle(OTabWidget::TextTab); |
58 | mainLayout->add(tabWidget); | 58 | mainLayout->add(tabWidget); |
59 | 59 | ||
60 | /* base tabs */ | 60 | /* base tabs */ |
61 | tabprof = new QWidget(this); | 61 | tabprof = new QWidget(this); |
62 | m_tabTerm = new QWidget(this); | 62 | m_tabTerm = new QWidget(this); |
63 | m_tabCon = new QWidget(this); | 63 | m_tabCon = new QWidget(this); |
64 | m_tabKey = new QWidget(this); | 64 | m_tabKey = new QWidget(this); |
65 | 65 | ||
66 | m_svCon = new QScrollView( m_tabCon ); | 66 | m_svCon = new QScrollView( m_tabCon ); |
67 | m_svCon->setResizePolicy( QScrollView::AutoOneFit ); | 67 | m_svCon->setResizePolicy( QScrollView::AutoOneFit ); |
68 | //m_svCon->setHScrollBarMode( QScrollView::AlwaysOff ); | 68 | //m_svCon->setHScrollBarMode( QScrollView::AlwaysOff ); |
69 | m_svCon->setFrameShape( QFrame::NoFrame ); | 69 | m_svCon->setFrameShape( QFrame::NoFrame ); |
70 | m_svTerm = new QScrollView( m_tabTerm ); | 70 | m_svTerm = new QScrollView( m_tabTerm ); |
71 | m_svTerm->setResizePolicy( QScrollView::AutoOneFit ); | 71 | m_svTerm->setResizePolicy( QScrollView::AutoOneFit ); |
72 | //m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff ); | 72 | //m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff ); |
73 | m_svTerm->setFrameShape( QFrame::NoFrame ); | 73 | m_svTerm->setFrameShape( QFrame::NoFrame ); |
74 | 74 | ||
75 | /* base layout for tabs */ | 75 | /* base layout for tabs */ |
76 | m_layCon = new QHBoxLayout( m_tabCon , 2 ); | 76 | m_layCon = new QHBoxLayout( m_tabCon , 2 ); |
77 | m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); | 77 | m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); |
78 | m_layKey = new QHBoxLayout( m_tabKey, 2 ); | 78 | m_layKey = new QHBoxLayout( m_tabKey, 2 ); |
79 | 79 | ||
80 | m_layCon->addWidget( m_svCon ); | 80 | m_layCon->addWidget( m_svCon ); |
81 | m_layTerm->addWidget( m_svTerm ); | 81 | m_layTerm->addWidget( m_svTerm ); |
82 | 82 | ||
83 | // profile tab | 83 | // profile tab |
84 | 84 | ||
85 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); | 85 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); |
86 | m_name = new QLineEdit(tabprof); | 86 | m_name = new QLineEdit(tabprof); |
87 | QLabel *con = new QLabel(tr("Connection"), tabprof ); | 87 | QLabel *con = new QLabel(tr("Connection"), tabprof ); |
88 | QLabel *term = new QLabel(tr("Terminal"), tabprof ); | 88 | QLabel *term = new QLabel(tr("Terminal"), tabprof ); |
89 | m_conCmb = new QComboBox( tabprof ); | 89 | m_conCmb = new QComboBox( tabprof ); |
90 | m_termCmb = new QComboBox( tabprof ); | 90 | m_termCmb = new QComboBox( tabprof ); |
91 | m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); | 91 | m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); |
92 | 92 | ||
93 | // layouting | 93 | // layouting |
94 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); | 94 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); |
95 | vbox3->add(name); | 95 | vbox3->add(name); |
96 | vbox3->add(m_name); | 96 | vbox3->add(m_name); |
97 | vbox3->add(con ); | 97 | vbox3->add(con ); |
98 | vbox3->add(m_conCmb ); | 98 | vbox3->add(m_conCmb ); |
99 | vbox3->add(term ); | 99 | vbox3->add(term ); |
100 | vbox3->add(m_termCmb ); | 100 | vbox3->add(m_termCmb ); |
101 | vbox3->add(m_autoConnect); | 101 | vbox3->add(m_autoConnect); |
102 | vbox3->addStretch(1); | 102 | vbox3->addStretch(1); |
103 | 103 | ||
104 | m_showconntab = 0; | 104 | m_showconntab = 0; |
105 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); | 105 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); |
106 | tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); | 106 | tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); |
107 | tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); | 107 | tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); |
108 | tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys")); | 108 | tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys")); |
109 | tabWidget->setCurrentTab( tabprof ); | 109 | tabWidget->setCurrentTab( tabprof ); |
110 | 110 | ||
111 | 111 | ||
112 | // fill the comboboxes | 112 | // fill the comboboxes |
113 | QStringList list = m_fact->connectionWidgets(); | 113 | QStringList list = m_fact->connectionWidgets(); |
114 | QStringList::Iterator it; | 114 | QStringList::Iterator it; |
115 | for (it =list.begin(); it != list.end(); ++it ) { | 115 | for (it =list.begin(); it != list.end(); ++it ) { |
116 | m_conCmb->insertItem( (*it) ); | 116 | m_conCmb->insertItem( (*it) ); |
117 | } | 117 | } |
118 | list = m_fact->terminalWidgets(); | 118 | list = m_fact->terminalWidgets(); |
119 | for (it =list.begin(); it != list.end(); ++it ) { | 119 | for (it =list.begin(); it != list.end(); ++it ) { |
120 | m_termCmb->insertItem( (*it) ); | 120 | m_termCmb->insertItem( (*it) ); |
121 | } | 121 | } |
122 | 122 | ||
123 | // load profile values | 123 | // load profile values |
124 | m_name->setText(m_prof.name()); | 124 | m_name->setText(m_prof.name()); |
125 | slotKeyActivated( "Default Keyboard" ); | 125 | slotKeyActivated( "Default Keyboard" ); |
126 | setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); | 126 | setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); |
127 | setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); | 127 | setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); |
128 | slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); | 128 | slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); |
129 | slotTermActivated( m_fact->external(m_prof.terminalName() ) ); | 129 | slotTermActivated( m_fact->external(m_prof.terminalName() ) ); |
130 | m_autoConnect->setChecked(m_prof.autoConnect()); | 130 | m_autoConnect->setChecked(m_prof.autoConnect()); |
131 | 131 | ||
132 | 132 | ||
133 | // signal and slots | 133 | // signal and slots |
134 | connect(m_conCmb, SIGNAL(activated(const QString& ) ), | 134 | connect(m_conCmb, SIGNAL(activated(const QString&) ), |
135 | this, SLOT(slotConActivated(const QString&) ) ); | 135 | this, SLOT(slotConActivated(const QString&) ) ); |
136 | connect(m_termCmb, SIGNAL(activated(const QString& ) ), | 136 | connect(m_termCmb, SIGNAL(activated(const QString&) ), |
137 | this, SLOT(slotTermActivated(const QString& ) ) ); | 137 | this, SLOT(slotTermActivated(const QString&) ) ); |
138 | 138 | ||
139 | } | 139 | } |
140 | 140 | ||
141 | ProfileEditorDialog::~ProfileEditorDialog() { | 141 | ProfileEditorDialog::~ProfileEditorDialog() { |
142 | 142 | ||
143 | } | 143 | } |
144 | void ProfileEditorDialog::accept() | 144 | void ProfileEditorDialog::accept() |
145 | { | 145 | { |
146 | if(profName().isEmpty()) | 146 | if(profName().isEmpty()) |
147 | { | 147 | { |
148 | QMessageBox::information(this, | 148 | QMessageBox::information(this, |
149 | QObject::tr("Invalid profile"), | 149 | QObject::tr("Invalid profile"), |
150 | QObject::tr("Please enter a profile name.")); | 150 | QObject::tr("Please enter a profile name.")); |
151 | return; | 151 | return; |
152 | } | 152 | } |
153 | // Save profile and plugin profile | 153 | // Save profile and plugin profile |
154 | //if(plugin_plugin) plugin_plugin->save(); | 154 | //if(plugin_plugin) plugin_plugin->save(); |
155 | 155 | ||
156 | // Save general values | 156 | // Save general values |
157 | m_prof.setName( profName() ); | 157 | m_prof.setName( profName() ); |
158 | m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); | 158 | m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); |
159 | m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); | 159 | m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); |
160 | m_prof.setAutoConnect( m_autoConnect->isChecked() ); | 160 | m_prof.setAutoConnect( m_autoConnect->isChecked() ); |
161 | 161 | ||
162 | if (m_con ) | 162 | if (m_con ) |
163 | m_con->save( m_prof ); | 163 | m_con->save( m_prof ); |
164 | if (m_term ) | 164 | if (m_term ) |
165 | m_term->save( m_prof ); | 165 | m_term->save( m_prof ); |
166 | if (m_key) | 166 | if (m_key) |
167 | m_key->save( m_prof ); | 167 | m_key->save( m_prof ); |
168 | 168 | ||
169 | QDialog::accept(); | 169 | QDialog::accept(); |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | QString ProfileEditorDialog::profName()const | 173 | QString ProfileEditorDialog::profName()const |
174 | { | 174 | { |
175 | return m_name->text(); | 175 | return m_name->text(); |
176 | } | 176 | } |
177 | 177 | ||
178 | QCString ProfileEditorDialog::profType()const | 178 | QCString ProfileEditorDialog::profType()const |
179 | { | 179 | { |
180 | /*QStringList w = m_fact->configWidgets(); | 180 | /*QStringList w = m_fact->configWidgets(); |
181 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 181 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
182 | if(device_box->currentText() == m_fact->name((*it))) return (*it); | 182 | if(device_box->currentText() == m_fact->name((*it))) return (*it); |
183 | */ | 183 | */ |
184 | return QCString(); | 184 | return QCString(); |
185 | } | 185 | } |
186 | /* | 186 | /* |
187 | * we need to switch the widget | 187 | * we need to switch the widget |
188 | */ | 188 | */ |
189 | void ProfileEditorDialog::slotConActivated( const QString& str ) { | 189 | void ProfileEditorDialog::slotConActivated( const QString& str ) { |
190 | 190 | ||
191 | delete m_con; | 191 | delete m_con; |
192 | 192 | ||
193 | m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() ); | 193 | m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() ); |
194 | 194 | ||
195 | if ( !m_con ) { | 195 | if ( !m_con ) { |
196 | m_con = new NoOptions( str, m_svCon->viewport(), "name"); | 196 | m_con = new NoOptions( str, m_svCon->viewport(), "name"); |
197 | } | 197 | } |
198 | 198 | ||
199 | // FIXME ugly hack right. Right solution would be to look into the layer and see if it | 199 | // FIXME ugly hack right. Right solution would be to look into the layer and see if it |
200 | // supports auto connect and then set it as prefered | 200 | // supports auto connect and then set it as prefered |
201 | if ( m_conCmb ->currentText() == tr("Local Console") ) { | 201 | if ( m_conCmb ->currentText() == tr("Local Console") ) { |
202 | m_autoConnect->setChecked( true ); | 202 | m_autoConnect->setChecked( true ); |
203 | m_prof.writeEntry("Terminal", Profile::Linux ); | 203 | m_prof.writeEntry("Terminal", Profile::Linux ); |
204 | slotTermActivated( m_fact->external (m_prof.terminalName() ) ); | 204 | slotTermActivated( m_fact->external (m_prof.terminalName() ) ); |
205 | } else { | 205 | } else { |
206 | m_prof.writeEntry("Terminal", Profile::VT102 ); | 206 | m_prof.writeEntry("Terminal", Profile::VT102 ); |
207 | slotTermActivated( m_fact->external (m_prof.terminalName() ) ); | 207 | slotTermActivated( m_fact->external (m_prof.terminalName() ) ); |
208 | m_autoConnect->setChecked( false ); | 208 | m_autoConnect->setChecked( false ); |
209 | } | 209 | } |
210 | 210 | ||
211 | m_con->load( m_prof ); | 211 | m_con->load( m_prof ); |
212 | m_svCon->addChild( m_con ); | 212 | m_svCon->addChild( m_con ); |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | /* | 216 | /* |
217 | * we need to switch the widget | 217 | * we need to switch the widget |
218 | */ | 218 | */ |
219 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { | 219 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { |
220 | 220 | ||
221 | delete m_term; | 221 | delete m_term; |
222 | 222 | ||
223 | m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() ); | 223 | m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() ); |
224 | 224 | ||
225 | if ( m_term ) { | 225 | if ( m_term ) { |
226 | m_term->load( m_prof ); | 226 | m_term->load( m_prof ); |
227 | m_svTerm->addChild( m_term ); | 227 | m_svTerm->addChild( m_term ); |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | void ProfileEditorDialog::slotKeyActivated(const QString &str) { | 231 | void ProfileEditorDialog::slotKeyActivated(const QString &str) { |
232 | delete m_key; | 232 | delete m_key; |
233 | m_key = m_fact->newKeyboardPlugin( str, m_tabKey ); | 233 | m_key = m_fact->newKeyboardPlugin( str, m_tabKey ); |
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp index 1034ede..b7f14c5 100644 --- a/noncore/apps/opie-console/session.cpp +++ b/noncore/apps/opie-console/session.cpp | |||
@@ -1,115 +1,115 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include "file_layer.h" | 3 | #include "file_layer.h" |
4 | #include "emulation_handler.h" | 4 | #include "emulation_handler.h" |
5 | #include "session.h" | 5 | #include "session.h" |
6 | 6 | ||
7 | 7 | ||
8 | Session::Session() { | 8 | Session::Session() { |
9 | m_widget = 0l; | 9 | m_widget = 0l; |
10 | m_layer = 0l; | 10 | m_layer = 0l; |
11 | m_emu = 0l; | 11 | m_emu = 0l; |
12 | m_transfer = 0l; | 12 | m_transfer = 0l; |
13 | } | 13 | } |
14 | Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) | 14 | Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) |
15 | : m_name( na ), m_widget( widget ), m_layer( lay ) | 15 | : m_name( na ), m_widget( widget ), m_layer( lay ) |
16 | { | 16 | { |
17 | // m_widLay = 0l; | 17 | // m_widLay = 0l; |
18 | // m_emLay = 0l; | 18 | // m_emLay = 0l; |
19 | m_emu = 0l; | 19 | m_emu = 0l; |
20 | } | 20 | } |
21 | Session::~Session() { | 21 | Session::~Session() { |
22 | delete m_layer; | 22 | delete m_layer; |
23 | delete m_emu; | 23 | delete m_emu; |
24 | delete m_widget; | 24 | delete m_widget; |
25 | /* the widget layer should be deleted by the m_widget */ | 25 | /* the widget layer should be deleted by the m_widget */ |
26 | } | 26 | } |
27 | QString Session::name()const { | 27 | QString Session::name()const { |
28 | return m_name; | 28 | return m_name; |
29 | } | 29 | } |
30 | QWidgetStack* Session::widgetStack() { | 30 | QWidgetStack* Session::widgetStack() { |
31 | return m_widget; | 31 | return m_widget; |
32 | } | 32 | } |
33 | IOLayer* Session::layer() { | 33 | IOLayer* Session::layer() { |
34 | return m_layer; | 34 | return m_layer; |
35 | } | 35 | } |
36 | EmulationHandler* Session::emulationHandler() { | 36 | EmulationHandler* Session::emulationHandler() { |
37 | return m_emu; | 37 | return m_emu; |
38 | } | 38 | } |
39 | QWidget* Session::widget() { | 39 | QWidget* Session::widget() { |
40 | if (!m_emu ) | 40 | if (!m_emu ) |
41 | return 0l; | 41 | return 0l; |
42 | 42 | ||
43 | return m_emu->widget(); | 43 | return m_emu->widget(); |
44 | } | 44 | } |
45 | Profile Session::profile()const { | 45 | Profile Session::profile()const { |
46 | return m_prof; | 46 | return m_prof; |
47 | } | 47 | } |
48 | /* | 48 | /* |
49 | WidgetLayer* Session::emulationWidget() { | 49 | WidgetLayer* Session::emulationWidget() { |
50 | return m_widLay; | 50 | return m_widLay; |
51 | } | 51 | } |
52 | */ | 52 | */ |
53 | void Session::connect() { | 53 | void Session::connect() { |
54 | if ( !m_layer || !m_emu ) | 54 | if ( !m_layer || !m_emu ) |
55 | return; | 55 | return; |
56 | 56 | ||
57 | QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), | 57 | QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), |
58 | m_emu, SLOT(recv(const QByteArray&) ) ); | 58 | m_emu, SLOT(recv(const QByteArray&) ) ); |
59 | QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), | 59 | QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), |
60 | m_layer, SLOT(send(const QByteArray&) ) ); | 60 | m_layer, SLOT(send(const QByteArray&) ) ); |
61 | QObject::connect(m_emu, SIGNAL(changeSize(int, int) ), | 61 | QObject::connect(m_emu, SIGNAL(changeSize(int,int) ), |
62 | m_layer, SLOT(setSize(int, int) ) ); | 62 | m_layer, SLOT(setSize(int,int) ) ); |
63 | } | 63 | } |
64 | 64 | ||
65 | void Session::disconnect() { | 65 | void Session::disconnect() { |
66 | 66 | ||
67 | if ( !m_layer || !m_emu ) | 67 | if ( !m_layer || !m_emu ) |
68 | return; | 68 | return; |
69 | 69 | ||
70 | QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), | 70 | QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), |
71 | m_emu, SLOT(recv(const QByteArray&) ) ); | 71 | m_emu, SLOT(recv(const QByteArray&) ) ); |
72 | QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), | 72 | QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), |
73 | m_layer, SLOT(send(const QByteArray&) ) ); | 73 | m_layer, SLOT(send(const QByteArray&) ) ); |
74 | } | 74 | } |
75 | 75 | ||
76 | void Session::setName( const QString& na){ | 76 | void Session::setName( const QString& na){ |
77 | m_name = na; | 77 | m_name = na; |
78 | } | 78 | } |
79 | 79 | ||
80 | void Session::setWidgetStack( QWidgetStack* wid ) { | 80 | void Session::setWidgetStack( QWidgetStack* wid ) { |
81 | delete m_emu; | 81 | delete m_emu; |
82 | m_emu = 0l; | 82 | m_emu = 0l; |
83 | delete m_widget; | 83 | delete m_widget; |
84 | /* the EmulationLayer was destroyed... */ | 84 | /* the EmulationLayer was destroyed... */ |
85 | 85 | ||
86 | m_widget = wid; | 86 | m_widget = wid; |
87 | } | 87 | } |
88 | void Session::setIOLayer( IOLayer* lay ) { | 88 | void Session::setIOLayer( IOLayer* lay ) { |
89 | delete m_layer; | 89 | delete m_layer; |
90 | m_layer = lay; | 90 | m_layer = lay; |
91 | } | 91 | } |
92 | 92 | ||
93 | void Session::setEmulationHandler( EmulationHandler* lay ) { | 93 | void Session::setEmulationHandler( EmulationHandler* lay ) { |
94 | delete m_emu; | 94 | delete m_emu; |
95 | m_emu = lay; | 95 | m_emu = lay; |
96 | } | 96 | } |
97 | void Session::setProfile( const Profile& prof ) { | 97 | void Session::setProfile( const Profile& prof ) { |
98 | m_prof = prof; | 98 | m_prof = prof; |
99 | } | 99 | } |
100 | /* | 100 | /* |
101 | void Session::setEmulationWidget( WidgetLayer* lay ) { | 101 | void Session::setEmulationWidget( WidgetLayer* lay ) { |
102 | delete m_widLay; | 102 | delete m_widLay; |
103 | m_widLay = lay; | 103 | m_widLay = lay; |
104 | } | 104 | } |
105 | */ | 105 | */ |
106 | void Session::setTransferDialog(QWidget *d) | 106 | void Session::setTransferDialog(QWidget *d) |
107 | { | 107 | { |
108 | m_transfer = d; | 108 | m_transfer = d; |
109 | } | 109 | } |
110 | 110 | ||
111 | QWidget *Session::transferDialog() | 111 | QWidget *Session::transferDialog() |
112 | { | 112 | { |
113 | return m_transfer; | 113 | return m_transfer; |
114 | } | 114 | } |
115 | 115 | ||
diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp index c47e73e..2f82417 100644 --- a/noncore/apps/opie-console/sz_transfer.cpp +++ b/noncore/apps/opie-console/sz_transfer.cpp | |||
@@ -1,84 +1,84 @@ | |||
1 | 1 | ||
2 | #include "sz_transfer.h" | 2 | #include "sz_transfer.h" |
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <stdio.h> | 4 | #include <stdio.h> |
5 | #include <sys/termios.h> | 5 | #include <sys/termios.h> |
6 | 6 | ||
7 | 7 | ||
8 | 8 | ||
9 | SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) | 9 | SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) |
10 | { | 10 | { |
11 | } | 11 | } |
12 | 12 | ||
13 | SzTransfer::~SzTransfer() { | 13 | SzTransfer::~SzTransfer() { |
14 | } | 14 | } |
15 | 15 | ||
16 | void SzTransfer::sendFile(const QFile& file) { | 16 | void SzTransfer::sendFile(const QFile& file) { |
17 | 17 | ||
18 | sendFile(file.name()); | 18 | sendFile(file.name()); |
19 | } | 19 | } |
20 | 20 | ||
21 | void SzTransfer::sendFile(const QString& file) { | 21 | void SzTransfer::sendFile(const QString& file) { |
22 | 22 | ||
23 | //setcbreak(2); /* raw no echo */ | 23 | //setcbreak(2); /* raw no echo */ |
24 | 24 | ||
25 | proc = new OProcess; | 25 | proc = new OProcess; |
26 | *proc << "sz"; | 26 | *proc << "sz"; |
27 | *proc << "-v" << "-v" << "-b" << file; | 27 | *proc << "-v" << "-v" << "-b" << file; |
28 | connect(proc, SIGNAL(processExited(OProcess *)), | 28 | connect(proc, SIGNAL(processExited(OProcess*)), |
29 | this, SLOT(sent())); | 29 | this, SLOT(sent())); |
30 | connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), | 30 | connect(proc, SIGNAL(receivedStdout(OProcess*,char*,int)), |
31 | this, SLOT(SzReceivedStdout(OProcess *, char *, int))); | 31 | this, SLOT(SzReceivedStdout(OProcess*,char*,int))); |
32 | connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), | 32 | connect(proc, SIGNAL(receivedStderr(OProcess*,char*,int)), |
33 | this, SLOT(SzReceivedStderr(OProcess *, char *, int))); | 33 | this, SLOT(SzReceivedStderr(OProcess*,char*,int))); |
34 | connect(layer(), SIGNAL(received(const QByteArray &)), | 34 | connect(layer(), SIGNAL(received(const QByteArray&)), |
35 | this, SLOT(receivedStdin(const QByteArray &))); | 35 | this, SLOT(receivedStdin(const QByteArray&))); |
36 | proc->start(OProcess::NotifyOnExit, OProcess::All); | 36 | proc->start(OProcess::NotifyOnExit, OProcess::All); |
37 | 37 | ||
38 | } | 38 | } |
39 | 39 | ||
40 | void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { | 40 | void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { |
41 | 41 | ||
42 | qWarning("recieved from sz on stdout %d bytes", buflen); | 42 | qWarning("recieved from sz on stdout %d bytes", buflen); |
43 | 43 | ||
44 | QByteArray data(buflen); | 44 | QByteArray data(buflen); |
45 | data.fill(*buffer, buflen); | 45 | data.fill(*buffer, buflen); |
46 | for (uint i = 0; i < data.count(); i++ ) { | 46 | for (uint i = 0; i < data.count(); i++ ) { |
47 | printf("%c", buffer[i] ); | 47 | printf("%c", buffer[i] ); |
48 | } | 48 | } |
49 | printf("\n"); | 49 | printf("\n"); |
50 | 50 | ||
51 | // send out through the io layer | 51 | // send out through the io layer |
52 | layer()->send(data); | 52 | layer()->send(data); |
53 | } | 53 | } |
54 | 54 | ||
55 | void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) { | 55 | void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) { |
56 | 56 | ||
57 | // parse and show data in a progress dialog/widget | 57 | // parse and show data in a progress dialog/widget |
58 | printf("stderr:\n"); | 58 | printf("stderr:\n"); |
59 | //for (int i = 0; i < length; i++) | 59 | //for (int i = 0; i < length; i++) |
60 | // printf("%c", buffer[i]); | 60 | // printf("%c", buffer[i]); |
61 | //printf("\n"); | 61 | //printf("\n"); |
62 | } | 62 | } |
63 | 63 | ||
64 | void SzTransfer::receivedStdin(const QByteArray &data) { | 64 | void SzTransfer::receivedStdin(const QByteArray &data) { |
65 | 65 | ||
66 | qWarning("recieved from io_serial %d bytes", data.size()); | 66 | qWarning("recieved from io_serial %d bytes", data.size()); |
67 | 67 | ||
68 | // recieved data from the io layer goes to sz | 68 | // recieved data from the io layer goes to sz |
69 | proc->writeStdin(data.data(), data.size()); | 69 | proc->writeStdin(data.data(), data.size()); |
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
73 | void SzTransfer::sent() { | 73 | void SzTransfer::sent() { |
74 | 74 | ||
75 | qWarning("sent file"); | 75 | qWarning("sent file"); |
76 | 76 | ||
77 | //setcbreak(0); /* default */ | 77 | //setcbreak(0); /* default */ |
78 | 78 | ||
79 | 79 | ||
80 | delete proc; | 80 | delete proc; |
81 | disconnect(layer(), SIGNAL(received(const QByteArray &)), | 81 | disconnect(layer(), SIGNAL(received(const QByteArray&)), |
82 | this, SLOT(receivedStdin(const QByteArray &))); | 82 | this, SLOT(receivedStdin(const QByteArray&))); |
83 | 83 | ||
84 | } | 84 | } |
diff --git a/noncore/apps/opie-console/test/senderui.cpp b/noncore/apps/opie-console/test/senderui.cpp index 4a7202d..b1725db 100644 --- a/noncore/apps/opie-console/test/senderui.cpp +++ b/noncore/apps/opie-console/test/senderui.cpp | |||
@@ -1,77 +1,77 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <fcntl.h> | 3 | #include <fcntl.h> |
4 | #include <sys/termios.h> | 4 | #include <sys/termios.h> |
5 | 5 | ||
6 | #include <qmultilineedit.h> | 6 | #include <qmultilineedit.h> |
7 | #include <qsocketnotifier.h> | 7 | #include <qsocketnotifier.h> |
8 | 8 | ||
9 | #include "../profile.h" | 9 | #include "../profile.h" |
10 | #include "../io_serial.h" | 10 | #include "../io_serial.h" |
11 | #include "../filetransfer.h" | 11 | #include "../filetransfer.h" |
12 | #include "../filereceive.h" | 12 | #include "../filereceive.h" |
13 | 13 | ||
14 | #include <opie2/oprocess.h> | 14 | #include <opie2/oprocess.h> |
15 | 15 | ||
16 | #include "senderui.h" | 16 | #include "senderui.h" |
17 | 17 | ||
18 | SenderUI::SenderUI() | 18 | SenderUI::SenderUI() |
19 | : Sender() { | 19 | : Sender() { |
20 | 20 | ||
21 | /* we do that manually */ | 21 | /* we do that manually */ |
22 | Profile prof; | 22 | Profile prof; |
23 | QString str = "/dev/bty0"; | 23 | QString str = "/dev/bty0"; |
24 | prof.writeEntry("Device",str ); | 24 | prof.writeEntry("Device",str ); |
25 | prof.writeEntry("Baud", 19200 ); | 25 | prof.writeEntry("Baud", 19200 ); |
26 | 26 | ||
27 | qWarning("prof " + prof.readEntry("Device") + " " + str); | 27 | qWarning("prof " + prof.readEntry("Device") + " " + str); |
28 | ser = new IOSerial(prof); | 28 | ser = new IOSerial(prof); |
29 | connect(ser, SIGNAL(received(const QByteArray& ) ), | 29 | connect(ser, SIGNAL(received(const QByteArray&) ), |
30 | this, SLOT(got(const QByteArray&) ) ); | 30 | this, SLOT(got(const QByteArray&) ) ); |
31 | 31 | ||
32 | if ( ser->open() ) | 32 | if ( ser->open() ) |
33 | qWarning("opened!!!"); | 33 | qWarning("opened!!!"); |
34 | else | 34 | else |
35 | qWarning("could not open"); | 35 | qWarning("could not open"); |
36 | 36 | ||
37 | 37 | ||
38 | } | 38 | } |
39 | SenderUI::~SenderUI() { | 39 | SenderUI::~SenderUI() { |
40 | 40 | ||
41 | } | 41 | } |
42 | void SenderUI::slotSendFile() { | 42 | void SenderUI::slotSendFile() { |
43 | 43 | ||
44 | sz = new FileTransfer(FileTransfer::SY, ser); | 44 | sz = new FileTransfer(FileTransfer::SY, ser); |
45 | sz->sendFile("/home/ich/bootopie-v06-13.jffs2"); | 45 | sz->sendFile("/home/ich/bootopie-v06-13.jffs2"); |
46 | 46 | ||
47 | connect (sz, SIGNAL(sent()), | 47 | connect (sz, SIGNAL(sent()), |
48 | this, SLOT(fileTransComplete())); | 48 | this, SLOT(fileTransComplete())); |
49 | } | 49 | } |
50 | 50 | ||
51 | void SenderUI::slotSend() { | 51 | void SenderUI::slotSend() { |
52 | QCString str = MultiLineEdit1->text().utf8(); | 52 | QCString str = MultiLineEdit1->text().utf8(); |
53 | qWarning("sending: %s", str.data() ); | 53 | qWarning("sending: %s", str.data() ); |
54 | str = str.replace( QRegExp("\n"), "\r"); | 54 | str = str.replace( QRegExp("\n"), "\r"); |
55 | ser->send( str ); | 55 | ser->send( str ); |
56 | } | 56 | } |
57 | void SenderUI::got(const QByteArray& ar) { | 57 | void SenderUI::got(const QByteArray& ar) { |
58 | qWarning("got:"); | 58 | qWarning("got:"); |
59 | for ( uint i = 0; i < ar.count(); i++ ) { | 59 | for ( uint i = 0; i < ar.count(); i++ ) { |
60 | printf("%c", ar[i] ); | 60 | printf("%c", ar[i] ); |
61 | } | 61 | } |
62 | printf("\n"); | 62 | printf("\n"); |
63 | } | 63 | } |
64 | 64 | ||
65 | void SenderUI::fileTransComplete() { | 65 | void SenderUI::fileTransComplete() { |
66 | 66 | ||
67 | qWarning("file transfer complete"); | 67 | qWarning("file transfer complete"); |
68 | } | 68 | } |
69 | void SenderUI::send() { | 69 | void SenderUI::send() { |
70 | 70 | ||
71 | } | 71 | } |
72 | void SenderUI::slotRev(){ | 72 | void SenderUI::slotRev(){ |
73 | qWarning("Going to receive!"); | 73 | qWarning("Going to receive!"); |
74 | FileReceive *rev = new FileReceive( FileReceive::SZ, ser ); | 74 | FileReceive *rev = new FileReceive( FileReceive::SZ, ser ); |
75 | rev->receive(); | 75 | rev->receive(); |
76 | 76 | ||
77 | } | 77 | } |
diff --git a/noncore/apps/opie-console/transferdialog.cpp b/noncore/apps/opie-console/transferdialog.cpp index 30e7caf..d494a6c 100644 --- a/noncore/apps/opie-console/transferdialog.cpp +++ b/noncore/apps/opie-console/transferdialog.cpp | |||
@@ -32,205 +32,205 @@ TransferDialog::TransferDialog(QWidget *parent, MainWindow *mainwindow, const ch | |||
32 | group = new QButtonGroup(QObject::tr("Transfer mode"), this); | 32 | group = new QButtonGroup(QObject::tr("Transfer mode"), this); |
33 | mode_send = new QRadioButton(QObject::tr("Send"), group); | 33 | mode_send = new QRadioButton(QObject::tr("Send"), group); |
34 | mode_receive = new QRadioButton(QObject::tr("Receive"), group); | 34 | mode_receive = new QRadioButton(QObject::tr("Receive"), group); |
35 | group->insert(mode_send, id_send); | 35 | group->insert(mode_send, id_send); |
36 | group->insert(mode_receive, id_receive); | 36 | group->insert(mode_receive, id_receive); |
37 | vbox2 = new QVBoxLayout(group, 2); | 37 | vbox2 = new QVBoxLayout(group, 2); |
38 | vbox2->addSpacing(10); | 38 | vbox2->addSpacing(10); |
39 | hbox3 = new QHBoxLayout(vbox2, 2); | 39 | hbox3 = new QHBoxLayout(vbox2, 2); |
40 | hbox3->add(mode_send); | 40 | hbox3->add(mode_send); |
41 | hbox3->add(mode_receive); | 41 | hbox3->add(mode_receive); |
42 | mode_send->setChecked(true); | 42 | mode_send->setChecked(true); |
43 | m_transfermode = id_send; | 43 | m_transfermode = id_send; |
44 | 44 | ||
45 | file = new QLabel(QObject::tr("Send file"), this); | 45 | file = new QLabel(QObject::tr("Send file"), this); |
46 | mode = new QLabel(QObject::tr("Transfer protocol"), this); | 46 | mode = new QLabel(QObject::tr("Transfer protocol"), this); |
47 | progress = new QLabel(QObject::tr("Progress"), this); | 47 | progress = new QLabel(QObject::tr("Progress"), this); |
48 | status = new QLabel(QObject::tr("Status"), this); | 48 | status = new QLabel(QObject::tr("Status"), this); |
49 | 49 | ||
50 | statusbar = new QLabel(QObject::tr("Ready"), this); | 50 | statusbar = new QLabel(QObject::tr("Ready"), this); |
51 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 51 | statusbar->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
52 | 52 | ||
53 | protocol = new QComboBox(this); | 53 | protocol = new QComboBox(this); |
54 | QStringList list = m_win->factory()->fileTransferLayers(); | 54 | QStringList list = m_win->factory()->fileTransferLayers(); |
55 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) | 55 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) |
56 | protocol->insertItem((*it)); | 56 | protocol->insertItem((*it)); |
57 | 57 | ||
58 | filename = new QLineEdit(this); | 58 | filename = new QLineEdit(this); |
59 | 59 | ||
60 | progressbar = new QProgressBar(this); | 60 | progressbar = new QProgressBar(this); |
61 | progressbar->setProgress(0); | 61 | progressbar->setProgress(0); |
62 | 62 | ||
63 | selector = new QPushButton("...", this); | 63 | selector = new QPushButton("...", this); |
64 | ok = new QPushButton(QObject::tr("Start transfer"), this); | 64 | ok = new QPushButton(QObject::tr("Start transfer"), this); |
65 | cancel = new QPushButton(QObject::tr("Cancel"), this); | 65 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
66 | 66 | ||
67 | vbox = new QVBoxLayout(this, 2); | 67 | vbox = new QVBoxLayout(this, 2); |
68 | vbox->add(group); | 68 | vbox->add(group); |
69 | vbox->add(file); | 69 | vbox->add(file); |
70 | hbox = new QHBoxLayout(vbox, 0); | 70 | hbox = new QHBoxLayout(vbox, 0); |
71 | hbox->add(filename); | 71 | hbox->add(filename); |
72 | hbox->add(selector); | 72 | hbox->add(selector); |
73 | vbox->add(mode); | 73 | vbox->add(mode); |
74 | vbox->add(protocol); | 74 | vbox->add(protocol); |
75 | vbox->add(progress); | 75 | vbox->add(progress); |
76 | vbox->add(progressbar); | 76 | vbox->add(progressbar); |
77 | vbox->add(status); | 77 | vbox->add(status); |
78 | vbox->add(statusbar); | 78 | vbox->add(statusbar); |
79 | vbox->addStretch(1); | 79 | vbox->addStretch(1); |
80 | hbox2 = new QHBoxLayout(vbox, 2); | 80 | hbox2 = new QHBoxLayout(vbox, 2); |
81 | hbox2->add(ok); | 81 | hbox2->add(ok); |
82 | hbox2->add(cancel); | 82 | hbox2->add(cancel); |
83 | 83 | ||
84 | setCaption(QObject::tr("File transfer")); | 84 | setCaption(QObject::tr("File transfer")); |
85 | show(); | 85 | show(); |
86 | 86 | ||
87 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); | 87 | connect(selector, SIGNAL(clicked()), SLOT(slotFilename())); |
88 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); | 88 | connect(ok, SIGNAL(clicked()), SLOT(slotTransfer())); |
89 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); | 89 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); |
90 | connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int))); | 90 | connect(group, SIGNAL(clicked(int)), SLOT(slotMode(int))); |
91 | } | 91 | } |
92 | 92 | ||
93 | TransferDialog::~TransferDialog() | 93 | TransferDialog::~TransferDialog() |
94 | { | 94 | { |
95 | } | 95 | } |
96 | 96 | ||
97 | void TransferDialog::slotFilename() | 97 | void TransferDialog::slotFilename() |
98 | { | 98 | { |
99 | QString f; | 99 | QString f; |
100 | 100 | ||
101 | f = Opie::OFileDialog::getOpenFileName(0); | 101 | f = Opie::OFileDialog::getOpenFileName(0); |
102 | if(!f.isNull()) filename->setText(f); | 102 | if(!f.isNull()) filename->setText(f); |
103 | } | 103 | } |
104 | 104 | ||
105 | void TransferDialog::slotTransfer() | 105 | void TransferDialog::slotTransfer() |
106 | { | 106 | { |
107 | if((m_transfermode == id_send) && (filename->text().isEmpty())) | 107 | if((m_transfermode == id_send) && (filename->text().isEmpty())) |
108 | { | 108 | { |
109 | QMessageBox::information(this, | 109 | QMessageBox::information(this, |
110 | QObject::tr("Attention"), | 110 | QObject::tr("Attention"), |
111 | QObject::tr("No file has been specified.")); | 111 | QObject::tr("No file has been specified.")); |
112 | return; | 112 | return; |
113 | } | 113 | } |
114 | 114 | ||
115 | ok->setEnabled(false); | 115 | ok->setEnabled(false); |
116 | 116 | ||
117 | cleanup(); | 117 | cleanup(); |
118 | m_autocleanup = 0; | 118 | m_autocleanup = 0; |
119 | 119 | ||
120 | if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); | 120 | if(m_transfermode == id_send) statusbar->setText(QObject::tr("Sending...")); |
121 | else statusbar->setText(QObject::tr("Receiving...")); | 121 | else statusbar->setText(QObject::tr("Receiving...")); |
122 | 122 | ||
123 | if(m_transfermode == id_send) | 123 | if(m_transfermode == id_send) |
124 | { | 124 | { |
125 | m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); | 125 | m_lay = m_win->factory()->newFileTransfer(protocol->currentText(), m_win->currentSession()->layer()); |
126 | m_lay->sendFile(filename->text()); | 126 | m_lay->sendFile(filename->text()); |
127 | 127 | ||
128 | connect(m_lay, SIGNAL(progress(const QString&, int, int, int, int, int)), | 128 | connect(m_lay, SIGNAL(progress(const QString&,int,int,int,int,int)), |
129 | SLOT(slotProgress(const QString&, int, int, int, int, int))); | 129 | SLOT(slotProgress(const QString&,int,int,int,int,int))); |
130 | connect(m_lay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); | 130 | connect(m_lay, SIGNAL(error(int,const QString&)), SLOT(slotError(int,const QString&))); |
131 | connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); | 131 | connect(m_lay, SIGNAL(sent()), SLOT(slotSent())); |
132 | } | 132 | } |
133 | else | 133 | else |
134 | { | 134 | { |
135 | m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer()); | 135 | m_recvlay = m_win->factory()->newReceive(protocol->currentText(), m_win->currentSession()->layer()); |
136 | m_recvlay->receive(); | 136 | m_recvlay->receive(); |
137 | 137 | ||
138 | connect(m_recvlay, SIGNAL(progress(const QString&, int, int, int, int, int)), | 138 | connect(m_recvlay, SIGNAL(progress(const QString&,int,int,int,int,int)), |
139 | SLOT(slotProgress(const QString&, int, int, int, int, int))); | 139 | SLOT(slotProgress(const QString&,int,int,int,int,int))); |
140 | connect(m_recvlay, SIGNAL(error(int, const QString&)), SLOT(slotError(int, const QString&))); | 140 | connect(m_recvlay, SIGNAL(error(int,const QString&)), SLOT(slotError(int,const QString&))); |
141 | connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); | 141 | connect(m_recvlay, SIGNAL(received(const QString&)), SLOT(slotReceived(const QString&))); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | void TransferDialog::cleanup() | 145 | void TransferDialog::cleanup() |
146 | { | 146 | { |
147 | if(m_lay) | 147 | if(m_lay) |
148 | { | 148 | { |
149 | m_lay->cancel(); | 149 | m_lay->cancel(); |
150 | delete m_lay; | 150 | delete m_lay; |
151 | m_lay = 0l; | 151 | m_lay = 0l; |
152 | } | 152 | } |
153 | if(m_recvlay) | 153 | if(m_recvlay) |
154 | { | 154 | { |
155 | m_recvlay->cancel(); | 155 | m_recvlay->cancel(); |
156 | delete m_recvlay; | 156 | delete m_recvlay; |
157 | m_recvlay = 0l; | 157 | m_recvlay = 0l; |
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | void TransferDialog::slotCancel() | 161 | void TransferDialog::slotCancel() |
162 | { | 162 | { |
163 | ok->setEnabled(true); | 163 | ok->setEnabled(true); |
164 | statusbar->setText(QObject::tr("Ready")); | 164 | statusbar->setText(QObject::tr("Ready")); |
165 | 165 | ||
166 | if((m_lay) || (m_recvlay)) | 166 | if((m_lay) || (m_recvlay)) |
167 | { | 167 | { |
168 | cleanup(); | 168 | cleanup(); |
169 | if(m_autocleanup) | 169 | if(m_autocleanup) |
170 | { | 170 | { |
171 | m_running = false; | 171 | m_running = false; |
172 | close(); | 172 | close(); |
173 | } | 173 | } |
174 | else | 174 | else |
175 | { | 175 | { |
176 | QMessageBox::information(this, | 176 | QMessageBox::information(this, |
177 | QObject::tr("Cancelled"), | 177 | QObject::tr("Cancelled"), |
178 | QObject::tr("The file transfer has been cancelled.")); | 178 | QObject::tr("The file transfer has been cancelled.")); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | else | 181 | else |
182 | { | 182 | { |
183 | m_running = false; | 183 | m_running = false; |
184 | close(); | 184 | close(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int ) | 188 | void TransferDialog::slotProgress(const QString& , int progress, int , int , int, int ) |
189 | { | 189 | { |
190 | progressbar->setProgress(progress); | 190 | progressbar->setProgress(progress); |
191 | } | 191 | } |
192 | 192 | ||
193 | void TransferDialog::slotError(int error, const QString& ) | 193 | void TransferDialog::slotError(int error, const QString& ) |
194 | { | 194 | { |
195 | statusbar->setText(QObject::tr("Ready")); | 195 | statusbar->setText(QObject::tr("Ready")); |
196 | 196 | ||
197 | switch(error) | 197 | switch(error) |
198 | { | 198 | { |
199 | case FileTransferLayer::NotSupported: | 199 | case FileTransferLayer::NotSupported: |
200 | QMessageBox::critical(this, | 200 | QMessageBox::critical(this, |
201 | QObject::tr("Error"), | 201 | QObject::tr("Error"), |
202 | QObject::tr("Operation not supported.")); | 202 | QObject::tr("Operation not supported.")); |
203 | break; | 203 | break; |
204 | case FileTransferLayer::StartError: | 204 | case FileTransferLayer::StartError: |
205 | QMessageBox::critical(this, | 205 | QMessageBox::critical(this, |
206 | QObject::tr("Error"), | 206 | QObject::tr("Error"), |
207 | QObject::tr("Transfer could not be started.")); | 207 | QObject::tr("Transfer could not be started.")); |
208 | break; | 208 | break; |
209 | case FileTransferLayer::NoError: | 209 | case FileTransferLayer::NoError: |
210 | QMessageBox::critical(this, | 210 | QMessageBox::critical(this, |
211 | QObject::tr("Error"), | 211 | QObject::tr("Error"), |
212 | QObject::tr("No error.")); | 212 | QObject::tr("No error.")); |
213 | break; | 213 | break; |
214 | case FileTransferLayer::Undefined: | 214 | case FileTransferLayer::Undefined: |
215 | QMessageBox::critical(this, | 215 | QMessageBox::critical(this, |
216 | QObject::tr("Error"), | 216 | QObject::tr("Error"), |
217 | QObject::tr("Undefined error occured.")); | 217 | QObject::tr("Undefined error occured.")); |
218 | break; | 218 | break; |
219 | case FileTransferLayer::Incomplete: | 219 | case FileTransferLayer::Incomplete: |
220 | QMessageBox::critical(this, | 220 | QMessageBox::critical(this, |
221 | QObject::tr("Error"), | 221 | QObject::tr("Error"), |
222 | QObject::tr("Incomplete transfer.")); | 222 | QObject::tr("Incomplete transfer.")); |
223 | break; | 223 | break; |
224 | case FileTransferLayer::Unknown: | 224 | case FileTransferLayer::Unknown: |
225 | default: | 225 | default: |
226 | QMessageBox::critical(this, | 226 | QMessageBox::critical(this, |
227 | QObject::tr("Error"), | 227 | QObject::tr("Error"), |
228 | QObject::tr("Unknown error occured.")); | 228 | QObject::tr("Unknown error occured.")); |
229 | break; | 229 | break; |
230 | } | 230 | } |
231 | 231 | ||
232 | m_autocleanup = 1; | 232 | m_autocleanup = 1; |
233 | } | 233 | } |
234 | 234 | ||
235 | void TransferDialog::slotSent() | 235 | void TransferDialog::slotSent() |
236 | { | 236 | { |
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index e759249..b0d589e 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -236,317 +236,317 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
236 | } | 236 | } |
237 | else if (rot.contains("Rot180")) | 237 | else if (rot.contains("Rot180")) |
238 | { | 238 | { |
239 | m_rot = 180; | 239 | m_rot = 180; |
240 | } | 240 | } |
241 | else if (rot.contains("Rot270")) | 241 | else if (rot.contains("Rot270")) |
242 | { | 242 | { |
243 | m_rot = 270; | 243 | m_rot = 270; |
244 | } | 244 | } |
245 | 245 | ||
246 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); | 246 | // qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); |
247 | */ | 247 | */ |
248 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; | 248 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; |
249 | 249 | ||
250 | #ifdef USEQPE | 250 | #ifdef USEQPE |
251 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); | 251 | setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); |
252 | #else | 252 | #else |
253 | setIcon( QPixmap (PICDIR "uqtreader.png") ); | 253 | setIcon( QPixmap (PICDIR "uqtreader.png") ); |
254 | #endif /* USEQPE */ | 254 | #endif /* USEQPE */ |
255 | 255 | ||
256 | // QToolBar *bar = new QToolBar( this ); | 256 | // QToolBar *bar = new QToolBar( this ); |
257 | // menubar = new QToolBar( this ); | 257 | // menubar = new QToolBar( this ); |
258 | #ifdef USEQPE | 258 | #ifdef USEQPE |
259 | Config config( APPDIR ); | 259 | Config config( APPDIR ); |
260 | #else | 260 | #else |
261 | QDir d = QDir::home(); // "/" | 261 | QDir d = QDir::home(); // "/" |
262 | if ( !d.cd(APPDIR) ) { // "/tmp" | 262 | if ( !d.cd(APPDIR) ) { // "/tmp" |
263 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 263 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
264 | d = QDir::home(); | 264 | d = QDir::home(); |
265 | d.mkdir(APPDIR); | 265 | d.mkdir(APPDIR); |
266 | d.cd(APPDIR); | 266 | d.cd(APPDIR); |
267 | } | 267 | } |
268 | QFileInfo fi(d, INIFILE); | 268 | QFileInfo fi(d, INIFILE); |
269 | // qDebug("Path:%s", (const char*)fi.absFilePath()); | 269 | // qDebug("Path:%s", (const char*)fi.absFilePath()); |
270 | Config config(fi.absFilePath()); | 270 | Config config(fi.absFilePath()); |
271 | #endif | 271 | #endif |
272 | config.setGroup("Toolbar"); | 272 | config.setGroup("Toolbar"); |
273 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); | 273 | m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); |
274 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); | 274 | m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); |
275 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); | 275 | m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); |
276 | menubar = new QToolBar("Menus", this, m_tbposition); | 276 | menubar = new QToolBar("Menus", this, m_tbposition); |
277 | 277 | ||
278 | // fileBar = new QToolBar("File", this); | 278 | // fileBar = new QToolBar("File", this); |
279 | // QToolBar* viewBar = new QToolBar("File", this); | 279 | // QToolBar* viewBar = new QToolBar("File", this); |
280 | // QToolBar* navBar = new QToolBar("File", this); | 280 | // QToolBar* navBar = new QToolBar("File", this); |
281 | // QToolBar* markBar = new QToolBar("File", this); | 281 | // QToolBar* markBar = new QToolBar("File", this); |
282 | 282 | ||
283 | #ifdef USEQPE | 283 | #ifdef USEQPE |
284 | mb = new QMenuBar( menubar ); | 284 | mb = new QMenuBar( menubar ); |
285 | #else | 285 | #else |
286 | mb = new QMenuBar( menubar ); | 286 | mb = new QMenuBar( menubar ); |
287 | #endif | 287 | #endif |
288 | 288 | ||
289 | //#ifdef USEQPE | 289 | //#ifdef USEQPE |
290 | QPopupMenu* tmp = new QPopupMenu(mb); | 290 | QPopupMenu* tmp = new QPopupMenu(mb); |
291 | mb->insertItem( geticon( "AppsIcon" ), tmp ); | 291 | mb->insertItem( geticon( "AppsIcon" ), tmp ); |
292 | //#else | 292 | //#else |
293 | // QMenuBar* tmp = mb; | 293 | // QMenuBar* tmp = mb; |
294 | //#endif | 294 | //#endif |
295 | 295 | ||
296 | QPopupMenu *file = new QPopupMenu( mb ); | 296 | QPopupMenu *file = new QPopupMenu( mb ); |
297 | tmp->insertItem( tr( "File" ), file ); | 297 | tmp->insertItem( tr( "File" ), file ); |
298 | 298 | ||
299 | QPopupMenu *navigation = new QPopupMenu(mb); | 299 | QPopupMenu *navigation = new QPopupMenu(mb); |
300 | tmp->insertItem( tr( "Navigation" ), navigation ); | 300 | tmp->insertItem( tr( "Navigation" ), navigation ); |
301 | 301 | ||
302 | QPopupMenu *view = new QPopupMenu( mb ); | 302 | QPopupMenu *view = new QPopupMenu( mb ); |
303 | tmp->insertItem( tr( "View" ), view ); | 303 | tmp->insertItem( tr( "View" ), view ); |
304 | 304 | ||
305 | QPopupMenu *marks = new QPopupMenu( this ); | 305 | QPopupMenu *marks = new QPopupMenu( this ); |
306 | tmp->insertItem( tr( "Marks" ), marks ); | 306 | tmp->insertItem( tr( "Marks" ), marks ); |
307 | 307 | ||
308 | QPopupMenu *settings = new QPopupMenu( this ); | 308 | QPopupMenu *settings = new QPopupMenu( this ); |
309 | tmp->insertItem( tr( "Settings" ), settings ); | 309 | tmp->insertItem( tr( "Settings" ), settings ); |
310 | 310 | ||
311 | // addToolBar(menubar, "Menus",QMainWindow::Top); | 311 | // addToolBar(menubar, "Menus",QMainWindow::Top); |
312 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); | 312 | // addToolBar(fileBar, "Toolbar",QMainWindow::Top); |
313 | 313 | ||
314 | // QPopupMenu *edit = new QPopupMenu( this ); | 314 | // QPopupMenu *edit = new QPopupMenu( this ); |
315 | 315 | ||
316 | /* | 316 | /* |
317 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 317 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
318 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 318 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
319 | a->addTo( bar ); | 319 | a->addTo( bar ); |
320 | a->addTo( file ); | 320 | a->addTo( file ); |
321 | */ | 321 | */ |
322 | 322 | ||
323 | editorStack = new QWidgetStack( this ); | 323 | editorStack = new QWidgetStack( this ); |
324 | setCentralWidget( editorStack ); | 324 | setCentralWidget( editorStack ); |
325 | 325 | ||
326 | searchVisible = FALSE; | 326 | searchVisible = FALSE; |
327 | regVisible = FALSE; | 327 | regVisible = FALSE; |
328 | m_fontVisible = false; | 328 | m_fontVisible = false; |
329 | 329 | ||
330 | m_annoWin = new CAnnoEdit(editorStack); | 330 | m_annoWin = new CAnnoEdit(editorStack); |
331 | editorStack->addWidget(m_annoWin, get_unique_id()); | 331 | editorStack->addWidget(m_annoWin, get_unique_id()); |
332 | connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); | 332 | connect( m_annoWin, SIGNAL( finished(const QString&,const QString&) ), this, SLOT( addAnno(const QString&,const QString&) ) ); |
333 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); | 333 | connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); |
334 | 334 | ||
335 | m_infoWin = new infowin(editorStack); | 335 | m_infoWin = new infowin(editorStack); |
336 | editorStack->addWidget(m_infoWin, get_unique_id()); | 336 | editorStack->addWidget(m_infoWin, get_unique_id()); |
337 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); | 337 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); |
338 | 338 | ||
339 | m_graphicwin = new GraphicWin(editorStack); | 339 | m_graphicwin = new GraphicWin(editorStack); |
340 | editorStack->addWidget(m_graphicwin, get_unique_id()); | 340 | editorStack->addWidget(m_graphicwin, get_unique_id()); |
341 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); | 341 | connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); |
342 | 342 | ||
343 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); | 343 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); |
344 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); | 344 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); |
345 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); | 345 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); |
346 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); | 346 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); |
347 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); | 347 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); |
348 | editorStack->addWidget( bkmkselector, get_unique_id() ); | 348 | editorStack->addWidget( bkmkselector, get_unique_id() ); |
349 | 349 | ||
350 | /* | 350 | /* |
351 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); | 351 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); |
352 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); | 352 | connect( importSelector, SIGNAL( fileSelected(const DocLnk&) ), this, SLOT( importFile(const DocLnk&) ) ); |
353 | 353 | ||
354 | editorStack->addWidget( importSelector, get_unique_id() ); | 354 | editorStack->addWidget( importSelector, get_unique_id() ); |
355 | 355 | ||
356 | // don't need the close visible, it is redundant... | 356 | // don't need the close visible, it is redundant... |
357 | importSelector->setCloseVisible( FALSE ); | 357 | importSelector->setCloseVisible( FALSE ); |
358 | */ | 358 | */ |
359 | // qDebug("Reading file list"); | 359 | // qDebug("Reading file list"); |
360 | readfilelist(); | 360 | readfilelist(); |
361 | 361 | ||
362 | reader = new QTReader( editorStack ); | 362 | reader = new QTReader( editorStack ); |
363 | 363 | ||
364 | reader->bDoUpdates = false; | 364 | reader->bDoUpdates = false; |
365 | 365 | ||
366 | #ifdef USEQPE | 366 | #ifdef USEQPE |
367 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); | 367 | ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); |
368 | #endif | 368 | #endif |
369 | 369 | ||
370 | // qDebug("Reading config"); | 370 | // qDebug("Reading config"); |
371 | // Config config( APPDIR ); | 371 | // Config config( APPDIR ); |
372 | config.setGroup( "View" ); | 372 | config.setGroup( "View" ); |
373 | m_debounce = config.readNumEntry("Debounce", 0); | 373 | m_debounce = config.readNumEntry("Debounce", 0); |
374 | #ifdef USEQPE | 374 | #ifdef USEQPE |
375 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); | 375 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); |
376 | #else | 376 | #else |
377 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); | 377 | m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); |
378 | #endif | 378 | #endif |
379 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); | 379 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); |
380 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); | 380 | reader->bfulljust = config.readBoolEntry( "FullJust", false ); |
381 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); | 381 | reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); |
382 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); | 382 | reader->setlead(config.readNumEntry( "ExtraLead", 0 )); |
383 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); | 383 | reader->btextfmt = config.readBoolEntry( "TextFmt", false ); |
384 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); | 384 | reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); |
385 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 385 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); |
386 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); | 386 | reader->bpeanut = config.readBoolEntry( "Peanut", false ); |
387 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 387 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
388 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); | 388 | reader->bdepluck = config.readBoolEntry( "Depluck", false ); |
389 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); | 389 | reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); |
390 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); | 390 | reader->bonespace = config.readBoolEntry( "OneSpace", false ); |
391 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 391 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
392 | reader->brepara = config.readBoolEntry( "Repara", false ); | 392 | reader->brepara = config.readBoolEntry( "Repara", false ); |
393 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 393 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); |
394 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 394 | reader->bindenter = config.readNumEntry( "Indent", 0 ); |
395 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 395 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); |
396 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 396 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); |
397 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 397 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); |
398 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 398 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
399 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 399 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
400 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 400 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
401 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); | 401 | reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); |
402 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 402 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
403 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 403 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
404 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 404 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
405 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 405 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
406 | reader->m_border = config.readNumEntry( "Margin", 6 ); | 406 | reader->m_border = config.readNumEntry( "Margin", 6 ); |
407 | #ifdef REPALM | 407 | #ifdef REPALM |
408 | reader->brepalm = config.readBoolEntry( "Repalm", true ); | 408 | reader->brepalm = config.readBoolEntry( "Repalm", true ); |
409 | #endif | 409 | #endif |
410 | reader->bremap = config.readBoolEntry( "Remap", true ); | 410 | reader->bremap = config.readBoolEntry( "Remap", true ); |
411 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); | 411 | reader->bmakebold = config.readBoolEntry( "MakeBold", false ); |
412 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); | 412 | reader->setContinuous(config.readBoolEntry( "Continuous", true )); |
413 | m_targetapp = config.readEntry( "TargetApp", QString::null ); | 413 | m_targetapp = config.readEntry( "TargetApp", QString::null ); |
414 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 414 | m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
415 | #ifdef _SCROLLPIPE | 415 | #ifdef _SCROLLPIPE |
416 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); | 416 | reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); |
417 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); | 417 | reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); |
418 | #endif | 418 | #endif |
419 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); | 419 | m_twoTouch = config.readBoolEntry( "TwoTouch", false); |
420 | m_doAnnotation = config.readBoolEntry( "Annotation", false); | 420 | m_doAnnotation = config.readBoolEntry( "Annotation", false); |
421 | m_doDictionary = config.readBoolEntry( "Dictionary", false); | 421 | m_doDictionary = config.readBoolEntry( "Dictionary", false); |
422 | m_doClipboard = config.readBoolEntry( "Clipboard", false); | 422 | m_doClipboard = config.readBoolEntry( "Clipboard", false); |
423 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); | 423 | m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); |
424 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); | 424 | m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); |
425 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); | 425 | m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); |
426 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); | 426 | m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); |
427 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); | 427 | m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); |
428 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); | 428 | m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); |
429 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); | 429 | m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); |
430 | 430 | ||
431 | m_leftScroll = config.readBoolEntry("LeftScroll", false); | 431 | m_leftScroll = config.readBoolEntry("LeftScroll", false); |
432 | m_rightScroll = config.readBoolEntry("RightScroll", false); | 432 | m_rightScroll = config.readBoolEntry("RightScroll", false); |
433 | m_upScroll = config.readBoolEntry("UpScroll", true); | 433 | m_upScroll = config.readBoolEntry("UpScroll", true); |
434 | m_downScroll = config.readBoolEntry("DownScroll", true); | 434 | m_downScroll = config.readBoolEntry("DownScroll", true); |
435 | 435 | ||
436 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); | 436 | m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); |
437 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); | 437 | reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); |
438 | 438 | ||
439 | #ifndef USEQPE | 439 | #ifndef USEQPE |
440 | config.setGroup( "Geometry" ); | 440 | config.setGroup( "Geometry" ); |
441 | setGeometry(0,0, | 441 | setGeometry(0,0, |
442 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), | 442 | config.readNumEntry( "width", QApplication::desktop()->width()/2 ), |
443 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); | 443 | config.readNumEntry( "height", QApplication::desktop()->height()/2 )); |
444 | move( | 444 | move( |
445 | config.readNumEntry( "x", 20 ), | 445 | config.readNumEntry( "x", 20 ), |
446 | config.readNumEntry( "y", 20 )); | 446 | config.readNumEntry( "y", 20 )); |
447 | #endif | 447 | #endif |
448 | 448 | ||
449 | 449 | ||
450 | 450 | ||
451 | setTwoTouch(m_twoTouch); | 451 | setTwoTouch(m_twoTouch); |
452 | 452 | ||
453 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); | 453 | connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); |
454 | 454 | ||
455 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); | 455 | connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); |
456 | connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, const QString&) ) ); | 456 | connect( reader, SIGNAL( OnWordSelected(const QString&,size_t,const QString&) ), this, SLOT( OnWordSelected(const QString&,size_t,const QString&) ) ); |
457 | connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) ); | 457 | connect( reader, SIGNAL( OnURLSelected(const QString&) ), this, SLOT( OnURLSelected(const QString&) ) ); |
458 | editorStack->addWidget( reader, get_unique_id() ); | 458 | editorStack->addWidget( reader, get_unique_id() ); |
459 | 459 | ||
460 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); | 460 | m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); |
461 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); | 461 | connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); |
462 | m_preferences_action->addTo( settings ); | 462 | m_preferences_action->addTo( settings ); |
463 | 463 | ||
464 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); | 464 | m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); |
465 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); | 465 | connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); |
466 | m_saveconfig_action->addTo( settings ); | 466 | m_saveconfig_action->addTo( settings ); |
467 | 467 | ||
468 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); | 468 | m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); |
469 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); | 469 | connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); |
470 | m_loadconfig_action->addTo( settings ); | 470 | m_loadconfig_action->addTo( settings ); |
471 | 471 | ||
472 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); | 472 | m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); |
473 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); | 473 | connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); |
474 | m_tidyconfig_action->addTo( settings ); | 474 | m_tidyconfig_action->addTo( settings ); |
475 | 475 | ||
476 | settings->insertSeparator(); | 476 | settings->insertSeparator(); |
477 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); | 477 | m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); |
478 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); | 478 | connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); |
479 | m_toolbarprefs_action->addTo( settings ); | 479 | m_toolbarprefs_action->addTo( settings ); |
480 | 480 | ||
481 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); | 481 | m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); |
482 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 482 | connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
483 | m_open_action->addTo( file ); | 483 | m_open_action->addTo( file ); |
484 | 484 | ||
485 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); | 485 | m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); |
486 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); | 486 | connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); |
487 | m_close_action->addTo( file ); | 487 | m_close_action->addTo( file ); |
488 | 488 | ||
489 | #ifdef _SCRIPT | 489 | #ifdef _SCRIPT |
490 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); | 490 | a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); |
491 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); | 491 | connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); |
492 | a->addTo( file ); | 492 | a->addTo( file ); |
493 | #endif | 493 | #endif |
494 | /* | 494 | /* |
495 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); | 495 | a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); |
496 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); | 496 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); |
497 | a->addTo( file ); | 497 | a->addTo( file ); |
498 | 498 | ||
499 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); | 499 | a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); |
500 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 500 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
501 | a->addTo( filebar() ); | 501 | a->addTo( filebar() ); |
502 | a->addTo( edit ); | 502 | a->addTo( edit ); |
503 | */ | 503 | */ |
504 | 504 | ||
505 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); | 505 | m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); |
506 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); | 506 | connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); |
507 | m_info_action->addTo( file ); | 507 | m_info_action->addTo( file ); |
508 | 508 | ||
509 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); | 509 | m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); |
510 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); | 510 | connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); |
511 | m_touch_action->setOn(m_twoTouch); | 511 | m_touch_action->setOn(m_twoTouch); |
512 | m_touch_action->addTo( file ); | 512 | m_touch_action->addTo( file ); |
513 | 513 | ||
514 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); | 514 | m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); |
515 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 515 | connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
516 | file->insertSeparator(); | 516 | file->insertSeparator(); |
517 | // a->addTo( bar ); | 517 | // a->addTo( bar ); |
518 | m_find_action->addTo( file ); | 518 | m_find_action->addTo( file ); |
519 | 519 | ||
520 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); | 520 | m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); |
521 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); | 521 | connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); |
522 | m_exportlinks_action->addTo( file ); | 522 | m_exportlinks_action->addTo( file ); |
523 | 523 | ||
524 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); | 524 | m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); |
525 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); | 525 | connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); |
526 | m_scrollButton->addTo(navigation); | 526 | m_scrollButton->addTo(navigation); |
527 | m_scrollButton->setOn(false); | 527 | m_scrollButton->setOn(false); |
528 | 528 | ||
529 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); | 529 | m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); |
530 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); | 530 | connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); |
531 | m_start_action->addTo(navigation); | 531 | m_start_action->addTo(navigation); |
532 | 532 | ||
533 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); | 533 | m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); |
534 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); | 534 | connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); |
535 | m_end_action->addTo(navigation); | 535 | m_end_action->addTo(navigation); |
536 | 536 | ||
537 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); | 537 | m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); |
538 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); | 538 | connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); |
539 | m_jump_action->addTo(navigation); | 539 | m_jump_action->addTo(navigation); |
540 | 540 | ||
541 | m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); | 541 | m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); |
542 | connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | 542 | connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); |
543 | m_pageline_action->addTo(navigation); | 543 | m_pageline_action->addTo(navigation); |
544 | m_pageline_action->setOn(reader->m_bpagemode); | 544 | m_pageline_action->setOn(reader->m_bpagemode); |
545 | 545 | ||
546 | m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); | 546 | m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); |
547 | connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); | 547 | connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); |
548 | m_pageup_action->addTo( navigation ); | 548 | m_pageup_action->addTo( navigation ); |
549 | 549 | ||
550 | m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); | 550 | m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); |
551 | connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 551 | connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
552 | m_pagedn_action->addTo( navigation ); | 552 | m_pagedn_action->addTo( navigation ); |
@@ -633,266 +633,266 @@ QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | |||
633 | view->insertSeparator(); | 633 | view->insertSeparator(); |
634 | m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); | 634 | m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); |
635 | connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); | 635 | connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); |
636 | m_setenc_action->addTo( view ); | 636 | m_setenc_action->addTo( view ); |
637 | 637 | ||
638 | m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); | 638 | m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); |
639 | connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 639 | connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
640 | m_setmono_action->addTo( view ); | 640 | m_setmono_action->addTo( view ); |
641 | m_setmono_action->setOn(reader->m_bMonoSpaced); | 641 | m_setmono_action->setOn(reader->m_bMonoSpaced); |
642 | 642 | ||
643 | 643 | ||
644 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); | 644 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); |
645 | // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); | 645 | // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); |
646 | 646 | ||
647 | 647 | ||
648 | 648 | ||
649 | // a->addTo( filebar() ); | 649 | // a->addTo( filebar() ); |
650 | // view->insertSeparator(); | 650 | // view->insertSeparator(); |
651 | 651 | ||
652 | /* | 652 | /* |
653 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); | 653 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); |
654 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 654 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
655 | a->setOn(reader->m_bMonoSpaced); | 655 | a->setOn(reader->m_bMonoSpaced); |
656 | a->addTo( view ); | 656 | a->addTo( view ); |
657 | */ | 657 | */ |
658 | /* | 658 | /* |
659 | a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); | 659 | a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); |
660 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); | 660 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); |
661 | a->addTo( view ); | 661 | a->addTo( view ); |
662 | */ | 662 | */ |
663 | 663 | ||
664 | m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); | 664 | m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); |
665 | connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); | 665 | connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); |
666 | m_mark_action->addTo( marks ); | 666 | m_mark_action->addTo( marks ); |
667 | 667 | ||
668 | m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); | 668 | m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); |
669 | connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); | 669 | connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); |
670 | m_annotate_action->addTo( marks ); | 670 | m_annotate_action->addTo( marks ); |
671 | 671 | ||
672 | m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); | 672 | m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); |
673 | connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); | 673 | connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); |
674 | m_goto_action->addTo( marks ); | 674 | m_goto_action->addTo( marks ); |
675 | 675 | ||
676 | m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); | 676 | m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); |
677 | connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); | 677 | connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); |
678 | m_delete_action->addTo( marks ); | 678 | m_delete_action->addTo( marks ); |
679 | 679 | ||
680 | m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); | 680 | m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); |
681 | connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); | 681 | connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); |
682 | marks->insertSeparator(); | 682 | marks->insertSeparator(); |
683 | m_autogen_action->addTo( marks ); | 683 | m_autogen_action->addTo( marks ); |
684 | 684 | ||
685 | m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); | 685 | m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); |
686 | connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); | 686 | connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); |
687 | m_clear_action->addTo( marks ); | 687 | m_clear_action->addTo( marks ); |
688 | 688 | ||
689 | m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); | 689 | m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); |
690 | connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); | 690 | connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); |
691 | m_save_action->addTo( marks ); | 691 | m_save_action->addTo( marks ); |
692 | 692 | ||
693 | m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); | 693 | m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); |
694 | connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); | 694 | connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); |
695 | marks->insertSeparator(); | 695 | marks->insertSeparator(); |
696 | m_tidy_action->addTo( marks ); | 696 | m_tidy_action->addTo( marks ); |
697 | 697 | ||
698 | m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); | 698 | m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); |
699 | connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); | 699 | connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); |
700 | marks->insertSeparator(); | 700 | marks->insertSeparator(); |
701 | m_startBlock_action->addTo( marks ); | 701 | m_startBlock_action->addTo( marks ); |
702 | 702 | ||
703 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); | 703 | m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); |
704 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 704 | connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
705 | m_endBlock_action->addTo( marks ); | 705 | m_endBlock_action->addTo( marks ); |
706 | 706 | ||
707 | m_bkmkAvail = NULL; | 707 | m_bkmkAvail = NULL; |
708 | 708 | ||
709 | 709 | ||
710 | setToolBarsMovable(m_tbmove); | 710 | setToolBarsMovable(m_tbmove); |
711 | addtoolbars(&config); | 711 | addtoolbars(&config); |
712 | 712 | ||
713 | pbar = new QProgressBar(this); | 713 | pbar = new QProgressBar(this); |
714 | pbar->hide(); | 714 | pbar->hide(); |
715 | 715 | ||
716 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 716 | searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
717 | 717 | ||
718 | searchBar->setHorizontalStretchable( TRUE ); | 718 | searchBar->setHorizontalStretchable( TRUE ); |
719 | 719 | ||
720 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | 720 | connect(searchBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); |
721 | 721 | ||
722 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 722 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
723 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 723 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
724 | // searchEdit->setFont( f ); | 724 | // searchEdit->setFont( f ); |
725 | searchBar->setStretchableWidget( searchEdit ); | 725 | searchBar->setStretchableWidget( searchEdit ); |
726 | 726 | ||
727 | 727 | ||
728 | #ifdef __ISEARCH | 728 | #ifdef __ISEARCH |
729 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 729 | connect( searchEdit, SIGNAL( textChanged(const QString&) ), |
730 | this, SLOT( search( const QString& ) ) ); | 730 | this, SLOT( search(const QString&) ) ); |
731 | #else | 731 | #else |
732 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 732 | connect( searchEdit, SIGNAL( returnPressed() ), |
733 | this, SLOT( search( ) ) ); | 733 | this, SLOT( search() ) ); |
734 | #endif | 734 | #endif |
735 | QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); | 735 | QAction*a = new QAction( tr( "Find Next" ), geticon( "next" ), QString::null, 0, this, 0 ); |
736 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 736 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
737 | a->addTo( searchBar ); | 737 | a->addTo( searchBar ); |
738 | 738 | ||
739 | a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); | 739 | a = new QAction( tr( "Close Find" ), geticon( "close" ), QString::null, 0, this, 0 ); |
740 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 740 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
741 | a->addTo( searchBar ); | 741 | a->addTo( searchBar ); |
742 | 742 | ||
743 | searchBar->hide(); | 743 | searchBar->hide(); |
744 | 744 | ||
745 | regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); | 745 | regBar = new QFloatBar( "Autogen", this, QMainWindow::Top, TRUE ); |
746 | connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); | 746 | connect(regBar, SIGNAL( OnHide() ), this, SLOT( restoreFocus() )); |
747 | 747 | ||
748 | regBar->setHorizontalStretchable( TRUE ); | 748 | regBar->setHorizontalStretchable( TRUE ); |
749 | 749 | ||
750 | regEdit = new QLineEdit( regBar, "regEdit" ); | 750 | regEdit = new QLineEdit( regBar, "regEdit" ); |
751 | // regEdit->setFont( f ); | 751 | // regEdit->setFont( f ); |
752 | 752 | ||
753 | regBar->setStretchableWidget( regEdit ); | 753 | regBar->setStretchableWidget( regEdit ); |
754 | 754 | ||
755 | connect( regEdit, SIGNAL( returnPressed( ) ), | 755 | connect( regEdit, SIGNAL( returnPressed() ), |
756 | this, SLOT( do_regaction() ) ); | 756 | this, SLOT( do_regaction() ) ); |
757 | 757 | ||
758 | a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); | 758 | a = new QAction( tr( "Do Reg" ), geticon( "enter" ), QString::null, 0, this, 0 ); |
759 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); | 759 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); |
760 | a->addTo( regBar ); | 760 | a->addTo( regBar ); |
761 | 761 | ||
762 | a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); | 762 | a = new QAction( tr( "Close Edit" ), geticon( "close" ), QString::null, 0, this, 0 ); |
763 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); | 763 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); |
764 | a->addTo( regBar ); | 764 | a->addTo( regBar ); |
765 | 765 | ||
766 | regBar->hide(); | 766 | regBar->hide(); |
767 | 767 | ||
768 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); | 768 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); |
769 | 769 | ||
770 | m_fontBar->setHorizontalStretchable( TRUE ); | 770 | m_fontBar->setHorizontalStretchable( TRUE ); |
771 | 771 | ||
772 | // qDebug("Font selector"); | 772 | // qDebug("Font selector"); |
773 | m_fontSelector = new QComboBox(false, m_fontBar); | 773 | m_fontSelector = new QComboBox(false, m_fontBar); |
774 | m_fontBar->setStretchableWidget( m_fontSelector ); | 774 | m_fontBar->setStretchableWidget( m_fontSelector ); |
775 | { | 775 | { |
776 | #ifndef USEQPE | 776 | #ifndef USEQPE |
777 | QFontDatabase f; | 777 | QFontDatabase f; |
778 | #else | 778 | #else |
779 | FontDatabase f; | 779 | FontDatabase f; |
780 | #endif | 780 | #endif |
781 | QStringList flist = f.families(); | 781 | QStringList flist = f.families(); |
782 | bool realfont = false; | 782 | bool realfont = false; |
783 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) | 783 | for (QStringList::Iterator nm = flist.begin(); nm != flist.end(); nm++) |
784 | { | 784 | { |
785 | if (reader->m_fontname == *nm) | 785 | if (reader->m_fontname == *nm) |
786 | { | 786 | { |
787 | realfont = true; | 787 | realfont = true; |
788 | } | 788 | } |
789 | if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); | 789 | if ((*nm).contains(FIXEDFONT,false)) reader->m_fontControl.hasCourier(true, *nm); |
790 | } | 790 | } |
791 | if (!realfont) reader->m_fontname = flist[0]; | 791 | if (!realfont) reader->m_fontname = flist[0]; |
792 | } // delete the FontDatabase!!! | 792 | } // delete the FontDatabase!!! |
793 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), | 793 | connect( m_fontSelector, SIGNAL( activated(const QString&) ), |
794 | this, SLOT( do_setfont(const QString&) ) ); | 794 | this, SLOT( do_setfont(const QString&) ) ); |
795 | connect( m_fontSelector, SIGNAL( activated(int ) ), | 795 | connect( m_fontSelector, SIGNAL( activated(int) ), |
796 | this, SLOT( do_setencoding(int) ) ); | 796 | this, SLOT( do_setencoding(int) ) ); |
797 | 797 | ||
798 | m_fontBar->hide(); | 798 | m_fontBar->hide(); |
799 | m_fontVisible = false; | 799 | m_fontVisible = false; |
800 | #ifdef USEMSGS | 800 | #ifdef USEMSGS |
801 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), | 801 | connect(qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), |
802 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); | 802 | this, SLOT( msgHandler(const QCString&,const QByteArray&) ) ); |
803 | #endif | 803 | #endif |
804 | // qDebug("Initing"); | 804 | // qDebug("Initing"); |
805 | reader->init(); | 805 | reader->init(); |
806 | // qDebug("Inited"); | 806 | // qDebug("Inited"); |
807 | // m_buttonAction[m_spaceTarget]->setOn(true); | 807 | // m_buttonAction[m_spaceTarget]->setOn(true); |
808 | // qDebug("fonting"); | 808 | // qDebug("fonting"); |
809 | do_setfont(reader->m_fontname); | 809 | do_setfont(reader->m_fontname); |
810 | if (!reader->m_lastfile.isEmpty()) | 810 | if (!reader->m_lastfile.isEmpty()) |
811 | { | 811 | { |
812 | //qDebug("doclnk"); | 812 | //qDebug("doclnk"); |
813 | //doc = new DocLnk(reader->m_lastfile); | 813 | //doc = new DocLnk(reader->m_lastfile); |
814 | //qDebug("doclnk done"); | 814 | //qDebug("doclnk done"); |
815 | if (pOpenlist != NULL) | 815 | if (pOpenlist != NULL) |
816 | { | 816 | { |
817 | 817 | ||
818 | /* | 818 | /* |
819 | int ind = 0; | 819 | int ind = 0; |
820 | Bkmk* p = (*pOpenlist)[ind]; | 820 | Bkmk* p = (*pOpenlist)[ind]; |
821 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) | 821 | while (p != NULL && toQString(CFiledata(p->anno()).name()) != reader->m_lastfile) |
822 | { | 822 | { |
823 | p = (*pOpenlist)[++ind]; | 823 | p = (*pOpenlist)[++ind]; |
824 | } | 824 | } |
825 | */ | 825 | */ |
826 | Bkmk* p = NULL; | 826 | Bkmk* p = NULL; |
827 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) | 827 | for (CList<Bkmk>::iterator iter = pOpenlist->begin(); iter != pOpenlist->end(); iter++) |
828 | { | 828 | { |
829 | p = iter.pContent(); | 829 | p = iter.pContent(); |
830 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) | 830 | if (toQString(CFiledata(p->anno()).name()) == reader->m_lastfile) |
831 | { | 831 | { |
832 | break; | 832 | break; |
833 | } | 833 | } |
834 | // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); | 834 | // qDebug("Item:%s", (const char*)toQString(CFiledata(p->anno()).name())); |
835 | p = NULL; | 835 | p = NULL; |
836 | } | 836 | } |
837 | if (p != NULL) | 837 | if (p != NULL) |
838 | { | 838 | { |
839 | //qDebug("openfrombkmk"); | 839 | //qDebug("openfrombkmk"); |
840 | if (!openfrombkmk(p)) | 840 | if (!openfrombkmk(p)) |
841 | showEditTools(); | 841 | showEditTools(); |
842 | } | 842 | } |
843 | else | 843 | else |
844 | { | 844 | { |
845 | //qDebug("openfile"); | 845 | //qDebug("openfile"); |
846 | openFile( reader->m_lastfile ); | 846 | openFile( reader->m_lastfile ); |
847 | } | 847 | } |
848 | } | 848 | } |
849 | else | 849 | else |
850 | { | 850 | { |
851 | // qDebug("Openfile 2"); | 851 | // qDebug("Openfile 2"); |
852 | if (!reader->m_lastfile.isEmpty()) | 852 | if (!reader->m_lastfile.isEmpty()) |
853 | openFile( reader->m_lastfile ); | 853 | openFile( reader->m_lastfile ); |
854 | } | 854 | } |
855 | } | 855 | } |
856 | else | 856 | else |
857 | { | 857 | { |
858 | showEditTools(); | 858 | showEditTools(); |
859 | } | 859 | } |
860 | // qApp->processEvents(); | 860 | // qApp->processEvents(); |
861 | reader->bDoUpdates = true; | 861 | reader->bDoUpdates = true; |
862 | reader->update(); | 862 | reader->update(); |
863 | config.setGroup("Version"); | 863 | config.setGroup("Version"); |
864 | int major = config.readNumEntry("Major", 0); | 864 | int major = config.readNumEntry("Major", 0); |
865 | int bkmktype = config.readNumEntry("BkmkType", 0); | 865 | int bkmktype = config.readNumEntry("BkmkType", 0); |
866 | char minor = config.readNumEntry("Minor", 0); | 866 | char minor = config.readNumEntry("Minor", 0); |
867 | if (CheckVersion(major, bkmktype, minor)) | 867 | if (CheckVersion(major, bkmktype, minor)) |
868 | { | 868 | { |
869 | config.writeEntry("Major", major); | 869 | config.writeEntry("Major", major); |
870 | config.writeEntry("BkmkType", bkmktype); | 870 | config.writeEntry("BkmkType", bkmktype); |
871 | config.writeEntry("Minor", (int)minor); | 871 | config.writeEntry("Minor", (int)minor); |
872 | } | 872 | } |
873 | // qDebug("finished update"); | 873 | // qDebug("finished update"); |
874 | } | 874 | } |
875 | 875 | ||
876 | void QTReaderApp::addtoolbars(Config* config) | 876 | void QTReaderApp::addtoolbars(Config* config) |
877 | { | 877 | { |
878 | config->setGroup("Toolbar"); | 878 | config->setGroup("Toolbar"); |
879 | 879 | ||
880 | if (fileBar != NULL) | 880 | if (fileBar != NULL) |
881 | { | 881 | { |
882 | if (fileBar != menubar) | 882 | if (fileBar != menubar) |
883 | { | 883 | { |
884 | fileBar->clear(); | 884 | fileBar->clear(); |
885 | } | 885 | } |
886 | else | 886 | else |
887 | { | 887 | { |
888 | m_preferences_action->removeFrom( filebar() ); | 888 | m_preferences_action->removeFrom( filebar() ); |
889 | m_open_action->removeFrom( filebar() ); | 889 | m_open_action->removeFrom( filebar() ); |
890 | m_close_action->removeFrom( filebar() ); | 890 | m_close_action->removeFrom( filebar() ); |
891 | m_info_action->removeFrom( filebar() ); | 891 | m_info_action->removeFrom( filebar() ); |
892 | m_touch_action->removeFrom( filebar() ); | 892 | m_touch_action->removeFrom( filebar() ); |
893 | m_find_action->removeFrom( filebar() ); | 893 | m_find_action->removeFrom( filebar() ); |
894 | } | 894 | } |
895 | } | 895 | } |
896 | 896 | ||
897 | m_preferences_action->addTo( filebar() ); | 897 | m_preferences_action->addTo( filebar() ); |
898 | addfilebar(config, "Open", m_open_action); | 898 | addfilebar(config, "Open", m_open_action); |
diff --git a/noncore/apps/opie-reader/fileBrowser.cpp b/noncore/apps/opie-reader/fileBrowser.cpp index ebd14f3..e1cde6c 100644 --- a/noncore/apps/opie-reader/fileBrowser.cpp +++ b/noncore/apps/opie-reader/fileBrowser.cpp | |||
@@ -1,176 +1,176 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | 2 | ||
3 | Derived from a file browser which was | 3 | Derived from a file browser which was |
4 | 4 | ||
5 | ** copyright 2001 ljp ljp@llornkcor.com | 5 | ** copyright 2001 ljp ljp@llornkcor.com |
6 | 6 | ||
7 | Extensive modification by Tim Wentford to allow it to work in rotated mode | 7 | Extensive modification by Tim Wentford to allow it to work in rotated mode |
8 | 8 | ||
9 | ****************************************************************************/ | 9 | ****************************************************************************/ |
10 | #include "fileBrowser.h" | 10 | #include "fileBrowser.h" |
11 | 11 | ||
12 | #include "QtrListView.h" | 12 | #include "QtrListView.h" |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qpushbutton.h> | 14 | #include <qpushbutton.h> |
15 | #ifndef _WINDOWS | 15 | #ifndef _WINDOWS |
16 | #include <unistd.h> | 16 | #include <unistd.h> |
17 | #endif | 17 | #endif |
18 | #include <qlayout.h> | 18 | #include <qlayout.h> |
19 | #ifdef _WINDOWS | 19 | #ifdef _WINDOWS |
20 | #include <direct.h> | 20 | #include <direct.h> |
21 | #endif | 21 | #endif |
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | 24 | ||
25 | 25 | ||
26 | fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) | 26 | fileBrowser::fileBrowser( bool allownew, QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter, const QString iPath ) |
27 | : QDialog( parent, name, true, | 27 | : QDialog( parent, name, true, |
28 | fl/* | WStyle_Customize | WStyle_Tool*/), | 28 | fl/* | WStyle_Customize | WStyle_Tool*/), |
29 | filterspec(QDir::All) | 29 | filterspec(QDir::All) |
30 | { | 30 | { |
31 | // showMaximized(); | 31 | // showMaximized(); |
32 | if ( !name ) | 32 | if ( !name ) |
33 | setName( "fileBrowser" ); | 33 | setName( "fileBrowser" ); |
34 | /* | 34 | /* |
35 | if (parent != NULL) | 35 | if (parent != NULL) |
36 | { | 36 | { |
37 | #ifdef OPIE | 37 | #ifdef OPIE |
38 | move(0,0); | 38 | move(0,0); |
39 | resize( parent->width(), parent->height() ); | 39 | resize( parent->width(), parent->height() ); |
40 | #else | 40 | #else |
41 | setGeometry(parent->x(), parent->y(), parent->width(), parent->height() ); | 41 | setGeometry(parent->x(), parent->y(), parent->width(), parent->height() ); |
42 | #endif | 42 | #endif |
43 | } | 43 | } |
44 | */ | 44 | */ |
45 | // showFullScreen(); | 45 | // showFullScreen(); |
46 | setCaption(tr( "Browse for file" ) ); | 46 | setCaption(tr( "Browse for file" ) ); |
47 | filterStr=filter; | 47 | filterStr=filter; |
48 | 48 | ||
49 | buttonOk = new QPushButton( this, "buttonOk" ); | 49 | buttonOk = new QPushButton( this, "buttonOk" ); |
50 | buttonOk->setFixedSize( 25, 25 ); | 50 | buttonOk->setFixedSize( 25, 25 ); |
51 | buttonOk->setAutoDefault( false ); | 51 | buttonOk->setAutoDefault( false ); |
52 | buttonOk->setText( tr( "/" ) ); | 52 | buttonOk->setText( tr( "/" ) ); |
53 | 53 | ||
54 | buttonShowHidden = new QPushButton( this, "buttonShowHidden" ); | 54 | buttonShowHidden = new QPushButton( this, "buttonShowHidden" ); |
55 | // buttonShowHidden->setFixedSize( 50, 25 ); | 55 | // buttonShowHidden->setFixedSize( 50, 25 ); |
56 | buttonShowHidden->setText( tr( "Hidden" ) ); | 56 | buttonShowHidden->setText( tr( "Hidden" ) ); |
57 | buttonShowHidden->setAutoDefault( false ); | 57 | buttonShowHidden->setAutoDefault( false ); |
58 | buttonShowHidden->setToggleButton( true ); | 58 | buttonShowHidden->setToggleButton( true ); |
59 | buttonShowHidden->setOn( false ); | 59 | buttonShowHidden->setOn( false ); |
60 | 60 | ||
61 | dirLabel = new QLabel(this, "DirLabel"); | 61 | dirLabel = new QLabel(this, "DirLabel"); |
62 | dirLabel->setAlignment(AlignLeft | AlignVCenter | ExpandTabs | WordBreak); | 62 | dirLabel->setAlignment(AlignLeft | AlignVCenter | ExpandTabs | WordBreak); |
63 | dirLabel->setText(currentDir.canonicalPath()); | 63 | dirLabel->setText(currentDir.canonicalPath()); |
64 | 64 | ||
65 | ListView = new QtrListView( this, "ListView" ); | 65 | ListView = new QtrListView( this, "ListView" ); |
66 | ListView->addColumn( tr( "Name" ) ); | 66 | ListView->addColumn( tr( "Name" ) ); |
67 | ListView->setSorting( 2, FALSE); | 67 | ListView->setSorting( 2, FALSE); |
68 | ListView->addColumn( tr( "Size" ) ); | 68 | ListView->addColumn( tr( "Size" ) ); |
69 | ListView->setSelectionMode(QListView::Single); | 69 | ListView->setSelectionMode(QListView::Single); |
70 | ListView->setAllColumnsShowFocus( TRUE ); | 70 | ListView->setAllColumnsShowFocus( TRUE ); |
71 | ListView->setColumnWidthMode(0, QListView::Manual); | 71 | ListView->setColumnWidthMode(0, QListView::Manual); |
72 | ListView->setColumnWidthMode(1, QListView::Manual); | 72 | ListView->setColumnWidthMode(1, QListView::Manual); |
73 | 73 | ||
74 | // signals and slots connections | 74 | // signals and slots connections |
75 | connect( buttonShowHidden, SIGNAL( toggled(bool) ), this, SLOT( setHidden(bool) ) ); | 75 | connect( buttonShowHidden, SIGNAL( toggled(bool) ), this, SLOT( setHidden(bool) ) ); |
76 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnRoot() ) ); | 76 | connect( buttonOk, SIGNAL( clicked() ), this, SLOT( OnRoot() ) ); |
77 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); | 77 | connect( ListView, SIGNAL(doubleClicked(QListViewItem*)), SLOT(listDoubleClicked(QListViewItem*)) ); |
78 | connect( ListView, SIGNAL(clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 78 | connect( ListView, SIGNAL(clicked(QListViewItem*)), SLOT(listClicked(QListViewItem*)) ); |
79 | connect( ListView, SIGNAL(OnOKButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 79 | connect( ListView, SIGNAL(OnOKButton(QListViewItem*)), SLOT(listClicked(QListViewItem*)) ); |
80 | connect( ListView, SIGNAL(OnCentreButton( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 80 | connect( ListView, SIGNAL(OnCentreButton(QListViewItem*)), SLOT(listClicked(QListViewItem*)) ); |
81 | connect( ListView, SIGNAL(OnCancelButton()), SLOT(OnCancel()) ); | 81 | connect( ListView, SIGNAL(OnCancelButton()), SLOT(OnCancel()) ); |
82 | 82 | ||
83 | QVBoxLayout* grid = new QVBoxLayout(this); | 83 | QVBoxLayout* grid = new QVBoxLayout(this); |
84 | QHBoxLayout* hgrid = new QHBoxLayout(grid); | 84 | QHBoxLayout* hgrid = new QHBoxLayout(grid); |
85 | hgrid->addWidget(dirLabel,1); | 85 | hgrid->addWidget(dirLabel,1); |
86 | hgrid->addWidget(buttonShowHidden); | 86 | hgrid->addWidget(buttonShowHidden); |
87 | hgrid->addWidget(buttonOk); | 87 | hgrid->addWidget(buttonOk); |
88 | grid->addWidget(ListView,1); | 88 | grid->addWidget(ListView,1); |
89 | if (allownew) | 89 | if (allownew) |
90 | { | 90 | { |
91 | m_filename = new QLineEdit(this); | 91 | m_filename = new QLineEdit(this); |
92 | grid->addWidget(m_filename); | 92 | grid->addWidget(m_filename); |
93 | connect( m_filename, SIGNAL( returnPressed() ), this, SLOT( onReturn() )); | 93 | connect( m_filename, SIGNAL( returnPressed() ), this, SLOT( onReturn() )); |
94 | } | 94 | } |
95 | else | 95 | else |
96 | { | 96 | { |
97 | m_filename = NULL; | 97 | m_filename = NULL; |
98 | } | 98 | } |
99 | 99 | ||
100 | if (QFileInfo(iPath).exists()) | 100 | if (QFileInfo(iPath).exists()) |
101 | { | 101 | { |
102 | currentDir.setPath(iPath); | 102 | currentDir.setPath(iPath); |
103 | #ifdef _WINDOWS | 103 | #ifdef _WINDOWS |
104 | _chdir(iPath.latin1()); | 104 | _chdir(iPath.latin1()); |
105 | #else | 105 | #else |
106 | chdir(iPath.latin1()); | 106 | chdir(iPath.latin1()); |
107 | #endif | 107 | #endif |
108 | } | 108 | } |
109 | else | 109 | else |
110 | { | 110 | { |
111 | currentDir.setPath(QDir::currentDirPath()); | 111 | currentDir.setPath(QDir::currentDirPath()); |
112 | chdir(QDir::currentDirPath().latin1()); | 112 | chdir(QDir::currentDirPath().latin1()); |
113 | } | 113 | } |
114 | 114 | ||
115 | populateList(); | 115 | populateList(); |
116 | 116 | ||
117 | if (modal) | 117 | if (modal) |
118 | QPEApplication::showDialog( this ); | 118 | QPEApplication::showDialog( this ); |
119 | } | 119 | } |
120 | 120 | ||
121 | void fileBrowser::resizeEvent(QResizeEvent* e) | 121 | void fileBrowser::resizeEvent(QResizeEvent* e) |
122 | { | 122 | { |
123 | ListView->setColumnWidth(1,(ListView->width())/4); | 123 | ListView->setColumnWidth(1,(ListView->width())/4); |
124 | ListView->setColumnWidth(0,ListView->width()-20-ListView->columnWidth(1)); | 124 | ListView->setColumnWidth(0,ListView->width()-20-ListView->columnWidth(1)); |
125 | } | 125 | } |
126 | 126 | ||
127 | fileBrowser::~fileBrowser() | 127 | fileBrowser::~fileBrowser() |
128 | { | 128 | { |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | void fileBrowser::populateList() | 132 | void fileBrowser::populateList() |
133 | { | 133 | { |
134 | ListView->clear(); | 134 | ListView->clear(); |
135 | ////qDebug(currentDir.canonicalPath()); | 135 | ////qDebug(currentDir.canonicalPath()); |
136 | // currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); | 136 | // currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks ); |
137 | currentDir.setFilter( filterspec ); | 137 | currentDir.setFilter( filterspec ); |
138 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 138 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
139 | currentDir.setMatchAllDirs(TRUE); | 139 | currentDir.setMatchAllDirs(TRUE); |
140 | 140 | ||
141 | currentDir.setNameFilter(filterStr); | 141 | currentDir.setNameFilter(filterStr); |
142 | // currentDir.setNameFilter("*.txt;*.etx"); | 142 | // currentDir.setNameFilter("*.txt;*.etx"); |
143 | QString fileL, fileS; | 143 | QString fileL, fileS; |
144 | const QFileInfoList *list = currentDir.entryInfoList(); | 144 | const QFileInfoList *list = currentDir.entryInfoList(); |
145 | QFileInfoListIterator it(*list); | 145 | QFileInfoListIterator it(*list); |
146 | QFileInfo *fi; | 146 | QFileInfo *fi; |
147 | while ( (fi=it.current()) ) | 147 | while ( (fi=it.current()) ) |
148 | { | 148 | { |
149 | if (fi->fileName() != ".") | 149 | if (fi->fileName() != ".") |
150 | { | 150 | { |
151 | fileS.sprintf( "%10li", fi->size() ); | 151 | fileS.sprintf( "%10li", fi->size() ); |
152 | fileL.sprintf( "%s",fi->fileName().data() ); | 152 | fileL.sprintf( "%s",fi->fileName().data() ); |
153 | if( fi->isDir() ) | 153 | if( fi->isDir() ) |
154 | { | 154 | { |
155 | fileL+="/"; | 155 | fileL+="/"; |
156 | } | 156 | } |
157 | else | 157 | else |
158 | { | 158 | { |
159 | //// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 159 | //// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
160 | } | 160 | } |
161 | new QListViewItem( ListView,fileL,fileS ); | 161 | new QListViewItem( ListView,fileL,fileS ); |
162 | } | 162 | } |
163 | ++it; | 163 | ++it; |
164 | } | 164 | } |
165 | ListView->setSorting( 2, FALSE); | 165 | ListView->setSorting( 2, FALSE); |
166 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); | 166 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); |
167 | ListView->setFocus(); | 167 | ListView->setFocus(); |
168 | } | 168 | } |
169 | 169 | ||
170 | void fileBrowser::upDir() | 170 | void fileBrowser::upDir() |
171 | { | 171 | { |
172 | //// qDebug(currentDir.canonicalPath()); | 172 | //// qDebug(currentDir.canonicalPath()); |
173 | } | 173 | } |
174 | 174 | ||
175 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 175 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
176 | { | 176 | { |
diff --git a/noncore/apps/opie-sheet/mainwindow.cpp b/noncore/apps/opie-sheet/mainwindow.cpp index 1fb2a3d..061748e 100644 --- a/noncore/apps/opie-sheet/mainwindow.cpp +++ b/noncore/apps/opie-sheet/mainwindow.cpp | |||
@@ -1,142 +1,142 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 11 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 12 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include "mainwindow.h" | 15 | #include "mainwindow.h" |
16 | 16 | ||
17 | #include <qpe/resource.h> | 17 | #include <qpe/resource.h> |
18 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
19 | 19 | ||
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qradiobutton.h> | 21 | #include <qradiobutton.h> |
22 | 22 | ||
23 | #include "cellformat.h" | 23 | #include "cellformat.h" |
24 | #include "numberdlg.h" | 24 | #include "numberdlg.h" |
25 | #include "textdlg.h" | 25 | #include "textdlg.h" |
26 | #include "sortdlg.h" | 26 | #include "sortdlg.h" |
27 | #include "finddlg.h" | 27 | #include "finddlg.h" |
28 | 28 | ||
29 | #define DEFAULT_NUM_ROWS 300 | 29 | #define DEFAULT_NUM_ROWS 300 |
30 | #define DEFAULT_NUM_COLS (26*3) | 30 | #define DEFAULT_NUM_COLS (26*3) |
31 | #define DEFAULT_NUM_SHEETS 3 | 31 | #define DEFAULT_NUM_SHEETS 3 |
32 | 32 | ||
33 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) | 33 | MainWindow::MainWindow(QWidget *parent, const char* n, WFlags fl) |
34 | :QMainWindow(parent, n, fl) | 34 | :QMainWindow(parent, n, fl) |
35 | { | 35 | { |
36 | // initialize variables | 36 | // initialize variables |
37 | documentModified=FALSE; | 37 | documentModified=FALSE; |
38 | 38 | ||
39 | // construct objects | 39 | // construct objects |
40 | currentDoc=0; | 40 | currentDoc=0; |
41 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); | 41 | fileSelector=new FileSelector("application/sheet-qt", this, QString::null); |
42 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); | 42 | ExcelSelector=new FileSelector("application/excel",this,QString::null,FALSE); |
43 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); | 43 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(selectorHide())); |
44 | connect(fileSelector, SIGNAL(newSelected(const DocLnk &)), this, SLOT(selectorFileNew(const DocLnk &))); | 44 | connect(fileSelector, SIGNAL(newSelected(const DocLnk&)), this, SLOT(selectorFileNew(const DocLnk&))); |
45 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), this, SLOT(selectorFileOpen(const DocLnk &))); | 45 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(selectorFileOpen(const DocLnk&))); |
46 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk &)),this,SLOT(slotImportExcel(const DocLnk &))); | 46 | connect(ExcelSelector,SIGNAL(fileSelected(const DocLnk&)),this,SLOT(slotImportExcel(const DocLnk&))); |
47 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); | 47 | connect(ExcelSelector,SIGNAL(closeMe()), this, SLOT(ExcelSelectorHide())); |
48 | 48 | ||
49 | 49 | ||
50 | listSheets.setAutoDelete(TRUE); | 50 | listSheets.setAutoDelete(TRUE); |
51 | 51 | ||
52 | initActions(); | 52 | initActions(); |
53 | initMenu(); | 53 | initMenu(); |
54 | initEditToolbar(); | 54 | initEditToolbar(); |
55 | initFunctionsToolbar(); | 55 | initFunctionsToolbar(); |
56 | initStandardToolbar(); | 56 | initStandardToolbar(); |
57 | initSheet(); | 57 | initSheet(); |
58 | 58 | ||
59 | // set window title | 59 | // set window title |
60 | setCaption(tr("Opie Sheet")); | 60 | setCaption(tr("Opie Sheet")); |
61 | 61 | ||
62 | // create sheets | 62 | // create sheets |
63 | selectorFileNew(DocLnk()); | 63 | selectorFileNew(DocLnk()); |
64 | } | 64 | } |
65 | 65 | ||
66 | MainWindow::~MainWindow() | 66 | MainWindow::~MainWindow() |
67 | { | 67 | { |
68 | if (currentDoc) delete currentDoc; | 68 | if (currentDoc) delete currentDoc; |
69 | } | 69 | } |
70 | 70 | ||
71 | void MainWindow::documentSave(DocLnk *lnkDoc) | 71 | void MainWindow::documentSave(DocLnk *lnkDoc) |
72 | { | 72 | { |
73 | FileManager fm; | 73 | FileManager fm; |
74 | QByteArray streamBuffer; | 74 | QByteArray streamBuffer; |
75 | QDataStream stream(streamBuffer, IO_WriteOnly); | 75 | QDataStream stream(streamBuffer, IO_WriteOnly); |
76 | 76 | ||
77 | typeSheet *currentSheet=findSheet(sheet->getName()); | 77 | typeSheet *currentSheet=findSheet(sheet->getName()); |
78 | if (!currentSheet) | 78 | if (!currentSheet) |
79 | { | 79 | { |
80 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); | 80 | QMessageBox::critical(this, tr("Error"), tr("Inconsistency error!")); |
81 | return; | 81 | return; |
82 | } | 82 | } |
83 | sheet->copySheetData(¤tSheet->data); | 83 | sheet->copySheetData(¤tSheet->data); |
84 | stream.writeRawBytes("SQT100", 6); | 84 | stream.writeRawBytes("SQT100", 6); |
85 | stream << (Q_UINT32)listSheets.count(); | 85 | stream << (Q_UINT32)listSheets.count(); |
86 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 86 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
87 | { | 87 | { |
88 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); | 88 | stream << tempSheet->name << (Q_UINT32)tempSheet->data.count(); |
89 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) | 89 | for (typeCellData *tempCell=tempSheet->data.first(); tempCell; tempCell=tempSheet->data.next()) |
90 | stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data; | 90 | stream << (Q_UINT32)tempCell->col << (Q_UINT32)tempCell->row << tempCell->borders.right << tempCell->borders.bottom << tempCell->background << (Q_UINT32)tempCell->alignment << tempCell->fontColor << tempCell->font << tempCell->data; |
91 | } | 91 | } |
92 | 92 | ||
93 | lnkDoc->setType("application/sheet-qt"); | 93 | lnkDoc->setType("application/sheet-qt"); |
94 | if (!fm.saveFile(*lnkDoc, streamBuffer)) | 94 | if (!fm.saveFile(*lnkDoc, streamBuffer)) |
95 | { | 95 | { |
96 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); | 96 | QMessageBox::critical(this, tr("Error"), tr("File cannot be saved!")); |
97 | return; | 97 | return; |
98 | } | 98 | } |
99 | documentModified=FALSE; | 99 | documentModified=FALSE; |
100 | } | 100 | } |
101 | 101 | ||
102 | void MainWindow::documentOpen(const DocLnk &lnkDoc) | 102 | void MainWindow::documentOpen(const DocLnk &lnkDoc) |
103 | { | 103 | { |
104 | FileManager fm; | 104 | FileManager fm; |
105 | QByteArray streamBuffer; | 105 | QByteArray streamBuffer; |
106 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) | 106 | if (!lnkDoc.isValid() || !fm.loadFile(lnkDoc, streamBuffer)) |
107 | { | 107 | { |
108 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); | 108 | QMessageBox::critical(this, tr("Error"), tr("File cannot be opened!")); |
109 | documentModified=FALSE; | 109 | documentModified=FALSE; |
110 | selectorFileNew(DocLnk()); | 110 | selectorFileNew(DocLnk()); |
111 | return; | 111 | return; |
112 | } | 112 | } |
113 | QDataStream stream(streamBuffer, IO_ReadOnly); | 113 | QDataStream stream(streamBuffer, IO_ReadOnly); |
114 | 114 | ||
115 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; | 115 | Q_UINT32 countSheet, countCell, i, j, row, col, alignment; |
116 | typeSheet *newSheet; | 116 | typeSheet *newSheet; |
117 | typeCellData *newCell; | 117 | typeCellData *newCell; |
118 | 118 | ||
119 | char fileFormat[7]; | 119 | char fileFormat[7]; |
120 | stream.readRawBytes(fileFormat, 6); | 120 | stream.readRawBytes(fileFormat, 6); |
121 | fileFormat[6]=0; | 121 | fileFormat[6]=0; |
122 | if ((QString)fileFormat!="SQT100") | 122 | if ((QString)fileFormat!="SQT100") |
123 | { | 123 | { |
124 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); | 124 | QMessageBox::critical(this, tr("Error"), tr("Invalid file format!")); |
125 | documentModified=FALSE; | 125 | documentModified=FALSE; |
126 | selectorFileNew(DocLnk()); | 126 | selectorFileNew(DocLnk()); |
127 | return; | 127 | return; |
128 | } | 128 | } |
129 | 129 | ||
130 | stream >> countSheet; | 130 | stream >> countSheet; |
131 | for (i=0; i<countSheet; ++i) | 131 | for (i=0; i<countSheet; ++i) |
132 | { | 132 | { |
133 | newSheet=new typeSheet; | 133 | newSheet=new typeSheet; |
134 | newSheet->data.setAutoDelete(TRUE); | 134 | newSheet->data.setAutoDelete(TRUE); |
135 | stream >> newSheet->name >> countCell; | 135 | stream >> newSheet->name >> countCell; |
136 | comboSheets->insertItem(newSheet->name); | 136 | comboSheets->insertItem(newSheet->name); |
137 | 137 | ||
138 | for (j=0; j<countCell; ++j) | 138 | for (j=0; j<countCell; ++j) |
139 | { | 139 | { |
140 | newCell=new typeCellData; | 140 | newCell=new typeCellData; |
141 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; | 141 | stream >> col >> row >> newCell->borders.right >> newCell->borders.bottom >> newCell->background >> alignment >> newCell->fontColor >> newCell->font >> newCell->data; |
142 | newCell->col=col; | 142 | newCell->col=col; |
@@ -487,253 +487,253 @@ void MainWindow::initMenu() | |||
487 | addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig); | 487 | addFlyAction(tr("COS(x)"), tr("COS(x)"), "COS(", submenuFuncTrig); |
488 | addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig); | 488 | addFlyAction(tr("TAN(x)"), tr("TAN(x)"), "TAN(", submenuFuncTrig); |
489 | addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig); | 489 | addFlyAction(tr("ASIN(x)"), tr("ASIN(x)"), "ASIN(", submenuFuncTrig); |
490 | addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig); | 490 | addFlyAction(tr("ACOS(x)"), tr("ACOS(x)"), "ACOS(", submenuFuncTrig); |
491 | addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig); | 491 | addFlyAction(tr("ATAN(x)"), tr("ATAN(x)"), "ATAN(", submenuFuncTrig); |
492 | addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig); | 492 | addFlyAction(tr("ATAN2(x,y)"), tr("ATAN2(x,y)"), "ATAN2(", submenuFuncTrig); |
493 | submenuFuncTrig->insertSeparator(); | 493 | submenuFuncTrig->insertSeparator(); |
494 | addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig); | 494 | addFlyAction(tr("SINH(x)"), tr("SINH(x)"), "SINH(", submenuFuncTrig); |
495 | addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig); | 495 | addFlyAction(tr("COSH(x)"), tr("COSH(x)"), "COSH(", submenuFuncTrig); |
496 | addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig); | 496 | addFlyAction(tr("TANH(x)"), tr("TANH(x)"), "TANH(", submenuFuncTrig); |
497 | addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig); | 497 | addFlyAction(tr("ACOSH(x)"), tr("ACOSH(x)"), "ACOSH(", submenuFuncTrig); |
498 | addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig); | 498 | addFlyAction(tr("ASINH(x)"), tr("ASINH(x)"), "ASINH(", submenuFuncTrig); |
499 | addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig); | 499 | addFlyAction(tr("ATANH(x)"), tr("ATANH(x)"), "ATANH(", submenuFuncTrig); |
500 | submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig); | 500 | submenuFunc->insertItem(tr("&Trigonometric"), submenuFuncTrig); |
501 | 501 | ||
502 | submenuFuncString=new QPopupMenu; | 502 | submenuFuncString=new QPopupMenu; |
503 | addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString); | 503 | addFlyAction(tr("LEN(s)"), tr("LEN(s)"), "LEN(",submenuFuncString); |
504 | addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString); | 504 | addFlyAction(tr("LEFT(s,num)"), tr("LEFT(s,num)"), "LEFT(",submenuFuncString); |
505 | addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString); | 505 | addFlyAction(tr("RIGHT(s,num)"), tr("RIGHT(s,num)"), "RIGHT(",submenuFuncString); |
506 | addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString); | 506 | addFlyAction(tr("MID(s,pos,len)"), tr("MID(s,pos,len)"), "MID(",submenuFuncString); |
507 | submenuFuncString->insertSeparator(); | 507 | submenuFuncString->insertSeparator(); |
508 | addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString); | 508 | addFlyAction(tr("CONCATENATE(s1,s2..)"), tr("CONCATENATE(s1,s2..)"), "CONCATENATE(",submenuFuncString); |
509 | addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString); | 509 | addFlyAction(tr("EXACT(s1,s2)"), tr("EXACT(s1,s2)"), "EXACT(",submenuFuncString); |
510 | addFlyAction(tr("FIND(what,where,pos)"), | 510 | addFlyAction(tr("FIND(what,where,pos)"), |
511 | tr("FIND(what,where,pos)"), "FIND(",submenuFuncString); | 511 | tr("FIND(what,where,pos)"), "FIND(",submenuFuncString); |
512 | addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString); | 512 | addFlyAction(tr("REPLACE(s,pos,len,ns)"), tr("REPLACE(s,pos,len,ns)"), "REPLACE(",submenuFuncString); |
513 | addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString); | 513 | addFlyAction(tr("REPT(s,n)"), tr("REPT(s,n)"), "REPT(",submenuFuncString); |
514 | submenuFuncString->insertSeparator(); | 514 | submenuFuncString->insertSeparator(); |
515 | addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString); | 515 | addFlyAction(tr("UPPER(s)"), tr("UPPER(s)"), "UPPER(",submenuFuncString); |
516 | addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString); | 516 | addFlyAction(tr("LOWER(s)"), tr("LOWER(s)"), "LOWER(",submenuFuncString); |
517 | submenuFunc->insertItem(tr("&Strings"), submenuFuncString); | 517 | submenuFunc->insertItem(tr("&Strings"), submenuFuncString); |
518 | 518 | ||
519 | submenuFuncStat=new QPopupMenu; | 519 | submenuFuncStat=new QPopupMenu; |
520 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); | 520 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); |
521 | addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat); | 521 | addFlyAction(tr("COUNT(range)"), tr("COUNT(range)"), "COUNT(",submenuFuncStat); |
522 | addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat); | 522 | addFlyAction(tr("COUNTIF(range,eqls)"), tr("COUNTIF(range,eqls)"), "COUNTIF(",submenuFuncStat); |
523 | addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat); | 523 | addFlyAction(tr("MAX(range)"), tr("MAX(range)"), "MAX(",submenuFuncStat); |
524 | addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat); | 524 | addFlyAction(tr("MIN(range)"), tr("MIN(range)"), "MIN(",submenuFuncStat); |
525 | addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat); | 525 | addFlyAction(tr("SUM(range)"), tr("SUM(range)"), "SUM(",submenuFuncStat); |
526 | addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat); | 526 | addFlyAction(tr("SUMSQ(range)"), tr("SUMSQ(range)"), "SUMSQ(",submenuFuncStat); |
527 | submenuFuncStat->insertSeparator(); | 527 | submenuFuncStat->insertSeparator(); |
528 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); | 528 | addFlyAction(tr("AVERAGE(range)"), tr("AVERAGE(range)"), "AVERAGE(",submenuFuncStat); |
529 | addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat); | 529 | addFlyAction(tr("VAR(range)"), tr("VAR(range)"), "VAR(",submenuFuncStat); |
530 | addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat); | 530 | addFlyAction(tr("VARP(range)"), tr("VARP(range)"), "VARP(",submenuFuncStat); |
531 | addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat); | 531 | addFlyAction(tr("STDEV(range)"), tr("STDEV(range)"), "STDEV(",submenuFuncStat); |
532 | addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat); | 532 | addFlyAction(tr("STDEVP(range)"), tr("STDEVP(range)"), "STDEVP(",submenuFuncStat); |
533 | addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat); | 533 | addFlyAction(tr("SKEW(range)"), tr("SKEW(range)"), "SKEW(",submenuFuncStat); |
534 | addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat); | 534 | addFlyAction(tr("KURT(range)"), tr("KURT(range)"), "KURT(",submenuFuncStat); |
535 | submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat); | 535 | submenuFunc->insertItem(tr("Sta&tistical"), submenuFuncStat); |
536 | 536 | ||
537 | submenuFuncScientific=new QPopupMenu; | 537 | submenuFuncScientific=new QPopupMenu; |
538 | addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific); | 538 | addFlyAction(tr("BESSELI(x,n)"), tr("BESSELI(x,n)"), "BESSELI(",submenuFuncScientific); |
539 | addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific); | 539 | addFlyAction(tr("BESSELJ(x,n)"), tr("BESSELJ(x,n)"), "BESSELJ(",submenuFuncScientific); |
540 | addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific); | 540 | addFlyAction(tr("BESSELK(x,n)"), tr("BESSELK(x,n)"), "BESSELK(",submenuFuncScientific); |
541 | addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific); | 541 | addFlyAction(tr("BESSELY(x,n)"), tr("BESSELY(x,n)"), "BESSELY(",submenuFuncScientific); |
542 | submenuFuncScientific->insertSeparator(); | 542 | submenuFuncScientific->insertSeparator(); |
543 | addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific); | 543 | addFlyAction(tr("BETAI(x,a,b)"), tr("BETAI(x,a,b)"), "BETAI(",submenuFuncScientific); |
544 | addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific); | 544 | addFlyAction(tr("ERF(a,b)"), tr("ERF(a,b)"), "ERF(",submenuFuncScientific); |
545 | addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific); | 545 | addFlyAction(tr("ERFC(a,b)"), tr("ERFC(a,b)"), "ERFC(",submenuFuncScientific); |
546 | addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific); | 546 | addFlyAction(tr("GAMMALN(x)"), tr("GAMMALN(x)"), "GAMMALN(",submenuFuncScientific); |
547 | addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific); | 547 | addFlyAction(tr("GAMMAP(x,a)"), tr("GAMMAP(x,a)"), "GAMMAP(",submenuFuncScientific); |
548 | addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific); | 548 | addFlyAction(tr("GAMMAQ(x,a)"), tr("GAMMAQ(x,a)"), "GAMMAQ(",submenuFuncScientific); |
549 | submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific); | 549 | submenuFunc->insertItem(tr("Scienti&fic"), submenuFuncScientific); |
550 | 550 | ||
551 | submenuFuncDistr=new QPopupMenu; | 551 | submenuFuncDistr=new QPopupMenu; |
552 | addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr); | 552 | addFlyAction(tr("BETADIST(z,a,b,Q?)"), tr("BETADIST(z,a,b,Q?)"), "BETADIST(",submenuFuncDistr); |
553 | addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr); | 553 | addFlyAction(tr("CHI2DIST(x,n,Q?)"), tr("CHI2DIST(x,n,Q?)"), "CHI2DIST(",submenuFuncDistr); |
554 | addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr); | 554 | addFlyAction(tr("CHIDIST(x,n,Q?)"), tr("CHIDIST(x,n,Q?)"), "CHIDIST(",submenuFuncDistr); |
555 | addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr); | 555 | addFlyAction(tr("FDIST(z,deg1,deg2,Q?)"), tr("FDIST(z,deg1,deg2,Q?)"), "FDIST(",submenuFuncDistr); |
556 | addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr); | 556 | addFlyAction(tr("GAMMADIST(x,a,b,Q?)"), tr("GAMMADIST(x,a,b,Q?)"), "GAMMADIST(",submenuFuncDistr); |
557 | addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr); | 557 | addFlyAction(tr("NORMALDIST(x,m,s,Q?)"), tr("NORMALDIST(x,m,s,Q?)"), "NORMALDIST(",submenuFuncDistr); |
558 | addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr); | 558 | addFlyAction(tr("PHI(x,Q?)"), tr("PHI(x,Q?)"), "PHI(",submenuFuncDistr); |
559 | addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr); | 559 | addFlyAction(tr("POISSON(x,n,Q?)"), tr("POISSON(x,n,Q?)"), "POISSON(",submenuFuncDistr); |
560 | submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr); | 560 | submenuFunc->insertItem(tr("&Distributions"), submenuFuncDistr); |
561 | 561 | ||
562 | 562 | ||
563 | 563 | ||
564 | menuInsert->insertSeparator(); | 564 | menuInsert->insertSeparator(); |
565 | insertCells->addTo(menuInsert); | 565 | insertCells->addTo(menuInsert); |
566 | insertRows->addTo(menuInsert); | 566 | insertRows->addTo(menuInsert); |
567 | insertCols->addTo(menuInsert); | 567 | insertCols->addTo(menuInsert); |
568 | insertSheets->addTo(menuInsert); | 568 | insertSheets->addTo(menuInsert); |
569 | } | 569 | } |
570 | 570 | ||
571 | void MainWindow::initStandardToolbar() | 571 | void MainWindow::initStandardToolbar() |
572 | { | 572 | { |
573 | toolbarStandard=new QToolBar(this); | 573 | toolbarStandard=new QToolBar(this); |
574 | toolbarStandard->setHorizontalStretchable(TRUE); | 574 | toolbarStandard->setHorizontalStretchable(TRUE); |
575 | moveToolBar(toolbarStandard, Top); | 575 | moveToolBar(toolbarStandard, Top); |
576 | 576 | ||
577 | fileNew->addTo(toolbarStandard); | 577 | fileNew->addTo(toolbarStandard); |
578 | fileOpen->addTo(toolbarStandard); | 578 | fileOpen->addTo(toolbarStandard); |
579 | fileSave->addTo(toolbarStandard); | 579 | fileSave->addTo(toolbarStandard); |
580 | 580 | ||
581 | comboSheets=new QComboBox(toolbarStandard); | 581 | comboSheets=new QComboBox(toolbarStandard); |
582 | toolbarStandard->setStretchableWidget(comboSheets); | 582 | toolbarStandard->setStretchableWidget(comboSheets); |
583 | connect(comboSheets, SIGNAL(activated(const QString &)), this, SLOT(slotSheetChanged(const QString &))); | 583 | connect(comboSheets, SIGNAL(activated(const QString&)), this, SLOT(slotSheetChanged(const QString&))); |
584 | } | 584 | } |
585 | 585 | ||
586 | void MainWindow::initFunctionsToolbar() | 586 | void MainWindow::initFunctionsToolbar() |
587 | { | 587 | { |
588 | toolbarFunctions=new QToolBar(this); | 588 | toolbarFunctions=new QToolBar(this); |
589 | toolbarFunctions->setHorizontalStretchable(TRUE); | 589 | toolbarFunctions->setHorizontalStretchable(TRUE); |
590 | moveToolBar(toolbarFunctions, Bottom); | 590 | moveToolBar(toolbarFunctions, Bottom); |
591 | 591 | ||
592 | funcEqual->addTo(toolbarFunctions); | 592 | funcEqual->addTo(toolbarFunctions); |
593 | funcPlus->addTo(toolbarFunctions); | 593 | funcPlus->addTo(toolbarFunctions); |
594 | funcMinus->addTo(toolbarFunctions); | 594 | funcMinus->addTo(toolbarFunctions); |
595 | funcCross->addTo(toolbarFunctions); | 595 | funcCross->addTo(toolbarFunctions); |
596 | funcDivide->addTo(toolbarFunctions); | 596 | funcDivide->addTo(toolbarFunctions); |
597 | funcParanOpen->addTo(toolbarFunctions); | 597 | funcParanOpen->addTo(toolbarFunctions); |
598 | funcParanClose->addTo(toolbarFunctions); | 598 | funcParanClose->addTo(toolbarFunctions); |
599 | funcComma->addTo(toolbarFunctions); | 599 | funcComma->addTo(toolbarFunctions); |
600 | 600 | ||
601 | toolFunction=new QToolButton(toolbarFunctions); | 601 | toolFunction=new QToolButton(toolbarFunctions); |
602 | toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" )); | 602 | toolFunction->setPixmap(Resource::loadPixmap( "opie-sheet/func-func" )); |
603 | toolFunction->setTextLabel(tr("Functions")); | 603 | toolFunction->setTextLabel(tr("Functions")); |
604 | toolFunction->setPopup(submenuFunc); | 604 | toolFunction->setPopup(submenuFunc); |
605 | toolFunction->setPopupDelay(0); | 605 | toolFunction->setPopupDelay(0); |
606 | } | 606 | } |
607 | 607 | ||
608 | void MainWindow::initEditToolbar() | 608 | void MainWindow::initEditToolbar() |
609 | { | 609 | { |
610 | toolbarEdit=new QToolBar(this); | 610 | toolbarEdit=new QToolBar(this); |
611 | toolbarEdit->setHorizontalStretchable(TRUE); | 611 | toolbarEdit->setHorizontalStretchable(TRUE); |
612 | moveToolBar(toolbarEdit, Bottom); | 612 | moveToolBar(toolbarEdit, Bottom); |
613 | 613 | ||
614 | editAccept->addTo(toolbarEdit); | 614 | editAccept->addTo(toolbarEdit); |
615 | editCancel->addTo(toolbarEdit); | 615 | editCancel->addTo(toolbarEdit); |
616 | 616 | ||
617 | editData=new QLineEdit(toolbarEdit); | 617 | editData=new QLineEdit(toolbarEdit); |
618 | toolbarEdit->setStretchableWidget(editData); | 618 | toolbarEdit->setStretchableWidget(editData); |
619 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); | 619 | connect(editData, SIGNAL(returnPressed()), this, SLOT(slotEditAccept())); |
620 | 620 | ||
621 | editCellSelect->addTo(toolbarEdit); | 621 | editCellSelect->addTo(toolbarEdit); |
622 | } | 622 | } |
623 | 623 | ||
624 | void MainWindow::slotHelpAbout() | 624 | void MainWindow::slotHelpAbout() |
625 | { | 625 | { |
626 | QDialog dialogAbout(this, 0, TRUE); | 626 | QDialog dialogAbout(this, 0, TRUE); |
627 | dialogAbout.resize(width()-40, height()-80); | 627 | dialogAbout.resize(width()-40, height()-80); |
628 | dialogAbout.setCaption(tr("About Opie Sheet")); | 628 | dialogAbout.setCaption(tr("About Opie Sheet")); |
629 | 629 | ||
630 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); | 630 | QLabel label(tr("Opie Sheet\nSpreadsheet Software for Opie\nQWDC Beta Winner (as Sheet/Qt)\n\nDeveloped by: Serdar Ozler\nRelease 1.0.2\nRelease Date: October 08, 2002\n\nThis product is licensed under GPL. It is freely distributable. If you want to get the latest version and also the source code, please visit the web site.\n\nhttp://qtopia.sitebest.com"), &dialogAbout); |
631 | label.setGeometry(dialogAbout.rect()); | 631 | label.setGeometry(dialogAbout.rect()); |
632 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); | 632 | label.setAlignment(Qt::AlignCenter | Qt::WordBreak); |
633 | 633 | ||
634 | dialogAbout.exec(); | 634 | dialogAbout.exec(); |
635 | } | 635 | } |
636 | 636 | ||
637 | void MainWindow::initSheet() | 637 | void MainWindow::initSheet() |
638 | { | 638 | { |
639 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); | 639 | sheet=new Sheet(DEFAULT_NUM_ROWS, DEFAULT_NUM_COLS, this); |
640 | setCentralWidget(sheet); | 640 | setCentralWidget(sheet); |
641 | 641 | ||
642 | connect(sheet, SIGNAL(currentDataChanged(const QString &)), editData, SLOT(setText(const QString &))); | 642 | connect(sheet, SIGNAL(currentDataChanged(const QString&)), editData, SLOT(setText(const QString&))); |
643 | connect(sheet, SIGNAL(cellClicked(const QString &)), this, SLOT(slotCellClicked(const QString &))); | 643 | connect(sheet, SIGNAL(cellClicked(const QString&)), this, SLOT(slotCellClicked(const QString&))); |
644 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); | 644 | connect(sheet, SIGNAL(sheetModified()), this, SLOT(slotDocModified())); |
645 | 645 | ||
646 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); | 646 | connect(editCut, SIGNAL(activated()), sheet, SLOT(editCut())); |
647 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); | 647 | connect(editCopy, SIGNAL(activated()), sheet, SLOT(editCopy())); |
648 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); | 648 | connect(editClear, SIGNAL(activated()), sheet, SLOT(editClear())); |
649 | } | 649 | } |
650 | 650 | ||
651 | void MainWindow::slotEditAccept() | 651 | void MainWindow::slotEditAccept() |
652 | { | 652 | { |
653 | sheet->setData(editData->text()); | 653 | sheet->setData(editData->text()); |
654 | } | 654 | } |
655 | 655 | ||
656 | void MainWindow::slotEditCancel() | 656 | void MainWindow::slotEditCancel() |
657 | { | 657 | { |
658 | editData->setText(sheet->getData()); | 658 | editData->setText(sheet->getData()); |
659 | } | 659 | } |
660 | 660 | ||
661 | void MainWindow::slotCellSelect(bool lock) | 661 | void MainWindow::slotCellSelect(bool lock) |
662 | { | 662 | { |
663 | sheet->lockClicks(lock); | 663 | sheet->lockClicks(lock); |
664 | } | 664 | } |
665 | 665 | ||
666 | void MainWindow::addToData(const QString &data) | 666 | void MainWindow::addToData(const QString &data) |
667 | { | 667 | { |
668 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); | 668 | editData->setText(editData->text().insert(editData->cursorPosition(), data)); |
669 | } | 669 | } |
670 | 670 | ||
671 | void MainWindow::slotFuncOutput() | 671 | void MainWindow::slotFuncOutput() |
672 | { | 672 | { |
673 | if (sender()->isA("QAction")) | 673 | if (sender()->isA("QAction")) |
674 | addToData(((QAction *)sender())->toolTip()); | 674 | addToData(((QAction *)sender())->toolTip()); |
675 | } | 675 | } |
676 | 676 | ||
677 | void MainWindow::slotInsertRows() | 677 | void MainWindow::slotInsertRows() |
678 | { | 678 | { |
679 | NumberDialog dialogNumber(this); | 679 | NumberDialog dialogNumber(this); |
680 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) | 680 | if (dialogNumber.exec(tr("Insert Rows"), tr("&Number of rows:"))==QDialog::Accepted) |
681 | sheet->insertRows(dialogNumber.getValue()); | 681 | sheet->insertRows(dialogNumber.getValue()); |
682 | } | 682 | } |
683 | 683 | ||
684 | void MainWindow::slotInsertCols() | 684 | void MainWindow::slotInsertCols() |
685 | { | 685 | { |
686 | NumberDialog dialogNumber(this); | 686 | NumberDialog dialogNumber(this); |
687 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) | 687 | if (dialogNumber.exec(tr("Insert Columns"), tr("&Number of columns:"))==QDialog::Accepted) |
688 | sheet->insertColumns(dialogNumber.getValue()); | 688 | sheet->insertColumns(dialogNumber.getValue()); |
689 | } | 689 | } |
690 | 690 | ||
691 | void MainWindow::slotInsertSheets() | 691 | void MainWindow::slotInsertSheets() |
692 | { | 692 | { |
693 | NumberDialog dialogNumber(this); | 693 | NumberDialog dialogNumber(this); |
694 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) | 694 | if (dialogNumber.exec(tr("Add Sheets"), tr("&Number of sheets:"))==QDialog::Accepted) |
695 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); | 695 | for (int i=dialogNumber.getValue(); i>0; --i) createNewSheet(); |
696 | } | 696 | } |
697 | 697 | ||
698 | void MainWindow::slotCellClicked(const QString &cell) | 698 | void MainWindow::slotCellClicked(const QString &cell) |
699 | { | 699 | { |
700 | editCellSelect->setOn(FALSE); | 700 | editCellSelect->setOn(FALSE); |
701 | addToData(cell); | 701 | addToData(cell); |
702 | } | 702 | } |
703 | 703 | ||
704 | typeSheet *MainWindow::createNewSheet() | 704 | typeSheet *MainWindow::createNewSheet() |
705 | { | 705 | { |
706 | typeSheet *newSheet=new typeSheet; | 706 | typeSheet *newSheet=new typeSheet; |
707 | int currentNo=1, tempNo=0; | 707 | int currentNo=1, tempNo=0; |
708 | bool ok; | 708 | bool ok; |
709 | 709 | ||
710 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 710 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
711 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) | 711 | if (tempSheet->name.startsWith(tr("Sheet")) && (tempNo=tempSheet->name.mid(tr("Sheet").length()).toInt(&ok))>=currentNo && ok) |
712 | currentNo=tempNo+1; | 712 | currentNo=tempNo+1; |
713 | 713 | ||
714 | newSheet->name=tr("Sheet")+QString::number(currentNo); | 714 | newSheet->name=tr("Sheet")+QString::number(currentNo); |
715 | newSheet->data.setAutoDelete(TRUE); | 715 | newSheet->data.setAutoDelete(TRUE); |
716 | 716 | ||
717 | comboSheets->insertItem(newSheet->name); | 717 | comboSheets->insertItem(newSheet->name); |
718 | listSheets.append(newSheet); | 718 | listSheets.append(newSheet); |
719 | return newSheet; | 719 | return newSheet; |
720 | } | 720 | } |
721 | 721 | ||
722 | typeSheet *MainWindow::findSheet(const QString &name) | 722 | typeSheet *MainWindow::findSheet(const QString &name) |
723 | { | 723 | { |
724 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) | 724 | for (typeSheet *tempSheet=listSheets.first(); tempSheet; tempSheet=listSheets.next()) |
725 | if (tempSheet->name==name) | 725 | if (tempSheet->name==name) |
726 | return tempSheet; | 726 | return tempSheet; |
727 | return NULL; | 727 | return NULL; |
728 | } | 728 | } |
729 | 729 | ||
730 | void MainWindow::slotSheetChanged(const QString &name) | 730 | void MainWindow::slotSheetChanged(const QString &name) |
731 | { | 731 | { |
732 | sheet->copySheetData(&findSheet(sheet->getName())->data); | 732 | sheet->copySheetData(&findSheet(sheet->getName())->data); |
733 | sheet->setName(name); | 733 | sheet->setName(name); |
734 | sheet->setSheetData(&findSheet(name)->data); | 734 | sheet->setSheetData(&findSheet(name)->data); |
735 | sheet->ReCalc(); | 735 | sheet->ReCalc(); |
736 | } | 736 | } |
737 | 737 | ||
738 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) | 738 | void MainWindow::addFlyAction(const QString &text, const QString &menuText, const QString &tip, QWidget *w) |
739 | { | 739 | { |
diff --git a/noncore/apps/opie-sheet/sheet.cpp b/noncore/apps/opie-sheet/sheet.cpp index f303d33..d4419af 100644 --- a/noncore/apps/opie-sheet/sheet.cpp +++ b/noncore/apps/opie-sheet/sheet.cpp | |||
@@ -1,143 +1,143 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | /* | 10 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 11 | * Opie Sheet (formerly Sheet/Qt) |
12 | * by Serdar Ozler <sozler@sitebest.com> | 12 | * by Serdar Ozler <sozler@sitebest.com> |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include "sheet.h" | 15 | #include "sheet.h" |
16 | 16 | ||
17 | #include <qmessagebox.h> | 17 | #include <qmessagebox.h> |
18 | #include <math.h> | 18 | #include <math.h> |
19 | #include <stdlib.h> | 19 | #include <stdlib.h> |
20 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include <time.h> | 21 | #include <time.h> |
22 | 22 | ||
23 | #define DEFAULT_COL_WIDTH 50 | 23 | #define DEFAULT_COL_WIDTH 50 |
24 | 24 | ||
25 | Sheet::Sheet(int numRows, int numCols, QWidget *parent) | 25 | Sheet::Sheet(int numRows, int numCols, QWidget *parent) |
26 | :QTable(numRows, numCols, parent) | 26 | :QTable(numRows, numCols, parent) |
27 | { | 27 | { |
28 | defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); | 28 | defaultBorders.right=defaultBorders.bottom=QPen(Qt::gray, 1, Qt::SolidLine); |
29 | defaultCellData.data=""; | 29 | defaultCellData.data=""; |
30 | defaultCellData.background=QBrush(Qt::white, Qt::SolidPattern); | 30 | defaultCellData.background=QBrush(Qt::white, Qt::SolidPattern); |
31 | defaultCellData.alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); | 31 | defaultCellData.alignment=(Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop); |
32 | defaultCellData.fontColor=Qt::black; | 32 | defaultCellData.fontColor=Qt::black; |
33 | defaultCellData.font=font(); | 33 | defaultCellData.font=font(); |
34 | defaultCellData.borders=defaultBorders; | 34 | defaultCellData.borders=defaultBorders; |
35 | 35 | ||
36 | clicksLocked=FALSE; | 36 | clicksLocked=FALSE; |
37 | selectionNo=-1; | 37 | selectionNo=-1; |
38 | setSelectionMode(QTable::Single); | 38 | setSelectionMode(QTable::Single); |
39 | 39 | ||
40 | sheetData.setAutoDelete(TRUE); | 40 | sheetData.setAutoDelete(TRUE); |
41 | clipboardData.setAutoDelete(TRUE); | 41 | clipboardData.setAutoDelete(TRUE); |
42 | for (int i=0; i<numCols; ++i) | 42 | for (int i=0; i<numCols; ++i) |
43 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); | 43 | horizontalHeader()->setLabel(i, getHeaderString(i+1), DEFAULT_COL_WIDTH); |
44 | 44 | ||
45 | 45 | ||
46 | connect(this, SIGNAL(currentChanged(int, int)), this, SLOT(slotCellSelected(int, int))); | 46 | connect(this, SIGNAL(currentChanged(int,int)), this, SLOT(slotCellSelected(int,int))); |
47 | connect(this, SIGNAL(valueChanged(int, int)), this, SLOT(slotCellChanged(int, int))); | 47 | connect(this, SIGNAL(valueChanged(int,int)), this, SLOT(slotCellChanged(int,int))); |
48 | } | 48 | } |
49 | 49 | ||
50 | Sheet::~Sheet() | 50 | Sheet::~Sheet() |
51 | { | 51 | { |
52 | } | 52 | } |
53 | 53 | ||
54 | typeCellData *Sheet::findCellData(int row, int col) | 54 | typeCellData *Sheet::findCellData(int row, int col) |
55 | { | 55 | { |
56 | typeCellData *tempCellData; | 56 | typeCellData *tempCellData; |
57 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) | 57 | for (tempCellData=sheetData.first(); tempCellData; tempCellData=sheetData.next()) |
58 | { | 58 | { |
59 | if (tempCellData->row==row && tempCellData->col==col) return tempCellData; | 59 | if (tempCellData->row==row && tempCellData->col==col) return tempCellData; |
60 | } | 60 | } |
61 | return NULL; | 61 | return NULL; |
62 | } | 62 | } |
63 | 63 | ||
64 | void Sheet::slotCellSelected(int row, int col) | 64 | void Sheet::slotCellSelected(int row, int col) |
65 | { | 65 | { |
66 | typeCellData *cellData=findCellData(row, col); | 66 | typeCellData *cellData=findCellData(row, col); |
67 | if (cellData) | 67 | if (cellData) |
68 | { | 68 | { |
69 | emit currentDataChanged(cellData->data); | 69 | emit currentDataChanged(cellData->data); |
70 | }else | 70 | }else |
71 | emit currentDataChanged(""); | 71 | emit currentDataChanged(""); |
72 | } | 72 | } |
73 | 73 | ||
74 | typeCellData *Sheet::createCellData(int row, int col) | 74 | typeCellData *Sheet::createCellData(int row, int col) |
75 | { | 75 | { |
76 | if (row<0 || col<0) return NULL; | 76 | if (row<0 || col<0) return NULL; |
77 | typeCellData *cellData=new typeCellData; | 77 | typeCellData *cellData=new typeCellData; |
78 | cellData->row=row; | 78 | cellData->row=row; |
79 | cellData->col=col; | 79 | cellData->col=col; |
80 | cellData->data=defaultCellData.data; | 80 | cellData->data=defaultCellData.data; |
81 | cellData->borders=defaultCellData.borders; | 81 | cellData->borders=defaultCellData.borders; |
82 | cellData->alignment=defaultCellData.alignment; | 82 | cellData->alignment=defaultCellData.alignment; |
83 | cellData->font=defaultCellData.font; | 83 | cellData->font=defaultCellData.font; |
84 | cellData->fontColor=defaultCellData.fontColor; | 84 | cellData->fontColor=defaultCellData.fontColor; |
85 | cellData->background=defaultCellData.background; | 85 | cellData->background=defaultCellData.background; |
86 | sheetData.append(cellData); | 86 | sheetData.append(cellData); |
87 | return cellData; | 87 | return cellData; |
88 | } | 88 | } |
89 | 89 | ||
90 | void Sheet::slotCellChanged(int row, int col) | 90 | void Sheet::slotCellChanged(int row, int col) |
91 | { | 91 | { |
92 | typeCellData *cellData=findCellData(row, col); | 92 | typeCellData *cellData=findCellData(row, col); |
93 | if (!cellData) cellData=createCellData(row, col); | 93 | if (!cellData) cellData=createCellData(row, col); |
94 | if (cellData) cellData->data=text(row, col); | 94 | if (cellData) cellData->data=text(row, col); |
95 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) | 95 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) |
96 | { | 96 | { |
97 | // modified by Toussis Manolis koppermind@panafonet.gr | 97 | // modified by Toussis Manolis koppermind@panafonet.gr |
98 | // the parser was crashing if there were no closed parenthesis. | 98 | // the parser was crashing if there were no closed parenthesis. |
99 | int w1,ii=0; | 99 | int w1,ii=0; |
100 | for(w1=0;w1<=(int)text(row, col).length();w1++) | 100 | for(w1=0;w1<=(int)text(row, col).length();w1++) |
101 | { | 101 | { |
102 | if(text(row,col)[w1]=='(') ii++; | 102 | if(text(row,col)[w1]=='(') ii++; |
103 | if(text(row,col)[w1]==')') ii--; | 103 | if(text(row,col)[w1]==')') ii--; |
104 | }; | 104 | }; |
105 | if(ii==0) setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); | 105 | if(ii==0) setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); |
106 | //end of modification | 106 | //end of modification |
107 | // old was plain: | 107 | // old was plain: |
108 | //setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); | 108 | //setText(cellData->row, cellData->col, dataParser(findCellName(cellData->row, cellData->col), cellData->data)); |
109 | }; | 109 | }; |
110 | emit sheetModified(); | 110 | emit sheetModified(); |
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
114 | void Sheet::ReCalc(void) | 114 | void Sheet::ReCalc(void) |
115 | { | 115 | { |
116 | typeCellData* cellData; | 116 | typeCellData* cellData; |
117 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) | 117 | for (cellData=sheetData.first(); cellData; cellData=sheetData.next()) |
118 | { | 118 | { |
119 | //printf("cellchanged:%d, %d\r\n",cellData->row,cellData->col); | 119 | //printf("cellchanged:%d, %d\r\n",cellData->row,cellData->col); |
120 | 120 | ||
121 | slotCellChanged(cellData->row,cellData->col); | 121 | slotCellChanged(cellData->row,cellData->col); |
122 | }; | 122 | }; |
123 | }; | 123 | }; |
124 | 124 | ||
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
128 | void Sheet::swapCells(int row1, int col1, int row2, int col2) | 128 | void Sheet::swapCells(int row1, int col1, int row2, int col2) |
129 | { | 129 | { |
130 | typeCellData *cellData1=findCellData(row1, col1), *cellData2=findCellData(row2, col2); | 130 | typeCellData *cellData1=findCellData(row1, col1), *cellData2=findCellData(row2, col2); |
131 | if (!cellData1) cellData1=createCellData(row1, col1); | 131 | if (!cellData1) cellData1=createCellData(row1, col1); |
132 | if (!cellData2) cellData2=createCellData(row2, col2); | 132 | if (!cellData2) cellData2=createCellData(row2, col2); |
133 | if (cellData1 && cellData2) | 133 | if (cellData1 && cellData2) |
134 | { | 134 | { |
135 | QString tempData(cellData1->data); | 135 | QString tempData(cellData1->data); |
136 | cellData1->data=cellData2->data; | 136 | cellData1->data=cellData2->data; |
137 | cellData2->data=tempData; | 137 | cellData2->data=tempData; |
138 | setText(cellData1->row, cellData1->col, dataParser(findCellName(cellData1->row, cellData1->col), cellData1->data)); | 138 | setText(cellData1->row, cellData1->col, dataParser(findCellName(cellData1->row, cellData1->col), cellData1->data)); |
139 | setText(cellData2->row, cellData2->col, dataParser(findCellName(cellData2->row, cellData2->col), cellData2->data)); | 139 | setText(cellData2->row, cellData2->col, dataParser(findCellName(cellData2->row, cellData2->col), cellData2->data)); |
140 | emit sheetModified(); | 140 | emit sheetModified(); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
diff --git a/noncore/apps/opie-write/mainwindow.cpp b/noncore/apps/opie-write/mainwindow.cpp index 6bb524f..90e1a70 100644 --- a/noncore/apps/opie-write/mainwindow.cpp +++ b/noncore/apps/opie-write/mainwindow.cpp | |||
@@ -30,345 +30,345 @@ | |||
30 | #include <qaction.h> | 30 | #include <qaction.h> |
31 | #include <qtoolbar.h> | 31 | #include <qtoolbar.h> |
32 | #include <qtoolbutton.h> | 32 | #include <qtoolbutton.h> |
33 | #include <qtabwidget.h> | 33 | #include <qtabwidget.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qfontdatabase.h> | 35 | #include <qfontdatabase.h> |
36 | #include <qcombobox.h> | 36 | #include <qcombobox.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qfileinfo.h> | 38 | #include <qfileinfo.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <qfiledialog.h> | 40 | #include <qfiledialog.h> |
41 | #include <qprinter.h> | 41 | #include <qprinter.h> |
42 | #include <qpaintdevicemetrics.h> | 42 | #include <qpaintdevicemetrics.h> |
43 | #include <qmenubar.h> | 43 | #include <qmenubar.h> |
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qcolordialog.h> | 45 | #include <qcolordialog.h> |
46 | #include <qpainter.h> | 46 | #include <qpainter.h> |
47 | #include <qstyle.h> | 47 | #include <qstyle.h> |
48 | 48 | ||
49 | class ButtonMenu : public QToolButton | 49 | class ButtonMenu : public QToolButton |
50 | { | 50 | { |
51 | Q_OBJECT | 51 | Q_OBJECT |
52 | public: | 52 | public: |
53 | ButtonMenu( QWidget *parent, const char *name=0 ) | 53 | ButtonMenu( QWidget *parent, const char *name=0 ) |
54 | : QToolButton( parent, name ), current(0) | 54 | : QToolButton( parent, name ), current(0) |
55 | { | 55 | { |
56 | setPopup( new QPopupMenu( this ) ); | 56 | setPopup( new QPopupMenu( this ) ); |
57 | setPopupDelay( 1 ); | 57 | setPopupDelay( 1 ); |
58 | connect( popup(), SIGNAL(activated(int)), this, SLOT(selected(int)) ); | 58 | connect( popup(), SIGNAL(activated(int)), this, SLOT(selected(int)) ); |
59 | } | 59 | } |
60 | 60 | ||
61 | int insertItem(const QIconSet &icon, const QString &text, int id ) { | 61 | int insertItem(const QIconSet &icon, const QString &text, int id ) { |
62 | if ( !popup()->count() ) { | 62 | if ( !popup()->count() ) { |
63 | setIconSet( icon ); | 63 | setIconSet( icon ); |
64 | current = id; | 64 | current = id; |
65 | } | 65 | } |
66 | return popup()->insertItem( icon, text, id ); | 66 | return popup()->insertItem( icon, text, id ); |
67 | } | 67 | } |
68 | 68 | ||
69 | void setCurrentItem( int id ) { | 69 | void setCurrentItem( int id ) { |
70 | if ( id != current ) { | 70 | if ( id != current ) { |
71 | current = id; | 71 | current = id; |
72 | setIconSet( *popup()->iconSet( id ) ); | 72 | setIconSet( *popup()->iconSet( id ) ); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | virtual QSize sizeHint() const { | 76 | virtual QSize sizeHint() const { |
77 | return QToolButton::sizeHint() + QSize( 4, 0 ); | 77 | return QToolButton::sizeHint() + QSize( 4, 0 ); |
78 | } | 78 | } |
79 | 79 | ||
80 | signals: | 80 | signals: |
81 | void activated( int id ); | 81 | void activated( int id ); |
82 | 82 | ||
83 | protected slots: | 83 | protected slots: |
84 | void selected( int id ) { | 84 | void selected( int id ) { |
85 | current = id; | 85 | current = id; |
86 | setIconSet( *popup()->iconSet( id ) ); | 86 | setIconSet( *popup()->iconSet( id ) ); |
87 | emit activated( id ); | 87 | emit activated( id ); |
88 | } | 88 | } |
89 | 89 | ||
90 | protected: | 90 | protected: |
91 | virtual void drawButtonLabel( QPainter *p ) { | 91 | virtual void drawButtonLabel( QPainter *p ) { |
92 | p->translate( -4, 0 ); | 92 | p->translate( -4, 0 ); |
93 | QToolButton::drawButtonLabel( p ); | 93 | QToolButton::drawButtonLabel( p ); |
94 | p->translate( 4, 0 ); | 94 | p->translate( 4, 0 ); |
95 | } | 95 | } |
96 | 96 | ||
97 | private: | 97 | private: |
98 | int current; | 98 | int current; |
99 | }; | 99 | }; |
100 | 100 | ||
101 | //=========================================================================== | 101 | //=========================================================================== |
102 | 102 | ||
103 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl ) | 103 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl ) |
104 | : QMainWindow( parent, name, fl ), | 104 | : QMainWindow( parent, name, fl ), |
105 | doc( 0 ) | 105 | doc( 0 ) |
106 | { | 106 | { |
107 | setRightJustification(TRUE); | 107 | setRightJustification(TRUE); |
108 | 108 | ||
109 | editorStack = new QWidgetStack( this ); | 109 | editorStack = new QWidgetStack( this ); |
110 | 110 | ||
111 | fileSelector = new FileSelector( "text/html", | 111 | fileSelector = new FileSelector( "text/html", |
112 | editorStack, "fileselector" ); | 112 | editorStack, "fileselector" ); |
113 | 113 | ||
114 | 114 | ||
115 | fileSelector->setCloseVisible( FALSE ); | 115 | fileSelector->setCloseVisible( FALSE ); |
116 | editorStack->addWidget( fileSelector, 0 ); | 116 | editorStack->addWidget( fileSelector, 0 ); |
117 | 117 | ||
118 | editor = new Qt3::QTextEdit( editorStack ); | 118 | editor = new Qt3::QTextEdit( editorStack ); |
119 | editor->setTextFormat( Qt::RichText ); | 119 | editor->setTextFormat( Qt::RichText ); |
120 | editorStack->addWidget( editor, 1 ); | 120 | editorStack->addWidget( editor, 1 ); |
121 | 121 | ||
122 | setupActions(); | 122 | setupActions(); |
123 | 123 | ||
124 | QObject::connect( fileSelector, SIGNAL(closeMe()), | 124 | QObject::connect( fileSelector, SIGNAL(closeMe()), |
125 | this, SLOT(showEditTools()) ); | 125 | this, SLOT(showEditTools()) ); |
126 | QObject::connect( fileSelector, SIGNAL(fileSelected(const DocLnk &)), | 126 | QObject::connect( fileSelector, SIGNAL(fileSelected(const DocLnk&)), |
127 | this, SLOT(openFile(const DocLnk &)) ); | 127 | this, SLOT(openFile(const DocLnk&)) ); |
128 | QObject::connect( fileSelector, SIGNAL(newSelected(const DocLnk&)), | 128 | QObject::connect( fileSelector, SIGNAL(newSelected(const DocLnk&)), |
129 | this, SLOT(newFile(const DocLnk&)) ); | 129 | this, SLOT(newFile(const DocLnk&)) ); |
130 | 130 | ||
131 | if ( fileSelector->fileCount() < 1 ) | 131 | if ( fileSelector->fileCount() < 1 ) |
132 | fileNew(); | 132 | fileNew(); |
133 | else { | 133 | else { |
134 | fileOpen(); | 134 | fileOpen(); |
135 | } | 135 | } |
136 | doConnections( editor ); | 136 | doConnections( editor ); |
137 | 137 | ||
138 | setCentralWidget( editorStack ); | 138 | setCentralWidget( editorStack ); |
139 | } | 139 | } |
140 | 140 | ||
141 | MainWindow::~MainWindow() | 141 | MainWindow::~MainWindow() |
142 | { | 142 | { |
143 | save(); | 143 | save(); |
144 | } | 144 | } |
145 | 145 | ||
146 | void MainWindow::setupActions() | 146 | void MainWindow::setupActions() |
147 | { | 147 | { |
148 | setToolBarsMovable(false); | 148 | setToolBarsMovable(false); |
149 | 149 | ||
150 | tbMenu = new QToolBar( this ); | 150 | tbMenu = new QToolBar( this ); |
151 | tbMenu->setHorizontalStretchable( TRUE ); | 151 | tbMenu->setHorizontalStretchable( TRUE ); |
152 | 152 | ||
153 | QMenuBar *menu = new QMenuBar( tbMenu ); | 153 | QMenuBar *menu = new QMenuBar( tbMenu ); |
154 | 154 | ||
155 | tbEdit = new QToolBar( this ); | 155 | tbEdit = new QToolBar( this ); |
156 | 156 | ||
157 | QPopupMenu *file = new QPopupMenu( this ); | 157 | QPopupMenu *file = new QPopupMenu( this ); |
158 | menu->insertItem( tr("File"), file ); | 158 | menu->insertItem( tr("File"), file ); |
159 | 159 | ||
160 | QPopupMenu *edit = new QPopupMenu( this ); | 160 | QPopupMenu *edit = new QPopupMenu( this ); |
161 | menu->insertItem( tr("Edit"), edit ); | 161 | menu->insertItem( tr("Edit"), edit ); |
162 | 162 | ||
163 | // ### perhaps these shortcut keys should have some | 163 | // ### perhaps these shortcut keys should have some |
164 | // IPaq keys defined??? | 164 | // IPaq keys defined??? |
165 | QAction *a; | 165 | QAction *a; |
166 | 166 | ||
167 | a = new QAction( tr( "New" ), Resource::loadPixmap("new"), QString::null, 0, this, 0 ); | 167 | a = new QAction( tr( "New" ), Resource::loadPixmap("new"), QString::null, 0, this, 0 ); |
168 | connect( a, SIGNAL(activated()), this, SLOT(fileNew()) ); | 168 | connect( a, SIGNAL(activated()), this, SLOT(fileNew()) ); |
169 | a->addTo( file ); | 169 | a->addTo( file ); |
170 | 170 | ||
171 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 171 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
172 | connect( a, SIGNAL(activated()), this, SLOT(fileOpen()) ); | 172 | connect( a, SIGNAL(activated()), this, SLOT(fileOpen()) ); |
173 | a->addTo( file ); | 173 | a->addTo( file ); |
174 | 174 | ||
175 | a = new QAction( tr( "Undo" ), Resource::loadIconSet("undo"), | 175 | a = new QAction( tr( "Undo" ), Resource::loadIconSet("undo"), |
176 | QString::null, 0, this, "editUndo" ); | 176 | QString::null, 0, this, "editUndo" ); |
177 | connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) ); | 177 | connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) ); |
178 | connect( editor, SIGNAL(undoAvailable(bool)), a, SLOT(setEnabled(bool)) ); | 178 | connect( editor, SIGNAL(undoAvailable(bool)), a, SLOT(setEnabled(bool)) ); |
179 | a->addTo( tbEdit ); | 179 | a->addTo( tbEdit ); |
180 | a->addTo( edit ); | 180 | a->addTo( edit ); |
181 | a = new QAction( tr( "Redo" ), Resource::loadIconSet("redo"), | 181 | a = new QAction( tr( "Redo" ), Resource::loadIconSet("redo"), |
182 | QString::null, 0, this, "editRedo" ); | 182 | QString::null, 0, this, "editRedo" ); |
183 | connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) ); | 183 | connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) ); |
184 | connect( editor, SIGNAL(redoAvailable(bool)), a, SLOT(setEnabled(bool)) ); | 184 | connect( editor, SIGNAL(redoAvailable(bool)), a, SLOT(setEnabled(bool)) ); |
185 | a->addTo( tbEdit ); | 185 | a->addTo( tbEdit ); |
186 | a->addTo( edit ); | 186 | a->addTo( edit ); |
187 | 187 | ||
188 | edit->insertSeparator(); | 188 | edit->insertSeparator(); |
189 | 189 | ||
190 | a = new QAction( tr( "Copy" ), Resource::loadIconSet("copy"), | 190 | a = new QAction( tr( "Copy" ), Resource::loadIconSet("copy"), |
191 | QString::null, 0, this, "editCopy" ); | 191 | QString::null, 0, this, "editCopy" ); |
192 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 192 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
193 | connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); | 193 | connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); |
194 | a->addTo( tbEdit ); | 194 | a->addTo( tbEdit ); |
195 | a->addTo( edit ); | 195 | a->addTo( edit ); |
196 | a = new QAction( tr( "Cut" ), Resource::loadIconSet("cut"), | 196 | a = new QAction( tr( "Cut" ), Resource::loadIconSet("cut"), |
197 | QString::null, 0, this, "editCut" ); | 197 | QString::null, 0, this, "editCut" ); |
198 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 198 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
199 | connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); | 199 | connect( editor, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool)) ); |
200 | a->addTo( tbEdit ); | 200 | a->addTo( tbEdit ); |
201 | a->addTo( edit ); | 201 | a->addTo( edit ); |
202 | a = new QAction( tr( "Paste" ), Resource::loadPixmap("paste"), | 202 | a = new QAction( tr( "Paste" ), Resource::loadPixmap("paste"), |
203 | QString::null, 0, this, "editPaste" ); | 203 | QString::null, 0, this, "editPaste" ); |
204 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 204 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
205 | a->addTo( tbEdit ); | 205 | a->addTo( tbEdit ); |
206 | a->addTo( edit ); | 206 | a->addTo( edit ); |
207 | 207 | ||
208 | tbFont = new QToolBar( this ); | 208 | tbFont = new QToolBar( this ); |
209 | tbFont->setLabel( "Font Actions" ); | 209 | tbFont->setLabel( "Font Actions" ); |
210 | tbFont->setHorizontalStretchable(TRUE); | 210 | tbFont->setHorizontalStretchable(TRUE); |
211 | 211 | ||
212 | comboFont = new QComboBox( FALSE, tbFont ); | 212 | comboFont = new QComboBox( FALSE, tbFont ); |
213 | FontDatabase db; | 213 | FontDatabase db; |
214 | QStringList f= db.families(); | 214 | QStringList f= db.families(); |
215 | comboFont->insertStringList( db.families() ); | 215 | comboFont->insertStringList( db.families() ); |
216 | connect( comboFont, SIGNAL( activated( const QString & ) ), | 216 | connect( comboFont, SIGNAL( activated(const QString&) ), |
217 | this, SLOT( textFamily( const QString & ) ) ); | 217 | this, SLOT( textFamily(const QString&) ) ); |
218 | comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( QApplication::font().family() ) ) ); | 218 | comboFont->setCurrentItem( comboFont->listBox()->index( comboFont->listBox()->findItem( QApplication::font().family() ) ) ); |
219 | comboFont->setMaximumWidth(90); | 219 | comboFont->setMaximumWidth(90); |
220 | 220 | ||
221 | comboSize = new QComboBox( TRUE, tbFont ); | 221 | comboSize = new QComboBox( TRUE, tbFont ); |
222 | QValueList<int> sizes = db.standardSizes(); | 222 | QValueList<int> sizes = db.standardSizes(); |
223 | QValueList<int>::Iterator it = sizes.begin(); | 223 | QValueList<int>::Iterator it = sizes.begin(); |
224 | for ( ; it != sizes.end(); ++it ) | 224 | for ( ; it != sizes.end(); ++it ) |
225 | comboSize->insertItem( QString::number( *it ) ); | 225 | comboSize->insertItem( QString::number( *it ) ); |
226 | connect( comboSize, SIGNAL( activated( const QString & ) ), | 226 | connect( comboSize, SIGNAL( activated(const QString&) ), |
227 | this, SLOT( textSize( const QString & ) ) ); | 227 | this, SLOT( textSize(const QString&) ) ); |
228 | comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) ); | 228 | comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) ); |
229 | comboSize->setFixedWidth( 38 ); | 229 | comboSize->setFixedWidth( 38 ); |
230 | 230 | ||
231 | tbStyle = new QToolBar( this ); | 231 | tbStyle = new QToolBar( this ); |
232 | tbStyle->setLabel( "Style Actions" ); | 232 | tbStyle->setLabel( "Style Actions" ); |
233 | 233 | ||
234 | actionTextBold = new QAction( tr( "Bold" ), | 234 | actionTextBold = new QAction( tr( "Bold" ), |
235 | Resource::loadPixmap("bold"), | 235 | Resource::loadPixmap("bold"), |
236 | QString::null, CTRL + Key_B, | 236 | QString::null, CTRL + Key_B, |
237 | this, "textBold" ); | 237 | this, "textBold" ); |
238 | connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) ); | 238 | connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) ); |
239 | actionTextBold->addTo( tbStyle ); | 239 | actionTextBold->addTo( tbStyle ); |
240 | actionTextBold->setToggleAction( TRUE ); | 240 | actionTextBold->setToggleAction( TRUE ); |
241 | actionTextItalic = new QAction( tr( "Italic" ), | 241 | actionTextItalic = new QAction( tr( "Italic" ), |
242 | Resource::loadPixmap("italic"), | 242 | Resource::loadPixmap("italic"), |
243 | tr( "&Italic" ), CTRL + Key_I, | 243 | tr( "&Italic" ), CTRL + Key_I, |
244 | this, "textItalic" ); | 244 | this, "textItalic" ); |
245 | connect( actionTextItalic, SIGNAL( activated() ), this, | 245 | connect( actionTextItalic, SIGNAL( activated() ), this, |
246 | SLOT( textItalic() ) ); | 246 | SLOT( textItalic() ) ); |
247 | actionTextItalic->addTo( tbStyle ); | 247 | actionTextItalic->addTo( tbStyle ); |
248 | actionTextItalic->setToggleAction( TRUE ); | 248 | actionTextItalic->setToggleAction( TRUE ); |
249 | actionTextUnderline = new QAction( tr( "Underline" ), | 249 | actionTextUnderline = new QAction( tr( "Underline" ), |
250 | Resource::loadPixmap("underline"), | 250 | Resource::loadPixmap("underline"), |
251 | tr( "&Underline" ), CTRL + Key_U, | 251 | tr( "&Underline" ), CTRL + Key_U, |
252 | this, "textUnderline" ); | 252 | this, "textUnderline" ); |
253 | connect( actionTextUnderline, SIGNAL( activated() ), | 253 | connect( actionTextUnderline, SIGNAL( activated() ), |
254 | this, SLOT( textUnderline() ) ); | 254 | this, SLOT( textUnderline() ) ); |
255 | actionTextUnderline->addTo( tbStyle ); | 255 | actionTextUnderline->addTo( tbStyle ); |
256 | actionTextUnderline->setToggleAction( TRUE ); | 256 | actionTextUnderline->setToggleAction( TRUE ); |
257 | 257 | ||
258 | alignMenu = new ButtonMenu( tbStyle ); | 258 | alignMenu = new ButtonMenu( tbStyle ); |
259 | alignMenu->insertItem( Resource::loadPixmap("left"), tr("Left"), AlignLeft ); | 259 | alignMenu->insertItem( Resource::loadPixmap("left"), tr("Left"), AlignLeft ); |
260 | alignMenu->insertItem( Resource::loadPixmap("center"), tr("Center"), AlignCenter ); | 260 | alignMenu->insertItem( Resource::loadPixmap("center"), tr("Center"), AlignCenter ); |
261 | alignMenu->insertItem( Resource::loadPixmap("right"), tr("Right"), AlignRight ); | 261 | alignMenu->insertItem( Resource::loadPixmap("right"), tr("Right"), AlignRight ); |
262 | alignMenu->insertItem( Resource::loadPixmap("opie-write/justify"), tr("Full"), Qt3::AlignJustify ); | 262 | alignMenu->insertItem( Resource::loadPixmap("opie-write/justify"), tr("Full"), Qt3::AlignJustify ); |
263 | connect( alignMenu, SIGNAL(activated(int)), this, SLOT(textAlign(int)) ); | 263 | connect( alignMenu, SIGNAL(activated(int)), this, SLOT(textAlign(int)) ); |
264 | } | 264 | } |
265 | 265 | ||
266 | Qt3::QTextEdit *MainWindow::currentEditor() const | 266 | Qt3::QTextEdit *MainWindow::currentEditor() const |
267 | { | 267 | { |
268 | return editor; | 268 | return editor; |
269 | } | 269 | } |
270 | 270 | ||
271 | void MainWindow::doConnections( Qt3::QTextEdit *e ) | 271 | void MainWindow::doConnections( Qt3::QTextEdit *e ) |
272 | { | 272 | { |
273 | connect( e, SIGNAL( currentFontChanged( const QFont & ) ), | 273 | connect( e, SIGNAL( currentFontChanged(const QFont&) ), |
274 | this, SLOT( fontChanged( const QFont & ) ) ); | 274 | this, SLOT( fontChanged(const QFont&) ) ); |
275 | connect( e, SIGNAL( currentColorChanged( const QColor & ) ), | 275 | connect( e, SIGNAL( currentColorChanged(const QColor&) ), |
276 | this, SLOT( colorChanged( const QColor & ) ) ); | 276 | this, SLOT( colorChanged(const QColor&) ) ); |
277 | connect( e, SIGNAL( currentAlignmentChanged( int ) ), | 277 | connect( e, SIGNAL( currentAlignmentChanged(int) ), |
278 | this, SLOT( alignmentChanged( int ) ) ); | 278 | this, SLOT( alignmentChanged(int) ) ); |
279 | } | 279 | } |
280 | 280 | ||
281 | void MainWindow::updateFontSizeCombo( const QFont &f ) | 281 | void MainWindow::updateFontSizeCombo( const QFont &f ) |
282 | { | 282 | { |
283 | comboSize->clear(); | 283 | comboSize->clear(); |
284 | FontDatabase fdb; | 284 | FontDatabase fdb; |
285 | QValueList<int> sizes = fdb.pointSizes( f.family() ); | 285 | QValueList<int> sizes = fdb.pointSizes( f.family() ); |
286 | QValueList<int>::Iterator it = sizes.begin(); | 286 | QValueList<int>::Iterator it = sizes.begin(); |
287 | for ( ; it != sizes.end(); ++it ) | 287 | for ( ; it != sizes.end(); ++it ) |
288 | comboSize->insertItem( QString::number( *it ) ); | 288 | comboSize->insertItem( QString::number( *it ) ); |
289 | } | 289 | } |
290 | 290 | ||
291 | void MainWindow::editUndo() | 291 | void MainWindow::editUndo() |
292 | { | 292 | { |
293 | if ( !currentEditor() ) | 293 | if ( !currentEditor() ) |
294 | return; | 294 | return; |
295 | currentEditor()->undo(); | 295 | currentEditor()->undo(); |
296 | } | 296 | } |
297 | 297 | ||
298 | void MainWindow::editRedo() | 298 | void MainWindow::editRedo() |
299 | { | 299 | { |
300 | if ( !currentEditor() ) | 300 | if ( !currentEditor() ) |
301 | return; | 301 | return; |
302 | currentEditor()->redo(); | 302 | currentEditor()->redo(); |
303 | } | 303 | } |
304 | 304 | ||
305 | void MainWindow::editCut() | 305 | void MainWindow::editCut() |
306 | { | 306 | { |
307 | if ( !currentEditor() ) | 307 | if ( !currentEditor() ) |
308 | return; | 308 | return; |
309 | currentEditor()->cut(); | 309 | currentEditor()->cut(); |
310 | } | 310 | } |
311 | 311 | ||
312 | void MainWindow::editCopy() | 312 | void MainWindow::editCopy() |
313 | { | 313 | { |
314 | if ( !currentEditor() ) | 314 | if ( !currentEditor() ) |
315 | return; | 315 | return; |
316 | currentEditor()->copy(); | 316 | currentEditor()->copy(); |
317 | } | 317 | } |
318 | 318 | ||
319 | void MainWindow::editPaste() | 319 | void MainWindow::editPaste() |
320 | { | 320 | { |
321 | if ( !currentEditor() ) | 321 | if ( !currentEditor() ) |
322 | return; | 322 | return; |
323 | currentEditor()->paste(); | 323 | currentEditor()->paste(); |
324 | } | 324 | } |
325 | 325 | ||
326 | void MainWindow::textBold() | 326 | void MainWindow::textBold() |
327 | { | 327 | { |
328 | if ( !currentEditor() ) | 328 | if ( !currentEditor() ) |
329 | return; | 329 | return; |
330 | currentEditor()->setBold( actionTextBold->isOn() ); | 330 | currentEditor()->setBold( actionTextBold->isOn() ); |
331 | } | 331 | } |
332 | 332 | ||
333 | void MainWindow::textUnderline() | 333 | void MainWindow::textUnderline() |
334 | { | 334 | { |
335 | if ( !currentEditor() ) | 335 | if ( !currentEditor() ) |
336 | return; | 336 | return; |
337 | currentEditor()->setUnderline( actionTextUnderline->isOn() ); | 337 | currentEditor()->setUnderline( actionTextUnderline->isOn() ); |
338 | } | 338 | } |
339 | 339 | ||
340 | void MainWindow::textItalic() | 340 | void MainWindow::textItalic() |
341 | { | 341 | { |
342 | if ( !currentEditor() ) | 342 | if ( !currentEditor() ) |
343 | return; | 343 | return; |
344 | currentEditor()->setItalic( actionTextItalic->isOn() ); | 344 | currentEditor()->setItalic( actionTextItalic->isOn() ); |
345 | } | 345 | } |
346 | 346 | ||
347 | void MainWindow::textFamily( const QString &f ) | 347 | void MainWindow::textFamily( const QString &f ) |
348 | { | 348 | { |
349 | if ( !currentEditor() ) | 349 | if ( !currentEditor() ) |
350 | return; | 350 | return; |
351 | currentEditor()->setFamily( f ); | 351 | currentEditor()->setFamily( f ); |
352 | currentEditor()->viewport()->setFocus(); | 352 | currentEditor()->viewport()->setFocus(); |
353 | } | 353 | } |
354 | 354 | ||
355 | void MainWindow::textSize( const QString &p ) | 355 | void MainWindow::textSize( const QString &p ) |
356 | { | 356 | { |
357 | if ( !currentEditor() ) | 357 | if ( !currentEditor() ) |
358 | return; | 358 | return; |
359 | currentEditor()->setPointSize( p.toInt() ); | 359 | currentEditor()->setPointSize( p.toInt() ); |
360 | currentEditor()->viewport()->setFocus(); | 360 | currentEditor()->viewport()->setFocus(); |
361 | } | 361 | } |
362 | 362 | ||
363 | void MainWindow::textStyle( int i ) | 363 | void MainWindow::textStyle( int i ) |
364 | { | 364 | { |
365 | if ( !currentEditor() ) | 365 | if ( !currentEditor() ) |
366 | return; | 366 | return; |
367 | if ( i == 0 ) | 367 | if ( i == 0 ) |
368 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayBlock, | 368 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayBlock, |
369 | Qt3::QStyleSheetItem::ListDisc ); | 369 | Qt3::QStyleSheetItem::ListDisc ); |
370 | else if ( i == 1 ) | 370 | else if ( i == 1 ) |
371 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, | 371 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, |
372 | Qt3::QStyleSheetItem::ListDisc ); | 372 | Qt3::QStyleSheetItem::ListDisc ); |
373 | else if ( i == 2 ) | 373 | else if ( i == 2 ) |
374 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, | 374 | currentEditor()->setParagType( Qt3::QStyleSheetItem::DisplayListItem, |
diff --git a/noncore/apps/opie-write/qtextedit.cpp b/noncore/apps/opie-write/qtextedit.cpp index 27dd515..73b7b7b 100644 --- a/noncore/apps/opie-write/qtextedit.cpp +++ b/noncore/apps/opie-write/qtextedit.cpp | |||
@@ -584,194 +584,194 @@ static bool block_set_alignment = FALSE; | |||
584 | 584 | ||
585 | The new alignment is \a a. | 585 | The new alignment is \a a. |
586 | 586 | ||
587 | \sa setAlignment() | 587 | \sa setAlignment() |
588 | */ | 588 | */ |
589 | 589 | ||
590 | /*! \fn void QTextEdit::cursorPositionChanged( QTextCursor *c ) | 590 | /*! \fn void QTextEdit::cursorPositionChanged( QTextCursor *c ) |
591 | 591 | ||
592 | This signal is emitted if the position of the cursor changed. \a c | 592 | This signal is emitted if the position of the cursor changed. \a c |
593 | points to the text cursor object. | 593 | points to the text cursor object. |
594 | 594 | ||
595 | \sa setCursorPosition() | 595 | \sa setCursorPosition() |
596 | */ | 596 | */ |
597 | 597 | ||
598 | /*! \overload void QTextEdit::cursorPositionChanged( int para, int pos ) | 598 | /*! \overload void QTextEdit::cursorPositionChanged( int para, int pos ) |
599 | 599 | ||
600 | This signal is emitted if the position of the cursor changed. \a | 600 | This signal is emitted if the position of the cursor changed. \a |
601 | para contains the paragraph index and \a pos contains the character | 601 | para contains the paragraph index and \a pos contains the character |
602 | position within the paragraph. | 602 | position within the paragraph. |
603 | 603 | ||
604 | \sa setCursorPosition() | 604 | \sa setCursorPosition() |
605 | */ | 605 | */ |
606 | 606 | ||
607 | /*! \fn void QTextEdit::returnPressed() | 607 | /*! \fn void QTextEdit::returnPressed() |
608 | 608 | ||
609 | This signal is emitted if the user pressed the Return or the Enter key. | 609 | This signal is emitted if the user pressed the Return or the Enter key. |
610 | */ | 610 | */ |
611 | 611 | ||
612 | /*! | 612 | /*! |
613 | \fn QTextCursor *QTextEdit::textCursor() const | 613 | \fn QTextCursor *QTextEdit::textCursor() const |
614 | 614 | ||
615 | Returns the text edit's text cursor. | 615 | Returns the text edit's text cursor. |
616 | 616 | ||
617 | \warning QTextCursor is not in the public API, but in special | 617 | \warning QTextCursor is not in the public API, but in special |
618 | circumstances you might wish to use it. | 618 | circumstances you might wish to use it. |
619 | */ | 619 | */ |
620 | 620 | ||
621 | /*! Constructs an empty QTextEdit with parent \a parent and name \a | 621 | /*! Constructs an empty QTextEdit with parent \a parent and name \a |
622 | name. | 622 | name. |
623 | */ | 623 | */ |
624 | 624 | ||
625 | QTextEdit::QTextEdit( QWidget *parent, const char *name ) | 625 | QTextEdit::QTextEdit( QWidget *parent, const char *name ) |
626 | : QScrollView( parent, name, WStaticContents | WRepaintNoErase | WResizeNoErase ), | 626 | : QScrollView( parent, name, WStaticContents | WRepaintNoErase | WResizeNoErase ), |
627 | doc( new QTextDocument( 0 ) ), undoRedoInfo( doc ) | 627 | doc( new QTextDocument( 0 ) ), undoRedoInfo( doc ) |
628 | { | 628 | { |
629 | init(); | 629 | init(); |
630 | } | 630 | } |
631 | 631 | ||
632 | /*! | 632 | /*! |
633 | Constructs a QTextEdit with parent \a parent and name \a name. The | 633 | Constructs a QTextEdit with parent \a parent and name \a name. The |
634 | text edit will display the text \a text using context \a context. | 634 | text edit will display the text \a text using context \a context. |
635 | 635 | ||
636 | The \a context is a path which the text edit's QMimeSourceFactory | 636 | The \a context is a path which the text edit's QMimeSourceFactory |
637 | uses to resolve the locations of files and images. It is passed to | 637 | uses to resolve the locations of files and images. It is passed to |
638 | the mimeSourceFactory() when quering data. | 638 | the mimeSourceFactory() when quering data. |
639 | 639 | ||
640 | For example if the text contains an image tag, | 640 | For example if the text contains an image tag, |
641 | \c{<img src="image.png">}, and the context is "path/to/look/in", the | 641 | \c{<img src="image.png">}, and the context is "path/to/look/in", the |
642 | QMimeSourceFactory will try to load the image from | 642 | QMimeSourceFactory will try to load the image from |
643 | "path/to/look/in/image.png". If the tag was | 643 | "path/to/look/in/image.png". If the tag was |
644 | \c{<img src="/image.png">}, the context will not be used (because | 644 | \c{<img src="/image.png">}, the context will not be used (because |
645 | QMimeSourceFactory recognizes that we have used an absolute path) | 645 | QMimeSourceFactory recognizes that we have used an absolute path) |
646 | and will try to load "/image.png". The context is applied in exactly | 646 | and will try to load "/image.png". The context is applied in exactly |
647 | the same way to \e hrefs, for example, | 647 | the same way to \e hrefs, for example, |
648 | \c{<a href="target.html">Target</a>}, would resolve to | 648 | \c{<a href="target.html">Target</a>}, would resolve to |
649 | "path/to/look/in/target.html". | 649 | "path/to/look/in/target.html". |
650 | 650 | ||
651 | */ | 651 | */ |
652 | 652 | ||
653 | QTextEdit::QTextEdit( const QString& text, const QString& context, | 653 | QTextEdit::QTextEdit( const QString& text, const QString& context, |
654 | QWidget *parent, const char *name) | 654 | QWidget *parent, const char *name) |
655 | : QScrollView( parent, name, WStaticContents | WRepaintNoErase | WResizeNoErase ), | 655 | : QScrollView( parent, name, WStaticContents | WRepaintNoErase | WResizeNoErase ), |
656 | doc( new QTextDocument( 0 ) ), undoRedoInfo( doc ) | 656 | doc( new QTextDocument( 0 ) ), undoRedoInfo( doc ) |
657 | { | 657 | { |
658 | init(); | 658 | init(); |
659 | setText( text, context ); | 659 | setText( text, context ); |
660 | } | 660 | } |
661 | 661 | ||
662 | /*! \reimp */ | 662 | /*! \reimp */ |
663 | 663 | ||
664 | QTextEdit::~QTextEdit() | 664 | QTextEdit::~QTextEdit() |
665 | { | 665 | { |
666 | delete undoRedoInfo.d; | 666 | delete undoRedoInfo.d; |
667 | undoRedoInfo.d = 0; | 667 | undoRedoInfo.d = 0; |
668 | delete cursor; | 668 | delete cursor; |
669 | delete doc; | 669 | delete doc; |
670 | delete d; | 670 | delete d; |
671 | } | 671 | } |
672 | 672 | ||
673 | void QTextEdit::init() | 673 | void QTextEdit::init() |
674 | { | 674 | { |
675 | setFrameStyle( Sunken ); | 675 | setFrameStyle( Sunken ); |
676 | undoEnabled = TRUE; | 676 | undoEnabled = TRUE; |
677 | readonly = TRUE; | 677 | readonly = TRUE; |
678 | setReadOnly( FALSE ); | 678 | setReadOnly( FALSE ); |
679 | d = new QTextEditPrivate; | 679 | d = new QTextEditPrivate; |
680 | connect( doc, SIGNAL( minimumWidthChanged( int ) ), | 680 | connect( doc, SIGNAL( minimumWidthChanged(int) ), |
681 | this, SLOT( documentWidthChanged( int ) ) ); | 681 | this, SLOT( documentWidthChanged(int) ) ); |
682 | 682 | ||
683 | mousePressed = FALSE; | 683 | mousePressed = FALSE; |
684 | inDoubleClick = FALSE; | 684 | inDoubleClick = FALSE; |
685 | modified = FALSE; | 685 | modified = FALSE; |
686 | onLink = QString::null; | 686 | onLink = QString::null; |
687 | overWrite = FALSE; | 687 | overWrite = FALSE; |
688 | wrapMode = WidgetWidth; | 688 | wrapMode = WidgetWidth; |
689 | wrapWidth = -1; | 689 | wrapWidth = -1; |
690 | wPolicy = AtWhiteSpace; | 690 | wPolicy = AtWhiteSpace; |
691 | inDnD = FALSE; | 691 | inDnD = FALSE; |
692 | 692 | ||
693 | doc->setFormatter( new QTextFormatterBreakWords ); | 693 | doc->setFormatter( new QTextFormatterBreakWords ); |
694 | doc->formatCollection()->defaultFormat()->setFont( QScrollView::font() ); | 694 | doc->formatCollection()->defaultFormat()->setFont( QScrollView::font() ); |
695 | doc->formatCollection()->defaultFormat()->setColor( colorGroup().color( QColorGroup::Text ) ); | 695 | doc->formatCollection()->defaultFormat()->setColor( colorGroup().color( QColorGroup::Text ) ); |
696 | currentFormat = doc->formatCollection()->defaultFormat(); | 696 | currentFormat = doc->formatCollection()->defaultFormat(); |
697 | currentAlignment = Qt3::AlignAuto; | 697 | currentAlignment = Qt3::AlignAuto; |
698 | 698 | ||
699 | viewport()->setBackgroundMode( PaletteBase ); | 699 | viewport()->setBackgroundMode( PaletteBase ); |
700 | viewport()->setAcceptDrops( TRUE ); | 700 | viewport()->setAcceptDrops( TRUE ); |
701 | resizeContents( 0, doc->lastParagraph() ? | 701 | resizeContents( 0, doc->lastParagraph() ? |
702 | ( doc->lastParagraph()->paragId() + 1 ) * doc->formatCollection()->defaultFormat()->height() : 0 ); | 702 | ( doc->lastParagraph()->paragId() + 1 ) * doc->formatCollection()->defaultFormat()->height() : 0 ); |
703 | 703 | ||
704 | setKeyCompression( TRUE ); | 704 | setKeyCompression( TRUE ); |
705 | viewport()->setMouseTracking( TRUE ); | 705 | viewport()->setMouseTracking( TRUE ); |
706 | #ifndef QT_NO_CURSOR | 706 | #ifndef QT_NO_CURSOR |
707 | viewport()->setCursor( isReadOnly() ? arrowCursor : ibeamCursor ); | 707 | viewport()->setCursor( isReadOnly() ? arrowCursor : ibeamCursor ); |
708 | #endif | 708 | #endif |
709 | cursor = new QTextCursor( doc ); | 709 | cursor = new QTextCursor( doc ); |
710 | 710 | ||
711 | formatTimer = new QTimer( this ); | 711 | formatTimer = new QTimer( this ); |
712 | connect( formatTimer, SIGNAL( timeout() ), | 712 | connect( formatTimer, SIGNAL( timeout() ), |
713 | this, SLOT( formatMore() ) ); | 713 | this, SLOT( formatMore() ) ); |
714 | lastFormatted = doc->firstParagraph(); | 714 | lastFormatted = doc->firstParagraph(); |
715 | 715 | ||
716 | scrollTimer = new QTimer( this ); | 716 | scrollTimer = new QTimer( this ); |
717 | connect( scrollTimer, SIGNAL( timeout() ), | 717 | connect( scrollTimer, SIGNAL( timeout() ), |
718 | this, SLOT( autoScrollTimerDone() ) ); | 718 | this, SLOT( autoScrollTimerDone() ) ); |
719 | 719 | ||
720 | interval = 0; | 720 | interval = 0; |
721 | changeIntervalTimer = new QTimer( this ); | 721 | changeIntervalTimer = new QTimer( this ); |
722 | connect( changeIntervalTimer, SIGNAL( timeout() ), | 722 | connect( changeIntervalTimer, SIGNAL( timeout() ), |
723 | this, SLOT( doChangeInterval() ) ); | 723 | this, SLOT( doChangeInterval() ) ); |
724 | 724 | ||
725 | cursorVisible = TRUE; | 725 | cursorVisible = TRUE; |
726 | blinkTimer = new QTimer( this ); | 726 | blinkTimer = new QTimer( this ); |
727 | connect( blinkTimer, SIGNAL( timeout() ), | 727 | connect( blinkTimer, SIGNAL( timeout() ), |
728 | this, SLOT( blinkCursor() ) ); | 728 | this, SLOT( blinkCursor() ) ); |
729 | 729 | ||
730 | #ifndef QT_NO_DRAGANDDROP | 730 | #ifndef QT_NO_DRAGANDDROP |
731 | dragStartTimer = new QTimer( this ); | 731 | dragStartTimer = new QTimer( this ); |
732 | connect( dragStartTimer, SIGNAL( timeout() ), | 732 | connect( dragStartTimer, SIGNAL( timeout() ), |
733 | this, SLOT( startDrag() ) ); | 733 | this, SLOT( startDrag() ) ); |
734 | #endif | 734 | #endif |
735 | 735 | ||
736 | 736 | ||
737 | formatMore(); | 737 | formatMore(); |
738 | 738 | ||
739 | blinkCursorVisible = FALSE; | 739 | blinkCursorVisible = FALSE; |
740 | 740 | ||
741 | viewport()->setFocusProxy( this ); | 741 | viewport()->setFocusProxy( this ); |
742 | viewport()->setFocusPolicy( WheelFocus ); | 742 | viewport()->setFocusPolicy( WheelFocus ); |
743 | viewport()->installEventFilter( this ); | 743 | viewport()->installEventFilter( this ); |
744 | installEventFilter( this ); | 744 | installEventFilter( this ); |
745 | } | 745 | } |
746 | 746 | ||
747 | void QTextEdit::paintDocument( bool drawAll, QPainter *p, int cx, int cy, int cw, int ch ) | 747 | void QTextEdit::paintDocument( bool drawAll, QPainter *p, int cx, int cy, int cw, int ch ) |
748 | { | 748 | { |
749 | bool drawCur = hasFocus() || viewport()->hasFocus(); | 749 | bool drawCur = hasFocus() || viewport()->hasFocus(); |
750 | if ( hasSelectedText() || isReadOnly() || !cursorVisible ) | 750 | if ( hasSelectedText() || isReadOnly() || !cursorVisible ) |
751 | drawCur = FALSE; | 751 | drawCur = FALSE; |
752 | QColorGroup g = colorGroup(); | 752 | QColorGroup g = colorGroup(); |
753 | if ( doc->paper() ) | 753 | if ( doc->paper() ) |
754 | g.setBrush( QColorGroup::Base, *doc->paper() ); | 754 | g.setBrush( QColorGroup::Base, *doc->paper() ); |
755 | 755 | ||
756 | if ( contentsY() < doc->y() ) { | 756 | if ( contentsY() < doc->y() ) { |
757 | p->fillRect( contentsX(), contentsY(), visibleWidth(), doc->y(), | 757 | p->fillRect( contentsX(), contentsY(), visibleWidth(), doc->y(), |
758 | g.brush( QColorGroup::Base ) ); | 758 | g.brush( QColorGroup::Base ) ); |
759 | } | 759 | } |
760 | if ( drawAll && doc->width() - contentsX() < cx + cw ) { | 760 | if ( drawAll && doc->width() - contentsX() < cx + cw ) { |
761 | p->fillRect( doc->width() - contentsX(), cy, cx + cw - doc->width() + contentsX(), ch, | 761 | p->fillRect( doc->width() - contentsX(), cy, cx + cw - doc->width() + contentsX(), ch, |
762 | g.brush( QColorGroup::Base ) ); | 762 | g.brush( QColorGroup::Base ) ); |
763 | } | 763 | } |
764 | 764 | ||
765 | p->setBrushOrigin( -contentsX(), -contentsY() ); | 765 | p->setBrushOrigin( -contentsX(), -contentsY() ); |
766 | 766 | ||
767 | lastFormatted = doc->draw( p, cx, cy, cw, ch, g, !drawAll, drawCur, cursor ); | 767 | lastFormatted = doc->draw( p, cx, cy, cw, ch, g, !drawAll, drawCur, cursor ); |
768 | 768 | ||
769 | if ( lastFormatted == doc->lastParagraph() ) | 769 | if ( lastFormatted == doc->lastParagraph() ) |
770 | resizeContents( contentsWidth(), doc->height() ); | 770 | resizeContents( contentsWidth(), doc->height() ); |
771 | 771 | ||
772 | if ( contentsHeight() < visibleHeight() && ( !doc->lastParagraph() || doc->lastParagraph()->isValid() ) && drawAll ) | 772 | if ( contentsHeight() < visibleHeight() && ( !doc->lastParagraph() || doc->lastParagraph()->isValid() ) && drawAll ) |
773 | p->fillRect( 0, contentsHeight(), visibleWidth(), | 773 | p->fillRect( 0, contentsHeight(), visibleWidth(), |
774 | visibleHeight() - contentsHeight(), g.brush( QColorGroup::Base ) ); | 774 | visibleHeight() - contentsHeight(), g.brush( QColorGroup::Base ) ); |
775 | } | 775 | } |
776 | 776 | ||
777 | /*! \reimp */ | 777 | /*! \reimp */ |
diff --git a/noncore/apps/qashmoney/accountdisplay.cpp b/noncore/apps/qashmoney/accountdisplay.cpp index 5ef5454..0fe5b09 100755 --- a/noncore/apps/qashmoney/accountdisplay.cpp +++ b/noncore/apps/qashmoney/accountdisplay.cpp | |||
@@ -1,390 +1,390 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qheader.h> | 2 | #include <qheader.h> |
3 | 3 | ||
4 | #include "accountdisplay.h" | 4 | #include "accountdisplay.h" |
5 | #include "newaccount.h" | 5 | #include "newaccount.h" |
6 | #include "transaction.h" | 6 | #include "transaction.h" |
7 | #include "transferdialog.h" | 7 | #include "transferdialog.h" |
8 | #include "transfer.h" | 8 | #include "transfer.h" |
9 | 9 | ||
10 | extern Account *account; | 10 | extern Account *account; |
11 | extern Transaction *transaction; | 11 | extern Transaction *transaction; |
12 | extern Transfer *transfer; | 12 | extern Transfer *transfer; |
13 | extern Preferences *preferences; | 13 | extern Preferences *preferences; |
14 | 14 | ||
15 | AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent ) | 15 | AccountDisplay::AccountDisplay ( QWidget *parent ) : QWidget ( parent ) |
16 | { | 16 | { |
17 | cleared = 0; | 17 | cleared = 0; |
18 | 18 | ||
19 | firstline = new QHBox ( this ); | 19 | firstline = new QHBox ( this ); |
20 | firstline->setSpacing ( 2 ); | 20 | firstline->setSpacing ( 2 ); |
21 | 21 | ||
22 | newaccount = new QPushButton ( firstline ); | 22 | newaccount = new QPushButton ( firstline ); |
23 | newaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") ); | 23 | newaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") ); |
24 | connect ( newaccount, SIGNAL ( released () ), this, SLOT ( addAccount () ) ); | 24 | connect ( newaccount, SIGNAL ( released() ), this, SLOT ( addAccount() ) ); |
25 | 25 | ||
26 | editaccount = new QPushButton ( firstline ); | 26 | editaccount = new QPushButton ( firstline ); |
27 | editaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); | 27 | editaccount->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); |
28 | connect ( editaccount, SIGNAL ( released () ), this, SLOT ( editAccount () ) ); | 28 | connect ( editaccount, SIGNAL ( released() ), this, SLOT ( editAccount() ) ); |
29 | 29 | ||
30 | deleteaccount = new QPushButton ( firstline ); | 30 | deleteaccount = new QPushButton ( firstline ); |
31 | deleteaccount->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") ); | 31 | deleteaccount->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") ); |
32 | connect ( deleteaccount, SIGNAL ( released () ), this, SLOT ( deleteAccount () ) ); | 32 | connect ( deleteaccount, SIGNAL ( released() ), this, SLOT ( deleteAccount() ) ); |
33 | 33 | ||
34 | transferbutton = new QPushButton ( firstline ); | 34 | transferbutton = new QPushButton ( firstline ); |
35 | transferbutton->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/transfer.png") ); | 35 | transferbutton->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/transfer.png") ); |
36 | transferbutton->setToggleButton ( TRUE ); | 36 | transferbutton->setToggleButton ( TRUE ); |
37 | connect ( transferbutton, SIGNAL ( toggled ( bool ) ), this, SLOT ( accountTransfer ( bool ) ) ); | 37 | connect ( transferbutton, SIGNAL ( toggled(bool) ), this, SLOT ( accountTransfer(bool) ) ); |
38 | 38 | ||
39 | listview = new QListView ( this ); | 39 | listview = new QListView ( this ); |
40 | listview->setAllColumnsShowFocus ( TRUE ); | 40 | listview->setAllColumnsShowFocus ( TRUE ); |
41 | listview->setShowSortIndicator ( TRUE ); | 41 | listview->setShowSortIndicator ( TRUE ); |
42 | listview->setRootIsDecorated ( TRUE ); | 42 | listview->setRootIsDecorated ( TRUE ); |
43 | listview->setMultiSelection ( FALSE ); | 43 | listview->setMultiSelection ( FALSE ); |
44 | connect ( listview, SIGNAL ( expanded ( QListViewItem * ) ), this, SLOT ( setAccountExpanded ( QListViewItem * ) ) ); | 44 | connect ( listview, SIGNAL ( expanded(QListViewItem*) ), this, SLOT ( setAccountExpanded(QListViewItem*) ) ); |
45 | connect ( listview, SIGNAL ( collapsed ( QListViewItem * ) ), this, SLOT ( setAccountCollapsed ( QListViewItem * ) ) ); | 45 | connect ( listview, SIGNAL ( collapsed(QListViewItem*) ), this, SLOT ( setAccountCollapsed(QListViewItem*) ) ); |
46 | 46 | ||
47 | listview->header()->setTracking ( FALSE ); | 47 | listview->header()->setTracking ( FALSE ); |
48 | connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) ); | 48 | connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) ); |
49 | connect ( listview->header(), SIGNAL ( clicked ( int ) ), this, SLOT ( saveSortingPreference ( int ) ) ); | 49 | connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) ); |
50 | 50 | ||
51 | layout = new QVBoxLayout ( this, 2, 5 ); | 51 | layout = new QVBoxLayout ( this, 2, 5 ); |
52 | layout->addWidget ( firstline ); | 52 | layout->addWidget ( firstline ); |
53 | layout->addWidget ( listview ); | 53 | layout->addWidget ( listview ); |
54 | } | 54 | } |
55 | 55 | ||
56 | void AccountDisplay::setTabs ( QWidget *newtab2, QTabWidget *newtabs ) | 56 | void AccountDisplay::setTabs ( QWidget *newtab2, QTabWidget *newtabs ) |
57 | { | 57 | { |
58 | tab2 = newtab2; | 58 | tab2 = newtab2; |
59 | maintabs = newtabs; | 59 | maintabs = newtabs; |
60 | } | 60 | } |
61 | 61 | ||
62 | void AccountDisplay::addAccount () | 62 | void AccountDisplay::addAccount () |
63 | { | 63 | { |
64 | // initialize local variables | 64 | // initialize local variables |
65 | int parentid = 0; | 65 | int parentid = 0; |
66 | type = 0; | 66 | type = 0; |
67 | QString parentlist [ listview->childCount() + 1 ] [ 3 ] ; | 67 | QString parentlist [ listview->childCount() + 1 ] [ 3 ] ; |
68 | 68 | ||
69 | // create new account window for entering data | 69 | // create new account window for entering data |
70 | NewAccount *newaccount = new NewAccount ( this ); | 70 | NewAccount *newaccount = new NewAccount ( this ); |
71 | int width = this->width(); | 71 | int width = this->width(); |
72 | newaccount->accountbox->setMaximumWidth ( ( int ) ( width * 0.5 ) ); | 72 | newaccount->accountbox->setMaximumWidth ( ( int ) ( width * 0.5 ) ); |
73 | newaccount->datebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 73 | newaccount->datebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
74 | newaccount->childbox->setMaximumWidth ( ( int ) ( width * 0.5 ) ); | 74 | newaccount->childbox->setMaximumWidth ( ( int ) ( width * 0.5 ) ); |
75 | newaccount->balancebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 75 | newaccount->balancebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
76 | newaccount->creditlimitbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 76 | newaccount->creditlimitbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
77 | 77 | ||
78 | // if there are no accounts, disable the child check box | 78 | // if there are no accounts, disable the child check box |
79 | if ( account->getNumberOfAccounts () == 0 ) | 79 | if ( account->getNumberOfAccounts () == 0 ) |
80 | newaccount->childcheckbox->setEnabled ( FALSE ); | 80 | newaccount->childcheckbox->setEnabled ( FALSE ); |
81 | 81 | ||
82 | // if there are accounts, fill up the pulldown menu for | 82 | // if there are accounts, fill up the pulldown menu for |
83 | // selecting a parent account. We should only add those parents without transactions | 83 | // selecting a parent account. We should only add those parents without transactions |
84 | else | 84 | else |
85 | { | 85 | { |
86 | int c = 0; | 86 | int c = 0; |
87 | QListViewItemIterator it ( listview ); | 87 | QListViewItemIterator it ( listview ); |
88 | for ( ; it.current(); ++it ) | 88 | for ( ; it.current(); ++it ) |
89 | { | 89 | { |
90 | int id = it.current()->text ( getIDColumn() ).toInt(); | 90 | int id = it.current()->text ( getIDColumn() ).toInt(); |
91 | // iterate through accountdisplay listview and add parents with no transactions | 91 | // iterate through accountdisplay listview and add parents with no transactions |
92 | // add this item to the list box only if it is a parent and has no transactions | 92 | // add this item to the list box only if it is a parent and has no transactions |
93 | if ( transfer->getNumberOfTransfers ( id ) == 0 && transaction->getNumberOfTransactions ( id ) == 0 && it.current()->parent() == 0 ) | 93 | if ( transfer->getNumberOfTransfers ( id ) == 0 && transaction->getNumberOfTransactions ( id ) == 0 && it.current()->parent() == 0 ) |
94 | { | 94 | { |
95 | newaccount->childbox->insertItem ( it.current()->text ( 0 ) ); | 95 | newaccount->childbox->insertItem ( it.current()->text ( 0 ) ); |
96 | parentlist [ c ] [ 0 ] = it.current()->text ( 0 ); | 96 | parentlist [ c ] [ 0 ] = it.current()->text ( 0 ); |
97 | parentlist [ c ] [ 1 ] = it.current()->text ( getIDColumn() ); | 97 | parentlist [ c ] [ 1 ] = it.current()->text ( getIDColumn() ); |
98 | parentlist [ c ] [ 2 ] = QString::number ( c ); | 98 | parentlist [ c ] [ 2 ] = QString::number ( c ); |
99 | c++; | 99 | c++; |
100 | } | 100 | } |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | if ( preferences->getPreference ( 4 ) == 0 ) | 104 | if ( preferences->getPreference ( 4 ) == 0 ) |
105 | newaccount->currencybox->setEnabled ( FALSE ); | 105 | newaccount->currencybox->setEnabled ( FALSE ); |
106 | 106 | ||
107 | // enter today's date in the date box as default | 107 | // enter today's date in the date box as default |
108 | QDate today = QDate::currentDate (); | 108 | QDate today = QDate::currentDate (); |
109 | int defaultday = today.day(); | 109 | int defaultday = today.day(); |
110 | int defaultmonth = today.month(); | 110 | int defaultmonth = today.month(); |
111 | int defaultyear = today.year(); | 111 | int defaultyear = today.year(); |
112 | newaccount->startdate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); | 112 | newaccount->startdate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); |
113 | 113 | ||
114 | //add account information if user pushes OK button | 114 | //add account information if user pushes OK button |
115 | if ( newaccount->exec() == QDialog::Accepted ) | 115 | if ( newaccount->exec() == QDialog::Accepted ) |
116 | { | 116 | { |
117 | if ( newaccount->childcheckbox->isChecked () == TRUE ) // set a parent id and type for a child account | 117 | if ( newaccount->childcheckbox->isChecked () == TRUE ) // set a parent id and type for a child account |
118 | { | 118 | { |
119 | // go through the parentlist we created and determine the parent accountid | 119 | // go through the parentlist we created and determine the parent accountid |
120 | // we can't use the name of the account because there may be two accounts | 120 | // we can't use the name of the account because there may be two accounts |
121 | // with the same name. This function does it all by accountid | 121 | // with the same name. This function does it all by accountid |
122 | int counter; | 122 | int counter; |
123 | for ( counter = 0; counter < listview->childCount() + 1; counter++ ) | 123 | for ( counter = 0; counter < listview->childCount() + 1; counter++ ) |
124 | if ( ( parentlist [ counter ] [ 2 ].toInt() ) == newaccount->childbox->currentItem() ) | 124 | if ( ( parentlist [ counter ] [ 2 ].toInt() ) == newaccount->childbox->currentItem() ) |
125 | { | 125 | { |
126 | parentid = parentlist [ counter ] [ 1 ].toInt(); | 126 | parentid = parentlist [ counter ] [ 1 ].toInt(); |
127 | break; | 127 | break; |
128 | } | 128 | } |
129 | type = ( newaccount->accounttype->currentItem() ) + 6; // sets account ids for child accounts. See accountdisplay.h for types | 129 | type = ( newaccount->accounttype->currentItem() ) + 6; // sets account ids for child accounts. See accountdisplay.h for types |
130 | } | 130 | } |
131 | else | 131 | else |
132 | { | 132 | { |
133 | parentid = -1; | 133 | parentid = -1; |
134 | type = newaccount->accounttype->currentItem(); // sets account ids for parent accounts | 134 | type = newaccount->accounttype->currentItem(); // sets account ids for parent accounts |
135 | } | 135 | } |
136 | 136 | ||
137 | // add the new account | 137 | // add the new account |
138 | if ( newaccount->getDateEdited () == TRUE ) | 138 | if ( newaccount->getDateEdited () == TRUE ) |
139 | account->addAccount ( newaccount->accountname->text(), parentid, newaccount->accountbalance->text().toFloat(), type, | 139 | account->addAccount ( newaccount->accountname->text(), parentid, newaccount->accountbalance->text().toFloat(), type, |
140 | newaccount->getDescription(), newaccount->creditlimit->text().toFloat(), newaccount->getYear(), | 140 | newaccount->getDescription(), newaccount->creditlimit->text().toFloat(), newaccount->getYear(), |
141 | newaccount->getMonth(), newaccount->getDay(), newaccount->accountbalance->text().toFloat(), newaccount->currencybox->currencybox->currentText() ); | 141 | newaccount->getMonth(), newaccount->getDay(), newaccount->accountbalance->text().toFloat(), newaccount->currencybox->currencybox->currentText() ); |
142 | else | 142 | else |
143 | account->addAccount ( newaccount->accountname->text (), parentid, newaccount->accountbalance->text().toFloat(), type, | 143 | account->addAccount ( newaccount->accountname->text (), parentid, newaccount->accountbalance->text().toFloat(), type, |
144 | newaccount->getDescription(), newaccount->creditlimit->text().toFloat(), defaultyear, | 144 | newaccount->getDescription(), newaccount->creditlimit->text().toFloat(), defaultyear, |
145 | defaultmonth, defaultday, newaccount->accountbalance->text().toFloat(), newaccount->currencybox->currencybox->currentText() ); | 145 | defaultmonth, defaultday, newaccount->accountbalance->text().toFloat(), newaccount->currencybox->currencybox->currentText() ); |
146 | 146 | ||
147 | if ( parentid != -1 ) | 147 | if ( parentid != -1 ) |
148 | account->changeParentAccountBalance ( parentid ); | 148 | account->changeParentAccountBalance ( parentid ); |
149 | 149 | ||
150 | // redisplay accounts | 150 | // redisplay accounts |
151 | // this function clears the account display first | 151 | // this function clears the account display first |
152 | account->displayAccounts ( listview ); | 152 | account->displayAccounts ( listview ); |
153 | setToggleButton(); | 153 | setToggleButton(); |
154 | } | 154 | } |
155 | maintabs->setTabEnabled ( tab2, FALSE ); | 155 | maintabs->setTabEnabled ( tab2, FALSE ); |
156 | } | 156 | } |
157 | 157 | ||
158 | void AccountDisplay::deleteAccount () | 158 | void AccountDisplay::deleteAccount () |
159 | { | 159 | { |
160 | if ( listview->selectedItem() == 0 ) | 160 | if ( listview->selectedItem() == 0 ) |
161 | QMessageBox::warning ( this, "QashMoney", "Please select an account\nto delete."); | 161 | QMessageBox::warning ( this, "QashMoney", "Please select an account\nto delete."); |
162 | else if ( listview->selectedItem()->parent() == 0 && listview->selectedItem()->childCount() != 0 ) | 162 | else if ( listview->selectedItem()->parent() == 0 && listview->selectedItem()->childCount() != 0 ) |
163 | QMessageBox::warning ( this, "QashMoney", "Can't delete parent accounts\nwith children"); | 163 | QMessageBox::warning ( this, "QashMoney", "Can't delete parent accounts\nwith children"); |
164 | else | 164 | else |
165 | { | 165 | { |
166 | QMessageBox mb ( "Delete Account", "This will delete all transactions\nand transfers for this account.", QMessageBox::Information, QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton ); | 166 | QMessageBox mb ( "Delete Account", "This will delete all transactions\nand transfers for this account.", QMessageBox::Information, QMessageBox::Ok, QMessageBox::Cancel, QMessageBox::NoButton ); |
167 | if ( mb.exec() == QMessageBox::Ok ) | 167 | if ( mb.exec() == QMessageBox::Ok ) |
168 | { | 168 | { |
169 | int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt (); | 169 | int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt (); |
170 | int parentid = account->getParentAccountID ( accountid ); | 170 | int parentid = account->getParentAccountID ( accountid ); |
171 | 171 | ||
172 | // delete all the transactions and transfers for the account | 172 | // delete all the transactions and transfers for the account |
173 | transaction->deleteAllTransactions ( accountid ); | 173 | transaction->deleteAllTransactions ( accountid ); |
174 | transfer->deleteAllTransfers ( accountid ); | 174 | transfer->deleteAllTransfers ( accountid ); |
175 | 175 | ||
176 | // delete the account | 176 | // delete the account |
177 | account->deleteAccount ( accountid ); | 177 | account->deleteAccount ( accountid ); |
178 | 178 | ||
179 | // update account balances | 179 | // update account balances |
180 | if ( parentid != -1 ) | 180 | if ( parentid != -1 ) |
181 | account->changeParentAccountBalance ( parentid ); | 181 | account->changeParentAccountBalance ( parentid ); |
182 | 182 | ||
183 | //redisplay accounts | 183 | //redisplay accounts |
184 | account->displayAccounts ( listview ); | 184 | account->displayAccounts ( listview ); |
185 | 185 | ||
186 | //remove all the columns from the accountdisplay if there are not any accounts | 186 | //remove all the columns from the accountdisplay if there are not any accounts |
187 | if ( account->getNumberOfAccounts() == 0 ) | 187 | if ( account->getNumberOfAccounts() == 0 ) |
188 | { | 188 | { |
189 | int columns = listview->columns(); | 189 | int columns = listview->columns(); |
190 | int counter; | 190 | int counter; |
191 | for ( counter = 0; counter <= columns; counter++ ) | 191 | for ( counter = 0; counter <= columns; counter++ ) |
192 | listview->removeColumn ( 0 ); | 192 | listview->removeColumn ( 0 ); |
193 | } | 193 | } |
194 | 194 | ||
195 | setToggleButton(); | 195 | setToggleButton(); |
196 | } | 196 | } |
197 | } | 197 | } |
198 | maintabs->setTabEnabled ( tab2, FALSE ); | 198 | maintabs->setTabEnabled ( tab2, FALSE ); |
199 | } | 199 | } |
200 | 200 | ||
201 | void AccountDisplay::setToggleButton () | 201 | void AccountDisplay::setToggleButton () |
202 | { | 202 | { |
203 | // iterate through account display and determine how many "transferable" accounts we have | 203 | // iterate through account display and determine how many "transferable" accounts we have |
204 | // if there are less than two, disable the transfer button | 204 | // if there are less than two, disable the transfer button |
205 | QListViewItemIterator it ( listview ); | 205 | QListViewItemIterator it ( listview ); |
206 | int counter = 0; | 206 | int counter = 0; |
207 | for ( ; it.current(); ++it ) | 207 | for ( ; it.current(); ++it ) |
208 | { | 208 | { |
209 | // add one to counter if we find a transferable account | 209 | // add one to counter if we find a transferable account |
210 | if ( it.current()->parent() != 0 || ( it.current()->childCount() ) == 0 ) | 210 | if ( it.current()->parent() != 0 || ( it.current()->childCount() ) == 0 ) |
211 | counter++; | 211 | counter++; |
212 | } | 212 | } |
213 | if ( counter > 1 ) | 213 | if ( counter > 1 ) |
214 | transferbutton->show(); | 214 | transferbutton->show(); |
215 | else | 215 | else |
216 | transferbutton->hide(); | 216 | transferbutton->hide(); |
217 | } | 217 | } |
218 | 218 | ||
219 | void AccountDisplay::accountTransfer ( bool state ) | 219 | void AccountDisplay::accountTransfer ( bool state ) |
220 | { | 220 | { |
221 | if ( state == TRUE ) | 221 | if ( state == TRUE ) |
222 | { | 222 | { |
223 | firstaccountid = -1; | 223 | firstaccountid = -1; |
224 | secondaccountid = -1; | 224 | secondaccountid = -1; |
225 | listview->clearSelection (); | 225 | listview->clearSelection (); |
226 | listview->setMultiSelection ( TRUE ); | 226 | listview->setMultiSelection ( TRUE ); |
227 | disableParentsWithChildren (); | 227 | disableParentsWithChildren (); |
228 | connect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); | 228 | connect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) ); |
229 | } | 229 | } |
230 | else | 230 | else |
231 | { | 231 | { |
232 | firstaccountid = -1; | 232 | firstaccountid = -1; |
233 | secondaccountid = -1; | 233 | secondaccountid = -1; |
234 | listview->clearSelection (); | 234 | listview->clearSelection (); |
235 | listview->setMultiSelection ( FALSE ); | 235 | listview->setMultiSelection ( FALSE ); |
236 | enableAccounts (); | 236 | enableAccounts (); |
237 | disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); | 237 | disconnect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) ); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | 240 | ||
241 | void AccountDisplay::getTransferAccounts ( QListViewItem * item ) | 241 | void AccountDisplay::getTransferAccounts ( QListViewItem * item ) |
242 | { | 242 | { |
243 | if ( item->parent() != 0 || item->childCount() == 0 ) // only set an account for transfer if its a child or parent with no children | 243 | if ( item->parent() != 0 || item->childCount() == 0 ) // only set an account for transfer if its a child or parent with no children |
244 | { | 244 | { |
245 | if ( firstaccountid == -1 ) | 245 | if ( firstaccountid == -1 ) |
246 | firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account | 246 | firstaccountid = item->text ( getIDColumn() ).toInt(); // set first account if we've selected a valid account |
247 | else | 247 | else |
248 | if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first | 248 | if ( item->text ( getIDColumn() ).toInt() != firstaccountid ) // set the second account if its not equal to the first |
249 | secondaccountid = item->text ( getIDColumn() ).toInt(); | 249 | secondaccountid = item->text ( getIDColumn() ).toInt(); |
250 | } | 250 | } |
251 | 251 | ||
252 | // open transfer window if both accounts are set | 252 | // open transfer window if both accounts are set |
253 | if ( firstaccountid != -1 && secondaccountid != -1 ) | 253 | if ( firstaccountid != -1 && secondaccountid != -1 ) |
254 | { | 254 | { |
255 | // construct the transferdialog window | 255 | // construct the transferdialog window |
256 | TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid ); | 256 | TransferDialog *td = new TransferDialog ( this, firstaccountid, secondaccountid ); |
257 | 257 | ||
258 | // enter today's date in the date box as default | 258 | // enter today's date in the date box as default |
259 | QDate today = QDate::currentDate (); | 259 | QDate today = QDate::currentDate (); |
260 | int defaultday = today.day(); | 260 | int defaultday = today.day(); |
261 | int defaultmonth = today.month(); | 261 | int defaultmonth = today.month(); |
262 | int defaultyear = today.year(); | 262 | int defaultyear = today.year(); |
263 | td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); | 263 | td->date->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); |
264 | 264 | ||
265 | if ( td->exec() == QDialog::Accepted ) | 265 | if ( td->exec() == QDialog::Accepted ) |
266 | { | 266 | { |
267 | // set the cleared integer if the checkbox is checked | 267 | // set the cleared integer if the checkbox is checked |
268 | if ( td->clearedcheckbox->isChecked() == TRUE ) | 268 | if ( td->clearedcheckbox->isChecked() == TRUE ) |
269 | cleared = 1; | 269 | cleared = 1; |
270 | qDebug("Year from transferdialog = %i",td->getYear()); | 270 | qDebug("Year from transferdialog = %i",td->getYear()); |
271 | // add the transfer with a new date if its been edited or use the default date | 271 | // add the transfer with a new date if its been edited or use the default date |
272 | if ( td->getDateEdited () == TRUE ) | 272 | if ( td->getDateEdited () == TRUE ) |
273 | transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared ); | 273 | transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), td->getDay(), td->getMonth(), td->getYear(), td->amount->text().toFloat(), cleared ); |
274 | else | 274 | else |
275 | transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared ); | 275 | transfer->addTransfer ( firstaccountid, account->getParentAccountID ( firstaccountid ), secondaccountid, account->getParentAccountID ( secondaccountid ), defaultday, defaultmonth, defaultyear, td->amount->text().toFloat(), cleared ); |
276 | 276 | ||
277 | // update account balances of both accounts and parents if necessary | 277 | // update account balances of both accounts and parents if necessary |
278 | account->updateAccountBalance ( firstaccountid ); | 278 | account->updateAccountBalance ( firstaccountid ); |
279 | if ( account->getParentAccountID ( firstaccountid ) != -1 ) | 279 | if ( account->getParentAccountID ( firstaccountid ) != -1 ) |
280 | account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) ); | 280 | account->changeParentAccountBalance ( account->getParentAccountID ( firstaccountid ) ); |
281 | account->updateAccountBalance ( secondaccountid ); | 281 | account->updateAccountBalance ( secondaccountid ); |
282 | if ( account->getParentAccountID ( secondaccountid ) != -1 ) | 282 | if ( account->getParentAccountID ( secondaccountid ) != -1 ) |
283 | account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) ); | 283 | account->changeParentAccountBalance ( account->getParentAccountID ( secondaccountid ) ); |
284 | 284 | ||
285 | // redisplay accounts | 285 | // redisplay accounts |
286 | account->displayAccounts ( listview ); | 286 | account->displayAccounts ( listview ); |
287 | } | 287 | } |
288 | else | 288 | else |
289 | { | 289 | { |
290 | firstaccountid = -1; | 290 | firstaccountid = -1; |
291 | secondaccountid = -1; | 291 | secondaccountid = -1; |
292 | listview->clearSelection (); | 292 | listview->clearSelection (); |
293 | listview->setMultiSelection ( FALSE ); | 293 | listview->setMultiSelection ( FALSE ); |
294 | disconnect ( listview, SIGNAL ( clicked ( QListViewItem * ) ), this, SLOT ( getTransferAccounts ( QListViewItem * ) ) ); | 294 | disconnect ( listview, SIGNAL ( clicked(QListViewItem*) ), this, SLOT ( getTransferAccounts(QListViewItem*) ) ); |
295 | } | 295 | } |
296 | 296 | ||
297 | // reset the accounts display window | 297 | // reset the accounts display window |
298 | transferbutton->toggle(); // toggling this button with clear the window as well | 298 | transferbutton->toggle(); // toggling this button with clear the window as well |
299 | 299 | ||
300 | // reenable all the accounts so the transaction tab will be properly set | 300 | // reenable all the accounts so the transaction tab will be properly set |
301 | enableAccounts (); | 301 | enableAccounts (); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | 304 | ||
305 | void AccountDisplay::disableParentsWithChildren () | 305 | void AccountDisplay::disableParentsWithChildren () |
306 | { | 306 | { |
307 | // iterate through accountdisplay listview and disable all the parents that have children | 307 | // iterate through accountdisplay listview and disable all the parents that have children |
308 | QListViewItemIterator it ( listview ); | 308 | QListViewItemIterator it ( listview ); |
309 | for ( ; it.current(); ++it ) | 309 | for ( ; it.current(); ++it ) |
310 | { | 310 | { |
311 | if ( it.current()->parent() == 0 && it.current()->childCount() != 0 ) | 311 | if ( it.current()->parent() == 0 && it.current()->childCount() != 0 ) |
312 | it.current()->setSelectable ( FALSE ); | 312 | it.current()->setSelectable ( FALSE ); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | void AccountDisplay::enableAccounts () | 316 | void AccountDisplay::enableAccounts () |
317 | { | 317 | { |
318 | // iterate through accountdisplay listview and enable all accounts | 318 | // iterate through accountdisplay listview and enable all accounts |
319 | QListViewItemIterator it ( listview ); | 319 | QListViewItemIterator it ( listview ); |
320 | for ( ; it.current(); ++it ) | 320 | for ( ; it.current(); ++it ) |
321 | it.current()->setSelectable ( TRUE ); | 321 | it.current()->setSelectable ( TRUE ); |
322 | } | 322 | } |
323 | 323 | ||
324 | void AccountDisplay::saveColumnSize ( int column, int oldsize, int newsize ) | 324 | void AccountDisplay::saveColumnSize ( int column, int oldsize, int newsize ) |
325 | { | 325 | { |
326 | switch ( column ) | 326 | switch ( column ) |
327 | { | 327 | { |
328 | case 0: | 328 | case 0: |
329 | if ( listview->columns() == 3 ) | 329 | if ( listview->columns() == 3 ) |
330 | preferences->changeColumnPreference ( 1, newsize ); | 330 | preferences->changeColumnPreference ( 1, newsize ); |
331 | else | 331 | else |
332 | preferences->changeColumnPreference ( 10, newsize ); | 332 | preferences->changeColumnPreference ( 10, newsize ); |
333 | break; | 333 | break; |
334 | case 1: | 334 | case 1: |
335 | if ( listview->columns() == 3 ) | 335 | if ( listview->columns() == 3 ) |
336 | preferences->changeColumnPreference ( 2, newsize ); | 336 | preferences->changeColumnPreference ( 2, newsize ); |
337 | else | 337 | else |
338 | preferences->changeColumnPreference ( 11, newsize ); | 338 | preferences->changeColumnPreference ( 11, newsize ); |
339 | break; | 339 | break; |
340 | case 2: | 340 | case 2: |
341 | preferences->changeColumnPreference ( 12, newsize ); | 341 | preferences->changeColumnPreference ( 12, newsize ); |
342 | break; | 342 | break; |
343 | } | 343 | } |
344 | 344 | ||
345 | } | 345 | } |
346 | 346 | ||
347 | void AccountDisplay::saveSortingPreference ( int column ) | 347 | void AccountDisplay::saveSortingPreference ( int column ) |
348 | { | 348 | { |
349 | preferences->changeSortingPreference ( 1, column ); | 349 | preferences->changeSortingPreference ( 1, column ); |
350 | } | 350 | } |
351 | 351 | ||
352 | int AccountDisplay::getIDColumn () | 352 | int AccountDisplay::getIDColumn () |
353 | { | 353 | { |
354 | int counter; | 354 | int counter; |
355 | int columns = listview->columns(); | 355 | int columns = listview->columns(); |
356 | for ( counter = 0; counter <= columns; counter++ ) | 356 | for ( counter = 0; counter <= columns; counter++ ) |
357 | if ( listview->header()->label ( counter ).length() == 0 ) | 357 | if ( listview->header()->label ( counter ).length() == 0 ) |
358 | return counter; | 358 | return counter; |
359 | } | 359 | } |
360 | 360 | ||
361 | void AccountDisplay::editAccount () | 361 | void AccountDisplay::editAccount () |
362 | { | 362 | { |
363 | if ( listview->selectedItem() == 0 ) | 363 | if ( listview->selectedItem() == 0 ) |
364 | QMessageBox::warning ( this, "QashMoney", "Please select an account\nto edit."); | 364 | QMessageBox::warning ( this, "QashMoney", "Please select an account\nto edit."); |
365 | else | 365 | else |
366 | { | 366 | { |
367 | // set the accountid | 367 | // set the accountid |
368 | int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt(); | 368 | int accountid = listview->selectedItem()->text ( getIDColumn() ).toInt(); |
369 | 369 | ||
370 | //construct new dialog box | 370 | //construct new dialog box |
371 | QDialog *editaccountwindow = new QDialog ( this, 0, TRUE ); | 371 | QDialog *editaccountwindow = new QDialog ( this, 0, TRUE ); |
372 | editaccountwindow->setCaption ( "Edit Account" ); | 372 | editaccountwindow->setCaption ( "Edit Account" ); |
373 | 373 | ||
374 | // construct the items which will go in the dialog bix | 374 | // construct the items which will go in the dialog bix |
375 | QLabel *namelabel = new QLabel ( "Account Name", editaccountwindow ); | 375 | QLabel *namelabel = new QLabel ( "Account Name", editaccountwindow ); |
376 | QLineEdit *accountname = new QLineEdit ( editaccountwindow ); | 376 | QLineEdit *accountname = new QLineEdit ( editaccountwindow ); |
377 | QLabel *descriptionlabel = new QLabel ( "Account Description", editaccountwindow ); | 377 | QLabel *descriptionlabel = new QLabel ( "Account Description", editaccountwindow ); |
378 | QLineEdit *accountdescription = new QLineEdit ( editaccountwindow ); | 378 | QLineEdit *accountdescription = new QLineEdit ( editaccountwindow ); |
379 | Currency *currencybox = new Currency ( editaccountwindow ); | 379 | Currency *currencybox = new Currency ( editaccountwindow ); |
380 | 380 | ||
381 | QVBoxLayout *layout = new QVBoxLayout ( editaccountwindow, 5, 2 ); | 381 | QVBoxLayout *layout = new QVBoxLayout ( editaccountwindow, 5, 2 ); |
382 | layout->addWidget ( namelabel ); | 382 | layout->addWidget ( namelabel ); |
383 | layout->addWidget ( accountname ); | 383 | layout->addWidget ( accountname ); |
384 | layout->addWidget ( descriptionlabel ); | 384 | layout->addWidget ( descriptionlabel ); |
385 | layout->addWidget ( accountdescription ); | 385 | layout->addWidget ( accountdescription ); |
386 | layout->addWidget ( currencybox ); | 386 | layout->addWidget ( currencybox ); |
387 | 387 | ||
388 | //set the account name | 388 | //set the account name |
389 | accountname->setText ( listview->selectedItem()->text ( 0 ) ); | 389 | accountname->setText ( listview->selectedItem()->text ( 0 ) ); |
390 | 390 | ||
diff --git a/noncore/apps/qashmoney/budgetdisplay.cpp b/noncore/apps/qashmoney/budgetdisplay.cpp index d4047bf..3fc4e6c 100755 --- a/noncore/apps/qashmoney/budgetdisplay.cpp +++ b/noncore/apps/qashmoney/budgetdisplay.cpp | |||
@@ -1,178 +1,178 @@ | |||
1 | #include <qmessagebox.h> | 1 | #include <qmessagebox.h> |
2 | #include <qheader.h> | 2 | #include <qheader.h> |
3 | #include <sqlite.h> | 3 | #include <sqlite.h> |
4 | 4 | ||
5 | #include "budgetdisplay.h" | 5 | #include "budgetdisplay.h" |
6 | #include "budget.h" | 6 | #include "budget.h" |
7 | #include "datepicker.h" | 7 | #include "datepicker.h" |
8 | #include "transaction.h" | 8 | #include "transaction.h" |
9 | 9 | ||
10 | extern Preferences *preferences; | 10 | extern Preferences *preferences; |
11 | extern Budget *budget; | 11 | extern Budget *budget; |
12 | extern Transaction *transaction; | 12 | extern Transaction *transaction; |
13 | 13 | ||
14 | BudgetDisplay::BudgetDisplay ( QWidget *parent ) : QWidget ( parent ) | 14 | BudgetDisplay::BudgetDisplay ( QWidget *parent ) : QWidget ( parent ) |
15 | { | 15 | { |
16 | QFont font = this->font(); | 16 | QFont font = this->font(); |
17 | font.setWeight ( QFont::Bold ); | 17 | font.setWeight ( QFont::Bold ); |
18 | 18 | ||
19 | //set the default date to today | 19 | //set the default date to today |
20 | newDate = QDate::currentDate (); | 20 | newDate = QDate::currentDate (); |
21 | year = newDate.year(); | 21 | year = newDate.year(); |
22 | month = newDate.month(); | 22 | month = newDate.month(); |
23 | day = newDate.day(); | 23 | day = newDate.day(); |
24 | datelabel = preferences->getDate ( year, month ); | 24 | datelabel = preferences->getDate ( year, month ); |
25 | 25 | ||
26 | setCaption ( "Budget" ); | 26 | setCaption ( "Budget" ); |
27 | 27 | ||
28 | firstline = new QHBox ( this ); | 28 | firstline = new QHBox ( this ); |
29 | firstline->setSpacing ( 2 ); | 29 | firstline->setSpacing ( 2 ); |
30 | secondline = new QHBox ( this ); | 30 | secondline = new QHBox ( this ); |
31 | secondline->setSpacing ( 10 ); | 31 | secondline->setSpacing ( 10 ); |
32 | 32 | ||
33 | menu = new QMenuBar ( this ); | 33 | menu = new QMenuBar ( this ); |
34 | menu->setFrameStyle ( QFrame::Box | QFrame::Sunken ); | 34 | menu->setFrameStyle ( QFrame::Box | QFrame::Sunken ); |
35 | budgetmenu = new QPopupMenu ( this ); | 35 | budgetmenu = new QPopupMenu ( this ); |
36 | lineitemsmenu = new QPopupMenu ( this ); | 36 | lineitemsmenu = new QPopupMenu ( this ); |
37 | datemenu = new QPopupMenu ( this ); | 37 | datemenu = new QPopupMenu ( this ); |
38 | menu->insertItem ( "Budget", budgetmenu ); | 38 | menu->insertItem ( "Budget", budgetmenu ); |
39 | menu->insertItem ( "Line Item", lineitemsmenu ); | 39 | menu->insertItem ( "Line Item", lineitemsmenu ); |
40 | menu->insertItem ( "Date", datemenu ); | 40 | menu->insertItem ( "Date", datemenu ); |
41 | budgetmenu->insertItem ( "New", this, SLOT ( newBudget () ), 0, 1 ); | 41 | budgetmenu->insertItem ( "New", this, SLOT ( newBudget() ), 0, 1 ); |
42 | budgetmenu->insertItem ( "Edit", this, SLOT ( editBudget () ), 0, 2 ); | 42 | budgetmenu->insertItem ( "Edit", this, SLOT ( editBudget() ), 0, 2 ); |
43 | budgetmenu->insertItem ( "Delete", this, SLOT ( deleteBudget () ), 0, 3 ); | 43 | budgetmenu->insertItem ( "Delete", this, SLOT ( deleteBudget() ), 0, 3 ); |
44 | lineitemsmenu->insertItem ( "New", this, SLOT ( newLineItem () ), 0, 1 ); | 44 | lineitemsmenu->insertItem ( "New", this, SLOT ( newLineItem() ), 0, 1 ); |
45 | lineitemsmenu->insertItem ( "Edit", this, SLOT ( editLineItem () ), 0, 2 ); | 45 | lineitemsmenu->insertItem ( "Edit", this, SLOT ( editLineItem() ), 0, 2 ); |
46 | lineitemsmenu->insertItem ( "Delete", this, SLOT ( deleteLineItem () ), 0, 3 ); | 46 | lineitemsmenu->insertItem ( "Delete", this, SLOT ( deleteLineItem() ), 0, 3 ); |
47 | datemenu->insertItem ( "Change", this, SLOT ( showCalendar() ) ); | 47 | datemenu->insertItem ( "Change", this, SLOT ( showCalendar() ) ); |
48 | 48 | ||
49 | budgetbox = new QComboBox ( firstline ); | 49 | budgetbox = new QComboBox ( firstline ); |
50 | connect ( budgetbox, SIGNAL ( activated ( int ) ), this, SLOT ( setCurrentBudget ( int ) ) ); | 50 | connect ( budgetbox, SIGNAL ( activated(int) ), this, SLOT ( setCurrentBudget(int) ) ); |
51 | 51 | ||
52 | budgetview = new QComboBox ( firstline ); | 52 | budgetview = new QComboBox ( firstline ); |
53 | budgetview->insertItem ( "Month" ); | 53 | budgetview->insertItem ( "Month" ); |
54 | budgetview->insertItem ( "Year" ); | 54 | budgetview->insertItem ( "Year" ); |
55 | connect ( budgetview, SIGNAL ( activated ( int ) ), this, SLOT ( setCurrentView ( int ) ) ); | 55 | connect ( budgetview, SIGNAL ( activated(int) ), this, SLOT ( setCurrentView(int) ) ); |
56 | 56 | ||
57 | budgeted = new QLabel ( secondline ); | 57 | budgeted = new QLabel ( secondline ); |
58 | budgeted->setFont ( font ); | 58 | budgeted->setFont ( font ); |
59 | actual = new QLabel ( secondline ); | 59 | actual = new QLabel ( secondline ); |
60 | actual->setFont ( font ); | 60 | actual->setFont ( font ); |
61 | date = new QLabel ( secondline ); | 61 | date = new QLabel ( secondline ); |
62 | date->setFont ( font ); | 62 | date->setFont ( font ); |
63 | 63 | ||
64 | listview = new QListView ( this ); | 64 | listview = new QListView ( this ); |
65 | listview->setAllColumnsShowFocus ( TRUE ); | 65 | listview->setAllColumnsShowFocus ( TRUE ); |
66 | listview->setShowSortIndicator ( TRUE ); | 66 | listview->setShowSortIndicator ( TRUE ); |
67 | listview->setRootIsDecorated ( TRUE ); | 67 | listview->setRootIsDecorated ( TRUE ); |
68 | listview->setMultiSelection ( FALSE ); | 68 | listview->setMultiSelection ( FALSE ); |
69 | listview->addColumn ( "Line Item", preferences->getColumnPreference ( 13 ) ); // column id 13 | 69 | listview->addColumn ( "Line Item", preferences->getColumnPreference ( 13 ) ); // column id 13 |
70 | listview->addColumn ( "Budget", preferences->getColumnPreference ( 14 ) ); // column id 14 | 70 | listview->addColumn ( "Budget", preferences->getColumnPreference ( 14 ) ); // column id 14 |
71 | listview->addColumn ( "Actual", preferences->getColumnPreference ( 15 ) ); // column id 15 | 71 | listview->addColumn ( "Actual", preferences->getColumnPreference ( 15 ) ); // column id 15 |
72 | listview->addColumn ( "", 0 ); // line item ids | 72 | listview->addColumn ( "", 0 ); // line item ids |
73 | listview->setColumnWidthMode ( 0, QListView::Manual ); | 73 | listview->setColumnWidthMode ( 0, QListView::Manual ); |
74 | listview->setColumnWidthMode ( 1, QListView::Manual ); | 74 | listview->setColumnWidthMode ( 1, QListView::Manual ); |
75 | listview->setColumnWidthMode ( 2, QListView::Manual ); | 75 | listview->setColumnWidthMode ( 2, QListView::Manual ); |
76 | listview->setColumnAlignment ( 1, Qt::AlignRight ); | 76 | listview->setColumnAlignment ( 1, Qt::AlignRight ); |
77 | listview->setColumnAlignment ( 2, Qt::AlignRight ); | 77 | listview->setColumnAlignment ( 2, Qt::AlignRight ); |
78 | listview->setColumnWidthMode ( 3, QListView::Manual ); | 78 | listview->setColumnWidthMode ( 3, QListView::Manual ); |
79 | 79 | ||
80 | listview->header()->setTracking ( FALSE ); | 80 | listview->header()->setTracking ( FALSE ); |
81 | connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) ); | 81 | connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) ); |
82 | connect ( listview->header(), SIGNAL ( clicked ( int ) ), this, SLOT ( saveSortingPreference ( int ) ) ); | 82 | connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) ); |
83 | 83 | ||
84 | // pull the column sorting preference from the preferences table, and configure the listview accordingly | 84 | // pull the column sorting preference from the preferences table, and configure the listview accordingly |
85 | int column = 0; | 85 | int column = 0; |
86 | int direction = 0; | 86 | int direction = 0; |
87 | preferences->getSortingPreference ( 3, &column, &direction ); | 87 | preferences->getSortingPreference ( 3, &column, &direction ); |
88 | listview->setSorting ( column, direction ); | 88 | listview->setSorting ( column, direction ); |
89 | 89 | ||
90 | displayBudgetNames(); | 90 | displayBudgetNames(); |
91 | 91 | ||
92 | layout = new QVBoxLayout ( this, 2, 2 ); | 92 | layout = new QVBoxLayout ( this, 2, 2 ); |
93 | layout->setMenuBar ( menu ); | 93 | layout->setMenuBar ( menu ); |
94 | layout->addWidget ( firstline ); | 94 | layout->addWidget ( firstline ); |
95 | layout->addWidget ( secondline ); | 95 | layout->addWidget ( secondline ); |
96 | layout->addWidget ( listview ); | 96 | layout->addWidget ( listview ); |
97 | } | 97 | } |
98 | 98 | ||
99 | void BudgetDisplay::deleteBudget () | 99 | void BudgetDisplay::deleteBudget () |
100 | { | 100 | { |
101 | listview->clear(); | 101 | listview->clear(); |
102 | transaction->clearBudgetIDs ( currentbudget ); | 102 | transaction->clearBudgetIDs ( currentbudget ); |
103 | budget->deleteBudget ( currentbudget ); | 103 | budget->deleteBudget ( currentbudget ); |
104 | if ( budgetbox->count() != 0 ) | 104 | if ( budgetbox->count() != 0 ) |
105 | displayBudgetNames(); | 105 | displayBudgetNames(); |
106 | checkBudgets(); | 106 | checkBudgets(); |
107 | } | 107 | } |
108 | 108 | ||
109 | void BudgetDisplay::saveColumnSize ( int column, int oldsize, int newsize ) | 109 | void BudgetDisplay::saveColumnSize ( int column, int oldsize, int newsize ) |
110 | { | 110 | { |
111 | switch ( column ) | 111 | switch ( column ) |
112 | { | 112 | { |
113 | case 0: | 113 | case 0: |
114 | preferences->changeColumnPreference ( 13, newsize ); | 114 | preferences->changeColumnPreference ( 13, newsize ); |
115 | break; | 115 | break; |
116 | case 1: | 116 | case 1: |
117 | preferences->changeColumnPreference ( 14, newsize ); | 117 | preferences->changeColumnPreference ( 14, newsize ); |
118 | break; | 118 | break; |
119 | case 2: | 119 | case 2: |
120 | preferences->changeColumnPreference ( 15, newsize ); | 120 | preferences->changeColumnPreference ( 15, newsize ); |
121 | break; | 121 | break; |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | void BudgetDisplay::saveSortingPreference ( int column ) | 125 | void BudgetDisplay::saveSortingPreference ( int column ) |
126 | { | 126 | { |
127 | preferences->changeSortingPreference ( 3, column ); | 127 | preferences->changeSortingPreference ( 3, column ); |
128 | } | 128 | } |
129 | 129 | ||
130 | int BudgetDisplay::getIDColumn () | 130 | int BudgetDisplay::getIDColumn () |
131 | { | 131 | { |
132 | int counter; | 132 | int counter; |
133 | int columns = listview->columns(); | 133 | int columns = listview->columns(); |
134 | for ( counter = 0; counter <= columns; counter++ ) | 134 | for ( counter = 0; counter <= columns; counter++ ) |
135 | if ( listview->header()->label ( counter ).length() == 0 ) | 135 | if ( listview->header()->label ( counter ).length() == 0 ) |
136 | return counter; | 136 | return counter; |
137 | } | 137 | } |
138 | 138 | ||
139 | void BudgetDisplay::newBudget () | 139 | void BudgetDisplay::newBudget () |
140 | { | 140 | { |
141 | constructBudgetWindow(); | 141 | constructBudgetWindow(); |
142 | int response = nb->exec(); | 142 | int response = nb->exec(); |
143 | if ( response == 1 ) | 143 | if ( response == 1 ) |
144 | { | 144 | { |
145 | // open a new budget object | 145 | // open a new budget object |
146 | int addedbudget = budget->addBudget ( budgetname->text(), 0, description->text(), currencybox->currencybox->currentText(), day, month, year, day, month, year, 0 ); | 146 | int addedbudget = budget->addBudget ( budgetname->text(), 0, description->text(), currencybox->currencybox->currentText(), day, month, year, day, month, year, 0 ); |
147 | transaction->clearBudgetIDs ( addedbudget ); | 147 | transaction->clearBudgetIDs ( addedbudget ); |
148 | displayBudgetNames(); | 148 | displayBudgetNames(); |
149 | } | 149 | } |
150 | checkBudgets(); | 150 | checkBudgets(); |
151 | } | 151 | } |
152 | 152 | ||
153 | void BudgetDisplay::constructBudgetWindow () | 153 | void BudgetDisplay::constructBudgetWindow () |
154 | { | 154 | { |
155 | //construct and format the new budget window | 155 | //construct and format the new budget window |
156 | nb = new QDialog ( this, 0, TRUE ); | 156 | nb = new QDialog ( this, 0, TRUE ); |
157 | nb->setCaption ( "Budget" ); | 157 | nb->setCaption ( "Budget" ); |
158 | QLabel *namelabel = new QLabel ( "Budget Name", nb ); | 158 | QLabel *namelabel = new QLabel ( "Budget Name", nb ); |
159 | budgetname = new QLineEdit ( nb ); | 159 | budgetname = new QLineEdit ( nb ); |
160 | QLabel *descriptionlabel = new QLabel ( "Description", nb ); | 160 | QLabel *descriptionlabel = new QLabel ( "Description", nb ); |
161 | description = new QLineEdit ( nb ); | 161 | description = new QLineEdit ( nb ); |
162 | currencybox = new Currency ( nb ); | 162 | currencybox = new Currency ( nb ); |
163 | QBoxLayout *layout = new QVBoxLayout ( nb, 2, 2 ); | 163 | QBoxLayout *layout = new QVBoxLayout ( nb, 2, 2 ); |
164 | layout->addWidget ( namelabel ); | 164 | layout->addWidget ( namelabel ); |
165 | layout->addWidget ( budgetname ); | 165 | layout->addWidget ( budgetname ); |
166 | layout->addWidget ( descriptionlabel ); | 166 | layout->addWidget ( descriptionlabel ); |
167 | layout->addWidget ( description ); | 167 | layout->addWidget ( description ); |
168 | layout->addWidget ( currencybox ); | 168 | layout->addWidget ( currencybox ); |
169 | } | 169 | } |
170 | 170 | ||
171 | void BudgetDisplay::displayBudgetNames () | 171 | void BudgetDisplay::displayBudgetNames () |
172 | { | 172 | { |
173 | budgetbox->clear(); | 173 | budgetbox->clear(); |
174 | if ( budget->getNumberOfBudgets() != 0 ) | 174 | if ( budget->getNumberOfBudgets() != 0 ) |
175 | { | 175 | { |
176 | ids = budget->getBudgetIDs(); | 176 | ids = budget->getBudgetIDs(); |
177 | for ( QStringList::Iterator it = ids->begin(); it != ids->end(); ++it ) | 177 | for ( QStringList::Iterator it = ids->begin(); it != ids->end(); ++it ) |
178 | { | 178 | { |
diff --git a/noncore/apps/qashmoney/calculator.cpp b/noncore/apps/qashmoney/calculator.cpp index 0e0a043..2c92103 100755 --- a/noncore/apps/qashmoney/calculator.cpp +++ b/noncore/apps/qashmoney/calculator.cpp | |||
@@ -1,113 +1,113 @@ | |||
1 | #include "calculator.h" | 1 | #include "calculator.h" |
2 | 2 | ||
3 | #include <qpushbutton.h> | 3 | #include <qpushbutton.h> |
4 | 4 | ||
5 | Calculator::Calculator ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) | 5 | Calculator::Calculator ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) |
6 | { | 6 | { |
7 | 7 | ||
8 | display = new QLineEdit ( this, "display" ); | 8 | display = new QLineEdit ( this, "display" ); |
9 | display->setFrame ( FALSE ); | 9 | display->setFrame ( FALSE ); |
10 | display->setAlignment ( Qt::AlignRight ); | 10 | display->setAlignment ( Qt::AlignRight ); |
11 | 11 | ||
12 | QPushButton *one = new QPushButton ( "1", this, "one" ); // make buttons for first row | 12 | QPushButton *one = new QPushButton ( "1", this, "one" ); // make buttons for first row |
13 | one->setFlat ( TRUE ); | 13 | one->setFlat ( TRUE ); |
14 | connect ( one, SIGNAL ( released () ), this, SLOT ( displayOne () ) ); | 14 | connect ( one, SIGNAL ( released() ), this, SLOT ( displayOne() ) ); |
15 | 15 | ||
16 | QPushButton *two = new QPushButton ( "2", this, "two" ); | 16 | QPushButton *two = new QPushButton ( "2", this, "two" ); |
17 | two->setFlat ( TRUE ); | 17 | two->setFlat ( TRUE ); |
18 | connect ( two, SIGNAL ( released () ), this, SLOT ( displayTwo () ) ); | 18 | connect ( two, SIGNAL ( released() ), this, SLOT ( displayTwo() ) ); |
19 | 19 | ||
20 | QPushButton *three = new QPushButton ( "3", this, "three" ); | 20 | QPushButton *three = new QPushButton ( "3", this, "three" ); |
21 | three->setFlat ( TRUE ); | 21 | three->setFlat ( TRUE ); |
22 | connect ( three, SIGNAL ( released () ), this, SLOT ( displayThree () ) ); | 22 | connect ( three, SIGNAL ( released() ), this, SLOT ( displayThree() ) ); |
23 | 23 | ||
24 | QPushButton *four = new QPushButton ( "4", this, "four" ); // make buttons for second row | 24 | QPushButton *four = new QPushButton ( "4", this, "four" ); // make buttons for second row |
25 | four->setFlat ( TRUE ); | 25 | four->setFlat ( TRUE ); |
26 | connect ( four, SIGNAL ( released () ), this, SLOT ( displayFour () ) ); | 26 | connect ( four, SIGNAL ( released() ), this, SLOT ( displayFour() ) ); |
27 | 27 | ||
28 | QPushButton *five = new QPushButton ( "5", this, "five" ); | 28 | QPushButton *five = new QPushButton ( "5", this, "five" ); |
29 | five->setFlat ( TRUE ); | 29 | five->setFlat ( TRUE ); |
30 | connect ( five, SIGNAL ( released () ), this, SLOT ( displayFive () ) ); | 30 | connect ( five, SIGNAL ( released() ), this, SLOT ( displayFive() ) ); |
31 | 31 | ||
32 | QPushButton *six = new QPushButton ( "6", this, "six" ); | 32 | QPushButton *six = new QPushButton ( "6", this, "six" ); |
33 | six->setFlat ( TRUE ); | 33 | six->setFlat ( TRUE ); |
34 | connect ( six, SIGNAL ( released () ), this, SLOT ( displaySix () ) ); | 34 | connect ( six, SIGNAL ( released() ), this, SLOT ( displaySix() ) ); |
35 | 35 | ||
36 | QPushButton *seven = new QPushButton ( "7", this, "seven" ); // make buttons for third row | 36 | QPushButton *seven = new QPushButton ( "7", this, "seven" ); // make buttons for third row |
37 | seven->setFlat ( TRUE ); | 37 | seven->setFlat ( TRUE ); |
38 | connect ( seven, SIGNAL ( released () ), this, SLOT ( displaySeven () ) ); | 38 | connect ( seven, SIGNAL ( released() ), this, SLOT ( displaySeven() ) ); |
39 | 39 | ||
40 | QPushButton *eight = new QPushButton ( "8", this, "eight" ); | 40 | QPushButton *eight = new QPushButton ( "8", this, "eight" ); |
41 | eight->setFlat ( TRUE ); | 41 | eight->setFlat ( TRUE ); |
42 | connect ( eight, SIGNAL ( released () ), this, SLOT ( displayEight () ) ); | 42 | connect ( eight, SIGNAL ( released() ), this, SLOT ( displayEight() ) ); |
43 | 43 | ||
44 | QPushButton *nine = new QPushButton ( "9", this, "nine" ); | 44 | QPushButton *nine = new QPushButton ( "9", this, "nine" ); |
45 | nine->setFlat ( TRUE ); | 45 | nine->setFlat ( TRUE ); |
46 | connect ( nine, SIGNAL ( released () ), this, SLOT ( displayNine () ) ); | 46 | connect ( nine, SIGNAL ( released() ), this, SLOT ( displayNine() ) ); |
47 | 47 | ||
48 | QPushButton *zero = new QPushButton ( "0", this, "zero" ); | 48 | QPushButton *zero = new QPushButton ( "0", this, "zero" ); |
49 | zero->setFlat ( TRUE ); | 49 | zero->setFlat ( TRUE ); |
50 | connect ( zero, SIGNAL ( released () ), this, SLOT ( displayZero () ) ); | 50 | connect ( zero, SIGNAL ( released() ), this, SLOT ( displayZero() ) ); |
51 | 51 | ||
52 | QPushButton *dp = new QPushButton ( ".", this, "dp" ); | 52 | QPushButton *dp = new QPushButton ( ".", this, "dp" ); |
53 | dp->setFlat ( TRUE ); | 53 | dp->setFlat ( TRUE ); |
54 | connect ( dp, SIGNAL ( released () ), this, SLOT ( displayPoint () ) ); | 54 | connect ( dp, SIGNAL ( released() ), this, SLOT ( displayPoint() ) ); |
55 | 55 | ||
56 | QPushButton *back = new QPushButton ( "<-", this, "back" ); | 56 | QPushButton *back = new QPushButton ( "<-", this, "back" ); |
57 | back->setFlat ( TRUE ); | 57 | back->setFlat ( TRUE ); |
58 | connect ( back, SIGNAL ( released () ), this, SLOT ( back () ) ); | 58 | connect ( back, SIGNAL ( released() ), this, SLOT ( back() ) ); |
59 | 59 | ||
60 | layout = new QGridLayout ( this, 5, 3, 5, 1, "calculatorlayout" ); | 60 | layout = new QGridLayout ( this, 5, 3, 5, 1, "calculatorlayout" ); |
61 | layout->addMultiCellWidget ( display, 0, 0, 0, 2 ); | 61 | layout->addMultiCellWidget ( display, 0, 0, 0, 2 ); |
62 | layout->addWidget ( one, 1, 0 ); | 62 | layout->addWidget ( one, 1, 0 ); |
63 | layout->addWidget ( two, 1, 1 ); | 63 | layout->addWidget ( two, 1, 1 ); |
64 | layout->addWidget ( three, 1, 2 ); | 64 | layout->addWidget ( three, 1, 2 ); |
65 | layout->addWidget ( four, 2, 0 ); | 65 | layout->addWidget ( four, 2, 0 ); |
66 | layout->addWidget ( five, 2, 1 ); | 66 | layout->addWidget ( five, 2, 1 ); |
67 | layout->addWidget ( six, 2, 2 ); | 67 | layout->addWidget ( six, 2, 2 ); |
68 | layout->addWidget ( seven, 3, 0 ); | 68 | layout->addWidget ( seven, 3, 0 ); |
69 | layout->addWidget ( eight, 3, 1 ); | 69 | layout->addWidget ( eight, 3, 1 ); |
70 | layout->addWidget ( nine, 3, 2 ); | 70 | layout->addWidget ( nine, 3, 2 ); |
71 | layout->addWidget ( zero, 4, 0 ); | 71 | layout->addWidget ( zero, 4, 0 ); |
72 | layout->addWidget ( dp, 4, 1 ); | 72 | layout->addWidget ( dp, 4, 1 ); |
73 | layout->addWidget ( back, 4, 2 ); | 73 | layout->addWidget ( back, 4, 2 ); |
74 | 74 | ||
75 | } | 75 | } |
76 | 76 | ||
77 | void Calculator::displayOne () | 77 | void Calculator::displayOne () |
78 | { display->insert ( "1" ); } | 78 | { display->insert ( "1" ); } |
79 | 79 | ||
80 | void Calculator::displayTwo () | 80 | void Calculator::displayTwo () |
81 | { display->insert ( "2" ); } | 81 | { display->insert ( "2" ); } |
82 | 82 | ||
83 | void Calculator::displayThree () | 83 | void Calculator::displayThree () |
84 | { display->insert ( "3" ); } | 84 | { display->insert ( "3" ); } |
85 | 85 | ||
86 | void Calculator::displayFour () | 86 | void Calculator::displayFour () |
87 | { display->insert ( "4" ); } | 87 | { display->insert ( "4" ); } |
88 | 88 | ||
89 | void Calculator::displayFive () | 89 | void Calculator::displayFive () |
90 | { display->insert ( "5" ); } | 90 | { display->insert ( "5" ); } |
91 | 91 | ||
92 | void Calculator::displaySix () | 92 | void Calculator::displaySix () |
93 | { display->insert ( "6" ); } | 93 | { display->insert ( "6" ); } |
94 | 94 | ||
95 | void Calculator::displaySeven () | 95 | void Calculator::displaySeven () |
96 | { display->insert ( "7" ); } | 96 | { display->insert ( "7" ); } |
97 | 97 | ||
98 | void Calculator::displayEight () | 98 | void Calculator::displayEight () |
99 | { display->insert ( "8" ); } | 99 | { display->insert ( "8" ); } |
100 | 100 | ||
101 | void Calculator::displayNine () | 101 | void Calculator::displayNine () |
102 | { display->insert ( "9" ); } | 102 | { display->insert ( "9" ); } |
103 | 103 | ||
104 | void Calculator::displayZero () | 104 | void Calculator::displayZero () |
105 | { display->insert ( "0" ); } | 105 | { display->insert ( "0" ); } |
106 | 106 | ||
107 | void Calculator::displayPoint () | 107 | void Calculator::displayPoint () |
108 | { display->insert ( "." ); } | 108 | { display->insert ( "." ); } |
109 | 109 | ||
110 | void Calculator::back () | 110 | void Calculator::back () |
111 | { display->backspace(); } | 111 | { display->backspace(); } |
112 | 112 | ||
113 | 113 | ||
diff --git a/noncore/apps/qashmoney/datepicker.cpp b/noncore/apps/qashmoney/datepicker.cpp index 02fbcf3..7997c0b 100755 --- a/noncore/apps/qashmoney/datepicker.cpp +++ b/noncore/apps/qashmoney/datepicker.cpp | |||
@@ -1,95 +1,95 @@ | |||
1 | #include "datepicker.h" | 1 | #include "datepicker.h" |
2 | 2 | ||
3 | DatePicker::DatePicker ( QDate entrydate ) : QDialog ( 0, 0, TRUE ) | 3 | DatePicker::DatePicker ( QDate entrydate ) : QDialog ( 0, 0, TRUE ) |
4 | { | 4 | { |
5 | setCaption ( "Select Date" ); | 5 | setCaption ( "Select Date" ); |
6 | date = entrydate; | 6 | date = entrydate; |
7 | day = date.day(); | 7 | day = date.day(); |
8 | month = date.month(); | 8 | month = date.month(); |
9 | year = date.year(); | 9 | year = date.year(); |
10 | 10 | ||
11 | daylabel = new QLabel ( "Day", this ); | 11 | daylabel = new QLabel ( "Day", this ); |
12 | monthlabel = new QLabel ( "Month", this ); | 12 | monthlabel = new QLabel ( "Month", this ); |
13 | yearlabel = new QLabel ( "Year", this ); | 13 | yearlabel = new QLabel ( "Year", this ); |
14 | 14 | ||
15 | daybox = new QComboBox ( this, "daybox" ); | 15 | daybox = new QComboBox ( this, "daybox" ); |
16 | connect ( daybox, SIGNAL ( activated ( int ) ), this, SLOT ( setDay ( int ) ) ); | 16 | connect ( daybox, SIGNAL ( activated(int) ), this, SLOT ( setDay(int) ) ); |
17 | displayDays ( daybox ); | 17 | displayDays ( daybox ); |
18 | monthbox = new QComboBox ( this, "monthbox" ); | 18 | monthbox = new QComboBox ( this, "monthbox" ); |
19 | connect ( monthbox, SIGNAL ( activated ( int ) ), this, SLOT ( setMonth ( int ) ) ); | 19 | connect ( monthbox, SIGNAL ( activated(int) ), this, SLOT ( setMonth(int) ) ); |
20 | displayMonths ( monthbox ); | 20 | displayMonths ( monthbox ); |
21 | yearbox = new QComboBox ( this, "yearbox" ); | 21 | yearbox = new QComboBox ( this, "yearbox" ); |
22 | connect ( yearbox, SIGNAL ( activated ( int ) ), this, SLOT ( setYear ( int ) ) ); | 22 | connect ( yearbox, SIGNAL ( activated(int) ), this, SLOT ( setYear(int) ) ); |
23 | displayYears ( yearbox ); | 23 | displayYears ( yearbox ); |
24 | 24 | ||
25 | layout = new QGridLayout ( this, 2, 3, 5, 5, "datepickerlayout" ); | 25 | layout = new QGridLayout ( this, 2, 3, 5, 5, "datepickerlayout" ); |
26 | layout->addWidget ( daylabel, 0, 2 ); | 26 | layout->addWidget ( daylabel, 0, 2 ); |
27 | layout->addWidget ( monthlabel, 0, 1 ); | 27 | layout->addWidget ( monthlabel, 0, 1 ); |
28 | layout->addWidget ( yearlabel, 0, 0 ); | 28 | layout->addWidget ( yearlabel, 0, 0 ); |
29 | layout->addWidget ( daybox, 1, 2 ); | 29 | layout->addWidget ( daybox, 1, 2 ); |
30 | layout->addWidget ( monthbox, 1, 1 ); | 30 | layout->addWidget ( monthbox, 1, 1 ); |
31 | layout->addWidget ( yearbox, 1, 0 ); | 31 | layout->addWidget ( yearbox, 1, 0 ); |
32 | } | 32 | } |
33 | 33 | ||
34 | void DatePicker::displayDays ( QComboBox *daybox ) | 34 | void DatePicker::displayDays ( QComboBox *daybox ) |
35 | { | 35 | { |
36 | int counter; | 36 | int counter; |
37 | int days = date.daysInMonth(); | 37 | int days = date.daysInMonth(); |
38 | for ( counter = 1; counter <= days; counter++ ) | 38 | for ( counter = 1; counter <= days; counter++ ) |
39 | daybox->insertItem ( QString::number ( counter ) ); | 39 | daybox->insertItem ( QString::number ( counter ) ); |
40 | daybox->setCurrentItem ( ( date.day() ) - 1 ); | 40 | daybox->setCurrentItem ( ( date.day() ) - 1 ); |
41 | } | 41 | } |
42 | 42 | ||
43 | void DatePicker::displayMonths ( QComboBox *monthbox ) | 43 | void DatePicker::displayMonths ( QComboBox *monthbox ) |
44 | { | 44 | { |
45 | int counter; | 45 | int counter; |
46 | for ( counter = 1; counter <= 12; counter++ ) | 46 | for ( counter = 1; counter <= 12; counter++ ) |
47 | monthbox->insertItem ( QString::number ( counter ) ); | 47 | monthbox->insertItem ( QString::number ( counter ) ); |
48 | monthbox->setCurrentItem ( ( date.month() ) - 1 ); | 48 | monthbox->setCurrentItem ( ( date.month() ) - 1 ); |
49 | } | 49 | } |
50 | 50 | ||
51 | void DatePicker::displayYears ( QComboBox *yearbox ) | 51 | void DatePicker::displayYears ( QComboBox *yearbox ) |
52 | { | 52 | { |
53 | int counter; | 53 | int counter; |
54 | int indexcounter = 0; | 54 | int indexcounter = 0; |
55 | int yearindex = 0; | 55 | int yearindex = 0; |
56 | int year = date.year(); | 56 | int year = date.year(); |
57 | for ( counter = ( year - 1 ); counter <= ( year + 1 ); counter++ ) | 57 | for ( counter = ( year - 1 ); counter <= ( year + 1 ); counter++ ) |
58 | { | 58 | { |
59 | yearbox->insertItem ( QString::number ( counter ) ); | 59 | yearbox->insertItem ( QString::number ( counter ) ); |
60 | if ( date.year() == counter ) | 60 | if ( date.year() == counter ) |
61 | yearindex = indexcounter; | 61 | yearindex = indexcounter; |
62 | indexcounter ++; | 62 | indexcounter ++; |
63 | } | 63 | } |
64 | yearbox->setCurrentItem ( yearindex ); | 64 | yearbox->setCurrentItem ( yearindex ); |
65 | } | 65 | } |
66 | 66 | ||
67 | void DatePicker::setDay ( int index ) | 67 | void DatePicker::setDay ( int index ) |
68 | { | 68 | { |
69 | day = daybox->text ( index ).toInt(); | 69 | day = daybox->text ( index ).toInt(); |
70 | } | 70 | } |
71 | 71 | ||
72 | void DatePicker::setMonth ( int index ) | 72 | void DatePicker::setMonth ( int index ) |
73 | { | 73 | { |
74 | month = monthbox->text( index ).toInt(); | 74 | month = monthbox->text( index ).toInt(); |
75 | } | 75 | } |
76 | 76 | ||
77 | void DatePicker::setYear ( int index ) | 77 | void DatePicker::setYear ( int index ) |
78 | { | 78 | { |
79 | year = yearbox->text ( index ).toInt(); | 79 | year = yearbox->text ( index ).toInt(); |
80 | } | 80 | } |
81 | 81 | ||
82 | int DatePicker::getDay () | 82 | int DatePicker::getDay () |
83 | { return day; } | 83 | { return day; } |
84 | 84 | ||
85 | int DatePicker::getMonth () | 85 | int DatePicker::getMonth () |
86 | { return month; } | 86 | { return month; } |
87 | 87 | ||
88 | int DatePicker::getYear () | 88 | int DatePicker::getYear () |
89 | { return year; } | 89 | { return year; } |
90 | 90 | ||
91 | 91 | ||
92 | 92 | ||
93 | 93 | ||
94 | 94 | ||
95 | 95 | ||
diff --git a/noncore/apps/qashmoney/memorydialog.cpp b/noncore/apps/qashmoney/memorydialog.cpp index e9ebd54..ba11540 100755 --- a/noncore/apps/qashmoney/memorydialog.cpp +++ b/noncore/apps/qashmoney/memorydialog.cpp | |||
@@ -1,86 +1,86 @@ | |||
1 | #include "memorydialog.h" | 1 | #include "memorydialog.h" |
2 | #include "memory.h" | 2 | #include "memory.h" |
3 | #include <qmessagebox.h> | 3 | #include <qmessagebox.h> |
4 | 4 | ||
5 | extern Memory *memory; | 5 | extern Memory *memory; |
6 | 6 | ||
7 | MemoryDialog::MemoryDialog () : QDialog ( 0, 0, TRUE ) | 7 | MemoryDialog::MemoryDialog () : QDialog ( 0, 0, TRUE ) |
8 | { | 8 | { |
9 | setCaption ( tr ( "Edit Memory" ) ); | 9 | setCaption ( tr ( "Edit Memory" ) ); |
10 | 10 | ||
11 | listbox = new QListBox ( this, "listbox" ); | 11 | listbox = new QListBox ( this, "listbox" ); |
12 | memory->displayMemoryItems ( listbox ); | 12 | memory->displayMemoryItems ( listbox ); |
13 | listbox->clearSelection(); | 13 | listbox->clearSelection(); |
14 | 14 | ||
15 | secondline = new QHBox ( this ); | 15 | secondline = new QHBox ( this ); |
16 | 16 | ||
17 | newbutton = new QPushButton ( secondline ); | 17 | newbutton = new QPushButton ( secondline ); |
18 | newbutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/new.png") ); | 18 | newbutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/new.png") ); |
19 | connect ( newbutton, SIGNAL ( released () ), this, SLOT ( addItem () ) ); | 19 | connect ( newbutton, SIGNAL ( released() ), this, SLOT ( addItem() ) ); |
20 | 20 | ||
21 | editbutton = new QPushButton ( secondline ); | 21 | editbutton = new QPushButton ( secondline ); |
22 | editbutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); | 22 | editbutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); |
23 | connect ( editbutton, SIGNAL ( released () ), this, SLOT ( editItem () ) ); | 23 | connect ( editbutton, SIGNAL ( released() ), this, SLOT ( editItem() ) ); |
24 | 24 | ||
25 | deletebutton = new QPushButton( secondline ); | 25 | deletebutton = new QPushButton( secondline ); |
26 | deletebutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/delete.png") ); | 26 | deletebutton->setPixmap( QPixmap ("/opt/QtPalmtop/pics/delete.png") ); |
27 | connect ( deletebutton, SIGNAL ( released () ), this, SLOT ( deleteItem () ) ); | 27 | connect ( deletebutton, SIGNAL ( released() ), this, SLOT ( deleteItem() ) ); |
28 | 28 | ||
29 | lineedit = new QLineEdit ( this ); | 29 | lineedit = new QLineEdit ( this ); |
30 | 30 | ||
31 | layout = new QVBoxLayout ( this, 2, 2 ); | 31 | layout = new QVBoxLayout ( this, 2, 2 ); |
32 | layout->addWidget ( listbox ); | 32 | layout->addWidget ( listbox ); |
33 | layout->addWidget ( secondline ); | 33 | layout->addWidget ( secondline ); |
34 | layout->addWidget ( lineedit ); | 34 | layout->addWidget ( lineedit ); |
35 | } | 35 | } |
36 | 36 | ||
37 | MemoryDialog::~MemoryDialog() | 37 | MemoryDialog::~MemoryDialog() |
38 | { | 38 | { |
39 | } | 39 | } |
40 | 40 | ||
41 | void MemoryDialog::addItem () | 41 | void MemoryDialog::addItem () |
42 | { | 42 | { |
43 | if ( lineedit->text().length() != 0 ) | 43 | if ( lineedit->text().length() != 0 ) |
44 | { | 44 | { |
45 | memory->addMemoryItem ( lineedit->text() ); | 45 | memory->addMemoryItem ( lineedit->text() ); |
46 | listbox->clear (); | 46 | listbox->clear (); |
47 | memory->displayMemoryItems ( listbox ); | 47 | memory->displayMemoryItems ( listbox ); |
48 | listbox->clearFocus(); | 48 | listbox->clearFocus(); |
49 | listbox->clearSelection (); | 49 | listbox->clearSelection (); |
50 | lineedit->clear(); | 50 | lineedit->clear(); |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | void MemoryDialog::editItem () | 54 | void MemoryDialog::editItem () |
55 | { | 55 | { |
56 | if ( listbox->currentItem() != -1 ) | 56 | if ( listbox->currentItem() != -1 ) |
57 | { | 57 | { |
58 | lineedit->setText ( listbox->currentText() ); | 58 | lineedit->setText ( listbox->currentText() ); |
59 | memory->deleteMemoryItem ( listbox->currentText() ); | 59 | memory->deleteMemoryItem ( listbox->currentText() ); |
60 | listbox->clear (); | 60 | listbox->clear (); |
61 | memory->displayMemoryItems ( listbox ); | 61 | memory->displayMemoryItems ( listbox ); |
62 | listbox->clearSelection(); | 62 | listbox->clearSelection(); |
63 | } | 63 | } |
64 | else | 64 | else |
65 | QMessageBox::warning ( this, "QashMoney", "Please select an item to edit." ); | 65 | QMessageBox::warning ( this, "QashMoney", "Please select an item to edit." ); |
66 | } | 66 | } |
67 | 67 | ||
68 | void MemoryDialog::deleteItem () | 68 | void MemoryDialog::deleteItem () |
69 | { | 69 | { |
70 | if ( listbox->currentItem() != -1 ) | 70 | if ( listbox->currentItem() != -1 ) |
71 | { | 71 | { |
72 | memory->deleteMemoryItem ( listbox->currentText() ); | 72 | memory->deleteMemoryItem ( listbox->currentText() ); |
73 | listbox->clear (); | 73 | listbox->clear (); |
74 | memory->displayMemoryItems ( listbox ); | 74 | memory->displayMemoryItems ( listbox ); |
75 | listbox->clearSelection(); | 75 | listbox->clearSelection(); |
76 | } | 76 | } |
77 | else | 77 | else |
78 | QMessageBox::warning ( this, "QashMoney", "Please select an item to delete." ); | 78 | QMessageBox::warning ( this, "QashMoney", "Please select an item to delete." ); |
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | 82 | ||
83 | 83 | ||
84 | 84 | ||
85 | 85 | ||
86 | 86 | ||
diff --git a/noncore/apps/qashmoney/newaccount.cpp b/noncore/apps/qashmoney/newaccount.cpp index 7e57a18..5932182 100755 --- a/noncore/apps/qashmoney/newaccount.cpp +++ b/noncore/apps/qashmoney/newaccount.cpp | |||
@@ -1,180 +1,180 @@ | |||
1 | #include "newaccount.h" | 1 | #include "newaccount.h" |
2 | #include "calculator.h" | 2 | #include "calculator.h" |
3 | #include "datepicker.h" | 3 | #include "datepicker.h" |
4 | #include <qmultilineedit.h> | 4 | #include <qmultilineedit.h> |
5 | 5 | ||
6 | extern Preferences *preferences; | 6 | extern Preferences *preferences; |
7 | 7 | ||
8 | NewAccount::NewAccount ( QWidget *parent, const char *name, bool modal ) : QDialog ( parent, name, modal ) | 8 | NewAccount::NewAccount ( QWidget *parent, const char *name, bool modal ) : QDialog ( parent, name, modal ) |
9 | { | 9 | { |
10 | accountdescription = ""; | 10 | accountdescription = ""; |
11 | dateedited = FALSE; | 11 | dateedited = FALSE; |
12 | setCaption( tr( "Account" ) ); | 12 | setCaption( tr( "Account" ) ); |
13 | 13 | ||
14 | namelabel = new QLabel ( "Account Name", this ); | 14 | namelabel = new QLabel ( "Account Name", this ); |
15 | 15 | ||
16 | accountbox = new QHBox ( this ); | 16 | accountbox = new QHBox ( this ); |
17 | accountname = new QLineEdit ( accountbox ); | 17 | accountname = new QLineEdit ( accountbox ); |
18 | descriptionbutton = new QPushButton ( accountbox ); | 18 | descriptionbutton = new QPushButton ( accountbox ); |
19 | descriptionbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/info.png" ) ); | 19 | descriptionbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/info.png" ) ); |
20 | 20 | ||
21 | datelabel = new QLabel ( "Date", this ); | 21 | datelabel = new QLabel ( "Date", this ); |
22 | 22 | ||
23 | datebox = new QHBox ( this ); | 23 | datebox = new QHBox ( this ); |
24 | startdate = new QLineEdit ( datebox ); | 24 | startdate = new QLineEdit ( datebox ); |
25 | startdate->setDisabled ( TRUE ); | 25 | startdate->setDisabled ( TRUE ); |
26 | datebutton = new QPushButton ( datebox ); | 26 | datebutton = new QPushButton ( datebox ); |
27 | datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); | 27 | datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); |
28 | 28 | ||
29 | childcheckbox = new QCheckBox ( this ); | 29 | childcheckbox = new QCheckBox ( this ); |
30 | childcheckbox->setText( tr ( "Child Account" ) ); | 30 | childcheckbox->setText( tr ( "Child Account" ) ); |
31 | 31 | ||
32 | childlabel = new QLabel ( "Child of", this ); | 32 | childlabel = new QLabel ( "Child of", this ); |
33 | childbox = new QComboBox ( FALSE, this ); | 33 | childbox = new QComboBox ( FALSE, this ); |
34 | hideChildPulldownMenu (); | 34 | hideChildPulldownMenu (); |
35 | 35 | ||
36 | balancelabel = new QLabel ( "Balance", this ); | 36 | balancelabel = new QLabel ( "Balance", this ); |
37 | 37 | ||
38 | balancebox = new QHBox ( this ); | 38 | balancebox = new QHBox ( this ); |
39 | accountbalance = new QLineEdit ( balancebox ); | 39 | accountbalance = new QLineEdit ( balancebox ); |
40 | accountbalance->setText ( "0.00" ); | 40 | accountbalance->setText ( "0.00" ); |
41 | balancecalculator = new QPushButton( balancebox ); | 41 | balancecalculator = new QPushButton( balancebox ); |
42 | balancecalculator->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); | 42 | balancecalculator->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); |
43 | 43 | ||
44 | creditlimitlabel = new QLabel ( "Credit Limit", this ); | 44 | creditlimitlabel = new QLabel ( "Credit Limit", this ); |
45 | 45 | ||
46 | creditlimitbox = new QHBox ( this ); | 46 | creditlimitbox = new QHBox ( this ); |
47 | creditlimit = new QLineEdit ( creditlimitbox ); | 47 | creditlimit = new QLineEdit ( creditlimitbox ); |
48 | creditlimitbox->setEnabled ( FALSE ); | 48 | creditlimitbox->setEnabled ( FALSE ); |
49 | creditlimitcalculator = new QPushButton( creditlimitbox ); | 49 | creditlimitcalculator = new QPushButton( creditlimitbox ); |
50 | creditlimitcalculator->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); | 50 | creditlimitcalculator->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); |
51 | 51 | ||
52 | currencybox = new Currency ( this ); | 52 | currencybox = new Currency ( this ); |
53 | 53 | ||
54 | typelabel = new QLabel ( "Type", this ); | 54 | typelabel = new QLabel ( "Type", this ); |
55 | accounttype = new QComboBox ( FALSE, this ); | 55 | accounttype = new QComboBox ( FALSE, this ); |
56 | accounttype->insertItem( tr( "Bank" ) ); | 56 | accounttype->insertItem( tr( "Bank" ) ); |
57 | accounttype->insertItem( tr( "Cash" ) ); | 57 | accounttype->insertItem( tr( "Cash" ) ); |
58 | accounttype->insertItem( tr( "Credit Card" ) ); | 58 | accounttype->insertItem( tr( "Credit Card" ) ); |
59 | accounttype->insertItem( tr( "Equity" ) ); | 59 | accounttype->insertItem( tr( "Equity" ) ); |
60 | accounttype->insertItem( tr( "Asset" ) ); | 60 | accounttype->insertItem( tr( "Asset" ) ); |
61 | accounttype->insertItem( tr( "Liability" ) ); | 61 | accounttype->insertItem( tr( "Liability" ) ); |
62 | 62 | ||
63 | layout = new QGridLayout ( this, 7, 2, 4, 2 ); | 63 | layout = new QGridLayout ( this, 7, 2, 4, 2 ); |
64 | layout->addWidget ( namelabel , 0, 0, Qt::AlignLeft ); | 64 | layout->addWidget ( namelabel , 0, 0, Qt::AlignLeft ); |
65 | layout->addWidget ( accountbox, 1, 0, Qt::AlignLeft ); | 65 | layout->addWidget ( accountbox, 1, 0, Qt::AlignLeft ); |
66 | layout->addWidget ( datelabel, 2, 0, Qt::AlignLeft ); | 66 | layout->addWidget ( datelabel, 2, 0, Qt::AlignLeft ); |
67 | layout->addWidget ( datebox, 3, 0, Qt::AlignLeft ); | 67 | layout->addWidget ( datebox, 3, 0, Qt::AlignLeft ); |
68 | layout->addWidget ( childcheckbox, 4, 0, Qt::AlignLeft ); | 68 | layout->addWidget ( childcheckbox, 4, 0, Qt::AlignLeft ); |
69 | layout->addWidget ( childlabel, 5, 0, Qt::AlignLeft ); | 69 | layout->addWidget ( childlabel, 5, 0, Qt::AlignLeft ); |
70 | layout->addWidget ( childbox, 6, 0, Qt::AlignLeft ); | 70 | layout->addWidget ( childbox, 6, 0, Qt::AlignLeft ); |
71 | layout->addWidget ( balancelabel, 0, 1, Qt::AlignLeft ); | 71 | layout->addWidget ( balancelabel, 0, 1, Qt::AlignLeft ); |
72 | layout->addWidget ( balancebox, 1, 1, Qt::AlignLeft ); | 72 | layout->addWidget ( balancebox, 1, 1, Qt::AlignLeft ); |
73 | layout->addWidget ( creditlimitlabel, 2, 1, Qt::AlignLeft ); | 73 | layout->addWidget ( creditlimitlabel, 2, 1, Qt::AlignLeft ); |
74 | layout->addWidget ( creditlimitbox, 3, 1, Qt::AlignLeft ); | 74 | layout->addWidget ( creditlimitbox, 3, 1, Qt::AlignLeft ); |
75 | layout->addWidget ( currencybox, 4, 1, Qt::AlignLeft ); | 75 | layout->addWidget ( currencybox, 4, 1, Qt::AlignLeft ); |
76 | layout->addWidget ( typelabel, 5, 1, Qt::AlignLeft ); | 76 | layout->addWidget ( typelabel, 5, 1, Qt::AlignLeft ); |
77 | layout->addWidget ( accounttype, 6, 1, Qt::AlignLeft ); | 77 | layout->addWidget ( accounttype, 6, 1, Qt::AlignLeft ); |
78 | 78 | ||
79 | connect ( childcheckbox, SIGNAL ( clicked () ), this, SLOT ( showChildPulldownMenu() ) ); | 79 | connect ( childcheckbox, SIGNAL ( clicked() ), this, SLOT ( showChildPulldownMenu() ) ); |
80 | connect ( balancecalculator, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); | 80 | connect ( balancecalculator, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); |
81 | connect ( creditlimitcalculator, SIGNAL ( released() ), this, SLOT ( showCreditLimitCalculator() ) ); | 81 | connect ( creditlimitcalculator, SIGNAL ( released() ), this, SLOT ( showCreditLimitCalculator() ) ); |
82 | connect ( accounttype, SIGNAL ( activated ( int ) ), this, SLOT ( activateCreditLimit ( int ) ) ); | 82 | connect ( accounttype, SIGNAL ( activated(int) ), this, SLOT ( activateCreditLimit(int) ) ); |
83 | connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) ); | 83 | connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) ); |
84 | connect ( descriptionbutton, SIGNAL ( released () ), this, SLOT ( addAccountDescription() ) ); | 84 | connect ( descriptionbutton, SIGNAL ( released() ), this, SLOT ( addAccountDescription() ) ); |
85 | } | 85 | } |
86 | 86 | ||
87 | NewAccount::~NewAccount () | 87 | NewAccount::~NewAccount () |
88 | { | 88 | { |
89 | } | 89 | } |
90 | 90 | ||
91 | void NewAccount::showChildPulldownMenu () | 91 | void NewAccount::showChildPulldownMenu () |
92 | { | 92 | { |
93 | if ( childcheckbox->isChecked() == TRUE ) | 93 | if ( childcheckbox->isChecked() == TRUE ) |
94 | { | 94 | { |
95 | childlabel->setEnabled ( TRUE ); | 95 | childlabel->setEnabled ( TRUE ); |
96 | childbox->setEnabled ( TRUE ); | 96 | childbox->setEnabled ( TRUE ); |
97 | } | 97 | } |
98 | else | 98 | else |
99 | hideChildPulldownMenu(); | 99 | hideChildPulldownMenu(); |
100 | } | 100 | } |
101 | 101 | ||
102 | void NewAccount::hideChildPulldownMenu () | 102 | void NewAccount::hideChildPulldownMenu () |
103 | { | 103 | { |
104 | childlabel->setEnabled ( FALSE ); | 104 | childlabel->setEnabled ( FALSE ); |
105 | childbox->setEnabled ( FALSE ); | 105 | childbox->setEnabled ( FALSE ); |
106 | } | 106 | } |
107 | 107 | ||
108 | void NewAccount::showCalculator () | 108 | void NewAccount::showCalculator () |
109 | { | 109 | { |
110 | Calculator *calculator = new Calculator ( this ); | 110 | Calculator *calculator = new Calculator ( this ); |
111 | calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) ); | 111 | calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) ); |
112 | if ( calculator->exec () == QDialog::Accepted ) | 112 | if ( calculator->exec () == QDialog::Accepted ) |
113 | accountbalance->setText ( calculator->display->text() ); | 113 | accountbalance->setText ( calculator->display->text() ); |
114 | } | 114 | } |
115 | 115 | ||
116 | void NewAccount::showCreditLimitCalculator () | 116 | void NewAccount::showCreditLimitCalculator () |
117 | { | 117 | { |
118 | Calculator *calculator = new Calculator ( this ); | 118 | Calculator *calculator = new Calculator ( this ); |
119 | calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) ); | 119 | calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) ); |
120 | if ( calculator->exec () == QDialog::Accepted ) | 120 | if ( calculator->exec () == QDialog::Accepted ) |
121 | creditlimit->setText ( calculator->display->text() ); | 121 | creditlimit->setText ( calculator->display->text() ); |
122 | } | 122 | } |
123 | 123 | ||
124 | void NewAccount::activateCreditLimit ( int index ) | 124 | void NewAccount::activateCreditLimit ( int index ) |
125 | { | 125 | { |
126 | if ( index == 2 || index == 5 ) | 126 | if ( index == 2 || index == 5 ) |
127 | creditlimitbox->setEnabled ( TRUE ); | 127 | creditlimitbox->setEnabled ( TRUE ); |
128 | else | 128 | else |
129 | { | 129 | { |
130 | creditlimit->clear (); | 130 | creditlimit->clear (); |
131 | creditlimitbox->setEnabled ( FALSE ); | 131 | creditlimitbox->setEnabled ( FALSE ); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | 134 | ||
135 | void NewAccount::showCalendar () | 135 | void NewAccount::showCalendar () |
136 | { | 136 | { |
137 | QDate newDate = QDate::currentDate (); | 137 | QDate newDate = QDate::currentDate (); |
138 | DatePicker *dp = new DatePicker ( newDate ); | 138 | DatePicker *dp = new DatePicker ( newDate ); |
139 | dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) ); | 139 | dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) ); |
140 | 140 | ||
141 | int response = dp->exec(); | 141 | int response = dp->exec(); |
142 | if ( response == QDialog::Accepted ) | 142 | if ( response == QDialog::Accepted ) |
143 | { | 143 | { |
144 | // Set date integers | 144 | // Set date integers |
145 | year = dp->getYear(); | 145 | year = dp->getYear(); |
146 | month = dp->getMonth(); | 146 | month = dp->getMonth(); |
147 | day = dp->getDay(); | 147 | day = dp->getDay(); |
148 | 148 | ||
149 | // Set dateedited to TRUE | 149 | // Set dateedited to TRUE |
150 | // This tells the accountdisplay object that the user edited an account | 150 | // This tells the accountdisplay object that the user edited an account |
151 | // and did change the date | 151 | // and did change the date |
152 | dateedited = TRUE; | 152 | dateedited = TRUE; |
153 | 153 | ||
154 | // Display date with our selected format | 154 | // Display date with our selected format |
155 | startdate->setText ( preferences->getDate ( year, month, day ) ); | 155 | startdate->setText ( preferences->getDate ( year, month, day ) ); |
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | bool NewAccount::getDateEdited () | 159 | bool NewAccount::getDateEdited () |
160 | { | 160 | { |
161 | return dateedited; | 161 | return dateedited; |
162 | } | 162 | } |
163 | 163 | ||
164 | int NewAccount::getDay () | 164 | int NewAccount::getDay () |
165 | { | 165 | { |
166 | return day; | 166 | return day; |
167 | } | 167 | } |
168 | 168 | ||
169 | int NewAccount::getMonth () | 169 | int NewAccount::getMonth () |
170 | { | 170 | { |
171 | return month; | 171 | return month; |
172 | } | 172 | } |
173 | 173 | ||
174 | int NewAccount::getYear () | 174 | int NewAccount::getYear () |
175 | { | 175 | { |
176 | return year; | 176 | return year; |
177 | } | 177 | } |
178 | 178 | ||
179 | QString NewAccount::getDescription () | 179 | QString NewAccount::getDescription () |
180 | { | 180 | { |
diff --git a/noncore/apps/qashmoney/newtransaction.cpp b/noncore/apps/qashmoney/newtransaction.cpp index 5c78139..87b7f7e 100755 --- a/noncore/apps/qashmoney/newtransaction.cpp +++ b/noncore/apps/qashmoney/newtransaction.cpp | |||
@@ -1,184 +1,184 @@ | |||
1 | #include "newtransaction.h" | 1 | #include "newtransaction.h" |
2 | #include "calculator.h" | 2 | #include "calculator.h" |
3 | #include "datepicker.h" | 3 | #include "datepicker.h" |
4 | #include "budget.h" | 4 | #include "budget.h" |
5 | 5 | ||
6 | #include <qmultilineedit.h> | 6 | #include <qmultilineedit.h> |
7 | 7 | ||
8 | extern Budget *budget; | 8 | extern Budget *budget; |
9 | extern Preferences *preferences; | 9 | extern Preferences *preferences; |
10 | 10 | ||
11 | NewTransaction::NewTransaction ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) | 11 | NewTransaction::NewTransaction ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) |
12 | { | 12 | { |
13 | transactiondescription = ""; | 13 | transactiondescription = ""; |
14 | currentlineitem = -1; | 14 | currentlineitem = -1; |
15 | currentbudget = -1; | 15 | currentbudget = -1; |
16 | dateedited = FALSE; | 16 | dateedited = FALSE; |
17 | setCaption( tr( "Transaction" ) ); | 17 | setCaption( tr( "Transaction" ) ); |
18 | 18 | ||
19 | // START FIRST COLUMN | 19 | // START FIRST COLUMN |
20 | 20 | ||
21 | namelabel = new QLabel ( "Transaction", this ); | 21 | namelabel = new QLabel ( "Transaction", this ); |
22 | 22 | ||
23 | transactionnamebox = new QHBox ( this ); | 23 | transactionnamebox = new QHBox ( this ); |
24 | transactionname = new QComboBox ( transactionnamebox ); | 24 | transactionname = new QComboBox ( transactionnamebox ); |
25 | transactionname->setEditable ( TRUE ); | 25 | transactionname->setEditable ( TRUE ); |
26 | descriptionbutton = new QPushButton ( transactionnamebox ); | 26 | descriptionbutton = new QPushButton ( transactionnamebox ); |
27 | descriptionbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/info.png" ) ); | 27 | descriptionbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/info.png" ) ); |
28 | connect ( descriptionbutton, SIGNAL ( released () ), this, SLOT ( addTransactionDescription() ) ); | 28 | connect ( descriptionbutton, SIGNAL ( released() ), this, SLOT ( addTransactionDescription() ) ); |
29 | 29 | ||
30 | amountlabel = new QLabel ( "Amount", this ); | 30 | amountlabel = new QLabel ( "Amount", this ); |
31 | 31 | ||
32 | transactionamountbox = new QHBox ( this ); | 32 | transactionamountbox = new QHBox ( this ); |
33 | transactionamount = new QLineEdit ( transactionamountbox ); | 33 | transactionamount = new QLineEdit ( transactionamountbox ); |
34 | transactionamount->setAlignment ( Qt::AlignRight ); | 34 | transactionamount->setAlignment ( Qt::AlignRight ); |
35 | transactionamount->setText ( "0.00" ); | 35 | transactionamount->setText ( "0.00" ); |
36 | calculatorbutton = new QPushButton( transactionamountbox ); | 36 | calculatorbutton = new QPushButton( transactionamountbox ); |
37 | calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); | 37 | calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); |
38 | connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); | 38 | connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); |
39 | 39 | ||
40 | datelabel = new QLabel ( "Date", this ); | 40 | datelabel = new QLabel ( "Date", this ); |
41 | 41 | ||
42 | transactiondatebox = new QHBox ( this ); | 42 | transactiondatebox = new QHBox ( this ); |
43 | transactiondate = new QLineEdit ( transactiondatebox ); | 43 | transactiondate = new QLineEdit ( transactiondatebox ); |
44 | transactiondate->setAlignment ( Qt::AlignRight ); | 44 | transactiondate->setAlignment ( Qt::AlignRight ); |
45 | transactiondate->setDisabled ( TRUE ); | 45 | transactiondate->setDisabled ( TRUE ); |
46 | datebutton = new QPushButton( transactiondatebox ); | 46 | datebutton = new QPushButton( transactiondatebox ); |
47 | datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); | 47 | datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); |
48 | connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) ); | 48 | connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) ); |
49 | 49 | ||
50 | clearedcheckbox = new QCheckBox ( "Cleared", this ); | 50 | clearedcheckbox = new QCheckBox ( "Cleared", this ); |
51 | depositbox = new QCheckBox ( "Credit", this ); | 51 | depositbox = new QCheckBox ( "Credit", this ); |
52 | 52 | ||
53 | // START SECOND COLUMN | 53 | // START SECOND COLUMN |
54 | 54 | ||
55 | numberlabel = new QLabel ( "Number", this ); | 55 | numberlabel = new QLabel ( "Number", this ); |
56 | transactionnumber = new QLineEdit ( this ); | 56 | transactionnumber = new QLineEdit ( this ); |
57 | 57 | ||
58 | budgetlabel = new QLabel ( "Budget", this ); | 58 | budgetlabel = new QLabel ( "Budget", this ); |
59 | budgetbox = new QComboBox ( FALSE, this ); | 59 | budgetbox = new QComboBox ( FALSE, this ); |
60 | 60 | ||
61 | lineitemlabel = new QLabel ( "LineItem", this ); | 61 | lineitemlabel = new QLabel ( "LineItem", this ); |
62 | lineitembox = new QComboBox ( FALSE, this ); | 62 | lineitembox = new QComboBox ( FALSE, this ); |
63 | 63 | ||
64 | layout = new QGridLayout ( this, 7, 2, 2, 2 ); | 64 | layout = new QGridLayout ( this, 7, 2, 2, 2 ); |
65 | layout->addWidget ( namelabel, 0, 0, Qt::AlignLeft ); | 65 | layout->addWidget ( namelabel, 0, 0, Qt::AlignLeft ); |
66 | layout->addWidget ( transactionnamebox, 1, 0, Qt::AlignLeft ); | 66 | layout->addWidget ( transactionnamebox, 1, 0, Qt::AlignLeft ); |
67 | layout->addWidget ( amountlabel, 2, 0, Qt::AlignLeft ); | 67 | layout->addWidget ( amountlabel, 2, 0, Qt::AlignLeft ); |
68 | layout->addWidget ( transactionamountbox, 3, 0, Qt::AlignLeft ); | 68 | layout->addWidget ( transactionamountbox, 3, 0, Qt::AlignLeft ); |
69 | layout->addWidget ( datelabel, 4, 0, Qt::AlignLeft ); | 69 | layout->addWidget ( datelabel, 4, 0, Qt::AlignLeft ); |
70 | layout->addWidget ( transactiondatebox, 5, 0, Qt::AlignLeft ); | 70 | layout->addWidget ( transactiondatebox, 5, 0, Qt::AlignLeft ); |
71 | layout->addWidget ( clearedcheckbox, 6, 0, Qt::AlignLeft ); | 71 | layout->addWidget ( clearedcheckbox, 6, 0, Qt::AlignLeft ); |
72 | layout->addWidget ( numberlabel, 0, 1, Qt::AlignLeft ); | 72 | layout->addWidget ( numberlabel, 0, 1, Qt::AlignLeft ); |
73 | layout->addWidget ( transactionnumber, 1, 1, Qt::AlignLeft ); | 73 | layout->addWidget ( transactionnumber, 1, 1, Qt::AlignLeft ); |
74 | layout->addWidget ( budgetlabel, 2, 1, Qt::AlignLeft ); | 74 | layout->addWidget ( budgetlabel, 2, 1, Qt::AlignLeft ); |
75 | layout->addWidget ( budgetbox, 3, 1, Qt::AlignLeft ); | 75 | layout->addWidget ( budgetbox, 3, 1, Qt::AlignLeft ); |
76 | layout->addWidget ( lineitemlabel, 4, 1, Qt::AlignLeft ); | 76 | layout->addWidget ( lineitemlabel, 4, 1, Qt::AlignLeft ); |
77 | layout->addWidget ( lineitembox, 5, 1, Qt::AlignLeft ); | 77 | layout->addWidget ( lineitembox, 5, 1, Qt::AlignLeft ); |
78 | layout->addWidget ( depositbox, 6, 1, Qt::AlignLeft ); | 78 | layout->addWidget ( depositbox, 6, 1, Qt::AlignLeft ); |
79 | 79 | ||
80 | if ( budget->getNumberOfBudgets() != 0 ) | 80 | if ( budget->getNumberOfBudgets() != 0 ) |
81 | { | 81 | { |
82 | budgetnameslist = budget->getBudgetNames(); | 82 | budgetnameslist = budget->getBudgetNames(); |
83 | budgetidslist = budget->getBudgetIDs(); | 83 | budgetidslist = budget->getBudgetIDs(); |
84 | budgetbox->insertStringList ( *budgetnameslist ); | 84 | budgetbox->insertStringList ( *budgetnameslist ); |
85 | lineitemlabel->setEnabled ( FALSE ); | 85 | lineitemlabel->setEnabled ( FALSE ); |
86 | lineitembox->setEnabled ( FALSE ); | 86 | lineitembox->setEnabled ( FALSE ); |
87 | connect ( budgetbox, SIGNAL ( activated ( int ) ), this, SLOT ( setCurrentBudget ( int ) ) ); | 87 | connect ( budgetbox, SIGNAL ( activated(int) ), this, SLOT ( setCurrentBudget(int) ) ); |
88 | connect ( lineitembox, SIGNAL ( activated ( int ) ), this, SLOT ( setCurrentLineItem ( int ) ) ); | 88 | connect ( lineitembox, SIGNAL ( activated(int) ), this, SLOT ( setCurrentLineItem(int) ) ); |
89 | } | 89 | } |
90 | else | 90 | else |
91 | { | 91 | { |
92 | budgetlabel->setEnabled ( FALSE ); | 92 | budgetlabel->setEnabled ( FALSE ); |
93 | budgetbox->setEnabled ( FALSE ); | 93 | budgetbox->setEnabled ( FALSE ); |
94 | lineitemlabel->setEnabled ( FALSE ); | 94 | lineitemlabel->setEnabled ( FALSE ); |
95 | lineitembox->setEnabled ( FALSE ); | 95 | lineitembox->setEnabled ( FALSE ); |
96 | } | 96 | } |
97 | 97 | ||
98 | } | 98 | } |
99 | 99 | ||
100 | NewTransaction::~NewTransaction () | 100 | NewTransaction::~NewTransaction () |
101 | { | 101 | { |
102 | } | 102 | } |
103 | 103 | ||
104 | void NewTransaction::showCalculator () | 104 | void NewTransaction::showCalculator () |
105 | { | 105 | { |
106 | Calculator *calculator = new Calculator ( this ); | 106 | Calculator *calculator = new Calculator ( this ); |
107 | calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) ); | 107 | calculator->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) ); |
108 | if ( calculator->exec () == QDialog::Accepted ) | 108 | if ( calculator->exec () == QDialog::Accepted ) |
109 | transactionamount->setText ( calculator->display->text() ); | 109 | transactionamount->setText ( calculator->display->text() ); |
110 | } | 110 | } |
111 | 111 | ||
112 | void NewTransaction::showCalendar () | 112 | void NewTransaction::showCalendar () |
113 | { | 113 | { |
114 | QDate newDate = QDate::currentDate (); | 114 | QDate newDate = QDate::currentDate (); |
115 | DatePicker *dp = new DatePicker ( newDate ); | 115 | DatePicker *dp = new DatePicker ( newDate ); |
116 | dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) ); | 116 | dp->setMaximumWidth ( ( int ) ( this->size().width() * 0.9 ) ); |
117 | 117 | ||
118 | int response = dp->exec(); | 118 | int response = dp->exec(); |
119 | if ( response == QDialog::Accepted ) | 119 | if ( response == QDialog::Accepted ) |
120 | { | 120 | { |
121 | // Set date integers | 121 | // Set date integers |
122 | year = dp->getYear(); | 122 | year = dp->getYear(); |
123 | month = dp->getMonth(); | 123 | month = dp->getMonth(); |
124 | day = dp->getDay(); | 124 | day = dp->getDay(); |
125 | 125 | ||
126 | // Set dateedited to TRUE | 126 | // Set dateedited to TRUE |
127 | // This tells the transactiondisplay object that the user edited an transaction | 127 | // This tells the transactiondisplay object that the user edited an transaction |
128 | // and did change the date3 | 128 | // and did change the date3 |
129 | dateedited = TRUE; | 129 | dateedited = TRUE; |
130 | 130 | ||
131 | // Display date with our selected format | 131 | // Display date with our selected format |
132 | transactiondate->setText ( preferences->getDate ( year, month, day ) ); | 132 | transactiondate->setText ( preferences->getDate ( year, month, day ) ); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | bool NewTransaction::getDateEdited () | 136 | bool NewTransaction::getDateEdited () |
137 | { | 137 | { |
138 | return dateedited; | 138 | return dateedited; |
139 | } | 139 | } |
140 | 140 | ||
141 | int NewTransaction::getDay () | 141 | int NewTransaction::getDay () |
142 | { | 142 | { |
143 | return day; | 143 | return day; |
144 | } | 144 | } |
145 | 145 | ||
146 | int NewTransaction::getMonth () | 146 | int NewTransaction::getMonth () |
147 | { | 147 | { |
148 | return month; | 148 | return month; |
149 | } | 149 | } |
150 | 150 | ||
151 | int NewTransaction::getYear () | 151 | int NewTransaction::getYear () |
152 | { | 152 | { |
153 | return year; | 153 | return year; |
154 | } | 154 | } |
155 | 155 | ||
156 | QString NewTransaction::getDescription () | 156 | QString NewTransaction::getDescription () |
157 | { | 157 | { |
158 | return transactiondescription; | 158 | return transactiondescription; |
159 | } | 159 | } |
160 | 160 | ||
161 | void NewTransaction::setDescription ( QString description ) | 161 | void NewTransaction::setDescription ( QString description ) |
162 | { | 162 | { |
163 | transactiondescription = description; | 163 | transactiondescription = description; |
164 | } | 164 | } |
165 | 165 | ||
166 | void NewTransaction::addTransactionDescription () | 166 | void NewTransaction::addTransactionDescription () |
167 | { | 167 | { |
168 | // Function for adding or editing an transaction description. | 168 | // Function for adding or editing an transaction description. |
169 | QDialog *description = new QDialog ( this, "description", TRUE ); | 169 | QDialog *description = new QDialog ( this, "description", TRUE ); |
170 | description->setCaption ( "Notes" ); | 170 | description->setCaption ( "Notes" ); |
171 | QMultiLineEdit *enter = new QMultiLineEdit ( description ); | 171 | QMultiLineEdit *enter = new QMultiLineEdit ( description ); |
172 | enter->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) ); | 172 | enter->setFixedSize ( ( int ) (this->width() * 0.75 ), ( int ) ( this->height() * 0.5 ) ); |
173 | enter->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) ); | 173 | enter->setWrapColumnOrWidth ( ( int ) (this->width() * 0.75 ) ); |
174 | enter->setWordWrap ( QMultiLineEdit::WidgetWidth ); | 174 | enter->setWordWrap ( QMultiLineEdit::WidgetWidth ); |
175 | if ( transactiondescription != "(NULL)" ) | 175 | if ( transactiondescription != "(NULL)" ) |
176 | enter->setText ( transactiondescription ); | 176 | enter->setText ( transactiondescription ); |
177 | if ( description->exec () == QDialog::Accepted ) | 177 | if ( description->exec () == QDialog::Accepted ) |
178 | transactiondescription = enter->text (); | 178 | transactiondescription = enter->text (); |
179 | } | 179 | } |
180 | 180 | ||
181 | int NewTransaction::getNameIndex ( QString name ) | 181 | int NewTransaction::getNameIndex ( QString name ) |
182 | { | 182 | { |
183 | int counter; | 183 | int counter; |
184 | int items = transactionname->count(); | 184 | int items = transactionname->count(); |
diff --git a/noncore/apps/qashmoney/preferencedialogs.cpp b/noncore/apps/qashmoney/preferencedialogs.cpp index 5408a5b..b83c957 100755 --- a/noncore/apps/qashmoney/preferencedialogs.cpp +++ b/noncore/apps/qashmoney/preferencedialogs.cpp | |||
@@ -1,216 +1,216 @@ | |||
1 | #include "preferencedialogs.h" | 1 | #include "preferencedialogs.h" |
2 | #include "preferences.h" | 2 | #include "preferences.h" |
3 | 3 | ||
4 | extern Preferences *preferences; | 4 | extern Preferences *preferences; |
5 | 5 | ||
6 | DatePreferences::DatePreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) | 6 | DatePreferences::DatePreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) |
7 | { | 7 | { |
8 | setCaption( tr( "Date" ) ); | 8 | setCaption( tr( "Date" ) ); |
9 | 9 | ||
10 | QLabel *datelabel = new QLabel ( "Format", this ); | 10 | QLabel *datelabel = new QLabel ( "Format", this ); |
11 | dateformat = new QComboBox ( this ); | 11 | dateformat = new QComboBox ( this ); |
12 | dateformat->setEditable ( FALSE ); | 12 | dateformat->setEditable ( FALSE ); |
13 | dateformat->insertItem ( "yyyymmdd" ); | 13 | dateformat->insertItem ( "yyyymmdd" ); |
14 | dateformat->insertItem ( "yymmdd" ); | 14 | dateformat->insertItem ( "yymmdd" ); |
15 | dateformat->insertItem ( "mmddyyyy" ); | 15 | dateformat->insertItem ( "mmddyyyy" ); |
16 | dateformat->insertItem ( "mmddyy" ); | 16 | dateformat->insertItem ( "mmddyy" ); |
17 | dateformat->insertItem ( "yyyyddmm" ); | 17 | dateformat->insertItem ( "yyyyddmm" ); |
18 | dateformat->insertItem ( "yyddmm" ); | 18 | dateformat->insertItem ( "yyddmm" ); |
19 | dateformat->insertItem ( "ddmmyyyy" ); | 19 | dateformat->insertItem ( "ddmmyyyy" ); |
20 | dateformat->insertItem ( "ddmmyy" ); | 20 | dateformat->insertItem ( "ddmmyy" ); |
21 | connect ( dateformat, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateFormat ( int ) ) ); | 21 | connect ( dateformat, SIGNAL ( activated(int) ), this, SLOT ( changeDateFormat(int) ) ); |
22 | 22 | ||
23 | QLabel *dateseparatorlabel = new QLabel ( "Separator", this ); | 23 | QLabel *dateseparatorlabel = new QLabel ( "Separator", this ); |
24 | dateseparator = new QComboBox ( this ); | 24 | dateseparator = new QComboBox ( this ); |
25 | dateseparator->insertItem ( "/" ); | 25 | dateseparator->insertItem ( "/" ); |
26 | dateseparator->insertItem ( "-" ); | 26 | dateseparator->insertItem ( "-" ); |
27 | dateseparator->insertItem ( "." ); | 27 | dateseparator->insertItem ( "." ); |
28 | connect ( dateseparator, SIGNAL ( activated ( int ) ), this, SLOT ( changeDateSeparator ( int ) ) ); | 28 | connect ( dateseparator, SIGNAL ( activated(int) ), this, SLOT ( changeDateSeparator(int) ) ); |
29 | 29 | ||
30 | defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); | 30 | defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); |
31 | connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultDatePreferences () ) ); | 31 | connect ( defaults, SIGNAL ( released() ), this, SLOT ( setDefaultDatePreferences() ) ); |
32 | 32 | ||
33 | dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 ); | 33 | dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 ); |
34 | dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 ); | 34 | dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 ); |
35 | 35 | ||
36 | layout = new QVBoxLayout ( this, 2, 2 ); | 36 | layout = new QVBoxLayout ( this, 2, 2 ); |
37 | layout->addWidget ( datelabel ); | 37 | layout->addWidget ( datelabel ); |
38 | layout->addWidget ( dateformat ); | 38 | layout->addWidget ( dateformat ); |
39 | layout->addWidget ( dateseparatorlabel ); | 39 | layout->addWidget ( dateseparatorlabel ); |
40 | layout->addWidget ( dateseparator ); | 40 | layout->addWidget ( dateseparator ); |
41 | layout->insertSpacing ( 4, 5 ); | 41 | layout->insertSpacing ( 4, 5 ); |
42 | layout->addWidget ( defaults ); | 42 | layout->addWidget ( defaults ); |
43 | 43 | ||
44 | } | 44 | } |
45 | 45 | ||
46 | DatePreferences::~DatePreferences () | 46 | DatePreferences::~DatePreferences () |
47 | { | 47 | { |
48 | } | 48 | } |
49 | 49 | ||
50 | void DatePreferences::changeDateFormat ( int index ) | 50 | void DatePreferences::changeDateFormat ( int index ) |
51 | { | 51 | { |
52 | index ++; | 52 | index ++; |
53 | preferences->changePreference ( 1, index ); | 53 | preferences->changePreference ( 1, index ); |
54 | } | 54 | } |
55 | 55 | ||
56 | void DatePreferences::changeDateSeparator ( int index ) | 56 | void DatePreferences::changeDateSeparator ( int index ) |
57 | { | 57 | { |
58 | index ++; | 58 | index ++; |
59 | preferences->changePreference ( 2, index ); | 59 | preferences->changePreference ( 2, index ); |
60 | } | 60 | } |
61 | 61 | ||
62 | void DatePreferences::setDefaultDatePreferences () | 62 | void DatePreferences::setDefaultDatePreferences () |
63 | { | 63 | { |
64 | preferences->setDefaultDatePreferences (); | 64 | preferences->setDefaultDatePreferences (); |
65 | dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 ); | 65 | dateformat->setCurrentItem ( ( preferences->getPreference ( 1 ) ) - 1 ); |
66 | dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 ); | 66 | dateseparator->setCurrentItem ( ( preferences->getPreference ( 2 ) ) - 1 ); |
67 | } | 67 | } |
68 | 68 | ||
69 | // START TRANSACTION PREFERENCES | 69 | // START TRANSACTION PREFERENCES |
70 | 70 | ||
71 | TransactionPreferences::TransactionPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) | 71 | TransactionPreferences::TransactionPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) |
72 | { | 72 | { |
73 | setCaption( tr ( "Transaction" ) ); | 73 | setCaption( tr ( "Transaction" ) ); |
74 | 74 | ||
75 | showclearedtransactions = new QCheckBox ( this ); | 75 | showclearedtransactions = new QCheckBox ( this ); |
76 | showclearedtransactions->setText ( "Show Cleared Transactions" ); | 76 | showclearedtransactions->setText ( "Show Cleared Transactions" ); |
77 | 77 | ||
78 | limittransactionsbox = new QHBox ( this ); | 78 | limittransactionsbox = new QHBox ( this ); |
79 | limittransactionsbox->setSpacing ( 2 ); | 79 | limittransactionsbox->setSpacing ( 2 ); |
80 | limittransactionslabel = new QLabel ( "Show ", limittransactionsbox ); | 80 | limittransactionslabel = new QLabel ( "Show ", limittransactionsbox ); |
81 | limittransactions = new QComboBox ( limittransactionsbox ); | 81 | limittransactions = new QComboBox ( limittransactionsbox ); |
82 | QLabel *limittransactionslabel2 = new QLabel ( "of cleared transactions. ", limittransactionsbox ); | 82 | QLabel *limittransactionslabel2 = new QLabel ( "of cleared transactions. ", limittransactionsbox ); |
83 | limittransactions->insertItem ( "14 days" ); | 83 | limittransactions->insertItem ( "14 days" ); |
84 | limittransactions->insertItem ( "30 days" ); | 84 | limittransactions->insertItem ( "30 days" ); |
85 | limittransactions->insertItem ( "90 days" ); | 85 | limittransactions->insertItem ( "90 days" ); |
86 | limittransactions->insertItem ( "180 days" ); | 86 | limittransactions->insertItem ( "180 days" ); |
87 | limittransactions->insertItem ( "365 days" ); | 87 | limittransactions->insertItem ( "365 days" ); |
88 | limittransactions->insertItem ( "All" ); | 88 | limittransactions->insertItem ( "All" ); |
89 | limittransactions->setCurrentItem ( preferences->getPreference ( 7 ) ); | 89 | limittransactions->setCurrentItem ( preferences->getPreference ( 7 ) ); |
90 | 90 | ||
91 | excludetransfers = new QCheckBox ( this ); | 91 | excludetransfers = new QCheckBox ( this ); |
92 | excludetransfers->setText ( "Include Transfers In Limit View" ); | 92 | excludetransfers->setText ( "Include Transfers In Limit View" ); |
93 | 93 | ||
94 | if ( preferences->getPreference ( 3 ) == 1 ) | 94 | if ( preferences->getPreference ( 3 ) == 1 ) |
95 | showclearedtransactions->setChecked ( TRUE ); | 95 | showclearedtransactions->setChecked ( TRUE ); |
96 | else | 96 | else |
97 | showclearedtransactions->setChecked ( FALSE ); | 97 | showclearedtransactions->setChecked ( FALSE ); |
98 | 98 | ||
99 | if ( preferences->getPreference ( 6 ) == 1 ) | 99 | if ( preferences->getPreference ( 6 ) == 1 ) |
100 | excludetransfers->setChecked ( TRUE ); | 100 | excludetransfers->setChecked ( TRUE ); |
101 | else | 101 | else |
102 | excludetransfers->setChecked ( FALSE ); | 102 | excludetransfers->setChecked ( FALSE ); |
103 | 103 | ||
104 | defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); | 104 | defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); |
105 | connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultTransactionPreferences () ) ); | 105 | connect ( defaults, SIGNAL ( released() ), this, SLOT ( setDefaultTransactionPreferences() ) ); |
106 | 106 | ||
107 | layout = new QVBoxLayout ( this, 2, 2 ); | 107 | layout = new QVBoxLayout ( this, 2, 2 ); |
108 | layout->addWidget ( showclearedtransactions ); | 108 | layout->addWidget ( showclearedtransactions ); |
109 | layout->addWidget ( limittransactionsbox ); | 109 | layout->addWidget ( limittransactionsbox ); |
110 | layout->addWidget ( excludetransfers ); | 110 | layout->addWidget ( excludetransfers ); |
111 | layout->insertSpacing ( 3, 5 ); | 111 | layout->insertSpacing ( 3, 5 ); |
112 | layout->addWidget ( defaults ); | 112 | layout->addWidget ( defaults ); |
113 | 113 | ||
114 | connect ( showclearedtransactions, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeShowClearedPreference ( bool ) ) ); | 114 | connect ( showclearedtransactions, SIGNAL ( toggled(bool) ), this, SLOT ( changeShowClearedPreference(bool) ) ); |
115 | connect ( excludetransfers, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeExcludeTranfersPreference ( bool ) ) ); | 115 | connect ( excludetransfers, SIGNAL ( toggled(bool) ), this, SLOT ( changeExcludeTranfersPreference(bool) ) ); |
116 | connect ( limittransactions, SIGNAL ( activated ( int ) ), this, SLOT ( changeLimitTransactionsPreference ( int ) ) ); | 116 | connect ( limittransactions, SIGNAL ( activated(int) ), this, SLOT ( changeLimitTransactionsPreference(int) ) ); |
117 | } | 117 | } |
118 | 118 | ||
119 | TransactionPreferences::~TransactionPreferences () | 119 | TransactionPreferences::~TransactionPreferences () |
120 | { | 120 | { |
121 | } | 121 | } |
122 | 122 | ||
123 | void TransactionPreferences::changeLimitTransactionsPreference ( int pref ) | 123 | void TransactionPreferences::changeLimitTransactionsPreference ( int pref ) |
124 | { | 124 | { |
125 | preferences->changePreference ( 7, pref ); | 125 | preferences->changePreference ( 7, pref ); |
126 | } | 126 | } |
127 | 127 | ||
128 | void TransactionPreferences::changeShowClearedPreference ( bool state ) | 128 | void TransactionPreferences::changeShowClearedPreference ( bool state ) |
129 | { | 129 | { |
130 | if ( state == TRUE ) | 130 | if ( state == TRUE ) |
131 | preferences->changePreference ( 3, 1 ); | 131 | preferences->changePreference ( 3, 1 ); |
132 | else | 132 | else |
133 | preferences->changePreference ( 3, 0 ); | 133 | preferences->changePreference ( 3, 0 ); |
134 | } | 134 | } |
135 | 135 | ||
136 | void TransactionPreferences::changeExcludeTranfersPreference ( bool state ) | 136 | void TransactionPreferences::changeExcludeTranfersPreference ( bool state ) |
137 | { | 137 | { |
138 | if ( state == TRUE ) | 138 | if ( state == TRUE ) |
139 | preferences->changePreference ( 6, 1 ); | 139 | preferences->changePreference ( 6, 1 ); |
140 | else | 140 | else |
141 | preferences->changePreference ( 6, 0 ); | 141 | preferences->changePreference ( 6, 0 ); |
142 | } | 142 | } |
143 | 143 | ||
144 | void TransactionPreferences::setDefaultTransactionPreferences () | 144 | void TransactionPreferences::setDefaultTransactionPreferences () |
145 | { | 145 | { |
146 | preferences->changePreference ( 3, 0 ); | 146 | preferences->changePreference ( 3, 0 ); |
147 | preferences->changePreference ( 6, 0 ); | 147 | preferences->changePreference ( 6, 0 ); |
148 | preferences->changePreference ( 7, 0 ); | 148 | preferences->changePreference ( 7, 0 ); |
149 | showclearedtransactions->setChecked ( FALSE ); | 149 | showclearedtransactions->setChecked ( FALSE ); |
150 | limittransactions->setCurrentItem ( 0 ); | 150 | limittransactions->setCurrentItem ( 0 ); |
151 | } | 151 | } |
152 | 152 | ||
153 | // START ACCOUNT PREFERNCES | 153 | // START ACCOUNT PREFERNCES |
154 | 154 | ||
155 | AccountPreferences::AccountPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) | 155 | AccountPreferences::AccountPreferences ( QWidget* parent ) : QDialog ( parent, 0, TRUE ) |
156 | { | 156 | { |
157 | 157 | ||
158 | setCaption( tr ( "Account" ) ); | 158 | setCaption( tr ( "Account" ) ); |
159 | 159 | ||
160 | currencysupport = new QCheckBox ( this ); | 160 | currencysupport = new QCheckBox ( this ); |
161 | currencysupport->setText ( "Enable Currency Support" ); | 161 | currencysupport->setText ( "Enable Currency Support" ); |
162 | 162 | ||
163 | onetouch = new QCheckBox ( this ); | 163 | onetouch = new QCheckBox ( this ); |
164 | onetouch->setText ( "One Touch Account Viewing" ); | 164 | onetouch->setText ( "One Touch Account Viewing" ); |
165 | 165 | ||
166 | if ( preferences->getPreference ( 4 ) == 1 ) | 166 | if ( preferences->getPreference ( 4 ) == 1 ) |
167 | currencysupport->setChecked ( TRUE ); | 167 | currencysupport->setChecked ( TRUE ); |
168 | else | 168 | else |
169 | currencysupport->setChecked ( FALSE ); | 169 | currencysupport->setChecked ( FALSE ); |
170 | 170 | ||
171 | if ( preferences->getPreference ( 5 ) == 1 ) | 171 | if ( preferences->getPreference ( 5 ) == 1 ) |
172 | onetouch->setChecked ( TRUE ); | 172 | onetouch->setChecked ( TRUE ); |
173 | else | 173 | else |
174 | onetouch->setChecked ( FALSE ); | 174 | onetouch->setChecked ( FALSE ); |
175 | 175 | ||
176 | defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); | 176 | defaults = new QPushButton ( QPixmap ( "/opt/QtPalmtop/pics/defaults.png" ), "Defaults", this ); |
177 | connect ( defaults, SIGNAL ( released () ), this, SLOT ( setDefaultAccountPreferences () ) ); | 177 | connect ( defaults, SIGNAL ( released() ), this, SLOT ( setDefaultAccountPreferences() ) ); |
178 | 178 | ||
179 | layout = new QVBoxLayout ( this, 2, 2 ); | 179 | layout = new QVBoxLayout ( this, 2, 2 ); |
180 | layout->addWidget ( currencysupport ); | 180 | layout->addWidget ( currencysupport ); |
181 | layout->addWidget ( onetouch ); | 181 | layout->addWidget ( onetouch ); |
182 | layout->insertSpacing ( 2, 5 ); | 182 | layout->insertSpacing ( 2, 5 ); |
183 | layout->addWidget ( defaults ); | 183 | layout->addWidget ( defaults ); |
184 | 184 | ||
185 | connect ( currencysupport, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeCurrencySupport ( bool ) ) ); | 185 | connect ( currencysupport, SIGNAL ( toggled(bool) ), this, SLOT ( changeCurrencySupport(bool) ) ); |
186 | connect ( onetouch, SIGNAL ( toggled ( bool ) ), this, SLOT ( changeOneTouchViewing ( bool ) ) ); | 186 | connect ( onetouch, SIGNAL ( toggled(bool) ), this, SLOT ( changeOneTouchViewing(bool) ) ); |
187 | } | 187 | } |
188 | 188 | ||
189 | AccountPreferences::~AccountPreferences () | 189 | AccountPreferences::~AccountPreferences () |
190 | { | 190 | { |
191 | } | 191 | } |
192 | 192 | ||
193 | void AccountPreferences::changeCurrencySupport ( bool state ) | 193 | void AccountPreferences::changeCurrencySupport ( bool state ) |
194 | { | 194 | { |
195 | if ( state == TRUE ) | 195 | if ( state == TRUE ) |
196 | preferences->changePreference ( 4, 1 ); | 196 | preferences->changePreference ( 4, 1 ); |
197 | else | 197 | else |
198 | preferences->changePreference ( 4, 0 ); | 198 | preferences->changePreference ( 4, 0 ); |
199 | } | 199 | } |
200 | 200 | ||
201 | void AccountPreferences::changeOneTouchViewing ( bool state ) | 201 | void AccountPreferences::changeOneTouchViewing ( bool state ) |
202 | { | 202 | { |
203 | if ( state == TRUE ) | 203 | if ( state == TRUE ) |
204 | preferences->changePreference ( 5, 1 ); | 204 | preferences->changePreference ( 5, 1 ); |
205 | else | 205 | else |
206 | preferences->changePreference ( 5, 0 ); | 206 | preferences->changePreference ( 5, 0 ); |
207 | } | 207 | } |
208 | 208 | ||
209 | void AccountPreferences::setDefaultAccountPreferences () | 209 | void AccountPreferences::setDefaultAccountPreferences () |
210 | { | 210 | { |
211 | preferences->changePreference ( 4, 0 ); | 211 | preferences->changePreference ( 4, 0 ); |
212 | preferences->changePreference ( 5, 0 ); | 212 | preferences->changePreference ( 5, 0 ); |
213 | currencysupport->setChecked ( FALSE ); | 213 | currencysupport->setChecked ( FALSE ); |
214 | onetouch->setChecked ( FALSE ); | 214 | onetouch->setChecked ( FALSE ); |
215 | } | 215 | } |
216 | 216 | ||
diff --git a/noncore/apps/qashmoney/qashmoney.cpp b/noncore/apps/qashmoney/qashmoney.cpp index d4cbc14..1455eb0 100755 --- a/noncore/apps/qashmoney/qashmoney.cpp +++ b/noncore/apps/qashmoney/qashmoney.cpp | |||
@@ -1,166 +1,166 @@ | |||
1 | #include "qashmoney.h" | 1 | #include "qashmoney.h" |
2 | #include "preferencedialogs.h" | 2 | #include "preferencedialogs.h" |
3 | #include "memorydialog.h" | 3 | #include "memorydialog.h" |
4 | 4 | ||
5 | #include <qheader.h> | 5 | #include <qheader.h> |
6 | 6 | ||
7 | Budget *budget = new Budget (); | 7 | Budget *budget = new Budget (); |
8 | Preferences *preferences = new Preferences (); | 8 | Preferences *preferences = new Preferences (); |
9 | Account *account = new Account (); | 9 | Account *account = new Account (); |
10 | Transaction *transaction = new Transaction (); | 10 | Transaction *transaction = new Transaction (); |
11 | Transfer *transfer = new Transfer (); | 11 | Transfer *transfer = new Transfer (); |
12 | Memory *memory = new Memory (); | 12 | Memory *memory = new Memory (); |
13 | 13 | ||
14 | QashMoney::QashMoney () : QWidget () | 14 | QashMoney::QashMoney () : QWidget () |
15 | { | 15 | { |
16 | preferences->addPreferences (); | 16 | preferences->addPreferences (); |
17 | preferences->initializeColumnPreferences (); | 17 | preferences->initializeColumnPreferences (); |
18 | preferences->initializeSortingPreferences (); | 18 | preferences->initializeSortingPreferences (); |
19 | 19 | ||
20 | // set the text in the upper part of the frame | 20 | // set the text in the upper part of the frame |
21 | setCaption ( tr ( "QashMoney" ) ); | 21 | setCaption ( tr ( "QashMoney" ) ); |
22 | 22 | ||
23 | // Create new menubar for our mainwindow | 23 | // Create new menubar for our mainwindow |
24 | // and add menu items | 24 | // and add menu items |
25 | mainmenu = new QMenuBar ( this ); | 25 | mainmenu = new QMenuBar ( this ); |
26 | mainmenu->setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); | 26 | mainmenu->setFrameStyle ( QFrame::PopupPanel | QFrame::Raised ); |
27 | preferencesmenu = new QPopupMenu ( this ); | 27 | preferencesmenu = new QPopupMenu ( this ); |
28 | utilitiesmenu = new QPopupMenu ( this ); | 28 | utilitiesmenu = new QPopupMenu ( this ); |
29 | mainmenu->insertItem ( "Preferences", preferencesmenu ); | 29 | mainmenu->insertItem ( "Preferences", preferencesmenu ); |
30 | mainmenu->insertItem ( "Utilities", utilitiesmenu ); | 30 | mainmenu->insertItem ( "Utilities", utilitiesmenu ); |
31 | preferencesmenu->insertItem ( "Date", this, SLOT ( displayDatePreferencesDialog () ) ); | 31 | preferencesmenu->insertItem ( "Date", this, SLOT ( displayDatePreferencesDialog() ) ); |
32 | preferencesmenu->insertItem ( "Account", this, SLOT ( displayAccountPreferencesDialog () ) ); | 32 | preferencesmenu->insertItem ( "Account", this, SLOT ( displayAccountPreferencesDialog() ) ); |
33 | preferencesmenu->insertItem ( "Transaction", this, SLOT ( displayTransactionPreferencesDialog () ) ); | 33 | preferencesmenu->insertItem ( "Transaction", this, SLOT ( displayTransactionPreferencesDialog() ) ); |
34 | utilitiesmenu->insertItem ( "Memory", this, SLOT ( displayMemoryDialog () ) ); | 34 | utilitiesmenu->insertItem ( "Memory", this, SLOT ( displayMemoryDialog() ) ); |
35 | 35 | ||
36 | // create the main tabwidget for displaying accounts and transactions | 36 | // create the main tabwidget for displaying accounts and transactions |
37 | maintabs = new QTabWidget ( this ); | 37 | maintabs = new QTabWidget ( this ); |
38 | tab = new QWidget ( this ); | 38 | tab = new QWidget ( this ); |
39 | tab_2 = new QWidget ( this ); | 39 | tab_2 = new QWidget ( this ); |
40 | tab_3 = new QWidget ( this ); | 40 | tab_3 = new QWidget ( this ); |
41 | maintabs->addTab ( tab, "Accounts" ); | 41 | maintabs->addTab ( tab, "Accounts" ); |
42 | maintabs->addTab ( tab_2, "Transactions" ); | 42 | maintabs->addTab ( tab_2, "Transactions" ); |
43 | maintabs->addTab ( tab_3, "Budgets" ); | 43 | maintabs->addTab ( tab_3, "Budgets" ); |
44 | tabheight = tab->height(); | 44 | tabheight = tab->height(); |
45 | maintabs->setTabEnabled ( tab_2, FALSE ); | 45 | maintabs->setTabEnabled ( tab_2, FALSE ); |
46 | 46 | ||
47 | // create a new account display object | 47 | // create a new account display object |
48 | accountdisplay = new AccountDisplay ( maintabs ); | 48 | accountdisplay = new AccountDisplay ( maintabs ); |
49 | accountdisplay->setTabs ( tab_2, maintabs ); | 49 | accountdisplay->setTabs ( tab_2, maintabs ); |
50 | connect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( setTransactionTab () ) ); | 50 | connect ( accountdisplay->listview, SIGNAL ( selectionChanged() ), this, SLOT ( setTransactionTab() ) ); |
51 | 51 | ||
52 | // set the connection to disable the one touch account viewing if we are transfering money | 52 | // set the connection to disable the one touch account viewing if we are transfering money |
53 | connect ( accountdisplay->transferbutton, SIGNAL ( toggled ( bool ) ), this, SLOT ( toggleOneTouchViewing ( bool ) ) ); | 53 | connect ( accountdisplay->transferbutton, SIGNAL ( toggled(bool) ), this, SLOT ( toggleOneTouchViewing(bool) ) ); |
54 | 54 | ||
55 | // create a new transactiondisplay object | 55 | // create a new transactiondisplay object |
56 | transactiondisplay = new TransactionDisplay ( maintabs ); | 56 | transactiondisplay = new TransactionDisplay ( maintabs ); |
57 | transactiondisplay->hide(); | 57 | transactiondisplay->hide(); |
58 | 58 | ||
59 | // create new budgetdisplay object | 59 | // create new budgetdisplay object |
60 | budgetdisplay = new BudgetDisplay ( maintabs ); | 60 | budgetdisplay = new BudgetDisplay ( maintabs ); |
61 | budgetdisplay->hide(); | 61 | budgetdisplay->hide(); |
62 | 62 | ||
63 | tabslayout = new QVBoxLayout ( maintabs, 4, 2 ); | 63 | tabslayout = new QVBoxLayout ( maintabs, 4, 2 ); |
64 | tabslayout->addSpacing ( tabheight ); | 64 | tabslayout->addSpacing ( tabheight ); |
65 | tabslayout->addWidget ( accountdisplay ); | 65 | tabslayout->addWidget ( accountdisplay ); |
66 | tabslayout->addWidget ( transactiondisplay ); | 66 | tabslayout->addWidget ( transactiondisplay ); |
67 | tabslayout->addWidget ( budgetdisplay ); | 67 | tabslayout->addWidget ( budgetdisplay ); |
68 | 68 | ||
69 | // connect a change in the maintabs with changing the tab display | 69 | // connect a change in the maintabs with changing the tab display |
70 | connect ( maintabs, SIGNAL ( currentChanged ( QWidget * ) ), this, SLOT ( changeTabDisplay () ) ); | 70 | connect ( maintabs, SIGNAL ( currentChanged(QWidget*) ), this, SLOT ( changeTabDisplay() ) ); |
71 | 71 | ||
72 | // create layout that will contain the menubar and the maintabs | 72 | // create layout that will contain the menubar and the maintabs |
73 | layout = new QVBoxLayout ( this, 2, 2 ); | 73 | layout = new QVBoxLayout ( this, 2, 2 ); |
74 | layout->setMenuBar ( mainmenu ); | 74 | layout->setMenuBar ( mainmenu ); |
75 | layout->addWidget ( maintabs ); | 75 | layout->addWidget ( maintabs ); |
76 | } | 76 | } |
77 | 77 | ||
78 | QashMoney::~QashMoney () | 78 | QashMoney::~QashMoney () |
79 | { | 79 | { |
80 | delete budget; | 80 | delete budget; |
81 | delete preferences; | 81 | delete preferences; |
82 | delete account; | 82 | delete account; |
83 | delete transaction; | 83 | delete transaction; |
84 | delete transfer; | 84 | delete transfer; |
85 | delete memory; | 85 | delete memory; |
86 | } | 86 | } |
87 | 87 | ||
88 | void QashMoney::changeTabDisplay () | 88 | void QashMoney::changeTabDisplay () |
89 | { | 89 | { |
90 | // if the user pressed the transactions tab, hide the account display | 90 | // if the user pressed the transactions tab, hide the account display |
91 | // object and create a new transaction display | 91 | // object and create a new transaction display |
92 | if ( maintabs->currentPageIndex() == 1 ) | 92 | if ( maintabs->currentPageIndex() == 1 ) |
93 | { | 93 | { |
94 | // initialize variables | 94 | // initialize variables |
95 | bool children = FALSE; | 95 | bool children = FALSE; |
96 | 96 | ||
97 | // hide the account display and define accountid | 97 | // hide the account display and define accountid |
98 | int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); | 98 | int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); |
99 | 99 | ||
100 | //remove all the columns from the transactiondisplay | 100 | //remove all the columns from the transactiondisplay |
101 | int columns = transactiondisplay->listview->columns(); | 101 | int columns = transactiondisplay->listview->columns(); |
102 | int counter; | 102 | int counter; |
103 | for ( counter = 0; counter <= columns; counter++ ) | 103 | for ( counter = 0; counter <= columns; counter++ ) |
104 | transactiondisplay->listview->removeColumn ( 0 ); | 104 | transactiondisplay->listview->removeColumn ( 0 ); |
105 | 105 | ||
106 | // set the account name and account balance | 106 | // set the account name and account balance |
107 | QString name = account->getAccountName ( accountid ); | 107 | QString name = account->getAccountName ( accountid ); |
108 | QString balance = account->getAccountBalance ( accountid ); | 108 | QString balance = account->getAccountBalance ( accountid ); |
109 | transactiondisplay->name->setText ( name ); | 109 | transactiondisplay->name->setText ( name ); |
110 | transactiondisplay->balance->setText ( balance ); | 110 | transactiondisplay->balance->setText ( balance ); |
111 | 111 | ||
112 | // clear the limitbox | 112 | // clear the limitbox |
113 | transactiondisplay->limitbox->clear(); | 113 | transactiondisplay->limitbox->clear(); |
114 | 114 | ||
115 | // get parent account id | 115 | // get parent account id |
116 | int parentaccountid = account->getParentAccountID ( accountid ); | 116 | int parentaccountid = account->getParentAccountID ( accountid ); |
117 | 117 | ||
118 | // add columns based on which account is selected | 118 | // add columns based on which account is selected |
119 | // this first if determines if we selected a parent with no children or a child | 119 | // this first if determines if we selected a parent with no children or a child |
120 | // in these cases, we add standard three columns for date, transaction, amount | 120 | // in these cases, we add standard three columns for date, transaction, amount |
121 | transactiondisplay->listview->addColumn ( "Date", 0 ); | 121 | transactiondisplay->listview->addColumn ( "Date", 0 ); |
122 | transactiondisplay->listview->addColumn ( "Transaction", 0 ); | 122 | transactiondisplay->listview->addColumn ( "Transaction", 0 ); |
123 | transactiondisplay->listview->addColumn ( "Amt", 0); | 123 | transactiondisplay->listview->addColumn ( "Amt", 0); |
124 | transactiondisplay->listview->setColumnAlignment ( 2, Qt::AlignRight ); | 124 | transactiondisplay->listview->setColumnAlignment ( 2, Qt::AlignRight ); |
125 | transactiondisplay->listview->addColumn ( "", 0 ); | 125 | transactiondisplay->listview->addColumn ( "", 0 ); |
126 | 126 | ||
127 | if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) // we selected a parent with children | 127 | if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) // we selected a parent with children |
128 | { | 128 | { |
129 | // add an extra column for the account name for eac child transaction | 129 | // add an extra column for the account name for eac child transaction |
130 | transactiondisplay->listview->addColumn ( "Acct", 0 ); | 130 | transactiondisplay->listview->addColumn ( "Acct", 0 ); |
131 | children = TRUE; | 131 | children = TRUE; |
132 | 132 | ||
133 | // hide the new transaction button | 133 | // hide the new transaction button |
134 | transactiondisplay->newtransaction->setEnabled ( FALSE ); | 134 | transactiondisplay->newtransaction->setEnabled ( FALSE ); |
135 | } | 135 | } |
136 | else //we selected a parent without children or a child | 136 | else //we selected a parent without children or a child |
137 | transactiondisplay->newtransaction->setEnabled ( TRUE ); | 137 | transactiondisplay->newtransaction->setEnabled ( TRUE ); |
138 | 138 | ||
139 | // disable the transactionid column so it can't be red | 139 | // disable the transactionid column so it can't be red |
140 | transactiondisplay->listview->header()->setResizeEnabled ( FALSE, 3 ); | 140 | transactiondisplay->listview->header()->setResizeEnabled ( FALSE, 3 ); |
141 | 141 | ||
142 | // set the accountid and children variables | 142 | // set the accountid and children variables |
143 | transactiondisplay->setChildren ( children ); | 143 | transactiondisplay->setChildren ( children ); |
144 | transactiondisplay->setAccountID ( accountid ); | 144 | transactiondisplay->setAccountID ( accountid ); |
145 | 145 | ||
146 | setTransactionDisplayDate (); | 146 | setTransactionDisplayDate (); |
147 | 147 | ||
148 | // display transactions | 148 | // display transactions |
149 | transactiondisplay->listview->clear(); | 149 | transactiondisplay->listview->clear(); |
150 | QString displaytext = "%"; | 150 | QString displaytext = "%"; |
151 | displaytext.prepend ( transactiondisplay->limitbox->text() ); | 151 | displaytext.prepend ( transactiondisplay->limitbox->text() ); |
152 | if ( transaction->getNumberOfTransactions() > 0 ) | 152 | if ( transaction->getNumberOfTransactions() > 0 ) |
153 | transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate ); | 153 | transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate ); |
154 | 154 | ||
155 | // display transfers | 155 | // display transfers |
156 | transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate ); | 156 | transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate ); |
157 | 157 | ||
158 | // open a new preferences object and resize the transaction display columns | 158 | // open a new preferences object and resize the transaction display columns |
159 | // each column will have a different size based on whether we are looking at a child | 159 | // each column will have a different size based on whether we are looking at a child |
160 | // account or children through a parent | 160 | // account or children through a parent |
161 | if ( parentaccountid != -1 || accountdisplay->listview->selectedItem()->childCount() == 0 ) // a parent with no children or a child - three columns | 161 | if ( parentaccountid != -1 || accountdisplay->listview->selectedItem()->childCount() == 0 ) // a parent with no children or a child - three columns |
162 | { | 162 | { |
163 | transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 3 ) ); // normal transaction date width | 163 | transactiondisplay->listview->setColumnWidth ( 0, preferences->getColumnPreference ( 3 ) ); // normal transaction date width |
164 | transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual ); | 164 | transactiondisplay->listview->setColumnWidthMode ( 0, QListView::Manual ); |
165 | transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 4 ) ); // normal transaction name width | 165 | transactiondisplay->listview->setColumnWidth ( 1, preferences->getColumnPreference ( 4 ) ); // normal transaction name width |
166 | transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual ); | 166 | transactiondisplay->listview->setColumnWidthMode ( 1, QListView::Manual ); |
@@ -259,144 +259,144 @@ void QashMoney::displayDatePreferencesDialog () | |||
259 | // set children so we can let displayTransfers know if there are children for the selected account | 259 | // set children so we can let displayTransfers know if there are children for the selected account |
260 | bool children; | 260 | bool children; |
261 | if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) | 261 | if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) |
262 | children = TRUE; | 262 | children = TRUE; |
263 | else | 263 | else |
264 | children = FALSE; | 264 | children = FALSE; |
265 | 265 | ||
266 | // redisplay transactions if they are visible incorporating | 266 | // redisplay transactions if they are visible incorporating |
267 | // any changes to the date format | 267 | // any changes to the date format |
268 | transactiondisplay->listview->clear(); | 268 | transactiondisplay->listview->clear(); |
269 | QString displaytext = "%"; | 269 | QString displaytext = "%"; |
270 | displaytext.prepend ( transactiondisplay->limitbox->text() ); | 270 | displaytext.prepend ( transactiondisplay->limitbox->text() ); |
271 | 271 | ||
272 | setTransactionDisplayDate(); | 272 | setTransactionDisplayDate(); |
273 | if ( transaction->getNumberOfTransactions() > 0 ) | 273 | if ( transaction->getNumberOfTransactions() > 0 ) |
274 | transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate ); | 274 | transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate ); |
275 | 275 | ||
276 | if ( transfer->getNumberOfTransfers() != 0 ) | 276 | if ( transfer->getNumberOfTransfers() != 0 ) |
277 | transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate ); | 277 | transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate ); |
278 | } | 278 | } |
279 | else if ( accountdisplay->isVisible() ) | 279 | else if ( accountdisplay->isVisible() ) |
280 | { | 280 | { |
281 | accountdisplay->listview->clearSelection(); | 281 | accountdisplay->listview->clearSelection(); |
282 | maintabs->setTabEnabled ( tab_2, FALSE ); | 282 | maintabs->setTabEnabled ( tab_2, FALSE ); |
283 | } | 283 | } |
284 | else | 284 | else |
285 | budgetdisplay->updateBudgetInformation(); | 285 | budgetdisplay->updateBudgetInformation(); |
286 | } | 286 | } |
287 | 287 | ||
288 | void QashMoney::displayTransactionPreferencesDialog () | 288 | void QashMoney::displayTransactionPreferencesDialog () |
289 | { | 289 | { |
290 | // display a dialog for setting preferences for transactions | 290 | // display a dialog for setting preferences for transactions |
291 | TransactionPreferences *td = new TransactionPreferences ( this ); | 291 | TransactionPreferences *td = new TransactionPreferences ( this ); |
292 | td->exec (); | 292 | td->exec (); |
293 | if ( transactiondisplay->isVisible() ) | 293 | if ( transactiondisplay->isVisible() ) |
294 | { | 294 | { |
295 | // set the account id | 295 | // set the account id |
296 | int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); | 296 | int accountid = accountdisplay->listview->selectedItem()->text ( accountdisplay->getIDColumn() ).toInt(); |
297 | 297 | ||
298 | // set children so we can let displayTransfers know if there are children for the selected account | 298 | // set children so we can let displayTransfers know if there are children for the selected account |
299 | bool children; | 299 | bool children; |
300 | if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) | 300 | if ( accountdisplay->listview->selectedItem()->parent() == 0 && accountdisplay->listview->selectedItem()->childCount() != 0 ) |
301 | children = TRUE; | 301 | children = TRUE; |
302 | else | 302 | else |
303 | children = FALSE; | 303 | children = FALSE; |
304 | 304 | ||
305 | // redisplay transactions incorporating any transaction preference changes | 305 | // redisplay transactions incorporating any transaction preference changes |
306 | transactiondisplay->listview->clear(); | 306 | transactiondisplay->listview->clear(); |
307 | QString displaytext = "%"; | 307 | QString displaytext = "%"; |
308 | displaytext.prepend ( transactiondisplay->limitbox->text() ); | 308 | displaytext.prepend ( transactiondisplay->limitbox->text() ); |
309 | 309 | ||
310 | setTransactionDisplayDate(); | 310 | setTransactionDisplayDate(); |
311 | if ( transaction->getNumberOfTransactions() > 0 ) | 311 | if ( transaction->getNumberOfTransactions() > 0 ) |
312 | transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate ); | 312 | transaction->displayTransactions ( transactiondisplay->listview, accountid, children, displaytext, newdate ); |
313 | 313 | ||
314 | if ( transfer->getNumberOfTransfers() != 0 ) | 314 | if ( transfer->getNumberOfTransfers() != 0 ) |
315 | transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate ); | 315 | transfer->displayTransfers ( transactiondisplay->listview, accountid, children, newdate ); |
316 | } | 316 | } |
317 | else | 317 | else |
318 | { | 318 | { |
319 | accountdisplay->listview->clearSelection(); | 319 | accountdisplay->listview->clearSelection(); |
320 | maintabs->setTabEnabled ( tab_2, FALSE ); | 320 | maintabs->setTabEnabled ( tab_2, FALSE ); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | void QashMoney::displayAccountPreferencesDialog () | 324 | void QashMoney::displayAccountPreferencesDialog () |
325 | { | 325 | { |
326 | // display a dialog for setting preferences for accounts | 326 | // display a dialog for setting preferences for accounts |
327 | AccountPreferences *ap = new AccountPreferences ( this ); | 327 | AccountPreferences *ap = new AccountPreferences ( this ); |
328 | ap->exec (); | 328 | ap->exec (); |
329 | 329 | ||
330 | if ( accountdisplay->isVisible() && account->getNumberOfAccounts() != 0 ) | 330 | if ( accountdisplay->isVisible() && account->getNumberOfAccounts() != 0 ) |
331 | { | 331 | { |
332 | accountdisplay->listview->clear(); | 332 | accountdisplay->listview->clear(); |
333 | account->displayAccounts ( accountdisplay->listview ); | 333 | account->displayAccounts ( accountdisplay->listview ); |
334 | accountdisplay->listview->clearSelection(); | 334 | accountdisplay->listview->clearSelection(); |
335 | maintabs->setTabEnabled ( tab_2, FALSE ); | 335 | maintabs->setTabEnabled ( tab_2, FALSE ); |
336 | } | 336 | } |
337 | changeTabDisplay(); | 337 | changeTabDisplay(); |
338 | } | 338 | } |
339 | 339 | ||
340 | void QashMoney::displayMemoryDialog () | 340 | void QashMoney::displayMemoryDialog () |
341 | { | 341 | { |
342 | // opens a dialog to add, edit and delete memory items | 342 | // opens a dialog to add, edit and delete memory items |
343 | MemoryDialog *md = new MemoryDialog (); | 343 | MemoryDialog *md = new MemoryDialog (); |
344 | md->exec(); | 344 | md->exec(); |
345 | } | 345 | } |
346 | 346 | ||
347 | void QashMoney::showTransactions () | 347 | void QashMoney::showTransactions () |
348 | { | 348 | { |
349 | maintabs->setCurrentPage ( 1 ); | 349 | maintabs->setCurrentPage ( 1 ); |
350 | } | 350 | } |
351 | 351 | ||
352 | void QashMoney::enableOneTouchViewing () | 352 | void QashMoney::enableOneTouchViewing () |
353 | { | 353 | { |
354 | if ( preferences->getPreference ( 5 ) == 1 ) | 354 | if ( preferences->getPreference ( 5 ) == 1 ) |
355 | connect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) ); | 355 | connect ( accountdisplay->listview, SIGNAL ( selectionChanged() ), this, SLOT ( showTransactions() ) ); |
356 | else | 356 | else |
357 | disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) ); | 357 | disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged() ), this, SLOT ( showTransactions() ) ); |
358 | } | 358 | } |
359 | 359 | ||
360 | void QashMoney::disableOneTouchViewing () | 360 | void QashMoney::disableOneTouchViewing () |
361 | { | 361 | { |
362 | disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged () ), this, SLOT ( showTransactions () ) ); | 362 | disconnect ( accountdisplay->listview, SIGNAL ( selectionChanged() ), this, SLOT ( showTransactions() ) ); |
363 | } | 363 | } |
364 | 364 | ||
365 | void QashMoney::toggleOneTouchViewing ( bool state ) | 365 | void QashMoney::toggleOneTouchViewing ( bool state ) |
366 | { | 366 | { |
367 | if ( state == TRUE ) | 367 | if ( state == TRUE ) |
368 | disableOneTouchViewing(); | 368 | disableOneTouchViewing(); |
369 | else | 369 | else |
370 | enableOneTouchViewing(); | 370 | enableOneTouchViewing(); |
371 | } | 371 | } |
372 | 372 | ||
373 | void QashMoney::setTransactionDisplayDate () | 373 | void QashMoney::setTransactionDisplayDate () |
374 | { | 374 | { |
375 | // determine how many days of transactions to show | 375 | // determine how many days of transactions to show |
376 | int limittype = preferences->getPreference ( 7 ); | 376 | int limittype = preferences->getPreference ( 7 ); |
377 | if ( limittype != 5 ) // set today's date if we are not showing all transactions | 377 | if ( limittype != 5 ) // set today's date if we are not showing all transactions |
378 | { | 378 | { |
379 | QDate today = QDate::currentDate (); | 379 | QDate today = QDate::currentDate (); |
380 | switch ( limittype ) // if we are not showing all transactions | 380 | switch ( limittype ) // if we are not showing all transactions |
381 | { | 381 | { |
382 | case 0: // viewing two weeks | 382 | case 0: // viewing two weeks |
383 | newdate = today.addDays ( -14 ); | 383 | newdate = today.addDays ( -14 ); |
384 | break; | 384 | break; |
385 | case 1: // viewing one month | 385 | case 1: // viewing one month |
386 | newdate = today.addDays ( -30 ); | 386 | newdate = today.addDays ( -30 ); |
387 | break; | 387 | break; |
388 | case 2: // three months | 388 | case 2: // three months |
389 | newdate = today.addDays ( -90 ); | 389 | newdate = today.addDays ( -90 ); |
390 | break; | 390 | break; |
391 | case 3: // six months | 391 | case 3: // six months |
392 | newdate = today.addDays ( -180 ); | 392 | newdate = today.addDays ( -180 ); |
393 | break; | 393 | break; |
394 | case 4: // one year | 394 | case 4: // one year |
395 | newdate = today.addDays ( -365 ); | 395 | newdate = today.addDays ( -365 ); |
396 | break; | 396 | break; |
397 | } | 397 | } |
398 | } | 398 | } |
399 | else | 399 | else |
400 | newdate = QDate ( 1900, 1, 1 ); | 400 | newdate = QDate ( 1900, 1, 1 ); |
401 | } | 401 | } |
402 | 402 | ||
diff --git a/noncore/apps/qashmoney/transactiondisplay.cpp b/noncore/apps/qashmoney/transactiondisplay.cpp index 474f11e..0b94d62 100755 --- a/noncore/apps/qashmoney/transactiondisplay.cpp +++ b/noncore/apps/qashmoney/transactiondisplay.cpp | |||
@@ -1,312 +1,312 @@ | |||
1 | #include "transactiondisplay.h" | 1 | #include "transactiondisplay.h" |
2 | #include "newtransaction.h" | 2 | #include "newtransaction.h" |
3 | #include "account.h" | 3 | #include "account.h" |
4 | #include "budget.h" | 4 | #include "budget.h" |
5 | #include "memory.h" | 5 | #include "memory.h" |
6 | #include "transfer.h" | 6 | #include "transfer.h" |
7 | #include "calculator.h" | 7 | #include "calculator.h" |
8 | #include "datepicker.h" | 8 | #include "datepicker.h" |
9 | 9 | ||
10 | #include <qmessagebox.h> | 10 | #include <qmessagebox.h> |
11 | #include <qheader.h> | 11 | #include <qheader.h> |
12 | #include <qmultilineedit.h> | 12 | #include <qmultilineedit.h> |
13 | 13 | ||
14 | extern Transaction *transaction; | 14 | extern Transaction *transaction; |
15 | extern Budget *budget; | 15 | extern Budget *budget; |
16 | extern Account *account; | 16 | extern Account *account; |
17 | extern Preferences *preferences; | 17 | extern Preferences *preferences; |
18 | extern Memory *memory; | 18 | extern Memory *memory; |
19 | extern Transfer *transfer; | 19 | extern Transfer *transfer; |
20 | 20 | ||
21 | TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent ) | 21 | TransactionDisplay::TransactionDisplay ( QWidget* parent ) : QWidget ( parent ) |
22 | { | 22 | { |
23 | // set transactiondisplay variables; | 23 | // set transactiondisplay variables; |
24 | accountid = 0; | 24 | accountid = 0; |
25 | children = TRUE; | 25 | children = TRUE; |
26 | 26 | ||
27 | firstline = new QHBox ( this ); | 27 | firstline = new QHBox ( this ); |
28 | firstline->setSpacing ( 2 ); | 28 | firstline->setSpacing ( 2 ); |
29 | 29 | ||
30 | newtransaction = new QPushButton ( firstline ); | 30 | newtransaction = new QPushButton ( firstline ); |
31 | newtransaction->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") ); | 31 | newtransaction->setPixmap ( QPixmap ("/opt/QtPalmtop/pics/new.png") ); |
32 | connect ( newtransaction, SIGNAL ( released () ), this, SLOT ( addTransaction () ) ); | 32 | connect ( newtransaction, SIGNAL ( released() ), this, SLOT ( addTransaction() ) ); |
33 | 33 | ||
34 | edittransaction = new QPushButton ( firstline ); | 34 | edittransaction = new QPushButton ( firstline ); |
35 | edittransaction->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); | 35 | edittransaction->setPixmap( QPixmap ("/opt/QtPalmtop/pics/edit.png") ); |
36 | connect ( edittransaction, SIGNAL ( released () ), this, SLOT ( checkListViewEdit () ) ); | 36 | connect ( edittransaction, SIGNAL ( released() ), this, SLOT ( checkListViewEdit() ) ); |
37 | 37 | ||
38 | deletetransaction = new QPushButton ( firstline ); | 38 | deletetransaction = new QPushButton ( firstline ); |
39 | deletetransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") ); | 39 | deletetransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/delete.png") ); |
40 | connect ( deletetransaction, SIGNAL ( released () ), this, SLOT ( checkListViewDelete () ) ); | 40 | connect ( deletetransaction, SIGNAL ( released() ), this, SLOT ( checkListViewDelete() ) ); |
41 | 41 | ||
42 | toggletransaction = new QPushButton ( firstline ); | 42 | toggletransaction = new QPushButton ( firstline ); |
43 | toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") ); | 43 | toggletransaction->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/redo.png") ); |
44 | connect ( toggletransaction, SIGNAL ( released () ), this, SLOT ( checkListViewToggle () ) ); | 44 | connect ( toggletransaction, SIGNAL ( released() ), this, SLOT ( checkListViewToggle() ) ); |
45 | 45 | ||
46 | viewtransactionnotes = new QPushButton ( firstline ); | 46 | viewtransactionnotes = new QPushButton ( firstline ); |
47 | viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") ); | 47 | viewtransactionnotes->setPixmap( QPixmap ( "/opt/QtPalmtop/pics/info.png") ); |
48 | connect ( viewtransactionnotes, SIGNAL ( released () ), this, SLOT ( showTransactionNotes () ) ); | 48 | connect ( viewtransactionnotes, SIGNAL ( released() ), this, SLOT ( showTransactionNotes() ) ); |
49 | 49 | ||
50 | secondline = new QHBox ( this ); | 50 | secondline = new QHBox ( this ); |
51 | secondline->setSpacing ( 5 ); | 51 | secondline->setSpacing ( 5 ); |
52 | 52 | ||
53 | name = new QLabel ( secondline ); | 53 | name = new QLabel ( secondline ); |
54 | balance = new QLabel ( secondline ); | 54 | balance = new QLabel ( secondline ); |
55 | 55 | ||
56 | QLabel *limit = new QLabel ( "Limit", secondline ); | 56 | QLabel *limit = new QLabel ( "Limit", secondline ); |
57 | limitbox = new QLineEdit ( secondline ); | 57 | limitbox = new QLineEdit ( secondline ); |
58 | limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) ); | 58 | limitbox->setMinimumWidth ( ( int ) ( this->width() / 6 ) ); |
59 | connect ( limitbox, SIGNAL ( textChanged ( const QString & ) ), this, SLOT ( limitDisplay ( const QString & ) ) ); | 59 | connect ( limitbox, SIGNAL ( textChanged(const QString&) ), this, SLOT ( limitDisplay(const QString&) ) ); |
60 | 60 | ||
61 | listview = new QListView ( this ); | 61 | listview = new QListView ( this ); |
62 | listview->setAllColumnsShowFocus ( TRUE ); | 62 | listview->setAllColumnsShowFocus ( TRUE ); |
63 | listview->setShowSortIndicator ( TRUE ); | 63 | listview->setShowSortIndicator ( TRUE ); |
64 | listview->header()->setTracking ( FALSE ); | 64 | listview->header()->setTracking ( FALSE ); |
65 | connect ( listview->header(), SIGNAL ( sizeChange ( int, int, int ) ), this, SLOT ( saveColumnSize ( int, int, int ) ) ); | 65 | connect ( listview->header(), SIGNAL ( sizeChange(int,int,int) ), this, SLOT ( saveColumnSize(int,int,int) ) ); |
66 | connect ( listview->header(), SIGNAL ( clicked ( int ) ), this, SLOT ( saveSortingPreference ( int ) ) ); | 66 | connect ( listview->header(), SIGNAL ( clicked(int) ), this, SLOT ( saveSortingPreference(int) ) ); |
67 | 67 | ||
68 | layout = new QVBoxLayout ( this, 2, 2 ); | 68 | layout = new QVBoxLayout ( this, 2, 2 ); |
69 | layout->addWidget ( firstline ); | 69 | layout->addWidget ( firstline ); |
70 | layout->addWidget ( secondline ); | 70 | layout->addWidget ( secondline ); |
71 | layout->addWidget ( listview ); | 71 | layout->addWidget ( listview ); |
72 | } | 72 | } |
73 | 73 | ||
74 | void TransactionDisplay::addTransaction () | 74 | void TransactionDisplay::addTransaction () |
75 | { | 75 | { |
76 | // create local variables | 76 | // create local variables |
77 | int cleared = -1; | 77 | int cleared = -1; |
78 | 78 | ||
79 | // create new transaction window | 79 | // create new transaction window |
80 | NewTransaction *newtransaction = new NewTransaction ( this ); | 80 | NewTransaction *newtransaction = new NewTransaction ( this ); |
81 | int width = this->size().width(); | 81 | int width = this->size().width(); |
82 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 82 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
83 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); | 83 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); |
84 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 84 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
85 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 85 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
86 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 86 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
87 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); | 87 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); |
88 | 88 | ||
89 | // enter today's date in the date box as defaul | 89 | // enter today's date in the date box as defaul |
90 | QDate today = QDate::currentDate (); | 90 | QDate today = QDate::currentDate (); |
91 | int defaultday = today.day(); | 91 | int defaultday = today.day(); |
92 | int defaultmonth = today.month(); | 92 | int defaultmonth = today.month(); |
93 | int defaultyear = today.year(); | 93 | int defaultyear = today.year(); |
94 | newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); | 94 | newtransaction->transactiondate->setText ( preferences->getDate ( defaultyear, defaultmonth, defaultday ) ); |
95 | 95 | ||
96 | // add memory items to the transactionname combobox | 96 | // add memory items to the transactionname combobox |
97 | memory->displayMemoryItems ( newtransaction->transactionname ); | 97 | memory->displayMemoryItems ( newtransaction->transactionname ); |
98 | newtransaction->transactionname->insertItem ( "", 0 ); | 98 | newtransaction->transactionname->insertItem ( "", 0 ); |
99 | 99 | ||
100 | if ( newtransaction->exec () == QDialog::Accepted ) | 100 | if ( newtransaction->exec () == QDialog::Accepted ) |
101 | { | 101 | { |
102 | if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction | 102 | if ( newtransaction->clearedcheckbox->isChecked () == TRUE ) // set a parent id and type for a child transaction |
103 | cleared = 1; | 103 | cleared = 1; |
104 | else | 104 | else |
105 | cleared = 0; | 105 | cleared = 0; |
106 | 106 | ||
107 | float amount = newtransaction->transactionamount->text().toFloat(); | 107 | float amount = newtransaction->transactionamount->text().toFloat(); |
108 | if ( newtransaction->depositbox->isChecked() == FALSE ) | 108 | if ( newtransaction->depositbox->isChecked() == FALSE ) |
109 | amount = amount * -1; | 109 | amount = amount * -1; |
110 | 110 | ||
111 | // add the transaction name to the memory items | 111 | // add the transaction name to the memory items |
112 | memory->addMemoryItem ( newtransaction->transactionname->currentText() ); | 112 | memory->addMemoryItem ( newtransaction->transactionname->currentText() ); |
113 | 113 | ||
114 | // add the transaction | 114 | // add the transaction |
115 | if ( newtransaction->getDateEdited () == TRUE ) | 115 | if ( newtransaction->getDateEdited () == TRUE ) |
116 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), | 116 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), |
117 | newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(), | 117 | newtransaction->transactionnumber->text().toInt(), newtransaction->getDay(), newtransaction->getMonth(), newtransaction->getYear(), amount, cleared, newtransaction->getCurrentBudget(), |
118 | newtransaction->getCurrentLineItem() ); | 118 | newtransaction->getCurrentLineItem() ); |
119 | else | 119 | else |
120 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), | 120 | transaction->addTransaction ( newtransaction->getDescription(), newtransaction->transactionname->currentText(), accountid, account->getParentAccountID ( accountid ), |
121 | newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() ); | 121 | newtransaction->transactionnumber->text().toInt(), defaultday, defaultmonth, defaultyear, amount, cleared, newtransaction->getCurrentBudget(), newtransaction->getCurrentLineItem() ); |
122 | 122 | ||
123 | // redisplay transactions | 123 | // redisplay transactions |
124 | listview->clear(); | 124 | listview->clear(); |
125 | QString displaytext = "%"; | 125 | QString displaytext = "%"; |
126 | displaytext.prepend ( limitbox->text() ); | 126 | displaytext.prepend ( limitbox->text() ); |
127 | setTransactionDisplayDate (); | 127 | setTransactionDisplayDate (); |
128 | if ( transaction->getNumberOfTransactions() > 0 ) | 128 | if ( transaction->getNumberOfTransactions() > 0 ) |
129 | transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); | 129 | transaction->displayTransactions ( listview, accountid, children, displaytext, displaydate ); |
130 | 130 | ||
131 | // redisplay transfers | 131 | // redisplay transfers |
132 | if ( transfer->getNumberOfTransfers() > 0 ) | 132 | if ( transfer->getNumberOfTransfers() > 0 ) |
133 | transfer->displayTransfers ( listview, accountid, children, displaydate ); | 133 | transfer->displayTransfers ( listview, accountid, children, displaydate ); |
134 | 134 | ||
135 | // add the transaction amount to the account it's associated with | 135 | // add the transaction amount to the account it's associated with |
136 | // and update its parent account balance if necessary | 136 | // and update its parent account balance if necessary |
137 | account->updateAccountBalance ( accountid ); | 137 | account->updateAccountBalance ( accountid ); |
138 | if ( account->getParentAccountID ( accountid ) != -1 ) | 138 | if ( account->getParentAccountID ( accountid ) != -1 ) |
139 | account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); | 139 | account->changeParentAccountBalance ( account->getParentAccountID ( accountid ) ); |
140 | 140 | ||
141 | // format then reset the account balance | 141 | // format then reset the account balance |
142 | redisplayAccountBalance (); | 142 | redisplayAccountBalance (); |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | void TransactionDisplay::checkListViewEdit () | 146 | void TransactionDisplay::checkListViewEdit () |
147 | { | 147 | { |
148 | if ( listview->selectedItem() == 0 ) | 148 | if ( listview->selectedItem() == 0 ) |
149 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit."); | 149 | QMessageBox::warning ( this, "QashMoney", "Please select a transaction\nto edit."); |
150 | else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) | 150 | else if ( listview->currentItem()->text ( getIDColumn() ).toInt() < 0 ) |
151 | editTransfer (); | 151 | editTransfer (); |
152 | else | 152 | else |
153 | editTransaction(); | 153 | editTransaction(); |
154 | } | 154 | } |
155 | 155 | ||
156 | void TransactionDisplay::showCalculator () | 156 | void TransactionDisplay::showCalculator () |
157 | { | 157 | { |
158 | Calculator *calculator = new Calculator ( this ); | 158 | Calculator *calculator = new Calculator ( this ); |
159 | if ( calculator->exec () == QDialog::Accepted ) | 159 | if ( calculator->exec () == QDialog::Accepted ) |
160 | amount->setText ( calculator->display->text() ); | 160 | amount->setText ( calculator->display->text() ); |
161 | } | 161 | } |
162 | 162 | ||
163 | void TransactionDisplay::showCalendar () | 163 | void TransactionDisplay::showCalendar () |
164 | { | 164 | { |
165 | QDate newDate = QDate::currentDate (); | 165 | QDate newDate = QDate::currentDate (); |
166 | DatePicker *dp = new DatePicker ( newDate ); | 166 | DatePicker *dp = new DatePicker ( newDate ); |
167 | if ( dp->exec () == QDialog::Accepted ) | 167 | if ( dp->exec () == QDialog::Accepted ) |
168 | { | 168 | { |
169 | year = dp->getYear(); | 169 | year = dp->getYear(); |
170 | month = dp->getMonth(); | 170 | month = dp->getMonth(); |
171 | day = dp->getDay(); | 171 | day = dp->getDay(); |
172 | date->setText ( preferences->getDate ( year, month, day ) ); | 172 | date->setText ( preferences->getDate ( year, month, day ) ); |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | void TransactionDisplay::editTransfer () | 176 | void TransactionDisplay::editTransfer () |
177 | { | 177 | { |
178 | transferid = listview->currentItem()->text ( getIDColumn() ).toInt(); | 178 | transferid = listview->currentItem()->text ( getIDColumn() ).toInt(); |
179 | fromaccount = transfer->getFromAccountID ( transferid ); | 179 | fromaccount = transfer->getFromAccountID ( transferid ); |
180 | toaccount = transfer->getToAccountID ( transferid ); | 180 | toaccount = transfer->getToAccountID ( transferid ); |
181 | year = transfer->getYear ( transferid ); | 181 | year = transfer->getYear ( transferid ); |
182 | month = transfer->getMonth ( transferid ); | 182 | month = transfer->getMonth ( transferid ); |
183 | day = transfer->getDay ( transferid ); | 183 | day = transfer->getDay ( transferid ); |
184 | 184 | ||
185 | QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE ); | 185 | QDialog *editransfer = new QDialog ( this, "edittransfer", TRUE ); |
186 | editransfer->setCaption ( "Transfer" ); | 186 | editransfer->setCaption ( "Transfer" ); |
187 | 187 | ||
188 | QStringList accountnames = account->getAccountNames(); | 188 | QStringList accountnames = account->getAccountNames(); |
189 | QStringList accountids = account->getAccountIDs(); | 189 | QStringList accountids = account->getAccountIDs(); |
190 | 190 | ||
191 | QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer ); | 191 | QLabel *fromaccountlabel = new QLabel ( "From Account:", editransfer ); |
192 | QFont f = this->font(); | 192 | QFont f = this->font(); |
193 | f.setWeight ( QFont::Bold ); | 193 | f.setWeight ( QFont::Bold ); |
194 | fromaccountlabel->setFont ( f ); | 194 | fromaccountlabel->setFont ( f ); |
195 | 195 | ||
196 | QComboBox *fromaccountbox = new QComboBox ( editransfer ); | 196 | QComboBox *fromaccountbox = new QComboBox ( editransfer ); |
197 | fromaccountbox->insertStringList ( accountnames ); | 197 | fromaccountbox->insertStringList ( accountnames ); |
198 | fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) ); | 198 | fromaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( fromaccount ) ) ); |
199 | 199 | ||
200 | QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer ); | 200 | QLabel *toaccountlabel = new QLabel ( "To Account:", editransfer ); |
201 | toaccountlabel->setFont ( f ); | 201 | toaccountlabel->setFont ( f ); |
202 | 202 | ||
203 | QComboBox *toaccountbox = new QComboBox ( editransfer ); | 203 | QComboBox *toaccountbox = new QComboBox ( editransfer ); |
204 | toaccountbox->insertStringList ( accountnames ); | 204 | toaccountbox->insertStringList ( accountnames ); |
205 | toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) ); | 205 | toaccountbox->setCurrentItem ( accountids.findIndex ( QString::number ( toaccount ) ) ); |
206 | 206 | ||
207 | QLabel *datelabel = new QLabel ( "Date", editransfer ); | 207 | QLabel *datelabel = new QLabel ( "Date", editransfer ); |
208 | QHBox *datebox = new QHBox ( editransfer ); | 208 | QHBox *datebox = new QHBox ( editransfer ); |
209 | datebox->setSpacing ( 2 ); | 209 | datebox->setSpacing ( 2 ); |
210 | date = new QLineEdit ( datebox ); | 210 | date = new QLineEdit ( datebox ); |
211 | date->setAlignment ( Qt::AlignRight ); | 211 | date->setAlignment ( Qt::AlignRight ); |
212 | date->setDisabled ( TRUE ); | 212 | date->setDisabled ( TRUE ); |
213 | date->setText ( preferences->getDate ( year, month, day ) ); | 213 | date->setText ( preferences->getDate ( year, month, day ) ); |
214 | QPushButton *datebutton = new QPushButton ( datebox ); | 214 | QPushButton *datebutton = new QPushButton ( datebox ); |
215 | datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); | 215 | datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); |
216 | connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) ); | 216 | connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) ); |
217 | 217 | ||
218 | QLabel *amounttlabel = new QLabel ( "Amount", editransfer ); | 218 | QLabel *amounttlabel = new QLabel ( "Amount", editransfer ); |
219 | 219 | ||
220 | QHBox *amountbox = new QHBox ( editransfer ); | 220 | QHBox *amountbox = new QHBox ( editransfer ); |
221 | amountbox->setSpacing ( 2 ); | 221 | amountbox->setSpacing ( 2 ); |
222 | amount = new QLineEdit ( amountbox ); | 222 | amount = new QLineEdit ( amountbox ); |
223 | amount->setAlignment ( Qt::AlignRight ); | 223 | amount->setAlignment ( Qt::AlignRight ); |
224 | amount->setText ( transfer->getAmount ( transferid ) ); | 224 | amount->setText ( transfer->getAmount ( transferid ) ); |
225 | QPushButton *calculatorbutton = new QPushButton( amountbox ); | 225 | QPushButton *calculatorbutton = new QPushButton( amountbox ); |
226 | calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); | 226 | calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); |
227 | connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); | 227 | connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); |
228 | 228 | ||
229 | QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer ); | 229 | QCheckBox *clearedcheckbox = new QCheckBox ( "Cleared", editransfer ); |
230 | 230 | ||
231 | QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 ); | 231 | QBoxLayout *layout = new QVBoxLayout ( editransfer, 4, 2 ); |
232 | layout->addWidget ( fromaccountlabel, Qt::AlignLeft ); | 232 | layout->addWidget ( fromaccountlabel, Qt::AlignLeft ); |
233 | layout->addWidget ( fromaccountbox, Qt::AlignLeft ); | 233 | layout->addWidget ( fromaccountbox, Qt::AlignLeft ); |
234 | layout->addWidget ( toaccountlabel, Qt::AlignLeft ); | 234 | layout->addWidget ( toaccountlabel, Qt::AlignLeft ); |
235 | layout->addWidget ( toaccountbox, Qt::AlignLeft ); | 235 | layout->addWidget ( toaccountbox, Qt::AlignLeft ); |
236 | layout->addSpacing ( 5 ); | 236 | layout->addSpacing ( 5 ); |
237 | layout->addWidget ( datelabel, Qt::AlignLeft ); | 237 | layout->addWidget ( datelabel, Qt::AlignLeft ); |
238 | layout->addWidget ( datebox, Qt::AlignLeft ); | 238 | layout->addWidget ( datebox, Qt::AlignLeft ); |
239 | layout->addWidget ( amounttlabel, Qt::AlignLeft ); | 239 | layout->addWidget ( amounttlabel, Qt::AlignLeft ); |
240 | layout->addWidget ( amountbox, Qt::AlignLeft ); | 240 | layout->addWidget ( amountbox, Qt::AlignLeft ); |
241 | layout->addWidget ( clearedcheckbox, Qt::AlignLeft ); | 241 | layout->addWidget ( clearedcheckbox, Qt::AlignLeft ); |
242 | 242 | ||
243 | if ( editransfer->exec() == QDialog::Accepted ) | 243 | if ( editransfer->exec() == QDialog::Accepted ) |
244 | { | 244 | { |
245 | //get fromaccount | 245 | //get fromaccount |
246 | fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt(); | 246 | fromaccount = ( accountids.operator[] ( fromaccountbox->currentItem() ) ).toInt(); |
247 | 247 | ||
248 | //get to account | 248 | //get to account |
249 | toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt(); | 249 | toaccount = ( accountids.operator[] ( toaccountbox->currentItem() ) ).toInt(); |
250 | 250 | ||
251 | //set cleared flag | 251 | //set cleared flag |
252 | int cleared = 0; | 252 | int cleared = 0; |
253 | if ( clearedcheckbox->isChecked() == TRUE ) | 253 | if ( clearedcheckbox->isChecked() == TRUE ) |
254 | cleared = 1; | 254 | cleared = 1; |
255 | 255 | ||
256 | //update transfer | 256 | //update transfer |
257 | transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ), | 257 | transfer->updateTransfer ( fromaccount, account->getParentAccountID ( fromaccount ), toaccount, account->getParentAccountID ( toaccount ), |
258 | day, month, year, amount->text().toFloat(), cleared, transferid ); | 258 | day, month, year, amount->text().toFloat(), cleared, transferid ); |
259 | 259 | ||
260 | account->updateAccountBalance ( fromaccount ); | 260 | account->updateAccountBalance ( fromaccount ); |
261 | if ( account->getParentAccountID ( fromaccount ) != -1 ) | 261 | if ( account->getParentAccountID ( fromaccount ) != -1 ) |
262 | account->changeParentAccountBalance ( account->getParentAccountID ( fromaccount ) ); | 262 | account->changeParentAccountBalance ( account->getParentAccountID ( fromaccount ) ); |
263 | 263 | ||
264 | updateAndDisplay ( toaccount ); | 264 | updateAndDisplay ( toaccount ); |
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | void TransactionDisplay::editTransaction () | 268 | void TransactionDisplay::editTransaction () |
269 | { | 269 | { |
270 | int cleared; | 270 | int cleared; |
271 | 271 | ||
272 | // set the transaction id and budgetid | 272 | // set the transaction id and budgetid |
273 | int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); | 273 | int transactionid = listview->currentItem()->text ( getIDColumn() ).toInt(); |
274 | int budgetid = transaction->getBudgetID ( transactionid ); | 274 | int budgetid = transaction->getBudgetID ( transactionid ); |
275 | int lineitemid = transaction->getLineItemID ( transactionid ); | 275 | int lineitemid = transaction->getLineItemID ( transactionid ); |
276 | 276 | ||
277 | // create edit transaction window | 277 | // create edit transaction window |
278 | NewTransaction *newtransaction = new NewTransaction ( this ); | 278 | NewTransaction *newtransaction = new NewTransaction ( this ); |
279 | int width = this->width(); | 279 | int width = this->width(); |
280 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 280 | newtransaction->transactionname->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
281 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); | 281 | newtransaction->transactionname->setMinimumWidth ( ( int ) ( width * 0.35 ) ); |
282 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); | 282 | newtransaction->lineitembox->setMaximumWidth ( ( int ) ( width * 0.45 ) ); |
283 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 283 | newtransaction->transactiondatebox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
284 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); | 284 | newtransaction->transactionamountbox->setMaximumWidth ( ( int ) ( width * 0.4 ) ); |
285 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); | 285 | newtransaction->transactionnumber->setMaximumWidth ( ( int ) ( width * 0.25 ) ); |
286 | 286 | ||
287 | // enter the date in the date box | 287 | // enter the date in the date box |
288 | newtransaction->year = transaction->getYear ( transactionid ); | 288 | newtransaction->year = transaction->getYear ( transactionid ); |
289 | newtransaction->month = transaction->getMonth ( transactionid ); | 289 | newtransaction->month = transaction->getMonth ( transactionid ); |
290 | newtransaction->day = transaction->getDay ( transactionid ); | 290 | newtransaction->day = transaction->getDay ( transactionid ); |
291 | newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) ); | 291 | newtransaction->transactiondate->setText ( preferences->getDate ( newtransaction->year, newtransaction->month, newtransaction->day ) ); |
292 | 292 | ||
293 | // set the description | 293 | // set the description |
294 | newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) ); | 294 | newtransaction->setDescription ( transaction->getTransactionDescription ( transactionid ) ); |
295 | 295 | ||
296 | // add memory items to the transactionname combobox | 296 | // add memory items to the transactionname combobox |
297 | memory->displayMemoryItems ( newtransaction->transactionname ); | 297 | memory->displayMemoryItems ( newtransaction->transactionname ); |
298 | 298 | ||
299 | // add correct transaction name | 299 | // add correct transaction name |
300 | newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) ); | 300 | newtransaction->transactionname->setEditText ( transaction->getPayee ( transactionid ) ); |
301 | 301 | ||
302 | // add transaction number | 302 | // add transaction number |
303 | newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) ); | 303 | newtransaction->transactionnumber->setText ( transaction->getNumber ( transactionid ) ); |
304 | 304 | ||
305 | // add transaction amount | 305 | // add transaction amount |
306 | newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) ); | 306 | newtransaction->transactionamount->setText ( transaction->getAbsoluteAmount ( transactionid ) ); |
307 | 307 | ||
308 | // check for and set the correct budget | 308 | // check for and set the correct budget |
309 | if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item | 309 | if ( budgetid >= 1 ) // only do it if this transaction has a budget and line item |
310 | { | 310 | { |
311 | newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 ); | 311 | newtransaction->budgetbox->setCurrentItem ( newtransaction->getBudgetIndex ( budgetid ) + 1 ); |
312 | if ( lineitemid >= 1 ) | 312 | if ( lineitemid >= 1 ) |
diff --git a/noncore/apps/qashmoney/transferdialog.cpp b/noncore/apps/qashmoney/transferdialog.cpp index 558abec..7a12fbf 100755 --- a/noncore/apps/qashmoney/transferdialog.cpp +++ b/noncore/apps/qashmoney/transferdialog.cpp | |||
@@ -1,112 +1,112 @@ | |||
1 | #include "transferdialog.h" | 1 | #include "transferdialog.h" |
2 | #include "datepicker.h" | 2 | #include "datepicker.h" |
3 | #include "calculator.h" | 3 | #include "calculator.h" |
4 | 4 | ||
5 | 5 | ||
6 | extern Preferences *preferences; | 6 | extern Preferences *preferences; |
7 | extern Account *account; | 7 | extern Account *account; |
8 | 8 | ||
9 | TransferDialog::TransferDialog ( QWidget *parent, int fromaccountid, int toaccountid ) : QDialog ( parent, 0, TRUE ) | 9 | TransferDialog::TransferDialog ( QWidget *parent, int fromaccountid, int toaccountid ) : QDialog ( parent, 0, TRUE ) |
10 | { | 10 | { |
11 | dateedited = FALSE; | 11 | dateedited = FALSE; |
12 | setCaption ( "Transfer" ); | 12 | setCaption ( "Transfer" ); |
13 | 13 | ||
14 | fromaccountlabel = new QLabel ( "From account:", this ); | 14 | fromaccountlabel = new QLabel ( "From account:", this ); |
15 | QFont f = this->font(); | 15 | QFont f = this->font(); |
16 | f.setWeight ( QFont::Bold ); | 16 | f.setWeight ( QFont::Bold ); |
17 | fromaccountlabel->setFont ( f ); | 17 | fromaccountlabel->setFont ( f ); |
18 | fromaccount = new QLabel ( account->getAccountName ( fromaccountid ), this ); | 18 | fromaccount = new QLabel ( account->getAccountName ( fromaccountid ), this ); |
19 | 19 | ||
20 | toaccountlabel = new QLabel ( "To Account:", this ); | 20 | toaccountlabel = new QLabel ( "To Account:", this ); |
21 | toaccountlabel->setFont ( f ); | 21 | toaccountlabel->setFont ( f ); |
22 | toaccount = new QLabel ( account->getAccountName ( toaccountid ), this ); | 22 | toaccount = new QLabel ( account->getAccountName ( toaccountid ), this ); |
23 | 23 | ||
24 | datelabel = new QLabel ( "Date", this ); | 24 | datelabel = new QLabel ( "Date", this ); |
25 | 25 | ||
26 | datebox = new QHBox ( this ); | 26 | datebox = new QHBox ( this ); |
27 | datebox->setSpacing ( 2 ); | 27 | datebox->setSpacing ( 2 ); |
28 | date = new QLineEdit ( datebox ); | 28 | date = new QLineEdit ( datebox ); |
29 | date->setAlignment ( Qt::AlignRight ); | 29 | date->setAlignment ( Qt::AlignRight ); |
30 | date->setDisabled ( TRUE ); | 30 | date->setDisabled ( TRUE ); |
31 | datebutton = new QPushButton ( datebox ); | 31 | datebutton = new QPushButton ( datebox ); |
32 | datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); | 32 | datebutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/date.png" ) ); |
33 | connect ( datebutton, SIGNAL ( released () ), this, SLOT ( showCalendar () ) ); | 33 | connect ( datebutton, SIGNAL ( released() ), this, SLOT ( showCalendar() ) ); |
34 | 34 | ||
35 | amounttlabel = new QLabel ( "Amount", this ); | 35 | amounttlabel = new QLabel ( "Amount", this ); |
36 | 36 | ||
37 | amountbox = new QHBox ( this ); | 37 | amountbox = new QHBox ( this ); |
38 | amountbox->setSpacing ( 2 ); | 38 | amountbox->setSpacing ( 2 ); |
39 | amount = new QLineEdit ( amountbox ); | 39 | amount = new QLineEdit ( amountbox ); |
40 | amount->setAlignment ( Qt::AlignRight ); | 40 | amount->setAlignment ( Qt::AlignRight ); |
41 | calculatorbutton = new QPushButton( amountbox ); | 41 | calculatorbutton = new QPushButton( amountbox ); |
42 | calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); | 42 | calculatorbutton->setPixmap ( QPixmap ( "/opt/QtPalmtop/pics/kcalc.png" ) ); |
43 | connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); | 43 | connect ( calculatorbutton, SIGNAL ( released() ), this, SLOT ( showCalculator() ) ); |
44 | 44 | ||
45 | clearedcheckbox = new QCheckBox ( "Cleared", this ); | 45 | clearedcheckbox = new QCheckBox ( "Cleared", this ); |
46 | 46 | ||
47 | layout = new QVBoxLayout ( this, 4, 2 ); | 47 | layout = new QVBoxLayout ( this, 4, 2 ); |
48 | layout->addWidget ( fromaccountlabel, Qt::AlignLeft ); | 48 | layout->addWidget ( fromaccountlabel, Qt::AlignLeft ); |
49 | layout->addWidget ( fromaccount, Qt::AlignLeft ); | 49 | layout->addWidget ( fromaccount, Qt::AlignLeft ); |
50 | layout->addWidget ( toaccountlabel, Qt::AlignLeft ); | 50 | layout->addWidget ( toaccountlabel, Qt::AlignLeft ); |
51 | layout->addWidget ( toaccount, Qt::AlignLeft ); | 51 | layout->addWidget ( toaccount, Qt::AlignLeft ); |
52 | layout->addSpacing ( 5 ); | 52 | layout->addSpacing ( 5 ); |
53 | layout->addWidget ( datelabel, Qt::AlignLeft ); | 53 | layout->addWidget ( datelabel, Qt::AlignLeft ); |
54 | layout->addWidget ( datebox, Qt::AlignLeft ); | 54 | layout->addWidget ( datebox, Qt::AlignLeft ); |
55 | layout->addWidget ( amounttlabel, Qt::AlignLeft ); | 55 | layout->addWidget ( amounttlabel, Qt::AlignLeft ); |
56 | layout->addWidget ( amountbox, Qt::AlignLeft ); | 56 | layout->addWidget ( amountbox, Qt::AlignLeft ); |
57 | layout->addWidget ( clearedcheckbox, Qt::AlignLeft ); | 57 | layout->addWidget ( clearedcheckbox, Qt::AlignLeft ); |
58 | } | 58 | } |
59 | 59 | ||
60 | bool TransferDialog::getDateEdited () | 60 | bool TransferDialog::getDateEdited () |
61 | { | 61 | { |
62 | return dateedited; | 62 | return dateedited; |
63 | } | 63 | } |
64 | 64 | ||
65 | void TransferDialog::showCalendar () | 65 | void TransferDialog::showCalendar () |
66 | { | 66 | { |
67 | QDate newDate = QDate::currentDate (); | 67 | QDate newDate = QDate::currentDate (); |
68 | DatePicker *dp = new DatePicker ( newDate ); | 68 | DatePicker *dp = new DatePicker ( newDate ); |
69 | if ( dp->exec () == QDialog::Accepted ) | 69 | if ( dp->exec () == QDialog::Accepted ) |
70 | { | 70 | { |
71 | // Set date integers | 71 | // Set date integers |
72 | year = dp->getYear(); | 72 | year = dp->getYear(); |
73 | month = dp->getMonth(); | 73 | month = dp->getMonth(); |
74 | day = dp->getDay(); | 74 | day = dp->getDay(); |
75 | 75 | ||
76 | // Set dateedited to TRUE | 76 | // Set dateedited to TRUE |
77 | // This tells the accountdisplay object that the user edited an account | 77 | // This tells the accountdisplay object that the user edited an account |
78 | // and did change the date | 78 | // and did change the date |
79 | dateedited = TRUE; | 79 | dateedited = TRUE; |
80 | 80 | ||
81 | // Display date with our selected format | 81 | // Display date with our selected format |
82 | date->setText ( preferences->getDate ( year, month, day ) ); | 82 | date->setText ( preferences->getDate ( year, month, day ) ); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | int TransferDialog::getDay () | 86 | int TransferDialog::getDay () |
87 | { | 87 | { |
88 | return day; | 88 | return day; |
89 | } | 89 | } |
90 | 90 | ||
91 | int TransferDialog::getMonth () | 91 | int TransferDialog::getMonth () |
92 | { | 92 | { |
93 | return month; | 93 | return month; |
94 | } | 94 | } |
95 | 95 | ||
96 | int TransferDialog::getYear () | 96 | int TransferDialog::getYear () |
97 | { | 97 | { |
98 | return year; | 98 | return year; |
99 | } | 99 | } |
100 | 100 | ||
101 | void TransferDialog::showCalculator () | 101 | void TransferDialog::showCalculator () |
102 | { | 102 | { |
103 | Calculator *calculator = new Calculator ( this ); | 103 | Calculator *calculator = new Calculator ( this ); |
104 | if ( calculator->exec () == QDialog::Accepted ) | 104 | if ( calculator->exec () == QDialog::Accepted ) |
105 | amount->setText ( calculator->display->text() ); | 105 | amount->setText ( calculator->display->text() ); |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
diff --git a/noncore/apps/tableviewer/tableviewer.cpp b/noncore/apps/tableviewer/tableviewer.cpp index f35dfcd..4c6d809 100644 --- a/noncore/apps/tableviewer/tableviewer.cpp +++ b/noncore/apps/tableviewer/tableviewer.cpp | |||
@@ -62,200 +62,200 @@ TableViewerWindow::TableViewerWindow(QWidget *parent, const char *name, WFlags f | |||
62 | 62 | ||
63 | dirty = FALSE; | 63 | dirty = FALSE; |
64 | ts.current_column = 0; | 64 | ts.current_column = 0; |
65 | ts.kRep = ds->getKeys(); | 65 | ts.kRep = ds->getKeys(); |
66 | 66 | ||
67 | /* build menus */ | 67 | /* build menus */ |
68 | menu = new QMenuBar(this, 0); | 68 | menu = new QMenuBar(this, 0); |
69 | 69 | ||
70 | QPopupMenu *file_menu = new QPopupMenu; | 70 | QPopupMenu *file_menu = new QPopupMenu; |
71 | file_menu->insertItem("New", this, SLOT(newDocument())); | 71 | file_menu->insertItem("New", this, SLOT(newDocument())); |
72 | 72 | ||
73 | file_menu->insertItem("Open", this, SLOT(selectDocument())); | 73 | file_menu->insertItem("Open", this, SLOT(selectDocument())); |
74 | file_menu->insertSeparator(); | 74 | file_menu->insertSeparator(); |
75 | file_menu->insertItem("Properties"); | 75 | file_menu->insertItem("Properties"); |
76 | 76 | ||
77 | /* later will want to set this up to clean up first via this, SLOT(quit) */ | 77 | /* later will want to set this up to clean up first via this, SLOT(quit) */ |
78 | menu->insertItem("Document", file_menu); | 78 | menu->insertItem("Document", file_menu); |
79 | 79 | ||
80 | QPopupMenu *edit_menu = new QPopupMenu; | 80 | QPopupMenu *edit_menu = new QPopupMenu; |
81 | edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot())); | 81 | edit_menu->insertItem("Edit Item", this, SLOT(editItemSlot())); |
82 | edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot())); | 82 | edit_menu->insertItem("Edit Keys", this, SLOT(editKeysSlot())); |
83 | edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot())); | 83 | edit_menu->insertItem("Edit filters", this, SLOT(filterViewSlot())); |
84 | menu->insertItem("Edit", edit_menu); | 84 | menu->insertItem("Edit", edit_menu); |
85 | 85 | ||
86 | QPopupMenu *view_menu = new QPopupMenu; | 86 | QPopupMenu *view_menu = new QPopupMenu; |
87 | view_menu->insertItem("Browse View", this, SLOT(browseViewSlot())); | 87 | view_menu->insertItem("Browse View", this, SLOT(browseViewSlot())); |
88 | view_menu->insertItem("List View", this, SLOT(listViewSlot())); | 88 | view_menu->insertItem("List View", this, SLOT(listViewSlot())); |
89 | menu->insertItem("View", view_menu); | 89 | menu->insertItem("View", view_menu); |
90 | 90 | ||
91 | QVBoxLayout *main_layout = new QVBoxLayout; | 91 | QVBoxLayout *main_layout = new QVBoxLayout; |
92 | 92 | ||
93 | /* Build tool bar */ | 93 | /* Build tool bar */ |
94 | navigation = new QToolBar(this, "navigation"); | 94 | navigation = new QToolBar(this, "navigation"); |
95 | QToolButton *newItemButton = new QToolButton( | 95 | QToolButton *newItemButton = new QToolButton( |
96 | QIconSet(Resource::loadPixmap("new")), "New Item", QString::null, | 96 | QIconSet(Resource::loadPixmap("new")), "New Item", QString::null, |
97 | this, SLOT(newItemSlot()), navigation, "New Item"); | 97 | this, SLOT(newItemSlot()), navigation, "New Item"); |
98 | QToolButton *editItemButton = new QToolButton( | 98 | QToolButton *editItemButton = new QToolButton( |
99 | QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null, | 99 | QIconSet(Resource::loadPixmap("edit")), "Edit Item", QString::null, |
100 | this, SLOT(editItemSlot()), navigation, "Edit Item"); | 100 | this, SLOT(editItemSlot()), navigation, "Edit Item"); |
101 | QToolButton *deleteItemButton = new QToolButton( | 101 | QToolButton *deleteItemButton = new QToolButton( |
102 | QIconSet(Resource::loadPixmap("trash")), "Delete Item", | 102 | QIconSet(Resource::loadPixmap("trash")), "Delete Item", |
103 | QString::null, this, | 103 | QString::null, this, |
104 | SLOT(deleteItemSlot()), navigation, "Delete Item"); | 104 | SLOT(deleteItemSlot()), navigation, "Delete Item"); |
105 | 105 | ||
106 | navigation->addSeparator(); | 106 | navigation->addSeparator(); |
107 | 107 | ||
108 | QToolButton *firstItemButton = new QToolButton( | 108 | QToolButton *firstItemButton = new QToolButton( |
109 | QIconSet(Resource::loadPixmap("fastback")), "First Item", | 109 | QIconSet(Resource::loadPixmap("fastback")), "First Item", |
110 | QString::null, this, | 110 | QString::null, this, |
111 | SLOT(firstItem()), navigation, "First Item"); | 111 | SLOT(firstItem()), navigation, "First Item"); |
112 | QToolButton *previousItemButton = new QToolButton( | 112 | QToolButton *previousItemButton = new QToolButton( |
113 | QIconSet(Resource::loadPixmap("back")), "Previous Item", | 113 | QIconSet(Resource::loadPixmap("back")), "Previous Item", |
114 | QString::null, this, | 114 | QString::null, this, |
115 | SLOT(previousItem()), navigation, "Previous Item"); | 115 | SLOT(previousItem()), navigation, "Previous Item"); |
116 | QToolButton *nextItemButton = new QToolButton( | 116 | QToolButton *nextItemButton = new QToolButton( |
117 | QIconSet(Resource::loadPixmap("forward")), "Next Item", | 117 | QIconSet(Resource::loadPixmap("forward")), "Next Item", |
118 | QString::null, this, | 118 | QString::null, this, |
119 | SLOT(nextItem()), navigation, "Next Item"); | 119 | SLOT(nextItem()), navigation, "Next Item"); |
120 | QToolButton *lastItemButton = new QToolButton( | 120 | QToolButton *lastItemButton = new QToolButton( |
121 | QIconSet(Resource::loadPixmap("fastforward")), "Last Item", | 121 | QIconSet(Resource::loadPixmap("fastforward")), "Last Item", |
122 | QString::null, this, | 122 | QString::null, this, |
123 | SLOT(lastItem()), navigation, "Last Item"); | 123 | SLOT(lastItem()), navigation, "Last Item"); |
124 | 124 | ||
125 | navigation->addSeparator(); | 125 | navigation->addSeparator(); |
126 | QToolButton *browseButton = new QToolButton( | 126 | QToolButton *browseButton = new QToolButton( |
127 | QIconSet(Resource::loadPixmap("day")), "View Single Item", | 127 | QIconSet(Resource::loadPixmap("day")), "View Single Item", |
128 | QString::null, this, | 128 | QString::null, this, |
129 | SLOT(browseViewSlot()), navigation, "View Single Item"); | 129 | SLOT(browseViewSlot()), navigation, "View Single Item"); |
130 | QToolButton *listButton = new QToolButton( | 130 | QToolButton *listButton = new QToolButton( |
131 | QIconSet(Resource::loadPixmap("month")), "View Multiple Items", | 131 | QIconSet(Resource::loadPixmap("month")), "View Multiple Items", |
132 | QString::null, this, | 132 | QString::null, this, |
133 | SLOT(listViewSlot()), navigation, "View Multiple Items"); | 133 | SLOT(listViewSlot()), navigation, "View Multiple Items"); |
134 | 134 | ||
135 | setToolBarsMovable(FALSE); | 135 | setToolBarsMovable(FALSE); |
136 | setToolBarsMovable(FALSE); | 136 | setToolBarsMovable(FALSE); |
137 | setToolBarsMovable(FALSE); | 137 | setToolBarsMovable(FALSE); |
138 | 138 | ||
139 | /* Build widgets */ | 139 | /* Build widgets */ |
140 | browseView = new TVBrowseView(&ts, this, 0); | 140 | browseView = new TVBrowseView(&ts, this, 0); |
141 | listView = new TVListView(&ts, this, 0); | 141 | listView = new TVListView(&ts, this, 0); |
142 | filterView = new TVFilterView(&ts, this, 0); | 142 | filterView = new TVFilterView(&ts, this, 0); |
143 | fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer", | 143 | fileSelector = new FileSelector("text/csv;text/x-xml-tableviewer", |
144 | this, "fileselector"); | 144 | this, "fileselector"); |
145 | fileSelector->setNewVisible(FALSE); | 145 | fileSelector->setNewVisible(FALSE); |
146 | fileSelector->setCloseVisible(FALSE); | 146 | fileSelector->setCloseVisible(FALSE); |
147 | 147 | ||
148 | cw = new QWidgetStack(this, 0); | 148 | cw = new QWidgetStack(this, 0); |
149 | cw->addWidget(listView, ListState); | 149 | cw->addWidget(listView, ListState); |
150 | cw->addWidget(browseView, BrowseState); | 150 | cw->addWidget(browseView, BrowseState); |
151 | cw->addWidget(filterView, FilterState); | 151 | cw->addWidget(filterView, FilterState); |
152 | cw->addWidget(fileSelector, FileState); | 152 | cw->addWidget(fileSelector, FileState); |
153 | 153 | ||
154 | current_view = FileState; | 154 | current_view = FileState; |
155 | cw->raiseWidget(current_view); | 155 | cw->raiseWidget(current_view); |
156 | fileSelector->reread(); | 156 | fileSelector->reread(); |
157 | 157 | ||
158 | connect(browseView, SIGNAL(searchOnKey(int, TVVariant)), | 158 | connect(browseView, SIGNAL(searchOnKey(int,TVVariant)), |
159 | this, SLOT(searchOnKey(int, TVVariant))); | 159 | this, SLOT(searchOnKey(int,TVVariant))); |
160 | connect(browseView, SIGNAL(sortChanged(int)), | 160 | connect(browseView, SIGNAL(sortChanged(int)), |
161 | this, SLOT(setPrimaryKey(int))); | 161 | this, SLOT(setPrimaryKey(int))); |
162 | 162 | ||
163 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); | 163 | connect(fileSelector, SIGNAL(closeMe()), this, SLOT(browseViewSlot())); |
164 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk &)), | 164 | connect(fileSelector, SIGNAL(fileSelected(const DocLnk&)), |
165 | this, SLOT(openDocument(const DocLnk &))); | 165 | this, SLOT(openDocument(const DocLnk&))); |
166 | 166 | ||
167 | main_layout->addWidget(menu); | 167 | main_layout->addWidget(menu); |
168 | main_layout->addWidget(cw); | 168 | main_layout->addWidget(cw); |
169 | 169 | ||
170 | setCentralWidget(cw); | 170 | setCentralWidget(cw); |
171 | 171 | ||
172 | } | 172 | } |
173 | 173 | ||
174 | /*! | 174 | /*! |
175 | Destroys the TableViewerWindow | 175 | Destroys the TableViewerWindow |
176 | */ | 176 | */ |
177 | TableViewerWindow::~TableViewerWindow() | 177 | TableViewerWindow::~TableViewerWindow() |
178 | { | 178 | { |
179 | if(dirty) | 179 | if(dirty) |
180 | saveDocument(); | 180 | saveDocument(); |
181 | } | 181 | } |
182 | 182 | ||
183 | /*! | 183 | /*! |
184 | Opens a file dialog and loads the file specified by the dialog | 184 | Opens a file dialog and loads the file specified by the dialog |
185 | */ | 185 | */ |
186 | void TableViewerWindow::selectDocument() | 186 | void TableViewerWindow::selectDocument() |
187 | { | 187 | { |
188 | if(dirty) | 188 | if(dirty) |
189 | saveDocument(); | 189 | saveDocument(); |
190 | current_view = FileState; | 190 | current_view = FileState; |
191 | cw->raiseWidget(current_view); | 191 | cw->raiseWidget(current_view); |
192 | fileSelector->reread(); | 192 | fileSelector->reread(); |
193 | } | 193 | } |
194 | 194 | ||
195 | void TableViewerWindow::saveDocument() | 195 | void TableViewerWindow::saveDocument() |
196 | { | 196 | { |
197 | if(!dirty) | 197 | if(!dirty) |
198 | return; | 198 | return; |
199 | 199 | ||
200 | FileManager fm; | 200 | FileManager fm; |
201 | QIODevice *dev = fm.saveFile(doc); | 201 | QIODevice *dev = fm.saveFile(doc); |
202 | 202 | ||
203 | if(!ds->saveSource(dev, doc.type())){ | 203 | if(!ds->saveSource(dev, doc.type())){ |
204 | qWarning("Save unsuccessful"); | 204 | qWarning("Save unsuccessful"); |
205 | return; | 205 | return; |
206 | } | 206 | } |
207 | dev->close(); | 207 | dev->close(); |
208 | dirty = FALSE; | 208 | dirty = FALSE; |
209 | } | 209 | } |
210 | 210 | ||
211 | void TableViewerWindow::newDocument() | 211 | void TableViewerWindow::newDocument() |
212 | { | 212 | { |
213 | DocLnk nf; | 213 | DocLnk nf; |
214 | nf.setType("text/x-xml-tableviewer"); | 214 | nf.setType("text/x-xml-tableviewer"); |
215 | nf.setName("table"); | 215 | nf.setName("table"); |
216 | 216 | ||
217 | delete ds; | 217 | delete ds; |
218 | ds = new DBStore(); | 218 | ds = new DBStore(); |
219 | 219 | ||
220 | ts.current_column = 0; | 220 | ts.current_column = 0; |
221 | ts.kRep = ds->getKeys(); | 221 | ts.kRep = ds->getKeys(); |
222 | browseView->reset(); | 222 | browseView->reset(); |
223 | listView->reset(); | 223 | listView->reset(); |
224 | filterView->reset(); | 224 | filterView->reset(); |
225 | 225 | ||
226 | doc = nf; | 226 | doc = nf; |
227 | dirty = FALSE; | 227 | dirty = FALSE; |
228 | 228 | ||
229 | current_view = BrowseState; | 229 | current_view = BrowseState; |
230 | cw->raiseWidget(current_view); | 230 | cw->raiseWidget(current_view); |
231 | 231 | ||
232 | /* now set up for editing the keys */ | 232 | /* now set up for editing the keys */ |
233 | ts.kRep->addKey("key", TVVariant::String); | 233 | ts.kRep->addKey("key", TVVariant::String); |
234 | editKeysSlot(); | 234 | editKeysSlot(); |
235 | } | 235 | } |
236 | 236 | ||
237 | void TableViewerWindow::setDocument(const QString &f) | 237 | void TableViewerWindow::setDocument(const QString &f) |
238 | { | 238 | { |
239 | openDocument(DocLnk(f, TRUE)); | 239 | openDocument(DocLnk(f, TRUE)); |
240 | } | 240 | } |
241 | 241 | ||
242 | void TableViewerWindow::openDocument(const DocLnk &f) | 242 | void TableViewerWindow::openDocument(const DocLnk &f) |
243 | { | 243 | { |
244 | 244 | ||
245 | if (!f.isValid()) | 245 | if (!f.isValid()) |
246 | return; | 246 | return; |
247 | 247 | ||
248 | FileManager fm; | 248 | FileManager fm; |
249 | QIODevice *dev = fm.openFile(f); | 249 | QIODevice *dev = fm.openFile(f); |
250 | doc = f; | 250 | doc = f; |
251 | 251 | ||
252 | if(ds->openSource(dev, doc.type())) { | 252 | if(ds->openSource(dev, doc.type())) { |
253 | DataElem *d; | 253 | DataElem *d; |
254 | 254 | ||
255 | browseView->reset(); | 255 | browseView->reset(); |
256 | listView->reset(); | 256 | listView->reset(); |
257 | filterView->reset(); | 257 | filterView->reset(); |
258 | 258 | ||
259 | current_view = BrowseState; | 259 | current_view = BrowseState; |
260 | cw->raiseWidget(current_view); | 260 | cw->raiseWidget(current_view); |
261 | 261 | ||
diff --git a/noncore/apps/tableviewer/ui/commonwidgets.cpp b/noncore/apps/tableviewer/ui/commonwidgets.cpp index 4c47951..e82018c 100644 --- a/noncore/apps/tableviewer/ui/commonwidgets.cpp +++ b/noncore/apps/tableviewer/ui/commonwidgets.cpp | |||
@@ -1,136 +1,136 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | 25 | ||
26 | #include <qpe/datebookmonth.h> | 26 | #include <qpe/datebookmonth.h> |
27 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
28 | #include <qspinbox.h> | 28 | #include <qspinbox.h> |
29 | #include "commonwidgets.h" | 29 | #include "commonwidgets.h" |
30 | 30 | ||
31 | DateEdit::DateEdit( QWidget *parent, const char *name, WFlags f ) | 31 | DateEdit::DateEdit( QWidget *parent, const char *name, WFlags f ) |
32 | : QToolButton(parent, name) | 32 | : QToolButton(parent, name) |
33 | { | 33 | { |
34 | QPopupMenu *m1 = new QPopupMenu(this); | 34 | QPopupMenu *m1 = new QPopupMenu(this); |
35 | dateSelector = new DateBookMonth(m1, 0, TRUE); | 35 | dateSelector = new DateBookMonth(m1, 0, TRUE); |
36 | m1->insertItem(dateSelector); | 36 | m1->insertItem(dateSelector); |
37 | setPopup(m1); | 37 | setPopup(m1); |
38 | setPopupDelay(0); | 38 | setPopupDelay(0); |
39 | 39 | ||
40 | connect(dateSelector, SIGNAL(dateClicked(int, int, int)), | 40 | connect(dateSelector, SIGNAL(dateClicked(int,int,int)), |
41 | this, SLOT(subValueChanged())); | 41 | this, SLOT(subValueChanged())); |
42 | 42 | ||
43 | setText(dateSelector->selectedDate().toString()); | 43 | setText(dateSelector->selectedDate().toString()); |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | DateEdit::~DateEdit() {} | 47 | DateEdit::~DateEdit() {} |
48 | 48 | ||
49 | QDate DateEdit::date() const | 49 | QDate DateEdit::date() const |
50 | { | 50 | { |
51 | return dateSelector->selectedDate(); | 51 | return dateSelector->selectedDate(); |
52 | } | 52 | } |
53 | 53 | ||
54 | void DateEdit::setDate(QDate d) | 54 | void DateEdit::setDate(QDate d) |
55 | { | 55 | { |
56 | dateSelector->setDate(d.year(), d.month(), d.day()); | 56 | dateSelector->setDate(d.year(), d.month(), d.day()); |
57 | setText(d.toString()); | 57 | setText(d.toString()); |
58 | } | 58 | } |
59 | 59 | ||
60 | QSizePolicy DateEdit::sizePolicy() const | 60 | QSizePolicy DateEdit::sizePolicy() const |
61 | { | 61 | { |
62 | QSizePolicy sp; | 62 | QSizePolicy sp; |
63 | sp.setHorData(QToolButton::sizePolicy().horData()); | 63 | sp.setHorData(QToolButton::sizePolicy().horData()); |
64 | sp.setVerData(QSizePolicy::Fixed); | 64 | sp.setVerData(QSizePolicy::Fixed); |
65 | 65 | ||
66 | return sp; | 66 | return sp; |
67 | } | 67 | } |
68 | 68 | ||
69 | void DateEdit::clear() | 69 | void DateEdit::clear() |
70 | { | 70 | { |
71 | QDate today = QDate::currentDate(); | 71 | QDate today = QDate::currentDate(); |
72 | 72 | ||
73 | dateSelector->setDate(today.year(), today.month(), today.day()); | 73 | dateSelector->setDate(today.year(), today.month(), today.day()); |
74 | setText(today.toString()); | 74 | setText(today.toString()); |
75 | } | 75 | } |
76 | 76 | ||
77 | void DateEdit::subValueChanged() | 77 | void DateEdit::subValueChanged() |
78 | { | 78 | { |
79 | QDate current = dateSelector->selectedDate(); | 79 | QDate current = dateSelector->selectedDate(); |
80 | 80 | ||
81 | setText(current.toString()); | 81 | setText(current.toString()); |
82 | emit valueChanged(current); | 82 | emit valueChanged(current); |
83 | } | 83 | } |
84 | 84 | ||
85 | TimeEdit::TimeEdit( QWidget *parent, const char *name, WFlags f ) | 85 | TimeEdit::TimeEdit( QWidget *parent, const char *name, WFlags f ) |
86 | : QWidget(parent, name, f) | 86 | : QWidget(parent, name, f) |
87 | { | 87 | { |
88 | QHBoxLayout *layout = new QHBoxLayout(this, 0); | 88 | QHBoxLayout *layout = new QHBoxLayout(this, 0); |
89 | 89 | ||
90 | layout->addWidget(hourKey = new QSpinBox(1, 12, 1, this)); | 90 | layout->addWidget(hourKey = new QSpinBox(1, 12, 1, this)); |
91 | hourKey->setWrapping(true); | 91 | hourKey->setWrapping(true); |
92 | hourKey->setMinimumWidth(30); | 92 | hourKey->setMinimumWidth(30); |
93 | hourKey->setMaximumWidth(35); | 93 | hourKey->setMaximumWidth(35); |
94 | 94 | ||
95 | layout->addWidget(new QLabel(" : ", this)); | 95 | layout->addWidget(new QLabel(" : ", this)); |
96 | layout->addWidget(minuteKey = new QSpinBox(0, 59, 1, this)); | 96 | layout->addWidget(minuteKey = new QSpinBox(0, 59, 1, this)); |
97 | minuteKey->setWrapping(true); | 97 | minuteKey->setWrapping(true); |
98 | minuteKey->setMinimumWidth(30); | 98 | minuteKey->setMinimumWidth(30); |
99 | minuteKey->setMaximumWidth(35); | 99 | minuteKey->setMaximumWidth(35); |
100 | 100 | ||
101 | layout->addWidget(new QLabel(" : ", this)); | 101 | layout->addWidget(new QLabel(" : ", this)); |
102 | layout->addWidget(secondKey = new QSpinBox(0, 59, 1, this, 0)); | 102 | layout->addWidget(secondKey = new QSpinBox(0, 59, 1, this, 0)); |
103 | secondKey->setWrapping(true); | 103 | secondKey->setWrapping(true); |
104 | secondKey->setMinimumWidth(30); | 104 | secondKey->setMinimumWidth(30); |
105 | secondKey->setMaximumWidth(35); | 105 | secondKey->setMaximumWidth(35); |
106 | 106 | ||
107 | layout->addWidget(ampm = new QComboBox(this)); | 107 | layout->addWidget(ampm = new QComboBox(this)); |
108 | ampm->insertItem("AM"); | 108 | ampm->insertItem("AM"); |
109 | ampm->insertItem("PM"); | 109 | ampm->insertItem("PM"); |
110 | 110 | ||
111 | layout->addStretch(-1); | 111 | layout->addStretch(-1); |
112 | 112 | ||
113 | clear(); | 113 | clear(); |
114 | 114 | ||
115 | connect(secondKey, SIGNAL(valueChanged(const QString&)), | 115 | connect(secondKey, SIGNAL(valueChanged(const QString&)), |
116 | this, SLOT(subValueChanged())); | 116 | this, SLOT(subValueChanged())); |
117 | connect(minuteKey, SIGNAL(valueChanged(const QString&)), | 117 | connect(minuteKey, SIGNAL(valueChanged(const QString&)), |
118 | this, SLOT(subValueChanged())); | 118 | this, SLOT(subValueChanged())); |
119 | connect(hourKey, SIGNAL(valueChanged(const QString&)), | 119 | connect(hourKey, SIGNAL(valueChanged(const QString&)), |
120 | this, SLOT(subValueChanged())); | 120 | this, SLOT(subValueChanged())); |
121 | connect(ampm, SIGNAL(activated(int)), | 121 | connect(ampm, SIGNAL(activated(int)), |
122 | this, SLOT(subValueChanged())); | 122 | this, SLOT(subValueChanged())); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | TimeEdit::~TimeEdit() {} | 126 | TimeEdit::~TimeEdit() {} |
127 | 127 | ||
128 | QTime TimeEdit::time() const | 128 | QTime TimeEdit::time() const |
129 | { | 129 | { |
130 | int s,m,h; | 130 | int s,m,h; |
131 | 131 | ||
132 | s = secondKey->text().toInt(); | 132 | s = secondKey->text().toInt(); |
133 | m = minuteKey->text().toInt(); | 133 | m = minuteKey->text().toInt(); |
134 | h = hourKey->text().toInt(); | 134 | h = hourKey->text().toInt(); |
135 | 135 | ||
136 | if(ampm->currentItem() == 1) { | 136 | if(ampm->currentItem() == 1) { |
diff --git a/noncore/apps/tableviewer/ui/tvbrowseview.cpp b/noncore/apps/tableviewer/ui/tvbrowseview.cpp index 22bac55..8a65ed1 100644 --- a/noncore/apps/tableviewer/ui/tvbrowseview.cpp +++ b/noncore/apps/tableviewer/ui/tvbrowseview.cpp | |||
@@ -1,123 +1,123 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "tvbrowseview.h" | 20 | #include "tvbrowseview.h" |
21 | #include "browsekeyentry.h" | 21 | #include "browsekeyentry.h" |
22 | #include <qtoolbutton.h> | 22 | #include <qtoolbutton.h> |
23 | #include <qtextview.h> | 23 | #include <qtextview.h> |
24 | #include <qtextbrowser.h> | 24 | #include <qtextbrowser.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include "../xmlencodeattr.h" | 26 | #include "../xmlencodeattr.h" |
27 | 27 | ||
28 | /*! | 28 | /*! |
29 | \class TVBrowseView | 29 | \class TVBrowseView |
30 | \brief The widget describing how to draw the browse view user interface | 30 | \brief The widget describing how to draw the browse view user interface |
31 | 31 | ||
32 | This widget allows for the user to browse through the table, one element | 32 | This widget allows for the user to browse through the table, one element |
33 | at a time, or search on a single key. Its main goal is to show a | 33 | at a time, or search on a single key. Its main goal is to show a |
34 | single element in a readable format and make it easy for the user to | 34 | single element in a readable format and make it easy for the user to |
35 | rapidly find specific elements in the table. | 35 | rapidly find specific elements in the table. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | /*! | 38 | /*! |
39 | Constructs a new TVBrowseView widget | 39 | Constructs a new TVBrowseView widget |
40 | */ | 40 | */ |
41 | TVBrowseView::TVBrowseView(TableState *t, QWidget* parent, const char *name, | 41 | TVBrowseView::TVBrowseView(TableState *t, QWidget* parent, const char *name, |
42 | WFlags fl ) | 42 | WFlags fl ) |
43 | { | 43 | { |
44 | if (!name) | 44 | if (!name) |
45 | setName("BrowseView"); | 45 | setName("BrowseView"); |
46 | 46 | ||
47 | // setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) ); | 47 | // setSizePolicy(QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding, 0, 0, sizePolicy().hasHeightForWidth() ) ); |
48 | QVBoxLayout *vlayout = new QVBoxLayout(this); | 48 | QVBoxLayout *vlayout = new QVBoxLayout(this); |
49 | textViewDisplay = new QTextBrowser(this, "textViewDisplay"); | 49 | textViewDisplay = new QTextBrowser(this, "textViewDisplay"); |
50 | vlayout->addWidget( textViewDisplay ); | 50 | vlayout->addWidget( textViewDisplay ); |
51 | 51 | ||
52 | keyEntry = new TVBrowseKeyEntry(this, "keyEntry"); | 52 | keyEntry = new TVBrowseKeyEntry(this, "keyEntry"); |
53 | vlayout->addWidget( keyEntry ); | 53 | vlayout->addWidget( keyEntry ); |
54 | 54 | ||
55 | /* connect the signals down */ | 55 | /* connect the signals down */ |
56 | 56 | ||
57 | connect(keyEntry, SIGNAL(searchOnKey(int, TVVariant)), | 57 | connect(keyEntry, SIGNAL(searchOnKey(int,TVVariant)), |
58 | this, SIGNAL(searchOnKey(int, TVVariant))); | 58 | this, SIGNAL(searchOnKey(int,TVVariant))); |
59 | connect(keyEntry, SIGNAL(sortChanged(int)), | 59 | connect(keyEntry, SIGNAL(sortChanged(int)), |
60 | this, SIGNAL(sortChanged(int))); | 60 | this, SIGNAL(sortChanged(int))); |
61 | 61 | ||
62 | ts = t; | 62 | ts = t; |
63 | keyEntry->setTableState(t); | 63 | keyEntry->setTableState(t); |
64 | } | 64 | } |
65 | 65 | ||
66 | /*! | 66 | /*! |
67 | Destroys the TVBrowseView widget | 67 | Destroys the TVBrowseView widget |
68 | */ | 68 | */ |
69 | TVBrowseView::~TVBrowseView() | 69 | TVBrowseView::~TVBrowseView() |
70 | { | 70 | { |
71 | } | 71 | } |
72 | 72 | ||
73 | void TVBrowseView::rebuildData() | 73 | void TVBrowseView::rebuildData() |
74 | { | 74 | { |
75 | if(!ts) | 75 | if(!ts) |
76 | return; | 76 | return; |
77 | if(!ts->current_elem) { | 77 | if(!ts->current_elem) { |
78 | /* also disable buttons */ | 78 | /* also disable buttons */ |
79 | textViewDisplay->setText(""); | 79 | textViewDisplay->setText(""); |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | 82 | ||
83 | setDisplayText(ts->current_elem); | 83 | setDisplayText(ts->current_elem); |
84 | } | 84 | } |
85 | 85 | ||
86 | /* Reset to initial state */ | 86 | /* Reset to initial state */ |
87 | void TVBrowseView::reset() | 87 | void TVBrowseView::reset() |
88 | { | 88 | { |
89 | textViewDisplay->setText(""); | 89 | textViewDisplay->setText(""); |
90 | keyEntry->reset(); | 90 | keyEntry->reset(); |
91 | } | 91 | } |
92 | 92 | ||
93 | /*! | 93 | /*! |
94 | sets the data element to be displayed to element | 94 | sets the data element to be displayed to element |
95 | */ | 95 | */ |
96 | void TVBrowseView::setDisplayText(const DataElem *element) | 96 | void TVBrowseView::setDisplayText(const DataElem *element) |
97 | { | 97 | { |
98 | QString rep = ""; | 98 | QString rep = ""; |
99 | 99 | ||
100 | KeyListIterator it(*ts->kRep); | 100 | KeyListIterator it(*ts->kRep); |
101 | 101 | ||
102 | while (it.current()) { | 102 | while (it.current()) { |
103 | if (element->hasValidValue(it.currentKey())) { | 103 | if (element->hasValidValue(it.currentKey())) { |
104 | if(it.currentKey() == ts->current_column) { | 104 | if(it.currentKey() == ts->current_column) { |
105 | rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>" | 105 | rep += "<A name=\"ckey\"></A><B><FONT COLOR=#FF0000>" |
106 | + encodeAttr(it.current()->name()) | 106 | + encodeAttr(it.current()->name()) |
107 | + ":</FONT></B> "; | 107 | + ":</FONT></B> "; |
108 | } else { | 108 | } else { |
109 | rep += "<B>" + encodeAttr(it.current()->name()) + ":</B> "; | 109 | rep += "<B>" + encodeAttr(it.current()->name()) + ":</B> "; |
110 | } | 110 | } |
111 | rep += encodeAttr(element->toQString(it.currentKey())) + "<BR>"; | 111 | rep += encodeAttr(element->toQString(it.currentKey())) + "<BR>"; |
112 | } | 112 | } |
113 | ++it; | 113 | ++it; |
114 | } | 114 | } |
115 | 115 | ||
116 | textViewDisplay->setText(rep); | 116 | textViewDisplay->setText(rep); |
117 | textViewDisplay->scrollToAnchor("ckey"); | 117 | textViewDisplay->scrollToAnchor("ckey"); |
118 | } | 118 | } |
119 | 119 | ||
120 | void TVBrowseView::rebuildKeys() | 120 | void TVBrowseView::rebuildKeys() |
121 | { | 121 | { |
122 | keyEntry->rebuildKeys(); | 122 | keyEntry->rebuildKeys(); |
123 | } | 123 | } |
diff --git a/noncore/apps/tableviewer/ui/tvfilterview.cpp b/noncore/apps/tableviewer/ui/tvfilterview.cpp index b03e846..22f1fb7 100644 --- a/noncore/apps/tableviewer/ui/tvfilterview.cpp +++ b/noncore/apps/tableviewer/ui/tvfilterview.cpp | |||
@@ -1,188 +1,188 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "tvfilterview.h" | 20 | #include "tvfilterview.h" |
21 | #include <qtoolbutton.h> | 21 | #include <qtoolbutton.h> |
22 | #include <qcombobox.h> | 22 | #include <qcombobox.h> |
23 | #include <qlistview.h> | 23 | #include <qlistview.h> |
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | #include <qheader.h> | 25 | #include <qheader.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | 28 | ||
29 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | 30 | ||
31 | TVFilterView::TVFilterView(TableState *t, QWidget* parent, | 31 | TVFilterView::TVFilterView(TableState *t, QWidget* parent, |
32 | const char *name, WFlags fl ) : QDialog(parent, name, TRUE, fl) | 32 | const char *name, WFlags fl ) : QDialog(parent, name, TRUE, fl) |
33 | { | 33 | { |
34 | if ( !name ) | 34 | if ( !name ) |
35 | setName( "Filter View" ); | 35 | setName( "Filter View" ); |
36 | 36 | ||
37 | QVBoxLayout *vlayout = new QVBoxLayout(this); | 37 | QVBoxLayout *vlayout = new QVBoxLayout(this); |
38 | 38 | ||
39 | display = new QListView(this, "display"); | 39 | display = new QListView(this, "display"); |
40 | display->addColumn("Key"); | 40 | display->addColumn("Key"); |
41 | display->addColumn("Constraint"); | 41 | display->addColumn("Constraint"); |
42 | display->addColumn("Value"); | 42 | display->addColumn("Value"); |
43 | display->header()->setClickEnabled(FALSE); | 43 | display->header()->setClickEnabled(FALSE); |
44 | display->header()->setResizeEnabled(FALSE); | 44 | display->header()->setResizeEnabled(FALSE); |
45 | 45 | ||
46 | vlayout->addWidget(display); | 46 | vlayout->addWidget(display); |
47 | 47 | ||
48 | QHBoxLayout *hlayout = new QHBoxLayout; | 48 | QHBoxLayout *hlayout = new QHBoxLayout; |
49 | hlayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); | 49 | hlayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum)); |
50 | 50 | ||
51 | newFilterButton = new QPushButton(this, "new Filter"); | 51 | newFilterButton = new QPushButton(this, "new Filter"); |
52 | newFilterButton->setMaximumSize(QSize(50, 32767)); | 52 | newFilterButton->setMaximumSize(QSize(50, 32767)); |
53 | newFilterButton->setText("New"); | 53 | newFilterButton->setText("New"); |
54 | hlayout->addWidget(newFilterButton); | 54 | hlayout->addWidget(newFilterButton); |
55 | 55 | ||
56 | deleteFilterButton = new QPushButton(this, "delete Filter"); | 56 | deleteFilterButton = new QPushButton(this, "delete Filter"); |
57 | deleteFilterButton->setMaximumSize(QSize(50, 32767)); | 57 | deleteFilterButton->setMaximumSize(QSize(50, 32767)); |
58 | deleteFilterButton->setText("Delete"); | 58 | deleteFilterButton->setText("Delete"); |
59 | hlayout->addWidget(deleteFilterButton); | 59 | hlayout->addWidget(deleteFilterButton); |
60 | 60 | ||
61 | clearFilterButton = new QPushButton(this, "delete Filter"); | 61 | clearFilterButton = new QPushButton(this, "delete Filter"); |
62 | clearFilterButton->setMaximumSize(QSize(60, 32767)); | 62 | clearFilterButton->setMaximumSize(QSize(60, 32767)); |
63 | clearFilterButton->setText("Clear All"); | 63 | clearFilterButton->setText("Clear All"); |
64 | hlayout->addWidget(clearFilterButton); | 64 | hlayout->addWidget(clearFilterButton); |
65 | 65 | ||
66 | vlayout->addLayout(hlayout); | 66 | vlayout->addLayout(hlayout); |
67 | 67 | ||
68 | QHBoxLayout *hlayout2 = new QHBoxLayout; | 68 | QHBoxLayout *hlayout2 = new QHBoxLayout; |
69 | 69 | ||
70 | keyNameCombo = new QComboBox(FALSE, this, "key name"); | 70 | keyNameCombo = new QComboBox(FALSE, this, "key name"); |
71 | keyNameCombo->setEnabled(FALSE); | 71 | keyNameCombo->setEnabled(FALSE); |
72 | hlayout2->addWidget(keyNameCombo); | 72 | hlayout2->addWidget(keyNameCombo); |
73 | 73 | ||
74 | QLabel *label = new QLabel(this); | 74 | QLabel *label = new QLabel(this); |
75 | label->setText("has value"); | 75 | label->setText("has value"); |
76 | hlayout2->addWidget(label); | 76 | hlayout2->addWidget(label); |
77 | 77 | ||
78 | keyEntry = new TVFilterKeyEntry(this, "key entry"); | 78 | keyEntry = new TVFilterKeyEntry(this, "key entry"); |
79 | keyEntry->setEnabled(FALSE); | 79 | keyEntry->setEnabled(FALSE); |
80 | 80 | ||
81 | vlayout->addLayout(hlayout2); | 81 | vlayout->addLayout(hlayout2); |
82 | vlayout->addWidget(keyEntry); | 82 | vlayout->addWidget(keyEntry); |
83 | 83 | ||
84 | connect(newFilterButton, SIGNAL( clicked() ), this, SLOT( newTerm() )); | 84 | connect(newFilterButton, SIGNAL( clicked() ), this, SLOT( newTerm() )); |
85 | connect(deleteFilterButton, SIGNAL( clicked() ), this, SLOT( deleteTerm())); | 85 | connect(deleteFilterButton, SIGNAL( clicked() ), this, SLOT( deleteTerm())); |
86 | connect(clearFilterButton, SIGNAL( clicked() ), this, SLOT( clearTerms())); | 86 | connect(clearFilterButton, SIGNAL( clicked() ), this, SLOT( clearTerms())); |
87 | 87 | ||
88 | connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() )); | 88 | connect(keyEntry, SIGNAL(valueChanged()), this, SLOT( updateTerm() )); |
89 | connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() )); | 89 | connect(keyNameCombo, SIGNAL(activated(int)), this, SLOT( updateTerm() )); |
90 | 90 | ||
91 | connect(display, SIGNAL(selectionChanged(QListViewItem*)), this, | 91 | connect(display, SIGNAL(selectionChanged(QListViewItem*)), this, |
92 | SLOT(setTerm(QListViewItem *))); | 92 | SLOT(setTerm(QListViewItem*))); |
93 | 93 | ||
94 | ts = t; | 94 | ts = t; |
95 | current = 0; | 95 | current = 0; |
96 | terms.setAutoDelete(true); | 96 | terms.setAutoDelete(true); |
97 | do_filter = false; | 97 | do_filter = false; |
98 | 98 | ||
99 | #ifdef Q_WS_QWS | 99 | #ifdef Q_WS_QWS |
100 | QPEApplication::showDialog( this ); | 100 | QPEApplication::showDialog( this ); |
101 | #endif | 101 | #endif |
102 | } | 102 | } |
103 | 103 | ||
104 | /*! | 104 | /*! |
105 | Destroys the TVFilterView widget | 105 | Destroys the TVFilterView widget |
106 | */ | 106 | */ |
107 | TVFilterView::~TVFilterView() | 107 | TVFilterView::~TVFilterView() |
108 | { | 108 | { |
109 | } | 109 | } |
110 | 110 | ||
111 | void TVFilterView::rebuildData() | 111 | void TVFilterView::rebuildData() |
112 | { | 112 | { |
113 | } | 113 | } |
114 | 114 | ||
115 | void TVFilterView::reset() | 115 | void TVFilterView::reset() |
116 | { | 116 | { |
117 | keyNameCombo->clear(); | 117 | keyNameCombo->clear(); |
118 | keyIds.clear(); | 118 | keyIds.clear(); |
119 | } | 119 | } |
120 | 120 | ||
121 | void TVFilterView::rebuildKeys() | 121 | void TVFilterView::rebuildKeys() |
122 | { | 122 | { |
123 | int i; | 123 | int i; |
124 | 124 | ||
125 | if (!ts) return; | 125 | if (!ts) return; |
126 | if(!ts->kRep) return; | 126 | if(!ts->kRep) return; |
127 | keyEntry->setTableState(ts); | 127 | keyEntry->setTableState(ts); |
128 | 128 | ||
129 | /* set up the list of keys that can be compared on */ | 129 | /* set up the list of keys that can be compared on */ |
130 | keyNameCombo->clear(); | 130 | keyNameCombo->clear(); |
131 | KeyListIterator it(*ts->kRep); | 131 | KeyListIterator it(*ts->kRep); |
132 | 132 | ||
133 | i = 0; | 133 | i = 0; |
134 | while(it.current()) { | 134 | while(it.current()) { |
135 | if(ts->kRep->validIndex(it.currentKey())) { | 135 | if(ts->kRep->validIndex(it.currentKey())) { |
136 | keyNameCombo->insertItem(it.current()->name()); | 136 | keyNameCombo->insertItem(it.current()->name()); |
137 | keyIds.insert(i, it.currentKey()); | 137 | keyIds.insert(i, it.currentKey()); |
138 | ++i; | 138 | ++i; |
139 | } | 139 | } |
140 | ++it; | 140 | ++it; |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | bool TVFilterView::passesFilter(DataElem *d) { | 144 | bool TVFilterView::passesFilter(DataElem *d) { |
145 | if (!filterActive()) return true; | 145 | if (!filterActive()) return true; |
146 | 146 | ||
147 | 147 | ||
148 | FilterTerm *t; | 148 | FilterTerm *t; |
149 | 149 | ||
150 | for (t = terms.first(); t != 0; t = terms.next() ) { | 150 | for (t = terms.first(); t != 0; t = terms.next() ) { |
151 | /* check against filter */ | 151 | /* check against filter */ |
152 | switch(t->ct) { | 152 | switch(t->ct) { |
153 | case ct_less: | 153 | case ct_less: |
154 | if (!d->lessThan(t->keyIndex, t->value)) | 154 | if (!d->lessThan(t->keyIndex, t->value)) |
155 | return false; | 155 | return false; |
156 | break; | 156 | break; |
157 | case ct_more: | 157 | case ct_more: |
158 | if (!d->moreThan(t->keyIndex, t->value)) | 158 | if (!d->moreThan(t->keyIndex, t->value)) |
159 | return false; | 159 | return false; |
160 | break; | 160 | break; |
161 | case ct_equal: | 161 | case ct_equal: |
162 | if (!d->equalTo(t->keyIndex, t->value)) | 162 | if (!d->equalTo(t->keyIndex, t->value)) |
163 | return false; | 163 | return false; |
164 | break; | 164 | break; |
165 | case ct_contains: | 165 | case ct_contains: |
166 | if (!d->contains(t->keyIndex, t->value)) | 166 | if (!d->contains(t->keyIndex, t->value)) |
167 | return false; | 167 | return false; |
168 | break; | 168 | break; |
169 | case ct_startswith: | 169 | case ct_startswith: |
170 | if (!d->startsWith(t->keyIndex, t->value)) | 170 | if (!d->startsWith(t->keyIndex, t->value)) |
171 | return false; | 171 | return false; |
172 | break; | 172 | break; |
173 | case ct_endswith: | 173 | case ct_endswith: |
174 | if (!d->endsWith(t->keyIndex, t->value)) | 174 | if (!d->endsWith(t->keyIndex, t->value)) |
175 | return false; | 175 | return false; |
176 | break; | 176 | break; |
177 | default: | 177 | default: |
178 | qWarning("TVFilterView::passesFilter() " | 178 | qWarning("TVFilterView::passesFilter() " |
179 | "unrecognized filter type"); | 179 | "unrecognized filter type"); |
180 | return false; | 180 | return false; |
181 | } | 181 | } |
182 | } | 182 | } |
183 | return true; | 183 | return true; |
184 | } | 184 | } |
185 | 185 | ||
186 | bool TVFilterView::filterActive() const | 186 | bool TVFilterView::filterActive() const |
187 | { | 187 | { |
188 | /* when button operated, also check the do_filter value | 188 | /* when button operated, also check the do_filter value |
diff --git a/noncore/apps/tableviewer/ui/tvlistview.cpp b/noncore/apps/tableviewer/ui/tvlistview.cpp index b25e813..b10ff1d 100644 --- a/noncore/apps/tableviewer/ui/tvlistview.cpp +++ b/noncore/apps/tableviewer/ui/tvlistview.cpp | |||
@@ -11,194 +11,194 @@ | |||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "tvlistview.h" | 20 | #include "tvlistview.h" |
21 | #include "../db/common.h" | 21 | #include "../db/common.h" |
22 | #include <qtoolbutton.h> | 22 | #include <qtoolbutton.h> |
23 | #include <qlistview.h> | 23 | #include <qlistview.h> |
24 | #include <qlayout.h> | 24 | #include <qlayout.h> |
25 | 25 | ||
26 | void TVListViewPrivate::setColumnWidth(int column, int width) | 26 | void TVListViewPrivate::setColumnWidth(int column, int width) |
27 | { | 27 | { |
28 | if(width > 70) width = 70; | 28 | if(width > 70) width = 70; |
29 | QListView::setColumnWidth(column, width); | 29 | QListView::setColumnWidth(column, width); |
30 | } | 30 | } |
31 | 31 | ||
32 | void TVListViewPrivate::setSorting(int column, bool increasing) | 32 | void TVListViewPrivate::setSorting(int column, bool increasing) |
33 | { | 33 | { |
34 | emit sortChanged(column); | 34 | emit sortChanged(column); |
35 | QListView::setSorting(column, increasing); | 35 | QListView::setSorting(column, increasing); |
36 | } | 36 | } |
37 | 37 | ||
38 | TVListViewPrivate::TVListViewPrivate(QWidget *parent, const char* name, | 38 | TVListViewPrivate::TVListViewPrivate(QWidget *parent, const char* name, |
39 | WFlags fl) : QListView(parent, name, fl) { | 39 | WFlags fl) : QListView(parent, name, fl) { |
40 | ; | 40 | ; |
41 | } | 41 | } |
42 | 42 | ||
43 | class TVListViewItem : public QListViewItem | 43 | class TVListViewItem : public QListViewItem |
44 | { | 44 | { |
45 | public: | 45 | public: |
46 | 46 | ||
47 | TVListViewItem(QListView *parent, DataElem *d); | 47 | TVListViewItem(QListView *parent, DataElem *d); |
48 | ~TVListViewItem(); | 48 | ~TVListViewItem(); |
49 | 49 | ||
50 | QString text(int i) const | 50 | QString text(int i) const |
51 | { | 51 | { |
52 | return data_reference->toQString(i); | 52 | return data_reference->toQString(i); |
53 | } | 53 | } |
54 | 54 | ||
55 | /* Do nothing... all data for this item should be generated */ | 55 | /* Do nothing... all data for this item should be generated */ |
56 | void setText(int i, const QString &) | 56 | void setText(int i, const QString &) |
57 | { | 57 | { |
58 | ; | 58 | ; |
59 | } | 59 | } |
60 | QString key(int i, bool a) const | 60 | QString key(int i, bool a) const |
61 | { | 61 | { |
62 | return data_reference->toSortableQString(i); | 62 | return data_reference->toSortableQString(i); |
63 | } | 63 | } |
64 | 64 | ||
65 | void setDataElem(DataElem *d) | 65 | void setDataElem(DataElem *d) |
66 | { | 66 | { |
67 | data_reference = d; | 67 | data_reference = d; |
68 | } | 68 | } |
69 | 69 | ||
70 | DataElem *getDataElem() { | 70 | DataElem *getDataElem() { |
71 | return data_reference; | 71 | return data_reference; |
72 | } | 72 | } |
73 | private: | 73 | private: |
74 | DataElem *data_reference; | 74 | DataElem *data_reference; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | TVListViewItem::TVListViewItem(QListView *parent, DataElem *d) | 77 | TVListViewItem::TVListViewItem(QListView *parent, DataElem *d) |
78 | : QListViewItem(parent) | 78 | : QListViewItem(parent) |
79 | { | 79 | { |
80 | data_reference = d; | 80 | data_reference = d; |
81 | } | 81 | } |
82 | 82 | ||
83 | TVListViewItem::~TVListViewItem() | 83 | TVListViewItem::~TVListViewItem() |
84 | { | 84 | { |
85 | data_reference = 0; | 85 | data_reference = 0; |
86 | } | 86 | } |
87 | 87 | ||
88 | TVListView::TVListView(TableState *t, QWidget* parent, | 88 | TVListView::TVListView(TableState *t, QWidget* parent, |
89 | const char *name, WFlags fl ) : QWidget(parent, name, fl) | 89 | const char *name, WFlags fl ) : QWidget(parent, name, fl) |
90 | { | 90 | { |
91 | if (!name) | 91 | if (!name) |
92 | setName("TVListView"); | 92 | setName("TVListView"); |
93 | 93 | ||
94 | // the next two lines need to be rationalized. | 94 | // the next two lines need to be rationalized. |
95 | resize(318,457); | 95 | resize(318,457); |
96 | setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, | 96 | setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, |
97 | (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); | 97 | (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); |
98 | setCaption(tr("List View")); | 98 | setCaption(tr("List View")); |
99 | 99 | ||
100 | QVBoxLayout *layout = new QVBoxLayout(this); | 100 | QVBoxLayout *layout = new QVBoxLayout(this); |
101 | layout->setSpacing(0); | 101 | layout->setSpacing(0); |
102 | layout->setMargin(0); | 102 | layout->setMargin(0); |
103 | 103 | ||
104 | listViewDisplay = new TVListViewPrivate(this, "listViewDisplay"); | 104 | listViewDisplay = new TVListViewPrivate(this, "listViewDisplay"); |
105 | layout->addWidget(listViewDisplay); | 105 | layout->addWidget(listViewDisplay); |
106 | 106 | ||
107 | connect(listViewDisplay, SIGNAL(currentChanged(QListViewItem *)), this, | 107 | connect(listViewDisplay, SIGNAL(currentChanged(QListViewItem*)), this, |
108 | SLOT(setCurrent(QListViewItem *))); | 108 | SLOT(setCurrent(QListViewItem*))); |
109 | connect(listViewDisplay, SIGNAL(sortChanged(int)), this, | 109 | connect(listViewDisplay, SIGNAL(sortChanged(int)), this, |
110 | SLOT(setSorting(int))); | 110 | SLOT(setSorting(int))); |
111 | 111 | ||
112 | listViewDisplay->setShowSortIndicator(true); | 112 | listViewDisplay->setShowSortIndicator(true); |
113 | 113 | ||
114 | it = new QListViewItemIterator(listViewDisplay); | 114 | it = new QListViewItemIterator(listViewDisplay); |
115 | ts = t; | 115 | ts = t; |
116 | } | 116 | } |
117 | 117 | ||
118 | TVListView::~TVListView() | 118 | TVListView::~TVListView() |
119 | { | 119 | { |
120 | } | 120 | } |
121 | 121 | ||
122 | void TVListView::addItem(DataElem *d) | 122 | void TVListView::addItem(DataElem *d) |
123 | { | 123 | { |
124 | TVListViewItem *i = new TVListViewItem(listViewDisplay, d); | 124 | TVListViewItem *i = new TVListViewItem(listViewDisplay, d); |
125 | 125 | ||
126 | delete it; | 126 | delete it; |
127 | it = new QListViewItemIterator(i); | 127 | it = new QListViewItemIterator(i); |
128 | } | 128 | } |
129 | 129 | ||
130 | /* remove current (it) item */ | 130 | /* remove current (it) item */ |
131 | void TVListView::removeItem() | 131 | void TVListView::removeItem() |
132 | { | 132 | { |
133 | QListViewItemIterator other(*it); | 133 | QListViewItemIterator other(*it); |
134 | 134 | ||
135 | QListViewItemIterator tmp = *it; | 135 | QListViewItemIterator tmp = *it; |
136 | (*it)++; | 136 | (*it)++; |
137 | if (!it->current()) { | 137 | if (!it->current()) { |
138 | *it = tmp; | 138 | *it = tmp; |
139 | (*it)--; | 139 | (*it)--; |
140 | if (!it->current()) { | 140 | if (!it->current()) { |
141 | delete it; | 141 | delete it; |
142 | it = 0; | 142 | it = 0; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | delete other.current(); | 146 | delete other.current(); |
147 | } | 147 | } |
148 | 148 | ||
149 | void TVListView::clearItems() | 149 | void TVListView::clearItems() |
150 | { | 150 | { |
151 | /* This is ok since the destructor for TVListItem does not know about | 151 | /* This is ok since the destructor for TVListItem does not know about |
152 | the data_reference pointer.. and hence will leave it alone */ | 152 | the data_reference pointer.. and hence will leave it alone */ |
153 | listViewDisplay->clear(); | 153 | listViewDisplay->clear(); |
154 | delete it; | 154 | delete it; |
155 | it = new QListViewItemIterator(listViewDisplay); | 155 | it = new QListViewItemIterator(listViewDisplay); |
156 | } | 156 | } |
157 | 157 | ||
158 | void TVListView::first() | 158 | void TVListView::first() |
159 | { | 159 | { |
160 | delete it; | 160 | delete it; |
161 | it = new QListViewItemIterator(listViewDisplay); | 161 | it = new QListViewItemIterator(listViewDisplay); |
162 | } | 162 | } |
163 | 163 | ||
164 | void TVListView::last() | 164 | void TVListView::last() |
165 | { | 165 | { |
166 | qWarning("TVListView::last not yet implemented"); | 166 | qWarning("TVListView::last not yet implemented"); |
167 | } | 167 | } |
168 | 168 | ||
169 | void TVListView::next() | 169 | void TVListView::next() |
170 | { | 170 | { |
171 | QListViewItemIterator tmp = *it; | 171 | QListViewItemIterator tmp = *it; |
172 | (*it)++; | 172 | (*it)++; |
173 | if (!it->current()) { | 173 | if (!it->current()) { |
174 | *it = tmp; | 174 | *it = tmp; |
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | void TVListView::previous() | 178 | void TVListView::previous() |
179 | { | 179 | { |
180 | QListViewItemIterator tmp = *it; | 180 | QListViewItemIterator tmp = *it; |
181 | (*it)--; | 181 | (*it)--; |
182 | if (!it->current()) { | 182 | if (!it->current()) { |
183 | *it = tmp; | 183 | *it = tmp; |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | DataElem *TVListView::getCurrentData() { | 187 | DataElem *TVListView::getCurrentData() { |
188 | if (it->current()) { | 188 | if (it->current()) { |
189 | return ((TVListViewItem *)it->current())->getDataElem(); | 189 | return ((TVListViewItem *)it->current())->getDataElem(); |
190 | } | 190 | } |
191 | return NULL; | 191 | return NULL; |
192 | } | 192 | } |
193 | 193 | ||
194 | /*! Now to implement the closest match function */ | 194 | /*! Now to implement the closest match function */ |
195 | void TVListView::findItem(int keyId, TVVariant value) | 195 | void TVListView::findItem(int keyId, TVVariant value) |
196 | { | 196 | { |
197 | QListViewItem *i; | 197 | QListViewItem *i; |
198 | TVListViewItem *best_so_far = NULL; | 198 | TVListViewItem *best_so_far = NULL; |
199 | /* start at the beginning... go through till find the closest elem */ | 199 | /* start at the beginning... go through till find the closest elem */ |
200 | i = listViewDisplay->firstChild(); | 200 | i = listViewDisplay->firstChild(); |
201 | while (i) { | 201 | while (i) { |
202 | /* search stuff */ | 202 | /* search stuff */ |
203 | if(best_so_far) { | 203 | if(best_so_far) { |
204 | if (DataElem::closer( | 204 | if (DataElem::closer( |
diff --git a/noncore/apps/tinykate/libkate/document/katedialogs.cpp b/noncore/apps/tinykate/libkate/document/katedialogs.cpp index 2f0ed7b..f4edd7e 100644 --- a/noncore/apps/tinykate/libkate/document/katedialogs.cpp +++ b/noncore/apps/tinykate/libkate/document/katedialogs.cpp | |||
@@ -1,162 +1,162 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | katedialogs.cpp - description | 2 | katedialogs.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | copyright : (C) 2001 by The Kate Team | 4 | copyright : (C) 2001 by The Kate Team |
5 | (C) 2002 by Joseph Wenninger | 5 | (C) 2002 by Joseph Wenninger |
6 | email : kwrite-devel@kde.org | 6 | email : kwrite-devel@kde.org |
7 | jowenn@kde.org | 7 | jowenn@kde.org |
8 | 8 | ||
9 | ***************************************************************************/ | 9 | ***************************************************************************/ |
10 | 10 | ||
11 | /*************************************************************************** | 11 | /*************************************************************************** |
12 | * * | 12 | * * |
13 | * This program is free software; you can redistribute it and/or modify * | 13 | * This program is free software; you can redistribute it and/or modify * |
14 | * it under the terms of the GNU General Public License as published by * | 14 | * it under the terms of the GNU General Public License as published by * |
15 | * the Free Software Foundation; either version 2 of the License, or * | 15 | * the Free Software Foundation; either version 2 of the License, or * |
16 | * (at your option) any later version. * | 16 | * (at your option) any later version. * |
17 | * * | 17 | * * |
18 | ***************************************************************************/ | 18 | ***************************************************************************/ |
19 | #include "katedialogs.h" | 19 | #include "katedialogs.h" |
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | #include <qgroupbox.h> | 22 | #include <qgroupbox.h> |
23 | #include <qvgroupbox.h> | 23 | #include <qvgroupbox.h> |
24 | #include <qhgroupbox.h> | 24 | #include <qhgroupbox.h> |
25 | #include <qhbox.h> | 25 | #include <qhbox.h> |
26 | #include <qvbox.h> | 26 | #include <qvbox.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qwidgetstack.h> | 29 | #include <qwidgetstack.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qlistview.h> | 31 | #include <qlistview.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | //FIXME #include <kcharsets.h> | 35 | //FIXME #include <kcharsets.h> |
36 | #include <kglobal.h> | 36 | #include <kglobal.h> |
37 | #include <qmap.h> | 37 | #include <qmap.h> |
38 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
39 | #include <kstddirs.h> | 39 | #include <kstddirs.h> |
40 | 40 | ||
41 | 41 | ||
42 | /******************************************************************************************************************* | 42 | /******************************************************************************************************************* |
43 | * Context Editor * | 43 | * Context Editor * |
44 | *******************************************************************************************************************/ | 44 | *******************************************************************************************************************/ |
45 | 45 | ||
46 | StyleChanger::StyleChanger( QWidget *parent ) | 46 | StyleChanger::StyleChanger( QWidget *parent ) |
47 | : QWidget(parent) | 47 | : QWidget(parent) |
48 | { | 48 | { |
49 | QLabel *label; | 49 | QLabel *label; |
50 | 50 | ||
51 | QGridLayout *glay = new QGridLayout( this, 4, 3, 0, KDialog::spacingHint() ); | 51 | QGridLayout *glay = new QGridLayout( this, 4, 3, 0, KDialog::spacingHint() ); |
52 | CHECK_PTR(glay); | 52 | CHECK_PTR(glay); |
53 | glay->addColSpacing( 1, KDialog::spacingHint() ); // Looks better | 53 | glay->addColSpacing( 1, KDialog::spacingHint() ); // Looks better |
54 | glay->setColStretch( 2, 10 ); | 54 | glay->setColStretch( 2, 10 ); |
55 | 55 | ||
56 | col = new KColorButton(this); | 56 | col = new KColorButton(this); |
57 | CHECK_PTR(col); | 57 | CHECK_PTR(col); |
58 | connect(col,SIGNAL(changed(const QColor &)),this,SLOT(changed())); | 58 | connect(col,SIGNAL(changed(const QColor&)),this,SLOT(changed())); |
59 | label = new QLabel(col,i18n("Normal:"),this); | 59 | label = new QLabel(col,i18n("Normal:"),this); |
60 | CHECK_PTR(label); | 60 | CHECK_PTR(label); |
61 | glay->addWidget(label,0,0); | 61 | glay->addWidget(label,0,0); |
62 | glay->addWidget(col,1,0); | 62 | glay->addWidget(col,1,0); |
63 | 63 | ||
64 | selCol = new KColorButton(this); | 64 | selCol = new KColorButton(this); |
65 | CHECK_PTR(selCol); | 65 | CHECK_PTR(selCol); |
66 | connect(selCol,SIGNAL(changed(const QColor &)),this,SLOT(changed())); | 66 | connect(selCol,SIGNAL(changed(const QColor&)),this,SLOT(changed())); |
67 | label = new QLabel(selCol,i18n("Selected:"),this); | 67 | label = new QLabel(selCol,i18n("Selected:"),this); |
68 | CHECK_PTR(label); | 68 | CHECK_PTR(label); |
69 | glay->addWidget(label,2,0); | 69 | glay->addWidget(label,2,0); |
70 | glay->addWidget(selCol,3,0); | 70 | glay->addWidget(selCol,3,0); |
71 | 71 | ||
72 | bold = new QCheckBox(i18n("Bold"),this); | 72 | bold = new QCheckBox(i18n("Bold"),this); |
73 | CHECK_PTR(bold); | 73 | CHECK_PTR(bold); |
74 | connect(bold,SIGNAL(clicked()),SLOT(changed())); | 74 | connect(bold,SIGNAL(clicked()),SLOT(changed())); |
75 | glay->addWidget(bold,1,2); | 75 | glay->addWidget(bold,1,2); |
76 | 76 | ||
77 | italic = new QCheckBox(i18n("Italic"),this); | 77 | italic = new QCheckBox(i18n("Italic"),this); |
78 | CHECK_PTR(italic); | 78 | CHECK_PTR(italic); |
79 | connect(italic,SIGNAL(clicked()),SLOT(changed())); | 79 | connect(italic,SIGNAL(clicked()),SLOT(changed())); |
80 | glay->addWidget(italic,2,2); | 80 | glay->addWidget(italic,2,2); |
81 | } | 81 | } |
82 | 82 | ||
83 | void StyleChanger::setRef(ItemStyle *s) { | 83 | void StyleChanger::setRef(ItemStyle *s) { |
84 | 84 | ||
85 | style = s; | 85 | style = s; |
86 | col->setColor(style->col); | 86 | col->setColor(style->col); |
87 | selCol->setColor(style->selCol); | 87 | selCol->setColor(style->selCol); |
88 | bold->setChecked(style->bold); | 88 | bold->setChecked(style->bold); |
89 | italic->setChecked(style->italic); | 89 | italic->setChecked(style->italic); |
90 | 90 | ||
91 | } | 91 | } |
92 | 92 | ||
93 | void StyleChanger::setEnabled(bool enable) { | 93 | void StyleChanger::setEnabled(bool enable) { |
94 | 94 | ||
95 | col->setEnabled(enable); | 95 | col->setEnabled(enable); |
96 | selCol->setEnabled(enable); | 96 | selCol->setEnabled(enable); |
97 | bold->setEnabled(enable); | 97 | bold->setEnabled(enable); |
98 | italic->setEnabled(enable); | 98 | italic->setEnabled(enable); |
99 | } | 99 | } |
100 | 100 | ||
101 | void StyleChanger::changed() { | 101 | void StyleChanger::changed() { |
102 | 102 | ||
103 | if (style) { | 103 | if (style) { |
104 | style->col = col->color(); | 104 | style->col = col->color(); |
105 | style->selCol = selCol->color(); | 105 | style->selCol = selCol->color(); |
106 | style->bold = bold->isChecked(); | 106 | style->bold = bold->isChecked(); |
107 | style->italic = italic->isChecked(); | 107 | style->italic = italic->isChecked(); |
108 | } | 108 | } |
109 | } | 109 | } |
110 | 110 | ||
111 | HighlightDialog::HighlightDialog( HlManager *hlManager, ItemStyleList *styleList, | 111 | HighlightDialog::HighlightDialog( HlManager *hlManager, ItemStyleList *styleList, |
112 | HlDataList *highlightDataList, | 112 | HlDataList *highlightDataList, |
113 | int hlNumber, QWidget *parent, | 113 | int hlNumber, QWidget *parent, |
114 | const char *name, bool modal ) | 114 | const char *name, bool modal ) |
115 | :KDialogBase(parent,name,modal,i18n("Highlight Settings"), Ok|Cancel, Ok) | 115 | :KDialogBase(parent,name,modal,i18n("Highlight Settings"), Ok|Cancel, Ok) |
116 | { | 116 | { |
117 | // QVBox *page = makeVBoxMainWidget(); | 117 | // QVBox *page = makeVBoxMainWidget(); |
118 | QFrame *page=addPage("FIXME"); | 118 | QFrame *page=addPage("FIXME"); |
119 | (new QVBoxLayout(page))->setAutoAdd(true); | 119 | (new QVBoxLayout(page))->setAutoAdd(true); |
120 | content=new HighlightDialogPage(hlManager,styleList,highlightDataList,hlNumber,page); | 120 | content=new HighlightDialogPage(hlManager,styleList,highlightDataList,hlNumber,page); |
121 | } | 121 | } |
122 | 122 | ||
123 | void HighlightDialog::done(int r) | 123 | void HighlightDialog::done(int r) |
124 | { | 124 | { |
125 | kdDebug(13010)<<"HighlightDialod done"<<endl; | 125 | kdDebug(13010)<<"HighlightDialod done"<<endl; |
126 | content->saveData(); | 126 | content->saveData(); |
127 | KDialogBase::done(r); | 127 | KDialogBase::done(r); |
128 | } | 128 | } |
129 | 129 | ||
130 | HighlightDialogPage::HighlightDialogPage(HlManager *hlManager, ItemStyleList *styleList, | 130 | HighlightDialogPage::HighlightDialogPage(HlManager *hlManager, ItemStyleList *styleList, |
131 | HlDataList* highlightDataList, | 131 | HlDataList* highlightDataList, |
132 | int hlNumber,QWidget *parent, const char *name) | 132 | int hlNumber,QWidget *parent, const char *name) |
133 | :QTabWidget(parent,name),defaultItemStyleList(styleList),hlData(0L) | 133 | :QTabWidget(parent,name),defaultItemStyleList(styleList),hlData(0L) |
134 | 134 | ||
135 | { | 135 | { |
136 | 136 | ||
137 | // defaults ========================================================= | 137 | // defaults ========================================================= |
138 | 138 | ||
139 | QFrame *page1 = new QFrame(this); | 139 | QFrame *page1 = new QFrame(this); |
140 | addTab(page1,i18n("&Defaults")); | 140 | addTab(page1,i18n("&Defaults")); |
141 | QGridLayout *grid = new QGridLayout(page1, 1, 1); | 141 | QGridLayout *grid = new QGridLayout(page1, 1, 1); |
142 | 142 | ||
143 | QVGroupBox *dvbox1 = new QVGroupBox( i18n("Default Item Styles"), page1 ); | 143 | QVGroupBox *dvbox1 = new QVGroupBox( i18n("Default Item Styles"), page1 ); |
144 | /*QLabel *label = */new QLabel( i18n("Item:"), dvbox1 ); | 144 | /*QLabel *label = */new QLabel( i18n("Item:"), dvbox1 ); |
145 | QComboBox *styleCombo = new QComboBox( false, dvbox1 ); | 145 | QComboBox *styleCombo = new QComboBox( false, dvbox1 ); |
146 | defaultStyleChanger = new StyleChanger( dvbox1 ); | 146 | defaultStyleChanger = new StyleChanger( dvbox1 ); |
147 | for( int i = 0; i < hlManager->defaultStyles(); i++ ) { | 147 | for( int i = 0; i < hlManager->defaultStyles(); i++ ) { |
148 | styleCombo->insertItem(hlManager->defaultStyleName(i)); | 148 | styleCombo->insertItem(hlManager->defaultStyleName(i)); |
149 | } | 149 | } |
150 | connect(styleCombo, SIGNAL(activated(int)), this, SLOT(defaultChanged(int))); | 150 | connect(styleCombo, SIGNAL(activated(int)), this, SLOT(defaultChanged(int))); |
151 | grid->addWidget(dvbox1, 0,0); | 151 | grid->addWidget(dvbox1, 0,0); |
152 | 152 | ||
153 | defaultChanged(0); | 153 | defaultChanged(0); |
154 | 154 | ||
155 | // highlight modes ===================================================== | 155 | // highlight modes ===================================================== |
156 | 156 | ||
157 | QFrame *page2 = new QFrame(this); | 157 | QFrame *page2 = new QFrame(this); |
158 | addTab(page2,i18n("&Highlight Modes")); | 158 | addTab(page2,i18n("&Highlight Modes")); |
159 | //grid = new QGridLayout(page2,2,2); | 159 | //grid = new QGridLayout(page2,2,2); |
160 | QVBoxLayout *bl=new QVBoxLayout(page2); | 160 | QVBoxLayout *bl=new QVBoxLayout(page2); |
161 | bl->setAutoAdd(true); | 161 | bl->setAutoAdd(true); |
162 | QHGroupBox *hbox1 = new QHGroupBox( i18n("Config Select"), page2 ); | 162 | QHGroupBox *hbox1 = new QHGroupBox( i18n("Config Select"), page2 ); |
@@ -193,193 +193,193 @@ HighlightDialogPage::HighlightDialogPage(HlManager *hlManager, ItemStyleList *st | |||
193 | 193 | ||
194 | styleDefault = new QCheckBox(i18n("Default"), vbox2 ); | 194 | styleDefault = new QCheckBox(i18n("Default"), vbox2 ); |
195 | connect(styleDefault,SIGNAL(clicked()),SLOT(changed())); | 195 | connect(styleDefault,SIGNAL(clicked()),SLOT(changed())); |
196 | styleChanger = new StyleChanger( vbox2 ); | 196 | styleChanger = new StyleChanger( vbox2 ); |
197 | 197 | ||
198 | hlDataList = highlightDataList; | 198 | hlDataList = highlightDataList; |
199 | hlChanged(hlNumber); | 199 | hlChanged(hlNumber); |
200 | } | 200 | } |
201 | 201 | ||
202 | 202 | ||
203 | void HighlightDialogPage::defaultChanged(int z) | 203 | void HighlightDialogPage::defaultChanged(int z) |
204 | { | 204 | { |
205 | defaultStyleChanger->setRef(defaultItemStyleList->at(z)); | 205 | defaultStyleChanger->setRef(defaultItemStyleList->at(z)); |
206 | } | 206 | } |
207 | 207 | ||
208 | 208 | ||
209 | void HighlightDialogPage::hlChanged(int z) | 209 | void HighlightDialogPage::hlChanged(int z) |
210 | { | 210 | { |
211 | writeback(); | 211 | writeback(); |
212 | 212 | ||
213 | hlData = hlDataList->at(z); | 213 | hlData = hlDataList->at(z); |
214 | 214 | ||
215 | wildcards->setText(hlData->wildcards); | 215 | wildcards->setText(hlData->wildcards); |
216 | mimetypes->setText(hlData->mimetypes); | 216 | mimetypes->setText(hlData->mimetypes); |
217 | 217 | ||
218 | itemCombo->clear(); | 218 | itemCombo->clear(); |
219 | for (ItemData *itemData = hlData->itemDataList.first(); itemData != 0L; | 219 | for (ItemData *itemData = hlData->itemDataList.first(); itemData != 0L; |
220 | itemData = hlData->itemDataList.next()) { | 220 | itemData = hlData->itemDataList.next()) { |
221 | kdDebug(13010) << itemData->name << endl; | 221 | kdDebug(13010) << itemData->name << endl; |
222 | itemCombo->insertItem(i18n(itemData->name.latin1())); | 222 | itemCombo->insertItem(i18n(itemData->name.latin1())); |
223 | } | 223 | } |
224 | 224 | ||
225 | itemChanged(0); | 225 | itemChanged(0); |
226 | } | 226 | } |
227 | 227 | ||
228 | void HighlightDialogPage::itemChanged(int z) | 228 | void HighlightDialogPage::itemChanged(int z) |
229 | { | 229 | { |
230 | itemData = hlData->itemDataList.at(z); | 230 | itemData = hlData->itemDataList.at(z); |
231 | 231 | ||
232 | styleDefault->setChecked(itemData->defStyle); | 232 | styleDefault->setChecked(itemData->defStyle); |
233 | styleChanger->setRef(itemData); | 233 | styleChanger->setRef(itemData); |
234 | } | 234 | } |
235 | 235 | ||
236 | void HighlightDialogPage::changed() | 236 | void HighlightDialogPage::changed() |
237 | { | 237 | { |
238 | itemData->defStyle = styleDefault->isChecked(); | 238 | itemData->defStyle = styleDefault->isChecked(); |
239 | } | 239 | } |
240 | 240 | ||
241 | void HighlightDialogPage::writeback() { | 241 | void HighlightDialogPage::writeback() { |
242 | if (hlData) { | 242 | if (hlData) { |
243 | hlData->wildcards = wildcards->text(); | 243 | hlData->wildcards = wildcards->text(); |
244 | hlData->mimetypes = mimetypes->text(); | 244 | hlData->mimetypes = mimetypes->text(); |
245 | } | 245 | } |
246 | } | 246 | } |
247 | 247 | ||
248 | void HighlightDialogPage::saveData() { | 248 | void HighlightDialogPage::saveData() { |
249 | kdDebug(13010)<<"HighlightDialogPage::saveData()"<<endl; | 249 | kdDebug(13010)<<"HighlightDialogPage::saveData()"<<endl; |
250 | writeback(); | 250 | writeback(); |
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | void HighlightDialogPage::hlEdit() { | 254 | void HighlightDialogPage::hlEdit() { |
255 | HlEditDialog diag(0,0,"hlEdit", true,hlData); | 255 | HlEditDialog diag(0,0,"hlEdit", true,hlData); |
256 | diag.show(); | 256 | diag.show(); |
257 | } | 257 | } |
258 | 258 | ||
259 | void HighlightDialogPage::hlNew() { | 259 | void HighlightDialogPage::hlNew() { |
260 | HlEditDialog diag(0,0,"hlEdit",true,0); | 260 | HlEditDialog diag(0,0,"hlEdit",true,0); |
261 | diag.show(); | 261 | diag.show(); |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | HlEditDialog::HlEditDialog(HlManager *,QWidget *parent, const char *name, bool modal,HlData *data) | 265 | HlEditDialog::HlEditDialog(HlManager *,QWidget *parent, const char *name, bool modal,HlData *data) |
266 | :KDialogBase(KDialogBase::Swallow, i18n("Highlight Conditions"), Ok|Cancel, Ok, parent, name, modal) | 266 | :KDialogBase(KDialogBase::Swallow, i18n("Highlight Conditions"), Ok|Cancel, Ok, parent, name, modal) |
267 | { | 267 | { |
268 | currentItem=0; | 268 | currentItem=0; |
269 | transTableCnt=0; | 269 | transTableCnt=0; |
270 | QHBox *wid=new QHBox(this); | 270 | QHBox *wid=new QHBox(this); |
271 | QVBox *lbox=new QVBox(wid); | 271 | QVBox *lbox=new QVBox(wid); |
272 | contextList=new KListView(lbox); | 272 | contextList=new KListView(lbox); |
273 | contextList->setRootIsDecorated(true); | 273 | contextList->setRootIsDecorated(true); |
274 | contextList->addColumn(i18n("Syntax structure")); | 274 | contextList->addColumn(i18n("Syntax structure")); |
275 | contextList->setSorting(-1); | 275 | contextList->setSorting(-1); |
276 | QHBox *bbox=new QHBox(lbox); | 276 | QHBox *bbox=new QHBox(lbox); |
277 | QPushButton *addContext=new QPushButton(i18n("New Context"),bbox); | 277 | QPushButton *addContext=new QPushButton(i18n("New Context"),bbox); |
278 | QPushButton *addItem=new QPushButton(i18n("New Item"),bbox); | 278 | QPushButton *addItem=new QPushButton(i18n("New Item"),bbox); |
279 | QVGroupBox *opt = new QVGroupBox( i18n("Options"), wid); | 279 | QVGroupBox *opt = new QVGroupBox( i18n("Options"), wid); |
280 | stack=new QWidgetStack(opt); | 280 | stack=new QWidgetStack(opt); |
281 | initContextOptions(contextOptions=new QVBox(stack)); | 281 | initContextOptions(contextOptions=new QVBox(stack)); |
282 | stack->addWidget(contextOptions,HlEContext); | 282 | stack->addWidget(contextOptions,HlEContext); |
283 | initItemOptions(itemOptions=new QVBox(stack)); | 283 | initItemOptions(itemOptions=new QVBox(stack)); |
284 | stack->addWidget(itemOptions,HlEItem); | 284 | stack->addWidget(itemOptions,HlEItem); |
285 | stack->raiseWidget(HlEContext); | 285 | stack->raiseWidget(HlEContext); |
286 | setMainWidget(wid); | 286 | setMainWidget(wid); |
287 | if (data!=0) loadFromDocument(data); | 287 | if (data!=0) loadFromDocument(data); |
288 | else newDocument(); | 288 | else newDocument(); |
289 | connect(contextList,SIGNAL(currentChanged( QListViewItem*)),this,SLOT(currentSelectionChanged ( QListViewItem * ))); | 289 | connect(contextList,SIGNAL(currentChanged(QListViewItem*)),this,SLOT(currentSelectionChanged(QListViewItem*))); |
290 | connect(addContext,SIGNAL(clicked()),this,SLOT(contextAddNew())); | 290 | connect(addContext,SIGNAL(clicked()),this,SLOT(contextAddNew())); |
291 | connect(addItem,SIGNAL(clicked()),this,SLOT(ItemAddNew())); | 291 | connect(addItem,SIGNAL(clicked()),this,SLOT(ItemAddNew())); |
292 | } | 292 | } |
293 | 293 | ||
294 | void HlEditDialog::newDocument() | 294 | void HlEditDialog::newDocument() |
295 | { | 295 | { |
296 | KStandardDirs *dirs = KGlobal::dirs(); | 296 | KStandardDirs *dirs = KGlobal::dirs(); |
297 | QStringList list=dirs->findAllResources("data","kate/syntax/syntax.template",false,true); | 297 | QStringList list=dirs->findAllResources("data","kate/syntax/syntax.template",false,true); |
298 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 298 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
299 | { | 299 | { |
300 | HlData data("","",*it); | 300 | HlData data("","",*it); |
301 | loadFromDocument(&data); | 301 | loadFromDocument(&data); |
302 | return; | 302 | return; |
303 | } | 303 | } |
304 | KMessageBox::error(this,i18n("Can't find template file")); | 304 | KMessageBox::error(this,i18n("Can't find template file")); |
305 | } | 305 | } |
306 | 306 | ||
307 | 307 | ||
308 | void HlEditDialog::initContextOptions(QVBox *co) | 308 | void HlEditDialog::initContextOptions(QVBox *co) |
309 | { | 309 | { |
310 | if( co!=0) | 310 | if( co!=0) |
311 | { | 311 | { |
312 | QHBox *tmp = new QHBox(co); | 312 | QHBox *tmp = new QHBox(co); |
313 | (void) new QLabel(i18n("Description:"),tmp); | 313 | (void) new QLabel(i18n("Description:"),tmp); |
314 | ContextDescr=new QLineEdit(tmp); | 314 | ContextDescr=new QLineEdit(tmp); |
315 | tmp= new QHBox(co); | 315 | tmp= new QHBox(co); |
316 | (void) new QLabel(i18n("Attribute:"),tmp); | 316 | (void) new QLabel(i18n("Attribute:"),tmp); |
317 | ContextAttribute=new QComboBox(tmp); | 317 | ContextAttribute=new QComboBox(tmp); |
318 | tmp= new QHBox(co); | 318 | tmp= new QHBox(co); |
319 | (void) new QLabel(i18n("LineEnd:"),tmp); | 319 | (void) new QLabel(i18n("LineEnd:"),tmp); |
320 | ContextLineEnd = new QComboBox(tmp); | 320 | ContextLineEnd = new QComboBox(tmp); |
321 | connect(ContextDescr,SIGNAL(textChanged(const QString&)),this,SLOT(contextDescrChanged(const QString&))); | 321 | connect(ContextDescr,SIGNAL(textChanged(const QString&)),this,SLOT(contextDescrChanged(const QString&))); |
322 | connect(ContextLineEnd,SIGNAL(activated(int)),this,SLOT(contextLineEndChanged(int))); | 322 | connect(ContextLineEnd,SIGNAL(activated(int)),this,SLOT(contextLineEndChanged(int))); |
323 | connect(ContextAttribute,SIGNAL(activated(int)),this,SLOT(contextAttributeChanged(int))); | 323 | connect(ContextAttribute,SIGNAL(activated(int)),this,SLOT(contextAttributeChanged(int))); |
324 | } | 324 | } |
325 | else | 325 | else |
326 | kdDebug(13010)<<"initContextOptions: Widget is 0"<<endl; | 326 | kdDebug(13010)<<"initContextOptions: Widget is 0"<<endl; |
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | void HlEditDialog::insertTranslationList(QString tag, QString trans,int length) | 330 | void HlEditDialog::insertTranslationList(QString tag, QString trans,int length) |
331 | { | 331 | { |
332 | ItemInfo data(trans,length); | 332 | ItemInfo data(trans,length); |
333 | id2tag.insert(transTableCnt,tag); | 333 | id2tag.insert(transTableCnt,tag); |
334 | id2info.insert(transTableCnt,data); | 334 | id2info.insert(transTableCnt,data); |
335 | tag2id.insert(tag,transTableCnt); | 335 | tag2id.insert(tag,transTableCnt); |
336 | transTableCnt++; | 336 | transTableCnt++; |
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | void HlEditDialog::initItemOptions(QVBox *co) | 340 | void HlEditDialog::initItemOptions(QVBox *co) |
341 | { | 341 | { |
342 | if (co!=0) | 342 | if (co!=0) |
343 | { | 343 | { |
344 | QHBox *tmp = new QHBox(co); | 344 | QHBox *tmp = new QHBox(co); |
345 | (void) new QLabel(i18n("Type:"),tmp); | 345 | (void) new QLabel(i18n("Type:"),tmp); |
346 | ItemType = new QComboBox(tmp); | 346 | ItemType = new QComboBox(tmp); |
347 | tmp= new QHBox(co); | 347 | tmp= new QHBox(co); |
348 | (void) new QLabel(i18n("Parameter:"),tmp); | 348 | (void) new QLabel(i18n("Parameter:"),tmp); |
349 | ItemParameter= new QLineEdit(tmp); | 349 | ItemParameter= new QLineEdit(tmp); |
350 | tmp= new QHBox(co); | 350 | tmp= new QHBox(co); |
351 | (void) new QLabel(i18n("Attribute:"),tmp); | 351 | (void) new QLabel(i18n("Attribute:"),tmp); |
352 | ItemAttribute= new QComboBox(tmp); | 352 | ItemAttribute= new QComboBox(tmp); |
353 | (void) new QLabel(i18n("Context switch:"),tmp); | 353 | (void) new QLabel(i18n("Context switch:"),tmp); |
354 | ItemContext = new QComboBox(tmp); | 354 | ItemContext = new QComboBox(tmp); |
355 | co->setSpacing(15); | 355 | co->setSpacing(15); |
356 | QPushButton *delItem=new QPushButton(i18n("Delete this item"),co); | 356 | QPushButton *delItem=new QPushButton(i18n("Delete this item"),co); |
357 | 357 | ||
358 | /* init translation lists */ | 358 | /* init translation lists */ |
359 | insertTranslationList("CharDetect","CharDetect",1); | 359 | insertTranslationList("CharDetect","CharDetect",1); |
360 | insertTranslationList("2CharDetect","2CharDetect",2); | 360 | insertTranslationList("2CharDetect","2CharDetect",2); |
361 | insertTranslationList("RangeDetect","RangeDetect",2); | 361 | insertTranslationList("RangeDetect","RangeDetect",2); |
362 | insertTranslationList("StringDetect","StringDetect",-1); | 362 | insertTranslationList("StringDetect","StringDetect",-1); |
363 | insertTranslationList("AnyChar","AnyChar",-1); | 363 | insertTranslationList("AnyChar","AnyChar",-1); |
364 | insertTranslationList("RegExpr","RegExpr",-1); | 364 | insertTranslationList("RegExpr","RegExpr",-1); |
365 | insertTranslationList("Int","Int",0); | 365 | insertTranslationList("Int","Int",0); |
366 | insertTranslationList("Float","Float",0); | 366 | insertTranslationList("Float","Float",0); |
367 | insertTranslationList("keyword","keyword",0); | 367 | insertTranslationList("keyword","keyword",0); |
368 | insertTranslationList("dataType","dataType",0); | 368 | insertTranslationList("dataType","dataType",0); |
369 | ItemType->clear(); | 369 | ItemType->clear(); |
370 | for (int i=0; i<transTableCnt; i++) ItemType->insertItem(id2info[i].trans_i18n); | 370 | for (int i=0; i<transTableCnt; i++) ItemType->insertItem(id2info[i].trans_i18n); |
371 | connect(ItemType,SIGNAL(activated(int)),this,SLOT(ItemTypeChanged(int))); | 371 | connect(ItemType,SIGNAL(activated(int)),this,SLOT(ItemTypeChanged(int))); |
372 | connect(ItemParameter,SIGNAL(textChanged(const QString&)),this,SLOT(ItemParameterChanged(const QString&))); | 372 | connect(ItemParameter,SIGNAL(textChanged(const QString&)),this,SLOT(ItemParameterChanged(const QString&))); |
373 | connect(ItemAttribute,SIGNAL(activated(int)),this,SLOT(ItemAttributeChanged(int))); | 373 | connect(ItemAttribute,SIGNAL(activated(int)),this,SLOT(ItemAttributeChanged(int))); |
374 | connect(ItemContext,SIGNAL(activated(int)),this,SLOT(ItemContextChanged(int))); | 374 | connect(ItemContext,SIGNAL(activated(int)),this,SLOT(ItemContextChanged(int))); |
375 | } | 375 | } |
376 | else | 376 | else |
377 | kdDebug(13010)<<"initItemOptions: Widget is 0"<<endl; | 377 | kdDebug(13010)<<"initItemOptions: Widget is 0"<<endl; |
378 | } | 378 | } |
379 | 379 | ||
380 | void HlEditDialog::loadFromDocument(HlData *hl) | 380 | void HlEditDialog::loadFromDocument(HlData *hl) |
381 | { | 381 | { |
382 | struct syntaxContextData *data; | 382 | struct syntaxContextData *data; |
383 | QListViewItem *last=0,*lastsub=0; | 383 | QListViewItem *last=0,*lastsub=0; |
384 | 384 | ||
385 | HlManager::self()->syntax->setIdentifier(hl->identifier); | 385 | HlManager::self()->syntax->setIdentifier(hl->identifier); |
diff --git a/noncore/apps/tinykate/libkate/document/katedocument.cpp b/noncore/apps/tinykate/libkate/document/katedocument.cpp index f05e21a..0c742d7 100644 --- a/noncore/apps/tinykate/libkate/document/katedocument.cpp +++ b/noncore/apps/tinykate/libkate/document/katedocument.cpp | |||
@@ -75,193 +75,193 @@ | |||
75 | #include "../view/kateview.h" | 75 | #include "../view/kateview.h" |
76 | #include "katebuffer.h" | 76 | #include "katebuffer.h" |
77 | #include "katetextline.h" | 77 | #include "katetextline.h" |
78 | 78 | ||
79 | #include "katecmd.h" | 79 | #include "katecmd.h" |
80 | 80 | ||
81 | KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text) | 81 | KateAction::KateAction(Action a, PointStruc &cursor, int len, const QString &text) |
82 | : action(a), cursor(cursor), len(len), text(text) { | 82 | : action(a), cursor(cursor), len(len), text(text) { |
83 | } | 83 | } |
84 | 84 | ||
85 | KateActionGroup::KateActionGroup(PointStruc &aStart, int type) | 85 | KateActionGroup::KateActionGroup(PointStruc &aStart, int type) |
86 | : start(aStart), action(0L), undoType(type) { | 86 | : start(aStart), action(0L), undoType(type) { |
87 | } | 87 | } |
88 | 88 | ||
89 | KateActionGroup::~KateActionGroup() { | 89 | KateActionGroup::~KateActionGroup() { |
90 | KateAction *current, *next; | 90 | KateAction *current, *next; |
91 | 91 | ||
92 | current = action; | 92 | current = action; |
93 | while (current) { | 93 | while (current) { |
94 | next = current->next; | 94 | next = current->next; |
95 | delete current; | 95 | delete current; |
96 | current = next; | 96 | current = next; |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | void KateActionGroup::insertAction(KateAction *a) { | 100 | void KateActionGroup::insertAction(KateAction *a) { |
101 | a->next = action; | 101 | a->next = action; |
102 | action = a; | 102 | action = a; |
103 | } | 103 | } |
104 | 104 | ||
105 | const char * KateActionGroup::typeName(int type) | 105 | const char * KateActionGroup::typeName(int type) |
106 | { | 106 | { |
107 | // return a short text description of the given undo group type suitable for a menu | 107 | // return a short text description of the given undo group type suitable for a menu |
108 | // not the lack of i18n's, the caller is expected to handle translation | 108 | // not the lack of i18n's, the caller is expected to handle translation |
109 | switch (type) { | 109 | switch (type) { |
110 | case ugPaste : return "Paste Text"; | 110 | case ugPaste : return "Paste Text"; |
111 | case ugDelBlock : return "Selection Overwrite"; | 111 | case ugDelBlock : return "Selection Overwrite"; |
112 | case ugIndent : return "Indent"; | 112 | case ugIndent : return "Indent"; |
113 | case ugUnindent : return "Unindent"; | 113 | case ugUnindent : return "Unindent"; |
114 | case ugComment : return "Comment"; | 114 | case ugComment : return "Comment"; |
115 | case ugUncomment : return "Uncomment"; | 115 | case ugUncomment : return "Uncomment"; |
116 | case ugReplace : return "Text Replace"; | 116 | case ugReplace : return "Text Replace"; |
117 | case ugSpell : return "Spell Check"; | 117 | case ugSpell : return "Spell Check"; |
118 | case ugInsChar : return "Typing"; | 118 | case ugInsChar : return "Typing"; |
119 | case ugDelChar : return "Delete Text"; | 119 | case ugDelChar : return "Delete Text"; |
120 | case ugInsLine : return "New Line"; | 120 | case ugInsLine : return "New Line"; |
121 | case ugDelLine : return "Delete Line"; | 121 | case ugDelLine : return "Delete Line"; |
122 | } | 122 | } |
123 | return ""; | 123 | return ""; |
124 | } | 124 | } |
125 | 125 | ||
126 | const int KateDocument::maxAttribs = 32; | 126 | const int KateDocument::maxAttribs = 32; |
127 | 127 | ||
128 | QStringList KateDocument::searchForList = QStringList(); | 128 | QStringList KateDocument::searchForList = QStringList(); |
129 | QStringList KateDocument::replaceWithList = QStringList(); | 129 | QStringList KateDocument::replaceWithList = QStringList(); |
130 | 130 | ||
131 | uint KateDocument::uniqueID = 0; | 131 | uint KateDocument::uniqueID = 0; |
132 | 132 | ||
133 | QPtrDict<KateDocument::KateDocPrivate>* KateDocument::d_ptr = 0; | 133 | QPtrDict<KateDocument::KateDocPrivate>* KateDocument::d_ptr = 0; |
134 | 134 | ||
135 | 135 | ||
136 | KateDocument::KateDocument(bool bSingleViewMode, bool bBrowserView, | 136 | KateDocument::KateDocument(bool bSingleViewMode, bool bBrowserView, |
137 | QWidget *parentWidget, const char *widgetName, | 137 | QWidget *parentWidget, const char *widgetName, |
138 | QObject *, const char *) | 138 | QObject *, const char *) |
139 | : Kate::Document (), | 139 | : Kate::Document (), |
140 | myFont(KGlobalSettings::generalFont()), myFontBold(KGlobalSettings::generalFont()), myFontItalic(KGlobalSettings::generalFont()), myFontBI(KGlobalSettings::generalFont()), | 140 | myFont(KGlobalSettings::generalFont()), myFontBold(KGlobalSettings::generalFont()), myFontItalic(KGlobalSettings::generalFont()), myFontBI(KGlobalSettings::generalFont()), |
141 | myFontMetrics (myFont), myFontMetricsBold (myFontBold), myFontMetricsItalic (myFontItalic), myFontMetricsBI (myFontBI), | 141 | myFontMetrics (myFont), myFontMetricsBold (myFontBold), myFontMetricsItalic (myFontItalic), myFontMetricsBI (myFontBI), |
142 | hlManager(HlManager::self ()) | 142 | hlManager(HlManager::self ()) |
143 | { | 143 | { |
144 | 144 | ||
145 | d(this)->hlSetByUser = false; | 145 | d(this)->hlSetByUser = false; |
146 | PreHighlightedTill=0; | 146 | PreHighlightedTill=0; |
147 | RequestPreHighlightTill=0; | 147 | RequestPreHighlightTill=0; |
148 | 148 | ||
149 | m_bSingleViewMode=bSingleViewMode; | 149 | m_bSingleViewMode=bSingleViewMode; |
150 | m_bBrowserView = bBrowserView; | 150 | m_bBrowserView = bBrowserView; |
151 | 151 | ||
152 | m_url = QString::null; | 152 | m_url = QString::null; |
153 | 153 | ||
154 | // NOTE: QFont::CharSet doesn't provide all the charsets KDE supports | 154 | // NOTE: QFont::CharSet doesn't provide all the charsets KDE supports |
155 | // (esp. it doesn't distinguish between UTF-8 and iso10646-1) | 155 | // (esp. it doesn't distinguish between UTF-8 and iso10646-1) |
156 | 156 | ||
157 | myEncoding = QString::fromLatin1(QTextCodec::codecForLocale()->name()); | 157 | myEncoding = QString::fromLatin1(QTextCodec::codecForLocale()->name()); |
158 | 158 | ||
159 | maxLength = -1; | 159 | maxLength = -1; |
160 | 160 | ||
161 | setFont (KGlobalSettings::generalFont()); | 161 | setFont (KGlobalSettings::generalFont()); |
162 | 162 | ||
163 | myDocID = uniqueID; | 163 | myDocID = uniqueID; |
164 | uniqueID++; | 164 | uniqueID++; |
165 | 165 | ||
166 | myDocName = QString (""); | 166 | myDocName = QString (""); |
167 | fileInfo = new QFileInfo (); | 167 | fileInfo = new QFileInfo (); |
168 | 168 | ||
169 | myCmd = new KateCmd (this); | 169 | myCmd = new KateCmd (this); |
170 | 170 | ||
171 | connect(this,SIGNAL(modifiedChanged ()),this,SLOT(slotModChanged ())); | 171 | connect(this,SIGNAL(modifiedChanged()),this,SLOT(slotModChanged())); |
172 | 172 | ||
173 | buffer = new KWBuffer; | 173 | buffer = new KWBuffer; |
174 | connect(buffer, SIGNAL(linesChanged(int)), this, SLOT(slotBufferChanged())); | 174 | connect(buffer, SIGNAL(linesChanged(int)), this, SLOT(slotBufferChanged())); |
175 | // connect(buffer, SIGNAL(textChanged()), this, SIGNAL(textChanged())); | 175 | // connect(buffer, SIGNAL(textChanged()), this, SIGNAL(textChanged())); |
176 | connect(buffer, SIGNAL(needHighlight(long,long)),this,SLOT(slotBufferHighlight(long,long))); | 176 | connect(buffer, SIGNAL(needHighlight(long,long)),this,SLOT(slotBufferHighlight(long,long))); |
177 | 177 | ||
178 | colors[0] = KGlobalSettings::baseColor(); | 178 | colors[0] = KGlobalSettings::baseColor(); |
179 | colors[1] = KGlobalSettings::highlightColor(); | 179 | colors[1] = KGlobalSettings::highlightColor(); |
180 | 180 | ||
181 | m_attribs = new Attribute[maxAttribs]; | 181 | m_attribs = new Attribute[maxAttribs]; |
182 | 182 | ||
183 | m_highlight = 0L; | 183 | m_highlight = 0L; |
184 | tabChars = 8; | 184 | tabChars = 8; |
185 | 185 | ||
186 | m_singleSelection = false; | 186 | m_singleSelection = false; |
187 | 187 | ||
188 | newDocGeometry = false; | 188 | newDocGeometry = false; |
189 | readOnly = false; | 189 | readOnly = false; |
190 | newDoc = false; | 190 | newDoc = false; |
191 | 191 | ||
192 | modified = false; | 192 | modified = false; |
193 | 193 | ||
194 | undoList.setAutoDelete(true); | 194 | undoList.setAutoDelete(true); |
195 | undoState = 0; | 195 | undoState = 0; |
196 | undoSteps = 50; | 196 | undoSteps = 50; |
197 | 197 | ||
198 | pseudoModal = 0L; | 198 | pseudoModal = 0L; |
199 | clear(); | 199 | clear(); |
200 | 200 | ||
201 | setHighlight(0); //calls updateFontData() | 201 | setHighlight(0); //calls updateFontData() |
202 | // if the user changes the highlight with the dialog, notify the doc | 202 | // if the user changes the highlight with the dialog, notify the doc |
203 | connect(hlManager,SIGNAL(changed()),SLOT(hlChanged())); | 203 | connect(hlManager,SIGNAL(changed()),SLOT(hlChanged())); |
204 | 204 | ||
205 | newDocGeometry = false; | 205 | newDocGeometry = false; |
206 | 206 | ||
207 | readConfig(); | 207 | readConfig(); |
208 | 208 | ||
209 | setReadOnly(false); | 209 | setReadOnly(false); |
210 | } | 210 | } |
211 | 211 | ||
212 | void KateDocument::setDontChangeHlOnSave() | 212 | void KateDocument::setDontChangeHlOnSave() |
213 | { | 213 | { |
214 | d(this)->hlSetByUser = true; | 214 | d(this)->hlSetByUser = true; |
215 | } | 215 | } |
216 | 216 | ||
217 | void KateDocument::setFont (QFont font) | 217 | void KateDocument::setFont (QFont font) |
218 | { | 218 | { |
219 | kdDebug()<<"Kate:: setFont"<<endl; | 219 | kdDebug()<<"Kate:: setFont"<<endl; |
220 | int oldwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 | 220 | int oldwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 |
221 | myFont = font; | 221 | myFont = font; |
222 | myFontBold = QFont (font); | 222 | myFontBold = QFont (font); |
223 | myFontBold.setBold (true); | 223 | myFontBold.setBold (true); |
224 | 224 | ||
225 | myFontItalic = QFont (font); | 225 | myFontItalic = QFont (font); |
226 | myFontItalic.setItalic (true); | 226 | myFontItalic.setItalic (true); |
227 | 227 | ||
228 | myFontBI = QFont (font); | 228 | myFontBI = QFont (font); |
229 | myFontBI.setBold (true); | 229 | myFontBI.setBold (true); |
230 | myFontBI.setItalic (true); | 230 | myFontBI.setItalic (true); |
231 | 231 | ||
232 | myFontMetrics = CachedFontMetrics (myFont); | 232 | myFontMetrics = CachedFontMetrics (myFont); |
233 | myFontMetricsBold = CachedFontMetrics (myFontBold); | 233 | myFontMetricsBold = CachedFontMetrics (myFontBold); |
234 | myFontMetricsItalic = CachedFontMetrics (myFontItalic); | 234 | myFontMetricsItalic = CachedFontMetrics (myFontItalic); |
235 | myFontMetricsBI = CachedFontMetrics (myFontBI); | 235 | myFontMetricsBI = CachedFontMetrics (myFontBI); |
236 | int newwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 | 236 | int newwidth=myFontMetrics.width('W'); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 |
237 | maxLength=maxLength*(float)newwidth/(float)oldwidth; //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 | 237 | maxLength=maxLength*(float)newwidth/(float)oldwidth; //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 |
238 | 238 | ||
239 | updateFontData(); | 239 | updateFontData(); |
240 | updateViews(); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 | 240 | updateViews(); //Quick & Dirty Hack (by JoWenn) //Remove in KDE 3.0 |
241 | 241 | ||
242 | } | 242 | } |
243 | 243 | ||
244 | long KateDocument::needPreHighlight(long till) | 244 | long KateDocument::needPreHighlight(long till) |
245 | { | 245 | { |
246 | int max=numLines()-1; | 246 | int max=numLines()-1; |
247 | if (till>max) | 247 | if (till>max) |
248 | { | 248 | { |
249 | till=max; | 249 | till=max; |
250 | } | 250 | } |
251 | if (PreHighlightedTill>=till) return -1; | 251 | if (PreHighlightedTill>=till) return -1; |
252 | 252 | ||
253 | long tmp=RequestPreHighlightTill; | 253 | long tmp=RequestPreHighlightTill; |
254 | if (RequestPreHighlightTill<till) | 254 | if (RequestPreHighlightTill<till) |
255 | { | 255 | { |
256 | RequestPreHighlightTill=till; | 256 | RequestPreHighlightTill=till; |
257 | if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight())); | 257 | if (tmp<=PreHighlightedTill) QTimer::singleShot(10,this,SLOT(doPreHighlight())); |
258 | } | 258 | } |
259 | return RequestPreHighlightTill; | 259 | return RequestPreHighlightTill; |
260 | } | 260 | } |
261 | 261 | ||
262 | void KateDocument::doPreHighlight() | 262 | void KateDocument::doPreHighlight() |
263 | { | 263 | { |
264 | int from = PreHighlightedTill; | 264 | int from = PreHighlightedTill; |
265 | int till = PreHighlightedTill+200; | 265 | int till = PreHighlightedTill+200; |
266 | int max = numLines()-1; | 266 | int max = numLines()-1; |
267 | if (till > max) | 267 | if (till > max) |
diff --git a/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp b/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp index a85fb87..8e68262 100644 --- a/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp +++ b/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp | |||
@@ -442,130 +442,130 @@ EditConfigTab::EditConfigTab(QWidget *parent, KateView *view) | |||
442 | encoding->insertStringList (KGlobal::charsets()->availableEncodingNames()); | 442 | encoding->insertStringList (KGlobal::charsets()->availableEncodingNames()); |
443 | encoding->setCurrentItem (KGlobal::charsets()->availableEncodingNames().findIndex(view->doc()->encoding())); | 443 | encoding->setCurrentItem (KGlobal::charsets()->availableEncodingNames().findIndex(view->doc()->encoding())); |
444 | #endif | 444 | #endif |
445 | leLayout->addStretch(); | 445 | leLayout->addStretch(); |
446 | 446 | ||
447 | // What is this? help | 447 | // What is this? help |
448 | QWhatsThis::add(opt[0], i18n("Word wrap is a feature that causes the editor to automatically start a new line of text and move (wrap) the cursor to the beginning of that new line. KateView will automatically start a new line of text when the current line reaches the length specified by the Wrap Words At: option.<p><b>NOTE:<b> Word Wrap will not change existing lines or wrap them for easy reading as in some applications.")); | 448 | QWhatsThis::add(opt[0], i18n("Word wrap is a feature that causes the editor to automatically start a new line of text and move (wrap) the cursor to the beginning of that new line. KateView will automatically start a new line of text when the current line reaches the length specified by the Wrap Words At: option.<p><b>NOTE:<b> Word Wrap will not change existing lines or wrap them for easy reading as in some applications.")); |
449 | QWhatsThis::add(e1, i18n("If the Word Wrap option is selected this entry determines the length (in characters) at which the editor will automatically start a new line.")); | 449 | QWhatsThis::add(e1, i18n("If the Word Wrap option is selected this entry determines the length (in characters) at which the editor will automatically start a new line.")); |
450 | QWhatsThis::add(opt[1], i18n("KateView will replace any tabs with the number of spaces indicated in the Tab Width: entry.")); | 450 | QWhatsThis::add(opt[1], i18n("KateView will replace any tabs with the number of spaces indicated in the Tab Width: entry.")); |
451 | QWhatsThis::add(e2, i18n("If the Replace Tabs By Spaces option is selected this entry determines the number of spaces with which the editor will automatically replace tabs.")); | 451 | QWhatsThis::add(e2, i18n("If the Replace Tabs By Spaces option is selected this entry determines the number of spaces with which the editor will automatically replace tabs.")); |
452 | QWhatsThis::add(opt[2], i18n("KateView will automatically eliminate extra spaces at the ends of lines of text.")); | 452 | QWhatsThis::add(opt[2], i18n("KateView will automatically eliminate extra spaces at the ends of lines of text.")); |
453 | QWhatsThis::add(opt[3], i18n("When the user types a left bracket ([,(, or {) KateView automatically enters the right bracket (}, ), or ]) to the right of the cursor.")); | 453 | QWhatsThis::add(opt[3], i18n("When the user types a left bracket ([,(, or {) KateView automatically enters the right bracket (}, ), or ]) to the right of the cursor.")); |
454 | QWhatsThis::add(opt[4], i18n("Checking this will cause sequences of similar actions to be undone at once.")); | 454 | QWhatsThis::add(opt[4], i18n("Checking this will cause sequences of similar actions to be undone at once.")); |
455 | QWhatsThis::add(opt[5], i18n("The editor will display a symbol to indicate the presence of a tab in the text.")); | 455 | QWhatsThis::add(opt[5], i18n("The editor will display a symbol to indicate the presence of a tab in the text.")); |
456 | QWhatsThis::add(opt[6], i18n("Not yet implemented.")); | 456 | QWhatsThis::add(opt[6], i18n("Not yet implemented.")); |
457 | QWhatsThis::add(opt[7], i18n("If this is selected, the insertion cursor will be moved to the first/last line when pressing the page up/down buttons.<p>If not selected, it will remain at it's relative position in the visible text.")); | 457 | QWhatsThis::add(opt[7], i18n("If this is selected, the insertion cursor will be moved to the first/last line when pressing the page up/down buttons.<p>If not selected, it will remain at it's relative position in the visible text.")); |
458 | QWhatsThis::add(e3, i18n("Sets the number of undo/redo steps to record. More steps uses more memory.")); | 458 | QWhatsThis::add(e3, i18n("Sets the number of undo/redo steps to record. More steps uses more memory.")); |
459 | QWhatsThis::add(opt[8], i18n("When on, moving the insertion cursor using the <b>Left</b> and <b>Right</b> keys will go on to previous/next line at beginning/end of the line, similar to most editors.<p>When off, the insertion cursor cannot be moved left of the line start, but it can be moved off the line end, which can be very handy for programmers.")); | 459 | QWhatsThis::add(opt[8], i18n("When on, moving the insertion cursor using the <b>Left</b> and <b>Right</b> keys will go on to previous/next line at beginning/end of the line, similar to most editors.<p>When off, the insertion cursor cannot be moved left of the line start, but it can be moved off the line end, which can be very handy for programmers.")); |
460 | } | 460 | } |
461 | 461 | ||
462 | void EditConfigTab::getData(KateView *view) | 462 | void EditConfigTab::getData(KateView *view) |
463 | { | 463 | { |
464 | int configFlags, z; | 464 | int configFlags, z; |
465 | 465 | ||
466 | configFlags = view->config(); | 466 | configFlags = view->config(); |
467 | for (z = 1; z < numFlags; z++) { | 467 | for (z = 1; z < numFlags; z++) { |
468 | configFlags &= ~flags[z]; | 468 | configFlags &= ~flags[z]; |
469 | if (opt[z]->isChecked()) configFlags |= flags[z]; | 469 | if (opt[z]->isChecked()) configFlags |= flags[z]; |
470 | } | 470 | } |
471 | view->setConfig(configFlags); | 471 | view->setConfig(configFlags); |
472 | 472 | ||
473 | view->setEncoding (encoding->currentText()); | 473 | view->setEncoding (encoding->currentText()); |
474 | view->doc()->setWordWrapAt(e1->value()); | 474 | view->doc()->setWordWrapAt(e1->value()); |
475 | view->doc()->setWordWrap (opt[0]->isChecked()); | 475 | view->doc()->setWordWrap (opt[0]->isChecked()); |
476 | view->setTabWidth(e2->value()); | 476 | view->setTabWidth(e2->value()); |
477 | view->setUndoSteps(e3->value()); | 477 | view->setUndoSteps(e3->value()); |
478 | } | 478 | } |
479 | 479 | ||
480 | ColorConfig::ColorConfig( QWidget *parent, char *name ) | 480 | ColorConfig::ColorConfig( QWidget *parent, char *name ) |
481 | : QWidget( parent, name ) | 481 | : QWidget( parent, name ) |
482 | { | 482 | { |
483 | QGridLayout *glay = new QGridLayout( this, 6, 2, 0, KDialog::spacingHint()); | 483 | QGridLayout *glay = new QGridLayout( this, 6, 2, 0, KDialog::spacingHint()); |
484 | glay->setColStretch(1,1); | 484 | glay->setColStretch(1,1); |
485 | glay->setRowStretch(5,1); | 485 | glay->setRowStretch(5,1); |
486 | 486 | ||
487 | QLabel *label; | 487 | QLabel *label; |
488 | 488 | ||
489 | label = new QLabel( i18n("Background:"), this); | 489 | label = new QLabel( i18n("Background:"), this); |
490 | label->setAlignment( AlignRight|AlignVCenter ); | 490 | label->setAlignment( AlignRight|AlignVCenter ); |
491 | m_back = new KColorButton( this ); | 491 | m_back = new KColorButton( this ); |
492 | glay->addWidget( label, 0, 0 ); | 492 | glay->addWidget( label, 0, 0 ); |
493 | glay->addWidget( m_back, 0, 1 ); | 493 | glay->addWidget( m_back, 0, 1 ); |
494 | 494 | ||
495 | label = new QLabel( i18n("Selected:"), this); | 495 | label = new QLabel( i18n("Selected:"), this); |
496 | label->setAlignment( AlignRight|AlignVCenter ); | 496 | label->setAlignment( AlignRight|AlignVCenter ); |
497 | m_selected = new KColorButton( this ); | 497 | m_selected = new KColorButton( this ); |
498 | glay->addWidget( label, 2, 0 ); | 498 | glay->addWidget( label, 2, 0 ); |
499 | glay->addWidget( m_selected, 2, 1 ); | 499 | glay->addWidget( m_selected, 2, 1 ); |
500 | 500 | ||
501 | // QWhatsThis help | 501 | // QWhatsThis help |
502 | QWhatsThis::add(m_back, i18n("Sets the background color of the editing area")); | 502 | QWhatsThis::add(m_back, i18n("Sets the background color of the editing area")); |
503 | QWhatsThis::add(m_selected, i18n("Sets the background color of the selection. To set the text color for selected text, use the "<b>Configure Highlighting</b>" dialog.")); | 503 | QWhatsThis::add(m_selected, i18n("Sets the background color of the selection. To set the text color for selected text, use the "<b>Configure Highlighting</b>" dialog.")); |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | ColorConfig::~ColorConfig() | 507 | ColorConfig::~ColorConfig() |
508 | { | 508 | { |
509 | } | 509 | } |
510 | 510 | ||
511 | void ColorConfig::setColors(QColor *colors) | 511 | void ColorConfig::setColors(QColor *colors) |
512 | { | 512 | { |
513 | m_back->setColor( colors[0] ); | 513 | m_back->setColor( colors[0] ); |
514 | m_selected->setColor( colors[1] ); | 514 | m_selected->setColor( colors[1] ); |
515 | } | 515 | } |
516 | 516 | ||
517 | void ColorConfig::getColors(QColor *colors) | 517 | void ColorConfig::getColors(QColor *colors) |
518 | { | 518 | { |
519 | colors[0] = m_back->color(); | 519 | colors[0] = m_back->color(); |
520 | colors[1] = m_selected->color(); | 520 | colors[1] = m_selected->color(); |
521 | } | 521 | } |
522 | 522 | ||
523 | FontConfig::FontConfig( QWidget *parent, char *name ) | 523 | FontConfig::FontConfig( QWidget *parent, char *name ) |
524 | : QWidget( parent, name ) | 524 | : QWidget( parent, name ) |
525 | { | 525 | { |
526 | // sizemanagment | 526 | // sizemanagment |
527 | QGridLayout *grid = new QGridLayout( this, 1, 1 ); | 527 | QGridLayout *grid = new QGridLayout( this, 1, 1 ); |
528 | // QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); | 528 | // QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); |
529 | // QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); | 529 | // QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); |
530 | // int size = cfg. readNumEntry ( "FontSize", 10 ); | 530 | // int size = cfg. readNumEntry ( "FontSize", 10 ); |
531 | // OFontSelector *m_fontselect; | 531 | // OFontSelector *m_fontselect; |
532 | 532 | ||
533 | m_fontselect = new Opie::OFontSelector ( false, this, "FontTab" ); | 533 | m_fontselect = new Opie::OFontSelector ( false, this, "FontTab" ); |
534 | // m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); | 534 | // m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); |
535 | // QWhatsThis::add( m_fontselect, | 535 | // QWhatsThis::add( m_fontselect, |
536 | // tr( "Select the desired name, style and size of the default font applications will use." ) ); | 536 | // tr( "Select the desired name, style and size of the default font applications will use." ) ); |
537 | 537 | ||
538 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), | 538 | connect( m_fontselect, SIGNAL( fontSelected(const QFont&)), |
539 | this, SLOT( slotFontSelected( const QFont & ))); | 539 | this, SLOT( slotFontSelected(const QFont&))); |
540 | grid->addWidget( m_fontselect, 0, 0); | 540 | grid->addWidget( m_fontselect, 0, 0); |
541 | 541 | ||
542 | 542 | ||
543 | // #if 0 | 543 | // #if 0 |
544 | // m_fontchooser = new KFontChooser ( this ); | 544 | // m_fontchooser = new KFontChooser ( this ); |
545 | // m_fontchooser->enableColumn(KFontChooser::StyleList, false); | 545 | // m_fontchooser->enableColumn(KFontChooser::StyleList, false); |
546 | // grid->addWidget( m_fontchooser, 0, 0); | 546 | // grid->addWidget( m_fontchooser, 0, 0); |
547 | 547 | ||
548 | // connect (m_fontchooser, SIGNAL (fontSelected( const QFont & )), this, SLOT (slotFontSelected( const QFont & ))); | 548 | // connect (m_fontchooser, SIGNAL (fontSelected(const QFont&)), this, SLOT (slotFontSelected(const QFont&))); |
549 | // #endif | 549 | // #endif |
550 | } | 550 | } |
551 | 551 | ||
552 | FontConfig::~FontConfig() | 552 | FontConfig::~FontConfig() |
553 | { | 553 | { |
554 | } | 554 | } |
555 | 555 | ||
556 | void FontConfig::setFont ( const QFont &font ) | 556 | void FontConfig::setFont ( const QFont &font ) |
557 | { | 557 | { |
558 | //#if 0 | 558 | //#if 0 |
559 | m_fontselect->setFont (font); | 559 | m_fontselect->setFont (font); |
560 | myFont = font; | 560 | myFont = font; |
561 | //#endif | 561 | //#endif |
562 | } | 562 | } |
563 | 563 | ||
564 | void FontConfig::slotFontSelected( const QFont &font ) | 564 | void FontConfig::slotFontSelected( const QFont &font ) |
565 | { | 565 | { |
566 | myFont = font; | 566 | myFont = font; |
567 | } | 567 | } |
568 | 568 | ||
569 | 569 | ||
570 | 570 | ||
571 | 571 | ||
diff --git a/noncore/apps/tinykate/tinykate.cpp b/noncore/apps/tinykate/tinykate.cpp index 19a0127..32c1eab 100644 --- a/noncore/apps/tinykate/tinykate.cpp +++ b/noncore/apps/tinykate/tinykate.cpp | |||
@@ -1,141 +1,141 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | tinykate.cpp | 2 | tinykate.cpp |
3 | Tiny KATE mainwindow | 3 | Tiny KATE mainwindow |
4 | ------------------- | 4 | ------------------- |
5 | begin : November 2002 | 5 | begin : November 2002 |
6 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> | 6 | copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free softwaSre; you can redistribute it and/or modify * | 11 | * This program is free softwaSre; 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. * | 13 | * the Free Software Foundation. * |
14 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * | 14 | * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | #include <qaction.h> | 17 | #include <qaction.h> |
18 | #include <qtoolbutton.h> | 18 | #include <qtoolbutton.h> |
19 | #include <qmenubar.h> | 19 | #include <qmenubar.h> |
20 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | 22 | ||
23 | #include <opie2/ofiledialog.h> | 23 | #include <opie2/ofiledialog.h> |
24 | 24 | ||
25 | #include "tinykate.h" | 25 | #include "tinykate.h" |
26 | 26 | ||
27 | #include <katedocument.h> | 27 | #include <katedocument.h> |
28 | #include <kglobal.h> | 28 | #include <kglobal.h> |
29 | 29 | ||
30 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : | 30 | TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : |
31 | QMainWindow( parent, name, f ) | 31 | QMainWindow( parent, name, f ) |
32 | { | 32 | { |
33 | shutDown=false; | 33 | shutDown=false; |
34 | nextUnnamed=0; | 34 | nextUnnamed=0; |
35 | currentView=0; | 35 | currentView=0; |
36 | viewCount=0; | 36 | viewCount=0; |
37 | setCaption(tr("TinyKATE")); | 37 | setCaption(tr("TinyKATE")); |
38 | KGlobal::setAppName("TinyKATE"); | 38 | KGlobal::setAppName("TinyKATE"); |
39 | 39 | ||
40 | QMenuBar *mb = new QMenuBar( this ); | 40 | QMenuBar *mb = new QMenuBar( this ); |
41 | mb->setMargin( 0 ); | 41 | mb->setMargin( 0 ); |
42 | 42 | ||
43 | tabwidget=new OTabWidget(this); | 43 | tabwidget=new OTabWidget(this); |
44 | setCentralWidget(tabwidget); | 44 | setCentralWidget(tabwidget); |
45 | connect(tabwidget,SIGNAL(currentChanged( QWidget *)),this,SLOT(slotCurrentChanged(QWidget *))); | 45 | connect(tabwidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(slotCurrentChanged(QWidget*))); |
46 | 46 | ||
47 | //FILE ACTIONS | 47 | //FILE ACTIONS |
48 | QPopupMenu *popup = new QPopupMenu( this ); | 48 | QPopupMenu *popup = new QPopupMenu( this ); |
49 | 49 | ||
50 | // Action for creating a new document | 50 | // Action for creating a new document |
51 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 51 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
52 | a->addTo( popup ); | 52 | a->addTo( popup ); |
53 | connect(a, SIGNAL(activated()), this, SLOT(slotNew())); | 53 | connect(a, SIGNAL(activated()), this, SLOT(slotNew())); |
54 | 54 | ||
55 | // Action for opening an exisiting document | 55 | // Action for opening an exisiting document |
56 | a = new QAction( tr( "Open" ),Resource::loadPixmap( "fileopen" ) , QString::null, 0, this, 0 ); | 56 | a = new QAction( tr( "Open" ),Resource::loadPixmap( "fileopen" ) , QString::null, 0, this, 0 ); |
57 | a->addTo(popup); | 57 | a->addTo(popup); |
58 | connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); | 58 | connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); |
59 | 59 | ||
60 | 60 | ||
61 | // Action for saving document | 61 | // Action for saving document |
62 | a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); | 62 | a = new QAction( tr( "Save" ), Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); |
63 | a->addTo(popup); | 63 | a->addTo(popup); |
64 | connect(a, SIGNAL(activated()), this, SLOT(slotSave())); | 64 | connect(a, SIGNAL(activated()), this, SLOT(slotSave())); |
65 | 65 | ||
66 | // Action for saving document to a new name | 66 | // Action for saving document to a new name |
67 | a = new QAction( tr( "Save As" ),Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); | 67 | a = new QAction( tr( "Save As" ),Resource::loadPixmap( "save" ) , QString::null, 0, this, 0 ); |
68 | a->addTo(popup); | 68 | a->addTo(popup); |
69 | connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs())); | 69 | connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs())); |
70 | 70 | ||
71 | // Action for closing the currently active document | 71 | // Action for closing the currently active document |
72 | a = new QAction( tr( "Close" ), Resource::loadPixmap( "quit_icon" ) , QString::null, 0, this, 0 ); | 72 | a = new QAction( tr( "Close" ), Resource::loadPixmap( "quit_icon" ) , QString::null, 0, this, 0 ); |
73 | a->addTo(popup); | 73 | a->addTo(popup); |
74 | connect(a, SIGNAL(activated()), this, SLOT(slotClose())); | 74 | connect(a, SIGNAL(activated()), this, SLOT(slotClose())); |
75 | 75 | ||
76 | 76 | ||
77 | mb->insertItem(tr("File"),popup); | 77 | mb->insertItem(tr("File"),popup); |
78 | 78 | ||
79 | //EDIT ACTIONS | 79 | //EDIT ACTIONS |
80 | 80 | ||
81 | // Action for cutting text | 81 | // Action for cutting text |
82 | editCut = new QToolButton( 0 ); | 82 | editCut = new QToolButton( 0 ); |
83 | editCut->setAutoRaise( true ); | 83 | editCut->setAutoRaise( true ); |
84 | editCut->setIconSet( Resource::loadPixmap( "cut" ) ); | 84 | editCut->setIconSet( Resource::loadPixmap( "cut" ) ); |
85 | 85 | ||
86 | // Action for Copying text | 86 | // Action for Copying text |
87 | editCopy = new QToolButton( 0 ); | 87 | editCopy = new QToolButton( 0 ); |
88 | editCopy->setAutoRaise( true ); | 88 | editCopy->setAutoRaise( true ); |
89 | editCopy->setIconSet( Resource::loadPixmap( "copy" ) ); | 89 | editCopy->setIconSet( Resource::loadPixmap( "copy" ) ); |
90 | 90 | ||
91 | // Action for pasting text | 91 | // Action for pasting text |
92 | editPaste = new QToolButton( 0 ); | 92 | editPaste = new QToolButton( 0 ); |
93 | editPaste->setAutoRaise( true ); | 93 | editPaste->setAutoRaise( true ); |
94 | editPaste->setIconSet( Resource::loadPixmap( "paste" ) ); | 94 | editPaste->setIconSet( Resource::loadPixmap( "paste" ) ); |
95 | 95 | ||
96 | // Action for finding / replacing text | 96 | // Action for finding / replacing text |
97 | editFindReplace = new QToolButton( 0 ); | 97 | editFindReplace = new QToolButton( 0 ); |
98 | editFindReplace->setAutoRaise( true ); | 98 | editFindReplace->setAutoRaise( true ); |
99 | editFindReplace->setIconSet( Resource::loadPixmap("find") ); | 99 | editFindReplace->setIconSet( Resource::loadPixmap("find") ); |
100 | 100 | ||
101 | // Action for undo | 101 | // Action for undo |
102 | editUndo = new QToolButton( 0 ); | 102 | editUndo = new QToolButton( 0 ); |
103 | editUndo->setAutoRaise( true ); | 103 | editUndo->setAutoRaise( true ); |
104 | editUndo->setIconSet( Resource::loadPixmap( "undo" ) ); | 104 | editUndo->setIconSet( Resource::loadPixmap( "undo" ) ); |
105 | 105 | ||
106 | // Action for redo | 106 | // Action for redo |
107 | editRedo = new QToolButton( 0 ); | 107 | editRedo = new QToolButton( 0 ); |
108 | editRedo->setAutoRaise( true ); | 108 | editRedo->setAutoRaise( true ); |
109 | editRedo->setIconSet( Resource::loadPixmap( "redo" ) ); | 109 | editRedo->setIconSet( Resource::loadPixmap( "redo" ) ); |
110 | 110 | ||
111 | //VIEW ACITONS | 111 | //VIEW ACITONS |
112 | popup = new QPopupMenu( this ); | 112 | popup = new QPopupMenu( this ); |
113 | 113 | ||
114 | viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); | 114 | viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); |
115 | viewIncFontSizes->addTo( popup ); | 115 | viewIncFontSizes->addTo( popup ); |
116 | 116 | ||
117 | viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); | 117 | viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); |
118 | viewDecFontSizes->addTo( popup ); | 118 | viewDecFontSizes->addTo( popup ); |
119 | 119 | ||
120 | mb->insertItem(tr("View"),popup); | 120 | mb->insertItem(tr("View"),popup); |
121 | 121 | ||
122 | popup = new QPopupMenu( this ); | 122 | popup = new QPopupMenu( this ); |
123 | mb->insertItem(tr("Utils"),popup); | 123 | mb->insertItem(tr("Utils"),popup); |
124 | 124 | ||
125 | 125 | ||
126 | mb->insertItem( editCut ); | 126 | mb->insertItem( editCut ); |
127 | mb->insertItem( editCopy ); | 127 | mb->insertItem( editCopy ); |
128 | mb->insertItem( editPaste ); | 128 | mb->insertItem( editPaste ); |
129 | mb->insertItem( editFindReplace ); | 129 | mb->insertItem( editFindReplace ); |
130 | mb->insertItem( editUndo ); | 130 | mb->insertItem( editUndo ); |
131 | mb->insertItem( editRedo ); | 131 | mb->insertItem( editRedo ); |
132 | 132 | ||
133 | 133 | ||
134 | //Highlight management | 134 | //Highlight management |
135 | hlmenu=new QPopupMenu(this); | 135 | hlmenu=new QPopupMenu(this); |
136 | HlManager *hlm=HlManager::self(); | 136 | HlManager *hlm=HlManager::self(); |
137 | for (int i=0;i<hlm->highlights();i++) | 137 | for (int i=0;i<hlm->highlights();i++) |
138 | { | 138 | { |
139 | hlmenu->insertItem(hlm->hlName(i),i); | 139 | hlmenu->insertItem(hlm->hlName(i),i); |
140 | } | 140 | } |
141 | popup->insertItem(tr("Highlighting"),hlmenu); | 141 | popup->insertItem(tr("Highlighting"),hlmenu); |
diff --git a/noncore/apps/zsafe/scqtfiledlg.cpp b/noncore/apps/zsafe/scqtfiledlg.cpp index dd72fdf..52b8d0d 100644 --- a/noncore/apps/zsafe/scqtfiledlg.cpp +++ b/noncore/apps/zsafe/scqtfiledlg.cpp | |||
@@ -102,155 +102,155 @@ ScQtFileDlg::ScQtFileDlg( QWidget* parent, const char* name, bool modal, WFlags | |||
102 | resize( 196, 279 ); | 102 | resize( 196, 279 ); |
103 | if (!name) | 103 | if (!name) |
104 | setCaption( tr( "FileDlg" ) ); | 104 | setCaption( tr( "FileDlg" ) ); |
105 | else | 105 | else |
106 | setCaption(name); | 106 | setCaption(name); |
107 | ScQtFileDlgLayout = new QVBoxLayout( this ); | 107 | ScQtFileDlgLayout = new QVBoxLayout( this ); |
108 | ScQtFileDlgLayout->setSpacing( 6 ); | 108 | ScQtFileDlgLayout->setSpacing( 6 ); |
109 | ScQtFileDlgLayout->setMargin( 11 ); | 109 | ScQtFileDlgLayout->setMargin( 11 ); |
110 | 110 | ||
111 | Layout5 = new QVBoxLayout; | 111 | Layout5 = new QVBoxLayout; |
112 | Layout5->setSpacing( 6 ); | 112 | Layout5->setSpacing( 6 ); |
113 | Layout5->setMargin( 0 ); | 113 | Layout5->setMargin( 0 ); |
114 | 114 | ||
115 | Layout4 = new QVBoxLayout; | 115 | Layout4 = new QVBoxLayout; |
116 | Layout4->setSpacing( 6 ); | 116 | Layout4->setSpacing( 6 ); |
117 | Layout4->setMargin( 0 ); | 117 | Layout4->setMargin( 0 ); |
118 | 118 | ||
119 | Layout3 = new QHBoxLayout; | 119 | Layout3 = new QHBoxLayout; |
120 | Layout3->setSpacing( 6 ); | 120 | Layout3->setSpacing( 6 ); |
121 | Layout3->setMargin( 0 ); | 121 | Layout3->setMargin( 0 ); |
122 | 122 | ||
123 | TypeComboBox = new QComboBox( FALSE, this, "TypeComboBox" ); | 123 | TypeComboBox = new QComboBox( FALSE, this, "TypeComboBox" ); |
124 | TypeComboBox->setEditable( TRUE ); | 124 | TypeComboBox->setEditable( TRUE ); |
125 | TypeComboBox->setInsertionPolicy( QComboBox::AtBottom ); | 125 | TypeComboBox->setInsertionPolicy( QComboBox::AtBottom ); |
126 | TypeComboBox->setAutoCompletion( FALSE ); | 126 | TypeComboBox->setAutoCompletion( FALSE ); |
127 | TypeComboBox->setDuplicatesEnabled( FALSE ); | 127 | TypeComboBox->setDuplicatesEnabled( FALSE ); |
128 | QToolTip::add( TypeComboBox, tr( "file type filter" ) ); | 128 | QToolTip::add( TypeComboBox, tr( "file type filter" ) ); |
129 | QWhatsThis::add( TypeComboBox, tr( "ComboBox FileTypeFilter\n" | 129 | QWhatsThis::add( TypeComboBox, tr( "ComboBox FileTypeFilter\n" |
130 | "\n" | 130 | "\n" |
131 | "edit or select the filter" ) ); | 131 | "edit or select the filter" ) ); |
132 | Layout3->addWidget( TypeComboBox ); | 132 | Layout3->addWidget( TypeComboBox ); |
133 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); | 133 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); |
134 | Layout3->addItem( spacer ); | 134 | Layout3->addItem( spacer ); |
135 | 135 | ||
136 | OkButton = new QToolButton( this, "OkButton" ); | 136 | OkButton = new QToolButton( this, "OkButton" ); |
137 | OkButton->setText( tr( "" ) ); | 137 | OkButton->setText( tr( "" ) ); |
138 | OkButton->setPixmap( image0 ); | 138 | OkButton->setPixmap( image0 ); |
139 | OkButton->setUsesBigPixmap( FALSE ); | 139 | OkButton->setUsesBigPixmap( FALSE ); |
140 | QToolTip::add( OkButton, tr( "confirms the selection and closes the form" ) ); | 140 | QToolTip::add( OkButton, tr( "confirms the selection and closes the form" ) ); |
141 | QWhatsThis::add( OkButton, tr( "OKButton" ) ); | 141 | QWhatsThis::add( OkButton, tr( "OKButton" ) ); |
142 | Layout3->addWidget( OkButton ); | 142 | Layout3->addWidget( OkButton ); |
143 | 143 | ||
144 | CancelButton = new QToolButton( this, "CancelButton" ); | 144 | CancelButton = new QToolButton( this, "CancelButton" ); |
145 | CancelButton->setText( tr( "" ) ); | 145 | CancelButton->setText( tr( "" ) ); |
146 | CancelButton->setPixmap( image1 ); | 146 | CancelButton->setPixmap( image1 ); |
147 | CancelButton->setUsesBigPixmap( FALSE ); | 147 | CancelButton->setUsesBigPixmap( FALSE ); |
148 | QToolTip::add( CancelButton, tr( "cancels the selection and closes the form" ) ); | 148 | QToolTip::add( CancelButton, tr( "cancels the selection and closes the form" ) ); |
149 | QWhatsThis::add( CancelButton, tr( "CancelButton" ) ); | 149 | QWhatsThis::add( CancelButton, tr( "CancelButton" ) ); |
150 | Layout3->addWidget( CancelButton ); | 150 | Layout3->addWidget( CancelButton ); |
151 | Layout4->addLayout( Layout3 ); | 151 | Layout4->addLayout( Layout3 ); |
152 | 152 | ||
153 | Layout3_2 = new QHBoxLayout; | 153 | Layout3_2 = new QHBoxLayout; |
154 | Layout3_2->setSpacing( 6 ); | 154 | Layout3_2->setSpacing( 6 ); |
155 | Layout3_2->setMargin( 0 ); | 155 | Layout3_2->setMargin( 0 ); |
156 | 156 | ||
157 | FNameLineEdit = new QLineEdit( this, "FNameLineEdit" ); | 157 | FNameLineEdit = new QLineEdit( this, "FNameLineEdit" ); |
158 | QToolTip::add( FNameLineEdit, tr( "shows the selected filename" ) ); | 158 | QToolTip::add( FNameLineEdit, tr( "shows the selected filename" ) ); |
159 | QWhatsThis::add( FNameLineEdit, tr( "Filename LineEdit\n" | 159 | QWhatsThis::add( FNameLineEdit, tr( "Filename LineEdit\n" |
160 | "\n" | 160 | "\n" |
161 | "shows the selected file\n" | 161 | "shows the selected file\n" |
162 | "and allows the direct filename\n" | 162 | "and allows the direct filename\n" |
163 | "edit" ) ); | 163 | "edit" ) ); |
164 | Layout3_2->addWidget( FNameLineEdit ); | 164 | Layout3_2->addWidget( FNameLineEdit ); |
165 | 165 | ||
166 | MkDirButton = new QToolButton( this, "MkDirButton" ); | 166 | MkDirButton = new QToolButton( this, "MkDirButton" ); |
167 | MkDirButton->setText( tr( "" ) ); | 167 | MkDirButton->setText( tr( "" ) ); |
168 | MkDirButton->setPixmap( image2 ); | 168 | MkDirButton->setPixmap( image2 ); |
169 | MkDirButton->setUsesBigPixmap( FALSE ); | 169 | MkDirButton->setUsesBigPixmap( FALSE ); |
170 | QToolTip::add( MkDirButton, tr( "confirms the selection and closes the form" ) ); | 170 | QToolTip::add( MkDirButton, tr( "confirms the selection and closes the form" ) ); |
171 | QWhatsThis::add( MkDirButton, tr( "OKButton" ) ); | 171 | QWhatsThis::add( MkDirButton, tr( "OKButton" ) ); |
172 | Layout3_2->addWidget( MkDirButton ); | 172 | Layout3_2->addWidget( MkDirButton ); |
173 | Layout4->addLayout( Layout3_2 ); | 173 | Layout4->addLayout( Layout3_2 ); |
174 | 174 | ||
175 | DirComboBox = new QComboBox( FALSE, this, "DirComboBox" ); | 175 | DirComboBox = new QComboBox( FALSE, this, "DirComboBox" ); |
176 | DirComboBox->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, DirComboBox->sizePolicy().hasHeightForWidth() ) ); | 176 | DirComboBox->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, DirComboBox->sizePolicy().hasHeightForWidth() ) ); |
177 | DirComboBox->setEditable( TRUE ); | 177 | DirComboBox->setEditable( TRUE ); |
178 | DirComboBox->setDuplicatesEnabled( FALSE ); | 178 | DirComboBox->setDuplicatesEnabled( FALSE ); |
179 | QWhatsThis::add( DirComboBox, tr( "ComboBox Directory \n" | 179 | QWhatsThis::add( DirComboBox, tr( "ComboBox Directory \n" |
180 | "edit or select the directories name" ) ); | 180 | "edit or select the directories name" ) ); |
181 | Layout4->addWidget( DirComboBox ); | 181 | Layout4->addWidget( DirComboBox ); |
182 | Layout5->addLayout( Layout4 ); | 182 | Layout5->addLayout( Layout4 ); |
183 | 183 | ||
184 | ListView = new QListView( this, "ListView" ); | 184 | ListView = new QListView( this, "ListView" ); |
185 | ListView->addColumn( tr( "Name" ) ); | 185 | ListView->addColumn( tr( "Name" ) ); |
186 | ListView->addColumn( tr( "size" ) ); | 186 | ListView->addColumn( tr( "size" ) ); |
187 | ListView->addColumn( tr( "type" ) ); | 187 | ListView->addColumn( tr( "type" ) ); |
188 | ListView->setRootIsDecorated( TRUE ); | 188 | ListView->setRootIsDecorated( TRUE ); |
189 | QToolTip::add( ListView, tr( "directory listview" ) ); | 189 | QToolTip::add( ListView, tr( "directory listview" ) ); |
190 | QWhatsThis::add( ListView, tr( "Directory ListView\n" | 190 | QWhatsThis::add( ListView, tr( "Directory ListView\n" |
191 | "\n" | 191 | "\n" |
192 | "shows the list of dirs and files" ) ); | 192 | "shows the list of dirs and files" ) ); |
193 | Layout5->addWidget( ListView ); | 193 | Layout5->addWidget( ListView ); |
194 | ScQtFileDlgLayout->addLayout( Layout5 ); | 194 | ScQtFileDlgLayout->addLayout( Layout5 ); |
195 | 195 | ||
196 | // signals and slots connections | 196 | // signals and slots connections |
197 | connect( OkButton, SIGNAL( clicked() ), this, SLOT( slotOK() ) ); | 197 | connect( OkButton, SIGNAL( clicked() ), this, SLOT( slotOK() ) ); |
198 | connect( DirComboBox, SIGNAL( activated(int) ), this, SLOT( slotDirComboBoxChanged( int ) ) ); | 198 | connect( DirComboBox, SIGNAL( activated(int) ), this, SLOT( slotDirComboBoxChanged(int) ) ); |
199 | connect( TypeComboBox, SIGNAL( activated(int) ), this, SLOT( slotTypeComboBoxChanged( int ) ) ); | 199 | connect( TypeComboBox, SIGNAL( activated(int) ), this, SLOT( slotTypeComboBoxChanged(int) ) ); |
200 | connect( CancelButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) ); | 200 | connect( CancelButton, SIGNAL( clicked() ), this, SLOT( slotCancel() ) ); |
201 | connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( slotSelectionChanged(QListViewItem *) ) ); | 201 | connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), this, SLOT( slotSelectionChanged(QListViewItem*) ) ); |
202 | connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), this, SLOT( slotSelectionChanged(QListViewItem *) ) ); | 202 | connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), this, SLOT( slotSelectionChanged(QListViewItem*) ) ); |
203 | connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( slotDoubleClicked(QListViewItem *) ) ); | 203 | connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( slotDoubleClicked(QListViewItem*) ) ); |
204 | connect( FNameLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotFileTextChanged( const QString & ) ) ); | 204 | connect( FNameLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( slotFileTextChanged(const QString&) ) ); |
205 | connect( FNameLineEdit, SIGNAL( returnPressed() ), this, SLOT( slotOK() ) ); | 205 | connect( FNameLineEdit, SIGNAL( returnPressed() ), this, SLOT( slotOK() ) ); |
206 | connect( MkDirButton, SIGNAL( clicked() ), this, SLOT( slotMkDir() ) ); | 206 | connect( MkDirButton, SIGNAL( clicked() ), this, SLOT( slotMkDir() ) ); |
207 | } | 207 | } |
208 | 208 | ||
209 | /* | 209 | /* |
210 | * Destroys the object and frees any allocated resources | 210 | * Destroys the object and frees any allocated resources |
211 | */ | 211 | */ |
212 | ScQtFileDlg::~ScQtFileDlg() | 212 | ScQtFileDlg::~ScQtFileDlg() |
213 | { | 213 | { |
214 | // no need to delete child widgets, Qt does it all for us | 214 | // no need to delete child widgets, Qt does it all for us |
215 | } | 215 | } |
216 | 216 | ||
217 | void ScQtFileDlg::slotCancel() | 217 | void ScQtFileDlg::slotCancel() |
218 | { | 218 | { |
219 | qWarning( "ScQtFileDlg::slotCancel(): Not implemented yet!" ); | 219 | qWarning( "ScQtFileDlg::slotCancel(): Not implemented yet!" ); |
220 | } | 220 | } |
221 | 221 | ||
222 | void ScQtFileDlg::slotDirComboBoxChanged( int ) | 222 | void ScQtFileDlg::slotDirComboBoxChanged( int ) |
223 | { | 223 | { |
224 | qWarning( "ScQtFileDlg::slotDirComboBoxChanged( int ): Not implemented yet!" ); | 224 | qWarning( "ScQtFileDlg::slotDirComboBoxChanged( int ): Not implemented yet!" ); |
225 | } | 225 | } |
226 | 226 | ||
227 | void ScQtFileDlg::slotDoubleClicked(QListViewItem *) | 227 | void ScQtFileDlg::slotDoubleClicked(QListViewItem *) |
228 | { | 228 | { |
229 | qWarning( "ScQtFileDlg::slotDoubleClicked(QListViewItem *): Not implemented yet!" ); | 229 | qWarning( "ScQtFileDlg::slotDoubleClicked(QListViewItem *): Not implemented yet!" ); |
230 | } | 230 | } |
231 | 231 | ||
232 | void ScQtFileDlg::slotFileTextChanged( const QString & ) | 232 | void ScQtFileDlg::slotFileTextChanged( const QString & ) |
233 | { | 233 | { |
234 | qWarning( "ScQtFileDlg::slotFileTextChanged( const QString & ): Not implemented yet!" ); | 234 | qWarning( "ScQtFileDlg::slotFileTextChanged( const QString & ): Not implemented yet!" ); |
235 | } | 235 | } |
236 | 236 | ||
237 | void ScQtFileDlg::slotMkDir() | 237 | void ScQtFileDlg::slotMkDir() |
238 | { | 238 | { |
239 | qWarning( "ScQtFileDlg::slotMkDir(): Not implemented yet!" ); | 239 | qWarning( "ScQtFileDlg::slotMkDir(): Not implemented yet!" ); |
240 | } | 240 | } |
241 | 241 | ||
242 | void ScQtFileDlg::slotOK() | 242 | void ScQtFileDlg::slotOK() |
243 | { | 243 | { |
244 | qWarning( "ScQtFileDlg::slotOK(): Not implemented yet!" ); | 244 | qWarning( "ScQtFileDlg::slotOK(): Not implemented yet!" ); |
245 | } | 245 | } |
246 | 246 | ||
247 | void ScQtFileDlg::slotSelectionChanged(QListViewItem *) | 247 | void ScQtFileDlg::slotSelectionChanged(QListViewItem *) |
248 | { | 248 | { |
249 | qWarning( "ScQtFileDlg::slotSelectionChanged(QListViewItem *): Not implemented yet!" ); | 249 | qWarning( "ScQtFileDlg::slotSelectionChanged(QListViewItem *): Not implemented yet!" ); |
250 | } | 250 | } |
251 | 251 | ||
252 | void ScQtFileDlg::slotTypeComboBoxChanged( int ) | 252 | void ScQtFileDlg::slotTypeComboBoxChanged( int ) |
253 | { | 253 | { |
254 | qWarning( "ScQtFileDlg::slotTypeComboBoxChanged( int ): Not implemented yet!" ); | 254 | qWarning( "ScQtFileDlg::slotTypeComboBoxChanged( int ): Not implemented yet!" ); |
255 | } | 255 | } |
256 | 256 | ||
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index a3e805e..a3467e5 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -597,198 +597,198 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
597 | cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); | 597 | cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); |
598 | cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); | 598 | cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); |
599 | menu->insertItem( tr("&Category"), cat ); | 599 | menu->insertItem( tr("&Category"), cat ); |
600 | 600 | ||
601 | QPopupMenu *it = new QPopupMenu( this ); | 601 | QPopupMenu *it = new QPopupMenu( this ); |
602 | it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); | 602 | it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); |
603 | it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); | 603 | it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); |
604 | it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); | 604 | it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); |
605 | it->insertSeparator(); | 605 | it->insertSeparator(); |
606 | it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); | 606 | it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); |
607 | it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); | 607 | it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); |
608 | it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); | 608 | it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); |
609 | it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); | 609 | it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); |
610 | menu->insertItem( tr("&Entry"), it ); | 610 | menu->insertItem( tr("&Entry"), it ); |
611 | 611 | ||
612 | QPopupMenu *help = new QPopupMenu( this ); | 612 | QPopupMenu *help = new QPopupMenu( this ); |
613 | help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); | 613 | help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); |
614 | menu->insertItem( tr("&Help"), help ); | 614 | menu->insertItem( tr("&Help"), help ); |
615 | 615 | ||
616 | // toolbar icons | 616 | // toolbar icons |
617 | 617 | ||
618 | New = new QToolButton( menu, "New" ); | 618 | New = new QToolButton( menu, "New" ); |
619 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); | 619 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); |
620 | New->setMouseTracking( TRUE ); | 620 | New->setMouseTracking( TRUE ); |
621 | New->setText( tr( "" ) ); | 621 | New->setText( tr( "" ) ); |
622 | New->setPixmap( new_img ); | 622 | New->setPixmap( new_img ); |
623 | QToolTip::add( New, tr( "New entry" ) ); | 623 | QToolTip::add( New, tr( "New entry" ) ); |
624 | 624 | ||
625 | Edit = new QToolButton( menu, "Edit" ); | 625 | Edit = new QToolButton( menu, "Edit" ); |
626 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); | 626 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); |
627 | Edit->setText( tr( "" ) ); | 627 | Edit->setText( tr( "" ) ); |
628 | Edit->setPixmap( edit_img ); | 628 | Edit->setPixmap( edit_img ); |
629 | QToolTip::add( Edit, tr( "Edit category or entry" ) ); | 629 | QToolTip::add( Edit, tr( "Edit category or entry" ) ); |
630 | 630 | ||
631 | Delete = new QToolButton( menu, "Delete" ); | 631 | Delete = new QToolButton( menu, "Delete" ); |
632 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | 632 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); |
633 | Delete->setText( tr( "" ) ); | 633 | Delete->setText( tr( "" ) ); |
634 | Delete->setPixmap( trash_img ); | 634 | Delete->setPixmap( trash_img ); |
635 | QToolTip::add( Delete, tr( "Delete category or entry" ) ); | 635 | QToolTip::add( Delete, tr( "Delete category or entry" ) ); |
636 | 636 | ||
637 | Find = new QToolButton( menu, "Find" ); | 637 | Find = new QToolButton( menu, "Find" ); |
638 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); | 638 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); |
639 | Find->setText( tr( "" ) ); | 639 | Find->setText( tr( "" ) ); |
640 | Find->setPixmap( find_img ); | 640 | Find->setPixmap( find_img ); |
641 | QToolTip::add( Find, tr( "Find entry" ) ); | 641 | QToolTip::add( Find, tr( "Find entry" ) ); |
642 | 642 | ||
643 | /* | 643 | /* |
644 | QBoxLayout * h = new QHBoxLayout( this ); | 644 | QBoxLayout * h = new QHBoxLayout( this ); |
645 | h->addWidget (menu); | 645 | h->addWidget (menu); |
646 | h->addWidget (New); | 646 | h->addWidget (New); |
647 | h->addWidget (Edit); | 647 | h->addWidget (Edit); |
648 | h->addWidget (Delete); | 648 | h->addWidget (Delete); |
649 | h->addWidget (Find); | 649 | h->addWidget (Find); |
650 | */ | 650 | */ |
651 | 651 | ||
652 | ListView = new ZListView( this, "ListView" ); | 652 | ListView = new ZListView( this, "ListView" ); |
653 | ListView->addColumn( tr( "Name" ) ); | 653 | ListView->addColumn( tr( "Name" ) ); |
654 | ListView->addColumn( tr( "Field 2" ) ); | 654 | ListView->addColumn( tr( "Field 2" ) ); |
655 | ListView->addColumn( tr( "Field 3" ) ); | 655 | ListView->addColumn( tr( "Field 3" ) ); |
656 | ListView->addColumn( tr( "Comment" ) ); | 656 | ListView->addColumn( tr( "Comment" ) ); |
657 | ListView->addColumn( tr( "Field 4" ) ); | 657 | ListView->addColumn( tr( "Field 4" ) ); |
658 | ListView->addColumn( tr( "Field 5" ) ); | 658 | ListView->addColumn( tr( "Field 5" ) ); |
659 | ListView->setAllColumnsShowFocus(TRUE); | 659 | ListView->setAllColumnsShowFocus(TRUE); |
660 | 660 | ||
661 | #ifdef DESKTOP | 661 | #ifdef DESKTOP |
662 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 662 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
663 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); | 663 | // ListView->setGeometry( QRect( 0, 22, this->width(), this->height() - 30 ) ); |
664 | #else | 664 | #else |
665 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 665 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
666 | // ListView->setGeometry( QRect( 0, 22, | 666 | // ListView->setGeometry( QRect( 0, 22, |
667 | // this->width(), this->height() - 30 ) ); | 667 | // this->width(), this->height() - 30 ) ); |
668 | // ListView->setMaximumSize( QSize( 440, 290 ) ); | 668 | // ListView->setMaximumSize( QSize( 440, 290 ) ); |
669 | #endif | 669 | #endif |
670 | ListView->setVScrollBarMode( QListView::Auto ); | 670 | ListView->setVScrollBarMode( QListView::Auto ); |
671 | 671 | ||
672 | QBoxLayout * l = new QVBoxLayout( this ); | 672 | QBoxLayout * l = new QVBoxLayout( this ); |
673 | l->addWidget (menu); | 673 | l->addWidget (menu); |
674 | l->addWidget (ListView); | 674 | l->addWidget (ListView); |
675 | 675 | ||
676 | #ifndef DESKTOP | 676 | #ifndef DESKTOP |
677 | // start a timer (100 ms) to load the default document | 677 | // start a timer (100 ms) to load the default document |
678 | docuTimer.start( 100, true ); | 678 | docuTimer.start( 100, true ); |
679 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); | 679 | connect( &docuTimer, SIGNAL(timeout()), SLOT( slotLoadDocu() ) ); |
680 | raiseFlag = true; | 680 | raiseFlag = true; |
681 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); | 681 | connect( &raiseTimer, SIGNAL(timeout()), SLOT( slotRaiseTimer() ) ); |
682 | #else | 682 | #else |
683 | // open the default document | 683 | // open the default document |
684 | openDocument(filename); | 684 | openDocument(filename); |
685 | #endif | 685 | #endif |
686 | 686 | ||
687 | // signals and slots connections for QTollButton | 687 | // signals and slots connections for QTollButton |
688 | connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); | 688 | connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); |
689 | connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); | 689 | connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); |
690 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); | 690 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); |
691 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); | 691 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); |
692 | // signals and slots connections for QListView | 692 | // signals and slots connections for QListView |
693 | connect( ListView, SIGNAL( selectionChanged( QListViewItem* ) ), | 693 | connect( ListView, SIGNAL( selectionChanged(QListViewItem*) ), |
694 | this, SLOT( listViewSelected( QListViewItem* ) ) ); | 694 | this, SLOT( listViewSelected(QListViewItem*) ) ); |
695 | connect( ListView, SIGNAL( doubleClicked( QListViewItem* ) ), | 695 | connect( ListView, SIGNAL( doubleClicked(QListViewItem*) ), |
696 | this, SLOT( showInfo( QListViewItem* ) ) ); | 696 | this, SLOT( showInfo(QListViewItem*) ) ); |
697 | connect( ListView, SIGNAL( returnPressed( QListViewItem* ) ), | 697 | connect( ListView, SIGNAL( returnPressed(QListViewItem*) ), |
698 | this, SLOT( showInfo( QListViewItem* ) ) ); | 698 | this, SLOT( showInfo(QListViewItem*) ) ); |
699 | 699 | ||
700 | } | 700 | } |
701 | 701 | ||
702 | const QColor *ZSafe::evenRowColor = &Qt::white; | 702 | const QColor *ZSafe::evenRowColor = &Qt::white; |
703 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; | 703 | // const QColor *ZSafe::oddRowColor = &Qt::lightGray; |
704 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); | 704 | const QColor *ZSafe::oddRowColor = new QColor(216,240,255); |
705 | 705 | ||
706 | /* | 706 | /* |
707 | * Destroys the object and frees any allocated resources | 707 | * Destroys the object and frees any allocated resources |
708 | */ | 708 | */ |
709 | ZSafe::~ZSafe() | 709 | ZSafe::~ZSafe() |
710 | { | 710 | { |
711 | // no need to delete child widgets, Qt does it all for us | 711 | // no need to delete child widgets, Qt does it all for us |
712 | quitMe(); | 712 | quitMe(); |
713 | } | 713 | } |
714 | 714 | ||
715 | // load the default document | 715 | // load the default document |
716 | void ZSafe::slotLoadDocu() | 716 | void ZSafe::slotLoadDocu() |
717 | { | 717 | { |
718 | openDocument (filename); | 718 | openDocument (filename); |
719 | } | 719 | } |
720 | 720 | ||
721 | void ZSafe::deletePwd() | 721 | void ZSafe::deletePwd() |
722 | { | 722 | { |
723 | 723 | ||
724 | if (!selectedItem) | 724 | if (!selectedItem) |
725 | return; | 725 | return; |
726 | if (!isCategory(selectedItem)) | 726 | if (!isCategory(selectedItem)) |
727 | { | 727 | { |
728 | switch( QMessageBox::information( this, tr("ZSafe"), | 728 | switch( QMessageBox::information( this, tr("ZSafe"), |
729 | tr("Do you want to delete?"), | 729 | tr("Do you want to delete?"), |
730 | tr("&Delete"), tr("D&on't Delete"), | 730 | tr("&Delete"), tr("D&on't Delete"), |
731 | 0 // Enter == button 0 | 731 | 0 // Enter == button 0 |
732 | ) ) { // Escape == button 2 | 732 | ) ) { // Escape == button 2 |
733 | case 0: // Delete clicked, Alt-S or Enter pressed. | 733 | case 0: // Delete clicked, Alt-S or Enter pressed. |
734 | // Delete | 734 | // Delete |
735 | modified = true; | 735 | modified = true; |
736 | selectedItem->parent()->takeItem(selectedItem); | 736 | selectedItem->parent()->takeItem(selectedItem); |
737 | selectedItem = NULL; | 737 | selectedItem = NULL; |
738 | break; | 738 | break; |
739 | case 1: // Don't delete | 739 | case 1: // Don't delete |
740 | break; | 740 | break; |
741 | } | 741 | } |
742 | } | 742 | } |
743 | else | 743 | else |
744 | { | 744 | { |
745 | delCategory(); | 745 | delCategory(); |
746 | } | 746 | } |
747 | } | 747 | } |
748 | 748 | ||
749 | void ZSafe::editPwd() | 749 | void ZSafe::editPwd() |
750 | { | 750 | { |
751 | if (!selectedItem) | 751 | if (!selectedItem) |
752 | return; | 752 | return; |
753 | if (!isCategory(selectedItem)) | 753 | if (!isCategory(selectedItem)) |
754 | { | 754 | { |
755 | // open the 'New Entry' dialog | 755 | // open the 'New Entry' dialog |
756 | NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE); | 756 | NewDialog *dialog = new NewDialog(this, tr("Edit Entry"), TRUE); |
757 | #ifdef WIN32 | 757 | #ifdef WIN32 |
758 | dialog->setCaption ("Qt " + tr("Edit Entry")); | 758 | dialog->setCaption ("Qt " + tr("Edit Entry")); |
759 | dialog->setGeometry(200, 250, 220, 310 ); | 759 | dialog->setGeometry(200, 250, 220, 310 ); |
760 | #endif | 760 | #endif |
761 | 761 | ||
762 | // set the labels | 762 | // set the labels |
763 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 763 | dialog->Name->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
764 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 764 | dialog->Username->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
765 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 765 | dialog->Password->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
766 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 766 | dialog->Comment->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
767 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); | 767 | dialog->Field5Label->setText(getFieldLabel (selectedItem,"5", tr("Field 4"))); |
768 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); | 768 | dialog->Field6Label->setText(getFieldLabel (selectedItem,"6", tr("Field 5"))); |
769 | 769 | ||
770 | // set the fields | 770 | // set the fields |
771 | dialog->NameField->setText(selectedItem->text (0)); | 771 | dialog->NameField->setText(selectedItem->text (0)); |
772 | dialog->UsernameField->setText(selectedItem->text (1)); | 772 | dialog->UsernameField->setText(selectedItem->text (1)); |
773 | dialog->PasswordField->setText(selectedItem->text (2)); | 773 | dialog->PasswordField->setText(selectedItem->text (2)); |
774 | QString comment = selectedItem->text (3); | 774 | QString comment = selectedItem->text (3); |
775 | comment.replace (QRegExp("<br>"), "\n"); | 775 | comment.replace (QRegExp("<br>"), "\n"); |
776 | dialog->Field5->setText(selectedItem->text (4)); | 776 | dialog->Field5->setText(selectedItem->text (4)); |
777 | dialog->Field6->setText(selectedItem->text (5)); | 777 | dialog->Field6->setText(selectedItem->text (5)); |
778 | dialog->CommentField->insertLine(comment); | 778 | dialog->CommentField->insertLine(comment); |
779 | dialog->CommentField->setCursorPosition(0,0); | 779 | dialog->CommentField->setCursorPosition(0,0); |
780 | 780 | ||
781 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); | 781 | DialogCode result = (DialogCode) QPEApplication::execDialog( dialog ); |
782 | 782 | ||
783 | #ifdef DESKTOP | 783 | #ifdef DESKTOP |
784 | result = Accepted; | 784 | result = Accepted; |
785 | #endif | 785 | #endif |
786 | if (result == Accepted) | 786 | if (result == Accepted) |
787 | { | 787 | { |
788 | modified = true; | 788 | modified = true; |
789 | // edit the selected item | 789 | // edit the selected item |
790 | QString name = dialog->NameField->text(); | 790 | QString name = dialog->NameField->text(); |
791 | selectedItem->setText (0, tr (name)); | 791 | selectedItem->setText (0, tr (name)); |
792 | QString user = dialog->UsernameField->text(); | 792 | QString user = dialog->UsernameField->text(); |
793 | selectedItem->setText (1, tr (user)); | 793 | selectedItem->setText (1, tr (user)); |
794 | QString pwd = dialog->PasswordField->text(); | 794 | QString pwd = dialog->PasswordField->text(); |
@@ -2486,194 +2486,194 @@ int ZSafe::saveFinalize(void) | |||
2486 | Krc2* krc2 = new Krc2(); | 2486 | Krc2* krc2 = new Krc2(); |
2487 | 2487 | ||
2488 | /* Tack on the PKCS 5 padding | 2488 | /* Tack on the PKCS 5 padding |
2489 | * How it works is we fill up the last n bytes with the value n | 2489 | * How it works is we fill up the last n bytes with the value n |
2490 | * | 2490 | * |
2491 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left | 2491 | * So, if we have, say, 13 bytes, 8 of which are used, we have 5 left |
2492 | * over, leaving us 3 short, so we fill it in with 3's. | 2492 | * over, leaving us 3 short, so we fill it in with 3's. |
2493 | * | 2493 | * |
2494 | * If we come out even, we fill it with 8 8s | 2494 | * If we come out even, we fill it with 8 8s |
2495 | * | 2495 | * |
2496 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. | 2496 | * um, except that in this instance we are using 4 shorts instead of 8 bytes. |
2497 | * so, half everything | 2497 | * so, half everything |
2498 | */ | 2498 | */ |
2499 | for (count1 = bufferIndex; count1 < 4; count1++) { | 2499 | for (count1 = bufferIndex; count1 < 4; count1++) { |
2500 | plaintext[count1] = (4 - bufferIndex); | 2500 | plaintext[count1] = (4 - bufferIndex); |
2501 | } | 2501 | } |
2502 | krc2->rc2_encrypt (plaintext); | 2502 | krc2->rc2_encrypt (plaintext); |
2503 | for (count1 = 0; count1 < 4; count1++) { | 2503 | for (count1 = 0; count1 < 4; count1++) { |
2504 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; | 2504 | ciphertext[count1] = iv[count1] ^ plaintext[count1]; |
2505 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; | 2505 | if (putc ((unsigned char) (ciphertext[count1] >> 8), fd) == EOF) retval = PWERR_DATA; |
2506 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; | 2506 | if (putc ((unsigned char) (ciphertext[count1] & 0xff), fd) == EOF) retval = PWERR_DATA; |
2507 | } | 2507 | } |
2508 | 2508 | ||
2509 | fclose (fd); | 2509 | fclose (fd); |
2510 | free(buffer); | 2510 | free(buffer); |
2511 | return retval; | 2511 | return retval; |
2512 | } | 2512 | } |
2513 | 2513 | ||
2514 | void ZSafe::quitMe () | 2514 | void ZSafe::quitMe () |
2515 | { | 2515 | { |
2516 | qWarning ("QUIT..."); | 2516 | qWarning ("QUIT..."); |
2517 | 2517 | ||
2518 | if (modified) | 2518 | if (modified) |
2519 | { | 2519 | { |
2520 | switch( QMessageBox::information( this, tr("ZSafe"), | 2520 | switch( QMessageBox::information( this, tr("ZSafe"), |
2521 | tr("Do you want to save\nbefore exiting?"), | 2521 | tr("Do you want to save\nbefore exiting?"), |
2522 | tr("&Save"), | 2522 | tr("&Save"), |
2523 | tr("S&ave with\nnew\npassword"), | 2523 | tr("S&ave with\nnew\npassword"), |
2524 | tr("&Don't Save"), | 2524 | tr("&Don't Save"), |
2525 | 0 // Enter == button 0 | 2525 | 0 // Enter == button 0 |
2526 | ) ) | 2526 | ) ) |
2527 | { // Escape == button 2 | 2527 | { // Escape == button 2 |
2528 | case 0: // Save clicked, Alt-S or Enter pressed. | 2528 | case 0: // Save clicked, Alt-S or Enter pressed. |
2529 | // save | 2529 | // save |
2530 | modified = false; | 2530 | modified = false; |
2531 | saveDocument(filename, FALSE); | 2531 | saveDocument(filename, FALSE); |
2532 | exitZs (1); | 2532 | exitZs (1); |
2533 | break; | 2533 | break; |
2534 | case 1: // | 2534 | case 1: // |
2535 | // Save with new password | 2535 | // Save with new password |
2536 | modified = false; | 2536 | modified = false; |
2537 | saveDocument(filename, TRUE); | 2537 | saveDocument(filename, TRUE); |
2538 | exitZs (1); | 2538 | exitZs (1); |
2539 | break; | 2539 | break; |
2540 | case 2: // Don't Save clicked or Alt-D pressed | 2540 | case 2: // Don't Save clicked or Alt-D pressed |
2541 | // don't save but exitZs | 2541 | // don't save but exitZs |
2542 | exitZs (1); | 2542 | exitZs (1); |
2543 | break; | 2543 | break; |
2544 | } | 2544 | } |
2545 | } | 2545 | } |
2546 | exitZs (1); | 2546 | exitZs (1); |
2547 | 2547 | ||
2548 | } | 2548 | } |
2549 | 2549 | ||
2550 | void ZSafe::categoryFieldActivated( const QString& category) | 2550 | void ZSafe::categoryFieldActivated( const QString& category) |
2551 | { | 2551 | { |
2552 | if (categoryDialog) | 2552 | if (categoryDialog) |
2553 | setCategoryDialogFields(categoryDialog, category); | 2553 | setCategoryDialogFields(categoryDialog, category); |
2554 | } | 2554 | } |
2555 | 2555 | ||
2556 | void ZSafe::addCategory() | 2556 | void ZSafe::addCategory() |
2557 | { | 2557 | { |
2558 | if (filename.isEmpty()) | 2558 | if (filename.isEmpty()) |
2559 | { | 2559 | { |
2560 | QMessageBox::critical( 0, tr("ZSafe"), | 2560 | QMessageBox::critical( 0, tr("ZSafe"), |
2561 | tr("No document defined.\nYou have to create a new document")); | 2561 | tr("No document defined.\nYou have to create a new document")); |
2562 | return; | 2562 | return; |
2563 | } | 2563 | } |
2564 | else | 2564 | else |
2565 | { | 2565 | { |
2566 | // open the 'Category' dialog | 2566 | // open the 'Category' dialog |
2567 | bool initIcons = false; | 2567 | bool initIcons = false; |
2568 | // open the 'Category' dialog | 2568 | // open the 'Category' dialog |
2569 | CategoryDialog *dialog; | 2569 | CategoryDialog *dialog; |
2570 | if (categoryDialog) | 2570 | if (categoryDialog) |
2571 | { | 2571 | { |
2572 | dialog = categoryDialog; | 2572 | dialog = categoryDialog; |
2573 | } | 2573 | } |
2574 | else | 2574 | else |
2575 | { | 2575 | { |
2576 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 2576 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
2577 | #ifdef WIN32 | 2577 | #ifdef WIN32 |
2578 | categoryDialog->setCaption ("Qt " + tr("Category")); | 2578 | categoryDialog->setCaption ("Qt " + tr("Category")); |
2579 | #endif | 2579 | #endif |
2580 | dialog = categoryDialog; | 2580 | dialog = categoryDialog; |
2581 | connect( dialog->CategoryField, | 2581 | connect( dialog->CategoryField, |
2582 | SIGNAL( activated ( const QString &)), | 2582 | SIGNAL( activated(const QString&)), |
2583 | this, SLOT( categoryFieldActivated( const QString & ) ) ); | 2583 | this, SLOT( categoryFieldActivated(const QString&) ) ); |
2584 | initIcons = true; | 2584 | initIcons = true; |
2585 | } | 2585 | } |
2586 | 2586 | ||
2587 | #ifdef DESKTOP | 2587 | #ifdef DESKTOP |
2588 | #ifndef WIN32 | 2588 | #ifndef WIN32 |
2589 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | 2589 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); |
2590 | #else | 2590 | #else |
2591 | // read all categories from the config file and store | 2591 | // read all categories from the config file and store |
2592 | // into a list | 2592 | // into a list |
2593 | QFile f (cfgFile); | 2593 | QFile f (cfgFile); |
2594 | QStringList list; | 2594 | QStringList list; |
2595 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2595 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
2596 | QTextStream t( &f ); // use a text stream | 2596 | QTextStream t( &f ); // use a text stream |
2597 | QString s; | 2597 | QString s; |
2598 | int n = 1; | 2598 | int n = 1; |
2599 | while ( !t.eof() ) { // until end of file... | 2599 | while ( !t.eof() ) { // until end of file... |
2600 | s = t.readLine(); // line of text excluding '\n' | 2600 | s = t.readLine(); // line of text excluding '\n' |
2601 | list.append(s); | 2601 | list.append(s); |
2602 | } | 2602 | } |
2603 | f.close(); | 2603 | f.close(); |
2604 | } | 2604 | } |
2605 | #endif | 2605 | #endif |
2606 | #else | 2606 | #else |
2607 | // read all categories from the config file and store | 2607 | // read all categories from the config file and store |
2608 | // into a list | 2608 | // into a list |
2609 | QFile f (cfgFile); | 2609 | QFile f (cfgFile); |
2610 | QStringList list; | 2610 | QStringList list; |
2611 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 2611 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
2612 | QTextStream t( &f ); // use a text stream | 2612 | QTextStream t( &f ); // use a text stream |
2613 | QString s; | 2613 | QString s; |
2614 | while ( !t.eof() ) { // until end of file... | 2614 | while ( !t.eof() ) { // until end of file... |
2615 | s = t.readLine(); // line of text excluding '\n' | 2615 | s = t.readLine(); // line of text excluding '\n' |
2616 | list.append(s); | 2616 | list.append(s); |
2617 | } | 2617 | } |
2618 | f.close(); | 2618 | f.close(); |
2619 | } | 2619 | } |
2620 | #endif | 2620 | #endif |
2621 | QStringList::Iterator it = list.begin(); | 2621 | QStringList::Iterator it = list.begin(); |
2622 | QString categ; | 2622 | QString categ; |
2623 | QString firstCategory; | 2623 | QString firstCategory; |
2624 | dialog->CategoryField->clear(); // remove all items | 2624 | dialog->CategoryField->clear(); // remove all items |
2625 | while( it != list.end() ) | 2625 | while( it != list.end() ) |
2626 | { | 2626 | { |
2627 | QString *cat = new QString (*it); | 2627 | QString *cat = new QString (*it); |
2628 | if (cat->contains("-field1", FALSE)) | 2628 | if (cat->contains("-field1", FALSE)) |
2629 | { | 2629 | { |
2630 | #ifdef DESKTOP | 2630 | #ifdef DESKTOP |
2631 | #ifndef WIN32 | 2631 | #ifndef WIN32 |
2632 | categ = cat->section ("-field1", 0, 0); | 2632 | categ = cat->section ("-field1", 0, 0); |
2633 | #else | 2633 | #else |
2634 | int pos = cat->find ("-field1"); | 2634 | int pos = cat->find ("-field1"); |
2635 | categ = cat->left (pos); | 2635 | categ = cat->left (pos); |
2636 | #endif | 2636 | #endif |
2637 | #else | 2637 | #else |
2638 | int pos = cat->find ("-field1"); | 2638 | int pos = cat->find ("-field1"); |
2639 | cat->truncate(pos); | 2639 | cat->truncate(pos); |
2640 | categ = *cat; | 2640 | categ = *cat; |
2641 | #endif | 2641 | #endif |
2642 | if (!categ.isEmpty()) | 2642 | if (!categ.isEmpty()) |
2643 | { | 2643 | { |
2644 | dialog->CategoryField->insertItem (categ, -1); | 2644 | dialog->CategoryField->insertItem (categ, -1); |
2645 | if (firstCategory.isEmpty()) | 2645 | if (firstCategory.isEmpty()) |
2646 | firstCategory = categ; | 2646 | firstCategory = categ; |
2647 | } | 2647 | } |
2648 | } | 2648 | } |
2649 | ++it; | 2649 | ++it; |
2650 | } | 2650 | } |
2651 | 2651 | ||
2652 | 2652 | ||
2653 | if (firstCategory.isEmpty()) | 2653 | if (firstCategory.isEmpty()) |
2654 | setCategoryDialogFields(dialog); | 2654 | setCategoryDialogFields(dialog); |
2655 | else | 2655 | else |
2656 | setCategoryDialogFields(dialog, firstCategory); | 2656 | setCategoryDialogFields(dialog, firstCategory); |
2657 | 2657 | ||
2658 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); | 2658 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); |
2659 | 2659 | ||
2660 | if (initIcons) | 2660 | if (initIcons) |
2661 | { | 2661 | { |
2662 | Wait waitDialog(this, tr("Wait dialog")); | 2662 | Wait waitDialog(this, tr("Wait dialog")); |
2663 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 2663 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
2664 | waitDialog.show(); | 2664 | waitDialog.show(); |
2665 | qApp->processEvents(); | 2665 | qApp->processEvents(); |
2666 | 2666 | ||
2667 | #ifdef DESKTOP | 2667 | #ifdef DESKTOP |
2668 | QDir d(iconPath); | 2668 | QDir d(iconPath); |
2669 | #else | 2669 | #else |
2670 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2670 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2671 | #endif | 2671 | #endif |
2672 | d.setFilter( QDir::Files); | 2672 | d.setFilter( QDir::Files); |
2673 | 2673 | ||
2674 | const QFileInfoList *list = d.entryInfoList(); | 2674 | const QFileInfoList *list = d.entryInfoList(); |
2675 | QFileInfoListIterator it( *list ); // create list iterator | 2675 | QFileInfoListIterator it( *list ); // create list iterator |
2676 | QFileInfo *fi; // pointer for traversing | 2676 | QFileInfo *fi; // pointer for traversing |
2677 | 2677 | ||
2678 | dialog->IconField->insertItem("predefined"); | 2678 | dialog->IconField->insertItem("predefined"); |
2679 | while ( (fi=it.current()) ) { // for each file... | 2679 | while ( (fi=it.current()) ) { // for each file... |
@@ -2893,194 +2893,194 @@ void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) | |||
2893 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); | 2893 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); |
2894 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); | 2894 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); |
2895 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); | 2895 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); |
2896 | 2896 | ||
2897 | QString icon; | 2897 | QString icon; |
2898 | Category *cat= categories.find (category); | 2898 | Category *cat= categories.find (category); |
2899 | if (cat) | 2899 | if (cat) |
2900 | { | 2900 | { |
2901 | icon = cat->getIconName(); | 2901 | icon = cat->getIconName(); |
2902 | } | 2902 | } |
2903 | else | 2903 | else |
2904 | icon = conf->readEntry(APP_KEY+category); | 2904 | icon = conf->readEntry(APP_KEY+category); |
2905 | 2905 | ||
2906 | #ifdef DESKTOP | 2906 | #ifdef DESKTOP |
2907 | QDir d(iconPath); | 2907 | QDir d(iconPath); |
2908 | #else | 2908 | #else |
2909 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2909 | QDir d(QPEApplication::qpeDir() + "/pics/"); |
2910 | #endif | 2910 | #endif |
2911 | d.setFilter( QDir::Files); | 2911 | d.setFilter( QDir::Files); |
2912 | 2912 | ||
2913 | const QFileInfoList *list = d.entryInfoList(); | 2913 | const QFileInfoList *list = d.entryInfoList(); |
2914 | int i=0; | 2914 | int i=0; |
2915 | QFileInfoListIterator it( *list ); // create list iterator | 2915 | QFileInfoListIterator it( *list ); // create list iterator |
2916 | QFileInfo *fi; // pointer for traversing | 2916 | QFileInfo *fi; // pointer for traversing |
2917 | if (icon.isEmpty() || icon.isNull()) | 2917 | if (icon.isEmpty() || icon.isNull()) |
2918 | { | 2918 | { |
2919 | dialog->IconField->setCurrentItem(0); | 2919 | dialog->IconField->setCurrentItem(0); |
2920 | } | 2920 | } |
2921 | else | 2921 | else |
2922 | { | 2922 | { |
2923 | while ( (fi=it.current()) ) | 2923 | while ( (fi=it.current()) ) |
2924 | { // for each file... | 2924 | { // for each file... |
2925 | QString fileName = fi->fileName(); | 2925 | QString fileName = fi->fileName(); |
2926 | if(fileName.right(4) == ".png") | 2926 | if(fileName.right(4) == ".png") |
2927 | { | 2927 | { |
2928 | fileName = fileName.mid(0,fileName.length()-4); | 2928 | fileName = fileName.mid(0,fileName.length()-4); |
2929 | 2929 | ||
2930 | if(fileName+".png"==icon) | 2930 | if(fileName+".png"==icon) |
2931 | { | 2931 | { |
2932 | dialog->IconField->setCurrentItem(i+1); | 2932 | dialog->IconField->setCurrentItem(i+1); |
2933 | break; | 2933 | break; |
2934 | } | 2934 | } |
2935 | ++i; | 2935 | ++i; |
2936 | } | 2936 | } |
2937 | ++it; | 2937 | ++it; |
2938 | } | 2938 | } |
2939 | } | 2939 | } |
2940 | } | 2940 | } |
2941 | 2941 | ||
2942 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) | 2942 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) |
2943 | { | 2943 | { |
2944 | QString app_key = APP_KEY; | 2944 | QString app_key = APP_KEY; |
2945 | #ifndef DESKTOP | 2945 | #ifndef DESKTOP |
2946 | conf->setGroup ("fieldDefs"); | 2946 | conf->setGroup ("fieldDefs"); |
2947 | #else | 2947 | #else |
2948 | #ifndef WIN32 | 2948 | #ifndef WIN32 |
2949 | app_key += "/fieldDefs/"; | 2949 | app_key += "/fieldDefs/"; |
2950 | #endif | 2950 | #endif |
2951 | #endif | 2951 | #endif |
2952 | QString category = dialog->CategoryField->currentText(); | 2952 | QString category = dialog->CategoryField->currentText(); |
2953 | // #ifndef WIN32 | 2953 | // #ifndef WIN32 |
2954 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); | 2954 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); |
2955 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); | 2955 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); |
2956 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); | 2956 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); |
2957 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); | 2957 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); |
2958 | conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); | 2958 | conf->writeEntry(app_key+category+"-field5", dialog->Field5->text()); |
2959 | conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); | 2959 | conf->writeEntry(app_key+category+"-field6", dialog->Field6->text()); |
2960 | // #endif | 2960 | // #endif |
2961 | saveConf(); | 2961 | saveConf(); |
2962 | #ifndef DESKTOP | 2962 | #ifndef DESKTOP |
2963 | conf->setGroup ("zsafe"); | 2963 | conf->setGroup ("zsafe"); |
2964 | #endif | 2964 | #endif |
2965 | } | 2965 | } |
2966 | 2966 | ||
2967 | void ZSafe::editCategory() | 2967 | void ZSafe::editCategory() |
2968 | { | 2968 | { |
2969 | if (!selectedItem) | 2969 | if (!selectedItem) |
2970 | return; | 2970 | return; |
2971 | if (isCategory(selectedItem)) | 2971 | if (isCategory(selectedItem)) |
2972 | { | 2972 | { |
2973 | QString category = selectedItem->text(0); | 2973 | QString category = selectedItem->text(0); |
2974 | bool initIcons = false; | 2974 | bool initIcons = false; |
2975 | // open the 'Category' dialog | 2975 | // open the 'Category' dialog |
2976 | CategoryDialog *dialog; | 2976 | CategoryDialog *dialog; |
2977 | if (categoryDialog) | 2977 | if (categoryDialog) |
2978 | { | 2978 | { |
2979 | dialog = categoryDialog; | 2979 | dialog = categoryDialog; |
2980 | } | 2980 | } |
2981 | else | 2981 | else |
2982 | { | 2982 | { |
2983 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); | 2983 | categoryDialog = new CategoryDialog(this, tr("Category"), TRUE); |
2984 | #ifdef WIN32 | 2984 | #ifdef WIN32 |
2985 | categoryDialog->setCaption ("Qt " + tr("Category")); | 2985 | categoryDialog->setCaption ("Qt " + tr("Category")); |
2986 | #endif | 2986 | #endif |
2987 | dialog = categoryDialog; | 2987 | dialog = categoryDialog; |
2988 | connect( dialog->CategoryField, | 2988 | connect( dialog->CategoryField, |
2989 | SIGNAL( activated ( const QString &)), | 2989 | SIGNAL( activated(const QString&)), |
2990 | this, SLOT( categoryFieldActivated( const QString & ) ) ); | 2990 | this, SLOT( categoryFieldActivated(const QString&) ) ); |
2991 | initIcons = true; | 2991 | initIcons = true; |
2992 | } | 2992 | } |
2993 | setCategoryDialogFields(dialog); | 2993 | setCategoryDialogFields(dialog); |
2994 | 2994 | ||
2995 | #ifdef DESKTOP | 2995 | #ifdef DESKTOP |
2996 | #ifndef WIN32 | 2996 | #ifndef WIN32 |
2997 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); | 2997 | QStringList list = conf->entryList( APP_KEY+"/fieldDefs" ); |
2998 | #else | 2998 | #else |
2999 | // read all categories from the config file and store | 2999 | // read all categories from the config file and store |
3000 | // into a list | 3000 | // into a list |
3001 | QFile f (cfgFile); | 3001 | QFile f (cfgFile); |
3002 | QStringList list; | 3002 | QStringList list; |
3003 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 3003 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
3004 | QTextStream t( &f ); // use a text stream | 3004 | QTextStream t( &f ); // use a text stream |
3005 | QString s; | 3005 | QString s; |
3006 | int n = 1; | 3006 | int n = 1; |
3007 | while ( !t.eof() ) { // until end of file... | 3007 | while ( !t.eof() ) { // until end of file... |
3008 | s = t.readLine(); // line of text excluding '\n' | 3008 | s = t.readLine(); // line of text excluding '\n' |
3009 | list.append(s); | 3009 | list.append(s); |
3010 | } | 3010 | } |
3011 | f.close(); | 3011 | f.close(); |
3012 | } | 3012 | } |
3013 | #endif | 3013 | #endif |
3014 | #else | 3014 | #else |
3015 | // read all categories from the config file and store | 3015 | // read all categories from the config file and store |
3016 | // into a list | 3016 | // into a list |
3017 | QFile f (cfgFile); | 3017 | QFile f (cfgFile); |
3018 | QStringList list; | 3018 | QStringList list; |
3019 | if ( f.open(IO_ReadOnly) ) { // file opened successfully | 3019 | if ( f.open(IO_ReadOnly) ) { // file opened successfully |
3020 | QTextStream t( &f ); // use a text stream | 3020 | QTextStream t( &f ); // use a text stream |
3021 | QString s; | 3021 | QString s; |
3022 | while ( !t.eof() ) { // until end of file... | 3022 | while ( !t.eof() ) { // until end of file... |
3023 | s = t.readLine(); // line of text excluding '\n' | 3023 | s = t.readLine(); // line of text excluding '\n' |
3024 | list.append(s); | 3024 | list.append(s); |
3025 | } | 3025 | } |
3026 | f.close(); | 3026 | f.close(); |
3027 | } | 3027 | } |
3028 | #endif | 3028 | #endif |
3029 | QStringList::Iterator it = list.begin(); | 3029 | QStringList::Iterator it = list.begin(); |
3030 | QString categ; | 3030 | QString categ; |
3031 | dialog->CategoryField->clear(); // remove all items | 3031 | dialog->CategoryField->clear(); // remove all items |
3032 | int i=0; | 3032 | int i=0; |
3033 | bool foundCategory = false; | 3033 | bool foundCategory = false; |
3034 | while( it != list.end() ) | 3034 | while( it != list.end() ) |
3035 | { | 3035 | { |
3036 | QString *cat = new QString (*it); | 3036 | QString *cat = new QString (*it); |
3037 | if (cat->contains("-field1", FALSE)) | 3037 | if (cat->contains("-field1", FALSE)) |
3038 | { | 3038 | { |
3039 | #ifdef DESKTOP | 3039 | #ifdef DESKTOP |
3040 | #ifndef WIN32 | 3040 | #ifndef WIN32 |
3041 | categ = cat->section ("-field1", 0, 0); | 3041 | categ = cat->section ("-field1", 0, 0); |
3042 | #else | 3042 | #else |
3043 | int pos = cat->find ("-field1"); | 3043 | int pos = cat->find ("-field1"); |
3044 | categ = cat->left (pos); | 3044 | categ = cat->left (pos); |
3045 | #endif | 3045 | #endif |
3046 | #else | 3046 | #else |
3047 | int pos = cat->find ("-field1"); | 3047 | int pos = cat->find ("-field1"); |
3048 | cat->truncate(pos); | 3048 | cat->truncate(pos); |
3049 | categ = *cat; | 3049 | categ = *cat; |
3050 | #endif | 3050 | #endif |
3051 | if (!categ.isEmpty()) | 3051 | if (!categ.isEmpty()) |
3052 | { | 3052 | { |
3053 | dialog->CategoryField->insertItem (categ, i); | 3053 | dialog->CategoryField->insertItem (categ, i); |
3054 | if (category.compare(categ) == 0) | 3054 | if (category.compare(categ) == 0) |
3055 | { | 3055 | { |
3056 | dialog->CategoryField->setCurrentItem(i); | 3056 | dialog->CategoryField->setCurrentItem(i); |
3057 | foundCategory = true; | 3057 | foundCategory = true; |
3058 | } | 3058 | } |
3059 | i++; | 3059 | i++; |
3060 | } | 3060 | } |
3061 | } | 3061 | } |
3062 | ++it; | 3062 | ++it; |
3063 | } | 3063 | } |
3064 | if (!foundCategory) | 3064 | if (!foundCategory) |
3065 | { | 3065 | { |
3066 | dialog->CategoryField->insertItem (category, i); | 3066 | dialog->CategoryField->insertItem (category, i); |
3067 | dialog->CategoryField->setCurrentItem(i); | 3067 | dialog->CategoryField->setCurrentItem(i); |
3068 | } | 3068 | } |
3069 | 3069 | ||
3070 | QString icon; | 3070 | QString icon; |
3071 | Category *cat= categories.find (selectedItem->text(0)); | 3071 | Category *cat= categories.find (selectedItem->text(0)); |
3072 | if (cat) | 3072 | if (cat) |
3073 | { | 3073 | { |
3074 | icon = cat->getIconName(); | 3074 | icon = cat->getIconName(); |
3075 | } | 3075 | } |
3076 | 3076 | ||
3077 | if (initIcons) | 3077 | if (initIcons) |
3078 | { | 3078 | { |
3079 | 3079 | ||
3080 | Wait waitDialog(this, tr("Wait dialog")); | 3080 | Wait waitDialog(this, tr("Wait dialog")); |
3081 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 3081 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
3082 | waitDialog.show(); | 3082 | waitDialog.show(); |
3083 | qApp->processEvents(); | 3083 | qApp->processEvents(); |
3084 | 3084 | ||
3085 | #ifdef DESKTOP | 3085 | #ifdef DESKTOP |
3086 | QDir d(iconPath); | 3086 | QDir d(iconPath); |