Skip to content

Commit

Permalink
Merge pull request #44 from yodalee/issue38-removeQ3inRescode
Browse files Browse the repository at this point in the history
Close #38 remove Q3 in qucs-rescode
  • Loading branch information
guitorri committed Sep 15, 2014
2 parents 08f4c7d + 99beeb3 commit f5c60ba
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 87 deletions.
26 changes: 11 additions & 15 deletions qucs/qucs-rescodes/helpdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ email : sudhakar.m.kumar@gmail.com

#include "helpdialog.h"

#include <QLayout>
#include <Q3HBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include <Q3TextEdit>
//Added by qt3to4:
#include <Q3VBoxLayout>
#include <QTextEdit>


HelpDialog::HelpDialog(QWidget *parent)
HelpDialog::HelpDialog(QWidget *parent)
: QDialog(parent, 0, false, Qt::WDestructiveClose)
{
setCaption("Resistance color codes help");
Expand All @@ -48,26 +46,24 @@ email : sudhakar.m.kumar@gmail.com


// -------- create dialog widgets ------------
resize(250, 230);
resize(300, 200);

vLayout = new Q3VBoxLayout(this);
vLayout = new QVBoxLayout(this);

Text = new Q3TextEdit(s, QString::null, this);
Text = new QTextEdit(s, this);
Text->setTextFormat(Qt::PlainText);
Text->setReadOnly(true);
Text->setMinimumSize(200,200);
vLayout->addWidget(Text);

Q3HBox *h = new Q3HBox(this);
vLayout->addWidget(h);
QHBoxLayout *h = new QHBoxLayout;
vLayout->addLayout(h);

h->setStretchFactor(new QWidget(h),5); // stretchable placeholder
QPushButton *ButtonClose = new QPushButton(tr("Close"), this);
h->addWidget(ButtonClose);

QPushButton *ButtonClose = new QPushButton(tr("Close"), h);
connect(ButtonClose, SIGNAL(clicked()), SLOT(slotClose()));
ButtonClose->setFocus();

h->setStretchFactor(new QWidget(h),5); // stretchable placeholder
}

HelpDialog::~HelpDialog()
Expand Down
10 changes: 4 additions & 6 deletions qucs/qucs-rescodes/helpdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
#define HELPDIALOG_H

#include <QDialog>
//Added by qt3to4:
#include <Q3VBoxLayout>
#include <QVBoxLayout>

class Q3TextEdit;
class Q3VBoxLayout;
class QTextEdit;

/**
*@author Michael Margraf
Expand All @@ -39,8 +37,8 @@ private slots:
void slotClose();

private:
Q3VBoxLayout *vLayout;
Q3TextEdit *Text;
QVBoxLayout *vLayout;
QTextEdit *Text;
};

#endif
86 changes: 47 additions & 39 deletions qucs/qucs-rescodes/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,33 @@
* *
***************************************************************************/

#include "classproto.h"
#include "myresistancebox.h"
#include "mycolorbox.h"
#include "qresistor.h"
#include "mywidget.h"
#include "helpdialog.h"

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef QUCS_RESCODES_MAIN_CPP
#define QUCS_RESCODES_MAIN_CPP
#include <QApplication>
#include <Q3HBox>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QPushButton>
#include <QFont>
#include <QLayout>
#include <Q3Grid>
#include <QPixmap>
#include <QString>
#include <QImage>
#include <QMenu>
#include <QMenuBar>
#include <Q3PopupMenu>
#include <QAction>
#include <QMessageBox>
#include <QLayout>
#include <QClipboard>
//Added by qt3to4:
#include <Q3GridLayout>

#include <vector>
#include <string>

#include "classproto.h"
#include "myresistancebox.h"
#include "mycolorbox.h"
#include "qresistor.h"
#include "mywidget.h"
#include "helpdialog.h"
//------------------------class member declarations for MyWidget---------------------------------//

MyWidget::MyWidget( QWidget *parent, const char *name )
Expand All @@ -59,20 +55,33 @@ MyWidget::MyWidget( QWidget *parent, const char *name )
#endif

// -------- create menubar -------------------
Q3PopupMenu *fileMenu = new Q3PopupMenu();
fileMenu->insertItem(tr("E&xit"), qApp, SLOT(quit()), Qt::CTRL+Qt::Key_Q);
QAction *fileExit = new QAction(tr("E&xit"), this);
fileExit->setShortcut(Qt::CTRL+Qt::Key_Q);
connect(fileExit, SIGNAL(activated()), qApp, SLOT(quit()));

QMenu *fileMenu = new QMenu(tr("&File"));
fileMenu->addAction(fileExit);

