r19937 by craig - Clean up ScMessageBox a little

scribus-commit scribus-commit at lists.scribus.net
Tue Mar 17 18:49:38 UTC 2015


Author: craig
Date: Tue Mar 17 18:49:38 2015
New Revision: 19937

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19937
Log:
Clean up ScMessageBox a little

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

Modified: trunk/Scribus/scribus/ui/scmessagebox.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19937&path=/trunk/Scribus/scribus/ui/scmessagebox.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/scmessagebox.cpp (original)
+++ trunk/Scribus/scribus/ui/scmessagebox.cpp Tue Mar 17 18:49:38 2015
@@ -24,19 +24,11 @@
  ***************************************************************************/
 
 #include <QMessageBox>
-
 #include <iostream>
 
 #include "scconfig.h"
 #include "scribuscore.h"
 #include "ui/scmessagebox.h"
-
-
-/*
-** ScMessageBox
-*/
-
-// Initialize private variables
 
 void ScMessageBox::initScMessageBox(void)
 {
@@ -69,21 +61,20 @@
 				QMessageBox::StandardButton defaultButton, QMessageBox::StandardButton defaultBatchButton)
 {
 	QMessageBox::StandardButton result = ((defaultBatchButton != QMessageBox::NoButton)? defaultBatchButton: defaultButton);
-
-	if (result == QMessageBox::NoButton) {
+	if (result == QMessageBox::NoButton)
+	{
 		QMessageBox::StandardButton buttonList[] = { QMessageBox::Yes, QMessageBox::Ok,
 					QMessageBox::Cancel, QMessageBox::Close, QMessageBox::Discard,
 					QMessageBox::No, QMessageBox::Abort, QMessageBox::Ignore, QMessageBox::NoButton };
-		for (int i = 0; buttonList[ i ] != QMessageBox::NoButton; i++)
+		for (int i = 0; buttonList[i] != QMessageBox::NoButton; i++)
 		{
-			if ((buttons & buttonList[ i ]) != 0)
+			if ((buttons & buttonList[i]) != 0)
 			{
-				result = buttonList[ i ];
+				result = buttonList[i];
 				break;
 			}
 		}
 	}
-
 	return result;
 }
 
@@ -100,24 +91,16 @@
 int ScMessageBox::exec()
 {
 	if (ScCore->usingGUI())
-	{
 		return QMessageBox::exec();
-	}
-
 	QString msg = messageTitle + text() + " " + informativeText() + " " + detailedText();
-
 	std::cerr << msg.toLocal8Bit().data() << std::endl;
-
 	return static_cast<int>(findDefaultButton(QMessageBox::standardButtons(), QMessageBox::NoButton, defaultBatchStandardButton));
 }
 
 QAbstractButton *ScMessageBox::clickedButton() const
 {
 	if (ScCore->usingGUI())
-	{
 		return QMessageBox::clickedButton();
-	}
-
 	return defaultBatchPushButton? defaultBatchPushButton: QMessageBox::defaultButton();
 }
 
@@ -130,12 +113,8 @@
 				StandardButtons buttons, StandardButton defaultButton, StandardButton defaultBatchButton)
 {
 	if (ScCore->usingGUI())
-	{
 		return QMessageBox::information(parent, title, text, buttons, defaultButton);
-	}
-
 	std::cerr << title.toLocal8Bit().data() << " " << text.toLocal8Bit().data() << std::endl;
-
 	return findDefaultButton(buttons, defaultButton, defaultBatchButton);
 }
 
@@ -143,12 +122,8 @@
 				StandardButtons buttons, StandardButton defaultButton, StandardButton defaultBatchButton)
 {
 	if (ScCore->usingGUI())
-	{
 		return QMessageBox::question(parent, title, text, buttons, defaultButton);
-	}
-
 	std::cerr << title.toLocal8Bit().data() << " " << text.toLocal8Bit().data() << std::endl;
-
 	return findDefaultButton(buttons, defaultButton, defaultBatchButton);
 }
 
@@ -156,12 +131,8 @@
 				StandardButtons buttons, StandardButton defaultButton, StandardButton defaultBatchButton)
 {
 	if (ScCore->usingGUI())
-	{
 		return QMessageBox::warning(parent, title, text, buttons, defaultButton);
-	}
-
 	std::cerr << title.toLocal8Bit().data() << " " << text.toLocal8Bit().data() << std::endl;
-
 	return findDefaultButton(buttons, defaultButton, defaultBatchButton);
 }
 
@@ -169,12 +140,8 @@
 				StandardButtons buttons, StandardButton defaultButton, StandardButton defaultBatchButton)
 {
 	if (ScCore->usingGUI())
-	{
 		return QMessageBox::critical(parent, title, text, buttons, defaultButton);
-	}
-
 	std::cerr << title.toLocal8Bit().data() << " " << text.toLocal8Bit().data() << std::endl;
-
 	return findDefaultButton(buttons, defaultButton, defaultBatchButton);
 }
 
@@ -185,7 +152,6 @@
 		QMessageBox::about(parent, title, text);
 		return;
 	}
-
 	std::cerr << title.toLocal8Bit().data() << " " << text.toLocal8Bit().data() << std::endl;
 }
 
@@ -196,6 +162,5 @@
 		QMessageBox::aboutQt(parent, title);
 		return;
 	}
-
 	std::cerr << title.toLocal8Bit().data() << std::endl;
 }

Modified: trunk/Scribus/scribus/ui/scmessagebox.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19937&path=/trunk/Scribus/scribus/ui/scmessagebox.h
==============================================================================
--- trunk/Scribus/scribus/ui/scmessagebox.h (original)
+++ trunk/Scribus/scribus/ui/scmessagebox.h Tue Mar 17 18:49:38 2015
@@ -41,25 +41,19 @@
 class SCRIBUS_API ScMessageBox : public QMessageBox
 {
 	Q_OBJECT
+
 public:
 	// Property-based API
-
 	ScMessageBox(QWidget *parent = 0);
-
 	ScMessageBox(QMessageBox::Icon icon, const QString &title, const QString &text,
 		QMessageBox::StandardButtons buttons = QMessageBox::NoButton, QWidget *parent = 0,
 		Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
-
 	int exec();
-
 	QAbstractButton *clickedButton() const;
-
 	void setDefaultBatchButton(QPushButton *button);
-
 	void setDefaultBatchButton(StandardButton button);
 
 	// Static function API
-
 	static QMessageBox::StandardButton information(QWidget *parent, const QString &title, const QString &text,
 			StandardButtons buttons = Ok, StandardButton defaultButton = NoButton, StandardButton defaultBatchButton = NoButton);
 
@@ -77,17 +71,14 @@
 
 private:
 	// Saved fields for the property-based API
-
 	QString messageTitle;
 	QPushButton *defaultBatchPushButton;
 	StandardButton defaultBatchStandardButton;
 
 	// Initialize private variables
-
 	void initScMessageBox(void);
 
 	// Find the appropriate default button
-
 	static QMessageBox::StandardButton findDefaultButton(QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton, StandardButton defaultBatchButton);
 };
 




More information about the scribus-commit mailing list