diff --git a/shared/info.cpp b/shared/info.cpp index bda2b9f..a5cf046 100644 --- a/shared/info.cpp +++ b/shared/info.cpp @@ -16,13 +16,25 @@ #include "info.h" +Shared::Info::Info(const QString& p_jid, bool p_editable): + jid(p_jid), + editable(p_editable), + vcard(), + activeKeys(), + inactiveKeys() +{} + Shared::Info::Info(): + jid(), + editable(false), vcard(), activeKeys(), inactiveKeys() {} Shared::Info::Info(const Shared::Info& other): + jid(other.jid), + editable(other.editable), vcard(other.vcard), activeKeys(other.activeKeys), inactiveKeys(other.inactiveKeys) diff --git a/shared/info.h b/shared/info.h index 1692991..c3f16f8 100644 --- a/shared/info.h +++ b/shared/info.h @@ -33,9 +33,12 @@ namespace Shared { class Info { public: Info(); + Info(const QString& jid, bool editable = false); Info(const Info& other); ~Info(); + QString jid; + bool editable; VCard vcard; std::list activeKeys; std::list inactiveKeys; diff --git a/ui/models/CMakeLists.txt b/ui/models/CMakeLists.txt index 629db32..84aba66 100644 --- a/ui/models/CMakeLists.txt +++ b/ui/models/CMakeLists.txt @@ -24,3 +24,5 @@ target_sources(squawk PRIVATE roster.cpp roster.h ) + +add_subdirectory(info) diff --git a/ui/models/info/CMakeLists.txt b/ui/models/info/CMakeLists.txt new file mode 100644 index 0000000..57a078c --- /dev/null +++ b/ui/models/info/CMakeLists.txt @@ -0,0 +1,10 @@ +target_sources(squawk PRIVATE + emails.cpp + emails.h + phones.cpp + phones.h + ) + +if (WITH_OMEMO) + add_subdirectory(omemo) +endif() diff --git a/ui/widgets/vcard/emailsmodel.cpp b/ui/models/info/emails.cpp similarity index 80% rename from ui/widgets/vcard/emailsmodel.cpp rename to ui/models/info/emails.cpp index 994fcc3..6c902bf 100644 --- a/ui/widgets/vcard/emailsmodel.cpp +++ b/ui/models/info/emails.cpp @@ -16,30 +16,29 @@ * along with this program. If not, see . */ -#include "emailsmodel.h" +#include "emails.h" #include "shared/icons.h" #include -UI::VCard::EMailsModel::EMailsModel(bool p_edit, QObject* parent): +Models::EMails::EMails(bool p_edit, QObject* parent): QAbstractTableModel(parent), edit(p_edit), - deque() -{ -} + deque() {} -int UI::VCard::EMailsModel::columnCount(const QModelIndex& parent) const -{ - return 3; -} +int Models::EMails::columnCount(const QModelIndex& parent) const { + return 3;} -int UI::VCard::EMailsModel::rowCount(const QModelIndex& parent) const -{ - return deque.size(); -} +int Models::EMails::rowCount(const QModelIndex& parent) const { + return deque.size();} -QVariant UI::VCard::EMailsModel::data(const QModelIndex& index, int role) const -{ +void Models::EMails::revertPreferred(quint32 row) { + setData(createIndex(row, 2), !isPreferred(row));} + +QString Models::EMails::getEmail(quint32 row) const { + return deque[row].address;} + +QVariant Models::EMails::data(const QModelIndex& index, int role) const { if (index.isValid()) { int col = index.column(); switch (col) { @@ -82,8 +81,7 @@ QVariant UI::VCard::EMailsModel::data(const QModelIndex& index, int role) const return QVariant(); } -Qt::ItemFlags UI::VCard::EMailsModel::flags(const QModelIndex& index) const -{ +Qt::ItemFlags Models::EMails::flags(const QModelIndex& index) const { Qt::ItemFlags f = QAbstractTableModel::flags(index); if (edit && index.column() != 2) { f = Qt::ItemIsEditable | f; @@ -91,8 +89,7 @@ Qt::ItemFlags UI::VCard::EMailsModel::flags(const QModelIndex& index) const return f; } -bool UI::VCard::EMailsModel::setData(const QModelIndex& index, const QVariant& value, int role) -{ +bool Models::EMails::setData(const QModelIndex& index, const QVariant& value, int role) { if (role == Qt::EditRole && checkIndex(index)) { Shared::VCard::Email& item = deque[index.row()]; switch (index.column()) { @@ -124,8 +121,7 @@ bool UI::VCard::EMailsModel::setData(const QModelIndex& index, const QVariant& v } -bool UI::VCard::EMailsModel::dropPrefered() -{ +bool Models::EMails::dropPrefered() { bool dropped = false; int i = 0; for (Shared::VCard::Email& email : deque) { @@ -140,16 +136,14 @@ bool UI::VCard::EMailsModel::dropPrefered() return dropped; } -QModelIndex UI::VCard::EMailsModel::addNewEmptyLine() -{ +QModelIndex Models::EMails::addNewEmptyLine() { beginInsertRows(QModelIndex(), deque.size(), deque.size()); deque.emplace_back(""); endInsertRows(); return createIndex(deque.size() - 1, 0, &(deque.back())); } -bool UI::VCard::EMailsModel::isPreferred(quint32 row) const -{ +bool Models::EMails::isPreferred(quint32 row) const { if (row < deque.size()) { return deque[row].prefered; } else { @@ -157,8 +151,7 @@ bool UI::VCard::EMailsModel::isPreferred(quint32 row) const } } -void UI::VCard::EMailsModel::removeLines(quint32 index, quint32 count) -{ +void Models::EMails::removeLines(quint32 index, quint32 count) { if (index < deque.size()) { quint32 maxCount = deque.size() - index; if (count > maxCount) { @@ -175,15 +168,13 @@ void UI::VCard::EMailsModel::removeLines(quint32 index, quint32 count) } } -void UI::VCard::EMailsModel::getEmails(std::deque& emails) const -{ +void Models::EMails::getEmails(std::deque& emails) const { for (const Shared::VCard::Email& my : deque) { emails.emplace_back(my); } } -void UI::VCard::EMailsModel::setEmails(const std::deque& emails) -{ +void Models::EMails::setEmails(const std::deque& emails) { if (deque.size() > 0) { removeLines(0, deque.size()); } @@ -196,13 +187,3 @@ void UI::VCard::EMailsModel::setEmails(const std::deque& e endInsertRows(); } } - -void UI::VCard::EMailsModel::revertPreferred(quint32 row) -{ - setData(createIndex(row, 2), !isPreferred(row)); -} - -QString UI::VCard::EMailsModel::getEmail(quint32 row) const -{ - return deque[row].address; -} diff --git a/ui/widgets/vcard/emailsmodel.h b/ui/models/info/emails.h similarity index 87% rename from ui/widgets/vcard/emailsmodel.h rename to ui/models/info/emails.h index bafbe9f..bb05a5c 100644 --- a/ui/widgets/vcard/emailsmodel.h +++ b/ui/models/info/emails.h @@ -16,8 +16,8 @@ * along with this program. If not, see . */ -#ifndef UI_VCARD_EMAILSMODEL_H -#define UI_VCARD_EMAILSMODEL_H +#ifndef MODELS_EMAILS_H +#define MODELS_EMAILS_H #include #include @@ -26,14 +26,12 @@ #include "shared/vcard.h" -namespace UI { -namespace VCard { +namespace Models { -class EMailsModel : public QAbstractTableModel -{ +class EMails : public QAbstractTableModel { Q_OBJECT public: - EMailsModel(bool edit = false, QObject *parent = nullptr); + EMails(bool edit = false, QObject *parent = nullptr); int rowCount(const QModelIndex& parent = QModelIndex()) const override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; @@ -59,6 +57,6 @@ private: bool dropPrefered(); }; -}} +} -#endif // UI_VCARD_EMAILSMODEL_H +#endif // MODELS_EMAILS_H diff --git a/ui/models/info/omemo/CMakeLists.txt b/ui/models/info/omemo/CMakeLists.txt new file mode 100644 index 0000000..166ca76 --- /dev/null +++ b/ui/models/info/omemo/CMakeLists.txt @@ -0,0 +1,4 @@ +target_sources(squawk PRIVATE + keys.cpp + keys.h +) diff --git a/ui/widgets/vcard/omemo/keysmodel.cpp b/ui/models/info/omemo/keys.cpp similarity index 80% rename from ui/widgets/vcard/omemo/keysmodel.cpp rename to ui/models/info/omemo/keys.cpp index 1488370..fa753c0 100644 --- a/ui/widgets/vcard/omemo/keysmodel.cpp +++ b/ui/models/info/omemo/keys.cpp @@ -14,23 +14,20 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#include "keysmodel.h" +#include "keys.h" -const QHash UI::KeysModel::roles = { +const QHash Models::Keys::roles = { {Label, "label"}, {FingerPrint, "fingerPrint"}, {TrustLevel, "trustLevel"} }; -UI::KeysModel::KeysModel(QObject* parent): +Models::Keys::Keys(QObject* parent): QAbstractListModel(parent), keys(), - modified() -{ + modified() {} -} - -UI::KeysModel::~KeysModel() { +Models::Keys::~Keys() { for (Shared::KeyInfo* key : keys) { delete key; } @@ -40,7 +37,7 @@ UI::KeysModel::~KeysModel() { } } -std::deque UI::KeysModel::modifiedKeys() const { +std::deque Models::Keys::modifiedKeys() const { std::deque response(modified.size()); int i = 0; @@ -52,13 +49,13 @@ std::deque UI::KeysModel::modifiedKeys() const { return response; } -void UI::KeysModel::addKey(const Shared::KeyInfo& info) { +void Models::Keys::addKey(const Shared::KeyInfo& info) { beginInsertRows(QModelIndex(), keys.size(), keys.size()); keys.push_back(new Shared::KeyInfo(info)); endInsertRows(); } -QVariant UI::KeysModel::data(const QModelIndex& index, int role) const { +QVariant Models::Keys::data(const QModelIndex& index, int role) const { int i = index.row(); const Shared::KeyInfo* info; bool dirty; @@ -94,13 +91,13 @@ QVariant UI::KeysModel::data(const QModelIndex& index, int role) const { return answer; } -int UI::KeysModel::rowCount(const QModelIndex& parent) const { +int Models::Keys::rowCount(const QModelIndex& parent) const { return keys.size(); } -QHash UI::KeysModel::roleNames() const {return roles;} +QHash Models::Keys::roleNames() const {return roles;} -QModelIndex UI::KeysModel::index(int row, int column, const QModelIndex& parent) const { +QModelIndex Models::Keys::index(int row, int column, const QModelIndex& parent) const { if (!hasIndex(row, column, parent)) { return QModelIndex(); } @@ -108,7 +105,7 @@ QModelIndex UI::KeysModel::index(int row, int column, const QModelIndex& parent) return createIndex(row, column, keys[row]); } -void UI::KeysModel::revertKey(int row) { +void Models::Keys::revertKey(int row) { std::map::const_iterator itr = modified.find(row); if (itr != modified.end()) { modified.erase(itr); @@ -117,7 +114,7 @@ void UI::KeysModel::revertKey(int row) { } } -void UI::KeysModel::setTrustLevel(int row, Shared::TrustLevel level) { +void Models::Keys::setTrustLevel(int row, Shared::TrustLevel level) { std::map::const_iterator itr = modified.find(row); Shared::KeyInfo* info; if (itr == modified.end()) { @@ -134,7 +131,7 @@ void UI::KeysModel::setTrustLevel(int row, Shared::TrustLevel level) { info->trustLevel = level; QModelIndex index = createIndex(row, 0, info); - dataChanged(index, index, {KeysModel::Dirty}); + dataChanged(index, index, {Keys::Dirty}); } diff --git a/ui/widgets/vcard/omemo/keysmodel.h b/ui/models/info/omemo/keys.h similarity index 89% rename from ui/widgets/vcard/omemo/keysmodel.h rename to ui/models/info/omemo/keys.h index e1a7606..2710bab 100644 --- a/ui/widgets/vcard/omemo/keysmodel.h +++ b/ui/models/info/omemo/keys.h @@ -14,23 +14,23 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#ifndef UI_KEYSMODEL_H -#define UI_KEYSMODEL_H +#ifndef MODELS_KEYS_H +#define MODELS_KEYS_H #include #include -namespace UI { +namespace Models { /** * @todo write docs */ -class KeysModel : public QAbstractListModel +class Keys : public QAbstractListModel { public: - KeysModel(QObject *parent = nullptr); - ~KeysModel(); + Keys(QObject *parent = nullptr); + ~Keys(); void addKey(const Shared::KeyInfo& info); @@ -64,4 +64,4 @@ private: } -#endif // UI_KEYSMODEL_H +#endif // MODELS_KEYS_H diff --git a/ui/widgets/vcard/phonesmodel.cpp b/ui/models/info/phones.cpp similarity index 83% rename from ui/widgets/vcard/phonesmodel.cpp rename to ui/models/info/phones.cpp index d3cace8..7c3b04f 100644 --- a/ui/widgets/vcard/phonesmodel.cpp +++ b/ui/models/info/phones.cpp @@ -16,30 +16,30 @@ * along with this program. If not, see . */ -#include "phonesmodel.h" +#include "phones.h" #include "shared/icons.h" #include -UI::VCard::PhonesModel::PhonesModel(bool p_edit, QObject* parent): +Models::Phones::Phones(bool p_edit, QObject* parent): QAbstractTableModel(parent), edit(p_edit), - deque() -{ + deque() {} + +int Models::Phones::columnCount(const QModelIndex& parent) const { + return 4;} + +int Models::Phones::rowCount(const QModelIndex& parent) const { + return deque.size();} + +void Models::Phones::revertPreferred(quint32 row) { + setData(createIndex(row, 3), !isPreferred(row)); } -int UI::VCard::PhonesModel::columnCount(const QModelIndex& parent) const -{ - return 4; -} +QString Models::Phones::getPhone(quint32 row) const { + return deque[row].number;} -int UI::VCard::PhonesModel::rowCount(const QModelIndex& parent) const -{ - return deque.size(); -} - -QVariant UI::VCard::PhonesModel::data(const QModelIndex& index, int role) const -{ +QVariant Models::Phones::data(const QModelIndex& index, int role) const { if (index.isValid()) { int col = index.column(); switch (col) { @@ -92,16 +92,14 @@ QVariant UI::VCard::PhonesModel::data(const QModelIndex& index, int role) const return QVariant(); } -QModelIndex UI::VCard::PhonesModel::addNewEmptyLine() -{ +QModelIndex Models::Phones::addNewEmptyLine() { beginInsertRows(QModelIndex(), deque.size(), deque.size()); deque.emplace_back("", Shared::VCard::Phone::other); endInsertRows(); return createIndex(deque.size() - 1, 0, &(deque.back())); } -Qt::ItemFlags UI::VCard::PhonesModel::flags(const QModelIndex& index) const -{ +Qt::ItemFlags Models::Phones::flags(const QModelIndex& index) const { Qt::ItemFlags f = QAbstractTableModel::flags(index); if (edit && index.column() != 3) { f = Qt::ItemIsEditable | f; @@ -109,8 +107,7 @@ Qt::ItemFlags UI::VCard::PhonesModel::flags(const QModelIndex& index) const return f; } -bool UI::VCard::PhonesModel::dropPrefered() -{ +bool Models::Phones::dropPrefered() { bool dropped = false; int i = 0; for (Shared::VCard::Phone& phone : deque) { @@ -125,15 +122,13 @@ bool UI::VCard::PhonesModel::dropPrefered() return dropped; } -void UI::VCard::PhonesModel::getPhones(std::deque& phones) const -{ +void Models::Phones::getPhones(std::deque& phones) const { for (const Shared::VCard::Phone& my : deque) { phones.emplace_back(my); } } -bool UI::VCard::PhonesModel::isPreferred(quint32 row) const -{ +bool Models::Phones::isPreferred(quint32 row) const { if (row < deque.size()) { return deque[row].prefered; } else { @@ -141,8 +136,7 @@ bool UI::VCard::PhonesModel::isPreferred(quint32 row) const } } -void UI::VCard::PhonesModel::removeLines(quint32 index, quint32 count) -{ +void Models::Phones::removeLines(quint32 index, quint32 count) { if (index < deque.size()) { quint32 maxCount = deque.size() - index; if (count > maxCount) { @@ -159,13 +153,7 @@ void UI::VCard::PhonesModel::removeLines(quint32 index, quint32 count) } } -void UI::VCard::PhonesModel::revertPreferred(quint32 row) -{ - setData(createIndex(row, 3), !isPreferred(row)); -} - -bool UI::VCard::PhonesModel::setData(const QModelIndex& index, const QVariant& value, int role) -{ +bool Models::Phones::setData(const QModelIndex& index, const QVariant& value, int role) { if (role == Qt::EditRole && checkIndex(index)) { Shared::VCard::Phone& item = deque[index.row()]; switch (index.column()) { @@ -204,8 +192,7 @@ bool UI::VCard::PhonesModel::setData(const QModelIndex& index, const QVariant& v return false; } -void UI::VCard::PhonesModel::setPhones(const std::deque& phones) -{ +void Models::Phones::setPhones(const std::deque& phones) { if (deque.size() > 0) { removeLines(0, deque.size()); } @@ -218,8 +205,3 @@ void UI::VCard::PhonesModel::setPhones(const std::deque& p endInsertRows(); } } - -QString UI::VCard::PhonesModel::getPhone(quint32 row) const -{ - return deque[row].number; -} diff --git a/ui/widgets/vcard/phonesmodel.h b/ui/models/info/phones.h similarity index 86% rename from ui/widgets/vcard/phonesmodel.h rename to ui/models/info/phones.h index 32d08b6..dec27d9 100644 --- a/ui/widgets/vcard/phonesmodel.h +++ b/ui/models/info/phones.h @@ -16,25 +16,19 @@ * along with this program. If not, see . */ -#ifndef UI_VCARD_PHONESMODEL_H -#define UI_VCARD_PHONESMODEL_H +#ifndef MODELS_PHONES_H +#define MODELS_PHONES_H #include #include #include "shared/vcard.h" -namespace UI { -namespace VCard { - -/** - * @todo write docs - */ -class PhonesModel : public QAbstractTableModel -{ +namespace Models { +class Phones : public QAbstractTableModel { Q_OBJECT public: - PhonesModel(bool edit = false, QObject *parent = nullptr); + Phones(bool edit = false, QObject *parent = nullptr); QVariant data(const QModelIndex& index, int role) const override; int columnCount(const QModelIndex& parent) const override; @@ -60,6 +54,6 @@ private: bool dropPrefered(); }; -}} +} -#endif // UI_VCARD_PHONESMODEL_H +#endif // MODELS_PHONES_H diff --git a/ui/widgets/CMakeLists.txt b/ui/widgets/CMakeLists.txt index 21d9504..be77db2 100644 --- a/ui/widgets/CMakeLists.txt +++ b/ui/widgets/CMakeLists.txt @@ -18,6 +18,7 @@ target_sources(squawk PRIVATE ) add_subdirectory(vcard) +add_subdirectory(info) add_subdirectory(messageline) add_subdirectory(settings) add_subdirectory(accounts) diff --git a/ui/widgets/info/CMakeLists.txt b/ui/widgets/info/CMakeLists.txt new file mode 100644 index 0000000..0029e84 --- /dev/null +++ b/ui/widgets/info/CMakeLists.txt @@ -0,0 +1,27 @@ +set(SOURCE_FILES + info.cpp + contactgeneral.cpp + contactcontacts.cpp +) + +set(UI_FILES + info.ui + contactgeneral.ui + contactcontacts.ui +) + +set(HEADER_FILES + info.h + contactgeneral.h + contactcontacts.h +) + +target_sources(squawk PRIVATE + ${SOURCE_FILES} + ${UI_FILES} + ${HEADER_FILES} +) + +if (WITH_OMEMO) + add_subdirectory(omemo) +endif() diff --git a/ui/widgets/info/contactcontacts.cpp b/ui/widgets/info/contactcontacts.cpp new file mode 100644 index 0000000..620d235 --- /dev/null +++ b/ui/widgets/info/contactcontacts.cpp @@ -0,0 +1,31 @@ +// Squawk messenger. +// Copyright (C) 2019 Yury Gubich +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "contactcontacts.h" +#include "ui_contactcontacts.h" + +UI::ContactContacts::ContactContacts(const QString& jid, QWidget* parent): + QWidget(parent), + m_ui(new Ui::ContactContacts) +{ + m_ui->setupUi(this); + + m_ui->jabberID->setText(jid); + m_ui->jabberID->setReadOnly(true); +} + +UI::ContactContacts::~ContactContacts() { +} diff --git a/ui/widgets/info/contactcontacts.h b/ui/widgets/info/contactcontacts.h new file mode 100644 index 0000000..7b26eed --- /dev/null +++ b/ui/widgets/info/contactcontacts.h @@ -0,0 +1,41 @@ +// Squawk messenger. +// Copyright (C) 2019 Yury Gubich +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef UI_WIDGETS_CONTACTCONTACTS_H +#define UI_WIDGETS_CONTACTCONTACTS_H + +#include +#include + +namespace UI { +namespace Ui +{ +class ContactContacts; +} + +class ContactContacts : public QWidget { + Q_OBJECT +public: + ContactContacts(const QString& jid, QWidget* parent = nullptr); + ~ContactContacts(); + +private: + QScopedPointer m_ui; +}; + +} + +#endif // UI_WIDGETS_CONTACTCONTACTS_H diff --git a/ui/widgets/info/contactcontacts.ui b/ui/widgets/info/contactcontacts.ui new file mode 100644 index 0000000..8104d50 --- /dev/null +++ b/ui/widgets/info/contactcontacts.ui @@ -0,0 +1,282 @@ + + + UI::ContactContacts + + + Contacts + + + + 0 + + + 0 + + + 6 + + + 0 + + + 0 + + + + + font: 600 24pt ; + + + Contact + + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + true + + + + + 0 + 0 + 545 + 544 + + + + + + + Qt::Horizontal + + + + + + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectRows + + + false + + + false + + + false + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + font: 600 16pt; + + + Addresses + + + Qt::AlignCenter + + + + + + + QAbstractItemView::SelectRows + + + false + + + false + + + false + + + + + + + font: 600 16pt; + + + E-Mail addresses + + + Qt::AlignCenter + + + + + + + Qt::AlignHCenter|Qt::AlignTop + + + + + + 150 + 0 + + + + + 300 + 16777215 + + + + + + + + Jabber ID + + + jabberID + + + + + + + + 150 + 0 + + + + + 300 + 16777215 + + + + + + + + Web site + + + url + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + font: 600 16pt; + + + Phone numbers + + + Qt::AlignCenter + + + + + + + QAbstractItemView::SelectRows + + + false + + + false + + + false + + + + + + + + + + + + diff --git a/ui/widgets/info/contactgeneral.cpp b/ui/widgets/info/contactgeneral.cpp new file mode 100644 index 0000000..62efe81 --- /dev/null +++ b/ui/widgets/info/contactgeneral.cpp @@ -0,0 +1,28 @@ +// Squawk messenger. +// Copyright (C) 2019 Yury Gubich +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "contactgeneral.h" +#include "ui_contactgeneral.h" + +UI::ContactGeneral::ContactGeneral(QWidget* parent): + QWidget(parent), + m_ui(new Ui::ContactGeneral) +{ + m_ui->setupUi(this); +} + +UI::ContactGeneral::~ContactGeneral() +{} diff --git a/ui/widgets/info/contactgeneral.h b/ui/widgets/info/contactgeneral.h new file mode 100644 index 0000000..5e116c6 --- /dev/null +++ b/ui/widgets/info/contactgeneral.h @@ -0,0 +1,41 @@ +// Squawk messenger. +// Copyright (C) 2019 Yury Gubich +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef UI_WIDGETS_CONTACTGENERAL_H +#define UI_WIDGETS_CONTACTGENERAL_H + +#include +#include + +namespace UI { +namespace Ui +{ +class ContactGeneral; +} + +class ContactGeneral : public QWidget{ + Q_OBJECT +public: + ContactGeneral(QWidget* parent = nullptr); + ~ContactGeneral(); + +private: + QScopedPointer m_ui; +}; + +} + +#endif // UI_WIDGETS_CONTACTGENERAL_H diff --git a/ui/widgets/info/contactgeneral.ui b/ui/widgets/info/contactgeneral.ui new file mode 100644 index 0000000..bb2b9e7 --- /dev/null +++ b/ui/widgets/info/contactgeneral.ui @@ -0,0 +1,448 @@ + + + UI::ContactGeneral + + + + 0 + 0 + 340 + 625 + + + + + 0 + + + 6 + + + 0 + + + 0 + + + 6 + + + + + + 0 + 0 + + + + font: 600 16pt; + + + Organization + + + Qt::AlignCenter + + + + + + + QLayout::SetDefaultConstraint + + + Qt::AlignHCenter|Qt::AlignTop + + + + + + 200 + 0 + + + + + 350 + 16777215 + + + + + + + + + 200 + 0 + + + + + 350 + 16777215 + + + + + + + + Middle name + + + middleName + + + + + + + First name + + + firstName + + + + + + + Last name + + + lastName + + + + + + + + 200 + 0 + + + + + 350 + 16777215 + + + + + + + + Nick name + + + nickName + + + + + + + + 200 + 0 + + + + + 350 + 16777215 + + + + + + + + Birthday + + + birthday + + + + + + + + + + + + Qt::AlignHCenter|Qt::AlignTop + + + + + Organization name + + + organizationName + + + + + + + + 200 + 0 + + + + + 350 + 16777215 + + + + + + + + Unit / Department + + + organizationDepartment + + + + + + + + 200 + 0 + + + + + 350 + 16777215 + + + + + + + + Role / Profession + + + organizationRole + + + + + + + + 200 + 0 + + + + + 350 + 16777215 + + + + + + + + Job title + + + organizationTitle + + + + + + + + 200 + 0 + + + + + 350 + 16777215 + + + + + + + + + + Qt::Horizontal + + + + + + + + + + + + Full name + + + fullName + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + + + + font: 600 24pt ; + + + General + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + font: 600 16pt; + + + QFrame::NoFrame + + + QFrame::Plain + + + Personal information + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + :/images/fallback/dark/big/user.svg:/images/fallback/dark/big/user.svg + + + + 0 + 0 + + + + QToolButton::InstantPopup + + + Qt::ToolButtonIconOnly + + + Qt::NoArrow + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + fullName + firstName + middleName + lastName + nickName + birthday + avatarButton + organizationName + organizationDepartment + organizationRole + organizationTitle + + + + + + diff --git a/ui/widgets/info/info.cpp b/ui/widgets/info/info.cpp new file mode 100644 index 0000000..eacab0f --- /dev/null +++ b/ui/widgets/info/info.cpp @@ -0,0 +1,30 @@ +// Squawk messenger. +// Copyright (C) 2019 Yury Gubich +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "info.h" +#include "ui_info.h" + +UI::Info::Info(const Shared::Info& info, QWidget* parent): + QWidget(parent), + m_ui(new Ui::Info()) +{ + m_ui->setupUi(this); + + +} + +UI::Info::~Info() +{} diff --git a/ui/widgets/info/info.h b/ui/widgets/info/info.h new file mode 100644 index 0000000..6858074 --- /dev/null +++ b/ui/widgets/info/info.h @@ -0,0 +1,45 @@ +// Squawk messenger. +// Copyright (C) 2019 Yury Gubich +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#ifndef UI_WIDGETS_INFO_H +#define UI_WIDGETS_INFO_H + +#include +#include + +#include + +#include "contactgeneral.h" + +namespace UI { +namespace Ui +{ +class Info; +} + +class Info : public QWidget { + Q_OBJECT +public: + Info(const Shared::Info& info, QWidget* parent = nullptr); + ~Info(); + +private: + QScopedPointer m_ui; +}; + +} + +#endif // UI_WIDGETS_INFO_H diff --git a/ui/widgets/info/info.ui b/ui/widgets/info/info.ui new file mode 100644 index 0000000..f600d8b --- /dev/null +++ b/ui/widgets/info/info.ui @@ -0,0 +1,137 @@ + + + UI::Info + + + + 0 + 0 + 400 + 300 + + + + + + 6 + + + 6 + + + 6 + + + 6 + + + + + font: 16pt + + + Contact john@dow.org card + + + Qt::AlignCenter + + + + + + + font: italic 8pt; + + + Received 12.07.2007 at 17.35 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + Qt::TabFocus + + + QTabWidget::North + + + QTabWidget::Rounded + + + 1 + + + Qt::ElideNone + + + true + + + false + + + + Description + + + + 0 + + + 6 + + + 0 + + + 0 + + + 6 + + + + + font: 600 24pt ; + + + Description + + + + + + + QFrame::StyledPanel + + + Qt::LinksAccessibleByMouse|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + + QDialogButtonBox::Close|QDialogButtonBox::Save + + + false + + + + + + + + diff --git a/ui/widgets/vcard/omemo/CMakeLists.txt b/ui/widgets/info/omemo/CMakeLists.txt similarity index 76% rename from ui/widgets/vcard/omemo/CMakeLists.txt rename to ui/widgets/info/omemo/CMakeLists.txt index e2ade51..f1dc4ed 100644 --- a/ui/widgets/vcard/omemo/CMakeLists.txt +++ b/ui/widgets/info/omemo/CMakeLists.txt @@ -2,8 +2,6 @@ target_sources(squawk PRIVATE omemo.cpp omemo.h omemo.ui - keysmodel.cpp - keysmodel.h keydelegate.cpp keydelegate.h ) diff --git a/ui/widgets/vcard/omemo/keydelegate.cpp b/ui/widgets/info/omemo/keydelegate.cpp similarity index 92% rename from ui/widgets/vcard/omemo/keydelegate.cpp rename to ui/widgets/info/omemo/keydelegate.cpp index d0023e5..fd687ad 100644 --- a/ui/widgets/vcard/omemo/keydelegate.cpp +++ b/ui/widgets/info/omemo/keydelegate.cpp @@ -18,7 +18,7 @@ #include #include -#include "keysmodel.h" +#include "ui/models/info/omemo/keys.h" #include constexpr uint8_t margin = 10; @@ -56,7 +56,7 @@ void UI::KeyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio painter->restore(); } - QVariant dirtyV = index.data(UI::KeysModel::Dirty); + QVariant dirtyV = index.data(Models::Keys::Dirty); if (dirtyV.isValid() && dirtyV.toBool()) { painter->save(); rect.setWidth(margin / 2); @@ -66,7 +66,7 @@ void UI::KeyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio } rect.adjust(margin, margin, -margin, -margin); - QVariant labelV = index.data(UI::KeysModel::Label); + QVariant labelV = index.data(Models::Keys::Label); if (labelV.isValid()) { QString label = labelV.toString(); if (label.size() > 0) { @@ -80,7 +80,7 @@ void UI::KeyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio } } - QVariant fingerPrintV = index.data(UI::KeysModel::FingerPrint); + QVariant fingerPrintV = index.data(Models::Keys::FingerPrint); if (fingerPrintV.isValid()) { painter->save(); painter->setFont(fingerPrintFont); @@ -111,7 +111,7 @@ void UI::KeyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio } - QVariant lastV = index.data(UI::KeysModel::LastInteraction); + QVariant lastV = index.data(Models::Keys::LastInteraction); if (lastV.isValid()) { QDateTime last = lastV.toDateTime(); if (last.isValid()) { @@ -125,7 +125,7 @@ void UI::KeyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio } } - QVariant levelV = index.data(UI::KeysModel::TrustLevel); + QVariant levelV = index.data(Models::Keys::TrustLevel); if (levelV.isValid()) { Shared::TrustLevel level = static_cast(levelV.toUInt()); QString levelName = Shared::Global::getName(level); @@ -150,7 +150,7 @@ QSize UI::KeyDelegate::sizeHint(const QStyleOptionViewItem& option, const QModel int mw = margin * 2; int width = 0; - QVariant labelV = index.data(UI::KeysModel::Label); + QVariant labelV = index.data(Models::Keys::Label); if (labelV.isValid()) { QString label = labelV.toString(); if (label.size() > 0) { @@ -159,7 +159,7 @@ QSize UI::KeyDelegate::sizeHint(const QStyleOptionViewItem& option, const QModel } } - QVariant fingerPrintV = index.data(UI::KeysModel::FingerPrint); + QVariant fingerPrintV = index.data(Models::Keys::FingerPrint); if (fingerPrintV.isValid()) { QString hex = fingerPrintV.toByteArray().toHex(); uint8_t parts = hex.size() / partSize; @@ -177,7 +177,7 @@ QSize UI::KeyDelegate::sizeHint(const QStyleOptionViewItem& option, const QModel width = std::max(width, firstLine * fingerPrintMetrics.horizontalAdvance(hex, partSize) + (firstLine - 1) * spaceWidth); width += 1; //there is a mistake somewhere, this the cheapest way to compensate it } - QVariant lastV = index.data(UI::KeysModel::LastInteraction); + QVariant lastV = index.data(Models::Keys::LastInteraction); if (lastV.isValid()) { QDateTime last = lastV.toDateTime(); if (last.isValid()) { @@ -187,7 +187,7 @@ QSize UI::KeyDelegate::sizeHint(const QStyleOptionViewItem& option, const QModel } } - QVariant levelV = index.data(UI::KeysModel::TrustLevel); + QVariant levelV = index.data(Models::Keys::TrustLevel); if (levelV.isValid()) { Shared::TrustLevel level = static_cast(levelV.toUInt()); QString levelName = Shared::Global::getName(level); diff --git a/ui/widgets/vcard/omemo/keydelegate.h b/ui/widgets/info/omemo/keydelegate.h similarity index 100% rename from ui/widgets/vcard/omemo/keydelegate.h rename to ui/widgets/info/omemo/keydelegate.h diff --git a/ui/widgets/vcard/omemo/omemo.cpp b/ui/widgets/info/omemo/omemo.cpp similarity index 90% rename from ui/widgets/vcard/omemo/omemo.cpp rename to ui/widgets/info/omemo/omemo.cpp index 3a5ab73..16414ee 100644 --- a/ui/widgets/vcard/omemo/omemo.cpp +++ b/ui/widgets/info/omemo/omemo.cpp @@ -71,13 +71,13 @@ void Omemo::onActiveKeysContextMenu(const QPoint& pos) { contextMenu->clear(); QModelIndex index = m_ui->keysView->indexAt(pos); if (index.isValid()) { - QVariant dirtyV = index.data(UI::KeysModel::Dirty); + QVariant dirtyV = index.data(Models::Keys::Dirty); if (dirtyV.isValid() && dirtyV.toBool()) { QAction* rev = contextMenu->addAction(Shared::icon("clean"), tr("Revert changes")); - connect(rev, &QAction::triggered, std::bind(&UI::KeysModel::revertKey, &keysModel, index.row())); + connect(rev, &QAction::triggered, std::bind(&Models::Keys::revertKey, &keysModel, index.row())); } - QVariant levelV = index.data(UI::KeysModel::TrustLevel); + QVariant levelV = index.data(Models::Keys::TrustLevel); if (levelV.isValid()) { Shared::TrustLevel level = static_cast(levelV.toUInt()); if (level == Shared::TrustLevel::undecided || @@ -86,7 +86,7 @@ void Omemo::onActiveKeysContextMenu(const QPoint& pos) { ) { QAction* rev = contextMenu->addAction(Shared::icon("favorite"), tr("Trust")); connect(rev, &QAction::triggered, - std::bind(&UI::KeysModel::setTrustLevel, &keysModel, + std::bind(&Models::Keys::setTrustLevel, &keysModel, index.row(), Shared::TrustLevel::manuallyTrusted ) ); @@ -99,7 +99,7 @@ void Omemo::onActiveKeysContextMenu(const QPoint& pos) { ) { QAction* rev = contextMenu->addAction(Shared::icon("unfavorite"), tr("Distrust")); connect(rev, &QAction::triggered, - std::bind(&UI::KeysModel::setTrustLevel, &keysModel, + std::bind(&Models::Keys::setTrustLevel, &keysModel, index.row(), Shared::TrustLevel::manuallyDistrusted ) ); diff --git a/ui/widgets/vcard/omemo/omemo.h b/ui/widgets/info/omemo/omemo.h similarity index 92% rename from ui/widgets/vcard/omemo/omemo.h rename to ui/widgets/info/omemo/omemo.h index 59e3dac..7c6b5a1 100644 --- a/ui/widgets/vcard/omemo/omemo.h +++ b/ui/widgets/info/omemo/omemo.h @@ -21,7 +21,7 @@ #include #include -#include "keysmodel.h" +#include "ui/models/info/omemo/keys.h" #include "keydelegate.h" #include "shared/icons.h" @@ -46,8 +46,8 @@ private: QScopedPointer m_ui; UI::KeyDelegate keysDelegate; UI::KeyDelegate unusedKeysDelegate; - UI::KeysModel keysModel; - UI::KeysModel unusedKeysModel; + Models::Keys keysModel; + Models::Keys unusedKeysModel; QMenu* contextMenu; }; diff --git a/ui/widgets/vcard/omemo/omemo.ui b/ui/widgets/info/omemo/omemo.ui similarity index 100% rename from ui/widgets/vcard/omemo/omemo.ui rename to ui/widgets/info/omemo/omemo.ui diff --git a/ui/widgets/room.h b/ui/widgets/room.h index 3f74e4e..3d231b8 100644 --- a/ui/widgets/room.h +++ b/ui/widgets/room.h @@ -20,7 +20,7 @@ #define ROOM_H #include "conversation.h" -#include "../models/room.h" +#include "ui/models/room.h" /** * @todo write docs diff --git a/ui/widgets/vcard/CMakeLists.txt b/ui/widgets/vcard/CMakeLists.txt index c37f4c6..5dca28d 100644 --- a/ui/widgets/vcard/CMakeLists.txt +++ b/ui/widgets/vcard/CMakeLists.txt @@ -1,13 +1,5 @@ target_sources(squawk PRIVATE - emailsmodel.cpp - emailsmodel.h - phonesmodel.cpp - phonesmodel.h vcard.cpp vcard.h vcard.ui ) - -if (WITH_OMEMO) - add_subdirectory(omemo) -endif() diff --git a/ui/widgets/vcard/vcard.cpp b/ui/widgets/vcard/vcard.cpp index a3e877b..d16aa83 100644 --- a/ui/widgets/vcard/vcard.cpp +++ b/ui/widgets/vcard/vcard.cpp @@ -235,10 +235,10 @@ void VCard::onContextMenu(const QPoint& point) { int row = sm->selectedRows().at(0).row(); if (emails.isPreferred(row)) { QAction* rev = contextMenu->addAction(Shared::icon("unfavorite"), tr("Unset this email as preferred")); - connect(rev, &QAction::triggered, std::bind(&UI::VCard::EMailsModel::revertPreferred, &emails, row)); + connect(rev, &QAction::triggered, std::bind(&Models::EMails::revertPreferred, &emails, row)); } else { QAction* rev = contextMenu->addAction(Shared::icon("favorite"), tr("Set this email as preferred")); - connect(rev, &QAction::triggered, std::bind(&UI::VCard::EMailsModel::revertPreferred, &emails, row)); + connect(rev, &QAction::triggered, std::bind(&Models::EMails::revertPreferred, &emails, row)); } } @@ -263,10 +263,10 @@ void VCard::onContextMenu(const QPoint& point) { int row = sm->selectedRows().at(0).row(); if (phones.isPreferred(row)) { QAction* rev = contextMenu->addAction(Shared::icon("view-media-favorite"), tr("Unset this phone as preferred")); - connect(rev, &QAction::triggered, std::bind(&UI::VCard::PhonesModel::revertPreferred, &phones, row)); + connect(rev, &QAction::triggered, std::bind(&Models::Phones::revertPreferred, &phones, row)); } else { QAction* rev = contextMenu->addAction(Shared::icon("favorite"), tr("Set this phone as preferred")); - connect(rev, &QAction::triggered, std::bind(&UI::VCard::PhonesModel::revertPreferred, &phones, row)); + connect(rev, &QAction::triggered, std::bind(&Models::Phones::revertPreferred, &phones, row)); } } diff --git a/ui/widgets/vcard/vcard.h b/ui/widgets/vcard/vcard.h index 82b7d53..7019797 100644 --- a/ui/widgets/vcard/vcard.h +++ b/ui/widgets/vcard/vcard.h @@ -37,13 +37,13 @@ #include #include "shared/vcard.h" -#include "emailsmodel.h" -#include "phonesmodel.h" +#include "ui/models/info/emails.h" +#include "ui/models/info/phones.h" #include "ui/utils/progress.h" #include "ui/utils/comboboxdelegate.h" #ifdef WITH_OMEMO -#include "omemo/omemo.h" +#include "ui/widgets/info/omemo/omemo.h" #endif namespace Ui @@ -92,8 +92,8 @@ private: QLabel* progressLabel; QWidget* overlay; QMenu* contextMenu; - UI::VCard::EMailsModel emails; - UI::VCard::PhonesModel phones; + Models::EMails emails; + Models::Phones phones; ComboboxDelegate* roleDelegate; ComboboxDelegate* phoneTypeDelegate; #ifdef WITH_OMEMO