diff -r 25ee6b988b73 -r 8f987e376035 vymmodel.cpp --- a/vymmodel.cpp Tue Dec 15 09:14:59 2009 +0000 +++ b/vymmodel.cpp Mon Jan 04 20:36:06 2010 +0000 @@ -1458,6 +1458,11 @@ version=s; } +QString VymModel::getVersion() +{ + return version; +} + void VymModel::setAuthor (const QString &s) { saveState ( @@ -1493,7 +1498,7 @@ return QDate::currentDate().toString ("yyyy-MM-dd"); } -int VymModel::branchCount() // FIXME-4 Optimize this: use internal counter instead of going through whole map each time... +int VymModel::branchCount() { int c=0; BranchItem *cur=NULL; @@ -2143,7 +2148,7 @@ return NULL; } -AttributeItem* VymModel::addAttribute() // FIXME-2 savestate missing +AttributeItem* VymModel::addAttribute() { BranchItem *selbi=getSelectedBranch(); if (selbi) @@ -2151,19 +2156,28 @@ QList cData; cData << "new attribute" << "undef"; AttributeItem *a=new AttributeItem (cData); - + if (addAttribute (a)) return a; + } + return NULL; +} + +AttributeItem* VymModel::addAttribute(AttributeItem *ai) // FIXME-2 savestate missing +{ + BranchItem *selbi=getSelectedBranch(); + if (selbi) + { emit (layoutAboutToBeChanged() ); QModelIndex parix=index(selbi); - int n=selbi->getRowNumAppend (a); + int n=selbi->getRowNumAppend (ai); beginInsertRows (parix,n,n); - selbi->appendChild (a); + selbi->appendChild (ai); endInsertRows (); emit (layoutChanged() ); reposition(); - return a; + return ai; } return NULL; } @@ -2435,9 +2449,14 @@ unselect(); saveStateRemovingPart (selbi, QString ("Delete %1").arg(getObjectName(selbi))); - TreeItem *pi=deleteItem (selbi); + BranchItem *pi=(BranchItem*)(deleteItem (selbi)); if (pi) { + if (pi->isScrolled() && pi->branchCount()==0) + { + pi->unScroll(); + emitDataHasChanged(pi); + } select (pi); emitShowSelection(); } @@ -4074,8 +4093,9 @@ } setExportMode (true); - QPixmap pix (mapEditor->getPixmap()); - pix.save(fname, format); + mapEditor->getScene()->update(); // FIXME-2 check this... + QImage img (mapEditor->getImage()); //FIXME-2 calls getTotalBBox, but also in ExportHTML::doExport() + img.save(fname, format); setExportMode (false); } @@ -4167,6 +4187,62 @@ } } +void VymModel::exportHTML (const QString &dir, bool askForName) +{ + ExportXHTMLDialog dia(NULL); + dia.setFilePath (filePath ); + dia.setMapName (mapName ); + dia.readSettings(); + if (dir!="") dia.setDir (dir); + + bool ok=true; + + /* + if (askForName) + { + if (dia.exec()!=QDialog::Accepted) + ok=false; + else + { + QDir d (dia.getDir()); + // Check, if warnings should be used before overwriting + // the output directory + if (d.exists() && d.count()>0) + { + WarningDialog warn; + warn.showCancelButton (true); + warn.setText(QString( + "The directory %1 is not empty.\n" + "Do you risk to overwrite some of its contents?").arg(d.path() )); + warn.setCaption("Warning: Directory not empty"); + warn.setShowAgainName("mainwindow/overwrite-dir-xhtml"); + + if (warn.exec()!=QDialog::Accepted) ok=false; + } + } + } +*/ + ok=true; + if (ok) + { + // Hide stuff during export, if settings want this + setExportMode (true); + + ExportHTML ex (this); + ex.setFile ("x/xxx.html"); + ex.doExport(); + setExportMode (false); + + //exportXML (dia.getDir(),false ); + //dia.doExport(mapName ); + //if (dia.hasChanged()) setChanged(); + + // Write image, too + exportImage ("x/xxx.png",false,"PNG"); + + } +} + void VymModel::exportXHTML (const QString &dir, bool askForName) { ExportXHTMLDialog dia(NULL); @@ -4795,10 +4871,13 @@ void VymModel::setHideTmpMode (TreeItem::HideTmpMode mode) { hidemode=mode; - for (int i=0;ichildCount();i++) - rootItem->child(i)->setHideTmp (mode); + for (int i=0;ibranchCount();i++) + rootItem->getBranchNum(i)->setHideTmp (mode); reposition(); - // FIXME-3 needed? scene()->update(); + if (mode==TreeItem::HideExport) + unselect(); + else + reselect(); } //////////////////////////////////////////////