blob: 42d8b2d0cc52b29be2651898cc64ee7977b90566 [file] [log] [blame]
Yingdi Yu79c25a22013-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;
Yingdi Yu64206112013-12-24 11:16:32 +080016using namespace ndn::ptr_lib;
Yingdi Yu79c25a22013-10-21 13:38:38 -070017using namespace std;
18
Yingdi Yu64206112013-12-24 11:16:32 +080019SetAliasDialog::SetAliasDialog(shared_ptr<ContactManager> contactManager,
Yingdi Yu79c25a22013-10-21 13:38:38 -070020 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
33SetAliasDialog::~SetAliasDialog()
34{
35 delete ui;
36}
37
38void
39SetAliasDialog::onOkClicked()
40{
41 QString text = ui->aliasInput->text();
Yingdi Yub35b8652013-11-07 11:32:40 -080042 string alias = text.toStdString();
Yingdi Yu79c25a22013-10-21 13:38:38 -070043
44 m_contactManager->getContactStorage()->updateAlias(Name(m_target), alias);
45
46 emit aliasChanged();
47
48 this->close();
49}
50
51void
52SetAliasDialog::onCancelClicked()
53{ this->close(); }
54
55void
56SetAliasDialog::setTargetIdentity(const string& name)
57{
58 m_target = name;
59 string msg("Set alias for ");
60 msg.append(name).append(":");
Yingdi Yub35b8652013-11-07 11:32:40 -080061 ui->introLabel->setText(QString::fromStdString(msg));
Yingdi Yu79c25a22013-10-21 13:38:38 -070062 ui->aliasInput->clear();
63}
64
65
66#if WAF
67#include "setaliasdialog.moc"
68#include "setaliasdialog.cpp.moc"
69#endif