Subversion Repositories public

Rev

Rev 61 | Rev 68 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 61 Rev 67
Line 20... Line 20...
20
#include <kmessagebox.h>
20
#include <kmessagebox.h>
21
#include <klistview.h>
21
#include <klistview.h>
22
#include <klocale.h>
22
#include <klocale.h>
23
#include <qdir.h>
23
#include <qdir.h>
24
#include <qfile.h>
24
#include <qfile.h>
-
 
25
#include <qclipboard.h>
-
 
26
#include <qapplication.h>
-
 
27
#include <qlabel.h>
25
 
28
 
26
#include <sys/stat.h>
29
#include <sys/stat.h>
27
 
30
 
28
#include "ratenplanwidget.h"
31
#include "ratenplanwidget.h"
29
#include "helper.h"
32
#include "helper.h"
Line 73... Line 76...
73
	   return;
76
	   return;
74
	}
77
	}
75
	
78
	
76
	fstat (tmpFile.handle(), &sbuf);
79
	fstat (tmpFile.handle(), &sbuf);
77
 
80
 
78
	if (sbuf.st_size <= sizeof(TPPARS))
81
	if (sbuf.st_size <= (long)sizeof(TPPARS))
79
	{
82
	{
80
	   tmpFile.close ();
83
	   tmpFile.close ();
81
	   KMessageBox::information(this, i18n("Bitte berechnen sie zuerst einen Tilgungsplan!"));
84
	   KMessageBox::information(this, i18n("Bitte berechnen sie zuerst einen Tilgungsplan!"));
82
	   return;
85
	   return;
83
	}
86
	}
Line 88... Line 91...
88
 
91
 
89
	// Nun lesen wir den Ratenplan aus und schreiben das Ergebnis in die
92
	// Nun lesen wir den Ratenplan aus und schreiben das Ergebnis in die
90
	// Tabelle der Dialogbox.
93
	// Tabelle der Dialogbox.
91
	line = 1;
94
	line = 1;
92
 
95
 
93
	while (read (tmpFile.handle(), &dTable, sizeof(DTABLE)) >= sizeof(DTABLE))
96
	while (read (tmpFile.handle(), &dTable, sizeof(DTABLE)) >= (int)sizeof(DTABLE))
