[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepim/karm
From:       Thorsten Staerk <dev () staerk ! de>
Date:       2006-04-08 16:52:56
Message-ID: 1144515176.189622.25420.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 527557 by tstaerk:

un-bloating the UI

 M  +0 -193    karmstorage.cpp  
 M  +0 -26     karmstorage.h  
 M  +1 -5      karmui.rc  
 M  +0 -32     taskview.cpp  
 M  +0 -3      taskview.h  


--- trunk/KDE/kdepim/karm/karmstorage.cpp #527556:527557
@@ -371,199 +371,6 @@
 }
 
 //----------------------------------------------------------------------------
-// Routines that handle legacy flat file format.
-// These only stored total and session times.
-//
-
-QString KarmStorage::loadFromFlatFile(TaskView* taskview,
-    const QString& filename)
-{
-  QString err;
-
-  kDebug(5970)
-    << "KarmStorage::loadFromFlatFile: " << filename << endl;
-
-  QFile f(filename);
-  if( !f.exists() )
-    err = i18n("File \"%1\" not found.").arg(filename);
-
-  if (!err.isEmpty())
-  {
-    if( !f.open( QIODevice::ReadOnly ) )
-      err = i18n("Could not open \"%1\".").arg(filename);
-  }
-
-  if (!err.isEmpty())
-  {
-
-    QString line;
-
-    Q3PtrStack<Task> stack;
-    Task *task;
-
-    QTextStream stream(&f);
-
-    while( !stream.atEnd() ) {
-      // lukas: this breaks for non-latin1 chars!!!
-      // if ( file.readLine( line, T_LINESIZE ) == 0 )
-      //   break;
-
-      line = stream.readLine();
-      kDebug(5970) << "DEBUG: line: " << line << "\n";
-
-      if (line.isNull())
-        break;
-
-      long minutes;
-      int level;
-      QString name;
-      DesktopList desktopList;
-      if (!parseLine(line, &minutes, &name, &level, &desktopList))
-        continue;
-
-      unsigned int stackLevel = stack.count();
-      for (unsigned int i = level; i<=stackLevel ; i++) {
-        stack.pop();
-      }
-
-      if (level == 1) {
-        kDebug(5970) << "KarmStorage::loadFromFlatFile - toplevel task: "
-          << name << " min: " << minutes << "\n";
-        task = new Task(name, minutes, 0, desktopList, taskview);
-        task->setUid(addTask(task, 0));
-      }
-      else {
-        Task *parent = stack.top();
-        kDebug(5970) << "KarmStorage::loadFromFlatFile - task: " << name
-            << " min: " << minutes << " parent" << parent->name() << "\n";
-        task = new Task(name, minutes, 0, desktopList, parent);
-
-        task->setUid(addTask(task, parent));
-
-        // Legacy File Format (!):
-        parent->changeTimes(0, -minutes);
-        taskview->setRootIsDecorated(true);
-        parent->setOpen(true);
-      }
-      if (!task->uid().isNull())
-        stack.push(task);
-      else
-        delete task;
-    }
-
-    f.close();
-
-  }
-
-  return err;
-}
-
-QString KarmStorage::loadFromFlatFileCumulative(TaskView* taskview,
-    const QString& filename)
-{
-  QString err = loadFromFlatFile(taskview, filename);
-  if (!err.isEmpty())
-  {
-    for (Task* task = taskview->first_child(); task;
-        task = task->nextSibling())
-    {
-      adjustFromLegacyFileFormat(task);
-    }
-  }
-  return err;
-}
-
-bool KarmStorage::parseLine(QString line, long *time, QString *name,
-    int *level, DesktopList* desktopList)
-{
-  if (line.find('#') == 0) {
-    // A comment line
-    return false;
-  }
-
-  int index = line.find('\t');
-  if (index == -1) {
-    // This doesn't seem like a valid record
-    return false;
-  }
-
-  QString levelStr = line.left(index);
-  QString rest = line.remove(0,index+1);
-
-  index = rest.find('\t');
-  if (index == -1) {
-    // This doesn't seem like a valid record
-    return false;
-  }
-
-  QString timeStr = rest.left(index);
-  rest = rest.remove(0,index+1);
-
-  bool ok;
-
-  index = rest.find('\t'); // check for optional desktops string
-  if (index >= 0) {
-    *name = rest.left(index);
-    QString deskLine = rest.remove(0,index+1);
-
-    // now transform the ds string (e.g. "3", or "1,4,5") into
-    // an DesktopList
-    QString ds;
-    int d;
-    int commaIdx = deskLine.find(',');
-    while (commaIdx >= 0) {
-      ds = deskLine.left(commaIdx);
-      d = ds.toInt(&ok);
-      if (!ok)
-        return false;
-
-      desktopList->push_back(d);
-      deskLine.remove(0,commaIdx+1);
-      commaIdx = deskLine.find(',');
-    }
-
-    d = deskLine.toInt(&ok);
-
-    if (!ok)
-      return false;
-
-    desktopList->push_back(d);
-  }
-  else {
-    *name = rest.remove(0,index+1);
-  }
-
-  *time = timeStr.toLong(&ok);
-
-  if (!ok) {
-    // the time field was not a number
-    return false;
-  }
-  *level = levelStr.toInt(&ok);
-  if (!ok) {
-    // the time field was not a number
-    return false;
-  }
-
-  return true;
-}
-
-void KarmStorage::adjustFromLegacyFileFormat(Task* task)
-{
-  // unless the parent is the listView
-  if ( task->parent() )
-    task->parent()->changeTimes(-task->sessionTime(), -task->time());
-
-  // traverse depth first -
-  // as soon as we're in a leaf, we'll substract it's time from the parent
-  // then, while descending back we'll do the same for each node untill
-  // we reach the root
-  for ( Task* subtask = task->firstChild(); subtask;
-      subtask = subtask->nextSibling() )
-    adjustFromLegacyFileFormat(subtask);
-}
-
-//----------------------------------------------------------------------------
 // Routines that handle Comma-Separated Values export file format.
 //
 QString KarmStorage::exportcsvFile( TaskView *taskview,
--- trunk/KDE/kdepim/karm/karmstorage.h #527556:527557
@@ -122,32 +122,6 @@
     QString save(TaskView* taskview);
 
     /**
-     * Read tasks and their total times from a text file (legacy storage).
-     *
-     * This reads from one of the two legacy file formats.  In this version,
-     * the parent task times do not include the sum of all their children's
-     * times.
-     *
-     * The format of the file is zero or more lines of:
-     *    1         task id (a number)
-     *    time      in minutes
-     *    string    task name
-     *    [string]  desktops, in which to count. e.g. "1,2,5" (optional)
-     */
-    QString loadFromFlatFile(TaskView* taskview, const QString& filename);
-
-    /**
-     *  Reads tasks and their total times from text file (legacy).
-     *
-     *  This is the older legacy format, where the task totals included the
-     *  children totals.
-     *
-     *  @see loadFromFlatFile
-     */
-    QString loadFromFlatFileCumulative(TaskView* taskview,
-        const QString& filename);
-
-    /**
      Output a report based on contents of ReportCriteria.
      */
     QString report( TaskView *taskview, const ReportCriteria &rc );
--- trunk/KDE/kdepim/karm/karmui.rc #527556:527557
@@ -5,11 +5,7 @@
     <Action name="start_new_session" />
     <Action name="reset_all_times" />
     <Separator />
-    <Menu name="import">
-      <text>&amp;Import</text>
-      <Action name="import_flatfile" />
-      <Action name="import_planner" />
-    </Menu>
+    <Action name="import_planner" />
     <Action name="export_times" />
     <Action name="export_history" />
   </Menu>
--- trunk/KDE/kdepim/karm/taskview.cpp #527556:527557
@@ -265,38 +265,6 @@
   kDebug(5970) << "exiting TaskView::refresh()" << endl;
 }
     
