exports.cpp
changeset 740 6dc0a20031f7
parent 723 11f9124c1cca
child 741 1b4d1ea6ea8c
     1.1 --- a/exports.cpp	Wed Feb 04 11:52:52 2009 +0000
     1.2 +++ b/exports.cpp	Wed Feb 04 16:33:16 2009 +0000
     1.3 @@ -143,51 +143,57 @@
     1.4  	QString s;
     1.5  	QString curIndent;
     1.6  	int i;
     1.7 +	TreeItem *ti;
     1.8 +	ti=model->first();
     1.9  	BranchObj *bo;
    1.10 -	bo=model->first();
    1.11 -	while (bo) 
    1.12 +	while (ti) 
    1.13  	{
    1.14 -		// Make indentstring
    1.15 -		curIndent="";
    1.16 -		for (i=0;i<bo->getDepth()-1;i++) curIndent+= indentPerDepth;
    1.17 +		if (ti->getType()==TreeItem::Branch || ti->getType()==TreeItem::MapCenter)
    1.18 +		{
    1.19 +			bo=(BranchObj*)(ti->getLMO());
    1.20  
    1.21 -		if (!bo->hasHiddenExportParent() )
    1.22 -		{
    1.23 -			switch (bo->getDepth())
    1.24 +			// Make indentstring
    1.25 +			curIndent="";
    1.26 +			for (i=0;i<ti->depth()-1;i++) curIndent+= indentPerDepth;
    1.27 +
    1.28 +			if (!bo->hasHiddenExportParent() )
    1.29  			{
    1.30 -				case 0:
    1.31 -					ts << underline (bo->getHeading(),QString("="));
    1.32 -					ts << "\n";
    1.33 -					break;
    1.34 -				case 1:
    1.35 -					ts << "\n";
    1.36 -					ts << (underline (getSectionString(bo) + bo->getHeading(), QString("-") ) );
    1.37 -					ts << "\n";
    1.38 -					break;
    1.39 -				case 2:
    1.40 -					ts << "\n";
    1.41 -					ts << (curIndent + "* " + bo->getHeading());
    1.42 -					ts << "\n";
    1.43 -					break;
    1.44 -				case 3:
    1.45 -					ts << (curIndent + "- " + bo->getHeading());
    1.46 -					ts << "\n";
    1.47 -					break;
    1.48 -				default:
    1.49 -					ts << (curIndent + "- " + bo->getHeading());
    1.50 -					ts << "\n";
    1.51 -					break;
    1.52 -			}
    1.53 +				switch (ti->depth())
    1.54 +				{
    1.55 +					case 0:
    1.56 +						ts << underline (ti->getHeading(),QString("="));
    1.57 +						ts << "\n";
    1.58 +						break;
    1.59 +					case 1:
    1.60 +						ts << "\n";
    1.61 +						ts << (underline (getSectionString(bo) + ti->getHeading(), QString("-") ) );
    1.62 +						ts << "\n";
    1.63 +						break;
    1.64 +					case 2:
    1.65 +						ts << "\n";
    1.66 +						ts << (curIndent + "* " + ti->getHeading());
    1.67 +						ts << "\n";
    1.68 +						break;
    1.69 +					case 3:
    1.70 +						ts << (curIndent + "- " + ti->getHeading());
    1.71 +						ts << "\n";
    1.72 +						break;
    1.73 +					default:
    1.74 +						ts << (curIndent + "- " + ti->getHeading());
    1.75 +						ts << "\n";
    1.76 +						break;
    1.77 +				}
    1.78  
    1.79 -			// If necessary, write note
    1.80 -			if (!bo->getNote().isEmpty())
    1.81 -			{
    1.82 -				curIndent +="  | ";
    1.83 -				s=bo->getNoteASCII( curIndent, 80);
    1.84 -				ts << s;
    1.85 +				// If necessary, write note
    1.86 +				if (!bo->getNote().isEmpty())
    1.87 +				{
    1.88 +					curIndent +="  | ";
    1.89 +					s=bo->getNoteASCII( curIndent, 80);
    1.90 +					ts << s;
    1.91 +				}
    1.92  			}
    1.93  		}
    1.94 -		bo=model->next(bo);
    1.95 +		ti=model->next();
    1.96  	}
    1.97  	file.close();
    1.98  }
    1.99 @@ -219,9 +225,11 @@
   1.100  	QString curIndent("");
   1.101  	int i;
   1.102  	BranchObj *bo;
   1.103 -	bo=model->first();
   1.104 -	while (bo) 
   1.105 +	TreeItem *ti=model->first();
   1.106 +	while (ti) 
   1.107  	{
   1.108 +		bo=(BranchObj*)(ti->getLMO());
   1.109 +
   1.110  		if (!bo->hasHiddenExportParent() )
   1.111  		{
   1.112  			// If necessary, write note
   1.113 @@ -234,13 +242,13 @@
   1.114  				ts <<"\"\",";
   1.115  
   1.116  			// Make indentstring
   1.117 -			for (i=0;i<bo->getDepth();i++) curIndent+= "\"\",";
   1.118 +			for (i=0;i<ti->depth();i++) curIndent+= "\"\",";
   1.119  
   1.120  			// Write heading
   1.121 -			ts << curIndent << "\"" << bo->getHeading()<<"\""<<endl;
   1.122 +			ts << curIndent << "\"" << ti->getHeading()<<"\""<<endl;
   1.123  		}
   1.124  		
   1.125 -		bo=model->next(bo);
   1.126 +		ti=model->next();
   1.127  		curIndent="";
   1.128  	}
   1.129  	file.close();
   1.130 @@ -344,34 +352,39 @@
   1.131    // QString curIndent("");
   1.132    // int i;
   1.133    BranchObj *bo;
   1.134 -  bo=model->first();
   1.135 -  while (bo) {
   1.136 +  TreeItem *ti=model->first();
   1.137 +  while (ti) 
   1.138 +  {
   1.139 +	bo=(BranchObj*)(ti->getLMO());
   1.140 +
   1.141  	if (!bo->hasHiddenExportParent() )
   1.142  	{
   1.143 -		if (bo->getDepth()==0);
   1.144 -		else if (bo->getDepth()==1) {
   1.145 -		  ts << ("\\chapter{" + bo->getHeading()+ "}\n");
   1.146 +		switch (ti->depth() ) 
   1.147 +		{
   1.148 +			case 0: break;
   1.149 +			case 1: 
   1.150 +			  ts << ("\\chapter{" + bo->getHeading()+ "}\n");
   1.151 +			  break;
   1.152 +			case 2: 
   1.153 +			  ts << ("\\section{" + bo->getHeading()+ "}\n");
   1.154 +			  break;
   1.155 +			case 3: 
   1.156 +			  ts << ("\\subsection{" + bo->getHeading()+ "}\n");
   1.157 +			  break;
   1.158 +			case 4: 
   1.159 +			  ts << ("\\subsubsection{" + bo->getHeading()+ "}\n");
   1.160 +			  break;
   1.161 +			default:
   1.162 +			  ts << ("\\paragraph*{" + bo->getHeading()+ "}\n");
   1.163 +			
   1.164  		}
   1.165 -		else if (bo->getDepth()==2) {
   1.166 -		  ts << ("\\section{" + bo->getHeading()+ "}\n");
   1.167 -		}
   1.168 -		else if (bo->getDepth()==3) {
   1.169 -		  ts << ("\\subsection{" + bo->getHeading()+ "}\n");
   1.170 -		}
   1.171 -		else if (bo->getDepth()==4) {
   1.172 -		  ts << ("\\subsubsection{" + bo->getHeading()+ "}\n");
   1.173 -		}
   1.174 -		else {
   1.175 -		  ts << ("\\paragraph*{" + bo->getHeading()+ "}\n");
   1.176 -		}
   1.177 -		
   1.178  		// If necessary, write note
   1.179  		if (!bo->getNote().isEmpty()) {
   1.180  		  ts << (bo->getNoteASCII());
   1.181  		  ts << ("\n");
   1.182  		}
   1.183  	}
   1.184 -    bo=model->next(bo);
   1.185 +    ti=model->next();
   1.186     }
   1.187    file.close();
   1.188  }