blob: 553b15c2dd2377f9c3bfa7e33a8247fbe7585acf [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
Yingdi Yufa4ce792014-02-06 18:09:22 -080018SetAliasDialog::SetAliasDialog(shared_ptr<chronos::ContactManager> contactManager,
Yingdi Yu2ac40fb2013-10-21 13:38:38 -070019 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();
Yingdi Yue35bdb82013-11-07 11:32:40 -080041 string alias = text.toStdString();
Yingdi Yu2ac40fb2013-10-21 13:38:38 -070042
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(":");
Yingdi Yue35bdb82013-11-07 11:32:40 -080060 ui->introLabel->setText(QString::fromStdString(msg));
Yingdi Yu2ac40fb2013-10-21 13:38:38 -070061 ui->aliasInput->clear();
62}
63
64
65#if WAF
66#include "setaliasdialog.moc"
67#include "setaliasdialog.cpp.moc"
68#endif