Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013, Regents of the University of California |
| 4 | * Yingdi Yu |
| 5 | * |
| 6 | * BSD license, See the LICENSE file for more information |
| 7 | * |
| 8 | * Author: Yingdi Yu <yingdi@cs.ucla.edu> |
| 9 | */ |
| 10 | |
| 11 | #include "setaliasdialog.h" |
| 12 | #include "ui_setaliasdialog.h" |
| 13 | |
| 14 | |
| 15 | using namespace ndn; |
| 16 | using namespace std; |
| 17 | |
Yingdi Yu | fa4ce79 | 2014-02-06 18:09:22 -0800 | [diff] [blame^] | 18 | SetAliasDialog::SetAliasDialog(shared_ptr<chronos::ContactManager> contactManager, |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 19 | QWidget *parent) |
| 20 | : QDialog(parent) |
| 21 | , ui(new Ui::SetAliasDialog) |
| 22 | , m_contactManager(contactManager) |
| 23 | { |
| 24 | ui->setupUi(this); |
| 25 | |
| 26 | connect(ui->okButton, SIGNAL(clicked()), |
| 27 | this, SLOT(onOkClicked())); |
| 28 | connect(ui->cancelButton, SIGNAL(clicked()), |
| 29 | this, SLOT(onCancelClicked())); |
| 30 | } |
| 31 | |
| 32 | SetAliasDialog::~SetAliasDialog() |
| 33 | { |
| 34 | delete ui; |
| 35 | } |
| 36 | |
| 37 | void |
| 38 | SetAliasDialog::onOkClicked() |
| 39 | { |
| 40 | QString text = ui->aliasInput->text(); |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 41 | string alias = text.toStdString(); |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 42 | |
| 43 | m_contactManager->getContactStorage()->updateAlias(Name(m_target), alias); |
| 44 | |
| 45 | emit aliasChanged(); |
| 46 | |
| 47 | this->close(); |
| 48 | } |
| 49 | |
| 50 | void |
| 51 | SetAliasDialog::onCancelClicked() |
| 52 | { this->close(); } |
| 53 | |
| 54 | void |
| 55 | SetAliasDialog::setTargetIdentity(const string& name) |
| 56 | { |
| 57 | m_target = name; |
| 58 | string msg("Set alias for "); |
| 59 | msg.append(name).append(":"); |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 60 | ui->introLabel->setText(QString::fromStdString(msg)); |
Yingdi Yu | 2ac40fb | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 61 | ui->aliasInput->clear(); |
| 62 | } |
| 63 | |
| 64 | |
| 65 | #if WAF |
| 66 | #include "setaliasdialog.moc" |
| 67 | #include "setaliasdialog.cpp.moc" |
| 68 | #endif |