Exemple #1
0
void K3bFileTreeView::addDefaultBranches()
{
  KURL home = KURL::fromPathOrURL( QDir::homeDirPath() );
  KURL root = KURL( "file:/" );

  KFileTreeBranch* treeBranch = addBranch( new K3bFileTreeBranch( this, root, i18n("Root"), SmallIcon("folder_red") ) );
  treeBranch = addBranch( new K3bFileTreeBranch( this, home, i18n("Home"), SmallIcon("folder_home") ) );
  treeBranch->setOpen( true );
}
Exemple #2
0
void DirSelectWidget::setRootPath(const KUrl& rootUrl, const KUrl& currentUrl)
{
    d->m_rootUrl = rootUrl;
    clear();
    QString root = QDir::cleanPath(rootUrl.toLocalFile());

    if (!root.endsWith('/'))
    {
        root.append("/");
    }

    QString currentPath = QDir::cleanPath(currentUrl.isValid() ? currentUrl.toLocalFile() : root);

    d->m_item = addBranch( rootUrl, rootUrl.fileName() );
    setDirOnlyMode( d->m_item, true );
    currentPath      = currentPath.mid( root.length() );
    d->m_pendingPath = currentPath.split('/', QString::KeepEmptyParts);

    if ( !d->m_pendingPath[0].isEmpty() )
    {
        d->m_pendingPath.prepend( "" );    // ensure we open the root first.
    }

    connect( d->m_item, SIGNAL( populateFinished(K3FileTreeViewItem*) ),
             this, SLOT( load() ) );

    load();

    connect( this, SIGNAL( executed(Q3ListViewItem*) ),
             this, SLOT( slotFolderSelected(Q3ListViewItem*) ) );
}
bool CDNAStatement::replaceBranch(unsigned int branchNum, const CDNAStatement& S){
	if(removeBranch(branchNum)) {
		addBranch(branchNum, S);    
		return true;
	}
	return false;
}
/** expands an archiv, if possible */
bool BaseTreeView::expandArchiv (KFileTreeViewItem *item)
{
  if (!item) return false;
  KURL urlToOpen = item->url();

  if ( ! urlToOpen.isLocalFile()) return false;

  QString mimeType = KMimeType::findByURL(urlToOpen)->name();

  if ( mimeType == "application/x-tgz" ||
       mimeType == "application/x-tbz" ||
       mimeType == "application/x-tar" ) //it is an archiv
    urlToOpen.setProtocol("tar");
  else
    if ( mimeType == "application/x-zip" ) //it is an archiv
      urlToOpen.setProtocol("zip");
    else
      return false;

  // change status if there is already a sub branch
  if (item->isExpandable()) {
    item->setOpen( ! item->isOpen());
    return true;
  };

  KFileTreeBranch *kftb = new BaseTreeBranch(this, urlToOpen, item->text(0), *(item->pixmap(0)), true, item);
  addBranch(kftb);  // connecting some signals
  kftb->populate(urlToOpen, item);
  item->setExpandable(true);
  item->setOpen(true);
  return true;
}
void AddressSpace::addBranch( const String &fullPath )
{
	FRL_EXCEPT_GUARD();
	if( rootTag == NULL )
		FRL_THROW_S_CLASS( NotFinalConstruct );
	if( fullPath.empty() )
		FRL_THROW_S_CLASS( InvalidBranchName );
	size_t pos = fullPath.rfind( delimiter + delimiter );
	if ( pos != String::npos )
		FRL_THROW_S_CLASS( InvalidBranchName );
	pos = fullPath.rfind( delimiter );
	if( pos == String::npos )
	{
		Tag *added = rootTag->addBranch( fullPath );
		nameBranchCache.insert( std::pair< String, Tag*>( fullPath, added ) );
		return;
	}
	// last or first symbol in branch name == delimiter
	if( pos == fullPath.size()-1 || pos == 0 )
		FRL_THROW_S_CLASS( InvalidBranchName );
	String tmpPath = fullPath.substr( 0, pos );
	if ( !isExistBranch(tmpPath) )
	{
		addBranch( tmpPath );
	}	
	Tag *added = getBranch( tmpPath )->addBranch( fullPath );
	nameBranchCache.insert( std::pair< String, Tag*>( fullPath, added ) );
}
Exemple #6
0
void K3bFileTreeView::addDeviceBranch( K3bDevice::Device* dev )
{
  K3bDeviceBranch* newBranch = new K3bDeviceBranch( this, dev );
  addBranch( newBranch );

  // search for an equal device
  int equalCnt = 0;
  K3bDeviceBranch* equalBranch = 0;
  for( QMap<KFileTreeBranch*, K3bDevice::Device*>::Iterator it = d->branchDeviceMap.begin();
       it != d->branchDeviceMap.end(); ++it ) {
    K3bDevice::Device* itDev = it.data();
    K3bDeviceBranch* itBranch = (K3bDeviceBranch*)it.key();
    if( itDev->vendor() == dev->vendor() &&
	itDev->description() == dev->description() ) {
      ++equalCnt;
      equalBranch = itBranch;
    }
  }

  // if there is at least one equal device add the block device name
  // if there is more than one equal device they have been updated after
  // adding the last one so there is no need to update more than two
  if( equalCnt > 0 ) {
    kdDebug() << "(K3bFileTreeView) equal branch" << endl;
    newBranch->showBlockDeviceName(true);
    equalBranch->showBlockDeviceName(true);
  }

  // add to maps
  d->branchDeviceMap.insert( newBranch, dev );
  d->deviceBranchDict.insert( (void*)dev, newBranch );

  updateMinimumWidth();
}
Exemple #7
0
void MLScriptLanguage::addLibrary( const QList<LibraryElementInfo>& funsigns )
{
	if (libraries != NULL)
	{
		SyntaxTreeNode* root = libraries->getItem(QModelIndex());
		foreach(LibraryElementInfo st,funsigns)
			addBranch(st,root);
	}
}
Exemple #8
0
void TerminalTracePrinter::visit(TraceConcreteBranch *node)
{
    // First process the left tree.
    node->getFalseBranch()->accept(this);

    // Now mCurrentTree represents the left subtree, so copy it into mCompletedLeftSubtrees.
    mCompletedLeftTrees.push(mCurrentTree);

    // Now clear the current tree and process the right subtree.
    mCurrentTree.clear();
    node->getTrueBranch()->accept(this);

    // Now we have both trees, so join them.
    addBranch("Branch");
}
Tag* AddressSpace::addLeaf( const String &fullPath, Bool createPath )
{
	FRL_EXCEPT_GUARD();
	if( fullPath.empty() )
		FRL_THROW_S_CLASS( InvalidLeafName );
	size_t pos = fullPath.rfind( delimiter + delimiter );
	if ( pos != String::npos )
		FRL_THROW_S_CLASS( InvalidLeafName );
	pos = fullPath.rfind( delimiter );
	if( pos == 0 || pos == fullPath.length()-1 )
		FRL_THROW_S_CLASS( InvalidLeafName );
	if( pos == String::npos )
	{
		if ( rootTag->isExistTag( fullPath ) )
			FRL_THROW_S_CLASS( Tag::IsExistTag );
		rootTag->addLeaf( fullPath );
		Tag *added = rootTag->getLeaf( fullPath );
		nameLeafCache.insert( std::pair< String, Tag*>( fullPath, added ) );
		return added;
	}
	String fullBranchName = fullPath.substr(0, pos );

	try
	{
		//getBranch( fullBranchName )->addLeaf( fullPath );
		if ( !isExistBranch(fullBranchName) )
		{
			addBranch( fullBranchName );
		}
		
		getBranch( fullBranchName )->addLeaf( fullPath );
		Tag *added = getBranch( fullBranchName )->getLeaf( fullPath );
		nameLeafCache.insert( std::pair< String, Tag*>( fullPath, added ) );
		return added;
	}
	catch( Tag::NotExistTag& )
	{
		if( ! createPath )
			FRL_THROW_S_CLASS( Tag::NotExistTag );
	}
	return NULL;
}
Exemple #10
0
void TerminalTracePrinter::visit(TraceSymbolicBranch* node)
{
    // First process the left tree.
    node->getFalseBranch()->accept(this);

    // Now mCurrentTree represents the left subtree, so copy it into mCompletedLeftSubtrees.
    mCompletedLeftTrees.push(mCurrentTree);

    // Now clear the current tree and process the right subtree.
    mCurrentTree.clear();
    node->getTrueBranch()->accept(this);


    QList<QString> branch;
    branch.append("Branch");
    ExpressionValuePrinter exprPrinter;
    node->getSymbolicCondition()->accept(&exprPrinter);
    branch.append(QString(exprPrinter.getResult().c_str()));

    // Now we have both trees, so join them.
    addBranch(branch);
}
Exemple #11
0
FileTreeBranch *ScanGallery::openRoot(const KUrl &root, const QString &title)
{
    FileTreeBranch *branch = addBranch(root, title);

    branch->setOpenPixmap(KIconLoader::global()->loadIcon("folder-image", KIconLoader::Small));
    branch->setShowExtensions(true);

    setDirOnlyMode(branch, false);

    connect(branch, SIGNAL(newTreeViewItems(FileTreeBranch *,const FileTreeViewItemList &)),
            SLOT(slotDecorate(FileTreeBranch *,const FileTreeViewItemList &)));

    connect(branch, SIGNAL(changedTreeViewItems(FileTreeBranch *,const FileTreeViewItemList &)),
            SLOT(slotDecorate(FileTreeBranch *,const FileTreeViewItemList &)));

    connect(branch, SIGNAL(directoryChildCount(FileTreeViewItem *,int)),
            SLOT(slotDirCount(FileTreeViewItem *,int)));

    connect(branch, SIGNAL(populateFinished(FileTreeViewItem *)),
            SLOT(slotStartupFinished(FileTreeViewItem *)));

    return (branch);
}
Exemple #12
0
//
// Add branches.
//
TIntermBranch* TIntermediate::addBranch(
    TOperator branchOp, const TSourceLoc &line)
{
    return addBranch(branchOp, 0, line);
}
void TreeFlattener::AddBranch(std::string _BranchName){
  addBranch(_BranchName);
}
Exemple #14
0
void COSBindingNode::walkBranches(CosNaming::NamingContext_var& nodeContext)
{
	CosNaming::NamingContext_var newNodeContext;
	CosNaming::Binding_var binding( new CosNaming::Binding );

	CosNaming::BindingIterator_var biIterVar( new CosNaming::_objref_BindingIterator );
	CosNaming::BindingIterator_out biIter( biIterVar );

	CosNaming::BindingList_var biListVar( new CosNaming::BindingList );
	CosNaming::BindingList_out biList( biListVar );
	
	CORBA::Object_var obj;

	unsigned i = 0;
	
	if(CORBA::is_nil(nodeContext))
	{
		_isLeaf = true;
		
		//No need to iterate through the tree; this is a leaf.
		return;
	}
	
	try {
		nodeContext->list(0, biList, biIter);
	}
	catch(CORBA::TRANSIENT&) {
		_isDead = true;
	}
	catch(CORBA::INV_OBJREF&) {
		_isLeaf = true;
	}
	catch(CORBA::Exception&) {
	}
	catch(...)  {
		std::cerr << "Other list exception." << std::endl;
	}

	if( isLeaf() )
	{
		//No need to iterate through the tree; this is a leaf.
		return;
	}

	bool deadServantFound = false;

	while(biIter->next_one(binding))
	{
		i++;
		//get the context for this branch and add a new node
		obj = nodeContext->resolve( binding->binding_name );

		try {
			obj->_non_existent();
		}
		catch(CORBA::TRANSIENT&)
		{
			//This is a dead servant. 
			deadServantFound = true;

			addBranch(std::string(omni::omniURI::nameToString(binding->binding_name)));

			//_branches.push_back( 
			//	new COSBindingNode(
			//	omni::omniURI::nameToString( binding->binding_name ), true) );
		}
		catch(CORBA::COMM_FAILURE)
		{
			//This is a dead servant. 
			deadServantFound = true;

			addBranch(std::string(omni::omniURI::nameToString(binding->binding_name)));
			//_branches.push_back(
			//	new COSBindingNode(
			//	omni::omniURI::nameToString( binding->binding_name ), true) );
		}

		if( !deadServantFound )
		{
			try {
				newNodeContext = CosNaming::NamingContext::
					_narrow( obj );
			}
			catch(...)
			{
				std::cerr << "Branch list exception: _narrow" << std::endl;
			}

			try {
				addBranch(std::string(omni::omniURI::nameToString(binding->binding_name)), newNodeContext);
				
				//_branches.push_back( 
				//	new COSBindingNode(
				//	omni::omniURI::nameToString( binding->binding_name ), newNodeContext)
				//	);
			}
			catch(CORBA::INV_OBJREF&)
			{
				std::cerr << "Branch list exception: push_back" << std::endl;
			}
		}
	}

}
void CloudsVisualSystemLSystem::selfUpdate(){

    time = timeline->getCurrentTime()*lsysGrowingSpeed;
    
    dots.clear();
    
    lsysGrowing.clear();
    for(int i = 0; i < lsysNodes.size(); i++){
                
        if (lsysNodes[i].startTime >= 0.0){
            float relativeTime = time - lsysNodes[i].startTime;
            
            for (int j = 0; j < lsysNodes[i].branchesIndex.size(); j++){
                addBranch( lsysGrowing, lsysNodes[i].branchesIndex[j], relativeTime, ofNoise(lsysNodes[i].x+time*0.01,lsysNodes[i].y));
            }
        }
    }
    
    if ( lsysFlowSpeed > 0.0 ){
        for(int i = 0; i < lsysNodes.size(); i++){
            
            if (lsysNodes[i].trailsPct >= 0.0){
                
                if (lsysNodes[i].startTime < 0.0){
                    break;
                }
                
                for (int j = 0; j < lsysNodes[i].branchesIndex.size(); j++){
                    
                    int index = lsysNodes[i].branchesIndex[j];
                    int totalPoints = lsysLines[ index ].size();
                    
                    float line = (totalPoints-1)*lsysNodes[i].trailsPct;
                    int k = line;
                    
                    float pct = line-(int)(line);
                    
                    ofPoint A = lsysLines[ index ][k];
                    ofPoint B = lsysLines[ index ][k+1];
                    ofPoint pos = (1.0-pct)*A + (pct)*B;
                    
                    lsysNodes[i].trails[j].push_back(pos);
                    while (lsysNodes[i].trails[j].size() > lsysFlowLenght) {
                        lsysNodes[i].trails[j].erase(lsysNodes[i].trails[j].begin());
                    }
                }
                
                lsysNodes[i].trailsPct += lsysFlowSpeed*ofNoise(ofGetElapsedTimef()*0.01)*0.01;
                
                if(lsysNodes[i].trailsPct > 1.0){
                    lsysNodes[i].trailsPct = -1.0;
                    for (int j = 0; j < lsysNodes[i].trails.size(); j++){
                        lsysNodes[i].trails[j].clear();
                    }
                }
            } else {
                for (int j = 0; j < lsysNodes[i].trails.size(); j++){
                    lsysNodes[i].trails[j].clear();
                }
                lsysNodes[i].trailsPct = ofRandom(-10.0,0.1);
            }
        }
    }
}
Exemple #16
0
void Rules::start()
{
    if (startRule.empty()) addBranch(DEFAULT_START_RULE);
    else addBranch(startRule);
}
Exemple #17
0
BranchStatement::BranchStatement(Expression& condition){
	addBranch(condition);
}
Exemple #18
0
// Merge two trees into a new tree.
void TerminalTracePrinter::addBranch(QString nodeText)
{
    QList<QString> nodeLines;
    nodeLines.append(nodeText);
    addBranch(nodeLines);
}
Exemple #19
0
void MLScriptLanguage::addBranch( const LibraryElementInfo& mi,SyntaxTreeNode* parent )
{
	if (mi.completename.isEmpty() || (parent == NULL))
		return;
	QString st = mi.completename;
	QVector<QVariant> dt(5,QVariant(QString()));
	int indexpoint = st.indexOf(wordsjoiner);
	if (indexpoint == -1)
	{
		int indexpar = st.indexOf(openpar);
		if (indexpar == -1)
		{
			//is a member
			dt[0] = st;
			dt[1] = mi.help;
			dt[4] = QString::number(MLScriptLanguage::MEMBERFIELD);
		}
		else 
		{
			//is a function. I will add the name of the function and the signature for the tooltip
			dt[0] = st.left(indexpar);
			dt[1] = mi.help;
			dt[3] = st;
			dt[4] = QString::number(MLScriptLanguage::FUNCTION);
		}
		SyntaxTreeNode* ch = parent->findChild(dt);

		//Search if the node is already in the tree
		if (ch == NULL)
		{
			parent->insertChildren(parent->childCount(),1,parent->columnCount());
			ch = parent->child(parent->childCount() - 1);
			for(int ii = 0;ii < 5;++ii)
				ch->setData(ii,dt[ii]);
		}
		return;
	}
	else
	{
		//+1 so I will take also the sep
		QString tmp  = st.left(indexpoint + 1);
		st.remove(tmp);
		QString specificsep = wordsjoiner.cap();
		tmp.remove(wordsjoiner);
		dt[0] = tmp;
		dt[2] = specificsep;
		dt[4] = QString::number(MLScriptLanguage::NAMESPACE);
		SyntaxTreeNode* ch = parent->findChild(dt);
		//Search if the node is already in the tree
		if (ch == NULL)
		{
			parent->insertChildren(parent->childCount(),1,parent->columnCount());
			ch = parent->child(parent->childCount() - 1);
			for(int ii = 0;ii < 5;++ii)
				ch->setData(ii,dt[ii]);
		}
		LibraryElementInfo minext;
		minext.completename = st;
		minext.help = mi.help; 
		addBranch(minext,ch);
	}
}