Ejemplo n.º 1
0
void browsers::TDTbrowser::OnTELLaddcell(wxString cellname, wxString parentname, int action) {
   wxTreeItemId item, newparent;
   switch (action) {
      case 0: {//new cell
         wxTreeItemId item = AppendItem(GetRootItem(), cellname);
         SetItemTextColour(item,GetItemTextColour(GetRootItem()));
         break;
      }   
      case 1: {//first reference of existing cell
         assert(findItem(cellname, item, GetRootItem()));
         while (findItem(parentname, newparent, GetRootItem())) 
            copyItem(item,newparent);
         DeleteChildren(item);
         Delete(item);
         break;
      }   
      case 2: {//
         assert(findItem(cellname, item, GetRootItem()));
         while (findItem(parentname, newparent, GetRootItem())) 
            copyItem(item,newparent);
         break;
      }
      default: assert(false);
   }
}
Ejemplo n.º 2
0
extern void Enqueue (Item X, Queue *Q) {
	
	#ifdef DEBUG
  	Item Y;
	int oldSize=Size(Q);
	if(Full(Q)) {
		printf("Violated precondition for Insert!\n");
		exit(EXIT_FAILURE);
	}
	#endif
	
	if (Q->size == 0) {  /*Checks to see if queue is empty*/
		Q->tail = Q->head;
	} else {
		Q->tail = Q->tail + 1;
	}
	if (Q->tail == MAXQUEUESIZE)
	{
		Q->tail = 0;  /*Circles through queue*/
	}
	copyItem(&Q->items[Q->tail],X);
	Q->size++;

	#ifdef DEBUG
	Tail(Q,&Y);
	if(Empty(Q) || Size(Q)!=oldSize+1 || !equalItems(Y,Q->items[Q->tail])) {
		printf("Violated postcondition for Insert!\n");
		exit(EXIT_FAILURE);
	}
	#endif
}
Ejemplo n.º 3
0
void Insert (Item X, int position, List *L) {
	ListNode *p, *q;
	assert(position >= 0);
	assert(position <= L->size);
	
	L->size++;
	q=(ListNode *)malloc(sizeof(ListNode));
	copyItem(&q->item,X);
			 
	if(position==0) {
		q->next=L->first;
		L->first=q;
	}
	else {
		p=moveTo(position-1,L);
		q->next=p->next;
		p->next=q;
	}
	assert(Empty(L) == 0);
	assert(Size(L) == L->size);
	Peek(position, L, &X);
	assert(strcmp(q->item.name, X.name) == 0);
	assert(q->item.grade == X.grade);
	
}
Ejemplo n.º 4
0
    void TradeItemModel::transferItems()
    {
        std::vector<ItemStack>::iterator it = mBorrowedToUs.begin();
        for (; it != mBorrowedToUs.end(); ++it)
        {
            // get index in the source model
            ItemModel* sourceModel = it->mCreator;
            size_t i=0;
            for (; i<sourceModel->getItemCount(); ++i)
            {
                if (it->mBase == sourceModel->getItem(i).mBase)
                    break;
            }
            if (i == sourceModel->getItemCount())
                throw std::runtime_error("The borrowed item disappeared");

            // reset owner while copying, but only for items bought by the player
            bool setNewOwner = (mMerchant.isEmpty());
            const ItemStack& item = sourceModel->getItem(i);
            // copy the borrowed items to our model
            copyItem(item, it->mCount, setNewOwner);
            // then remove them from the source model
            sourceModel->removeItem(item, it->mCount);
        }
        mBorrowedToUs.clear();
        mBorrowedFromUs.clear();
    }
Ejemplo n.º 5
0
    void TradeItemModel::transferItems()
    {
        std::vector<ItemStack>::iterator it = mBorrowedToUs.begin();
        for (; it != mBorrowedToUs.end(); ++it)
        {
            // get index in the source model
            ItemModel* sourceModel = it->mCreator;
            size_t i=0;
            for (; i<sourceModel->getItemCount(); ++i)
            {
                if (it->mBase == sourceModel->getItem(i).mBase)
                    break;
            }
            if (i == sourceModel->getItemCount())
                throw std::runtime_error("The borrowed item disappeared");

            const ItemStack& item = sourceModel->getItem(i);
            // copy the borrowed items to our model
            copyItem(item, it->mCount);
            // then remove them from the source model
            sourceModel->removeItem(item, it->mCount);
        }
        mBorrowedToUs.clear();
        mBorrowedFromUs.clear();
    }
