#include <detailsdialog.h>
Inheritance diagram for DetailsDialog:


Definition at line 40 of file detailsdialog.h.
Public Slots | |
| void | verify () |
Public Member Functions | |
| DetailsDialog (const QString &title, QWidget *parent) | |
| QList< QPair< QString, int > > | orderItems () |
| QString | senderName () const |
| QString | senderAddress () const |
| bool | sendOffers () |
Private Member Functions | |
| void | setupItemsTable () |
Private Attributes | |
| QLabel * | nameLabel |
| QLabel * | addressLabel |
| QCheckBox * | offersCheckBox |
| QLineEdit * | nameEdit |
| QStringList | items |
| QTableWidget * | itemsTable |
| QTextEdit * | addressEdit |
| QDialogButtonBox * | buttonBox |
Definition at line 28 of file detailsdialog.cpp.
References QDialog::accepted(), addressEdit, addressLabel, QGridLayout::addWidget(), Qt::AlignLeft, Qt::AlignTop, buttonBox, QDialogButtonBox::Cancel, QObject::connect(), itemsTable, nameEdit, nameLabel, offersCheckBox, QDialogButtonBox::Ok, QDialog::reject(), QDialog::rejected(), QLabel::setAlignment(), QWidget::setLayout(), setupItemsTable(), QWidget::setWindowTitle(), SIGNAL, SLOT, and verify().
00029 : QDialog(parent) 00030 { 00031 nameLabel = new QLabel(tr("Name:")); 00032 addressLabel = new QLabel(tr("Address:")); 00033 addressLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop); 00034 00035 nameEdit = new QLineEdit; 00036 addressEdit = new QTextEdit; 00037 00038 offersCheckBox = new QCheckBox(tr("Send information about products and " 00039 "special offers")); 00040 00041 setupItemsTable(); 00042 00043 buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok 00044 | QDialogButtonBox::Cancel); 00045 00046 connect(buttonBox, SIGNAL(accepted()), this, SLOT(verify())); 00047 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); 00048 00049 QGridLayout *mainLayout = new QGridLayout; 00050 mainLayout->addWidget(nameLabel, 0, 0); 00051 mainLayout->addWidget(nameEdit, 0, 1); 00052 mainLayout->addWidget(addressLabel, 1, 0); 00053 mainLayout->addWidget(addressEdit, 1, 1); 00054 mainLayout->addWidget(itemsTable, 0, 2, 2, 1); 00055 mainLayout->addWidget(offersCheckBox, 2, 1, 1, 2); 00056 mainLayout->addWidget(buttonBox, 3, 0, 1, 3); 00057 setLayout(mainLayout); 00058 00059 setWindowTitle(title); 00060 }
Here is the call graph for this function:

| void DetailsDialog::verify | ( | ) | [slot] |
Definition at line 108 of file detailsdialog.cpp.
References QDialog::accept(), addressEdit, QString::isEmpty(), nameEdit, QMessageBox::No, QDialog::reject(), QLineEdit::text(), QTextEdit::toPlainText(), QMessageBox::warning(), and QMessageBox::Yes.
Referenced by DetailsDialog().
00109 { 00110 if (!nameEdit->text().isEmpty() && !addressEdit->toPlainText().isEmpty()) { 00111 accept(); 00112 return; 00113 } 00114 00115 QMessageBox::StandardButton answer; 00116 answer = QMessageBox::warning(this, tr("Incomplete Form"), 00117 tr("The form does not contain all the necessary information.\n" 00118 "Do you want to discard it?"), 00119 QMessageBox::Yes | QMessageBox::No); 00120 00121 if (answer == QMessageBox::Yes) 00122 reject(); 00123 }
Definition at line 78 of file detailsdialog.cpp.
References QList< T >::append(), QList< T >::count(), QTableWidgetItem::data(), Qt::DisplayRole, QList< T >::first(), QTableWidget::item(), items, itemsTable, qMax(), row, QTableWidgetItem::text(), and QVariant::toInt().
Referenced by MainWindow::createSample(), and MainWindow::openDialog().
00079 { 00080 QList<QPair<QString, int> > orderList; 00081 00082 for (int row = 0; row < items.count(); ++row) { 00083 QPair<QString, int> item; 00084 item.first = itemsTable->item(row, 0)->text(); 00085 int quantity = itemsTable->item(row, 1)->data(Qt::DisplayRole).toInt(); 00086 item.second = qMax(0, quantity); 00087 orderList.append(item); 00088 } 00089 00090 return orderList; 00091 }
Here is the call graph for this function:

| QString DetailsDialog::senderName | ( | ) | const |
Definition at line 93 of file detailsdialog.cpp.
References nameEdit, and QLineEdit::text().
Referenced by MainWindow::openDialog().
Here is the call graph for this function:

| QString DetailsDialog::senderAddress | ( | ) | const |
Definition at line 98 of file detailsdialog.cpp.
References addressEdit, and QTextEdit::toPlainText().
Referenced by MainWindow::openDialog().
00099 { 00100 return addressEdit->toPlainText(); 00101 }
Here is the call graph for this function:

| bool DetailsDialog::sendOffers | ( | ) |
Definition at line 103 of file detailsdialog.cpp.
References QAbstractButton::isChecked(), and offersCheckBox.
Referenced by MainWindow::openDialog().
00104 { 00105 return offersCheckBox->isChecked(); 00106 }
Here is the call graph for this function:

| void DetailsDialog::setupItemsTable | ( | ) | [private] |
Definition at line 62 of file detailsdialog.cpp.
References QList< T >::count(), Qt::ItemIsEnabled, Qt::ItemIsSelectable, items, itemsTable, name, row, and QTableWidget::setItem().
Referenced by DetailsDialog().
00063 { 00064 items << tr("T-shirt") << tr("Badge") << tr("Reference book") 00065 << tr("Coffee cup"); 00066 00067 itemsTable = new QTableWidget(items.count(), 2); 00068 00069 for (int row = 0; row < items.count(); ++row) { 00070 QTableWidgetItem *name = new QTableWidgetItem(items[row]); 00071 name->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); 00072 itemsTable->setItem(row, 0, name); 00073 QTableWidgetItem *quantity = new QTableWidgetItem("1"); 00074 itemsTable->setItem(row, 1, quantity); 00075 } 00076 }
Here is the call graph for this function:

QLabel* DetailsDialog::nameLabel [private] |
QLabel* DetailsDialog::addressLabel [private] |
QCheckBox* DetailsDialog::offersCheckBox [private] |
QLineEdit* DetailsDialog::nameEdit [private] |
Definition at line 62 of file detailsdialog.h.
Referenced by DetailsDialog(), senderName(), and verify().
QStringList DetailsDialog::items [private] |
QTableWidget* DetailsDialog::itemsTable [private] |
Definition at line 64 of file detailsdialog.h.
Referenced by DetailsDialog(), orderItems(), and setupItemsTable().
QTextEdit* DetailsDialog::addressEdit [private] |
Definition at line 65 of file detailsdialog.h.
Referenced by DetailsDialog(), senderAddress(), and verify().
QDialogButtonBox* DetailsDialog::buttonBox [private] |
1.5.1