FileActionDialog now supports variable modal buttons
FossilOrigin-Name: d80b84c6b58b7daf71174d32a8c33cab0e2aabac
This commit is contained in:
		| @@ -1,9 +1,11 @@ | ||||
| #include <QCheckBox> | ||||
| #include "FileActionDialog.h" | ||||
| #include "ui_FileActionDialog.h" | ||||
|  | ||||
| FileActionDialog::FileActionDialog(QWidget *parent, const QString &title, const QString &message, const QStringList &files, const QString &checkBoxText, bool *checkBoxResult) : | ||||
| FileActionDialog::FileActionDialog(QWidget *parent, const QString &title, const QString &message, const QStringList &listData, const QString &checkBoxText, bool *checkBoxResult) : | ||||
| 	QDialog(parent, Qt::Sheet), | ||||
|     ui(new Ui::FileActionDialog) | ||||
| 	ui(new Ui::FileActionDialog), | ||||
| 	clickedButton(QDialogButtonBox::NoButton) | ||||
| { | ||||
|     ui->setupUi(this); | ||||
| 	setWindowTitle(title); | ||||
| @@ -20,9 +22,8 @@ FileActionDialog::FileActionDialog(QWidget *parent, const QString &title, const | ||||
| 		ui->verticalLayout->insertWidget(2, checkBox); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	for(QStringList::const_iterator it=files.begin(); it!=files.end(); ++it) | ||||
| 		itemModel.appendRow(new QStandardItem(*it)); | ||||
| 	foreach(const QString &s, listData) | ||||
| 		itemModel.appendRow(new QStandardItem(s)); | ||||
| } | ||||
|  | ||||
| FileActionDialog::~FileActionDialog() | ||||
| @@ -30,9 +31,9 @@ FileActionDialog::~FileActionDialog() | ||||
| 	delete ui; | ||||
| } | ||||
|  | ||||
| bool FileActionDialog::run(QWidget *parent, const QString &title, const QString &message, const QStringList &files, const QString &checkBoxText, bool *checkBoxResult) | ||||
| bool FileActionDialog::run(QWidget *parent, const QString &title, const QString &message, const QStringList &listData, const QString &checkBoxText, bool *checkBoxResult) | ||||
| { | ||||
| 	FileActionDialog dlg(parent, title, message, files, checkBoxText, checkBoxResult); | ||||
| 	FileActionDialog dlg(parent, title, message, listData, checkBoxText, checkBoxResult); | ||||
| 	int res = dlg.exec(); | ||||
|  | ||||
| 	if(!checkBoxText.isEmpty() && checkBoxResult && dlg.checkBox) | ||||
| @@ -40,3 +41,19 @@ bool FileActionDialog::run(QWidget *parent, const QString &title, const QString | ||||
|  | ||||
| 	return res == QDialog::Accepted; | ||||
| } | ||||
|  | ||||
| QDialogButtonBox::StandardButton FileActionDialog::runStandardButtons(QWidget *parent, StandardButtons buttons, const QString &title, const QString &message, const QStringList &listData) | ||||
| { | ||||
| 	FileActionDialog dlg(parent, title, message, listData); | ||||
| 	dlg.ui->buttonBox->setStandardButtons(buttons); | ||||
|  | ||||
| 	dlg.exec(); | ||||
| 	return dlg.clickedButton; | ||||
| } | ||||
|  | ||||
| void FileActionDialog::on_buttonBox_clicked(QAbstractButton *button) | ||||
| { | ||||
| 	// Retrieve the flag corresponding to the standard clicked | ||||
| 	clickedButton = ui->buttonBox->standardButton(button); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
|  | ||||
| #include <QDialog> | ||||
| #include <QStandardItemModel> | ||||
| #include <QCheckBox> | ||||
| #include <QDialogButtonBox> | ||||
|  | ||||
| namespace Ui { | ||||
|     class FileActionDialog; | ||||
| @@ -12,18 +12,27 @@ namespace Ui { | ||||
| class FileActionDialog : public QDialog | ||||
| { | ||||
|     Q_OBJECT | ||||
|  | ||||
| public: | ||||
| 	explicit FileActionDialog(QWidget *parent, const QString &title, const QString &message, const QStringList &files, const QString &checkBoxText=QString(), bool *checkBoxResult=0); | ||||
| 	explicit FileActionDialog(QWidget *parent, const QString &title, const QString &message, const QStringList &listData, const QString &checkBoxText=QString(), bool *checkBoxResult=0); | ||||
|     ~FileActionDialog(); | ||||
|  | ||||
| 	static bool run(QWidget *parent, const QString &title, const QString &message, const QStringList &files, const QString &checkBoxText=QString(), bool *checkBoxResult=0); | ||||
| 	static bool run(QWidget *parent, const QString &title, const QString &message, const QStringList &listData, const QString &checkBoxText=QString(), bool *checkBoxResult=0); | ||||
|  | ||||
| 	typedef QDialogButtonBox::StandardButton StandardButton; | ||||
| 	typedef QDialogButtonBox::StandardButtons StandardButtons; | ||||
|  | ||||
| 	static StandardButton runStandardButtons(QWidget *parent, StandardButtons, const QString &title, const QString &message, const QStringList &listData); | ||||
|  | ||||
|  | ||||
| private slots: | ||||
| 	void on_buttonBox_clicked(QAbstractButton *button); | ||||
|  | ||||
| private: | ||||
|     Ui::FileActionDialog *ui; | ||||
| 	QStandardItemModel	itemModel; | ||||
| 	QCheckBox *checkBox; | ||||
| 	class QCheckBox *checkBox; | ||||
| 	bool *checkBoxResult; | ||||
| 	StandardButton clickedButton; | ||||
| }; | ||||
|  | ||||
| #endif // FILEACTIONDIALOG_H | ||||
|   | ||||
| @@ -48,9 +48,6 @@ | ||||
|    </item> | ||||
|    <item> | ||||
|     <widget class="QDialogButtonBox" name="buttonBox"> | ||||
|      <property name="orientation"> | ||||
|       <enum>Qt::Horizontal</enum> | ||||
|      </property> | ||||
|      <property name="standardButtons"> | ||||
|       <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||||
|      </property> | ||||
|   | ||||
							
								
								
									
										16
									
								
								manifest
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								manifest
									
									
									
									
									
								
							| @@ -1,11 +1,11 @@ | ||||
| C Removed\sclone\srepository\scommand\s(for\snow) | ||||
| D 2011-08-06T08:52:52.947 | ||||
| C FileActionDialog\snow\ssupports\svariable\smodal\sbuttons\n | ||||
| D 2011-08-06T15:34:40.595 | ||||
| F CommitDialog.cpp a1fcdc94933f4e1a144224c7c70f1e067d3ee31e | ||||
| F CommitDialog.h 0550b1b652924ae54b6f6c9274cad2d4c491808a | ||||
| F CommitDialog.ui 5067623f6af6f5a42c87df903278e383e945e154 | ||||
| F FileActionDialog.cpp ed26a6f9dd1debd6926d4bbff7ba18acb63dacc0 | ||||
| F FileActionDialog.h 873a9f720753a37d67071563ed7954f91b0d4699 | ||||
| F FileActionDialog.ui 3d4f7ad0665d51dc3ba405edbc472dd317138c5f | ||||
| F FileActionDialog.cpp 629f29f676f3e547965f350fb9a4ee5797cc3e0b | ||||
| F FileActionDialog.h 15db1650b3a13d70bc338371e4c033c66e3b79ce | ||||
| F FileActionDialog.ui c63644428579741aeb5fa052e237ba799ced9ad7 | ||||
| F MainWindow.cpp 96ce6b4bb5ee66f04a43e2171b20e8ee510a5ac7 | ||||
| F MainWindow.h 8a23caf1a70d41fe60a25894649a88b1efb851ba | ||||
| F MainWindow.ui 9f901c1f06b24df3cbd36d5349ffe0d82896c05b | ||||
| @@ -173,7 +173,7 @@ F icons/fuel.icns 81e535004b62db801a02f3e15d0a33afc9d4070b | ||||
| F icons/fuel.ico eb529ab3332a17b9302ef3e851db5b9ebce2a038 | ||||
| F main.cpp aed85ed9766ddb8685e300e8ca4a0dc193ae2586 | ||||
| F resources.qrc e98383ed205f4e37100c60057e0129c3b86dea53 | ||||
| P 797c2e6a66cb336351d569ab80737a7e491403f0 | ||||
| R b71e721aa96a201b7c70272083f26743 | ||||
| P 665b2ad1b609530a9c2c2815e143213e5e691100 | ||||
| R 1f233c6d016ce42191b217639282c217 | ||||
| U kostas | ||||
| Z 5723c9d6f3d128a270ccbc410612a6ae | ||||
| Z f4122d426b89a67b7273148c8690abf1 | ||||
|   | ||||
| @@ -1 +1 @@ | ||||
| 665b2ad1b609530a9c2c2815e143213e5e691100 | ||||
| d80b84c6b58b7daf71174d32a8c33cab0e2aabac | ||||
		Reference in New Issue
	
	Block a user