-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '731db4f685513712036cbd81d66bab2896da23b2'
- Loading branch information
Showing
4 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include "dialogVariableToSum.h" | ||
|
||
DialogVariableToSum::DialogVariableToSum(QList<QString> variableList) | ||
: variableList(variableList) | ||
{ | ||
setWindowTitle("Choose variable to sum"); | ||
this->resize(400, 200); | ||
QVBoxLayout *mainLayout = new QVBoxLayout(); | ||
QVBoxLayout *variableLayout = new QVBoxLayout; | ||
QHBoxLayout *layoutOk = new QHBoxLayout; | ||
QDialogButtonBox buttonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); | ||
|
||
layoutOk->addWidget(&buttonBox); | ||
for (int i = 0; i<variableList.size(); i++) | ||
{ | ||
QCheckBox* checkbox = new QCheckBox(variableList[i], this); | ||
checkList.append(checkbox); | ||
variableLayout->addWidget(checkbox); | ||
} | ||
|
||
mainLayout->addLayout(variableLayout); | ||
mainLayout->addLayout(layoutOk); | ||
setLayout(mainLayout); | ||
|
||
connect(&buttonBox, &QDialogButtonBox::accepted, [=](){ this->done(true); }); | ||
connect(&buttonBox, &QDialogButtonBox::rejected, [=](){ this->done(false); }); | ||
|
||
show(); | ||
exec(); | ||
|
||
} | ||
|
||
void DialogVariableToSum::done(bool res) | ||
{ | ||
if (res) | ||
{ | ||
foreach (QCheckBox *checkBox, checkList) | ||
{ | ||
if (checkBox->isChecked()) | ||
{ | ||
selectedVariable.append(checkBox->text()); | ||
} | ||
} | ||
QDialog::done(QDialog::Accepted); | ||
return; | ||
} | ||
else // cancel, close or exc was pressed | ||
{ | ||
QDialog::done(QDialog::Rejected); | ||
return; | ||
} | ||
} | ||
|
||
QList<QString> DialogVariableToSum::getSelectedVariable() | ||
{ | ||
return selectedVariable; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef DIALOGVARIABLETOSUM_H | ||
#define DIALOGVARIABLETOSUM_H | ||
|
||
#include <QtWidgets> | ||
|
||
class DialogVariableToSum : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
private: | ||
QList<QString> variableList; | ||
QList<QString> selectedVariable; | ||
QList<QCheckBox*> checkList; | ||
|
||
public: | ||
DialogVariableToSum(QList<QString> variableList); | ||
QList<QString> getSelectedVariable(); | ||
void done(bool res); | ||
}; | ||
|
||
#endif // DIALOGVARIABLETOSUM_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters