author | zautrix <zautrix> | 2005-04-23 20:32:56 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-23 20:32:56 (UTC) |
commit | 119181e56ffd7987ae57749bde85935e29482955 (patch) (unidiff) | |
tree | 194551ded27d91ad912d0cbc7dac29bbd502fc0e /microkde | |
parent | d5787e249e4c60fb8de5141b07f9bb4b94c65868 (diff) | |
download | kdepimpi-119181e56ffd7987ae57749bde85935e29482955.zip kdepimpi-119181e56ffd7987ae57749bde85935e29482955.tar.gz kdepimpi-119181e56ffd7987ae57749bde85935e29482955.tar.bz2 |
fixii
-rw-r--r-- | microkde/kapplication.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp index 2c9e3b6..f36c5ae 100644 --- a/microkde/kapplication.cpp +++ b/microkde/kapplication.cpp | |||
@@ -114,129 +114,132 @@ void KApplication::showText(QString caption, QString text) | |||
114 | lay->setSpacing( 3 ); | 114 | lay->setSpacing( 3 ); |
115 | lay->setMargin( 3 ); | 115 | lay->setMargin( 3 ); |
116 | KTextEdit tb ( &dia ); | 116 | KTextEdit tb ( &dia ); |
117 | tb.setWordWrap( QMultiLineEdit::WidgetWidth ); | 117 | tb.setWordWrap( QMultiLineEdit::WidgetWidth ); |
118 | lay->addWidget( &tb ); | 118 | lay->addWidget( &tb ); |
119 | tb.setText( text ); | 119 | tb.setText( text ); |
120 | #ifdef DESKTOP_VERSION | 120 | #ifdef DESKTOP_VERSION |
121 | dia.resize( 640, 480); | 121 | dia.resize( 640, 480); |
122 | #else | 122 | #else |
123 | dia.showMaximized(); | 123 | dia.showMaximized(); |
124 | #endif | 124 | #endif |
125 | dia.exec(); | 125 | dia.exec(); |
126 | 126 | ||
127 | } | 127 | } |
128 | 128 | ||
129 | #include <qlabel.h> | 129 | #include <qlabel.h> |
130 | #include <qpushbutton.h> | 130 | #include <qpushbutton.h> |
131 | #include <qlayout.h> | 131 | #include <qlayout.h> |
132 | #include <qdir.h> | 132 | #include <qdir.h> |
133 | #include <qradiobutton.h> | 133 | #include <qradiobutton.h> |
134 | #include <qbuttongroup.h> | 134 | #include <qbuttongroup.h> |
135 | #include "kglobal.h" | 135 | #include "kglobal.h" |
136 | #include "klocale.h" | 136 | #include "klocale.h" |
137 | 137 | ||
138 | class KBackupPrefs : public QDialog | 138 | class KBackupPrefs : public QDialog |
139 | { | 139 | { |
140 | public: | 140 | public: |
141 | KBackupPrefs( QString message , QWidget *parent=0, const char *name=0 ) : | 141 | KBackupPrefs( QString message , QWidget *parent=0, const char *name=0 ) : |
142 | QDialog( parent, name, true ) | 142 | QDialog( parent, name, true ) |
143 | { | 143 | { |
144 | setCaption( i18n("Backup Failed!") ); | 144 | setCaption( i18n("Backup Failed!") ); |
145 | QVBoxLayout* lay = new QVBoxLayout( this ); | 145 | QVBoxLayout* lay = new QVBoxLayout( this ); |
146 | lay->setSpacing( 3 ); | 146 | lay->setSpacing( 3 ); |
147 | lay->setMargin( 3 ); | 147 | lay->setMargin( 3 ); |
148 | QLabel * lab = new QLabel( message, this ); | 148 | QLabel * lab = new QLabel( message, this ); |
149 | lay->addWidget( lab ); | 149 | lay->addWidget( lab ); |
150 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Choose action"), this ); | 150 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Choose action"), this ); |
151 | lay->addWidget( format ); | 151 | lay->addWidget( format ); |
152 | format->setExclusive ( true ) ; | 152 | format->setExclusive ( true ) ; |
153 | vcal = new QRadioButton(i18n("Try again now"), format ); | 153 | vcal = new QRadioButton(i18n("Try again now"), format ); |
154 | tcal = new QRadioButton(i18n("Try again later"), format ); | 154 | tcal = new QRadioButton(i18n("Try again later"), format ); |
155 | ical = new QRadioButton(i18n("Try again tomorrow"), format ); | 155 | ical = new QRadioButton(i18n("Try again tomorrow"), format ); |
156 | ocal = new QRadioButton(i18n("Disable backup"), format ); | 156 | ocal = new QRadioButton(i18n("Disable backup"), format ); |
157 | vcal->setChecked( true ); | 157 | vcal->setChecked( true ); |
158 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 158 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
159 | lay->addWidget(ok ); | 159 | lay->addWidget(ok ); |
160 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 160 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
161 | } | 161 | } |
162 | 162 | ||
163 | bool again() { return vcal->isChecked(); } | 163 | bool again() { return vcal->isChecked(); } |
164 | bool later() { return tcal->isChecked(); } | 164 | bool later() { return tcal->isChecked(); } |
165 | bool againTomorrow() { return ical->isChecked(); } | 165 | bool againTomorrow() { return ical->isChecked(); } |
166 | private: | 166 | private: |
167 | QRadioButton* vcal, *ical, *ocal, *tcal; | 167 | QRadioButton* vcal, *ical, *ocal, *tcal; |
168 | }; | 168 | }; |
169 | int KApplication::createBackup( QString fn, QString dp, int numBup ) | 169 | int KApplication::createBackup( QString fn, QString dp, int numBup ) |
170 | { | 170 | { |
171 | if ( numBup < 1) return 3; | 171 | if ( numBup < 1) return 3; |
172 | int ret = 3; | 172 | int ret = 3; |
173 | //qDebug("KApplication::createBackup %s --- %s --- %d", fn.latin1(), dp.latin1(), numBup); | 173 | //qDebug("KApplication::createBackup %s --- %s --- %d", fn.latin1(), dp.latin1(), numBup); |
174 | QDir bupDir ( dp ); | 174 | QDir bupDir ( dp ); |
175 | bool tryAgain = true; | 175 | bool tryAgain = true; |
176 | while ( tryAgain ) { | 176 | while ( tryAgain ) { |
177 | if ( !bupDir.exists() ) { | 177 | if ( !bupDir.exists() ) { |
178 | KBackupPrefs noDir( i18n("<b>Backup directory does not exist: </b>") + dp.right(30)); | 178 | QString bd = dp.right(25); |
179 | if ( dp.length() > 25 ) | ||
180 | bd = "..." + bd; | ||
181 | KBackupPrefs noDir( i18n("<b>Backup directory does not exist: </b>") + bd); | ||
179 | if ( !noDir.exec() ) return 3; | 182 | if ( !noDir.exec() ) return 3; |
180 | if ( noDir.againTomorrow() ) { | 183 | if ( noDir.againTomorrow() ) { |
181 | return 0; | 184 | return 0; |
182 | } else if ( noDir.later() ) { | 185 | } else if ( noDir.later() ) { |
183 | return 3; | 186 | return 3; |
184 | } else if ( !noDir.again() ) { | 187 | } else if ( !noDir.again() ) { |
185 | return 2; | 188 | return 2; |
186 | } | 189 | } |
187 | } else { | 190 | } else { |
188 | tryAgain = false; | 191 | tryAgain = false; |
189 | } | 192 | } |
190 | } | 193 | } |
191 | // we have a valid dir! | 194 | // we have a valid dir! |
192 | QStringList allFileList = bupDir.entryList(QDir::Files); | 195 | QStringList allFileList = bupDir.entryList(QDir::Files); |
193 | QFileInfo fileInfo ( fn ); | 196 | QFileInfo fileInfo ( fn ); |
194 | QString fName = fileInfo.fileName (); | 197 | QString fName = fileInfo.fileName (); |
195 | QStringList fileList; | 198 | QStringList fileList; |
196 | 199 | ||
197 | int i; | 200 | int i; |
198 | for ( i = 0; i < allFileList.count(); ++i ) { | 201 | for ( i = 0; i < allFileList.count(); ++i ) { |
199 | QString fi = allFileList[i]; | 202 | QString fi = allFileList[i]; |
200 | if ( fi. find( fName ) > -1 ) | 203 | if ( fi. find( fName ) > -1 ) |
201 | fileList.append( fi ); | 204 | fileList.append( fi ); |
202 | } | 205 | } |
203 | qDebug("KApp: %d backup files exist ", fileList.count()); | 206 | qDebug("KApp: %d backup files exist ", fileList.count()); |
204 | int count = fileList.count(); | 207 | int count = fileList.count(); |
205 | fileList.sort(); | 208 | fileList.sort(); |
206 | int remCount = 0; | 209 | int remCount = 0; |
207 | while ( count >= numBup ) { | 210 | while ( count >= numBup ) { |
208 | QString fnr = dp + "/"+fileList[remCount]; | 211 | QString fnr = dp + "/"+fileList[remCount]; |
209 | QFile::remove( fnr ); | 212 | QFile::remove( fnr ); |
210 | --count; | 213 | --count; |
211 | ++remCount; | 214 | ++remCount; |
212 | } | 215 | } |
213 | QDateTime mRunStart = QDateTime::currentDateTime(); | 216 | QDateTime mRunStart = QDateTime::currentDateTime(); |
214 | QString file = "%1%2%3-%4%5%6-"; | 217 | QString file = "%1%2%3-%4%5%6-"; |
215 | file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); | 218 | file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); |
216 | file.replace ( QRegExp (" "), "0" ); | 219 | file.replace ( QRegExp (" "), "0" ); |
217 | file += fName ; | 220 | file += fName ; |
218 | file = dp + file; | 221 | file = dp + file; |
219 | QString command; | 222 | QString command; |
220 | int res = 0; | 223 | int res = 0; |
221 | #ifdef _WIN32_ | 224 | #ifdef _WIN32_ |
222 | command = "copy \""+ QDir::convertSeparators( fn)+ "\" \""+QDir::convertSeparators(file)+ "\" "; | 225 | command = "copy \""+ QDir::convertSeparators( fn)+ "\" \""+QDir::convertSeparators(file)+ "\" "; |
223 | #else | 226 | #else |
224 | command = "cp "+ fn+ " "+file; | 227 | command = "cp "+ fn+ " "+file; |
225 | #endif | 228 | #endif |
226 | //qDebug("command %s ",command.latin1() ); | 229 | //qDebug("command %s ",command.latin1() ); |
227 | tryAgain = true; | 230 | tryAgain = true; |
228 | while ( tryAgain ) { | 231 | while ( tryAgain ) { |
229 | res = system ( command.latin1() ); | 232 | res = system ( command.latin1() ); |
230 | qDebug("KApp: Copy result %d ", res); | 233 | qDebug("KApp: Copy result %d ", res); |
231 | if ( res != 0 ) { | 234 | if ( res != 0 ) { |
232 | KBackupPrefs noDir( i18n("<b>The backup copy command failed!</b>")); | 235 | KBackupPrefs noDir( i18n("<b>The backup copy command failed!</b>")); |
233 | if ( !noDir.exec() ) return 3; | 236 | if ( !noDir.exec() ) return 3; |
234 | if ( noDir.againTomorrow() ) { | 237 | if ( noDir.againTomorrow() ) { |
235 | return 0; | 238 | return 0; |
236 | } else if ( noDir.later() ) { | 239 | } else if ( noDir.later() ) { |
237 | return 3; | 240 | return 3; |
238 | } else if ( !noDir.again() ) { | 241 | } else if ( !noDir.again() ) { |
239 | return 2; | 242 | return 2; |
240 | } | 243 | } |
241 | } else { | 244 | } else { |
242 | tryAgain = false; | 245 | tryAgain = false; |