Diffstat (limited to 'noncore/apps/checkbook/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/checkbook/mainwindow.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/noncore/apps/checkbook/mainwindow.cpp b/noncore/apps/checkbook/mainwindow.cpp index 567b8ad..2c0abf1 100644 --- a/noncore/apps/checkbook/mainwindow.cpp +++ b/noncore/apps/checkbook/mainwindow.cpp | |||
@@ -18,26 +18,28 @@ | |||
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 "mainwindow.h" | 29 | #include "mainwindow.h" |
30 | #include "password.h" | ||
30 | #include "checkbook.h" | 31 | #include "checkbook.h" |
31 | 32 | ||
33 | #include <qpe/config.h> | ||
32 | #include <qpe/global.h> | 34 | #include <qpe/global.h> |
33 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
34 | #include <qpe/qpemenubar.h> | 36 | #include <qpe/qpemenubar.h> |
35 | #include <qpe/qpemessagebox.h> | 37 | #include <qpe/qpemessagebox.h> |
36 | #include <qpe/qpetoolbar.h> | 38 | #include <qpe/qpetoolbar.h> |
37 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
38 | 40 | ||
39 | #include <qaction.h> | 41 | #include <qaction.h> |
40 | #include <qdir.h> | 42 | #include <qdir.h> |
41 | #include <qlistbox.h> | 43 | #include <qlistbox.h> |
42 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
43 | #include <qstring.h> | 45 | #include <qstring.h> |
@@ -96,59 +98,75 @@ MainWindow::MainWindow() | |||
96 | { | 98 | { |
97 | QStringList checkbooks = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, | 99 | QStringList checkbooks = checkdir.entryList( "*.qcb", QDir::Files|QDir::Readable|QDir::Writable, |
98 | QDir::Time ); | 100 | QDir::Time ); |
99 | for ( QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++ ) | 101 | for ( QStringList::Iterator it = checkbooks.begin(); it != checkbooks.end(); it++ ) |
100 | { | 102 | { |
101 | (*it) = (*it).remove( (*it).find('.'), (*it).length() ); | 103 | (*it) = (*it).remove( (*it).find('.'), (*it).length() ); |
102 | } | 104 | } |
103 | cbList->insertStringList( checkbooks ); | 105 | cbList->insertStringList( checkbooks ); |
104 | } | 106 | } |
105 | cbList->sort(); | 107 | cbList->sort(); |
106 | cbList->setSelected( 0, TRUE ); | 108 | cbList->setSelected( 0, TRUE ); |
107 | 109 | ||
108 | currencySymbol = '$'; | 110 | currencySymbol = "$"; |
109 | } | 111 | } |
110 | 112 | ||
111 | MainWindow::~MainWindow() | 113 | MainWindow::~MainWindow() |
112 | { | 114 | { |
113 | } | 115 | } |
114 | 116 | ||
115 | void MainWindow::slotNew() | 117 | void MainWindow::slotNew() |
116 | { | 118 | { |
117 | Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol ); | 119 | Checkbook *currcb = new Checkbook( this, "", cbDir, currencySymbol ); |
118 | currcb->showMaximized(); | 120 | currcb->showMaximized(); |
119 | if ( currcb->exec() == QDialog::Accepted ) | 121 | if ( currcb->exec() == QDialog::Accepted ) |
120 | { | 122 | { |
121 | cbList->insertItem( currcb->getName() ); | 123 | cbList->insertItem( currcb->getName() ); |
122 | cbList->sort(); | 124 | cbList->sort(); |
123 | delete currcb; | 125 | delete currcb; |
124 | } | 126 | } |
125 | } | 127 | } |
126 | 128 | ||
127 | void MainWindow::slotEdit() | 129 | void MainWindow::slotEdit() |
128 | { | 130 | { |
129 | QString currname = cbList->currentText(); | 131 | QString currname = cbList->currentText(); |
132 | |||
133 | QString tempstr = cbDir; | ||
134 | tempstr.append( currname ); | ||
135 | tempstr.append( ".qcb" ); | ||
136 | |||
137 | Config config( tempstr, Config::File ); | ||
138 | config.setGroup( "Account" ); | ||
139 | QString password = config.readEntryCrypt( "Password", "" ); | ||
140 | if ( password != "" ) | ||
141 | { | ||
142 | Password *pw = new Password( this, tr( "Enter password" ), tr( "Please enter your password:" ) ); | ||
143 | if ( pw->exec() != QDialog::Accepted || pw->password != password ) | ||
144 | { | ||
145 | delete pw; | ||
146 | return; | ||
147 | } | ||
148 | delete pw; | ||
149 | } | ||
150 | |||
130 | Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol ); | 151 | Checkbook *currcb = new Checkbook( this, currname, cbDir, currencySymbol ); |
131 | currcb->showMaximized(); | 152 | currcb->showMaximized(); |
132 | if ( currcb->exec() == QDialog::Accepted ) | 153 | if ( currcb->exec() == QDialog::Accepted ) |
133 | { | 154 | { |
134 | QString newname = currcb->getName(); | 155 | QString newname = currcb->getName(); |
135 | if ( currname != newname ) | 156 | if ( currname != newname ) |
136 | { | 157 | { |
137 | cbList->changeItem( newname, cbList->currentItem() ); | 158 | cbList->changeItem( newname, cbList->currentItem() ); |
138 | cbList->sort(); | 159 | cbList->sort(); |
139 | 160 | ||
140 | QString tempstr = cbDir; | ||
141 | tempstr.append( currname ); | ||
142 | tempstr.append( ".qcb" ); | ||
143 | QFile f( tempstr ); | 161 | QFile f( tempstr ); |
144 | if ( f.exists() ) | 162 | if ( f.exists() ) |
145 | { | 163 | { |
146 | f.remove(); | 164 | f.remove(); |
147 | } | 165 | } |
148 | } | 166 | } |
149 | delete currcb; | 167 | delete currcb; |
150 | } | 168 | } |
151 | } | 169 | } |
152 | 170 | ||
153 | void MainWindow::slotDelete() | 171 | void MainWindow::slotDelete() |
154 | { | 172 | { |