void Database_Items::setupItems() { battleCharacterTimer->start(200); itemRef = NULL; animRef = NULL; stackedWidget1->setCurrentWidget(wPlaceHolder); stackedWidget2->setCurrentWidget(wCommonItem); updateItemList(); weapon_updateCharacterClassList(); weapon_updateSkillList(); weapon_updateBattleAnimationList(); weapon_updateAttributeList(); weapon_updateConditionList(); medicine_updateCharacterClassList(); medicine_updateConditionList(); skillBook_updateCharacterClassList(); skillBook_updateSkillList(); seed_updateCharacterClassList(); skillScroll_updateCharacterClassList(); skillScroll_updateSkillList(); equipment_updateSkillList(); equipment_updateCharacterClassList(); equipment_updateAttributeList(); equipment_updateConditionList(); switch_lwSwitch->addItem(ProjectData::switchVariableIdToString(0)); if (ProjectData::itemNames.size() > 0) { lwItemList->setCurrentRow(0); lwItemList->item(0)->setSelected(true); } ignoreEvents = false; }
bool MComponent::makeMakeFile( bool long_lines ) { bool ok = true; WFileName mk( _filename ); mk.setExt( makeExt ); updateItemList(); if( needsMake() || !mk.attribs() ) { ContFile tmak; if( long_lines ) tmak.long_lines(); if( !tmak.open( mk, OStyleWrite ) ) { ok = false; } else { tmak.puts( "!define BLANK \"\"\n" ); initWorkFiles( _workFiles ); // for( int i=0; i<_workFiles.count(); i++ ) { // ((MWorkFile*)_workFiles[i])->dump( tmak ); // } writeRule( tmak ); finiWorkFiles(); tmak.close(); ok = tmak.ok(); setNeedsMake( false ); } } return( ok ); }
void MComponent::newItem( MItem* item ) { _items.setUpdates( false ); addItem( item ); updateItemList( false ); _items.setUpdates( !_batchMode ); touchTarget( false ); setDirty(); }
bool MComponent::renameItem( MItem* item, WFileName& fn, MRule* rule ) { if( item->rename( fn, rule ) ) { updateItemList(); setDirty(); item->touchResult(); return( true ); } return( false ); }
void MComponent::removeItem( MItem* item ) { _items.setUpdates( false ); for( int i=_items.count(); i>0; i-- ) { MItem* m = (MItem*)_items[i-1]; if( m->parent() == item ) { delete _items.removeSame( m ); } } delete _items.removeSame( item ); updateItemList(); touchTarget( false ); setDirty(); }
void MainWindow::on_itemListDelete_clicked() { QList<QListWidgetItem *> selectedItems=ui->itemList->selectedItems(); if(selectedItems.size()!=1) { QMessageBox::warning(this,tr("Error"),tr("Select a bot into the bot list")); return; } quint32 id=selectedItems.first()->data(99).toUInt(); if(!items.contains(id)) { QMessageBox::warning(this,tr("Error"),tr("Unable remove the bot, because the returned id is not into the list")); return; } bool ok; //load the bots QDomElement child = domDocument.documentElement().firstChildElement("item"); while(!child.isNull()) { if(!child.hasAttribute("id")) qDebug() << QStringLiteral("Has not attribute \"id\": child.tagName(): %1 (at line: %2)").arg(child.tagName()).arg(child.lineNumber()); else if(!child.isElement()) qDebug() << QStringLiteral("Is not an element: child.tagName(): %1, name: %2 (at line: %3)").arg(child.tagName().arg(child.attribute("name")).arg(child.lineNumber())); else { quint8 tempId=child.attribute("id").toUShort(&ok); if(ok) { if(tempId==id) { child.parentNode().removeChild(child); break; } } else qDebug() << QStringLiteral("Attribute \"id\" is not a number: bot.tagName(): %1 (at line: %2)").arg(child.tagName()).arg(child.lineNumber()); } child = child.nextSiblingElement("item"); } items.remove(id); updateItemList(); }
void MainWindow::on_itemListAdd_clicked() { int index=1; while(items.contains(index)) index++; bool ok; index=QInputDialog::getInt(this,tr("Id"),tr("What id do you want"),index,0,2000000000,1,&ok); if(!ok) return; if(items.contains(index)) { QMessageBox::warning(this,tr("Error"),tr("Id already taken")); return; } QDomElement newXmlElement=domDocument.createElement("item"); newXmlElement.setAttribute("id",index); domDocument.documentElement().appendChild(newXmlElement); items[index]=newXmlElement; updateItemList(); }
void Database_Items::on_bArraySize_clicked() { int numItems = ProjectData::itemNames.size(); ArraySize *arraysize = new ArraySize(numItems, 1, 5000); if (arraysize->exec()) { int newSize = arraysize->getValue(); if (newSize < numItems) { int confirmdelete = QMessageBox::warning(0, "Delete Data?", QString("If you decrease the array size then\nany unsaved changes will be perminately lost.\nIs it ok to delete data?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::No); if (confirmdelete == QMessageBox::Yes) { if (itemRef != NULL) { if (newSize >= itemRef->getDataID()) { delete itemRef; itemRef = NULL; } } for (int i = numItems - 1; i >= newSize; --i) ProjectData::deleteItem(i); } } else { for (int i = numItems; i < newSize; ++i) { Item *item = new Item; item->setName(QString("Item%1").arg(i, 4, 10, QChar('0'))); ProjectData::addItem(item); delete item; } } ignoreEvents = true; updateItemList(); ignoreEvents = false; } delete arraysize; }
void MComponent::refresh() { updateItemList(); updateAllViews(); }
void MComponent::setBatchMode( bool batchMode ) { _batchMode = batchMode; updateItemList(); }
void MComponent::setAutotrack( bool state ) { _autotrack = state; updateItemList(); setDirty(); }
void InlinePalette::editingFinished() { updateItemList(); }
void MainWindow::on_openItemFile_clicked() { if(ui->lineEditItemFile->text().isEmpty()) { QMessageBox::warning(this,tr("Error"),tr("You need select a Item file")); return; } if(!ui->lineEditItemFile->text().contains(QRegExp("\\.xml$"))) { QMessageBox::warning(this,tr("Error"),tr("The Item file is a xml file")); return; } QFile xmlFile(ui->lineEditItemFile->text()); if(!xmlFile.open(QIODevice::ReadOnly)) { QMessageBox::warning(this,tr("Error"),tr("Unable to open the file %1:\n%2").arg(xmlFile.fileName()).arg(xmlFile.errorString())); return; } settings.setValue("file",ui->lineEditItemFile->text()); QByteArray xmlContent=xmlFile.readAll(); xmlFile.close(); QString errorStr; int errorLine,errorColumn; if (!domDocument.setContent(xmlContent, false, &errorStr,&errorLine,&errorColumn)) { QMessageBox::warning(this,tr("Error"),tr("Unable to open the file %1:\nParse error at line %2, column %3: %4").arg(xmlFile.fileName()).arg(errorLine).arg(errorColumn).arg(errorStr)); return; } bool ok; QDomElement root = domDocument.documentElement(); if(root.tagName()!="items") { QMessageBox::warning(this,tr("Error"),tr("Unable to open the file %1:\nThe root balise is not Items").arg(xmlFile.fileName())); return; } bool error=false; //load the Items QDomElement child = root.firstChildElement("item"); while(!child.isNull()) { if(!child.hasAttribute("id") || !child.hasAttribute("price")) { qDebug() << QStringLiteral("Has not attribute \"id\" or \"price\": child.tagName(): %1 (at line: %2)").arg(child.tagName()).arg(child.lineNumber()); error=true; } else if(!child.isElement()) { qDebug() << QStringLiteral("Is not an element: child.tagName(): %1, name: %2 (at line: %3)").arg(child.tagName().arg(child.attribute("name")).arg(child.lineNumber())); error=true; } else { quint32 id=child.attribute("id").toUInt(&ok); if(ok) items[id]=child; else { qDebug() << QStringLiteral("Attribute \"id\" is not a number: Item.tagName(): %1 (at line: %2)").arg(child.tagName()).arg(child.lineNumber()); error=true; } } child = child.nextSiblingElement("item"); } if(error) QMessageBox::warning(this,tr("Error"),tr("Some error have been found into the file").arg(xmlFile.fileName())); ui->stackedWidget->setCurrentWidget(ui->page_list); updateItemList(); }