diff options
author | deva <deva> | 2006-03-06 10:44:07 +0000 |
---|---|---|
committer | deva <deva> | 2006-03-06 10:44:07 +0000 |
commit | c9bfc4db72b84292f541c795993abde98e22121f (patch) | |
tree | 687411dce72a70dc0f4c337c8e496607308f8ab4 /client/cprquerydialog.cc | |
parent | c629a137b5f91097004f1a267d1433393e5cc512 (diff) |
*** empty log message ***
Diffstat (limited to 'client/cprquerydialog.cc')
-rw-r--r-- | client/cprquerydialog.cc | 86 |
1 files changed, 47 insertions, 39 deletions
diff --git a/client/cprquerydialog.cc b/client/cprquerydialog.cc index 19337a4..15e00d1 100644 --- a/client/cprquerydialog.cc +++ b/client/cprquerydialog.cc @@ -27,7 +27,7 @@ #include <config.h> #ifdef USE_GUI -#include <qframe.h> +#include <QFrame> #include "messagebox.h" #include "cprquerydialog.h" @@ -39,10 +39,11 @@ CPRQueryDialog::CPRQueryDialog(Info *info, QWidget *parent, const char *name, QStatusBar *status) - : QDialog(parent, name, TRUE) + : QDialog(parent) { + setModal(true); this->info = info; - setCaption(name); + setWindowTitle(name); // Load image QPixmap pix_backspace; @@ -60,7 +61,7 @@ CPRQueryDialog::CPRQueryDialog(Info *info, cpr[0] = '\0'; internalCpr[0] = '\0'; - cprSocket = new QSocket(this); + cprSocket = new QTcpSocket(this); connect(cprSocket, SIGNAL(readyRead()), SLOT(cprSocket_readyRead())); connect(cprSocket, SIGNAL(connected()), SLOT(cprSocket_connected())); connect(cprSocket, SIGNAL(error(int)), SLOT(cprSocket_error(int))); @@ -72,21 +73,21 @@ CPRQueryDialog::CPRQueryDialog(Info *info, connect(timer, SIGNAL(timeout()), SLOT(cprSocket_timeout())); // Generate input buttons - QGridLayout *gl = new QGridLayout(this, 4, 3, 10, 2); - - QButton *b1 = createButton(this, "1", 1); - QButton *b2 = createButton(this, "2", 2); - QButton *b3 = createButton(this, "3", 3); - QButton *b4 = createButton(this, "4", 4); - QButton *b5 = createButton(this, "5", 5); - QButton *b6 = createButton(this, "6", 6); - QButton *b7 = createButton(this, "7", 7); - QButton *b8 = createButton(this, "8", 8); - QButton *b9 = createButton(this, "9", 9); - QButton *b0 = createButton(this, "0", 0); - QButton *bbs = createButton(this, "", 10); - bbs->setPixmap(pix_backspace); - QButton *bca = createButton(this, "CA", 11); + QGridLayout *gl = new QGridLayout(this);//, 4, 3, 10, 2); + + QPushButton *b1 = createButton(this, "1", 1); + QPushButton *b2 = createButton(this, "2", 2); + QPushButton *b3 = createButton(this, "3", 3); + QPushButton *b4 = createButton(this, "4", 4); + QPushButton *b5 = createButton(this, "5", 5); + QPushButton *b6 = createButton(this, "6", 6); + QPushButton *b7 = createButton(this, "7", 7); + QPushButton *b8 = createButton(this, "8", 8); + QPushButton *b9 = createButton(this, "9", 9); + QPushButton *b0 = createButton(this, "0", 0); + QPushButton *bbs = createButton(this, "", 10); + bbs->setIcon(pix_backspace); + QPushButton *bca = createButton(this, "CA", 11); gl->addWidget(b1, 0,0); gl->addWidget(b2, 0,1); @@ -160,7 +161,8 @@ QPushButton *CPRQueryDialog::createButton(QWidget *parent, const char *text, int { char buf[32]; sprintf(buf, "%d", value); - QPushButton *q = new QPushButton(this, buf); + QPushButton *q = new QPushButton(this); + q->setText(buf); QFont f("Lucida", 48); q->setFixedSize(150, 100); @@ -366,19 +368,19 @@ void CPRQueryDialog::cprSocket_error(int errnum) // Print error message switch(errnum) { - case QSocket::ErrConnectionRefused: // if the connection was refused + case QAbstractSocket::ConnectionRefusedError: // if the connection was refused msg.append("ErrConnectionRefused"); break; - case QSocket::ErrHostNotFound: // if the host was not found + case QAbstractSocket::HostNotFoundError: // if the host was not found msg.append("ErrHostNotFound"); break; - case QSocket::ErrSocketRead: // if a read from the socket failed + case QAbstractSocket::SocketAccessError: // if a read from the socket failed msg.append("ErrSocketRead"); break; } - if(statusbar) statusbar->message(msg, 5000); - MessageBox(this, "Fejl", msg, TYPE_OK, ICON_ERROR).exec(); + if(statusbar) statusbar->showMessage(msg, 5000); + MessageBox(this, "Fejl", msg.toStdString().c_str(), TYPE_OK, ICON_ERROR).exec(); //info->error(msg.c_str()); accept(); } @@ -399,7 +401,7 @@ void CPRQueryDialog::cprSocket_readyRead() if (!cprSocket->canReadLine()) return; QString msg = QString("Recieving name from cpr database..."); - if(statusbar) statusbar->message(msg, 5000); + if(statusbar) statusbar->showMessage(msg, 5000); timer->stop(); while(cprSocket->canReadLine()) { @@ -407,13 +409,13 @@ void CPRQueryDialog::cprSocket_readyRead() if (s.startsWith("0001")) { name.append(s.right(s.length()-4)); lastname.append(s.right(s.length()-4)); - name.setLength(name.length()-1); + name.resize(name.length()-1); if (name.length()) name += QString(", "); } if (s.startsWith("0002")) { name.append(s.right(s.length()-4)); firstname.append(s.right(s.length()-4)); - name.setLength(name.length()-1); + name.resize(name.length()-1); cprSocket->close(); lbl_name->setText(name); accept(); @@ -440,11 +442,11 @@ void CPRQueryDialog::cprSocket_readyRead() void CPRQueryDialog::cprSocket_connected() { QString msg = QString("Connected to cpr database, sending cpr number..."); - if(statusbar) statusbar->message(msg, 5000); + if(statusbar) statusbar->showMessage(msg, 5000); timer->stop(); - cprSocket->writeBlock(internalCpr, 10); - cprSocket->writeBlock("\n", 1); + cprSocket->write(internalCpr, 10); + cprSocket->write("\n", 1); } /** @@ -461,25 +463,31 @@ void CPRQueryDialog::cprSocket_timeout() // Print connection status switch(cprSocket->state()) { - case QSocket::Idle: // if there is no connection - msg.append("Idle"); + case QAbstractSocket::UnconnectedState: // if there is no connection + msg.append("Unconnected"); break; - case QSocket::HostLookup: // during a DNS lookup + case QAbstractSocket::HostLookupState: // during a DNS lookup msg.append("HostLookup"); break; - case QSocket::Connecting: // during TCP connection establishment + case QAbstractSocket::ConnectingState: // during TCP connection establishment msg.append("Connecting"); break; - case QSocket::Connected: // when there is an operational connection + case QAbstractSocket::ConnectedState: // when there is an operational connection msg.append("Conected"); break; - case QSocket::Closing: // if the socket is closing down, but is not yet closed. + case QAbstractSocket::ClosingState: // if the socket is closing down, but is not yet closed. msg.append("Closing"); break; + case QAbstractSocket::BoundState: // + msg.append("Bound"); + break; + case QAbstractSocket::ListeningState: // + msg.append("Listening"); + break; } - if(statusbar) statusbar->message(msg, 5000); - MessageBox(this, "Fejl", msg, TYPE_OK, ICON_ERROR).exec(); + if(statusbar) statusbar->showMessage(msg, 5000); + MessageBox(this, "Fejl", msg.toStdString().c_str(), TYPE_OK, ICON_ERROR).exec(); accept(); } |