src/miscallenous.cc

changeset 834
3e697ba996e8
parent 818
748ba8818af8
child 840
d077dd19bf9a
equal deleted inserted replaced
833:ad681d97d341 834:3e697ba996e8
288 } 288 }
289 289
290 assert (false); 290 assert (false);
291 return 0.0; 291 return 0.0;
292 } 292 }
293
294
295 // =============================================================================
296 //
297 QString prettyFileSize (qint64 size)
298 {
299 QString result;
300
301 if (size < 1024)
302 return QString::number (size) + " bytes";
303 else if (size < (1024 * 1024))
304 return QString::number ((double) size / 1024, 'f', 1) + " Kb";
305 else if (size < (1024 * 1024 * 1024))
306 return QString::number ((double) size / (1024 * 1024), 'f', 1) + " Mb";
307 else
308 return QString::number ((double) size / (1024 * 1024 * 1024), 'f', 1) + " Gb";
309 }

mercurial