Example #1
0
K3bDataItem* K3bDirItem::takeDataItem( K3bDataItem* item )
{
  int x = m_children.findRef( item );
  if( x > -1 ) {
    K3bDataItem* item = m_children.take();
    updateSize( item, true );
    if( item->isDir() )
      updateFiles( -1*((K3bDirItem*)item)->numFiles(), -1*((K3bDirItem*)item)->numDirs()-1 );
    else
      updateFiles( -1, 0 );

    item->m_parentDir = 0;

    // inform the doc
    if( doc() )
      doc()->itemRemovedFromDir( this, item );

    if( item->isFile() ) {
      // restore the item imported from an old session
      if( static_cast<K3bFileItem*>(item)->replaceItemFromOldSession() )
	addDataItem( static_cast<K3bFileItem*>(item)->replaceItemFromOldSession() );
    }

    return item;
  }
  else
    return 0;
}
Example #2
0
  // Data consumption
  bool dataConsume( istream & argstream )
  {
    bool bRet = false;
    if( argstream.rdstate() == ios::goodbit )
    {
      value = testline;
      while( argstream.rdstate() == ios::goodbit &&
             getline( argstream ) &&
             testline != boundary &&
             testline != endboundary )
      {
        value +="\n";
        value += testline;
      }

      // set the proper state
      if(testline == boundary) state = newData;
      else if(testline == endboundary) state = eof;
      // add the whole item
      addDataItem();
    }
    else
    {
      state = eof;
    }
    return bRet;
  }
Example #3
0
void DataTreeView::dataAdded( const phantom::data& a_Data, serialization::Node* a_pNode)
{
    DataTreeViewItem* pParentItem = getItem(a_pNode);
    o_assert(pParentItem);
    string name = nameOf(a_Data.type()).c_str();
    addDataItem(a_Data);
    sortItems(0, Qt::AscendingOrder);
}
Example #4
0
K3bDirItem::K3bDirItem( const K3bDirItem& item )
  : K3bDataItem( item ),
    m_size(0),
    m_followSymlinksSize(0),
    m_blocks(0),
    m_followSymlinksBlocks(0),
    m_files(0),
    m_dirs(0),
    m_localPath( item.m_localPath )
{
  for( QPtrListIterator<K3bDataItem> it( item.children() ); *it; ++it )
    addDataItem( (*it)->copy() );
}
Example #5
0
void DataTreeView::nodeLoaded()
{
    serialization::Node* pNode = as<serialization::Node*>(phantom::connection::sender());
    phantom::vector<phantom::data> allData;
    pNode->fetchData(allData);
    pNode->getDataBase()->sortOwnerDataFirst(allData.begin(), allData.end());
    for (auto it = allData.begin(); it != allData.end(); it++)
    {
        DataTreeViewItem* pItem = getItem(*it);
        o_assert(pItem == nullptr);
        addDataItem(*it);
    }
    DataTreeViewItem* pNodeItem = getItem(pNode);
    pNodeItem->setIcon(0, pNode->getParentNode() ? m_NodeLoadedIcon : m_NodeRootIcon);
}
Example #6
0
 // data consumption is line oriented until we get to a file attachment
 bool consume( istream & argstream )
 {
   bool bret = true;
   ocString test;
   while(  argstream.rdstate() == ios::goodbit &&
           state != eof &&
           getline( argstream ) )
   {
     writelog2("Consumed",testline);
     switch( state )
     {
     case init:
       // check to see if we just consumed the boundary
       if( boundary != testline )
       {
         state = eof;
       }
       else
       {
         state = newData;
       }
       break;
     case newData:
       // should be reading the content disposition line
       test = testline.parse(": ");
       transform(test.begin(),test.end(),test.begin(),::tolower);
       writelog2("Testing",test);
       if( test == "content-disposition" )
       {
         // good - see what the data is
         test = testline.parse("; ");          
         // Added :: prefix to tolower so SGI recognizes global scope C function
         transform(test.begin(),test.end(),test.begin(),::tolower);          
         // expect it to be form-data
         writelog2("Content Testing",test);
         if( test == "form-data" )
         {
           // parse any remaining parameters
           while( testline.length() && !testline.endOfParse() )
           {
             ocString test = testline.parse("; ");
             writelog2("Param Testing",test);
             if( test.length() )
             {
               string paramname=test.parse("=\"");
               // Added :: prefix to tolower so SGI recognizes global scope C function
               transform(paramname.begin(),paramname.end(),paramname.begin(),::tolower);
               // could be name or filename
               if( paramname == "name" )
               {
                 // set the name
                 name = test.parse("\"");
                 state = dataSep;
               }
               else if( paramname == "filename" )
               {
                 writelog2("Fix Filename",test);
                 fixupFilename(test.parse("\""));
                 writelog("Filename Fixed");
                 state = fileType;
               }
             }
           }
         }
       }
       else
       {
         // unexpected place so abort method call
         state = eof;
       }
       break;
     case fileType:
       // expect Content-Type: image/jpeg
       test = testline.parse(": ");
       // Added :: prefix to tolower so SGI recognizes global scope C function
       transform(test.begin(),test.end(),test.begin(),::tolower);
       if( test == "content-type" )
       {
         type = testline.remainder();
         state = fileSep;
       }
       else
       {
         state = eof;
       }
       break;
     case fileSep:
       if(testline.length() == 0)
       {
         state = readFile;
       }
       else
       {
         state = eof;
       }
       break;
     case dataSep:
       // expect an empty line
       if(testline.length() == 0)
       {
         state = readData;
       }
       else
       {
         state = eof;
       }
       break;
     case readData:
       // expect the data
       dataConsume(argstream);
       break;
     case readFile:
       fileConsume(argstream);
       addFile();
       addDataItem();
       // fileConsume also consumes the boundary (up to the (potential) -- closing)
       state = fileRead;
       break;
     case fileRead:
       if( testline == "--" )
       {
         state = eof;
       }
       state = newData;
       break;
     case finished:
       // see if there is another boundary:
       if( boundary == testline )
       {
         state = newData; // note that the terminating boundary will have -- at the end
       }
       else
       {
         state = eof;
       }
       break;
     default:
       state = eof;
       break;
     } // end switch
   }  // end while
   return bret;
 }
Example #7
0
void DataLayout::addDataItems(const QList<DataItem> &items)
{
	foreach (const DataItem &item, items)
		addDataItem(item);
}