Changing WarningDialog to QMessageBox
diff --git a/src/addcontactpanel.cpp b/src/addcontactpanel.cpp
index 78f6102..38bc6e9 100644
--- a/src/addcontactpanel.cpp
+++ b/src/addcontactpanel.cpp
@@ -10,6 +10,7 @@
#include "addcontactpanel.h"
#include "ui_addcontactpanel.h"
+#include <QMessageBox>
#ifndef Q_MOC_RUN
// #include <cryptopp/base64.h>
@@ -90,8 +91,7 @@
m_contactManager->fetchKey(m_searchIdentity);
else
{
- m_warningDialog->setMsg("Wrong key certificate name!");
- m_warningDialog->show();
+ QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Wrong key certificate name!"));
}
}
}
@@ -128,8 +128,7 @@
try{
m_contactManager->getContactStorage()->addContact(contactItem);
}catch(exception& e){
- m_warningDialog->setMsg(e.what());
- m_warningDialog->show();
+ QMessageBox::information(this, tr("Chronos"), QString::fromStdString(e.what()));
_LOG_ERROR("Exception: " << e.what());
return;
}
@@ -143,8 +142,7 @@
try{
m_currentEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(endorseCertificate));
}catch(exception& e){
- m_warningDialog->setMsg(e.what());
- m_warningDialog->show();
+ QMessageBox::information(this, tr("Chronos"), QString::fromStdString(e.what()));
_LOG_ERROR("Exception: " << e.what());
return;
}
@@ -157,8 +155,7 @@
void
AddContactPanel::selfEndorseCertificateFetchFailed(const Name& identity)
{
- m_warningDialog->setMsg("Cannot fetch contact profile");
- m_warningDialog->show();
+ QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Cannot fetch contact profile"));
}
void
@@ -167,8 +164,7 @@
try{
m_currentEndorseCertificate = Ptr<EndorseCertificate>(new EndorseCertificate(endorseCertificate));
}catch(exception& e){
- m_warningDialog->setMsg(e.what());
- m_warningDialog->show();
+ QMessageBox::information(this, tr("Chronos"), QString::fromStdString(e.what()));
_LOG_ERROR("Exception: " << e.what());
return;
}
@@ -181,8 +177,7 @@
void
AddContactPanel::onContactKeyFetchFailed(const Name& identity)
{
- m_warningDialog->setMsg("Cannot fetch contact ksk certificate");
- m_warningDialog->show();
+ QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Cannot fetch contact ksk certificate"));
}
void
diff --git a/src/browsecontactdialog.cpp b/src/browsecontactdialog.cpp
index 20a23a9..78a6ab4 100644
--- a/src/browsecontactdialog.cpp
+++ b/src/browsecontactdialog.cpp
@@ -11,6 +11,7 @@
#include "browsecontactdialog.h"
#include "ui_browsecontactdialog.h"
+#include <QMessageBox>
#ifndef Q_MOC_RUN
#include <boost/asio.hpp>
@@ -73,8 +74,7 @@
request_stream.connect("ndncert.named-data.net","80");
if(!request_stream)
{
- m_warningDialog->setMsg("Fail to fetch certificate directory! #1");
- m_warningDialog->show();
+ QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Fail to fetch certificate directory! #1"));
return;
}
request_stream << "GET /cert/list/ HTTP/1.0\r\n";
@@ -85,8 +85,7 @@
std::getline(request_stream,line1);
if (!request_stream)
{
- m_warningDialog->setMsg("Fail to fetch certificate directory! #2");
- m_warningDialog->show();
+ QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Fail to fetch certificate directory! #2"));
return;
}
@@ -100,14 +99,12 @@
if (!response_stream||http_version.substr(0,5)!="HTTP/")
{
- m_warningDialog->setMsg("Fail to fetch certificate directory! #3");
- m_warningDialog->show();
+ QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Fail to fetch certificate directory! #3"));
return;
}
if (status_code!=200)
{
- m_warningDialog->setMsg("Fail to fetch certificate directory! #4");
- m_warningDialog->show();
+ QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Fail to fetch certificate directory! #4"));
return;
}
vector<string> headers;
@@ -135,13 +132,11 @@
it++;
}
}catch (exception &e){
- m_warningDialog->setMsg("Fail to fetch certificate directory! #5");
- m_warningDialog->show();
+ QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Fail to fetch certificate directory! #5"));
}
}catch(std::exception &e){
- m_warningDialog->setMsg("Fail to fetch certificate directory! #N");
- m_warningDialog->show();
+ QMessageBox::information(this, tr("Chronos"), QString::fromStdString("Fail to fetch certificate directory! #N"));
}
}
@@ -189,7 +184,8 @@
for(; it != certNameList.end(); it++)
{
try{
- m_certificateNameList.push_back(Name (*it));
+ Name name(*it);
+ m_certificateNameList.push_back(name);
}
catch(error::Name)
{
@@ -259,6 +255,8 @@
for(int i = ui->InfoTable->rowCount() - 1; i >= 0 ; i--)
ui->InfoTable->removeRow(i);
+ ui->InfoTable->horizontalHeader()->show();
+
map<Name, Profile>::iterator it = m_profileMap.find(certName);
if(it != m_profileMap.end())
{
@@ -317,6 +315,18 @@
BrowseContactDialog::onCancelClicked()
{ this->close(); }
+void
+BrowseContactDialog::closeEvent(QCloseEvent *e)
+{
+ ui->InfoTable->clear();
+ for(int i = ui->InfoTable->rowCount() - 1; i >= 0 ; i--)
+ ui->InfoTable->removeRow(i);
+ ui->InfoTable->horizontalHeader()->hide();
+
+ hide();
+ e->ignore();
+}
+
#if WAF
#include "browsecontactdialog.moc"
#include "browsecontactdialog.cpp.moc"
diff --git a/src/browsecontactdialog.h b/src/browsecontactdialog.h
index dfcb64c..8b8029f 100644
--- a/src/browsecontactdialog.h
+++ b/src/browsecontactdialog.h
@@ -14,6 +14,7 @@
#include <QDialog>
#include <QStringListModel>
+#include <QCloseEvent>
#include "warningdialog.h"
@@ -56,6 +57,10 @@
void
fetchCertificate();
+protected:
+ void
+ closeEvent(QCloseEvent *e);
+
private slots:
void
updateSelection(const QItemSelection &selected,
diff --git a/src/contact-manager.cpp b/src/contact-manager.cpp
index eac5c51..2203ffe 100644
--- a/src/contact-manager.cpp
+++ b/src/contact-manager.cpp
@@ -45,7 +45,7 @@
try{
m_wrapper = Ptr<Wrapper>(new Wrapper(m_keychain));
}catch(ndn::Error::ndnOperation& e){
- emit noNdnConnection(QString::fromStdString("Cannot conect to ndnd!\n Have you started your ndnd?"));
+ emit noNdnConnection(QString::fromStdString("Cannot conect to ndnd!\nHave you started your ndnd?"));
}
}
diff --git a/src/contactpanel.cpp b/src/contactpanel.cpp
index b0276b7..1fc62aa 100644
--- a/src/contactpanel.cpp
+++ b/src/contactpanel.cpp
@@ -113,7 +113,7 @@
this, SLOT(openProfileEditor()));
connect(m_profileEditor, SIGNAL(noKeyOrCert(const QString&)),
- this, SLOT(showError(const QString&)));
+ this, SLOT(showWarning(const QString&)));
// connect(ui->AddContactButton, SIGNAL(clicked()),
// this, SLOT(openAddContactPanel()));
@@ -252,6 +252,7 @@
string prefix = QString::fromStdString (originPrefix).trimmed ().toUtf8().constData();
string randomSuffix = getRandomString();
m_localPrefix = Name(prefix);
+
}
void
@@ -439,6 +440,11 @@
}
void
+ContactPanel::showWarning(const QString& msg){
+ QMessageBox::information(this, tr("Chronos"), msg);
+}
+
+void
ContactPanel::updateSelection(const QItemSelection &selected,
const QItemSelection &deselected)
{
@@ -531,13 +537,20 @@
ContactPanel::updateDefaultIdentity(const QString& identity, const QString& nickName)
{
// _LOG_DEBUG(identity.toStdString());
- m_defaultIdentity = Name(identity.toStdString());
- Name defaultKeyName = m_keychain->getIdentityManager()->getPublicStorage()->getDefaultKeyNameForIdentity(m_defaultIdentity);
+ Name defaultIdentity = Name(identity.toStdString());
+ Name defaultKeyName = m_keychain->getIdentityManager()->getPublicStorage()->getDefaultKeyNameForIdentity(defaultIdentity);
if(defaultKeyName.size() == 0)
- showError(QString::fromStdString("Corresponding key is missing!\nHave you created the key?"));
+ {
+ showWarning(QString::fromStdString("Corresponding key is missing!\nHave you created the key?"));
+ return;
+ }
Name defaultCertName = m_keychain->getIdentityManager()->getPublicStorage()->getDefaultCertificateNameForKey(defaultKeyName);
if(defaultCertName.size() == 0)
- showError(QString::fromStdString("Corresponding certificate is missing!\nHave you installed the certificate?"));
+ {
+ showWarning(QString::fromStdString("Corresponding certificate is missing!\nHave you installed the certificate?"));
+ return;
+ }
+ m_defaultIdentity = defaultIdentity;
m_profileEditor->setCurrentIdentity(m_defaultIdentity);
m_nickName = nickName.toStdString();
m_handler->clearInterestFilter(m_inviteListenPrefix);
diff --git a/src/contactpanel.h b/src/contactpanel.h
index 92bccf3..439f52a 100644
--- a/src/contactpanel.h
+++ b/src/contactpanel.h
@@ -122,6 +122,9 @@
showError(const QString& msg);
void
+ showWarning(const QString& msg);
+
+ void
updateSelection(const QItemSelection &selected,
const QItemSelection &deselected);
diff --git a/src/profileeditor.cpp b/src/profileeditor.cpp
index f0f92d2..4804431 100644
--- a/src/profileeditor.cpp
+++ b/src/profileeditor.cpp
@@ -85,11 +85,17 @@
{
Name defaultKeyName = m_identityManager->getPublicStorage()->getDefaultKeyNameForIdentity(m_currentIdentity);
if(defaultKeyName.size() == 0)
- emit noKeyOrCert(QString::fromStdString("Corresponding key is missing!\nHave you created the key?"));
+ {
+ emit noKeyOrCert(QString::fromStdString("Corresponding key is missing!\nHave you created the key?"));
+ return;
+ }
+
Name defaultCertName = m_identityManager->getPublicStorage()->getDefaultCertificateNameForKey(defaultKeyName);
if(defaultCertName.size() == 0)
- emit noKeyOrCert(QString::fromStdString("Corresponding certificate is missing!\nHave you installed the certificate?"));
-
+ {
+ emit noKeyOrCert(QString::fromStdString("Corresponding certificate is missing!\nHave you installed the certificate?"));
+ return;
+ }
m_tableModel->submitAll();
m_contactManager->updateProfileData(m_currentIdentity);