Q3PopupMenu *helpMenu = new Q3PopupMenu();
helpMenu->insertItem(tr("Help..."), this, SLOT(slotHelpIntro()), Qt::Key_F1);
helpMenu->insertSeparator();
helpMenu->insertItem(
tr("&About ResistorCodes..."), this, SLOT(slotHelpAbout()), 0);
helpMenu->insertItem(tr("About Qt..."), this, SLOT(slotHelpAboutQt()), 0);
QAction *help = new QAction(tr("Help..."), this);
help->setShortcut(Qt::Key_F1);
connect(help, SIGNAL(activated()), this, SLOT(slotHelpIntro()));

QMenuBar *bar = new QMenuBar(this);
bar->insertItem(tr("&File"), fileMenu);
bar->insertSeparator ();
bar->insertItem(tr("&Help"), helpMenu);
QAction *about = new QAction(tr("&About ResistorCodes..."), this);
connect(about, SIGNAL(activated()), this, SLOT(slotHelpAbout()));

QAction *aboutQt = new QAction(tr("&About Qt..."), this);
connect(aboutQt, SIGNAL(activated()), this, SLOT(slotHelpAboutQt()));

QMenu *helpMenu = new QMenu(tr("&Help"));
helpMenu->addAction(help);
helpMenu->addAction(about);
helpMenu->addSeparator();
helpMenu->addAction(aboutQt);

QMenuBar *menuBar = new QMenuBar(this);
menuBar->addMenu(fileMenu);
menuBar->insertSeparator();
menuBar->addMenu(helpMenu);

res= new QResistor();
//--------------------resistance displayin ui ---------------------------------//
Expand All @@ -87,31 +96,32 @@ MyWidget::MyWidget( QWidget *parent, const char *name )
//-------------------paste the configuration to clipboard--------------------------------------------//
connect(res, SIGNAL(valueModified(QResistor*)),this,SLOT(slotConfiguration()));
//-------------------switching buttons ui--------------------------------------//
Q3HBox *buttonBox = new Q3HBox(this,"buttonBox");

QPushButton *calcColor = new QPushButton(QPixmap(":/bitmaps/next.png")," To Colors", buttonBox, "calcColor" );
QPushButton *calcColor = new QPushButton(QPixmap(":/bitmaps/next.png")," To Colors", this, "calcColor" );
connect(calcColor, SIGNAL(clicked()),this,SLOT(setResistanceValue()));

QPushButton *calcResistance = new QPushButton(QPixmap(":/bitmaps/previous.png")," To Resistance", buttonBox, "calcResistance" );
QPushButton *calcResistance = new QPushButton(QPixmap(":/bitmaps/previous.png")," To Resistance", this, "calcResistance" );
connect(calcResistance, SIGNAL(clicked()),this,SLOT(setColorValue()));

QPushButton *quit = new QPushButton( "Quit", buttonBox, "quit" );
// quit->setFont( QFont( "Times", 18, QFont::Bold ) );
QPushButton *quit = new QPushButton( "Quit", this, "quit" );
connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) );

QHBoxLayout *buttonBox = new QHBoxLayout;
buttonBox->addWidget(calcColor);
buttonBox->addWidget(calcResistance);
buttonBox->addWidget(quit);

//--------------------packing all of them together---------------------------------------//
Q3GridLayout *grid = new Q3GridLayout( this, 4, 1, 10 );
//3x1, 10 pixel border
QGridLayout *grid = new QGridLayout(this);
grid->setMargin(10);

#ifndef __APPLE__
QWidget *Space = new QWidget(this); // reserve space for menubar
Space->setFixedSize(1, bar->height());
Space->setFixedSize(1, menuBar->height());
grid->addWidget(Space, 0,0);
#endif

grid->addWidget( resBox, 1, 0 );
grid->addWidget( buttonBox, 2, 0 );
grid->addLayout( buttonBox, 2, 0 );
grid->addWidget( colorBox, 3, 0 );

}
Expand Down Expand Up @@ -176,8 +186,6 @@ int main( int argc, char **argv )
QApplication a( argc, argv );

MyWidget w;
// w.setGeometry( 100, 100, 500, 355 );
// w.setFixedSize(500, 355 );
a.setMainWidget( &w );
w.show();
return a.exec();
Expand Down
20 changes: 13 additions & 7 deletions qucs/qucs-rescodes/mycolorbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
* *
***************************************************************************/


#include "mycolorbox.h"
#include "qresistor.h"

#include <QComboBox>
#include <Q3GroupBox>
#include <QGroupBox>
#include <QHBoxLayout>

#include <vector>
#include <map>
#include <string>
#include "mycolorbox.h"
#include "qresistor.h"

