vymmodel.cpp
changeset 822 c2ce9944148c
parent 821 4a84d7e444d8
child 823 0bba81dde1bc
     1.1 --- a/vymmodel.cpp	Thu Jan 21 11:56:57 2010 +0000
     1.2 +++ b/vymmodel.cpp	Wed Feb 10 13:48:42 2010 +0000
     1.3 @@ -143,9 +143,6 @@
     1.4  	// Network
     1.5  	netstate=Offline;
     1.6  
     1.7 -	// Create MapCenter
     1.8 -	//  addMapCenter();  FIXME-2 VM create this in MapEditor until BO and MCO are independent of scene
     1.9 -
    1.10  	//Initialize DBUS object
    1.11  	adaptorModel=new AdaptorModel(this);	// Created and not deleted as documented in Qt
    1.12      if (!dbusConnection.registerObject (QString("/vymmodel_%1").arg(mapNum),this))
    1.13 @@ -1438,14 +1435,14 @@
    1.14  	return  ti;
    1.15  }
    1.16  
    1.17 -TreeItem* VymModel::findID (const QString &s)	//FIXME-4 Search also other types...
    1.18 +TreeItem* VymModel::findID (const uint &i)	//FIXME-3 Search also other types...
    1.19  {
    1.20  	BranchItem *cur=NULL;
    1.21  	BranchItem *prev=NULL;
    1.22  	nextBranch(cur,prev);
    1.23  	while (cur) 
    1.24  	{
    1.25 -		if (s==cur->getID() ) return cur;
    1.26 +		if (i==cur->getID() ) return cur;
    1.27  		nextBranch(cur,prev);
    1.28  	}
    1.29  	return NULL;
    1.30 @@ -1553,7 +1550,6 @@
    1.31  
    1.32  void VymModel::setNote(const QString &s)
    1.33  {
    1.34 -	cout << "VM::setNote\n";
    1.35  	TreeItem *selti=getSelectedItem();
    1.36  	if (selti) 
    1.37  	{
    1.38 @@ -1881,7 +1877,7 @@
    1.39  	}	
    1.40  }
    1.41  
    1.42 -void VymModel::setHideLinkUnselected (bool b)//FIXME-2
    1.43 +void VymModel::setHideLinkUnselected (bool b) // FIXME-2 Images still have visible link after load
    1.44  {
    1.45  	TreeItem *ti=getSelectedItem();
    1.46  	if (ti && (ti->getType()==TreeItem::Image ||ti->isBranchLikeType()))
    1.47 @@ -2023,7 +2019,7 @@
    1.48  	}
    1.49  }
    1.50  
    1.51 -bool VymModel::moveUp(BranchItem *bi)	//FIXME-2 crashes if trying to move MCO
    1.52 +bool VymModel::moveUp(BranchItem *bi)	
    1.53  {
    1.54  	if (bi && bi->canMoveUp()) 
    1.55  		return relinkBranch (bi,(BranchItem*)bi->parent(),bi->num()-1);
    1.56 @@ -2094,17 +2090,20 @@
    1.57  	}
    1.58  }
    1.59  
    1.60 -void VymModel::sortChildren()
    1.61 +void VymModel::sortChildren(bool inverse)
    1.62  {
    1.63  	BranchItem* selbi=getSelectedBranch();
    1.64  	if (selbi)
    1.65  	{
    1.66  		if(selbi->branchCount()>1)
    1.67  		{
    1.68 +			if (!inverse)
    1.69 +			{
    1.70  			saveStateChangingPart(
    1.71  				selbi,selbi, "sortChildren ()",
    1.72  				QString("Sort children of %1").arg(getObjectName(selbi)));
    1.73 -			selbi->sortChildren();
    1.74 +			}
    1.75 +			selbi->sortChildren(inverse);
    1.76  			reposition();
    1.77  			emitShowSelection();
    1.78  		}
    1.79 @@ -2221,6 +2220,7 @@
    1.80  
    1.81  		emit (layoutChanged() );
    1.82  
    1.83 +		ai->createMapObj(mapScene);		//FIXME-2 check that...
    1.84  		reposition();
    1.85  		return ai;
    1.86  	}
    1.87 @@ -2399,6 +2399,10 @@
    1.88  	{
    1.89  		unselect();
    1.90   
    1.91 +		// Do we need to update frame type?
    1.92 +		bool keepFrame=false;
    1.93 +		 
    1.94 +
    1.95  		emit (layoutAboutToBeChanged() );
    1.96  		BranchItem *branchpi=(BranchItem*)branch->parent();
    1.97  		// Remove at current position
    1.98 @@ -2432,7 +2436,7 @@
    1.99  			branch->setType(TreeItem::Branch);
   1.100  
   1.101  		// reset parObj, fonts, frame, etc in related LMO or other view-objects
   1.102 -		branch->updateStyles();
   1.103 +		branch->updateStyles(keepFrame);
   1.104  
   1.105  		emit (layoutChanged() );
   1.106  		reposition();	// both for moveUp/Down and relinking
   1.107 @@ -2937,19 +2941,9 @@
   1.108  				QString bugID=rx.cap(1);
   1.109  				cout << "VM::getBugzillaData bug="<<bugID.toStdString()<<endl;
   1.110  
   1.111 +				Process p;
   1.112 +				//QString script="test/sleep.sh";
   1.113  				QString script="test/vym-bug.pl";
   1.114 -				/*
   1.115 -				QProgressDialog progress2("Copying files...", "Abort Copy", 0, 40, mainWindow);
   1.116 -				progress2.setWindowModality(Qt::WindowModal);
   1.117 -				progress2.setValue (3);
   1.118 -				progress2.update();
   1.119 -				QProgressDialog progress ("Contacting Bugzilla...","empty",0,0);
   1.120 -				progress.setCancelButton (NULL);
   1.121 -				progress.setWindowModality(Qt::WindowModal);
   1.122 -				progress.show();
   1.123 -				progress.update();
   1.124 -*/
   1.125 -				Process p;
   1.126  				p.start (script,QStringList()<<bugID);
   1.127  				if (!p.waitForStarted())
   1.128  				{
   1.129 @@ -2959,10 +2953,8 @@
   1.130  				if (!p.waitForFinished())
   1.131  				{
   1.132  					cout <<"VM::getBugzillaData couldn't finish "<<script.toStdString()<<endl;
   1.133 -					//progress.hide();
   1.134  					return;
   1.135  				}
   1.136 -				//progress.hide();
   1.137  				//QByteArray result=p.readAll();
   1.138  				QString result=p.getStdout();
   1.139  				while (result.endsWith("\n")) result.chop(1); 
   1.140 @@ -4091,6 +4083,10 @@
   1.141  		} else if (parser.checkParCount(0))
   1.142  		{
   1.143  			sortChildren();
   1.144 +		} else if (parser.checkParCount(1))
   1.145 +		{
   1.146 +			b=parser.parBool(ok,0);
   1.147 +			if (ok) sortChildren(b);
   1.148  		}
   1.149  	/////////////////////////////////////////////////////////////////////
   1.150  	} else if (com=="toggleFlag")
   1.151 @@ -4223,8 +4219,8 @@
   1.152  	}
   1.153  
   1.154  	setExportMode (true);
   1.155 -	mapEditor->getScene()->update();		// FIXME-2 check this...
   1.156 -	QImage img (mapEditor->getImage());	//FIXME-2 calls getTotalBBox, but also in ExportHTML::doExport()
   1.157 +	mapEditor->getScene()->update();		// FIXME-3 check this...
   1.158 +	QImage img (mapEditor->getImage());	//FIXME-3 calls getTotalBBox, but also in ExportHTML::doExport()
   1.159  	img.save(fname, format);
   1.160  	setExportMode (false);
   1.161  }
   1.162 @@ -4317,24 +4313,23 @@
   1.163  	}
   1.164  }
   1.165  
   1.166 -void VymModel::exportHTML (const QString &dir, bool askForName)
   1.167 -{
   1.168 -	ExportXHTMLDialog dia(NULL);
   1.169 +void VymModel::exportHTML (const QString &dir, bool askForName)	//FIXME-2 own dialogue missing and also option to save settings in map
   1.170 +{
   1.171 +	ExportXHTMLDialog dia(NULL);	
   1.172  	dia.setFilePath (filePath );
   1.173  	dia.setMapName (mapName );
   1.174  	dia.readSettings();
   1.175  	if (dir!="") dia.setDir (dir);
   1.176 -
   1.177 +	QDir d;
   1.178  	bool ok=true;
   1.179  	
   1.180 -	/*
   1.181  	if (askForName)
   1.182  	{
   1.183  		if (dia.exec()!=QDialog::Accepted) 
   1.184  			ok=false;
   1.185  		else	
   1.186  		{
   1.187 -			QDir d (dia.getDir());
   1.188 +			d=dia.getDir();
   1.189  			// Check, if warnings should be used before overwriting
   1.190  			// the output directory
   1.191  			if (d.exists() && d.count()>0)
   1.192 @@ -4345,21 +4340,20 @@
   1.193  					"The directory %1 is not empty.\n"
   1.194  					"Do you risk to overwrite some of its contents?").arg(d.path() ));
   1.195  				warn.setCaption("Warning: Directory not empty");
   1.196 -				warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
   1.197 +				warn.setShowAgainName("mainwindow/export-XML-overwrite-dir");
   1.198  
   1.199  				if (warn.exec()!=QDialog::Accepted) ok=false;
   1.200  			}
   1.201  		}	
   1.202  	}
   1.203 -*/ 
   1.204 -	ok=true;
   1.205  	if (ok)
   1.206  	{
   1.207  		// Hide stuff during export, if settings want this
   1.208  		setExportMode (true);
   1.209  
   1.210  		ExportHTML ex (this);
   1.211 -		ex.setFile ("x/xxx.html");
   1.212 +		ex.setFile (d.path()+"/"+mapName+".html");
   1.213 +		cout << "VM::exportHTML  writing "<<ex.getFile().toStdString()<<endl;
   1.214  		ex.doExport();
   1.215  		setExportMode (false);
   1.216  
   1.217 @@ -4368,7 +4362,7 @@
   1.218  		//if (dia.hasChanged()) setChanged();
   1.219  
   1.220  		// Write image, too
   1.221 -		exportImage ("x/xxx.png",false,"PNG");
   1.222 +		exportImage (d.path()+"/"+mapName+".png",false,"PNG");
   1.223  
   1.224  	}
   1.225  }
   1.226 @@ -4604,8 +4598,7 @@
   1.227  	}
   1.228  }
   1.229  
   1.230 -void VymModel::selectMapBackgroundImage ()	// FIXME-2 move to ME
   1.231 -// FIXME-4 for using background image: view.setCacheMode(QGraphicsView::CacheBackground);
   1.232 +void VymModel::selectMapBackgroundImage ()	// FIXME-3 for using background image: view.setCacheMode(QGraphicsView::CacheBackground);  Also this belongs into ME
   1.233  {
   1.234  	Q3FileDialog *fd=new Q3FileDialog( NULL);
   1.235  	fd->setMode (Q3FileDialog::ExistingFile);