diff --git a/RingWinClient.pro b/RingWinClient.pro index 2bb81bc927ce0ec479bd21176748a730e07d76ae..2cf2624f7f90be0679c954220c08bb2b34697ec2 100644 --- a/RingWinClient.pro +++ b/RingWinClient.pro @@ -51,8 +51,6 @@ SOURCES += main.cpp\ utils.cpp \ wizarddialog.cpp \ windowscontactbackend.cpp \ - historydelegate.cpp \ - contactdelegate.cpp \ selectareadialog.cpp \ accountserializationadapter.cpp \ instantmessagingwidget.cpp \ @@ -86,8 +84,6 @@ HEADERS += mainwindow.h \ utils.h \ wizarddialog.h \ windowscontactbackend.h \ - historydelegate.h \ - contactdelegate.h \ selectareadialog.h \ accountserializationadapter.h \ instantmessagingwidget.h \ diff --git a/callwidget.cpp b/callwidget.cpp index 5dfe0d841aa4c9b1d5ac07cadcc8877abd31452b..c3c3c2732591948b26c1ab6a4dfbc163f1402afd 100644 --- a/callwidget.cpp +++ b/callwidget.cpp @@ -50,8 +50,6 @@ #include "contactpicker.h" #include "contactmethodpicker.h" #include "globalsystemtray.h" -#include "historydelegate.h" -#include "contactdelegate.h" #include "smartlistdelegate.h" #include "imdelegate.h" #include "pixbufmanipulator.h" @@ -113,59 +111,11 @@ CallWidget::CallWidget(QWidget* parent) : PersonModel::instance(). addCollection<WindowsContactBackend>(LoadOptions::FORCE_ENABLED); - CategorizedContactModel::instance().setSortAlphabetical(false); - CategorizedContactModel::instance().setUnreachableHidden(true); - ui->contactView->setModel(&CategorizedContactModel::instance()); - contactDelegate_ = new ContactDelegate(); - ui->contactView->setItemDelegate(contactDelegate_); - - CategorizedHistoryModel::instance(). - addCollection<LocalHistoryCollection>(LoadOptions::FORCE_ENABLED); - - ui->historyList->setModel(CategorizedHistoryModel::SortedProxy::instance().model()); - CategorizedHistoryModel::SortedProxy::instance().model()->sort(0, Qt::DescendingOrder); - ui->historyList->setHeaderHidden(true); - historyDelegate_ = new HistoryDelegate(); - ui->historyList->setItemDelegate(historyDelegate_); - - connect(CategorizedHistoryModel::SortedProxy::instance().model(), &QSortFilterProxyModel::layoutChanged, [=]() { - auto idx = CategorizedHistoryModel::SortedProxy::instance().model()->index(0,0); - if (idx.isValid()) - ui->historyList->setExpanded(idx, true); - }); - connect(ui->smartList, &QTreeView::entered, this, &CallWidget::on_entered); smartListDelegate_ = new SmartListDelegate(); ui->smartList->setSmartListItemDelegate(smartListDelegate_); - ui->historyList->setContextMenuPolicy(Qt::CustomContextMenu); - connect(ui->historyList, &QListView::customContextMenuRequested, [=](const QPoint& pos){ - if (ui->historyList->currentIndex().parent().isValid()) { - QPoint globalPos = ui->historyList->mapToGlobal(pos); - QMenu menu; - - ContactMethod* contactMethod = ui->historyList->currentIndex() - .data(static_cast<int>(Call::Role::ContactMethod)).value<ContactMethod*>(); - - auto copyAction = new QAction(tr("Copy number"), this); - menu.addAction(copyAction); - connect(copyAction, &QAction::triggered, [=]() { - QApplication::clipboard()->setText(contactMethod->uri()); - }); - if (not contactMethod->contact() || contactMethod->contact()->isPlaceHolder()) { - auto addExisting = new QAction(tr("Add to contact"), this); - menu.addAction(addExisting); - connect(addExisting, &QAction::triggered, [=]() { - ContactPicker contactPicker(contactMethod); - contactPicker.move(globalPos.x(), globalPos.y() - (contactPicker.height()/2)); - contactPicker.exec(); - }); - } - menu.exec(globalPos); - } - }); - findRingAccount(); setupOutOfCallIM(); setupSmartListMenu(); @@ -200,7 +150,6 @@ CallWidget::~CallWidget() { delete ui; delete menu_; - delete contactDelegate_; delete imDelegate_; delete pageAnim_; delete smartListDelegate_; @@ -485,50 +434,6 @@ CallWidget::atExit() { } -void -CallWidget::on_contactView_doubleClicked(const QModelIndex& index) -{ - if (not index.isValid()) - return; - - auto var = index.child(0,0).data( - static_cast<int>(Person::Role::Object)); - if (var.isValid()) { - Person* person = var.value<Person*>(); - ContactMethod* uri = nullptr; - if (person->phoneNumbers().size() == 1) { - uri = person->phoneNumbers().at(0); - } else if (person->phoneNumbers().size() > 1) { - ContactMethodPicker dlg(person->phoneNumbers()); - auto pos = QCursor::pos(); - dlg.move(pos.x(), pos.y()); - if (dlg.exec()) - uri = dlg.getSelected(); - } - if (uri) { - auto outCall = CallModel::instance().dialingCall(uri); - outCall->performAction(Call::Action::ACCEPT); - ui->mainTabMenu->setCurrentIndex(0); - ui->smartList->setFocus(); - } - } -} - -void -CallWidget::on_historyList_doubleClicked(const QModelIndex& index) -{ - if (not index.isValid()) - return; - - auto number = index.data(static_cast<int>(Call::Role::ContactMethod)).value<ContactMethod*>(); - if (number) { - auto outCall = CallModel::instance().dialingCall(number); - outCall->performAction(Call::Action::ACCEPT); - ui->mainTabMenu->setCurrentIndex(0); - ui->smartList->setFocus(); - } -} - void CallWidget::callStateToView(Call* value) { if (value) { @@ -662,18 +567,6 @@ CallWidget::settingsButtonClicked() emit NavigationRequested(ScreenEnum::ConfScreen); } -void -CallWidget::contactButtonClicked(bool checked) -{ - ui->mainTabMenu->setCurrentIndex(checked ? 1 : 0); -} - -void -CallWidget::historicButtonClicked(bool checked) -{ - ui->mainTabMenu->setCurrentIndex(checked ? 2 : 0); -} - void CallWidget::searchContactLineEditEntry(const URI &uri) { diff --git a/callwidget.h b/callwidget.h index 2ed1ca097599861aad2e7a6ba661b8443c963d69..8c826762f1b6678f948dba2139bc0edc20f08423 100644 --- a/callwidget.h +++ b/callwidget.h @@ -35,8 +35,6 @@ #include "categorizedhistorymodel.h" #include "media/textrecording.h" -class ContactDelegate; -class HistoryDelegate; class SmartListDelegate; class ImDelegate; class QPropertyAnimation; @@ -56,9 +54,7 @@ public: void findRingAccount(); public slots: - void contactButtonClicked(bool checked); void settingsButtonClicked(); - void historicButtonClicked(bool checked); void showIMOutOfCall(const QModelIndex& nodeIdx); void btnComBarVideoClicked(); @@ -72,10 +68,8 @@ public slots: private slots: void on_acceptButton_clicked(); void on_refuseButton_clicked(); - void on_contactView_doubleClicked(const QModelIndex& index); void on_cancelButton_clicked(); void on_smartList_doubleClicked(const QModelIndex& index); - void on_historyList_doubleClicked(const QModelIndex& index); void on_sendIMButton_clicked(); void on_imMessageEdit_returnPressed(); void on_contactMethodComboBox_currentIndexChanged(const QString& number); @@ -104,8 +98,6 @@ private: int outputVolume_; int inputVolume_; QMenu* menu_; - ContactDelegate* contactDelegate_; - HistoryDelegate* historyDelegate_; SmartListDelegate* smartListDelegate_; QPersistentModelIndex highLightedIndex_; ImDelegate* imDelegate_; diff --git a/callwidget.ui b/callwidget.ui index 0243c8b4255a1654cd4b93e9acd574f3505d7fa8..e257f888ad02eac8b37a3f96c6fc848e1d9002bd 100644 --- a/callwidget.ui +++ b/callwidget.ui @@ -359,66 +359,6 @@ </item> </layout> </widget> - <widget class="QWidget" name="mainTabMenuPage2"> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QListView" name="contactView"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> - <property name="horizontalScrollBarPolicy"> - <enum>Qt::ScrollBarAsNeeded</enum> - </property> - <property name="sizeAdjustPolicy"> - <enum>QAbstractScrollArea::AdjustIgnored</enum> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="mainTabMenuPage3"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QTreeView" name="historyList"/> - </item> - </layout> - </widget> </widget> </item> </layout> diff --git a/contactdelegate.cpp b/contactdelegate.cpp deleted file mode 100644 index 3ca7bdccc930a2425517b66ffa360c0f154334cc..0000000000000000000000000000000000000000 --- a/contactdelegate.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2015-2016 by Savoir-faire Linux * - * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>* - * * - * 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 "contactdelegate.h" - -#include "person.h" -#include "contactmethod.h" - -ContactDelegate::ContactDelegate(QObject *parent) - : QStyledItemDelegate(parent) -{ -} - - -void -ContactDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ - QStyleOptionViewItem opt = option; - initStyleOption(&opt, index); - - if (index.column() == 0) { - opt.text.clear(); - QStyle *style = opt.widget ? opt.widget->style() : QApplication::style(); - style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget); - QRect rect = opt.rect; - QPalette::ColorGroup cg = (opt.state & QStyle::State_Enabled) ? - QPalette::Normal : QPalette::Disabled; - if (cg == QPalette::Normal && !(opt.state & QStyle::State_Active)) - cg = QPalette::Inactive; - painter->setPen(opt.palette.color(cg, QPalette::Text)); - painter->setOpacity(1.0); - QVariant var_c = index.child(0,0).data( - static_cast<int>(Person::Role::Object)); - if (var_c.isValid()) { - Person *c = var_c.value<Person *>(); - painter->drawText(QRect(rect.left()+sizeImage_+5, rect.top(), - rect.width(), rect.height()/2), - opt.displayAlignment, c->formattedName()); - QVariant var_p = c->photo(); - if (var_p.isValid()) { - painter->drawImage(QRect(rect.left()+1, rect.top()+1, - sizeImage_, sizeImage_), - var_p.value<QImage>()); - } else { - QImage defaultImage(":images/account.png"); - painter->drawImage(QRect(rect.left(), rect.top(), - sizeImage_, sizeImage_), - defaultImage); - } - switch (c->phoneNumbers().size()) { - case 0: - break; - case 1: - { - QString number; - QVariant var_n = - c->phoneNumbers().first()->roleData(Qt::DisplayRole); - if (var_n.isValid()) - number = var_n.value<QString>(); - - painter->drawText(QRect(rect.left()+sizeImage_+5, - rect.top() + rect.height()/2, - rect.width(), rect.height()/2), - opt.displayAlignment, number); - break; - } - default: - painter->drawText(QRect(rect.left()+sizeImage_+5, - rect.top() + rect.height()/2, - rect.width(), rect.height()/2), - opt.displayAlignment, tr("<Multiple contact methods>")); - break; - } - } - } -} - -QSize -ContactDelegate::sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ - QSize result = QStyledItemDelegate::sizeHint(option, index); - auto height = (result.height()*2)+2; - if (height < sizeImage_) - height = sizeImage_; - result.setHeight(height); - return result; -} diff --git a/contactdelegate.h b/contactdelegate.h deleted file mode 100644 index 21b6e36bd83ba9512bc1307d49ad5a9d36067886..0000000000000000000000000000000000000000 --- a/contactdelegate.h +++ /dev/null @@ -1,40 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2015-2016 by Savoir-faire Linux * - * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>* - * * - * 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/>. * - **************************************************************************/ - -#pragma once - -#include <QObject> -#include <QString> -#include <QPainter> -#include <QApplication> -#include <QStyledItemDelegate> - -class ContactDelegate : public QStyledItemDelegate -{ - Q_OBJECT -public: - explicit ContactDelegate(QObject *parent = 0); - -protected: - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; - -private: - constexpr static int sizeImage_ = 48; -}; - diff --git a/historydelegate.cpp b/historydelegate.cpp deleted file mode 100644 index 46516f8396ae0d60b3f0d6563e9ee72d64431408..0000000000000000000000000000000000000000 --- a/historydelegate.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2015-2016 by Savoir-faire Linux * - * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>* - * * - * 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 "historydelegate.h" - -HistoryDelegate::HistoryDelegate(QObject *parent) : - QStyledItemDelegate(parent) -{ - -} - -void -HistoryDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ - QStyleOptionViewItem opt = option; - initStyleOption(&opt, index); - - if (index.column() == 0) { - auto name = index.model()->data(index, Qt::DisplayRole).toString(); - auto number = index.model()->data(index, static_cast<int>(Call::Role::Number)).toString(); - Call::Direction direction = index.model()->data(index, static_cast<int>(Call::Role::Direction)).value<Call::Direction>(); - - opt.text.clear(); - opt.decorationSize = QSize(imgSize_,imgSize_); - opt.decorationPosition = QStyleOptionViewItem::Left; - opt.decorationAlignment = Qt::AlignCenter; - QStyle *style = opt.widget ? opt.widget->style() : QApplication::style(); - style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget); - auto rect = opt.rect; - QPalette::ColorGroup cg = (opt.state & QStyle::State_Enabled) ? QPalette::Normal : QPalette::Disabled; - if (cg == QPalette::Normal && !(opt.state & QStyle::State_Active)) - cg = QPalette::Inactive; - painter->setPen(opt.palette.color(cg, QPalette::Text)); - painter->setOpacity(1.0); - if (not number.isEmpty()) { - painter->drawText(QRect(rect.left() +imgSize_ + 5, rect.top(), rect.width(), rect.height()/2), - Qt::AlignBottom, name); - painter->setOpacity(0.7); - painter->drawText(QRect(rect.left()+imgSize_ + 5, rect.top() + rect.height()/2, rect.width(), rect.height()/2), - Qt::AlignTop, number); - painter->setOpacity(1.0); - QImage arrow; - switch (direction) { - case Call::Direction::INCOMING: - arrow.load("://images/arrow-down.png"); - break; - case Call::Direction::OUTGOING: - arrow.load("://images/arrow-up.png"); - break; - } - painter->drawImage(QRect(rect.left() -imgSize_, rect.top() + (rect.height()-imgSize_)/2, imgSize_, imgSize_), arrow); - } else { - painter->drawText(QRect(rect.left(), rect.top(), rect.width(), rect.height()), - opt.displayAlignment, name); - } - } -} - -QSize -HistoryDelegate::sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index ) const -{ - QSize result = QStyledItemDelegate::sizeHint(option, index); - return result; -} diff --git a/historydelegate.h b/historydelegate.h deleted file mode 100644 index 3a05347036ce591d3e49afe0a488bf5378679d9f..0000000000000000000000000000000000000000 --- a/historydelegate.h +++ /dev/null @@ -1,42 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2015-2016 by Savoir-faire Linux * - * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>* - * * - * 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/>. * - **************************************************************************/ - -#pragma once - -#include <QObject> -#include <QString> -#include <QPainter> -#include <QApplication> -#include <QStyledItemDelegate> - -#include "categorizedhistorymodel.h" - -class HistoryDelegate : public QStyledItemDelegate -{ - Q_OBJECT -public: - explicit HistoryDelegate(QObject *parent = 0); - -protected: - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; - -private: - constexpr static int imgSize_ = 25; -}; -