forked from blue/squawk
hopefully end of refactoring of vcard to Info widget
This commit is contained in:
parent
bf11d8a74e
commit
e4a2728ef8
20 changed files with 268 additions and 1717 deletions
|
@ -236,3 +236,11 @@ void UI::ContactContacts::onCopyPhone() {
|
|||
QString UI::ContactContacts::title() const {
|
||||
return m_ui->contactHeading->text();
|
||||
}
|
||||
|
||||
void UI::ContactContacts::fillVCard(Shared::VCard& card) const {
|
||||
card.setUrl(m_ui->url->text());
|
||||
|
||||
emails.getEmails(card.getEmails());
|
||||
phones.getPhones(card.getPhones());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,3 +25,20 @@ UI::Description::Description(QWidget* parent):
|
|||
}
|
||||
|
||||
UI::Description::~Description() {}
|
||||
|
||||
QString UI::Description::title() const {
|
||||
return m_ui->descriptionHeading->text();
|
||||
}
|
||||
|
||||
QString UI::Description::description() const {
|
||||
return m_ui->description->toPlainText();
|
||||
}
|
||||
|
||||
void UI::Description::setDescription(const QString& description) {
|
||||
m_ui->description->setText(description);
|
||||
}
|
||||
|
||||
void UI::Description::setEditable(bool editable) {
|
||||
m_ui->description->setReadOnly(!editable);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,11 @@ public:
|
|||
Description(QWidget* parent = nullptr);
|
||||
~Description();
|
||||
|
||||
QString title() const;
|
||||
QString description() const;
|
||||
void setEditable(bool editable);
|
||||
void setDescription(const QString& description);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::Description> m_ui;
|
||||
};
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
#include "info.h"
|
||||
#include "ui_info.h"
|
||||
|
||||
UI::Info::Info(QWidget* parent):
|
||||
UI::Info::Info(const QString& p_jid, QWidget* parent):
|
||||
QWidget(parent),
|
||||
jid(p_jid),
|
||||
m_ui(new Ui::Info()),
|
||||
contactGeneral(nullptr),
|
||||
contactContacts(nullptr),
|
||||
|
@ -28,8 +29,10 @@ UI::Info::Info(QWidget* parent):
|
|||
progressLabel(new QLabel())
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->buttonBox->hide();
|
||||
|
||||
initializeOverlay();
|
||||
initializeButtonBox();
|
||||
}
|
||||
|
||||
UI::Info::~Info() {
|
||||
|
@ -50,11 +53,17 @@ void UI::Info::setData(const Shared::Info& info) {
|
|||
case Shared::EntryType::contact:
|
||||
initializeContactGeneral(info);
|
||||
initializeContactContacts(info);
|
||||
initializeDescription(info.editable);
|
||||
initializeDescription(info);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!info.editable)
|
||||
m_ui->buttonBox->hide();
|
||||
else
|
||||
m_ui->buttonBox->show();
|
||||
|
||||
}
|
||||
|
||||
void UI::Info::initializeOverlay() {
|
||||
|
@ -80,9 +89,32 @@ void UI::Info::initializeOverlay() {
|
|||
overlay->hide();
|
||||
}
|
||||
|
||||
void UI::Info::initializeButtonBox() {
|
||||
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &UI::Info::onButtonBoxAccepted);
|
||||
connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &UI::Info::close);
|
||||
|
||||
m_ui->buttonBox->hide();
|
||||
}
|
||||
|
||||
void UI::Info::onButtonBoxAccepted() {
|
||||
//TODO this is not good, since I don't exactly know what am I editing it's bad to assume there even going to be a vcard
|
||||
Shared::Info info;
|
||||
if (contactGeneral != nullptr)
|
||||
contactGeneral->fillVCard(info.vcard);
|
||||
if (contactContacts != nullptr)
|
||||
contactContacts->fillVCard(info.vcard);
|
||||
if (description != nullptr)
|
||||
info.vcard.setDescription(description->description());
|
||||
|
||||
emit saveInfo(info);
|
||||
}
|
||||
|
||||
void UI::Info::showProgress(const QString& line) {
|
||||
progressLabel->setText(line);
|
||||
if (line.size() > 0)
|
||||
progressLabel->setText(line);
|
||||
else
|
||||
progressLabel->setText(tr("Requesting information about %1").arg(jid));
|
||||
|
||||
overlay->show();
|
||||
progress->start();
|
||||
}
|
||||
|
@ -99,3 +131,23 @@ void UI::Info::initializeContactGeneral(const Shared::Info& info) {
|
|||
}
|
||||
contactGeneral->setVCard(info.jid, info.vcard, info.editable);
|
||||
}
|
||||
|
||||
void UI::Info::initializeContactContacts(const Shared::Info& info) {
|
||||
if (contactContacts == nullptr) {
|
||||
contactContacts = new ContactContacts;
|
||||
m_ui->tabWidget->addTab(contactContacts, contactContacts->title());
|
||||
}
|
||||
contactContacts->setVCard(info.jid, info.vcard, info.editable);
|
||||
}
|
||||
|
||||
void UI::Info::initializeDescription(const Shared::Info& info) {
|
||||
if (description == nullptr) {
|
||||
description = new Description;
|
||||
m_ui->tabWidget->addTab(description, description->title());
|
||||
}
|
||||
|
||||
description->setDescription(info.vcard.getDescription());
|
||||
description->setEditable(info.editable);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,18 +39,28 @@ class Info;
|
|||
class Info : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Info(QWidget* parent = nullptr);
|
||||
Info(const QString& jid, QWidget* parent = nullptr);
|
||||
~Info();
|
||||
|
||||
void setData(const Shared::Info& info);
|
||||
void showProgress(const QString& = "");
|
||||
void hideProgress();
|
||||
|
||||
public:
|
||||
QString jid;
|
||||
|
||||
signals:
|
||||
void saveInfo(const Shared::Info& info);
|
||||
|
||||
private slots:
|
||||
void onButtonBoxAccepted();
|
||||
|
||||
private:
|
||||
void initializeContactGeneral(const Shared::Info& info);
|
||||
void initializeContactContacts(const Shared::Info& info);
|
||||
void initializeDescription(bool editable);
|
||||
void initializeDescription(const Shared::Info& info);
|
||||
void initializeOverlay();
|
||||
void initializeButtonBox();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::Info> m_ui;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue