1.1 --- a/vymmodel.cpp Tue Dec 15 09:14:59 2009 +0000
1.2 +++ b/vymmodel.cpp Mon Jan 04 20:36:06 2010 +0000
1.3 @@ -1458,6 +1458,11 @@
1.4 version=s;
1.5 }
1.6
1.7 +QString VymModel::getVersion()
1.8 +{
1.9 + return version;
1.10 +}
1.11 +
1.12 void VymModel::setAuthor (const QString &s)
1.13 {
1.14 saveState (
1.15 @@ -1493,7 +1498,7 @@
1.16 return QDate::currentDate().toString ("yyyy-MM-dd");
1.17 }
1.18
1.19 -int VymModel::branchCount() // FIXME-4 Optimize this: use internal counter instead of going through whole map each time...
1.20 +int VymModel::branchCount()
1.21 {
1.22 int c=0;
1.23 BranchItem *cur=NULL;
1.24 @@ -2143,7 +2148,7 @@
1.25 return NULL;
1.26 }
1.27
1.28 -AttributeItem* VymModel::addAttribute() // FIXME-2 savestate missing
1.29 +AttributeItem* VymModel::addAttribute()
1.30 {
1.31 BranchItem *selbi=getSelectedBranch();
1.32 if (selbi)
1.33 @@ -2151,19 +2156,28 @@
1.34 QList<QVariant> cData;
1.35 cData << "new attribute" << "undef";
1.36 AttributeItem *a=new AttributeItem (cData);
1.37 -
1.38 + if (addAttribute (a)) return a;
1.39 + }
1.40 + return NULL;
1.41 +}
1.42 +
1.43 +AttributeItem* VymModel::addAttribute(AttributeItem *ai) // FIXME-2 savestate missing
1.44 +{
1.45 + BranchItem *selbi=getSelectedBranch();
1.46 + if (selbi)
1.47 + {
1.48 emit (layoutAboutToBeChanged() );
1.49
1.50 QModelIndex parix=index(selbi);
1.51 - int n=selbi->getRowNumAppend (a);
1.52 + int n=selbi->getRowNumAppend (ai);
1.53 beginInsertRows (parix,n,n);
1.54 - selbi->appendChild (a);
1.55 + selbi->appendChild (ai);
1.56 endInsertRows ();
1.57
1.58 emit (layoutChanged() );
1.59
1.60 reposition();
1.61 - return a;
1.62 + return ai;
1.63 }
1.64 return NULL;
1.65 }
1.66 @@ -2435,9 +2449,14 @@
1.67 unselect();
1.68 saveStateRemovingPart (selbi, QString ("Delete %1").arg(getObjectName(selbi)));
1.69
1.70 - TreeItem *pi=deleteItem (selbi);
1.71 + BranchItem *pi=(BranchItem*)(deleteItem (selbi));
1.72 if (pi)
1.73 {
1.74 + if (pi->isScrolled() && pi->branchCount()==0)
1.75 + {
1.76 + pi->unScroll();
1.77 + emitDataHasChanged(pi);
1.78 + }
1.79 select (pi);
1.80 emitShowSelection();
1.81 }
1.82 @@ -4074,8 +4093,9 @@
1.83 }
1.84
1.85 setExportMode (true);
1.86 - QPixmap pix (mapEditor->getPixmap());
1.87 - pix.save(fname, format);
1.88 + mapEditor->getScene()->update(); // FIXME-2 check this...
1.89 + QImage img (mapEditor->getImage()); //FIXME-2 calls getTotalBBox, but also in ExportHTML::doExport()
1.90 + img.save(fname, format);
1.91 setExportMode (false);
1.92 }
1.93
1.94 @@ -4167,6 +4187,62 @@
1.95 }
1.96 }
1.97
1.98 +void VymModel::exportHTML (const QString &dir, bool askForName)
1.99 +{
1.100 + ExportXHTMLDialog dia(NULL);
1.101 + dia.setFilePath (filePath );
1.102 + dia.setMapName (mapName );
1.103 + dia.readSettings();
1.104 + if (dir!="") dia.setDir (dir);
1.105 +
1.106 + bool ok=true;
1.107 +
1.108 + /*
1.109 + if (askForName)
1.110 + {
1.111 + if (dia.exec()!=QDialog::Accepted)
1.112 + ok=false;
1.113 + else
1.114 + {
1.115 + QDir d (dia.getDir());
1.116 + // Check, if warnings should be used before overwriting
1.117 + // the output directory
1.118 + if (d.exists() && d.count()>0)
1.119 + {
1.120 + WarningDialog warn;
1.121 + warn.showCancelButton (true);
1.122 + warn.setText(QString(
1.123 + "The directory %1 is not empty.\n"
1.124 + "Do you risk to overwrite some of its contents?").arg(d.path() ));
1.125 + warn.setCaption("Warning: Directory not empty");
1.126 + warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
1.127 +
1.128 + if (warn.exec()!=QDialog::Accepted) ok=false;
1.129 + }
1.130 + }
1.131 + }
1.132 +*/
1.133 + ok=true;
1.134 + if (ok)
1.135 + {
1.136 + // Hide stuff during export, if settings want this
1.137 + setExportMode (true);
1.138 +
1.139 + ExportHTML ex (this);
1.140 + ex.setFile ("x/xxx.html");
1.141 + ex.doExport();
1.142 + setExportMode (false);
1.143 +
1.144 + //exportXML (dia.getDir(),false );
1.145 + //dia.doExport(mapName );
1.146 + //if (dia.hasChanged()) setChanged();
1.147 +
1.148 + // Write image, too
1.149 + exportImage ("x/xxx.png",false,"PNG");
1.150 +
1.151 + }
1.152 +}
1.153 +
1.154 void VymModel::exportXHTML (const QString &dir, bool askForName)
1.155 {
1.156 ExportXHTMLDialog dia(NULL);
1.157 @@ -4795,10 +4871,13 @@
1.158 void VymModel::setHideTmpMode (TreeItem::HideTmpMode mode)
1.159 {
1.160 hidemode=mode;
1.161 - for (int i=0;i<rootItem->childCount();i++)
1.162 - rootItem->child(i)->setHideTmp (mode);
1.163 + for (int i=0;i<rootItem->branchCount();i++)
1.164 + rootItem->getBranchNum(i)->setHideTmp (mode);
1.165 reposition();
1.166 - // FIXME-3 needed? scene()->update();
1.167 + if (mode==TreeItem::HideExport)
1.168 + unselect();
1.169 + else
1.170 + reselect();
1.171 }
1.172
1.173 //////////////////////////////////////////////