-void TaskView::loadFromFlatFile()
-{
-  kDebug(5970) << "TaskView::loadFromFlatFile()" << endl;
-
-  //KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
-
-  QString fileName(KFileDialog::getOpenFileName(QString(), QString(),
-        0));
-  if (!fileName.isEmpty()) {
-    QString err = _storage->loadFromFlatFile(this, fileName);
-    if (!err.isEmpty())
-    {
-      KMessageBox::error(this, err);
-      return;
-    }
-    // Register tasks with desktop tracker
-    int task_idx = 0;
-    Task* task = item_at_index(task_idx++);
-    while (task)
-    {
-      // item_at_index returns 0 where no more items.
-      _desktopTracker->registerForDesktops( task, task->getDesktops() );
-      task = item_at_index(task_idx++);
-    }
-
-    setSelected(first_child(), true);
-    setCurrentItem(first_child());
-
-    _desktopTracker->startTracking();
-  }
-}
-
 QString TaskView::importPlanner(QString fileName)
 {
   kDebug(5970) << "entering importPlanner" << endl;
--- trunk/KDE/kdepim/karm/taskview.h #527556:527557
@@ -105,9 +105,6 @@
      /** Used to refresh (e.g. after import) */
     void refresh();
 
-   /** Used to import a legacy file format. */
-    void loadFromFlatFile();
-
     /** used to import tasks from imendio planner */
     QString importPlanner( QString fileName="" );
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic