r21358 by craig -

scribus-commit scribus-commit at lists.scribus.net
Sat May 28 16:20:04 UTC 2016


Author: craig
Date: Sat May 28 16:20:04 2016
New Revision: 21358

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21358
Log:
Fix Resource Manager not showing downloaded files in available list

Modified:
    trunk/Scribus/scribus/ui/resourcemanager.cpp
    trunk/Scribus/scribus/ui/resourcemanager.h

Modified: trunk/Scribus/scribus/ui/resourcemanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21358&path=/trunk/Scribus/scribus/ui/resourcemanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/resourcemanager.cpp	(original)
+++ trunk/Scribus/scribus/ui/resourcemanager.cpp	Sat May 28 16:20:04 2016
@@ -104,6 +104,65 @@
 		categoryComboBox->addItem(i.value(), i.key());
 	}
 	categoryChanged();
+}
+
+void ResourceManager::readAvailablePalettes()
+{
+	QFile dataFile(ScPaths::downloadDir() + dataFiles[RM_PALETTES]);
+	if (!dataFile.exists())
+		return;
+	dataFile.open(QIODevice::ReadOnly);
+	QTextStream ts(&dataFile);
+	ts.setCodec(QTextCodec::codecForName("UTF-8"));
+	QString errorMsg;
+	int eline;
+	int ecol;
+	QDomDocument doc( QString(dataFiles[RM_PALETTES]).remove(".xml") );
+	QString data(ts.readAll());
+	dataFile.close();
+	if ( !doc.setContent( data, &errorMsg, &eline, &ecol ))
+	{
+		if (data.toLower().contains("404 not found"))
+			qDebug()<<"File not found on server";
+		else
+			qDebug()<<"Could not open file"<<dataFile.fileName();
+		return;
+	}
+	availableList.clear();
+	QDomElement docElem = doc.documentElement();
+	QDomNode n = docElem.firstChild();
+	while( !n.isNull() )
+	{
+		QDomElement e = n.toElement();
+		if( !e.isNull() )
+		{
+			if (e.tagName()=="palette")
+			{
+				if (e.hasAttribute("type") && e.hasAttribute("filetype"))
+				{
+					//if (e.attribute("type")=="scribusofficial")
+					{
+						struct DownloadItem d;
+						d.desc=e.attribute("description");
+						d.download=false;
+						d.files=e.attribute("files");
+						d.extractfiles="";
+						d.url=e.attribute("URL");
+						d.version=e.attribute("version");
+						d.lang=e.attribute("language");
+						d.license=e.attribute("license");
+						d.filetype=e.attribute("filetype");
+						d.type=e.attribute("type");
+						d.source=e.attribute("source");
+						QUrl url(d.url);
+						if (url.isValid() && !url.isEmpty() && !url.host().isEmpty())
+							availableList.append(d);
+					}
+				}
+			}
+		}
+		n = n.nextSibling();
+	}
 }
 
 void ResourceManager::updateInstalledFonts()
@@ -656,61 +715,6 @@
 
 void ResourceManager::updateAvailablePalettes()
 {
-	QFile dataFile(ScPaths::downloadDir() + dataFiles[RM_PALETTES]);
-	if (!dataFile.exists())
-		return;
-	dataFile.open(QIODevice::ReadOnly);
-	QTextStream ts(&dataFile);
-	ts.setCodec(QTextCodec::codecForName("UTF-8"));
-	QString errorMsg;
-	int eline;
-	int ecol;
-	QDomDocument doc( QString(dataFiles[RM_PALETTES]).remove(".xml") );
-	QString data(ts.readAll());
-	dataFile.close();
-	if ( !doc.setContent( data, &errorMsg, &eline, &ecol ))
-	{
-		if (data.toLower().contains("404 not found"))
-			qDebug()<<"File not found on server";
-		else
-			qDebug()<<"Could not open file"<<dataFile.fileName();
-		return;
-	}
-	availableList.clear();
-	QDomElement docElem = doc.documentElement();
-	QDomNode n = docElem.firstChild();
-	while( !n.isNull() )
-	{
-		QDomElement e = n.toElement();
-		if( !e.isNull() )
-		{
-			if (e.tagName()=="palette")
-			{
-				if (e.hasAttribute("type") && e.hasAttribute("filetype"))
-				{
-					//if (e.attribute("type")=="scribusofficial")
-					{
-						struct DownloadItem d;
-						d.desc=e.attribute("description");
-						d.download=false;
-						d.files=e.attribute("files");
-						d.extractfiles="";
-						d.url=e.attribute("URL");
-						d.version=e.attribute("version");
-						d.lang=e.attribute("language");
-						d.license=e.attribute("license");
-						d.filetype=e.attribute("filetype");
-						d.type=e.attribute("type");
-						d.source=e.attribute("source");
-						QUrl url(d.url);
-						if (url.isValid() && !url.isEmpty() && !url.host().isEmpty())
-							availableList.append(d);
-					}
-				}
-			}
-		}
-		n = n.nextSibling();
-	}
 	availableTableWidget->clear();
 	if(availableList.isEmpty())
 	{
@@ -731,7 +735,7 @@
 		newItem2->setFlags(newItem1->flags());
 		availableTableWidget->setItem(row, column++, newItem2);
 		QTableWidgetItem *newItem3 = new QTableWidgetItem();
-		newItem3->setCheckState(dictionaryMap.contains(d.files) ? Qt::Checked : Qt::Unchecked);
+		newItem3->setCheckState(dictionaryMap.contains(d.desc) ? Qt::Checked : Qt::Unchecked);
 		newItem3->setFlags(newItem1->flags() & ~Qt::ItemIsUserCheckable);
 		availableTableWidget->setItem(row, column++, newItem3);
 		QTableWidgetItem *newItem4 = new QTableWidgetItem(d.license);
@@ -816,8 +820,9 @@
 			updateAvailableHelp();
 			break;
 		case RM_PALETTES:
+			readAvailablePalettes();
+			updateInstalledPalettes();
 			updateAvailablePalettes();
-			updateInstalledPalettes();
 			break;
 		case RM_TEST:
 			updateInstalledTest();
@@ -1271,7 +1276,6 @@
 			break;
 		}
 	}
-	qDebug()<<lang<<licenceFileName;
 	if (!licenceFileName.isEmpty())
 	{
 		bool doDownload=true;

Modified: trunk/Scribus/scribus/ui/resourcemanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21358&path=/trunk/Scribus/scribus/ui/resourcemanager.h
==============================================================================
--- trunk/Scribus/scribus/ui/resourcemanager.h	(original)
+++ trunk/Scribus/scribus/ui/resourcemanager.h	Sat May 28 16:20:04 2016
@@ -60,6 +60,8 @@
 		void languageChange();
 
 	protected:
+		void readAvailablePalettes();
+
 		void updateInstalledFonts();
 		void updateInstalledHyph();
 		void updateInstalledSpell();




More information about the scribus-commit mailing list