r20879 by craig -
scribus-commit
scribus-commit at lists.scribus.net
Tue Feb 2 21:03:23 UTC 2016
Author: craig
Date: Tue Feb 2 21:03:23 2016
New Revision: 20879
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20879
Log:
coverity #93093: fix unchecked dynamic_cast and remove some unnecessary code
Modified:
trunk/Scribus/scribus/ui/spalette.cpp
Modified: trunk/Scribus/scribus/ui/spalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20879&path=/trunk/Scribus/scribus/ui/spalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/spalette.cpp (original)
+++ trunk/Scribus/scribus/ui/spalette.cpp Tue Feb 2 21:03:23 2016
@@ -110,12 +110,65 @@
if (currentDoc != NULL)
{
QStringList st;
- st.clear();
addItem( tr("No Style"));
for (int x = 0; x < currentDoc->charStyles().count(); ++x)
{
if ( !currentDoc->charStyles()[x].name().isEmpty() )
st.append(currentDoc->charStyles()[x].name());
+ }
+ st.sort();
+ addItems(st);
+ }
+ QListView *tmpView = dynamic_cast<QListView*>(view());
+ if (tmpView)
+ {
+ int tmpWidth = tmpView->sizeHintForColumn(0);
+ if (tmpWidth > 0)
+ tmpView->setMinimumWidth(tmpWidth + 24);
+ }
+ connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+}
+
+void CharStyleComboBox::selFormat(int e)
+{
+ if (e == 0)
+ emit newStyle(QString::null);
+ else
+ emit newStyle(currentText());
+}
+
+CellStyleComboBox::CellStyleComboBox(QWidget* parent) : QComboBox(parent)
+{
+ setEditable(false);
+ addItem( tr("No Style"));
+ currentDoc = NULL;
+ connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+}
+
+void CellStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
+{
+ currentDoc = newCurrentDoc;
+ updateFormatList();
+}
+
+void CellStyleComboBox::setFormat(QString name)
+{
+ setCurrentComboItem(this, name.isEmpty() ? tr("No Style") : name);
+}
+
+void CellStyleComboBox::updateFormatList()
+{
+ disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+ clear();
+ if (currentDoc != NULL)
+ {
+ QStringList st;
+ st.clear();
+ addItem( tr("No Style"));
+ for (int x = 0; x < currentDoc->cellStyles().count(); ++x)
+ {
+ if ( !currentDoc->cellStyles()[x].name().isEmpty() )
+ st.append(currentDoc->cellStyles()[x].name());
}
st.sort();
addItems(st);
@@ -127,38 +180,38 @@
connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
}
-void CharStyleComboBox::selFormat(int e)
-{
- if (e == 0)
- {
- emit newStyle(QString::null);
- }
- else
- {
- emit newStyle(currentText());
- }
-}
-
-CellStyleComboBox::CellStyleComboBox(QWidget* parent) : QComboBox(parent)
-{
- setEditable(false);
- addItem( tr("No Style"));
- currentDoc = NULL;
- connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
-}
-
-void CellStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
-{
- currentDoc = newCurrentDoc;
- updateFormatList();
-}
-
-void CellStyleComboBox::setFormat(QString name)
-{
- setCurrentComboItem(this, name.isEmpty() ? tr("No Style") : name);
-}
-
-void CellStyleComboBox::updateFormatList()
+void CellStyleComboBox::selFormat(int e)
+{
+ if (e == 0)
+ {
+ emit newStyle(QString::null);
+ }
+ else
+ {
+ emit newStyle(currentText());
+ }
+}
+
+TableStyleComboBox::TableStyleComboBox(QWidget* parent) : QComboBox(parent)
+{
+ setEditable(false);
+ addItem( tr("No Style"));
+ currentDoc = NULL;
+ connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
+}
+
+void TableStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
+{
+ currentDoc = newCurrentDoc;
+ updateFormatList();
+}
+
+void TableStyleComboBox::setFormat(QString name)
+{
+ setCurrentComboItem(this, name.isEmpty() ? tr("No Style") : name);
+}
+
+void TableStyleComboBox::updateFormatList()
{
disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
clear();
@@ -167,10 +220,10 @@
QStringList st;
st.clear();
addItem( tr("No Style"));
- for (int x = 0; x < currentDoc->cellStyles().count(); ++x)
- {
- if ( !currentDoc->cellStyles()[x].name().isEmpty() )
- st.append(currentDoc->cellStyles()[x].name());
+ for (int x = 0; x < currentDoc->tableStyles().count(); ++x)
+ {
+ if ( !currentDoc->tableStyles()[x].name().isEmpty() )
+ st.append(currentDoc->tableStyles()[x].name());
}
st.sort();
addItems(st);
@@ -182,61 +235,6 @@
connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
}
-void CellStyleComboBox::selFormat(int e)
-{
- if (e == 0)
- {
- emit newStyle(QString::null);
- }
- else
- {
- emit newStyle(currentText());
- }
-}
-
-TableStyleComboBox::TableStyleComboBox(QWidget* parent) : QComboBox(parent)
-{
- setEditable(false);
- addItem( tr("No Style"));
- currentDoc = NULL;
- connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
-}
-
-void TableStyleComboBox::setDoc(ScribusDoc *newCurrentDoc)
-{
- currentDoc = newCurrentDoc;
- updateFormatList();
-}
-
-void TableStyleComboBox::setFormat(QString name)
-{
- setCurrentComboItem(this, name.isEmpty() ? tr("No Style") : name);
-}
-
-void TableStyleComboBox::updateFormatList()
-{
- disconnect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
- clear();
- if (currentDoc != NULL)
- {
- QStringList st;
- st.clear();
- addItem( tr("No Style"));
- for (int x = 0; x < currentDoc->tableStyles().count(); ++x)
- {
- if ( !currentDoc->tableStyles()[x].name().isEmpty() )
- st.append(currentDoc->tableStyles()[x].name());
- }
- st.sort();
- addItems(st);
- }
- QListView *tmpView = dynamic_cast<QListView*>(view());
- int tmpWidth = tmpView->sizeHintForColumn(0);
- if (tmpWidth > 0)
- tmpView->setMinimumWidth(tmpWidth + 24);
- connect(this, SIGNAL(activated(int)), this, SLOT(selFormat(int)));
-}
-
void TableStyleComboBox::selFormat(int e)
{
if (e == 0)
More information about the scribus-commit
mailing list