Skip to content

Commit

Permalink
Podstawowa wersja aplikacji Qt5 Adresy
Browse files Browse the repository at this point in the history
  • Loading branch information
xinulsw committed Jan 11, 2015
1 parent 3689834 commit 409b20f
Show file tree
Hide file tree
Showing 10 changed files with 911 additions and 37 deletions.
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
#html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = 'Materiały CG IT'
htmlhelp_basename = u'Materiały CG IT'

# -- Options for LaTeX output ---------------------------------------------

Expand Down Expand Up @@ -250,7 +250,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'materiayecgit', u'Materiały eCG IT Documentation',
('index', 'materialyecgit', u'Materiały eCG IT Documentation',
[u'Robert Bednarz'], 1)
]

Expand All @@ -264,8 +264,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'MateriayeCGIT', u'Materiały eCG IT Documentation',
u'Robert Bednarz', 'MateriayeCGIT', 'One line description of project.',
('index', 'MaterialyeCGIT', u'Materiały eCG IT Documentation',
u'Robert Bednarz', 'MaterialyeCGIT', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
4 changes: 2 additions & 2 deletions docs/qt/adresy/adresy02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ adresy::adresy(QWidget *parent) :
koniecBtn = ui->koniecBtn;
koniecBtn->setEnabled(true);

setWindowTitle(trUtf8("Prosta książka adresowa"));

connect(dodajBtn, SIGNAL(clicked()), this, SLOT(dodajKontakt()));
connect(koniecBtn,SIGNAL(clicked()),this, SLOT(koniec()));

setWindowTitle(trUtf8("Prosta książka adresowa"));
}

adresy::~adresy()
Expand Down
4 changes: 2 additions & 2 deletions docs/qt/adresy/adresy02.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public slots:
QLineEdit *nazwaLine;
QTextEdit *adresText;

QString staraNazwa;
QString staryAdres;
Tryb aktTryb;
void aktGui(Tryb tryb);
QString staraNazwa;
QString staryAdres;
QMap<QString,QString> kontakty;

};
Expand Down
145 changes: 145 additions & 0 deletions docs/qt/adresy/adresy03.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#include "adresy.h"
#include "ui_adresy.h"

adresy::adresy(QWidget *parent) :
QWidget(parent),
ui(new Ui::adresy)
{
ui->setupUi(this);

QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));

nazwaLine = new QLineEdit;
nazwaLine = ui->nazwaLine;
nazwaLine->setReadOnly(true);

adresText = new QTextEdit;
adresText = ui->adresText;
adresText->setReadOnly(true);

dodajBtn = new QPushButton;
dodajBtn = ui->dodajBtn;

zapiszBtn = new QPushButton;
zapiszBtn = ui->zapiszBtn;
zapiszBtn->hide();

anulujBtn = new QPushButton;
anulujBtn = ui->anulujBtn;
anulujBtn->hide();

nastBtn = new QPushButton;
nastBtn = ui->nastBtn;
nastBtn->setEnabled(false);

poprzBtn = new QPushButton;
poprzBtn = ui->poprzBtn;
poprzBtn->setEnabled(false);

edytujBtn = new QPushButton;
edytujBtn = ui->edytujBtn;
edytujBtn->setEnabled(false);

usunBtn = new QPushButton;
usunBtn = ui->usunBtn;
usunBtn->setEnabled(false);

koniecBtn = new QPushButton;
koniecBtn = ui->koniecBtn;
koniecBtn->setEnabled(true);

connect(dodajBtn, SIGNAL(clicked()), this, SLOT(dodajKontakt()));
connect(koniecBtn,SIGNAL(clicked()),this, SLOT(koniec()));
connect(zapiszBtn, SIGNAL(clicked()), this, SLOT(zapiszKontakt()));
connect(anulujBtn, SIGNAL(clicked()), this, SLOT(anuluj()));

setWindowTitle(trUtf8("Prosta książka adresowa"));
}

adresy::~adresy()
{
delete ui;
}

void adresy::dodajKontakt() {
staraNazwa = nazwaLine->text();
staryAdres = adresText->toPlainText();

nazwaLine->clear();
adresText->clear();

aktGui(dodajT);
}

void adresy::aktGui(Tryb tryb) {
aktTryb=tryb;
switch (aktTryb) {
case dodajT:
case edytujT:
nazwaLine->setReadOnly(false);
nazwaLine->setFocus(Qt::OtherFocusReason);
adresText->setReadOnly(false);

dodajBtn->setEnabled(false);
edytujBtn->setEnabled(false);
usunBtn->setEnabled(false);

zapiszBtn->show();
anulujBtn->show();

nastBtn->setEnabled(false);
poprzBtn->setEnabled(false);
break;
case nawigujT:
if (kontakty.isEmpty()) {
nazwaLine->clear();
adresText->clear();
}
nazwaLine->setReadOnly(true);
adresText->setReadOnly(true);
dodajBtn->setEnabled(true);

int ile=kontakty.size();
edytujBtn->setEnabled(ile >= 1);
usunBtn->setEnabled(ile >=1 );
nastBtn->setEnabled(ile > 1);
poprzBtn->setEnabled(ile > 1);

zapiszBtn->hide();
anulujBtn->hide();
break;
}
}

void adresy::koniec() {
adresy::close();
}

void adresy::zapiszKontakt() {
QString nazwa = nazwaLine->text();
QString adres = adresText->toPlainText();

if (nazwa == "" || adres == "") {
QMessageBox::information(this, trUtf8("Puste pole"),trUtf8("Proszę wpisać nazwę i adres."));
return;
}

if (aktTryb == dodajT) {
if (!kontakty.contains(nazwa)) {
kontakty.insert(nazwa, adres);
QMessageBox::information(this, trUtf8("Dodano wpis"),
trUtf8("Kontakt \"%1\" dodano do książki adresowej.").arg(nazwa));
} else {
QMessageBox::information(this, trUtf8("Nie dodano wpisu"),
trUtf8("Przykro, ale kontakt \"%1\" jest już w książce adresowej.").arg(nazwa));
}
}

aktGui(nawigujT);
}

void adresy::anuluj() {
nazwaLine->setText(staraNazwa);
adresText->setText(staryAdres);
aktGui(nawigujT);
}
52 changes: 52 additions & 0 deletions docs/qt/adresy/adresy03.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#ifndef ADRESY_H
#define ADRESY_H

#include <QWidget>
#include <QLineEdit>
#include <QTextEdit>
#include <QPushButton>
#include <QTextCodec>
#include <QMessageBox>

namespace Ui {
class adresy;
}

class adresy : public QWidget
{
Q_OBJECT

public:
explicit adresy(QWidget *parent = 0);
~adresy();

enum Tryb { nawigujT, dodajT, edytujT };

public slots:
void dodajKontakt();
void koniec();
void zapiszKontakt();
void anuluj();

private:
Ui::adresy *ui;
QPushButton *dodajBtn;
QPushButton *zapiszBtn;
QPushButton *anulujBtn;
QPushButton *poprzBtn;
QPushButton *nastBtn;
QPushButton *edytujBtn;
QPushButton *usunBtn;
QPushButton *koniecBtn;
QLineEdit *nazwaLine;
QTextEdit *adresText;

QString staraNazwa;
QString staryAdres;
Tryb aktTryb;
void aktGui(Tryb tryb);
QMap<QString,QString> kontakty;

};

#endif // ADRESY_H

0 comments on commit 409b20f

Please sign in to comment.