mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Simplify code on the printingDialog
instead of duplicate the code that only chaged the QList that it would access, create a temporary list and use it for dealing with the code. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									c496d5fa05
								
							
						
					
					
						commit
						1210d4b575
					
				
					 1 changed files with 11 additions and 31 deletions
				
			
		| 
						 | 
				
			
			@ -51,39 +51,19 @@ void PrintOptions::setup()
 | 
			
		|||
 | 
			
		||||
void PrintOptions::setupTemplates()
 | 
			
		||||
{
 | 
			
		||||
	if (printOptions->type == print_options::DIVELIST) {
 | 
			
		||||
		// insert dive list templates in the UI and select the current template
 | 
			
		||||
		qSort(grantlee_templates);
 | 
			
		||||
		int current_index = 0, index = 0;
 | 
			
		||||
		for (QList<QString>::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) {
 | 
			
		||||
			if ((*i).compare(printOptions->p_template) == 0) {
 | 
			
		||||
				current_index = index;
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
			index++;
 | 
			
		||||
	QStringList currList = printOptions->type == print_options::DIVELIST ?
 | 
			
		||||
		grantlee_templates : grantlee_statistics_templates;
 | 
			
		||||
 | 
			
		||||
	qSort(currList);
 | 
			
		||||
	int current_index = 0;
 | 
			
		||||
	ui.printTemplate->clear();
 | 
			
		||||
	Q_FOREACH(const QString& theme, currList) {
 | 
			
		||||
		if (theme == printOptions->p_template){
 | 
			
		||||
			current_index = currList.indexOf(theme);
 | 
			
		||||
		}
 | 
			
		||||
		ui.printTemplate->clear();
 | 
			
		||||
		for (QList<QString>::iterator i = grantlee_templates.begin(); i != grantlee_templates.end(); ++i) {
 | 
			
		||||
			ui.printTemplate->addItem((*i).split('.')[0], QVariant::fromValue(*i));
 | 
			
		||||
		}
 | 
			
		||||
		ui.printTemplate->setCurrentIndex(current_index);
 | 
			
		||||
	} else if (printOptions->type == print_options::STATISTICS) {
 | 
			
		||||
		// insert statistics templates in the UI and select the current template
 | 
			
		||||
		qSort(grantlee_statistics_templates);
 | 
			
		||||
		int current_index = 0, index = 0;
 | 
			
		||||
		for (QList<QString>::iterator i = grantlee_statistics_templates.begin(); i != grantlee_statistics_templates.end(); ++i) {
 | 
			
		||||
			if ((*i).compare(printOptions->p_template) == 0) {
 | 
			
		||||
				current_index = index;
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
			index++;
 | 
			
		||||
		}
 | 
			
		||||
		ui.printTemplate->clear();
 | 
			
		||||
		for (QList<QString>::iterator i = grantlee_statistics_templates.begin(); i != grantlee_statistics_templates.end(); ++i) {
 | 
			
		||||
			ui.printTemplate->addItem((*i).split('.')[0], QVariant::fromValue(*i));
 | 
			
		||||
		}
 | 
			
		||||
		ui.printTemplate->setCurrentIndex(current_index);
 | 
			
		||||
		ui.printTemplate->addItem(theme.split('.')[0], theme);
 | 
			
		||||
	}
 | 
			
		||||
	ui.printTemplate->setCurrentIndex(current_index);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// print type radio buttons
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue