-rw-r--r-- | pwmanager/pwmanager/csv.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/pwmanager/pwmanager/csv.cpp b/pwmanager/pwmanager/csv.cpp index 194edf2..226cc08 100644 --- a/pwmanager/pwmanager/csv.cpp +++ b/pwmanager/pwmanager/csv.cpp | |||
@@ -23,6 +23,8 @@ | |||
23 | 23 | ||
24 | #include <kmessagebox.h> | 24 | #include <kmessagebox.h> |
25 | #include <klocale.h> | 25 | #include <klocale.h> |
26 | //Added by qt3to4: | ||
27 | #include <Q3CString> | ||
26 | 28 | ||
27 | #define MAX_CSV_FILE_SIZE(50 * 1024 * 1024) // bytes | 29 | #define MAX_CSV_FILE_SIZE(50 * 1024 * 1024) // bytes |
28 | 30 | ||
@@ -42,7 +44,7 @@ bool Csv::importData(const QString &filepath, | |||
42 | bool ret = true; | 44 | bool ret = true; |
43 | QByteArray d; | 45 | QByteArray d; |
44 | QFile f(filepath); | 46 | QFile f(filepath); |
45 | if (!f.open(IO_ReadOnly)) { | 47 | if (!f.open(QIODevice::ReadOnly)) { |
46 | KMessageBox::error(parent, | 48 | KMessageBox::error(parent, |
47 | i18n("Could not open file.\n" | 49 | i18n("Could not open file.\n" |
48 | "Does the file exist?"), | 50 | "Does the file exist?"), |
@@ -89,7 +91,7 @@ bool Csv::doImport(const QByteArray &d, | |||
89 | 91 | ||
90 | int refIndex = 0; | 92 | int refIndex = 0; |
91 | int ret; | 93 | int ret; |
92 | QCString s, curCat; | 94 | Q3CString s, curCat; |
93 | int fieldIndex = 0; | 95 | int fieldIndex = 0; |
94 | bool inRecord = false; | 96 | bool inRecord = false; |
95 | /* fieldIndex is a reference count to see which | 97 | /* fieldIndex is a reference count to see which |
@@ -121,27 +123,27 @@ bool Csv::doImport(const QByteArray &d, | |||
121 | curCat = s; | 123 | curCat = s; |
122 | break; | 124 | break; |
123 | case 1:// desc | 125 | case 1:// desc |
124 | di.desc = s; | 126 | di.desc = std::string(s); |
125 | ++fieldIndex; | 127 | ++fieldIndex; |
126 | break; | 128 | break; |
127 | case 2: // name | 129 | case 2: // name |
128 | di.name = s; | 130 | di.name = std::string(s); |
129 | ++fieldIndex; | 131 | ++fieldIndex; |
130 | break; | 132 | break; |
131 | case 3: // pw | 133 | case 3: // pw |
132 | di.pw = s; | 134 | di.pw = std::string(s); |
133 | ++fieldIndex; | 135 | ++fieldIndex; |
134 | break; | 136 | break; |
135 | case 4: // url | 137 | case 4: // url |
136 | di.url = s; | 138 | di.url = std::string(s); |
137 | ++fieldIndex; | 139 | ++fieldIndex; |
138 | break; | 140 | break; |
139 | case 5: // launcher | 141 | case 5: // launcher |
140 | di.launcher = s; | 142 | di.launcher = std::string(s); |
141 | ++fieldIndex; | 143 | ++fieldIndex; |
142 | break; | 144 | break; |
143 | case 6: // comment | 145 | case 6: // comment |
144 | di.comment = s; | 146 | di.comment = std::string(s); |
145 | ++fieldIndex; | 147 | ++fieldIndex; |
146 | break; | 148 | break; |
147 | default: | 149 | default: |
@@ -154,7 +156,7 @@ bool Csv::doImport(const QByteArray &d, | |||
154 | case 1: | 156 | case 1: |
155 | // record complete. | 157 | // record complete. |
156 | if (fieldIndex == 6) | 158 | if (fieldIndex == 6) |
157 | di.comment = s; | 159 | di.comment = std::string(s); |
158 | inRecord = false; | 160 | inRecord = false; |
159 | fieldIndex = 0; | 161 | fieldIndex = 0; |
160 | doc->addEntry(curCat, &di, true); | 162 | doc->addEntry(curCat, &di, true); |
@@ -175,7 +177,7 @@ bool Csv::doImport(const QByteArray &d, | |||
175 | return false; | 177 | return false; |
176 | } | 178 | } |
177 | 179 | ||
178 | int Csv::nextField(QCString *ret, | 180 | int Csv::nextField(Q3CString *ret, |
179 | const QByteArray &in, | 181 | const QByteArray &in, |
180 | bool inRecord, | 182 | bool inRecord, |
181 | int *_refIndex) | 183 | int *_refIndex) |
@@ -353,7 +355,7 @@ bool Csv::exportData(const QString &filepath, | |||
353 | } | 355 | } |
354 | } | 356 | } |
355 | QFile f(filepath); | 357 | QFile f(filepath); |
356 | if (!f.open(IO_ReadWrite)) { | 358 | if (!f.open(QIODevice::ReadWrite)) { |
357 | KMessageBox::error(parent, | 359 | KMessageBox::error(parent, |
358 | i18n("Could not open file for writing."), | 360 | i18n("Could not open file for writing."), |
359 | i18n("Open error.")); | 361 | i18n("Open error.")); |
@@ -376,7 +378,7 @@ bool Csv::doExport(QFile &f, | |||
376 | unsigned int numEntr; | 378 | unsigned int numEntr; |
377 | unsigned int i, j; | 379 | unsigned int i, j; |
378 | PwMDataItem d; | 380 | PwMDataItem d; |
379 | QCString s, catName; | 381 | Q3CString s, catName; |
380 | QByteArray b; | 382 | QByteArray b; |
381 | 383 | ||
382 | for (i = 0; i < numCat; ++i) { | 384 | for (i = 0; i < numCat; ++i) { |
@@ -401,7 +403,7 @@ bool Csv::doExport(QFile &f, | |||
401 | b = s; | 403 | b = s; |
402 | // remove \0 termination | 404 | // remove \0 termination |
403 | #ifndef PWM_EMBEDDED | 405 | #ifndef PWM_EMBEDDED |
404 | b.resize(b.size() - 1, QGArray::SpeedOptim); | 406 | b.resize(b.size() - 1, Q3GArray::SpeedOptim); |
405 | #else | 407 | #else |
406 | b.resize(b.size() - 1); | 408 | b.resize(b.size() - 1); |
407 | #endif | 409 | #endif |
@@ -412,15 +414,15 @@ bool Csv::doExport(QFile &f, | |||
412 | return true; | 414 | return true; |
413 | } | 415 | } |
414 | 416 | ||
415 | QCString Csv::newField(QCString s) | 417 | Q3CString Csv::newField(Q3CString s) |
416 | { | 418 | { |
417 | if (s.isEmpty()) | 419 | if (s.isEmpty()) |
418 | return QCString(); | 420 | return Q3CString(); |
419 | QCString ret("\""); | 421 | Q3CString ret("\""); |
420 | #ifndef PWM_EMBEDDED | 422 | #ifndef PWM_EMBEDDED |
421 | s.replace('\"', "\"\""); | 423 | s.replace('\"', "\"\""); |
422 | #else | 424 | #else |
423 | s.replace(QRegExp("\""), "\"\""); | 425 | s.replace("\"", "\"\""); |
424 | #endif | 426 | #endif |
425 | ret += s; | 427 | ret += s; |
426 | ret += "\""; | 428 | ret += "\""; |