blob: 38e70d98acbdf4932e4300d2ef445900804cba9c [file] [log] [blame]
Yingdi Yu2ac40fb2013-10-21 13:38:38 -07001/* -*- 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
15using namespace ndn;
16using namespace std;
17
18SetAliasDialog::SetAliasDialog(Ptr<ContactManager> contactManager,
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
32SetAliasDialog::~SetAliasDialog()
33{
34 delete ui;
35}
36
37void
38SetAliasDialog::onOkClicked()
39{
40 QString text = ui->aliasInput->text();
41 string alias = text.toUtf8().constData();
42
43 m_contactManager->getContactStorage()->updateAlias(Name(m_target), alias);
44
45 emit aliasChanged();
46
47 this->close();
48}
49
50void
51SetAliasDialog::onCancelClicked()
52{ this->close(); }
53
54void
55SetAliasDialog::setTargetIdentity(const string& name)
56{
57 m_target = name;
58 string msg("Set alias for ");
59 msg.append(name).append(":");
60 ui->introLabel->setText(QString::fromUtf8(msg.c_str()));
61 ui->aliasInput->clear();
62}
63
64
65#if WAF
66#include "setaliasdialog.moc"
67#include "setaliasdialog.cpp.moc"
68#endif