#include <iostream>

MyColorBox::MyColorBox( QWidget *parent, const char *name )
: Q3GroupBox(5,Qt::Horizontal,"Colour Codes" ,parent, name )
: QGroupBox("Colour Codes" ,parent)
{
//--------------------color code displaying ui-------------------------------------//
QStringList colors;
Expand All @@ -54,7 +53,14 @@ MyColorBox::MyColorBox( QWidget *parent, const char *name )

colorCode[4]=new QComboBox (this);
colorCode[4]->insertStringList(tolColors);

QHBoxLayout *hbox = new QHBoxLayout;
for (int i = 0; i < 5; ++i) {
hbox->addWidget(colorCode[i]);
}
this->setLayout(hbox);
}

map<string,int> MyColorBox::constructRevTolindexMap()
{
map<string,int> revTolindexMap;
Expand Down
7 changes: 3 additions & 4 deletions qucs/qucs-rescodes/mycolorbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@
* *
***************************************************************************/



#include <Q3GroupBox>
#include <string>
#include <map>
#include <vector>
using namespace std;

#include <QGroupBox>

class QResistor;
class QComboBox;

class MyColorBox: public Q3GroupBox
class MyColorBox: public QGroupBox
{
Q_OBJECT

Expand Down
37 changes: 26 additions & 11 deletions qucs/qucs-rescodes/myresistancebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,33 @@
* *
***************************************************************************/


#include "myresistancebox.h"
#include "qresistor.h"

#include <QValidator>
#include <QLabel>
#include <QComboBox>
#include <QLineEdit>
#include <Q3GroupBox>
#include "myresistancebox.h"
#include "qresistor.h"
#include <math.h>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>

#include <cmath>

MyResistanceBox::MyResistanceBox( QWidget *parent, const char *name )
: Q3GroupBox(3,Qt::Horizontal,"Resistance Values" ,parent, name )
//: QGroupBox(3,Qt::Horizontal,"Resistance Values" ,parent, name )
: QGroupBox("Resistance Values", parent)
{
//--------------------resistance displaying ui ---------------------------------//
resValueEdit = new QLineEdit(this);

resValueEdit = new QLineEdit (this, "resValueEdit");
const QDoubleValidator *validator = new QDoubleValidator (resValueEdit,"validator");
resValueEdit->setValidator(validator);
resValueEdit->setMaxLength(6);
resUnit = new QComboBox(this, "resUnit");
tolerance = new QComboBox(this, "tolerance");
stdRes = new QLabel("Closest standard resistance : 0 Ohms \n Tolerance : 20%",this, "stdRes");

resUnit = new QComboBox(this);
tolerance = new QComboBox(this);
stdRes = new QLabel("Closest standard resistance : 0 Ohms \n Tolerance : 20%");

QStringList units;
units << "Ohms" << "kOhms" << "MOhms";
Expand All @@ -46,11 +50,22 @@ MyResistanceBox::MyResistanceBox( QWidget *parent, const char *name )
QStringList tols;
tols << "20%" << "10%" << "5%" << "2%" << "1%" << "0.5%" << "0.25%" << "0.1%" << "0.05%";
tolerance ->insertStringList(tols);

QHBoxLayout *hbox = new QHBoxLayout;
hbox->addWidget(resValueEdit);
hbox->addWidget(resUnit);
hbox->addWidget(tolerance);

QVBoxLayout *vbox = new QVBoxLayout;
vbox->addLayout(hbox);
vbox->addWidget(stdRes);

this->setLayout(vbox);
}

void MyResistanceBox::update(QResistor *res)
{
stdRes->setText("Closest standard resistance : "+QString::number(res->getResistance())+QString(QChar(res->getModifier()))+"Ohms \n Tolerance : "+QString::number(res->getTolerance())+"%");
stdRes->setText("Closest standard resistance : "+ QString::number(res->getResistance())+QString(QChar(res->getModifier()))+"Ohms \n Tolerance : "+QString::number(res->getTolerance())+"%");
}

float MyResistanceBox::enteredValue()
Expand Down
7 changes: 2 additions & 5 deletions qucs/qucs-rescodes/myresistancebox.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@
* *
***************************************************************************/



#include <QLineEdit>
#include <Q3GroupBox>
//Added by qt3to4:
#include <QGroupBox>
#include <QLabel>
class QLabel;
class QResistor;
class QString;
class QComboBox;
class MyResistanceBox: public Q3GroupBox
class MyResistanceBox: public QGroupBox
{
Q_OBJECT
QString closestRes;
Expand Down

0 comments on commit f5c60ba

Please sign in to comment.