94
	{
97
	{
95
	      zeile.sprintf("%04d", line);
98
	      zeile.sprintf("%04d", line);
96
	      date_int(&day, &mon, &year, dTable.datum);
99
	      date_int(&day, &mon, &year, dTable.datum);
97
	      datum.sprintf("%02d.%02d.%d", day, mon, year);
100
	      datum.sprintf("%02d.%02d.%d", day, mon, year);
98
 
101
 
Line 138... Line 141...
138
void ratenplanWidget::pbCancelSlot()
141
void ratenplanWidget::pbCancelSlot()
139
{
142
{
140
	done(QDialog::Accepted);
143
	done(QDialog::Accepted);
141
}
144
}
142
 
145
 
-
 
146
void ratenplanWidget::lbSelSlot(QListViewItem *item)
-
 
147
{
-
 
148
QString zeile;
-
 
149
QClipboard *cb = QApplication::clipboard();
-
 
150
 
-
 
151
	zeile.append(item->text(1).ascii());	// Datum
-
 
152
	zeile.append("\t");
-
 
153
	zeile.append(item->text(2).ascii());	// Text
-
 
154
	zeile.append("\t");
-
 
155
	zeile.append(item->text(3).ascii());	// Kapital
-
 
156
	zeile.append("\t");
-
 
157
	zeile.append(item->text(4).ascii());	// Tilgung
-
 
158
	zeile.append("\t");
-
 
159
	zeile.append(item->text(5).ascii());	// Rate
-
 
160
	zeile.append("\t");
-
 
161
	zeile.append(item->text(6).ascii());	// Zinsen
-
 
162
	zeile.append("\t");
-
 
163
	zeile.append(item->text(7).ascii());	// Restkapital
-
 
164
 
-
 
165
	cb->setText(zeile);
-
 
166
	textLabel_Status->setText(QString("Zeile %1 des Ratenplans wurde in Zwischenablage kopiert").arg(item->text(0).ascii()));
-
 
167
}
-
 
168
 
-
 
169
void ratenplanWidget::pbClipboardSlot()
-
 
170
{
-
 
171
QString hdir = QDir::homeDirPath ();
-
 
172
QString zeile, str;
-
 
173
QFile tmpFile;
-
 
174
TPPARS TpPars;
-
 
175
DTABLE dTable;
-
 
176
int day, mon, year, line;
-
 
177
char hv0[128];
-
 
178
struct stat sbuf;
-
 
179
QClipboard *cb = QApplication::clipboard();
-
 
180
 
-
 
181
	hdir.append("/.date_tbl.dat");
-
 
182
	tmpFile.setName(hdir);
-
 
183
 
-
 
184
	if (tmpFile.open(IO_ReadOnly) == FALSE)
-
 
185
	{
-
 
186
	   KMessageBox::error(0, QString("Could not open file for reading: %1").arg(tmpFile.errorString()));
-
 
187
	   return;
-
 
188
	}
-
 
189
	
-
 
190
	fstat (tmpFile.handle(), &sbuf);
-
 
191
 
-
 
192
	if (sbuf.st_size <= (long)sizeof(TPPARS))
-
 
193
	{
-
 
194
	   tmpFile.close ();
-
 
195
	   KMessageBox::information(this, i18n("Bitte berechnen sie zuerst einen Tilgungsplan!"));
-
 
196
	   return;
-
 
197
	}
-
 
198
 
-
 
199
	// Als erstes befindet sich die Struktur mit den Parametern und
-
 
200
	// Summenergebnissen in der Datei.
-
 
201
	read(tmpFile.handle(), &TpPars, sizeof(TPPARS));
-
 
202
	// Diese schreiben wir als erstes in das Clipboard
-
 
203
	zeile = QString("Auszahlungsbetrag:\t%1\n").arg(PointNumber(TpPars.rahmen, 2, &hv0[0]));
-
 
204
	date_int(&day, &mon, &year, TpPars.ragab);
-
 
205
	str.sprintf("Auszahlung am:\t%02d.%02d.%d\n", day, mon, year);
-
 
206
	zeile.append(str);
-
 
207
	str.sprintf("Zinssatz Soll:\t%s\n\n", PointNumber(TpPars.zssoll, 3, &hv0[0]));
-
 
208
	zeile.append(str);
-
 
209
 
-
 
210
	// Nun lesen wir den Ratenplan aus und schreiben das Ergebnis in das
-
 
211
	// Clipboard
-
 
212
	// Überschrift
-
 
213
	zeile.append("Datum\tText\tKapital\tTilgung\tRate\tZinsen\tRestkapital\n");
-
 
214
	// Loop
-
 
215
	line = 1;
-
 
216
 
-
 
217
	while (read (tmpFile.handle(), &dTable, sizeof(DTABLE)) >= (int)sizeof(DTABLE))
-
 
218
	{
-
 
219
	      date_int(&day, &mon, &year, dTable.datum);
-
 
220
 
-
 
221
	      if (dTable.kz != 'E')
-
 
222
		 str.sprintf("%02d.%02d.%d\t", day, mon, year);
-
 
223
	      else
-
 
224
		 str.sprintf("Raten: %ld\t", dTable.datum);
-
 
225
 
-
 
226
	      zeile.append(str);
-
 
227
 
-
 
228
	      switch (dTable.kz)
-
 
229
	      {
-
 
230
		 case 'A': zeile.append("Abschluss\t"); break;
-
 
231
		 case 'R': zeile.append("Rate\t"); break;
-
 
232
		 case 'Z':
-
 
233
		    str = QString("Zinssatzänderung auf %1\n").arg(dTable.rate, 0, 'f', 3);
-
 
234
		    zeile.append(str);
-
 
235
		 break;
-
 
236
		 case 'E': zeile.append("Ergebnis\t"); break;
-
 
237
		 default:
-
 
238
		    str = QString("??? <%1>\t").arg(dTable.kz);
-
 
239
		    zeile.append(str);
-
 
240
	      }
-
 
241
 
-
 
242
	      if (dTable.kz != 'Z')
-
 
243
	      {
-
 
244
		 str = QString("%1\t").arg(PointNumber(dTable.kapital, 2, &hv0[0]));
-
 
245
		 zeile.append(str);
-
 
246
		 str = QString("%1\t").arg(PointNumber(dTable.tilg, 2, &hv0[0]));
-
 
247
		 zeile.append(str);
-
 
248
		 str = QString("%1\t").arg(PointNumber(dTable.rate, 2, &hv0[0]));
-
 
249
		 zeile.append(str);
-
 
250
		 str = QString("%1\t").arg(PointNumber(dTable.zinsen, 2, &hv0[0]));
-
 
251
		 zeile.append(str);
-
 
252
		 str = QString("%1\n").arg(PointNumber(dTable.rkapi, 2, &hv0[0]));
-
 
253
		 zeile.append(str);
-
 
254
	      }
-
 
255
	      else
-
 
256
	      {
-
 
257
		 str = QString("\t\t\t\t\n");
-
 
258
		 zeile.append(str);
-
 
259
	      }
-
 
260
	      line++;
-
 
261
	}
-
 
262
 
-
 
263
	tmpFile.close();
-
 
264
	cb->setText(zeile);
-
 
265
	textLabel_Status->setText(i18n("Ratenplan wurde in Zwischenablage kopiert"));
-
 
266
}
-
 
267
 
-
 
268
void ratenplanWidget::pbSaveSlot()
-
 
269
{
-
 
270
}
-
 
271
 
-
 
272
 
143
#include "ratenplanwidget.moc"
273
#include "ratenplanwidget.moc"
144
 
274