Task::Task(const Task& parent) : INHERITED(parent) , fReporter(parent.fReporter) , fTaskRunner(parent.fTaskRunner) , fDepth(parent.depth()+1) { fReporter->start(); }
inline static SkString find_base_name(const Task& parent, SkTArray<SkString>* suffixList) { const int suffixes = parent.depth() + 1; const SkString& name = parent.name(); const int totalSuffixLength = split_suffixes(suffixes, name.c_str(), suffixList); return SkString(name.c_str(), name.size() - totalSuffixLength); }
Task::Task(const Task& parent) : fReporter(parent.fReporter) , fTaskRunner(parent.fTaskRunner) , fDepth(parent.depth() + 1) { fReporter->taskCreated(); }
//---------------------------------------------------------------------------- // Routines that handle Comma-Separated Values export file format. // QString timetrackerstorage::exportcsvFile(TaskView *taskview, const ReportCriteria &rc) { kDebug(5970) << "Entering function"; QString delim = rc.delimiter; QString dquote = rc.quote; QString double_dquote = dquote + dquote; bool to_quote = true; QString err; Task* task; int maxdepth=0; QString title = i18n("Export Progress"); KProgressDialog dialog( taskview, 0, title ); dialog.setAutoClose( true ); dialog.setAllowCancel( true ); dialog.progressBar()->setMaximum( 2 * taskview->count() ); // The default dialog was not displaying all the text in the title bar. int width = taskview->fontMetrics().width(title) * 3; QSize dialogsize; dialogsize.setWidth(width); dialog.setInitialSize( dialogsize ); if ( taskview->count() > 1 ) dialog.show(); QString retval; // Find max task depth int tasknr = 0; while ( tasknr < taskview->count() && !dialog.wasCancelled() ) { dialog.progressBar()->setValue( dialog.progressBar()->value() + 1 ); if ( tasknr % 15 == 0 ) kapp->processEvents(); // repainting is slow if ( taskview->itemAt(tasknr)->depth() > maxdepth ) maxdepth = taskview->itemAt(tasknr)->depth(); tasknr++; } // Export to file tasknr = 0; while ( tasknr < taskview->count() && !dialog.wasCancelled() ) { task = taskview->itemAt( tasknr ); dialog.progressBar()->setValue( dialog.progressBar()->value() + 1 ); if ( tasknr % 15 == 0 ) kapp->processEvents(); // indent the task in the csv-file: for ( int i=0; i < task->depth(); ++i ) retval += delim; /* // CSV compliance // Surround the field with quotes if the field contains // a comma (delim) or a double quote if (task->name().contains(delim) || task->name().contains(dquote)) to_quote = true; else to_quote = false; */ to_quote = true; if (to_quote) retval += dquote; // Double quotes replaced by a pair of consecutive double quotes retval += task->name().replace( dquote, double_dquote ); if (to_quote) retval += dquote; // maybe other tasks are more indented, so to align the columns: for ( int i = 0; i < maxdepth - task->depth(); ++i ) retval += delim; retval += delim + formatTime( task->sessionTime(), rc.decimalMinutes ) + delim + formatTime( task->time(), rc.decimalMinutes ) + delim + formatTime( task->totalSessionTime(), rc.decimalMinutes ) + delim + formatTime( task->totalTime(), rc.decimalMinutes ) + '\n'; tasknr++; } // save, either locally or remote if ((rc.url.isLocalFile()) || (!rc.url.url().contains("/"))) { QString filename=rc.url.toLocalFile(); if (filename.isEmpty()) filename=rc.url.url(); QFile f( filename ); if( !f.open( QIODevice::WriteOnly ) ) { err = i18n( "Could not open \"%1\".", filename ); } if (err.length()==0) { QTextStream stream(&f); // Export to file stream << retval; f.close(); } } else // use remote file { KTemporaryFile tmpFile; if ( !tmpFile.open() ) err = QString::fromLatin1( "Unable to get temporary file" ); else { QTextStream stream ( &tmpFile ); stream << retval; stream.flush(); if (!KIO::NetAccess::upload( tmpFile.fileName(), rc.url, 0 )) err=QString::fromLatin1("Could not upload"); } } return err; }
WriteTask::WriteTask(const Task& parent, SkBitmap bitmap) : CpuTask(parent), fBitmap(bitmap) { const int suffixes = parent.depth() + 1; const SkString& name = parent.name(); const int totalSuffixLength = split_suffixes(suffixes, name.c_str(), &fSuffixes); fGmName.set(name.c_str(), name.size()-totalSuffixLength); }