r23684 by craig - Code cleanup
scribus-commit
scribus-commit at lists.scribus.net
Sun May 3 19:26:01 UTC 2020
Author: craig
Date: Sun May 3 19:26:00 2020
New Revision: 23684
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23684
Log:
Code cleanup
Modified:
trunk/Scribus/scribus/ui/layers.cpp
trunk/Scribus/scribus/ui/loremipsum.cpp
trunk/Scribus/scribus/ui/loremipsum.h
trunk/Scribus/scribus/ui/marginwidget.h
trunk/Scribus/scribus/ui/newdocdialog.cpp
trunk/Scribus/scribus/ui/pagepalette_widgets.cpp
trunk/Scribus/scribus/ui/pagepalette_widgets.h
Modified: trunk/Scribus/scribus/ui/layers.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23684&path=/trunk/Scribus/scribus/ui/layers.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/layers.cpp (original)
+++ trunk/Scribus/scribus/ui/layers.cpp Sun May 3 19:26:00 2020
@@ -157,7 +157,7 @@
connect(deleteLayerButton, SIGNAL(clicked()), this, SLOT(removeLayer()));
connect(raiseLayerButton, SIGNAL(clicked()), this, SLOT(upLayer()));
connect(lowerLayerButton, SIGNAL(clicked()), this, SLOT(downLayer()));
- connect(Table, SIGNAL(cellChanged(int, int)), this, SLOT(changeName(int, int)));
+ connect(Table, SIGNAL(cellChanged(int,int)), this, SLOT(changeName(int,int)));
connect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeOpacity()));
connect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
connect(header, SIGNAL(sectionClicked(int)), this, SLOT(toggleAllfromHeader(int)));
@@ -167,8 +167,8 @@
{
disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
disconnect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeOpacity()));
- disconnect(Table, SIGNAL(cellClicked(int, int)), this, SLOT(setActiveLayer(int, int)));
- disconnect(Table, SIGNAL(cellChanged(int, int)), this, SLOT(changeName(int, int)));
+ disconnect(Table, SIGNAL(cellClicked(int,int)), this, SLOT(setActiveLayer(int,int)));
+ disconnect(Table, SIGNAL(cellChanged(int,int)), this, SLOT(changeName(int,int)));
Table->clearContents();
Table->setRowCount(0);
m_Doc = nullptr;
@@ -212,8 +212,8 @@
{
disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
disconnect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeOpacity()));
- disconnect(Table, SIGNAL(cellClicked(int, int)), this, SLOT(setActiveLayer(int, int)));
- disconnect(Table, SIGNAL(cellChanged(int, int)), this, SLOT(changeName(int, int)));
+ disconnect(Table, SIGNAL(cellClicked(int,int)), this, SLOT(setActiveLayer(int,int)));
+ disconnect(Table, SIGNAL(cellChanged(int,int)), this, SLOT(changeName(int,int)));
QString tmp;
ScLayers::iterator it;
int layerCount = m_Doc->layerCount();
@@ -303,8 +303,8 @@
Table->setItem(row, 7, new QTableWidgetItem(m_Doc->layerName(layerID)));
}
- connect(Table, SIGNAL(cellChanged(int, int)), this, SLOT(changeName(int, int)));
- connect(Table, SIGNAL(cellClicked(int, int)), this, SLOT(setActiveLayer(int, int)));
+ connect(Table, SIGNAL(cellChanged(int,int)), this, SLOT(changeName(int,int)));
+ connect(Table, SIGNAL(cellClicked(int,int)), this, SLOT(setActiveLayer(int,int)));
connect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeOpacity()));
connect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
}
@@ -535,27 +535,27 @@
int row = layerCount - m_Doc->layerLevelFromID(it->ID) - 1;
if (index == 1)
{
- ((QCheckBox*)(Table->cellWidget(row, 1)))->toggle();
+ (dynamic_cast<QCheckBox*>(Table->cellWidget(row, 1)))->toggle();
it->isViewable = ((QCheckBox*)(Table->cellWidget(row, 1)))->isChecked();
}
if (index == 2)
{
- ((QCheckBox*)(Table->cellWidget(row, 2)))->toggle();
+ (dynamic_cast<QCheckBox*>(Table->cellWidget(row, 2)))->toggle();
it->isPrintable = ((QCheckBox*)(Table->cellWidget(row, 2)))->isChecked();
}
if (index == 3)
{
- ((QCheckBox*)(Table->cellWidget(row, 3)))->toggle();
+ (dynamic_cast<QCheckBox*>(Table->cellWidget(row, 3)))->toggle();
it->isEditable = !((QCheckBox*)(Table->cellWidget(row, 3)))->isChecked();
}
if (index == 4)
{
- ((QCheckBox*)(Table->cellWidget(row, 4)))->toggle();
+ (dynamic_cast<QCheckBox*>(Table->cellWidget(row, 4)))->toggle();
it->flowControl = ((QCheckBox*)(Table->cellWidget(row, 4)))->isChecked();
}
else if (index == 5)
{
- ((QCheckBox*)(Table->cellWidget(row, 5)))->toggle();
+ (dynamic_cast<QCheckBox*>(Table->cellWidget(row, 5)))->toggle();
it->outlineMode = ((QCheckBox*)(Table->cellWidget(row, 5)))->isChecked();
}
}
@@ -573,8 +573,7 @@
const QObject* senderBox = sender();
if (strcmp(senderBox->metaObject()->className(), "QToolButton") == 0)
{
- QColor neu = QColor();
- neu = QColorDialog::getColor(m_Doc->layerMarker(layerID), this);
+ QColor neu(QColorDialog::getColor(m_Doc->layerMarker(layerID), this));
if (neu.isValid())
{
QPixmap pm(20,15);
@@ -611,7 +610,7 @@
return;
disconnect(blendMode, SIGNAL(activated(int)), this, SLOT(changeBlendMode(int)));
disconnect(opacitySpinBox, SIGNAL(valueChanged(double)), this, SLOT(changeOpacity()));
- disconnect(Table, SIGNAL(cellClicked(int, int)), this, SLOT(setActiveLayer(int, int)));
+ disconnect(Table, SIGNAL(cellClicked(int,int)), this, SLOT(setActiveLayer(int,int)));
int layerToMark = layerID;
if (layerID == -1)
layerToMark = m_Doc->activeLayer();
Modified: trunk/Scribus/scribus/ui/loremipsum.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23684&path=/trunk/Scribus/scribus/ui/loremipsum.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/loremipsum.cpp (original)
+++ trunk/Scribus/scribus/ui/loremipsum.cpp Sun May 3 19:26:00 2020
@@ -45,17 +45,15 @@
#include "selection.h"
#include "undomanager.h"
-QString getLoremLocation(const QString& fname)
-{
- return QDir::toNativeSeparators(ScPaths::instance().shareDir() + "/loremipsum/" + fname);
-}
-
-LoremParser::LoremParser(const QString& fname)
-{
- name = author = url = "n/a";
- correct = false;
+QString getLoremLocation(const QString& filename)
+{
+ return QDir::toNativeSeparators(ScPaths::instance().shareDir() + "/loremipsum/" + filename);
+}
+
+LoremParser::LoremParser(const QString& filename)
+{
QDomDocument doc("loremdoc");
- QFile file(getLoremLocation(fname));
+ QFile file(getLoremLocation(filename));
if (!file.open(QIODevice::ReadOnly))
return;
if (!doc.setContent(&file))
@@ -248,7 +246,7 @@
// signals and slots connections
connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
- connect( loremList, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(accept()));
+ connect( loremList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(accept()));
}
Modified: trunk/Scribus/scribus/ui/loremipsum.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23684&path=/trunk/Scribus/scribus/ui/loremipsum.h
==============================================================================
--- trunk/Scribus/scribus/ui/loremipsum.h (original)
+++ trunk/Scribus/scribus/ui/loremipsum.h Sun May 3 19:26:00 2020
@@ -52,13 +52,13 @@
~LoremParser(){};
//! Is the LI correct?
- bool correct;
+ bool correct {false};
//! Name to display
- QString name;
+ QString name {"n/a"};
//! Author of the LI
- QString author;
+ QString author {"n/a"};
//! Website of the LI
- QString url;
+ QString url {"n/a"};
//! Paragraphs of the LI
QStringList loremIpsum;
@@ -109,22 +109,22 @@
private:
- ScribusDoc* m_Doc;
- QTreeWidget* loremList;
- QLabel* paraLabel;
- QSpinBox* paraBox;
- QCheckBox* randomCheckBox;
- QCheckBox* appendCheckBox;
- QPushButton* okButton;
- QPushButton* cancelButton;
- QGridLayout* LoremManagerLayout;
- QVBoxLayout* layout3;
- QHBoxLayout* layout2;
- QSpacerItem* paraSpacer;
- QHBoxLayout* layout1;
- QSpacerItem* buttonSpacer;
+ QCheckBox* appendCheckBox {nullptr};
+ QCheckBox* randomCheckBox {nullptr};
+ QGridLayout* LoremManagerLayout {nullptr};
+ QHBoxLayout* layout1 {nullptr};
+ QHBoxLayout* layout2 {nullptr};
+ QLabel* paraLabel {nullptr};
+ QPushButton* cancelButton {nullptr};
+ QPushButton* okButton {nullptr};
+ QSpacerItem* buttonSpacer {nullptr};
+ QSpacerItem* paraSpacer {nullptr};
+ QSpinBox* paraBox {nullptr};
QString standardloremtext;
- UndoManager* undoManager;
+ QTreeWidget* loremList {nullptr};
+ QVBoxLayout* layout3 {nullptr};
+ ScribusDoc* m_Doc {nullptr};
+ UndoManager* undoManager {nullptr};
//! all lorems with Public Name -> filename structure
QMap<QString,QString> availableLorems;
Modified: trunk/Scribus/scribus/ui/marginwidget.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23684&path=/trunk/Scribus/scribus/ui/marginwidget.h
==============================================================================
--- trunk/Scribus/scribus/ui/marginwidget.h (original)
+++ trunk/Scribus/scribus/ui/marginwidget.h Sun May 3 19:26:00 2020
@@ -46,7 +46,7 @@
/*! \brief Setup the spinboxes properties (min/max value etc.) by width */
void setPageWidth(double width);
/*! \brief Setup the spinboxes properties (min/max value etc.) by height */
- void setPageHeight(double heigth);
+ void setPageHeight(double height);
/*! \brief Setup the widgets by new options */
void setNewUnit(int newUnitIndex);
/*! \brief Set the page size for margin getting from cups */
Modified: trunk/Scribus/scribus/ui/newdocdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23684&path=/trunk/Scribus/scribus/ui/newdocdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/newdocdialog.cpp (original)
+++ trunk/Scribus/scribus/ui/newdocdialog.cpp Sun May 3 19:26:00 2020
@@ -161,14 +161,14 @@
connect(unitOfMeasureComboBox, SIGNAL(activated(int)), this, SLOT(setUnit(int)));
connect(Distance, SIGNAL(valueChanged(double)), this, SLOT(setDistance(double)));
connect(autoTextFrame, SIGNAL(clicked()), this, SLOT(handleAutoFrame()));
- connect(layoutsView, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* )));
- connect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* )));
- connect(layoutsView, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* )));
- connect(layoutsView, SIGNAL(itemPressed(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* )));
+ connect(layoutsView, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem* )));
+ connect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem* )));
+ connect(layoutsView, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem* )));
+ connect(layoutsView, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem* )));
if (startUp)
{
connect(nftGui, SIGNAL(leaveOK()), this, SLOT(ExitOK()));
- connect(recentDocListBox, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(recentDocListBox_doubleClicked()));
+ connect(recentDocListBox, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(recentDocListBox_doubleClicked()));
connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(adjustTitles(int)));
}
}
@@ -450,10 +450,10 @@
void NewDocDialog::selectItem(uint nr)
{
- disconnect(layoutsView, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* )));
- disconnect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* )));
- disconnect(layoutsView, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* )));
- disconnect(layoutsView, SIGNAL(itemPressed(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* )));
+ disconnect(layoutsView, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem* )));
+ disconnect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem* )));
+ disconnect(layoutsView, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem* )));
+ disconnect(layoutsView, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem* )));
if (nr > 0)
{
firstPage->setEnabled(true);
@@ -472,10 +472,10 @@
}
layoutsView->setCurrentRow(nr);
layoutsView->item(nr)->setSelected(true);
- connect(layoutsView, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* )));
- connect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* )));
- connect(layoutsView, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* )));
- connect(layoutsView, SIGNAL(itemPressed(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* )));
+ connect(layoutsView, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem* )));
+ connect(layoutsView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem* )));
+ connect(layoutsView, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem* )));
+ connect(layoutsView, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(itemSelected(QListWidgetItem* )));
}
void NewDocDialog::itemSelected(QListWidgetItem* ic)
Modified: trunk/Scribus/scribus/ui/pagepalette_widgets.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23684&path=/trunk/Scribus/scribus/ui/pagepalette_widgets.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_widgets.cpp (original)
+++ trunk/Scribus/scribus/ui/pagepalette_widgets.cpp Sun May 3 19:26:00 2020
@@ -29,10 +29,10 @@
/* IconItems Code */
SeItem::SeItem(const QString& text, uint nr, const QPixmap& Pix)
- : QTableWidgetItem(QIcon(Pix), "", 1002)
-{
- pageNumber = nr;
- pageName = text;
+ : QTableWidgetItem(QIcon(Pix), "", 1002),
+ pageNumber(nr),
+ pageName(text)
+{
setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
}
@@ -44,9 +44,6 @@
/* ListBox Subclass */
SeList::SeList(QWidget* parent) : QListWidget(parent)
{
- m_currItem = nullptr;
- m_mousePressed = false;
- m_thumb = false;
setAcceptDrops(true);
}
@@ -139,18 +136,8 @@
setDragEnabled(true);
setAcceptDrops(true);
setDropIndicatorShown(true);
-// viewport()->setAcceptDrops(true);
setShowGrid(false);
setWordWrap(true);
- m_mousePressed = false;
- m_pageCount = 0;
- m_colmult = 1;
- m_coladd = 0;
- m_rowmult = 2;
- m_rowadd = 1;
- m_cols = 1;
- m_firstPage = 0;
-// setFocusPolicy(Qt::NoFocus);
}
void SeView::mousePressEvent(QMouseEvent* e)
@@ -337,27 +324,26 @@
void SeView::dragMoveEvent(QDragMoveEvent *e)
{
- if (e->mimeData()->hasFormat("page/magic"))
- {
- e->acceptProposedAction();
- int a = rowAt(e->pos().y());
- int b = columnAt(e->pos().x());
- clearPix();
- if ((a == -1) || (b == -1))
- return;
- if (columnCount() == 1)
- {
- if ((a % 2) == 0)
- {
- item(a, 0)->setBackground(Qt::darkBlue);
- }
- }
- else
- {
- if (((b % 2) == 0) || (a == rowCount()-1))
- {
- item(a, b)->setBackground(Qt::darkBlue);
- }
+ if (!e->mimeData()->hasFormat("page/magic"))
+ return;
+ e->acceptProposedAction();
+ int a = rowAt(e->pos().y());
+ int b = columnAt(e->pos().x());
+ clearPix();
+ if ((a == -1) || (b == -1))
+ return;
+ if (columnCount() == 1)
+ {
+ if ((a % 2) == 0)
+ {
+ item(a, 0)->setBackground(Qt::darkBlue);
+ }
+ }
+ else
+ {
+ if (((b % 2) == 0) || (a == rowCount()-1))
+ {
+ item(a, b)->setBackground(Qt::darkBlue);
}
}
}
@@ -385,14 +371,13 @@
void SeView::clearPix()
{
- int counter = 0;
int rowcounter = 0;
- for (int a = 0; a < rowCount(); ++a)
- {
- counter = 0;
+ for (int i = 0; i < rowCount(); ++i)
+ {
+ int counter = 0;
if (columnCount() == 1)
{
- if ((a % 2) == 0)
+ if ((i % 2) == 0)
{
item(rowcounter, 0)->setBackground(Qt::white);
rowcounter += 2;
@@ -400,9 +385,9 @@
}
else
{
- for (int b = 0; b < columnCount(); ++b)
- {
- if ((b % 2) == 0)
+ for (int j = 0; j < columnCount(); ++j)
+ {
+ if ((j % 2) == 0)
{
item(rowcounter, counter)->setBackground(Qt::white);
counter += 2;
@@ -411,9 +396,9 @@
rowcounter++;
}
}
- for (int c = 0; c < columnCount(); ++c)
- {
- item(rowCount()-1, c)->setBackground(Qt::white);
+ for (int i = 0; i < columnCount(); ++i)
+ {
+ item(rowCount()-1, i)->setBackground(Qt::white);
}
}
Modified: trunk/Scribus/scribus/ui/pagepalette_widgets.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23684&path=/trunk/Scribus/scribus/ui/pagepalette_widgets.h
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_widgets.h (original)
+++ trunk/Scribus/scribus/ui/pagepalette_widgets.h Sun May 3 19:26:00 2020
@@ -77,12 +77,12 @@
void mouseReleaseEvent(QMouseEvent *m);
void mousePressEvent(QMouseEvent* e);
void mouseMoveEvent(QMouseEvent* e);
- virtual void keyPressEvent(QKeyEvent* e);
+ virtual void keyPressEvent(QKeyEvent* e);
+ QListWidgetItem *m_currItem {nullptr};
QPoint m_mousePos;
- bool m_mousePressed;
- QListWidgetItem *m_currItem;
- bool m_thumb;
+ bool m_mousePressed {false};
+ bool m_thumb {false};
};
@@ -113,20 +113,20 @@
virtual void dragEnterEvent(QDragEnterEvent *e);
virtual void dragLeaveEvent(QDragLeaveEvent *e);
virtual void dragMoveEvent(QDragMoveEvent *e);
- virtual void mouseReleaseEvent(QMouseEvent *m);
+ virtual void mouseReleaseEvent(QMouseEvent *e);
virtual void mousePressEvent(QMouseEvent* e);
virtual void mouseMoveEvent(QMouseEvent* e);
virtual void keyPressEvent(QKeyEvent* e);
QPoint m_mousePos;
- bool m_mousePressed;
- int m_pageCount;
- int m_colmult;
- int m_rowmult;
- int m_coladd;
- int m_rowadd;
- int m_cols;
- int m_firstPage;
+ bool m_mousePressed {false};
+ int m_coladd {0};
+ int m_colmult {1};
+ int m_cols {1};
+ int m_firstPage {0};
+ int m_pageCount {0};
+ int m_rowadd {1};
+ int m_rowmult {2};
};
class SCRIBUS_API TrashBin : public QLabel
More information about the scribus-commit
mailing list