Ejemplo n.º 6
0
void Peek (int position, List *L, Item *X) {
	ListNode *p;
	assert(position>=0);
	assert(position<=L->size);
	assert(Empty(L) == 0);
	p=moveTo(position,L);
	copyItem(X,p->item);
}
Ejemplo n.º 7
0
extern void Tail (Queue *Q, Item *I) {
	#ifdef DEBUG
	if(Empty(Q)) {
		printf("Violated precondition for Remove!\n");
		exit(EXIT_FAILURE);
	}
	#endif
	copyItem(I, Q->items[Q->tail]);
}
void Head (Queue *Q, Item *I) {
#ifdef DEBUG
	if(Empty(Q)) {
		printf("Violated precondition for Head!\n");
		exit(EXIT_FAILURE);
	}
#endif
	copyItem(I,Q->items[Q->head]);
	Q->head++;
	if(Q->head >= MAXQUEUESIZE)
		Q->head = Q->head - MAXQUEUESIZE;
}
Ejemplo n.º 9
0
void browsers::CellBrowser::copyItem(const wxTreeItemId item, const wxTreeItemId newparent) {
   wxTreeItemId newitem = AppendItem(newparent, GetItemText(item));
   SetItemImage(newitem, GetItemImage(item,wxTreeItemIcon_Normal), wxTreeItemIcon_Normal);
   SetItemImage(newitem, GetItemImage(item,wxTreeItemIcon_Expanded), wxTreeItemIcon_Expanded);
   SetItemImage(newparent,0,wxTreeItemIcon_Normal);
   SetItemImage(newparent,1,wxTreeItemIcon_Expanded);
   SetItemTextColour(newitem, GetItemTextColour(newparent));
   wxTreeItemIdValue cookie;
   wxTreeItemId child = GetFirstChild(item,cookie);
   while (child.IsOk()) {
      copyItem(child, newitem);
      child = GetNextChild(item,cookie);
   }
}
Ejemplo n.º 10
0
SpreadTableView::SpreadTableView(QWidget *parent) :
    QTableView(parent)
{
    spreadInformationAction = new QAction(tr("Spread &Information"), parent);
    connect(spreadInformationAction, SIGNAL(triggered()), this, SLOT(spreadInformation()));

    copyRowsAction = new QAction(tr("Copy &Row(s) to Clipboard"), parent);
    //copyRowsAction->setShortcuts(QKeySequence::Copy);
    connect(copyRowsAction, SIGNAL(triggered()), this, SLOT(copyRows()));

    copyItemAction = new QAction(tr("Copy &Item to Clipboard"), parent);
    connect(copyItemAction, SIGNAL(triggered()), this, SLOT(copyItem()));

    copySeedAction = new QAction(tr("Copy &Seed to Clipboard"), parent);
    connect(copySeedAction, SIGNAL(triggered()), this, SLOT(copySeed()));
}
Ejemplo n.º 11
0
void Insert (Item X, int position, List *L) {
	ListNode *p, *q;
	
	L->size++;
	q=(ListNode *)malloc(sizeof(ListNode));
	copyItem(&q->item,X);
			 
	if(position==0) {
		q->next=L->first;
		L->first=q;
	}
	else {
		p=moveTo(position-1,L);
		q->next=p->next;
		p->next=q;
	}
}
void Tail (Queue *Q, Item *I) {
int newSpot;
#ifdef DEBUG
	if(Empty(Q)) {
		printf("Violated precondition for Tail!\n");
		exit(EXIT_FAILURE);
	}
#endif
	newSpot = Q->head + Size(Q) - 1;
	if(newSpot >= MAXQUEUESIZE)
		newSpot = newSpot - MAXQUEUESIZE;
	copyItem(I,Q->items[newSpot]);
	Q->head--;
	if(Q->head < 0)
		Q->head = Q->head + MAXQUEUESIZE;

}
Ejemplo n.º 13
0
void browsers::TDTbrowser::OnTELLremovecell(wxString cellname, wxString parentname, bool orphan) {
   wxTreeItemId newparent;
   if (orphan) {
      wxTreeItemId item;
      findItem(cellname, item, GetRootItem());
      copyItem(item,GetRootItem());
      item = wxTreeItemId();
      assert(findItem(parentname, newparent, GetRootItem()));
      assert(findItem(cellname, item, newparent));
      DeleteChildren(item);
      Delete(item);
   }
   else
      while (findItem(parentname, newparent, GetRootItem())) {
         wxTreeItemId item;
         assert(findItem(cellname, item, newparent));
         DeleteChildren(item);
         Delete(item);
      }
}
void Enqueue (Item I, Queue *Q) {
  	int newSpot;
#ifdef DEBUG
	int oldSize=Size(Q);
	if(Full(Q)) {
		printf("Violated precondition for Enqueue!\n");
		exit(EXIT_FAILURE);
	}
#endif
	newSpot = Q->head + Size(Q);
	if(newSpot >= MAXQUEUESIZE)
		newSpot = newSpot - MAXQUEUESIZE;
	copyItem(&Q->items[newSpot],I);
	Q->size++;
#ifdef DEBUG
	if(Empty(Q) || Size(Q)!=oldSize+1) {
		printf("Violated postcondition for Enqueue!\n");
		exit(EXIT_FAILURE);
	}
#endif
}
Ejemplo n.º 15
0
void modulePD::sCopyItem()
{
  copyItem(parent, "", TRUE).exec();
}
Ejemplo n.º 16
0
void Peek (int position, List *L, Item *X) {
	ListNode *p;
	p=moveTo(position,L);
	copyItem(X,p->item);
}
Ejemplo n.º 17
0
// ==== PRIVATE SLOTS ====
void FOWorker::slotStartOperations(){
  if(DEBUG){ qDebug() << "Start File operations" << isRM << isCP << isMV << ofiles << nfiles << overwrite; }
  //Now setup the UI
  /*ui->progressBar->setRange(0,ofiles.length());
  ui->progressBar->setValue(0);
  ui->progressBar->setVisible(true);
  QApplication::processEvents();*/
  /*if(!isRM && overwrite==-1){
    //Check if the new files already exist, and prompt for action
    QStringList existing;
    for(int i=0; i<nfiles.length(); i++){
      if(QFile::exists(nfiles[i])){ existing << nfiles[i].section("/",-1); }
    }
    if(!existing.isEmpty()){
      //Prompt for whether to overwrite, not overwrite, or cancel
      QMessageBox::StandardButton ans = QMessageBox::question(this, tr("Overwrite Files?"), tr("Do you want to overwrite the existing files?")+"\n"+tr("Note: It will just add a number to the filename otherwise.")+"\n\n"+existing.join(", "), QMessageBox::YesToAll | QMessageBox::NoToAll | QMessageBox::Cancel, QMessageBox::NoToAll);
      if(ans==QMessageBox::NoToAll){ overwrite = 0; } //don't overwrite
      else if(ans==QMessageBox::YesToAll){ overwrite = 1; } //overwrite
      else{ emit finished(QStringList()); return; } //cancel operations
    }
  }*/
	
  //Get the complete number of items to be operated on (better tracking)
  QStringList olist, nlist; //old/new list to actually be used (not inputs - modified/added as necessary)
  for(int i=0; i<ofiles.length() && !stopped; i++){
    if(isRM){ //only old files
      olist << subfiles(ofiles[i], false); //dirs need to be last for removals
    }else if(isCP || isRESTORE){
      if(QFile::exists(nfiles[i])){
	if(overwrite!=1){
	  qDebug() << " - Get New Filename:" << nfiles[i];
	  nfiles[i] = newFileName(nfiles[i]); //prompt for new file name up front before anything starts
	  qDebug() << " -- " << nfiles[i];
	}
      }
      if(nfiles[i] == ofiles[i] && overwrite==1){
	//Trying to copy a file/dir to itself - skip it
	continue;
      }
      QStringList subs = subfiles(ofiles[i], true); //dirs need to be first for additions
      for(int s=0; s<subs.length(); s++){
        olist << subs[s];
	QString newsub = subs[s].section(ofiles[i],0,100, QString::SectionSkipEmpty); 
	    newsub.prepend(nfiles[i]);
	nlist << newsub;
      }
    }else{ //Move/rename
      if( nfiles[i].startsWith(ofiles[i]+"/") ){
	//This is trying to move a directory into itself  (not possible)
	// Example: move "~/mydir" -> "~/mydir/mydir2"
	QStringList err; err << tr("Invalid Move") << QString(tr("It is not possible to move a directory into itself. Please make a copy of the directory instead.\n\nOld Location: %1\nNew Location: %2")).arg(ofiles[i], nfiles[i]);
	emit finished(err); return;
      }else{
	//Check for existance of the new name
	if(QFile::exists(nfiles[i])){
	  if(overwrite!=1){
	    nfiles[i] = newFileName(nfiles[i]); //prompt for new file name up front before anything starts
	  }
        }
	//no changes necessary
        olist << ofiles[i];
        nlist << nfiles[i];
      }
    }
  }
  //Now start iterating over the operations
  QStringList errlist;
  for(int i=0; i<olist.length() && !stopped; i++){
    if(isRM){
      /*ui->label->setText( QString(tr("Removing: %1")).arg(olist[i].section("/",-1)) );
      QApplication::processEvents();*/
      emit startingItem(i+1,olist.length(), olist[i], "");
      errlist << removeItem(olist[i]);
    }else if(isCP || isRESTORE){
      /*ui->label->setText( QString(tr("Copying: %1 to %2")).arg(olist[i].section("/",-1), nlist[i].section("/",-1)) );
      QApplication::processEvents();*/
      emit startingItem(i+1,olist.length(), olist[i],nlist[i]);
      if(QFile::exists(nlist[i])){
	if(overwrite==1){
	  errlist << removeItem(nlist[i], true); //recursively remove the file/dir since we are supposed to overwrite it
	}
      }
      //If a parent directory fails to copy, skip all the children as well (they will also fail)
      //QApplication::processEvents();
      if( !errlist.contains(olist[i].section("/",0,-1)) ){ 
        errlist << copyItem(olist[i], nlist[i]);
      }
    }else if(isMV){
      /*ui->label->setText( QString(tr("Moving: %1 to %2")).arg(ofiles[i].section("/",-1), nfiles[i].section("/",-1)) );
      QApplication::processEvents();*/
      emit startingItem(i+1,olist.length(), olist[i], nlist[i]);
      //Clean up any overwritten files/dirs
      if(QFile::exists(nlist[i])){
	if(overwrite==1){
	  errlist << removeItem(nlist[i], true); //recursively remove the file/dir since we are supposed to overwrite it
	}
      }
      //Perform the move if no error yet (including skipping all children)
      if( !errlist.contains(olist[i].section("/",0,-1)) ){ 
        if( !QFile::rename(ofiles[i], nfiles[i]) ){
          errlist << ofiles[i];
        }
      }	
    }
    //ui->progressBar->setValue(i+1);
    //QApplication::processEvents();
  }
  //All finished, emit the signal
  errlist.removeAll(""); //make sure to clear any empty items
  emit finished(errlist);
  qDebug() << "Done with File Operations";
}
Ejemplo n.º 18
0
void cutItem(QStandardItemModel *model, QStandardItem *item)
{
	copyItem(model, item);
	deleteItem(model, item);
}
Ejemplo n.º 19
0
LLInventoryItem::LLInventoryItem(const LLInventoryItem* other) :
	LLInventoryObject()
{
	copyItem(other);
}
Ejemplo n.º 20
0
void menuProducts::sCopyItem()
{
  copyItem(parent, "", TRUE).exec();
}