Yingdi Yu | 79c25a2 | 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; |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 16 | using namespace ndn::ptr_lib; |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 17 | using namespace std; |
| 18 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 19 | SetAliasDialog::SetAliasDialog(shared_ptr<ContactManager> contactManager, |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 20 | QWidget *parent) |
| 21 | : QDialog(parent) |
| 22 | , ui(new Ui::SetAliasDialog) |
| 23 | , m_contactManager(contactManager) |
| 24 | { |
| 25 | ui->setupUi(this); |
| 26 | |
| 27 | connect(ui->okButton, SIGNAL(clicked()), |
| 28 | this, SLOT(onOkClicked())); |
| 29 | connect(ui->cancelButton, SIGNAL(clicked()), |
| 30 | this, SLOT(onCancelClicked())); |
| 31 | } |
| 32 | |
| 33 | SetAliasDialog::~SetAliasDialog() |
| 34 | { |
| 35 | delete ui; |
| 36 | } |
| 37 | |
| 38 | void |
| 39 | SetAliasDialog::onOkClicked() |
| 40 | { |
| 41 | QString text = ui->aliasInput->text(); |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 42 | string alias = text.toStdString(); |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 43 | |
| 44 | m_contactManager->getContactStorage()->updateAlias(Name(m_target), alias); |
| 45 | |
| 46 | emit aliasChanged(); |
| 47 | |
| 48 | this->close(); |
| 49 | } |
| 50 | |
| 51 | void |
| 52 | SetAliasDialog::onCancelClicked() |
| 53 | { this->close(); } |
| 54 | |
| 55 | void |
| 56 | SetAliasDialog::setTargetIdentity(const string& name) |
| 57 | { |
| 58 | m_target = name; |
| 59 | string msg("Set alias for "); |
| 60 | msg.append(name).append(":"); |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 61 | ui->introLabel->setText(QString::fromStdString(msg)); |
Yingdi Yu | 79c25a2 | 2013-10-21 13:38:38 -0700 | [diff] [blame] | 62 | ui->aliasInput->clear(); |
| 63 | } |
| 64 | |
| 65 | |
| 66 | #if WAF |
| 67 | #include "setaliasdialog.moc" |
| 68 | #include "setaliasdialog.cpp.moc" |
| 69 | #endif |