Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10769 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Jhansi Reddy Remala
committed
Dec 18, 2011
1 parent
524081e
commit 072b06b
Showing
3 changed files
with
264 additions
and
0 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,151 @@ | ||
#include "CustomDialog.h" | ||
|
||
CustomDialog::CustomDialog(QWidget* parent):QDialog(parent) | ||
{ | ||
groups.clear(); | ||
group.optLabels.clear(); | ||
group.radioButtons.clear(); | ||
button_box = new QDialogButtonBox(Qt::Vertical); | ||
button_box1 = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel,Qt::Horizontal); | ||
|
||
|
||
connect(button_box1,SIGNAL(accepted()),this,SLOT(accept())); | ||
connect(button_box1,SIGNAL(rejected()),this,SLOT(reject())); | ||
|
||
values.clear(); | ||
|
||
} | ||
|
||
void CustomDialog::Initialize() | ||
{ | ||
groups.clear(); | ||
group.optLabels.clear(); | ||
group.radioButtons.clear(); | ||
} | ||
|
||
void CustomDialog::addGroup(QString grpname,QString checkName,int numOptions) | ||
{ | ||
group.CheckBox = new QCheckBox(grpname); | ||
group.button = new QPushButton(checkName); | ||
group.group_widget = new QWidget(); | ||
group.num_options=numOptions; | ||
|
||
connect(group.button,SIGNAL(toggled(bool)),group.group_widget,SLOT(setVisible(bool))); | ||
|
||
groups.push_back(group); | ||
} | ||
|
||
void CustomDialog::addSubGroup(QString optionLabel,int indx) | ||
{ | ||
//group=groups[groups.size()-1]; | ||
//group=groups.at(indx); | ||
qDebug()<<"size of groups "<<groups.size()<<"\n"; | ||
groups[indx].optLabels.push_back(optionLabel); | ||
QRadioButton* button1 = new QRadioButton(optionLabel); | ||
groups[indx].radioButtons.push_back(button1); | ||
|
||
} | ||
|
||
|
||
|
||
void CustomDialog::add(int indx) | ||
{ | ||
//group=groups[groups.size()-1]; | ||
qDebug()<<"size of groups "<<groups.size()<<"\n"; | ||
//group=groups.at(indx); | ||
if(groups[indx].num_options==groups[indx].radioButtons.size()) | ||
{ | ||
|
||
QMessageBox::about(this,"hi","entered"); | ||
groups[indx].grp_hlayout = new QHBoxLayout; | ||
groups[indx].grp_vlayout = new QVBoxLayout; | ||
groups[indx].grp_hlayout->addWidget(groups[indx].CheckBox); | ||
//groups[indx].grp_hlayout->addWidget(groups[indx].button); | ||
groups[indx].button->setCheckable(true); | ||
groups[indx].button->setAutoDefault(false); | ||
button_box->addButton(groups[indx].button,QDialogButtonBox::AcceptRole); | ||
|
||
groups[indx].grp_vlayout->addLayout(groups[indx].grp_hlayout); | ||
|
||
for(int i=0;i<groups[indx].radioButtons.size();i++) | ||
{ | ||
groups[indx].grp_vlayout->addWidget(groups[indx].radioButtons[i]); | ||
} | ||
|
||
groups[indx].group_widget->setLayout(groups[indx].grp_vlayout); | ||
} | ||
} | ||
|
||
void CustomDialog::open() | ||
{ | ||
QGridLayout* layout = new QGridLayout; | ||
layout->setSizeConstraint(QLayout::SetFixedSize); | ||
|
||
qDebug()<<"size of groups "<<groups.size()<<"\n"; | ||
|
||
layout->addWidget(button_box,0,1); | ||
//groups[0].group_widget->show(); | ||
|
||
for(int i=0;i<groups.size();i++) | ||
groups[i].group_widget->hide(); | ||
int i=0; | ||
for(i;i<groups.size();i++) | ||
layout->addWidget(groups[i].group_widget,i+2,0,i+3,groups[i].radioButtons.size()); | ||
setLayout(layout); | ||
|
||
layout->addWidget(button_box1,i+3,1); | ||
|
||
|
||
setWindowTitle(tr("Styles")); | ||
|
||
} | ||
|
||
void CustomDialog::getValue(QString grpName,int &property) | ||
{ | ||
for(int i=0;i<groups.size();i++) | ||
{ | ||
if(grpName==groups[i].CheckBox->text()) | ||
{ | ||
for(int j=0;j<groups[i].radioButtons.size();j++) | ||
{ | ||
if(groups[0].radioButtons[j]->isChecked()) | ||
{ | ||
QMessageBox::about(this,"hi",groups[0].radioButtons[j]->text()); | ||
property=j; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
/*void CustomDialog::accept() | ||
{ | ||
values.clear(); | ||
for(int i=0;i<groups.size();i++) | ||
{ | ||
for(int j=0;j<groups[i].radioButtons.size();j++) | ||
{ | ||
if(groups[0].radioButtons[j]->isChecked()) | ||
{ | ||
values.push_back(j); | ||
} | ||
} | ||
} | ||
QDialog::close(); | ||
} | ||
void CustomDialog::reject() | ||
{ | ||
values.clear(); | ||
}*/ | ||
|
||
|
||
void CustomDialog::changeEvent(QEvent *event) | ||
{ | ||
if(event->type()==QEvent::OkRequest) | ||
QMessageBox::about(this,"hi","event accepted"); | ||
|
||
} | ||
|
||
|
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,57 @@ | ||
#ifndef CUSTOMDIALOG_H | ||
#define CUSTOMDIALOG_H | ||
|
||
#include "basic.h" | ||
|
||
class CustomDialog: public QDialog | ||
{ | ||
Q_OBJECT; | ||
|
||
public: | ||
struct Group | ||
{ | ||
QCheckBox* CheckBox; | ||
QPushButton* button; | ||
QVector<QRadioButton*> radioButtons; | ||
QVector<QString> optLabels; | ||
int num_options; | ||
QHBoxLayout* grp_hlayout; | ||
QVBoxLayout* grp_vlayout; | ||
QWidget* group_widget; | ||
|
||
}; | ||
|
||
CustomDialog(QWidget* parent=0); | ||
void addGroup(QString grpName,QString checkName,int numOptions); | ||
void addSubGroup(QString optionLabel,int indx); | ||
void Initialize(); | ||
void open(); | ||
void add(int indx); | ||
void getValue(QString grpName,int &property); | ||
|
||
QVector<int> values; | ||
|
||
/*public slots: | ||
virtual void accept(); | ||
virtual void reject();*/ | ||
|
||
virtual void changeEvent(QEvent *event); | ||
|
||
|
||
QVector<Group> groups; | ||
private: | ||
|
||
|
||
void addGroups(); | ||
|
||
|
||
|
||
|
||
Group group; | ||
|
||
QGridLayout* layout; | ||
QDialogButtonBox *button_box,*button_box1; | ||
|
||
}; | ||
|
||
#endif // CUSTOMDIALOG_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#ifndef BASIC_H | ||
#define BASIC_H | ||
|
||
#include <vector> | ||
#include <math.h> | ||
|
||
#include <QtGui> | ||
#include <QtGui/QWidget> | ||
#include <QtGui/QMainWindow> | ||
#include <QtGui/QAction> | ||
#include <QtGui/QLabel> | ||
#include <QtGui/QPushButton> | ||
#include <QtGui/QToolButton> | ||
#include <QtGui/QToolBar> | ||
#include <QtGui/QPainter> | ||
#include <QtGui/QPixmap> | ||
#include <QtGui/QImage> | ||
#include <QtCore/QPoint> | ||
#include <QtGui/QColor> | ||
#include <QtGui/QPen> | ||
#include <QtGui/QBrush> | ||
#include <QtCore/QRect> | ||
#include <QtCore/QSize> | ||
#include <QtGui/QLinearGradient> | ||
#include <QtGui/QLayout> | ||
#include <QtGui/QVBoxLayout> | ||
#include <QtGui/QHBoxLayout> | ||
#include <QtCore/QDebug> | ||
#include <QtGui/QFrame> | ||
#include <QtGui/QGraphicsScene> | ||
#include <QtGui/QGraphicsView> | ||
#include <QtGui/QGraphicsSceneMouseEvent> | ||
#include <QtGui/QGraphicsLineItem> | ||
#include <QtGui/QGraphicsItem> | ||
#include <QtGui/QCursor> | ||
#include <QtGui/QPainterPath> | ||
#include <QtCore/QVector> | ||
#include <QtCore/QFile> | ||
#include <QtCore/QStringList> | ||
#include <QtCore/QString> | ||
#include <QtCore/QTextStream> | ||
#include <QtGui/QIcon> | ||
#include <QtGui/QMenu> | ||
#include <QtGui/QButtonGroup> | ||
#include <QtGui/QMessageBox> | ||
#include <QtGui/QFileDialog> | ||
#include <QtGui/QCheckBox> | ||
#include <QtGui/QKeyEvent> | ||
#include <QtCore/QRectF> | ||
#include <QtGui/QTextCursor> | ||
#include <QtGui/QDialog> | ||
#include <QtGui/QColorDialog> | ||
#include <QtGui/QDialogButtonBox> | ||
|
||
|
||
#endif // BASIC_H |