r22708 by jghali - code style fixes
scribus-commit
scribus-commit at lists.scribus.net
Sun Sep 30 02:35:01 UTC 2018
Author: jghali
Date: Sun Sep 30 02:35:01 2018
New Revision: 22708
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22708
Log:
code style fixes
Modified:
trunk/Scribus/scribus/ui/scrapbookpalette.cpp
Modified: trunk/Scribus/scribus/ui/scrapbookpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22708&path=/trunk/Scribus/scribus/ui/scrapbookpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/scrapbookpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/scrapbookpalette.cpp Sun Sep 30 02:35:01 2018
@@ -92,7 +92,7 @@
QList<QUrl> urlList;
if (fi.suffix().toLower() == "sce")
{
- if ( fi.exists() )
+ if (fi.exists())
{
QUrl ur = QUrl::fromLocalFile(dt);
urlList.append(ur);
@@ -101,7 +101,7 @@
}
else if ((vectorFiles.contains(fi.suffix().toLower())) || (rasterFiles.contains(fi.suffix().toLower())))
{
- if ( fi.exists() )
+ if (fi.exists())
{
QUrl ur = QUrl::fromLocalFile(dt);
urlList.append(ur);
@@ -143,16 +143,16 @@
if (startElemPos >= 0)
emit objDropped(text);
}
- else if ( e->mimeData()->hasFormat("text/uri-list"))
+ else if (e->mimeData()->hasFormat("text/uri-list"))
{
QStringList vectorFiles = LoadSavePlugin::getExtensionsForPreview(FORMATID_FIRSTUSER);
QString formatD(FormatsManager::instance()->extensionListForFormat(FormatsManager::RASTORIMAGES, 1));
QStringList rasterFiles = formatD.split("|");
QList<QUrl> fileUrls = e->mimeData()->urls();
e->acceptProposedAction();
- for( int i = 0; i < fileUrls.count(); ++i )
- {
- QUrl url( fileUrls[i] );
+ for (int i = 0; i < fileUrls.count(); ++i)
+ {
+ QUrl url(fileUrls[i] );
QFileInfo fi(url.path());
if (vectorFiles.contains(fi.suffix().toLower()))
{
@@ -183,11 +183,11 @@
void BibView::checkForImg(const QDomElement& elem, bool &hasImage)
{
- QDomNode DOC = elem.firstChild();
- while(!DOC.isNull())
- {
- QDomElement pg = DOC.toElement();
- if(pg.tagName() == "PAGEOBJECT")
+ QDomNode node = elem.firstChild();
+ while (!node.isNull())
+ {
+ QDomElement pg = node.toElement();
+ if (pg.tagName() == "PAGEOBJECT")
{
PageItem::ItemType PType = static_cast<PageItem::ItemType>(pg.attribute("PTYPE").toInt());
if ((PType == PageItem::ImageFrame) || (PType == PageItem::TextFrame))
@@ -213,7 +213,7 @@
if (hasImage)
break;
}
- DOC = DOC.nextSibling();
+ node = node.nextSibling();
}
}
@@ -223,11 +223,11 @@
QDomDocument docu("scridoc");
docu.setContent(text);
QDomElement elem = docu.documentElement();
- QDomNode DOC = elem.firstChild();
- while(!DOC.isNull())
- {
- QDomElement pg = DOC.toElement();
- if(pg.tagName() == "ITEM")
+ QDomNode node = elem.firstChild();
+ while (!node.isNull())
+ {
+ QDomElement pg = node.toElement();
+ if (pg.tagName() == "ITEM")
{
PageItem::ItemType PType = static_cast<PageItem::ItemType>(pg.attribute("PTYPE").toInt());
if ((PType == PageItem::ImageFrame) || (PType == PageItem::TextFrame))
@@ -253,7 +253,7 @@
if (hasImage)
break;
}
- DOC = DOC.nextSibling();
+ node = node.nextSibling();
}
QFileInfo fid(nam);
if (hasImage)
@@ -264,10 +264,10 @@
QString source = "";
QString fileDir = ScPaths::applicationDataDir();
bool first = true;
- DOC = elem.firstChild();
- while(!DOC.isNull())
- {
- QDomElement pg = DOC.toElement();
+ node = elem.firstChild();
+ while (!node.isNull())
+ {
+ QDomElement pg = node.toElement();
if (pg.tagName() == "ITEM")
{
if (first)
@@ -346,10 +346,10 @@
checkAndChangeGroups(pg, dir, fid);
}
}
- DOC = DOC.nextSibling();
+ node = node.nextSibling();
}
QFile f(nam);
- if(!f.open(QIODevice::WriteOnly))
+ if (!f.open(QIODevice::WriteOnly))
return ;
QDataStream s;
QByteArray cs = docu.toByteArray();
@@ -362,10 +362,10 @@
{
QString source;
QString fileDir = ScPaths::applicationDataDir();
- QDomNode DOC = elem.firstChild();
- while (!DOC.isNull())
- {
- QDomElement pg = DOC.toElement();
+ QDomNode node = elem.firstChild();
+ while (!node.isNull())
+ {
+ QDomElement pg = node.toElement();
if (pg.tagName() == "PAGEOBJECT")
{
PageItem::ItemType PType = static_cast<PageItem::ItemType>(pg.attribute("PTYPE").toInt());
@@ -441,7 +441,7 @@
checkAndChangeGroups(pg, dir, fid);
}
}
- DOC = DOC.nextSibling();
+ node = node.nextSibling();
}
}
@@ -453,26 +453,26 @@
QByteArray cf;
if (!loadRawText(name, cf))
return;
- if( cf.left(17) == "<SCRIBUSSCRAPUTF8")
+ if (cf.left(17) == "<SCRIBUSSCRAPUTF8")
{
ff = QString::fromUtf8(cf.data());
isUtf8 = true;
}
else
ff = QString::fromLocal8Bit(cf.data());
- if(!docu.setContent(ff))
+ if (!docu.setContent(ff))
return;
- QDomElement elem=docu.documentElement();
+ QDomElement elem = docu.documentElement();
if ((elem.tagName() != "SCRIBUSSCRAP") && (elem.tagName() != "SCRIBUSSCRAPUTF8"))
return;
- QDomNode DOC=elem.firstChild();
- while(!DOC.isNull())
- {
- QDomElement dc=DOC.toElement();
+ QDomNode node = elem.firstChild();
+ while (!node.isNull())
+ {
+ QDomElement dc=node.toElement();
if (dc.tagName()=="OBJEKT")
{
QFile fi(QDir::cleanPath(QDir::toNativeSeparators(newName + "/" + dc.attribute("NAME", nullptr) + ".sce")));
- if(!fi.open(QIODevice::WriteOnly))
+ if (!fi.open(QIODevice::WriteOnly))
continue ;
QDataStream s(&fi);
QString fn = dc.attribute("DATA", nullptr);
@@ -480,7 +480,7 @@
s.writeRawData(cf.data(), cf.length());
fi.close();
}
- DOC=DOC.nextSibling();
+ node = node.nextSibling();
}
}
@@ -608,7 +608,7 @@
if ((testResult != -1) && (testResult >= FORMATID_FIRSTUSER))
{
const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult);
- if( fmt )
+ if (fmt)
{
QImage im = fmt->readThumbnail(QDir::cleanPath(QDir::toNativeSeparators(name + "/" + d4[dc])));
im = im.scaled(60, 60, Qt::KeepAspectRatio, Qt::SmoothTransformation);
@@ -699,7 +699,7 @@
}
/* This is the main Dialog-Class for the Scrapbook */
-Biblio::Biblio( QWidget* parent) : ScDockPalette( parent, "Sclib", nullptr)
+Biblio::Biblio( QWidget* parent) : ScDockPalette(parent, "Sclib", nullptr)
{
// resize( 230, 190 );
setObjectName(QString::fromLocal8Bit("Sclib"));
@@ -1245,7 +1245,7 @@
}
QFileInfo fi(dt);
QFile f(QDir::cleanPath(QDir::toNativeSeparators(bv->ScFilename + "/" + nam + "." + fi.completeSuffix().toLower())));
- if(!f.open(QIODevice::WriteOnly))
+ if (!f.open(QIODevice::WriteOnly))
return false;
QDataStream s;
s.setDevice(&f);
@@ -1458,12 +1458,12 @@
QDomDocument docu("scridoc");
docu.setContent(f);
QDomElement elem = docu.documentElement();
- QDomNode DOC = elem.firstChild();
+ QDomNode node = elem.firstChild();
QFileInfo fid(nam);
- while(!DOC.isNull())
- {
- QDomElement pg = DOC.toElement();
- if(pg.tagName() == "ITEM")
+ while (!node.isNull())
+ {
+ QDomElement pg = node.toElement();
+ if (pg.tagName() == "ITEM")
{
PageItem::ItemType PType = static_cast<PageItem::ItemType>(pg.attribute("PTYPE").toInt());
if ((PType == PageItem::ImageFrame) || (PType == PageItem::TextFrame))
@@ -1502,10 +1502,10 @@
adjustReferencesGroups(pg, fid);
}
}
- DOC = DOC.nextSibling();
+ node = node.nextSibling();
}
QFile fl(nam);
- if(!fl.open(QIODevice::WriteOnly))
+ if (!fl.open(QIODevice::WriteOnly))
return ;
QDataStream s;
QByteArray cs = docu.toByteArray();
@@ -1517,11 +1517,11 @@
void Biblio::adjustReferencesGroups(const QDomElement& elem, const QFileInfo& fid)
{
- QDomNode DOC = elem.firstChild();
- while(!DOC.isNull())
- {
- QDomElement pg = DOC.toElement();
- if(pg.tagName() == "PAGEOBJECT")
+ QDomNode node = elem.firstChild();
+ while (!node.isNull())
+ {
+ QDomElement pg = node.toElement();
+ if (pg.tagName() == "PAGEOBJECT")
{
PageItem::ItemType PType = static_cast<PageItem::ItemType>(pg.attribute("PTYPE").toInt());
if ((PType == PageItem::ImageFrame) || (PType == PageItem::TextFrame))
@@ -1560,7 +1560,7 @@
adjustReferencesGroups(pg, fid);
}
}
- DOC = DOC.nextSibling();
+ node = node.nextSibling();
}
}
@@ -1569,17 +1569,17 @@
QDomDocument docu("scridoc");
docu.setContent(text);
QDomElement elem = docu.documentElement();
- QDomNode DOC = elem.firstChild();
+ QDomNode node = elem.firstChild();
QString result = "";
- while(!DOC.isNull())
- {
- QDomElement pg = DOC.toElement();
- if(pg.tagName() == "ITEM")
+ while (!node.isNull())
+ {
+ QDomElement pg = node.toElement();
+ if (pg.tagName() == "ITEM")
{
result = pg.attribute("ANNAME");
break;
}
- DOC = DOC.nextSibling();
+ node = node.nextSibling();
}
return result;
}
@@ -1592,126 +1592,125 @@
bool isVector = false;
QString tmp;
QFileInfo fi(path);
- if ( fi.exists() )
- {
- QString nam = "";
- nam = fi.baseName();
- if (Frame3->currentIndex() == 1)
- {
- if (activeBView->objectMap.contains(nam))
- nam += "("+ tmp.setNum(tempCount) + ")";
- tempCount++;
- }
- else
- {
- if (activeBView->objectMap.contains(nam))
- nam += "("+ tmp.setNum(tempCount) + ")";
- }
- Query dia(this, "tt", true, tr("&Name:"), tr("New Entry"));
- dia.setValidator(QRegExp("[\\w()]+"));
- dia.setEditText(nam, true);
- dia.setTestList(activeBView->objectMap.keys());
- if (dia.exec())
- nam = dia.getEditText();
- else
- return;
- QImage img;
- if (testResult == 9999)
- {
- bool mode = false;
- ScImage im;
- CMSettings cms(nullptr, "", Intent_Perceptual);
- cms.allowColorManagement(false);
- if (im.loadPicture(path, 1, cms, ScImage::Thumbnail, 72, &mode))
- img = im.scaled(60, 60, Qt::KeepAspectRatio, Qt::SmoothTransformation);
- isImage = true;
- }
- else
- {
- const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult);
- if( fmt )
- {
- img = fmt->readThumbnail(path);
- img = img.scaled(60, 60, Qt::KeepAspectRatio, Qt::SmoothTransformation);
- }
- isVector = true;
- }
- QByteArray cf;
- if (!loadRawText(path, cf))
- return;
- QPixmap pm = QPixmap::fromImage(img);
- QFile f(QDir::cleanPath(QDir::toNativeSeparators(activeBView->ScFilename + "/" + nam + "." + fi.completeSuffix())));
- if(!f.open(QIODevice::WriteOnly))
- return;
- QDataStream s;
- s.setDevice(&f);
- s.writeRawData(cf.data(), cf.length());
- f.close();
- if (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews)
- {
- QDir thumbs(activeBView->ScFilename);
- if (thumbs.exists())
- {
- if ((activeBView->canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
- thumbs.mkdir(".ScribusThumbs");
- }
- img.save(QDir::cleanPath(QDir::toNativeSeparators(activeBView->ScFilename + "/.ScribusThumbs/" + nam +".png")), "PNG");
- }
- activeBView->AddObj(nam, QDir::cleanPath(QDir::toNativeSeparators(activeBView->ScFilename + "/" + nam + "." + fi.completeSuffix())), pm, false, isImage, isVector);
- QPixmap pm2(60, 60);
- pm2.fill(palette().color(QPalette::Base));
- QPainter p;
- p.begin(&pm2);
- p.drawPixmap(30 - pm.width() / 2, 30 - pm.height() / 2, pm);
- p.end();
- QListWidgetItem *item = new QListWidgetItem(QIcon(pm2), nam, activeBView);
- item->setToolTip(nam);
- activeBView->objectMap[nam].widgetItem = item;
- if (isImage)
- item->setHidden(conf_HideImages->isChecked());
- if (isVector)
- item->setHidden(conf_HideVectors->isChecked());
- if (Frame3->currentIndex() == 1)
- {
- if (tempBView->objectMap.count() > PrefsManager::instance()->appPrefs.scrapbookPrefs.numScrapbookCopies)
- {
- QMap<QString,BibView::Elem>::Iterator it;
- it = tempBView->objectMap.begin();
- QFile f(it.value().Data);
- f.remove();
- QFileInfo fi(QDir::toNativeSeparators(tempBView->ScFilename + "/.ScribusThumbs/" + it.key() + ".png"));
- if (fi.exists())
- {
- QFile f2(QDir::toNativeSeparators(tempBView->ScFilename + "/.ScribusThumbs/" + it.key() + ".png"));
- f2.remove();
- }
- QFileInfo fiD(QDir::toNativeSeparators(tempBView->ScFilename + "/" + it.key()));
- if ((fiD.exists()) && (fiD.isDir()))
- {
- QDir dd = QDir(QDir::toNativeSeparators(tempBView->ScFilename));
- QDir d(QDir::toNativeSeparators(tempBView->ScFilename + "/" + it.key()), "*", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
- if ((d.exists()) && (d.count() != 0))
+ if (!fi.exists())
+ return;
+
+ QString nam = fi.baseName();
+ if (Frame3->currentIndex() == 1)
+ {
+ if (activeBView->objectMap.contains(nam))
+ nam += "("+ tmp.setNum(tempCount) + ")";
+ tempCount++;
+ }
+ else
+ {
+ if (activeBView->objectMap.contains(nam))
+ nam += "("+ tmp.setNum(tempCount) + ")";
+ }
+ Query dia(this, "tt", true, tr("&Name:"), tr("New Entry"));
+ dia.setValidator(QRegExp("[\\w()]+"));
+ dia.setEditText(nam, true);
+ dia.setTestList(activeBView->objectMap.keys());
+ if (dia.exec())
+ nam = dia.getEditText();
+ else
+ return;
+ QImage img;
+ if (testResult == 9999)
+ {
+ bool mode = false;
+ ScImage im;
+ CMSettings cms(nullptr, "", Intent_Perceptual);
+ cms.allowColorManagement(false);
+ if (im.loadPicture(path, 1, cms, ScImage::Thumbnail, 72, &mode))
+ img = im.scaled(60, 60, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ isImage = true;
+ }
+ else
+ {
+ const FileFormat * fmt = LoadSavePlugin::getFormatById(testResult);
+ if (fmt)
+ {
+ img = fmt->readThumbnail(path);
+ img = img.scaled(60, 60, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ }
+ isVector = true;
+ }
+ QByteArray cf;
+ if (!loadRawText(path, cf))
+ return;
+ QPixmap pm = QPixmap::fromImage(img);
+ QFile f(QDir::cleanPath(QDir::toNativeSeparators(activeBView->ScFilename + "/" + nam + "." + fi.completeSuffix())));
+ if (!f.open(QIODevice::WriteOnly))
+ return;
+ QDataStream s;
+ s.setDevice(&f);
+ s.writeRawData(cf.data(), cf.length());
+ f.close();
+ if (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews)
+ {
+ QDir thumbs(activeBView->ScFilename);
+ if (thumbs.exists())
+ {
+ if ((activeBView->canWrite) && (PrefsManager::instance()->appPrefs.scrapbookPrefs.writePreviews))
+ thumbs.mkdir(".ScribusThumbs");
+ }
+ img.save(QDir::cleanPath(QDir::toNativeSeparators(activeBView->ScFilename + "/.ScribusThumbs/" + nam +".png")), "PNG");
+ }
+ activeBView->AddObj(nam, QDir::cleanPath(QDir::toNativeSeparators(activeBView->ScFilename + "/" + nam + "." + fi.completeSuffix())), pm, false, isImage, isVector);
+ QPixmap pm2(60, 60);
+ pm2.fill(palette().color(QPalette::Base));
+ QPainter p;
+ p.begin(&pm2);
+ p.drawPixmap(30 - pm.width() / 2, 30 - pm.height() / 2, pm);
+ p.end();
+ QListWidgetItem *item = new QListWidgetItem(QIcon(pm2), nam, activeBView);
+ item->setToolTip(nam);
+ activeBView->objectMap[nam].widgetItem = item;
+ if (isImage)
+ item->setHidden(conf_HideImages->isChecked());
+ if (isVector)
+ item->setHidden(conf_HideVectors->isChecked());
+ if (Frame3->currentIndex() == 1)
+ {
+ if (tempBView->objectMap.count() > PrefsManager::instance()->appPrefs.scrapbookPrefs.numScrapbookCopies)
+ {
+ QMap<QString,BibView::Elem>::Iterator it;
+ it = tempBView->objectMap.begin();
+ QFile f(it.value().Data);
+ f.remove();
+ QFileInfo fi(QDir::toNativeSeparators(tempBView->ScFilename + "/.ScribusThumbs/" + it.key() + ".png"));
+ if (fi.exists())
+ {
+ QFile f2(QDir::toNativeSeparators(tempBView->ScFilename + "/.ScribusThumbs/" + it.key() + ".png"));
+ f2.remove();
+ }
+ QFileInfo fiD(QDir::toNativeSeparators(tempBView->ScFilename + "/" + it.key()));
+ if ((fiD.exists()) && (fiD.isDir()))
+ {
+ QDir dd = QDir(QDir::toNativeSeparators(tempBView->ScFilename));
+ QDir d(QDir::toNativeSeparators(tempBView->ScFilename + "/" + it.key()), "*", QDir::Name, QDir::Files | QDir::Readable | QDir::NoSymLinks);
+ if ((d.exists()) && (d.count() != 0))
+ {
+ for (uint dc = 0; dc < d.count(); ++dc)
{
- for (uint dc = 0; dc < d.count(); ++dc)
- {
- QFile::remove(QDir::toNativeSeparators(tempBView->ScFilename + "/" + it.key() + "/" + d[dc]));
- }
+ QFile::remove(QDir::toNativeSeparators(tempBView->ScFilename + "/" + it.key() + "/" + d[dc]));
}
- dd.rmdir(QDir::toNativeSeparators(tempBView->ScFilename + "/" + it.key()));
- }
- QString name = it.key();
- tempBView->objectMap.erase(it);
- QList<QListWidgetItem *> itL = tempBView->findItems(name, Qt::MatchExactly);
- if (itL.count() > 0)
- {
- QListWidgetItem *ite = itL.at(0);
- delete tempBView->takeItem(tempBView->row(ite));
- }
- }
- emit updateRecentMenue();
- }
- reloadLib(activeBView->ScFilename);
- }
+ }
+ dd.rmdir(QDir::toNativeSeparators(tempBView->ScFilename + "/" + it.key()));
+ }
+ QString name = it.key();
+ tempBView->objectMap.erase(it);
+ QList<QListWidgetItem *> itL = tempBView->findItems(name, Qt::MatchExactly);
+ if (itL.count() > 0)
+ {
+ QListWidgetItem *ite = itL.at(0);
+ delete tempBView->takeItem(tempBView->row(ite));
+ }
+ }
+ emit updateRecentMenue();
+ }
+ reloadLib(activeBView->ScFilename);
}
void Biblio::ObjFromMenu(QString text)
@@ -1770,6 +1769,7 @@
item->setToolTip(nam);
activeBView->objectMap[nam].widgetItem = item;
delete pre;
+
if (Frame3->currentIndex() == 1)
{
if (tempBView->objectMap.count() > PrefsManager::instance()->appPrefs.scrapbookPrefs.numScrapbookCopies)
More information about the scribus-commit
mailing list