started refactoring of the VCard UI

This commit is contained in:
Blue 2023-02-01 18:56:00 +03:00
parent bb304ce774
commit 4af16b75bf
Signed by untrusted user: blue
GPG Key ID: 9B203B252A63EE38
32 changed files with 1250 additions and 166 deletions

View File

@ -16,13 +16,25 @@
#include "info.h" #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(): Shared::Info::Info():
jid(),
editable(false),
vcard(), vcard(),
activeKeys(), activeKeys(),
inactiveKeys() inactiveKeys()
{} {}
Shared::Info::Info(const Shared::Info& other): Shared::Info::Info(const Shared::Info& other):
jid(other.jid),
editable(other.editable),
vcard(other.vcard), vcard(other.vcard),
activeKeys(other.activeKeys), activeKeys(other.activeKeys),
inactiveKeys(other.inactiveKeys) inactiveKeys(other.inactiveKeys)

View File

@ -33,9 +33,12 @@ namespace Shared {
class Info { class Info {
public: public:
Info(); Info();
Info(const QString& jid, bool editable = false);
Info(const Info& other); Info(const Info& other);
~Info(); ~Info();
QString jid;
bool editable;
VCard vcard; VCard vcard;
std::list<KeyInfo> activeKeys; std::list<KeyInfo> activeKeys;
std::list<KeyInfo> inactiveKeys; std::list<KeyInfo> inactiveKeys;

View File

@ -24,3 +24,5 @@ target_sources(squawk PRIVATE
roster.cpp roster.cpp
roster.h roster.h
) )
add_subdirectory(info)

View File

@ -0,0 +1,10 @@
target_sources(squawk PRIVATE
emails.cpp
emails.h
phones.cpp
phones.h
)
if (WITH_OMEMO)
add_subdirectory(omemo)
endif()

View File

@ -16,30 +16,29 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "emailsmodel.h" #include "emails.h"
#include "shared/icons.h" #include "shared/icons.h"
#include <QCoreApplication> #include <QCoreApplication>
UI::VCard::EMailsModel::EMailsModel(bool p_edit, QObject* parent): Models::EMails::EMails(bool p_edit, QObject* parent):
QAbstractTableModel(parent), QAbstractTableModel(parent),
edit(p_edit), edit(p_edit),
deque() deque() {}
{
}
int UI::VCard::EMailsModel::columnCount(const QModelIndex& parent) const int Models::EMails::columnCount(const QModelIndex& parent) const {
{ return 3;}
return 3;
}
int UI::VCard::EMailsModel::rowCount(const QModelIndex& parent) const int Models::EMails::rowCount(const QModelIndex& parent) const {
{ return deque.size();}
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()) { if (index.isValid()) {
int col = index.column(); int col = index.column();
switch (col) { switch (col) {
@ -82,8 +81,7 @@ QVariant UI::VCard::EMailsModel::data(const QModelIndex& index, int role) const
return QVariant(); 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); Qt::ItemFlags f = QAbstractTableModel::flags(index);
if (edit && index.column() != 2) { if (edit && index.column() != 2) {
f = Qt::ItemIsEditable | f; f = Qt::ItemIsEditable | f;
@ -91,8 +89,7 @@ Qt::ItemFlags UI::VCard::EMailsModel::flags(const QModelIndex& index) const
return f; 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)) { if (role == Qt::EditRole && checkIndex(index)) {
Shared::VCard::Email& item = deque[index.row()]; Shared::VCard::Email& item = deque[index.row()];
switch (index.column()) { 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; bool dropped = false;
int i = 0; int i = 0;
for (Shared::VCard::Email& email : deque) { for (Shared::VCard::Email& email : deque) {
@ -140,16 +136,14 @@ bool UI::VCard::EMailsModel::dropPrefered()
return dropped; return dropped;
} }
QModelIndex UI::VCard::EMailsModel::addNewEmptyLine() QModelIndex Models::EMails::addNewEmptyLine() {
{
beginInsertRows(QModelIndex(), deque.size(), deque.size()); beginInsertRows(QModelIndex(), deque.size(), deque.size());
deque.emplace_back(""); deque.emplace_back("");
endInsertRows(); endInsertRows();
return createIndex(deque.size() - 1, 0, &(deque.back())); 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()) { if (row < deque.size()) {
return deque[row].prefered; return deque[row].prefered;
} else { } 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()) { if (index < deque.size()) {
quint32 maxCount = deque.size() - index; quint32 maxCount = deque.size() - index;
if (count > maxCount) { if (count > maxCount) {
@ -175,15 +168,13 @@ void UI::VCard::EMailsModel::removeLines(quint32 index, quint32 count)
} }
} }
void UI::VCard::EMailsModel::getEmails(std::deque<Shared::VCard::Email>& emails) const void Models::EMails::getEmails(std::deque<Shared::VCard::Email>& emails) const {
{
for (const Shared::VCard::Email& my : deque) { for (const Shared::VCard::Email& my : deque) {
emails.emplace_back(my); emails.emplace_back(my);
} }
} }
void UI::VCard::EMailsModel::setEmails(const std::deque<Shared::VCard::Email>& emails) void Models::EMails::setEmails(const std::deque<Shared::VCard::Email>& emails) {
{
if (deque.size() > 0) { if (deque.size() > 0) {
removeLines(0, deque.size()); removeLines(0, deque.size());
} }
@ -196,13 +187,3 @@ void UI::VCard::EMailsModel::setEmails(const std::deque<Shared::VCard::Email>& e
endInsertRows(); 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;
}

View File

@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UI_VCARD_EMAILSMODEL_H #ifndef MODELS_EMAILS_H
#define UI_VCARD_EMAILSMODEL_H #define MODELS_EMAILS_H
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include <QIcon> #include <QIcon>
@ -26,14 +26,12 @@
#include "shared/vcard.h" #include "shared/vcard.h"
namespace UI { namespace Models {
namespace VCard {
class EMailsModel : public QAbstractTableModel class EMails : public QAbstractTableModel {
{
Q_OBJECT Q_OBJECT
public: public:
EMailsModel(bool edit = false, QObject *parent = nullptr); EMails(bool edit = false, QObject *parent = nullptr);
int rowCount(const QModelIndex& parent = QModelIndex()) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override; int columnCount(const QModelIndex& parent = QModelIndex()) const override;
@ -59,6 +57,6 @@ private:
bool dropPrefered(); bool dropPrefered();
}; };
}} }
#endif // UI_VCARD_EMAILSMODEL_H #endif // MODELS_EMAILS_H

View File

@ -0,0 +1,4 @@
target_sources(squawk PRIVATE
keys.cpp
keys.h
)

View File

@ -14,23 +14,20 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "keysmodel.h" #include "keys.h"
const QHash<int, QByteArray> UI::KeysModel::roles = { const QHash<int, QByteArray> Models::Keys::roles = {
{Label, "label"}, {Label, "label"},
{FingerPrint, "fingerPrint"}, {FingerPrint, "fingerPrint"},
{TrustLevel, "trustLevel"} {TrustLevel, "trustLevel"}
}; };
UI::KeysModel::KeysModel(QObject* parent): Models::Keys::Keys(QObject* parent):
QAbstractListModel(parent), QAbstractListModel(parent),
keys(), keys(),
modified() modified() {}
{
} Models::Keys::~Keys() {
UI::KeysModel::~KeysModel() {
for (Shared::KeyInfo* key : keys) { for (Shared::KeyInfo* key : keys) {
delete key; delete key;
} }
@ -40,7 +37,7 @@ UI::KeysModel::~KeysModel() {
} }
} }
std::deque<Shared::KeyInfo> UI::KeysModel::modifiedKeys() const { std::deque<Shared::KeyInfo> Models::Keys::modifiedKeys() const {
std::deque<Shared::KeyInfo> response(modified.size()); std::deque<Shared::KeyInfo> response(modified.size());
int i = 0; int i = 0;
@ -52,13 +49,13 @@ std::deque<Shared::KeyInfo> UI::KeysModel::modifiedKeys() const {
return response; return response;
} }
void UI::KeysModel::addKey(const Shared::KeyInfo& info) { void Models::Keys::addKey(const Shared::KeyInfo& info) {
beginInsertRows(QModelIndex(), keys.size(), keys.size()); beginInsertRows(QModelIndex(), keys.size(), keys.size());
keys.push_back(new Shared::KeyInfo(info)); keys.push_back(new Shared::KeyInfo(info));
endInsertRows(); 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(); int i = index.row();
const Shared::KeyInfo* info; const Shared::KeyInfo* info;
bool dirty; bool dirty;
@ -94,13 +91,13 @@ QVariant UI::KeysModel::data(const QModelIndex& index, int role) const {
return answer; return answer;
} }
int UI::KeysModel::rowCount(const QModelIndex& parent) const { int Models::Keys::rowCount(const QModelIndex& parent) const {
return keys.size(); return keys.size();
} }
QHash<int, QByteArray> UI::KeysModel::roleNames() const {return roles;} QHash<int, QByteArray> 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)) { if (!hasIndex(row, column, parent)) {
return QModelIndex(); return QModelIndex();
} }
@ -108,7 +105,7 @@ QModelIndex UI::KeysModel::index(int row, int column, const QModelIndex& parent)
return createIndex(row, column, keys[row]); return createIndex(row, column, keys[row]);
} }
void UI::KeysModel::revertKey(int row) { void Models::Keys::revertKey(int row) {
std::map<int, Shared::KeyInfo*>::const_iterator itr = modified.find(row); std::map<int, Shared::KeyInfo*>::const_iterator itr = modified.find(row);
if (itr != modified.end()) { if (itr != modified.end()) {
modified.erase(itr); 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<int, Shared::KeyInfo*>::const_iterator itr = modified.find(row); std::map<int, Shared::KeyInfo*>::const_iterator itr = modified.find(row);
Shared::KeyInfo* info; Shared::KeyInfo* info;
if (itr == modified.end()) { if (itr == modified.end()) {
@ -134,7 +131,7 @@ void UI::KeysModel::setTrustLevel(int row, Shared::TrustLevel level) {
info->trustLevel = level; info->trustLevel = level;
QModelIndex index = createIndex(row, 0, info); QModelIndex index = createIndex(row, 0, info);
dataChanged(index, index, {KeysModel::Dirty}); dataChanged(index, index, {Keys::Dirty});
} }

View File

@ -14,23 +14,23 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef UI_KEYSMODEL_H #ifndef MODELS_KEYS_H
#define UI_KEYSMODEL_H #define MODELS_KEYS_H
#include <QAbstractListModel> #include <QAbstractListModel>
#include <shared/keyinfo.h> #include <shared/keyinfo.h>
namespace UI { namespace Models {
/** /**
* @todo write docs * @todo write docs
*/ */
class KeysModel : public QAbstractListModel class Keys : public QAbstractListModel
{ {
public: public:
KeysModel(QObject *parent = nullptr); Keys(QObject *parent = nullptr);
~KeysModel(); ~Keys();
void addKey(const Shared::KeyInfo& info); void addKey(const Shared::KeyInfo& info);
@ -64,4 +64,4 @@ private:
} }
#endif // UI_KEYSMODEL_H #endif // MODELS_KEYS_H

View File

@ -16,30 +16,30 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "phonesmodel.h" #include "phones.h"
#include "shared/icons.h" #include "shared/icons.h"
#include <QCoreApplication> #include <QCoreApplication>
UI::VCard::PhonesModel::PhonesModel(bool p_edit, QObject* parent): Models::Phones::Phones(bool p_edit, QObject* parent):
QAbstractTableModel(parent), QAbstractTableModel(parent),
edit(p_edit), 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 QString Models::Phones::getPhone(quint32 row) const {
{ return deque[row].number;}
return 4;
}
int UI::VCard::PhonesModel::rowCount(const QModelIndex& parent) const QVariant Models::Phones::data(const QModelIndex& index, int role) const {
{
return deque.size();
}
QVariant UI::VCard::PhonesModel::data(const QModelIndex& index, int role) const
{
if (index.isValid()) { if (index.isValid()) {
int col = index.column(); int col = index.column();
switch (col) { switch (col) {
@ -92,16 +92,14 @@ QVariant UI::VCard::PhonesModel::data(const QModelIndex& index, int role) const
return QVariant(); return QVariant();
} }
QModelIndex UI::VCard::PhonesModel::addNewEmptyLine() QModelIndex Models::Phones::addNewEmptyLine() {
{
beginInsertRows(QModelIndex(), deque.size(), deque.size()); beginInsertRows(QModelIndex(), deque.size(), deque.size());
deque.emplace_back("", Shared::VCard::Phone::other); deque.emplace_back("", Shared::VCard::Phone::other);
endInsertRows(); endInsertRows();
return createIndex(deque.size() - 1, 0, &(deque.back())); 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); Qt::ItemFlags f = QAbstractTableModel::flags(index);
if (edit && index.column() != 3) { if (edit && index.column() != 3) {
f = Qt::ItemIsEditable | f; f = Qt::ItemIsEditable | f;
@ -109,8 +107,7 @@ Qt::ItemFlags UI::VCard::PhonesModel::flags(const QModelIndex& index) const
return f; return f;
} }
bool UI::VCard::PhonesModel::dropPrefered() bool Models::Phones::dropPrefered() {
{
bool dropped = false; bool dropped = false;
int i = 0; int i = 0;
for (Shared::VCard::Phone& phone : deque) { for (Shared::VCard::Phone& phone : deque) {
@ -125,15 +122,13 @@ bool UI::VCard::PhonesModel::dropPrefered()
return dropped; return dropped;
} }
void UI::VCard::PhonesModel::getPhones(std::deque<Shared::VCard::Phone>& phones) const void Models::Phones::getPhones(std::deque<Shared::VCard::Phone>& phones) const {
{
for (const Shared::VCard::Phone& my : deque) { for (const Shared::VCard::Phone& my : deque) {
phones.emplace_back(my); phones.emplace_back(my);
} }
} }
bool UI::VCard::PhonesModel::isPreferred(quint32 row) const bool Models::Phones::isPreferred(quint32 row) const {
{
if (row < deque.size()) { if (row < deque.size()) {
return deque[row].prefered; return deque[row].prefered;
} else { } 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()) { if (index < deque.size()) {
quint32 maxCount = deque.size() - index; quint32 maxCount = deque.size() - index;
if (count > maxCount) { if (count > maxCount) {
@ -159,13 +153,7 @@ void UI::VCard::PhonesModel::removeLines(quint32 index, quint32 count)
} }
} }
void UI::VCard::PhonesModel::revertPreferred(quint32 row) bool Models::Phones::setData(const QModelIndex& index, const QVariant& value, int role) {
{
setData(createIndex(row, 3), !isPreferred(row));
}
bool UI::VCard::PhonesModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
if (role == Qt::EditRole && checkIndex(index)) { if (role == Qt::EditRole && checkIndex(index)) {
Shared::VCard::Phone& item = deque[index.row()]; Shared::VCard::Phone& item = deque[index.row()];
switch (index.column()) { switch (index.column()) {
@ -204,8 +192,7 @@ bool UI::VCard::PhonesModel::setData(const QModelIndex& index, const QVariant& v
return false; return false;
} }
void UI::VCard::PhonesModel::setPhones(const std::deque<Shared::VCard::Phone>& phones) void Models::Phones::setPhones(const std::deque<Shared::VCard::Phone>& phones) {
{
if (deque.size() > 0) { if (deque.size() > 0) {
removeLines(0, deque.size()); removeLines(0, deque.size());
} }
@ -218,8 +205,3 @@ void UI::VCard::PhonesModel::setPhones(const std::deque<Shared::VCard::Phone>& p
endInsertRows(); endInsertRows();
} }
} }
QString UI::VCard::PhonesModel::getPhone(quint32 row) const
{
return deque[row].number;
}

View File

@ -16,25 +16,19 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UI_VCARD_PHONESMODEL_H #ifndef MODELS_PHONES_H
#define UI_VCARD_PHONESMODEL_H #define MODELS_PHONES_H
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include <QIcon> #include <QIcon>
#include "shared/vcard.h" #include "shared/vcard.h"
namespace UI { namespace Models {
namespace VCard { class Phones : public QAbstractTableModel {
/**
* @todo write docs
*/
class PhonesModel : public QAbstractTableModel
{
Q_OBJECT Q_OBJECT
public: public:
PhonesModel(bool edit = false, QObject *parent = nullptr); Phones(bool edit = false, QObject *parent = nullptr);
QVariant data(const QModelIndex& index, int role) const override; QVariant data(const QModelIndex& index, int role) const override;
int columnCount(const QModelIndex& parent) const override; int columnCount(const QModelIndex& parent) const override;
@ -60,6 +54,6 @@ private:
bool dropPrefered(); bool dropPrefered();
}; };
}} }
#endif // UI_VCARD_PHONESMODEL_H #endif // MODELS_PHONES_H

View File

@ -18,6 +18,7 @@ target_sources(squawk PRIVATE
) )
add_subdirectory(vcard) add_subdirectory(vcard)
add_subdirectory(info)
add_subdirectory(messageline) add_subdirectory(messageline)
add_subdirectory(settings) add_subdirectory(settings)
add_subdirectory(accounts) add_subdirectory(accounts)

View File

@ -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()

View File

@ -0,0 +1,31 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// 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 <http://www.gnu.org/licenses/>.
#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() {
}

View File

@ -0,0 +1,41 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// 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 <http://www.gnu.org/licenses/>.
#ifndef UI_WIDGETS_CONTACTCONTACTS_H
#define UI_WIDGETS_CONTACTCONTACTS_H
#include <QWidget>
#include <QScopedPointer>
namespace UI {
namespace Ui
{
class ContactContacts;
}
class ContactContacts : public QWidget {
Q_OBJECT
public:
ContactContacts(const QString& jid, QWidget* parent = nullptr);
~ContactContacts();
private:
QScopedPointer<Ui::ContactContacts> m_ui;
};
}
#endif // UI_WIDGETS_CONTACTCONTACTS_H

View File

@ -0,0 +1,282 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UI::ContactContacts</class>
<widget class="QWidget" name="Contacts">
<attribute name="title">
<string>Contacts</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="contactHeading">
<property name="styleSheet">
<string notr="true">font: 600 24pt ;</string>
</property>
<property name="text">
<string>Contact</string>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="contactScrollArea">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>545</width>
<height>544</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3" columnstretch="1,3,1">
<item row="7" column="1">
<widget class="Line" name="phonesLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QTableView" name="emailsView">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item row="10" column="1">
<widget class="Line" name="addressesLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="12">
<spacer name="contactLeftSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="Line" name="contactFormLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="Line" name="emailsLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="11" column="1">
<spacer name="contactBottomSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="1">
<widget class="QLabel" name="addressesHeading">
<property name="styleSheet">
<string notr="true">font: 600 16pt;</string>
</property>
<property name="text">
<string>Addresses</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QTableView" name="phonesView">
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="emailsHeading">
<property name="styleSheet">
<string notr="true">font: 600 16pt;</string>
</property>
<property name="text">
<string>E-Mail addresses</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QFormLayout" name="contactForm">
<property name="formAlignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<item row="0" column="1">
<widget class="QLineEdit" name="jabberID">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="jabberIDLabel">
<property name="text">
<string>Jabber ID</string>
</property>
<property name="buddy">
<cstring>jabberID</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="url">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="urlLabel">
<property name="text">
<string>Web site</string>
</property>
<property name="buddy">
<cstring>url</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="2" rowspan="12">
<spacer name="contactRightSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1">
<widget class="QLabel" name="phenesHeading">
<property name="styleSheet">
<string notr="true">font: 600 16pt;</string>
</property>
<property name="text">
<string>Phone numbers</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QTableView" name="addressesView">
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<attribute name="horizontalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,28 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// 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 <http://www.gnu.org/licenses/>.
#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()
{}

View File

@ -0,0 +1,41 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// 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 <http://www.gnu.org/licenses/>.
#ifndef UI_WIDGETS_CONTACTGENERAL_H
#define UI_WIDGETS_CONTACTGENERAL_H
#include <QWidget>
#include <QScopedPointer>
namespace UI {
namespace Ui
{
class ContactGeneral;
}
class ContactGeneral : public QWidget{
Q_OBJECT
public:
ContactGeneral(QWidget* parent = nullptr);
~ContactGeneral();
private:
QScopedPointer<Ui::ContactGeneral> m_ui;
};
}
#endif // UI_WIDGETS_CONTACTGENERAL_H

View File

@ -0,0 +1,448 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UI::ContactGeneral</class>
<widget class="QWidget" name="General">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>625</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,2,2,1">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="6" column="1" colspan="2">
<widget class="QLabel" name="organizationHeading">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">font: 600 16pt;</string>
</property>
<property name="text">
<string>Organization</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QFormLayout" name="personalForm">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="formAlignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<item row="1" column="1">
<widget class="QLineEdit" name="middleName">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="firstName">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="middleNameLabel">
<property name="text">
<string>Middle name</string>
</property>
<property name="buddy">
<cstring>middleName</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="firstNameLabel">
<property name="text">
<string>First name</string>
</property>
<property name="buddy">
<cstring>firstName</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lastNameLabel">
<property name="text">
<string>Last name</string>
</property>
<property name="buddy">
<cstring>lastName</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lastName">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="nickNameLabel">
<property name="text">
<string>Nick name</string>
</property>
<property name="buddy">
<cstring>nickName</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="nickName">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="birthdayLabel">
<property name="text">
<string>Birthday</string>
</property>
<property name="buddy">
<cstring>birthday</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDateEdit" name="birthday"/>
</item>
</layout>
</item>
<item row="7" column="1" colspan="2">
<layout class="QFormLayout" name="organizationForm">
<property name="formAlignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="organizationNameLabel">
<property name="text">
<string>Organization name</string>
</property>
<property name="buddy">
<cstring>organizationName</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="organizationName">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="organizationDepartmentLabel">
<property name="text">
<string>Unit / Department</string>
</property>
<property name="buddy">
<cstring>organizationDepartment</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="organizationDepartment">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="roleLabel">
<property name="text">
<string>Role / Profession</string>
</property>
<property name="buddy">
<cstring>organizationRole</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="organizationRole">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="organizationTitleLabel">
<property name="text">
<string>Job title</string>
</property>
<property name="buddy">
<cstring>organizationTitle</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="organizationTitle">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="1" colspan="2">
<widget class="Line" name="organizationLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<layout class="QFormLayout" name="commonForm">
<item row="0" column="1">
<widget class="QLineEdit" name="fullName"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="fullNameLabel">
<property name="text">
<string>Full name</string>
</property>
<property name="buddy">
<cstring>fullName</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0" rowspan="7">
<spacer name="generalLeftHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1" colspan="2">
<widget class="Line" name="personalLine">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QLabel" name="generalHeading">
<property name="styleSheet">
<string notr="true">font: 600 24pt ;</string>
</property>
<property name="text">
<string>General</string>
</property>
</widget>
</item>
<item row="3" column="3" rowspan="7">
<spacer name="generalRightHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLabel" name="personalHeading">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">font: 600 16pt;</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Personal information</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="avatarButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="user">
<normaloff>:/images/fallback/dark/big/user.svg</normaloff>:/images/fallback/dark/big/user.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
<property name="arrowType">
<enum>Qt::NoArrow</enum>
</property>
</widget>
</item>
<item row="9" column="1" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
<tabstop>fullName</tabstop>
<tabstop>firstName</tabstop>
<tabstop>middleName</tabstop>
<tabstop>lastName</tabstop>
<tabstop>nickName</tabstop>
<tabstop>birthday</tabstop>
<tabstop>avatarButton</tabstop>
<tabstop>organizationName</tabstop>
<tabstop>organizationDepartment</tabstop>
<tabstop>organizationRole</tabstop>
<tabstop>organizationTitle</tabstop>
</tabstops>
<resources>
<include location="../../../resources/resources.qrc"/>
</resources>
<connections/>
</ui>

30
ui/widgets/info/info.cpp Normal file
View File

@ -0,0 +1,30 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// 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 <http://www.gnu.org/licenses/>.
#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()
{}

45
ui/widgets/info/info.h Normal file
View File

@ -0,0 +1,45 @@
// Squawk messenger.
// Copyright (C) 2019 Yury Gubich <blue@macaw.me>
//
// 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 <http://www.gnu.org/licenses/>.
#ifndef UI_WIDGETS_INFO_H
#define UI_WIDGETS_INFO_H
#include <QWidget>
#include <QScopedPointer>
#include <shared/info.h>
#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<Ui::Info> m_ui;
};
}
#endif // UI_WIDGETS_INFO_H

137
ui/widgets/info/info.ui Normal file
View File

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UI::Info</class>
<widget class="QWidget" name="UI::Info">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="title">
<property name="styleSheet">
<string notr="true">font: 16pt </string>
</property>
<property name="text">
<string notr="true">Contact john@dow.org card</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="receivingTimeLabel">
<property name="styleSheet">
<string notr="true">font: italic 8pt;</string>
</property>
<property name="text">
<string>Received 12.07.2007 at 17.35</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="tabPosition">
<enum>QTabWidget::North</enum>
</property>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
</property>
<property name="documentMode">
<bool>true</bool>
</property>
<property name="tabBarAutoHide">
<bool>false</bool>
</property>
<widget class="QWidget" name="Description">
<attribute name="title">
<string>Description</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="descriptionHeading">
<property name="styleSheet">
<string notr="true">font: 600 24pt ;</string>
</property>
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QTextEdit" name="description">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Save</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -2,8 +2,6 @@ target_sources(squawk PRIVATE
omemo.cpp omemo.cpp
omemo.h omemo.h
omemo.ui omemo.ui
keysmodel.cpp
keysmodel.h
keydelegate.cpp keydelegate.cpp
keydelegate.h keydelegate.h
) )

View File

@ -18,7 +18,7 @@
#include <QPainter> #include <QPainter>
#include <QDebug> #include <QDebug>
#include "keysmodel.h" #include "ui/models/info/omemo/keys.h"
#include <shared/global.h> #include <shared/global.h>
constexpr uint8_t margin = 10; constexpr uint8_t margin = 10;
@ -56,7 +56,7 @@ void UI::KeyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio
painter->restore(); painter->restore();
} }
QVariant dirtyV = index.data(UI::KeysModel::Dirty); QVariant dirtyV = index.data(Models::Keys::Dirty);
if (dirtyV.isValid() && dirtyV.toBool()) { if (dirtyV.isValid() && dirtyV.toBool()) {
painter->save(); painter->save();
rect.setWidth(margin / 2); rect.setWidth(margin / 2);
@ -66,7 +66,7 @@ void UI::KeyDelegate::paint(QPainter* painter, const QStyleOptionViewItem& optio
} }
rect.adjust(margin, margin, -margin, -margin); rect.adjust(margin, margin, -margin, -margin);
QVariant labelV = index.data(UI::KeysModel::Label); QVariant labelV = index.data(Models::Keys::Label);
if (labelV.isValid()) { if (labelV.isValid()) {
QString label = labelV.toString(); QString label = labelV.toString();
if (label.size() > 0) { 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()) { if (fingerPrintV.isValid()) {
painter->save(); painter->save();
painter->setFont(fingerPrintFont); 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()) { if (lastV.isValid()) {
QDateTime last = lastV.toDateTime(); QDateTime last = lastV.toDateTime();
if (last.isValid()) { 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()) { if (levelV.isValid()) {
Shared::TrustLevel level = static_cast<Shared::TrustLevel>(levelV.toUInt()); Shared::TrustLevel level = static_cast<Shared::TrustLevel>(levelV.toUInt());
QString levelName = Shared::Global::getName(level); QString levelName = Shared::Global::getName(level);
@ -150,7 +150,7 @@ QSize UI::KeyDelegate::sizeHint(const QStyleOptionViewItem& option, const QModel
int mw = margin * 2; int mw = margin * 2;
int width = 0; int width = 0;
QVariant labelV = index.data(UI::KeysModel::Label); QVariant labelV = index.data(Models::Keys::Label);
if (labelV.isValid()) { if (labelV.isValid()) {
QString label = labelV.toString(); QString label = labelV.toString();
if (label.size() > 0) { 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()) { if (fingerPrintV.isValid()) {
QString hex = fingerPrintV.toByteArray().toHex(); QString hex = fingerPrintV.toByteArray().toHex();
uint8_t parts = hex.size() / partSize; 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 = 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 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()) { if (lastV.isValid()) {
QDateTime last = lastV.toDateTime(); QDateTime last = lastV.toDateTime();
if (last.isValid()) { 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()) { if (levelV.isValid()) {
Shared::TrustLevel level = static_cast<Shared::TrustLevel>(levelV.toUInt()); Shared::TrustLevel level = static_cast<Shared::TrustLevel>(levelV.toUInt());
QString levelName = Shared::Global::getName(level); QString levelName = Shared::Global::getName(level);

View File

@ -71,13 +71,13 @@ void Omemo::onActiveKeysContextMenu(const QPoint& pos) {
contextMenu->clear(); contextMenu->clear();
QModelIndex index = m_ui->keysView->indexAt(pos); QModelIndex index = m_ui->keysView->indexAt(pos);
if (index.isValid()) { if (index.isValid()) {
QVariant dirtyV = index.data(UI::KeysModel::Dirty); QVariant dirtyV = index.data(Models::Keys::Dirty);
if (dirtyV.isValid() && dirtyV.toBool()) { if (dirtyV.isValid() && dirtyV.toBool()) {
QAction* rev = contextMenu->addAction(Shared::icon("clean"), tr("Revert changes")); 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()) { if (levelV.isValid()) {
Shared::TrustLevel level = static_cast<Shared::TrustLevel>(levelV.toUInt()); Shared::TrustLevel level = static_cast<Shared::TrustLevel>(levelV.toUInt());
if (level == Shared::TrustLevel::undecided || if (level == Shared::TrustLevel::undecided ||
@ -86,7 +86,7 @@ void Omemo::onActiveKeysContextMenu(const QPoint& pos) {
) { ) {
QAction* rev = contextMenu->addAction(Shared::icon("favorite"), tr("Trust")); QAction* rev = contextMenu->addAction(Shared::icon("favorite"), tr("Trust"));
connect(rev, &QAction::triggered, connect(rev, &QAction::triggered,
std::bind(&UI::KeysModel::setTrustLevel, &keysModel, std::bind(&Models::Keys::setTrustLevel, &keysModel,
index.row(), Shared::TrustLevel::manuallyTrusted index.row(), Shared::TrustLevel::manuallyTrusted
) )
); );
@ -99,7 +99,7 @@ void Omemo::onActiveKeysContextMenu(const QPoint& pos) {
) { ) {
QAction* rev = contextMenu->addAction(Shared::icon("unfavorite"), tr("Distrust")); QAction* rev = contextMenu->addAction(Shared::icon("unfavorite"), tr("Distrust"));
connect(rev, &QAction::triggered, connect(rev, &QAction::triggered,
std::bind(&UI::KeysModel::setTrustLevel, &keysModel, std::bind(&Models::Keys::setTrustLevel, &keysModel,
index.row(), Shared::TrustLevel::manuallyDistrusted index.row(), Shared::TrustLevel::manuallyDistrusted
) )
); );

View File

@ -21,7 +21,7 @@
#include <QScopedPointer> #include <QScopedPointer>
#include <QMenu> #include <QMenu>
#include "keysmodel.h" #include "ui/models/info/omemo/keys.h"
#include "keydelegate.h" #include "keydelegate.h"
#include "shared/icons.h" #include "shared/icons.h"
@ -46,8 +46,8 @@ private:
QScopedPointer<Ui::Omemo> m_ui; QScopedPointer<Ui::Omemo> m_ui;
UI::KeyDelegate keysDelegate; UI::KeyDelegate keysDelegate;
UI::KeyDelegate unusedKeysDelegate; UI::KeyDelegate unusedKeysDelegate;
UI::KeysModel keysModel; Models::Keys keysModel;
UI::KeysModel unusedKeysModel; Models::Keys unusedKeysModel;
QMenu* contextMenu; QMenu* contextMenu;
}; };

View File

@ -20,7 +20,7 @@
#define ROOM_H #define ROOM_H
#include "conversation.h" #include "conversation.h"
#include "../models/room.h" #include "ui/models/room.h"
/** /**
* @todo write docs * @todo write docs

View File

@ -1,13 +1,5 @@
target_sources(squawk PRIVATE target_sources(squawk PRIVATE
emailsmodel.cpp
emailsmodel.h
phonesmodel.cpp
phonesmodel.h
vcard.cpp vcard.cpp
vcard.h vcard.h
vcard.ui vcard.ui
) )
if (WITH_OMEMO)
add_subdirectory(omemo)
endif()

View File

@ -235,10 +235,10 @@ void VCard::onContextMenu(const QPoint& point) {
int row = sm->selectedRows().at(0).row(); int row = sm->selectedRows().at(0).row();
if (emails.isPreferred(row)) { if (emails.isPreferred(row)) {
QAction* rev = contextMenu->addAction(Shared::icon("unfavorite"), tr("Unset this email as preferred")); 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 { } else {
QAction* rev = contextMenu->addAction(Shared::icon("favorite"), tr("Set this email as preferred")); 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(); int row = sm->selectedRows().at(0).row();
if (phones.isPreferred(row)) { if (phones.isPreferred(row)) {
QAction* rev = contextMenu->addAction(Shared::icon("view-media-favorite"), tr("Unset this phone as preferred")); 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 { } else {
QAction* rev = contextMenu->addAction(Shared::icon("favorite"), tr("Set this phone as preferred")); 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));
} }
} }

View File

@ -37,13 +37,13 @@
#include <set> #include <set>
#include "shared/vcard.h" #include "shared/vcard.h"
#include "emailsmodel.h" #include "ui/models/info/emails.h"
#include "phonesmodel.h" #include "ui/models/info/phones.h"
#include "ui/utils/progress.h" #include "ui/utils/progress.h"
#include "ui/utils/comboboxdelegate.h" #include "ui/utils/comboboxdelegate.h"
#ifdef WITH_OMEMO #ifdef WITH_OMEMO
#include "omemo/omemo.h" #include "ui/widgets/info/omemo/omemo.h"
#endif #endif
namespace Ui namespace Ui
@ -92,8 +92,8 @@ private:
QLabel* progressLabel; QLabel* progressLabel;
QWidget* overlay; QWidget* overlay;
QMenu* contextMenu; QMenu* contextMenu;
UI::VCard::EMailsModel emails; Models::EMails emails;
UI::VCard::PhonesModel phones; Models::Phones phones;
ComboboxDelegate* roleDelegate; ComboboxDelegate* roleDelegate;
ComboboxDelegate* phoneTypeDelegate; ComboboxDelegate* phoneTypeDelegate;
#ifdef WITH_OMEMO #ifdef WITH_OMEMO