diff --git a/src/widgets/accountstatusviewer.cpp b/src/widgets/accountstatusviewer.cpp deleted file mode 100644 index 7ad9e7d2..00000000 --- a/src/widgets/accountstatusviewer.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * This library 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 * - * Lesser 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 "accountstatusviewer.h" - -//Qt -#include -#include -#include - -//Ring -#include -#include - -AccountStatusViewer::AccountStatusViewer(Account* a, QWidget* parent) : QDialog(parent), -m_pView(new QTableView(this)) -{ - QVBoxLayout* l = new QVBoxLayout(this); - l->addWidget(m_pView); - m_pView->setWordWrap(true); - m_pView->setModel(a->statusModel()); - - if (m_pView->horizontalHeader()) { - m_pView->horizontalHeader()->setSectionResizeMode (0,QHeaderView::Stretch ); - m_pView->horizontalHeader()->setSectionResizeMode (1,QHeaderView::ResizeToContents); - m_pView->horizontalHeader()->setSectionResizeMode (2,QHeaderView::ResizeToContents); - m_pView->horizontalHeader()->setSectionResizeMode (3,QHeaderView::ResizeToContents); - } - - resize(800,600); -} - -AccountStatusViewer::~AccountStatusViewer() -{ - -} - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/accountstatusviewer.h b/src/widgets/accountstatusviewer.h deleted file mode 100644 index 9556fa4b..00000000 --- a/src/widgets/accountstatusviewer.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * This library 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 * - * Lesser 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 ACCOUNTSTATUSVIEWER_H -#define ACCOUNTSTATUSVIEWER_H - -#include -#include "typedefs.h" - -//Qt -class QTableView; -class QWidget; - -//Ring -class Account; - -class LIB_EXPORT AccountStatusViewer : public QDialog -{ - Q_OBJECT -public: - explicit AccountStatusViewer(Account* a , QWidget* parent = nullptr); - virtual ~AccountStatusViewer(); - -private: - QTableView* m_pView; -}; - -#endif - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/autocombobox.cpp b/src/widgets/autocombobox.cpp deleted file mode 100644 index 63ad6529..00000000 --- a/src/widgets/autocombobox.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * 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 "autocombobox.h" - -#include -#include -#include -#include - -AutoComboBox::AutoComboBox(QWidget* parent) : QComboBox(parent), m_pSelectionModel(nullptr) -{ - connect(this,SIGNAL(currentIndexChanged(int)),this,SLOT(slotComboBoxSelectionChanged(int))); -} - -AutoComboBox::~AutoComboBox() -{ -} - -void AutoComboBox::bindToModel(QAbstractItemModel* m, QItemSelectionModel* s) -{ - Q_ASSERT(m); - Q_ASSERT(s); - if (m_pSelectionModel) - disconnect(m_pSelectionModel,&QItemSelectionModel::currentChanged,this,&AutoComboBox::slotModelSelectionChanged); - - blockSignals(true); - setModel(m); - m_pSelectionModel = s; - setCurrentIndex(s->currentIndex().row()); - blockSignals(false); - - connect(m_pSelectionModel,&QItemSelectionModel::currentChanged,this,&AutoComboBox::slotModelSelectionChanged); -} - -void AutoComboBox::slotComboBoxSelectionChanged(int idx) -{ - if (!m_pSelectionModel) - return; - - const QModelIndex i = model()->index(idx,0,QModelIndex()); - - if (i.isValid() && m_pSelectionModel) - m_pSelectionModel->setCurrentIndex(i,QItemSelectionModel::ClearAndSelect); -} - -void AutoComboBox::slotModelSelectionChanged(const QModelIndex& idx) -{ - if (!idx.isValid()) - return; - - setCurrentIndex(idx.row()); -} - -QItemSelectionModel* AutoComboBox::selectionModel() -{ - return m_pSelectionModel; -} - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/autocombobox.h b/src/widgets/autocombobox.h deleted file mode 100644 index 7cd307c0..00000000 --- a/src/widgets/autocombobox.h +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * 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 AUTOCOMBOBOX_H -#define AUTOCOMBOBOX_H - -#include - -#include -#include "typedefs.h" - -class QItemSelectionModel; - -class LIB_EXPORT AutoComboBox : public QComboBox -{ - Q_OBJECT - -public: - explicit AutoComboBox(QWidget* parent = nullptr); - virtual ~AutoComboBox(); - - void bindToModel(QAbstractItemModel* m, QItemSelectionModel* s); - - QItemSelectionModel* selectionModel(); - -private: - QItemSelectionModel* m_pSelectionModel; - -private Q_SLOTS: - void slotComboBoxSelectionChanged(int idx); - void slotModelSelectionChanged(const QModelIndex& idx); -}; - -#endif - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/categorizedtree.cpp b/src/widgets/categorizedtree.cpp deleted file mode 100644 index f33cef8e..00000000 --- a/src/widgets/categorizedtree.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2013-2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * This library 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 * - * Lesser 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 "categorizedtree.h" - -CategorizedTree::CategorizedTree(QWidget* parent) : QTreeView(parent) -{} - -void CategorizedTree::drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const -{ - Q_UNUSED( painter ) - Q_UNUSED( rect ) - Q_UNUSED( index ) -} - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/categorizedtree.h b/src/widgets/categorizedtree.h deleted file mode 100644 index 05055680..00000000 --- a/src/widgets/categorizedtree.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2013-2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * This library 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 * - * Lesser 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 CATEGORIZED_TREE_H -#define CATEGORIZED_TREE_H - -#include - -class CategorizedTree : public QTreeView -{ - Q_OBJECT -public: - explicit CategorizedTree(QWidget* parent = nullptr); - -protected: - virtual void drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const override; -}; - -#endif - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/categorizedtreeview.cpp b/src/widgets/categorizedtreeview.cpp deleted file mode 100644 index 522c5a1c..00000000 --- a/src/widgets/categorizedtreeview.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2012 by Savoir-Faire Linux * - * @author: Emmanuel Lepage Vallee * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License version 2 as published by the Free Software Foundation. * - * * - * This library 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 * - * Library 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 "categorizedtreeview.h" - -//Qt -#include -#include -#include -#include -#include -#include -#include - -//KDE -#include - -//Ring -#include -#include -#include -#include - -///Constructor -CategorizedTreeView::CategorizedTreeView(QWidget *parent) - : CategorizedTree(parent),m_Type(CategorizedTreeView::ViewType::Other), - m_InitSignals(false) -{ -} - -CategorizedTreeView::~CategorizedTreeView() -{ - -} - -void CategorizedTreeView::setModel ( QAbstractItemModel * model ) -{ - connect(model,&QAbstractItemModel::rowsInserted,this,&CategorizedTreeView::slotExpandInserted); - QTreeView::setModel(model); -} - -void CategorizedTreeView::contextMenuEvent ( QContextMenuEvent * e ) { - const QModelIndex index = indexAt(e->pos()); - - //There is currently nothing to do when right-clicking empty space - if (index.isValid()) { - emit contextMenuRequest(index); - e->accept(); - } -} - - -void CategorizedTreeView::dragLeaveEvent( QDragLeaveEvent *e) -{ - if (!m_InitSignals) - initSignals(); - if (m_HoverIdx.isValid()) { - ((QAbstractItemModel*)m_HoverIdx.model())->setData(m_HoverIdx,-1,300); - m_HoverIdx = QModelIndex(); - } - QTreeView::dragLeaveEvent(e); -} - -void CategorizedTreeView::dragEnterEvent( QDragEnterEvent *e) -{ - if (!m_InitSignals) - initSignals(); - const auto idxAt = indexAt(e->pos()); - const CallModel::DropPayloadType type = payloadType(e->mimeData()); - bool accept = false; - switch (m_Type) { - case ViewType::Other: - break; - case ViewType::Person: - accept = CategorizedContactModel::acceptedPayloadTypes() & type; - break; - case ViewType::History: - accept = CategorizedHistoryModel::instance().acceptedPayloadTypes() & type; - break; - case ViewType::BookMark: - break; - case ViewType::Call: - accept = CallModel::instance().acceptedPayloadTypes() & type; - break; - }; - if (accept) { - e->acceptProposedAction(); - e->accept(); - if (idxAt.isValid() && idxAt.parent().isValid()) { - ((QAbstractItemModel*)idxAt.model())->setData(idxAt,1,300); - m_HoverIdx = idxAt; - } - } -} - -void CategorizedTreeView::dropEvent( QDropEvent* e ) -{ - if (!m_InitSignals) - initSignals(); - const QModelIndex newIdx = indexAt(e->pos()); - //HACK client get invalid indexes unless I do this, find out why - - //Clear drop state - cancelHoverState(); - - model()->dropMimeData(e->mimeData(), Qt::TargetMoveAction, newIdx.row(), newIdx.column(), newIdx.parent()); -} - -void CategorizedTreeView::dragMoveEvent( QDragMoveEvent *e) -{ - if (!m_InitSignals) - initSignals(); - e->acceptProposedAction(); -} - -void CategorizedTreeView::setDelegate(QStyledItemDelegate* delegate) -{ - if (!m_InitSignals) - initSignals(); - setItemDelegate(delegate); -} - - -void CategorizedTreeView::mouseDoubleClickEvent(QMouseEvent* event) -{ - const auto idxAt = indexAt(event->pos()); - emit itemDoubleClicked(idxAt); -// if (m_Type != ViewType::Person) - QTreeView::mouseDoubleClickEvent(event); -} - -///This function allow for custom rendering of the drag widget -void CategorizedTreeView::startDrag(Qt::DropActions supportedActions) -{ - if (m_Type == CategorizedTreeView::ViewType::Call) { -// Q_D(QAbstractItemView); - const auto index = selectionModel()->currentIndex(); - if (index.isValid()) { - QModelIndexList list; - list << index; - QMimeData *data = model()->mimeData(list); - if (!data) - return; - - //Execute the drag -// QDrag *drag = new QDrag(this); -// drag->setPixmap(ConferenceDelegate::getDragPixmap(this,index)); -// drag->setMimeData(data); -// drag->setHotSpot(QCursor::pos() - QCursor::pos()); -// const Qt::DropAction defaultDropAction = Qt::IgnoreAction; -// drag->exec(supportedActions, defaultDropAction); - } - } - else { - const auto index = selectionModel()->currentIndex(); - if (index.isValid()) { - QModelIndexList list; - list << index; - QMimeData *data = model()->mimeData(list); - if (!data) - return; - - //Create the pixmap - QStyleOptionViewItem option; - option.locale = locale(); - option.widget = this; - option.state = QStyle::State_Selected | QStyle::State_Enabled | QStyle::State_Active | QStyle::State_Small; - option.rect = QRect(0,0,width(),height()); - QSize size = itemDelegate()->sizeHint(option,index); - QSize itemSize = size; - for (int i=0;irowCount(index);i++) { - size.setHeight(size.height()+itemDelegate()->sizeHint(option,index.child(i,0)).height()); - } - - //Setup the painter - QPixmap pixmap(width(),size.height()); - QPainter customPainter(&pixmap); - customPainter.eraseRect(option.rect); - customPainter.setCompositionMode(QPainter::CompositionMode_Clear); - customPainter.fillRect(option.rect,QBrush(Qt::white)); - customPainter.setCompositionMode(QPainter::CompositionMode_SourceOver); - - //Draw the parent - option.rect = QRect(0,0,width(),itemSize.height()); - itemDelegate()->paint(&customPainter, option, index); - - //Draw the children - for (int i=0;irowCount(index);i++) { - itemSize.setHeight(itemDelegate()->sizeHint(option,index.child(i,0)).height()); - option.rect = QRect(10,option.rect.y()+option.rect.height(),width()-20,itemSize.height()); - option.state = QStyle::State_Enabled | QStyle::State_Active | QStyle::State_Small; - itemDelegate()->paint(&customPainter, option, index.child(i,0)); - } - - //Execute the drag - QDrag *drag = new QDrag(this); - drag->setPixmap(pixmap); - drag->setMimeData(data); - drag->setHotSpot(QCursor::pos() - QCursor::pos()); - const Qt::DropAction defaultDropAction = Qt::IgnoreAction; - drag->exec(supportedActions, defaultDropAction); - } -// QAbstractItemView::startDrag(supportedActions); - } -} - -bool CategorizedTreeView::edit(const QModelIndex& index, EditTrigger trigger, QEvent* event) -{ - if (state() == QAbstractItemView::EditingState) { - const Call::LifeCycleState current = qvariant_cast(index.data(static_cast(Call::Role::LifeCycleState))); - return !(current != Call::LifeCycleState::CREATION); - } - return QTreeView::edit(index,trigger,event); -} - -CallModel::DropPayloadType CategorizedTreeView::payloadType(const QMimeData* data) -{ - if (data->hasFormat(RingMimes::CALLID)) - return CallModel::DropPayloadType::CALL; - else if (data->hasFormat(RingMimes::CONTACT)) - return CallModel::DropPayloadType::CONTACT; - else if (data->hasFormat(RingMimes::HISTORYID)) - return CallModel::DropPayloadType::HISTORY; - else if (data->hasFormat(RingMimes::PHONENUMBER)) - return CallModel::DropPayloadType::NUMBER; - else if (data->hasFormat(RingMimes::PLAIN_TEXT)) - return CallModel::DropPayloadType::TEXT; - else - return CallModel::DropPayloadType::NONE; -} - -void CategorizedTreeView::cancelHoverState() -{ - if (m_HoverIdx.isValid()) { - //Prevent recursion - const QModelIndex oldIdx = m_HoverIdx; - m_HoverIdx = QModelIndex(); - ((QAbstractItemModel*)oldIdx.model())->setData(oldIdx,-1,static_cast(Call::Role::DropState)); - } -} - -void CategorizedTreeView::setHoverState(const QModelIndex& idx) -{ - if (idx != m_HoverIdx) { - cancelHoverState(); - model()->setData(idx,1,static_cast(Call::Role::DropState)); - m_HoverIdx = idx; - } -} - -void CategorizedTreeView::initSignals() -{ - if (model()) { - connect(model(),&QAbstractItemModel::layoutChanged,this,&CategorizedTreeView::cancelHoverState); - } - m_InitSignals = true; -} - -void CategorizedTreeView::setDirty(const QRect &rect) -{ - setDirtyRegion(rect); -} - -void CategorizedTreeView::slotExpandInserted(const QModelIndex& parentIdx,int start, int end) -{ - for (int i=start;i<=end;i++) { - setExpanded(model()->index(i,0,parentIdx),true); - } -} - -void CategorizedTreeView::forwardInput(QKeyEvent* e) -{ - keyPressEvent(e); -} - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/categorizedtreeview.h b/src/widgets/categorizedtreeview.h deleted file mode 100644 index 9b2ff86f..00000000 --- a/src/widgets/categorizedtreeview.h +++ /dev/null @@ -1,89 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2013-2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * 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 CATEGORIZEDTREEVIEW_H -#define CATEGORIZEDTREEVIEW_H - -#include "categorizedtree.h" - -class QStyledItemDelegate; -class QKeyEvent; - -//Ring -#include - -///CategorizedTreeView: A better looking widget than the plain QListWidget -class CategorizedTreeView final : public CategorizedTree -{ - Q_OBJECT - - public: - friend class ConferenceDelegate; - - enum class ViewType { - Other, - Person, - History, - BookMark, - Call - }; - - explicit CategorizedTreeView(QWidget *parent = nullptr); - virtual ~CategorizedTreeView(); - void setDelegate(QStyledItemDelegate* delegate); - void setViewType(ViewType type) {m_Type = type;} - - void setHoverState(const QModelIndex& idx); - - virtual void setModel ( QAbstractItemModel * model ) override; - - protected: - virtual void contextMenuEvent ( QContextMenuEvent * e ) override; - virtual void dragLeaveEvent ( QDragLeaveEvent * e ) override; - virtual void dragEnterEvent ( QDragEnterEvent * e ) override; - virtual void dragMoveEvent ( QDragMoveEvent * e ) override; - virtual void dropEvent ( QDropEvent * e ) override; - virtual void mouseDoubleClickEvent(QMouseEvent* event) override; - virtual void startDrag ( Qt::DropActions supportedActions ) override; - virtual bool edit(const QModelIndex& index, EditTrigger trigger, QEvent* event) override; - - QModelIndex m_HoverIdx; - - private: - ViewType m_Type; - bool m_InitSignals; - - //Helper - static CallModel::DropPayloadType payloadType(const QMimeData* data); - void initSignals(); - - Q_SIGNALS: - void contextMenuRequest(QModelIndex); - void itemDoubleClicked(QModelIndex); - -public Q_SLOTS: - void cancelHoverState(); - void setDirty(const QRect &rect); - void forwardInput(QKeyEvent* e); - -private Q_SLOTS: - void slotExpandInserted(const QModelIndex& parentIdx,int start, int end); -}; - -#endif - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/certificateviewer.cpp b/src/widgets/certificateviewer.cpp deleted file mode 100644 index e165ffc7..00000000 --- a/src/widgets/certificateviewer.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * This library 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 * - * Lesser 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 "certificateviewer.h" - -//Qt -#include -#include -#include - -//Ring -#include -#include -#include - -CertificateViewer::CertificateViewer(const QModelIndex& idx, QWidget* parent) : QDialog(parent), -m_pChainOfTrust(new QTreeView(this)),m_pView(new QTreeView(this)) -{ - setModal(true); - - QVBoxLayout* l = new QVBoxLayout(this); - m_pChainOfTrust->setMaximumSize(999999,150); - l->addWidget(m_pChainOfTrust); - l->addWidget(m_pView); - m_pView->setWordWrap(true); - m_pView->setUniformRowHeights(false); - m_pView->setModel(CertificateModel::instance().singleCertificateModel(idx)); - - if (m_pView->header()) { - m_pView->header()->setSectionResizeMode (0,QHeaderView::ResizeToContents); - m_pView->header()->setSectionResizeMode (1,QHeaderView::Stretch ); - } - m_pView->expandAll(); - resize(600,800); - - connect(m_pChainOfTrust, &QTreeView::clicked, this, &CertificateViewer::selectCert ); -} - -CertificateViewer::CertificateViewer(Certificate* cert, QWidget* parent) : QDialog(parent),m_pChainOfTrust(new QTreeView(this)), m_pView(new QTreeView(this)) -{ - if (!cert) - return; - QVBoxLayout* l = new QVBoxLayout(this); - m_pChainOfTrust->setMaximumSize(999999,150); - m_pView->setWordWrap(true); - m_pView->setUniformRowHeights(false); - l->addWidget(m_pChainOfTrust); - l->addWidget(m_pView); -// l->setStretchFactor(m_pChainOfTrust,0.3); - m_pView->setModel(cert->model()); - - m_pChainOfTrust->setModel(cert->chainOfTrustModel()); - m_pChainOfTrust->expandAll(); - - if (m_pView->header()) { - m_pView->header()->setSectionResizeMode (0,QHeaderView::ResizeToContents); - m_pView->header()->setSectionResizeMode (1,QHeaderView::Stretch ); - } - - m_pView->expandAll(); - resize(600,800); - - connect(m_pChainOfTrust, &QTreeView::clicked, this, &CertificateViewer::selectCert ); -} - -CertificateViewer::~CertificateViewer() -{ - -} - -void CertificateViewer::selectCert(const QModelIndex& idx) -{ - Certificate* c = qvariant_cast(idx.data((int)ChainOfTrustModel::Role::OBJECT)); - - if (!c) - return; - - m_pView->setModel(c->model()); - m_pView->expandAll(); -} - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/certificateviewer.h b/src/widgets/certificateviewer.h deleted file mode 100644 index 4f0a39df..00000000 --- a/src/widgets/certificateviewer.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * This library 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 * - * Lesser 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 CERTIFICATE_VIEWER_H -#define CERTIFICATE_VIEWER_H - -#include -#include -#include "typedefs.h" - -//Qt -class QTreeView; -class QWidget; - -//Ring -class Certificate; - -class LIB_EXPORT CertificateViewer : public QDialog -{ - Q_OBJECT -public: - explicit CertificateViewer(const QModelIndex& idx, QWidget* parent = nullptr); - explicit CertificateViewer(Certificate* cert , QWidget* parent = nullptr); - virtual ~CertificateViewer(); - -private Q_SLOTS: - void selectCert(const QModelIndex& idx); - -private: - QTreeView* m_pChainOfTrust; - QTreeView* m_pView; -}; - -#endif - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/contextlistview.cpp b/src/widgets/contextlistview.cpp deleted file mode 100644 index 42f4d84e..00000000 --- a/src/widgets/contextlistview.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2016 by Emmanuel Lepage-Vallee * - * Author : Emmanuel Lepage Vallee * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * This library 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 * - * Lesser 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 "contextlistview.h" - -// Qt -#include -#include - -// Ring -#include - -ContextListView::ContextListView(QWidget* parent) : QListView(parent) -{ -} - -void ContextListView::contextMenuEvent(QContextMenuEvent* e) -{ - const QModelIndex index = indexAt(e->pos()); - - if (index.isValid()) { - const QVariant objTv = index.data(static_cast(Ring::Role::ObjectType)); - - //Be sure the model support the UAM abstraction - if (!objTv.canConvert()) { - qWarning() << "Cannot determine object type"; - return; - } - - const auto objT = qvariant_cast(objTv); - - // Deduce each kind of objects from the relations - switch(objT) { - case Ring::ObjectType::Person : - case Ring::ObjectType::ContactMethod : - case Ring::ObjectType::Call : - case Ring::ObjectType::Media : - case Ring::ObjectType::Certificate : - case Ring::ObjectType::ContactRequest : - case Ring::ObjectType::Event : - case Ring::ObjectType::Individual : - case Ring::ObjectType::COUNT__ : - break; - } - } -} - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/contextlistview.h b/src/widgets/contextlistview.h deleted file mode 100644 index 7ccc8048..00000000 --- a/src/widgets/contextlistview.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2016 by Emmanuel Lepage-Vallee * - * Author : Emmanuel Lepage Vallee * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * This library 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 * - * Lesser 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 CONTEXT_LIST_VIEW_H -#define CONTEXT_LIST_VIEW_H - -#include - -class ContextListView final : public QListView -{ - Q_OBJECT -public: - explicit ContextListView(QWidget* parent = nullptr); - -protected: - virtual void contextMenuEvent ( QContextMenuEvent * e ) override; -}; - -#endif - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/directoryview.cpp b/src/widgets/directoryview.cpp deleted file mode 100644 index f4e5f9cd..00000000 --- a/src/widgets/directoryview.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2017 by Bluesystems * - * Author : Emmanuel Lepage Vallee * - * * - * 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 "directoryview.h" - -#include "ui_directoryview.h" - -#include -#include - -#include -#include - -DirectoryView::DirectoryView(QWidget* parent) : QDialog(parent) -{ - Ui_DirectoryView ui; - ui.setupUi(this); - - auto p = new QSortFilterProxyModel(this); - p->setSourceModel(&PhoneDirectoryModel::instance()); - p->setFilterRole((int)ContactMethod::Role::Filter); - p->setFilterCaseSensitivity( Qt::CaseInsensitive ); - p->setSortCaseSensitivity ( Qt::CaseInsensitive ); - connect(ui.lineEdit ,SIGNAL(filterStringChanged(QString)), p, SLOT(setFilterRegExp(QString))); - ui.tableView->setModel(p); - exec(); - - auto le = ui.lineEdit; - auto tv = ui.tableView; - - QTimer::singleShot(0, [le, p, tv]() { - le->setFocus(Qt::OtherFocusReason); - for (int i = 0; i < p->columnCount(); i++) - tv->horizontalHeader()->setSectionResizeMode(i,QHeaderView::ResizeToContents); - }); -} - -DirectoryView::~DirectoryView() -{ -} diff --git a/src/widgets/directoryview.h b/src/widgets/directoryview.h deleted file mode 100644 index 2c6a209e..00000000 --- a/src/widgets/directoryview.h +++ /dev/null @@ -1,34 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2017 by Bluesystems * - * Author : Emmanuel Lepage Vallee * - * * - * 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 . * - **************************************************************************/ -#pragma once - -#include -#include "typedefs.h" - -//Ring -class Certificate; - -class LIB_EXPORT DirectoryView : public QDialog -{ - Q_OBJECT -public: - explicit DirectoryView(QWidget* parent = nullptr); - virtual ~DirectoryView(); -}; - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/fileselector.cpp b/src/widgets/fileselector.cpp deleted file mode 100644 index 5bc5fa96..00000000 --- a/src/widgets/fileselector.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2012-2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * 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 "fileselector.h" - -#include - -#include - -FileSelector::FileSelector(QWidget* parent) : QWidget(parent) -{ - setupUi(this); -} - -void FileSelector::slotFileSelector() -{ -} - -void FileSelector::slotOpenFile() -{ - const auto fn = QFileDialog::getOpenFileName(this, i18n("Open File"), "", tr("All files")); - m_pFilePath->setText(fn); - emit urlSelected(fn); -} - -void FileSelector::setText(const QString& text) -{ - m_pFilePath->setText(text); -} - -QString FileSelector::text() const -{ - return m_pFilePath->text(); -} - -// kate: space-indent on; indent-width 4; replace-tabs on; diff --git a/src/widgets/fileselector.h b/src/widgets/fileselector.h deleted file mode 100644 index 04485481..00000000 --- a/src/widgets/fileselector.h +++ /dev/null @@ -1,49 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2012-2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * 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 FILESELECTOR_H -#define FILESELECTOR_H - -#include - -#include "ui_fileselect.h" - -/** - * This was provided by KF5::KIOWidgets, but as this app is being moved to mobile - * and QML, that dependency was increasingly unmaintainable. This code is - * temporary and will be removed once the port is complete. - */ -class FileSelector : public QWidget, public Ui_FileSelect -{ - Q_OBJECT -public: - explicit FileSelector(QWidget* parent = nullptr); - - void setText(const QString& text); - QString text() const; - -private Q_SLOTS: - void slotFileSelector(); - void slotOpenFile(); - -Q_SIGNALS: - void urlSelected(const QUrl& url); -}; - -#endif - -// kate: space-indent on; indent-width 4; replace-tabs on; diff --git a/src/widgets/groupedtoolbutton.cpp b/src/widgets/groupedtoolbutton.cpp deleted file mode 100644 index 0fb2c6e0..00000000 --- a/src/widgets/groupedtoolbutton.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// vim: set tabstop=4 shiftwidth=4 noexpandtab: -/* -Widget taken from Gwenview -Copyright 2007 Aurélien Gâteau - -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 2 -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, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -*/ -// Self -#include "groupedtoolbutton.h" - -// Qt -#include -#include -#include -#include - -GroupedToolButton::GroupedToolButton(QWidget* parent) - : QToolButton(parent), - mGroupPosition(NotGrouped) -{ - setToolButtonStyle(Qt::ToolButtonIconOnly); - setFocusPolicy(Qt::NoFocus); - setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); -} - -void GroupedToolButton::setGroupPosition(GroupedToolButton::GroupPosition groupPosition) -{ - mGroupPosition = groupPosition; -} - - -void GroupedToolButton::paintEvent(QPaintEvent* event) -{ - if (mGroupPosition == NotGrouped) { - QToolButton::paintEvent(event); - return; - } - QStylePainter painter(this); - QStyleOptionToolButton opt; - initStyleOption(&opt); - QStyleOptionToolButton panelOpt = opt; - - // Panel - QRect& panelRect = panelOpt.rect; - switch (mGroupPosition) { - case GroupLeft: - panelRect.setWidth(panelRect.width() * 2); - break; - case GroupCenter: - panelRect.setLeft(panelRect.left() - panelRect.width()); - panelRect.setWidth(panelRect.width() * 3); - break; - case GroupRight: - panelRect.setLeft(panelRect.left() - panelRect.width()); - break; - case NotGrouped: - Q_ASSERT(0); - } - painter.drawPrimitive(QStyle::PE_PanelButtonTool, panelOpt); - - // Separator - const int y1 = opt.rect.top() + 6; - const int y2 = opt.rect.bottom() - 6; - if (mGroupPosition & GroupRight) { - const int x = opt.rect.left(); - painter.setPen(opt.palette.color(QPalette::Light)); - painter.drawLine(x, y1, x, y2); - } - if (mGroupPosition & GroupLeft) { - const int x = opt.rect.right(); - painter.setPen(opt.palette.color(QPalette::Mid)); - painter.drawLine(x, y1, x, y2); - } - - // Text - painter.drawControl(QStyle::CE_ToolButtonLabel, opt); -} - -// kate: space-indent on; indent-width 4; replace-tabs on; diff --git a/src/widgets/groupedtoolbutton.h b/src/widgets/groupedtoolbutton.h deleted file mode 100644 index 1254c3f6..00000000 --- a/src/widgets/groupedtoolbutton.h +++ /dev/null @@ -1,80 +0,0 @@ -// vim: set tabstop=4 shiftwidth=4 noexpandtab: -/* -Gwenview: an image viewer -Copyright 2007 Aurélien Gâteau - -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 2 -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, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -*/ -#ifndef GROUPEDTOOLBUTTON_H -#define GROUPEDTOOLBUTTON_H - -// Qt -#include -#include "typedefs.h" - -/** - * A thin tool button which can be grouped with another and look like one solid - * bar: - * - * (button1 | button2) - */ -class LIB_EXPORT GroupedToolButton : public QToolButton -{ - Q_OBJECT -public: - enum GroupPosition { - NotGrouped = 0, - GroupLeft = 1, - GroupRight = 2, - GroupCenter = 3 - }; - - explicit GroupedToolButton(QWidget* parent = nullptr); - - void setGroupPosition(GroupedToolButton::GroupPosition groupPosition); - -protected: - virtual void paintEvent(QPaintEvent* event) override; - -private: - GroupPosition mGroupPosition; -}; - -class LeftToolButton final : public GroupedToolButton { - Q_OBJECT -public: - explicit LeftToolButton(QWidget* parent = nullptr) : GroupedToolButton(parent) { - setGroupPosition(GroupPosition::GroupLeft); - } -}; -class RightToolButton final : public GroupedToolButton { - Q_OBJECT -public: - explicit RightToolButton(QWidget* parent = nullptr) : GroupedToolButton(parent) { - setGroupPosition(GroupPosition::GroupRight); - } -}; -class CenterToolButton final : public GroupedToolButton { - Q_OBJECT -public: - explicit CenterToolButton(QWidget* parent = nullptr) : GroupedToolButton(parent) { - setGroupPosition(GroupPosition::GroupCenter); - } -}; - -#endif /* GROUPEDTOOLBUTTON_H */ - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/kphonenumberselector.cpp b/src/widgets/kphonenumberselector.cpp deleted file mode 100644 index c1b36405..00000000 --- a/src/widgets/kphonenumberselector.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2013-2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * 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 "kphonenumberselector.h" - -//KDE -#include -#include - -//Ring -#include "contactmethod.h" -#include "numbercategory.h" -#include "phonedirectorymodel.h" -#include -#include - - -void KPhoneNumberSelector::init() -{ -} - -ContactMethod* KPhoneNumberSelector::number(const Person* contact) -{ - if (contact) { - if (contact->individual()->phoneNumbers().size()>1) { - bool ok = false; - QHash map ; - QStringList list; - const auto pn = contact->individual()->phoneNumbers(); - for (auto number : qAsConst(pn)) { - map[number->category()->name()+" ("+number->uri()+')'] = number->uri(); - list << number->category()->name()+" ("+number->uri()+')'; - } - const QString result = QInputDialog::getItem (nullptr,i18n("Select phone number"), i18n("This contact has many phone numbers, please select the one you wish to call"), list, 0, false, &ok); - return PhoneDirectoryModel::instance().getNumber(result);//new ContactMethod(result,""); - } - else if (contact->individual()->phoneNumbers().size() == 1) - return contact->individual()->phoneNumbers().constFirst(); - } - return const_cast(ContactMethod::BLANK()); -} - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/kphonenumberselector.h b/src/widgets/kphonenumberselector.h deleted file mode 100644 index bb0a3ba1..00000000 --- a/src/widgets/kphonenumberselector.h +++ /dev/null @@ -1,41 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2013-2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * 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 KPHONENUMBERSELECTOR_H -#define KPHONENUMBERSELECTOR_H - -//Ring -#include - -class ContactMethod; -class Person; - -class KPhoneNumberSelector : public Interfaces::ContactMethodSelectorI -{ -public: - explicit KPhoneNumberSelector() = default; - KPhoneNumberSelector(const KPhoneNumberSelector&) = delete; - KPhoneNumberSelector& operator=(const KPhoneNumberSelector&) = delete; - virtual ~KPhoneNumberSelector(){} - - virtual ContactMethod* number(const Person* contact) override; - static void init(); -}; - -#endif - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/menumodelview.cpp b/src/widgets/menumodelview.cpp deleted file mode 100644 index 9b0783ef..00000000 --- a/src/widgets/menumodelview.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2015 by Emmanuel Lepage Vallee * - * Author : Emmanuel Lepage Vallee * - * * - * 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 "menumodelview.h" - -//Qt -#include -#include -#include -#include -#include - -//Recursively build the menu, please note this doesn't use any kind of lazy-loading optimizations -void MenuModelView::drill(QAbstractItemModel* model, QItemSelectionModel* s, const QModelIndex& parent) -{ - const int rc = model->rowCount(parent); - - if (!rc) - return; - - for (int i=0; i < rc;i++) { - const QModelIndex idx = model->index(i,0); - - QIcon icon; - const QVariant icn = idx.data(Qt::DecorationRole); - - if (icn.canConvert()) - icon = qvariant_cast(icn); - else if (icn.canConvert()) - icon = QIcon(qvariant_cast(icn)); - - QAction* action = addAction(icon, idx.data(Qt::DisplayRole).toString()); - - action->setCheckable(idx.flags() & Qt::ItemIsUserCheckable); - action->setEnabled(idx.flags() & (Qt::ItemIsEnabled | Qt::ItemIsSelectable)); - - QPersistentModelIndex pidx(idx); - - if (idx == s->currentIndex()) { - action->setChecked(true); - - const QMetaObject::Connection conn = connect(s, &QItemSelectionModel::currentChanged, this, [this, action, pidx](const QModelIndex& idx2) { - if (idx2 == pidx) - emit actionChanged(action); - }); - - //Make sure the slot isn't called after a reload, the action pointer would be invalid - connect(action, &QObject::destroyed, [conn]() {disconnect(conn);}); - } - - connect(action, &QAction::triggered, this, [pidx,s,this](bool) { - if (pidx.isValid()) { - s->setCurrentIndex(pidx, QItemSelectionModel::ClearAndSelect); - emit itemClicked(pidx); - } - }); - - drill(model, s, idx); - } -} - -MenuModelView::MenuModelView(QAbstractItemModel* model, QItemSelectionModel* s, QWidget* parent) : QMenu(parent), m_pModel(model) -{ - drill(model, s); - - //TODO check for dataChanged and rowInserted/removed more efficiently - const auto reload = [this, model, s]() { - clear(); - foreach (QAction* a, m_lActions) - delete a; - m_lActions.clear(); - drill(model,s); - }; - - connect(model, &QAbstractItemModel::layoutChanged, reload); - connect(model, &QAbstractItemModel::rowsInserted , reload); - connect(model, &QAbstractItemModel::rowsRemoved , reload); - connect(model, &QAbstractItemModel::dataChanged , reload); -} - -MenuModelView::~MenuModelView() -{ - foreach (QAction* a, m_lActions) - delete a; - m_lActions.clear(); -} - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/menumodelview.h b/src/widgets/menumodelview.h deleted file mode 100644 index 0eb178b6..00000000 --- a/src/widgets/menumodelview.h +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2015 by Emmanuel Lepage Vallee * - * Author : Emmanuel Lepage Vallee * - * * - * 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 MENUMODELVIEW_H -#define MENUMODELVIEW_H - -#include -#include -class QItemSelectionModel; -class QAction; - -/** - * Basic bindings between a QMenu and a QAbstractItemModel - * - * This can be used along with a selection model or some helper function - * to share logic between clients without support for QAction - */ -class MenuModelView : public QMenu -{ - Q_OBJECT - -public: - explicit MenuModelView(QAbstractItemModel* model, QItemSelectionModel* s, QWidget* parent = nullptr); - virtual ~MenuModelView(); - -private: - //Attributes - QAbstractItemModel* m_pModel; - QList m_lActions; - - //Helpers - void drill(QAbstractItemModel* model, QItemSelectionModel* s, const QModelIndex& parent = QModelIndex()); - -Q_SIGNALS: - void actionChanged(QAction* a); - void itemClicked(const QModelIndex& idx); -}; - -#endif - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/securityprogress.cpp b/src/widgets/securityprogress.cpp deleted file mode 100644 index ca0f2cb8..00000000 --- a/src/widgets/securityprogress.cpp +++ /dev/null @@ -1,437 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2014-2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * 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 "securityprogress.h" - -//Qt -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//KDE -#include - -//Ring -#include - -class SecurityProgress : public QProgressBar -{ - Q_OBJECT -public: - explicit SecurityProgress(QWidget* parent = nullptr); - virtual ~SecurityProgress(); - SecurityEvaluationModel::SecurityLevel m_Level; - -protected: - //Virtual events - void paintEvent ( QPaintEvent* event) override; - -private: - //Attributes - QStringList m_Names; - QList m_lColors; - QList m_lAltColors; - -}; - -SecurityProgress::SecurityProgress(QWidget* parent) : QProgressBar(parent), -m_Level(SecurityEvaluationModel::SecurityLevel::NONE) -{ - setMaximum(enum_class_size()); - setValue((int)m_Level); - setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed )); - m_Names << i18n("None") << i18n("Weak") << i18n("Medium") << i18n("Acceptable") << i18n("Strong") << i18n("Complete"); - m_lColors = { - QColor(0xA0, 0x21, 0x11), - QColor(0xE4, 0x7D, 0x08), - QColor(0xCB, 0xC9, 0x10), - QColor(0x6D, 0xA0, 0x0F), - QColor(0x0E, 0xA0, 0x2B), - QColor(0x12, 0x86, 0x0E) - }; -// m_lColors.resize(enum_class_size()); -// m_Names.resize(enum_class_size()); - - foreach(const QColor& col,m_lColors) { - QColor newCol = col; - newCol.setRed (newCol.red() -55); - newCol.setGreen(newCol.green()-55); - newCol.setBlue (newCol.blue() -55); - m_lAltColors << newCol; - } -} - -SecurityProgress::~SecurityProgress() -{ - -} - -void SecurityProgress::paintEvent(QPaintEvent* event) -{ - Q_UNUSED(event) - // Setup - QPainter painter(this); - painter.setRenderHint (QPainter::Antialiasing, true ); - const QRect rect(2,2,width()-4,height()-4); - - // Draw the background - QLinearGradient decoGradient1; - decoGradient1.setStart(rect.topLeft()); - decoGradient1.setFinalStop(rect.bottomLeft()); - QColor bg = QApplication::palette().base().color(); - const char dark = ((bg.red() + bg.green() + bg.blue())/3.0) < 127?1:-1; - bg.setRed (bg.red ()+(35*dark)); - bg.setGreen(bg.green()+(35*dark)); - bg.setBlue (bg.blue ()+(35*dark)); - decoGradient1.setColorAt(0, Qt::transparent); - decoGradient1.setColorAt(1, bg); - painter.setBrush(decoGradient1); - QColor bg2 = bg; - bg2.setRed (bg.red ()+(75*dark)); - bg2.setGreen(bg.green()+(75*dark)); - bg2.setBlue (bg.blue ()+(75*dark)); - painter.setPen(Qt::transparent); - painter.drawRoundedRect(rect,7,7); - - // Draw the current status - QLinearGradient decoGradient2; - decoGradient2.setStart(rect.topLeft()); - decoGradient2.setFinalStop(rect.bottomLeft()); - decoGradient2.setColorAt(0, m_lColors[value()-1 <0? 0 : value()-1]); - decoGradient2.setColorAt(1, m_lAltColors[value()-1 <0? 0 : value()-1]); - const QRect progress(rect.x(),rect.y(),rect.width()*(((float)value())/((float)maximum()))-1,rect.height()); - painter.setBrush(decoGradient2); - painter.drawRoundedRect(progress,7,7); - painter.drawRect(QRect(progress.x()+progress.width()-10,progress.y(),10,progress.height())); - - // Draw the bars - const int stepWidth = width()/maximum(); - QPen pen = painter.pen(); - pen.setWidth(1); -// QFont f = painter.font(); -// f.setBold(true); -// painter.setFont(f); - for (int i=0;isetContentsMargins(0,0,0,0); - l->setSpacing(0); - - m_pLevel = new SecurityProgress(this); - l->addWidget(m_pLevel,0,0); - - QHBoxLayout* labels = new QHBoxLayout(nullptr); - l->addLayout(labels,1,0); - - QLabel* infoIcon = new QLabel(this); - QLabel* warningIcon = new QLabel(this); - QLabel* issueIcon = new QLabel(this); - QLabel* errorIcon = new QLabel(this); - - m_pInfoL = new QLabel(this); - m_pWarningL = new QLabel(this); - m_pIssueL = new QLabel(this); - m_pErrorL = new QLabel(this); - - infoIcon-> setPixmap(QIcon::fromTheme(QStringLiteral("dialog-information")).pixmap(QSize(16,16))); - warningIcon->setPixmap(QIcon::fromTheme(QStringLiteral("dialog-warning") ).pixmap(QSize(16,16))); - issueIcon-> setPixmap(QIcon::fromTheme(QStringLiteral("task-attempt") ).pixmap(QSize(16,16))); - errorIcon-> setPixmap(QIcon::fromTheme(QStringLiteral("dialog-error") ).pixmap(QSize(16,16))); - - m_pInfoL ->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_pWarningL->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_pIssueL ->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_pErrorL ->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - - labels->addWidget ( errorIcon ); - labels->addWidget ( m_pErrorL ); - labels->addWidget ( issueIcon ); - labels->addWidget ( m_pIssueL ); - labels->addWidget ( warningIcon ); - labels->addWidget ( m_pWarningL ); - labels->addWidget ( infoIcon ); - labels->addWidget ( m_pInfoL ); - - m_pView = new QTableView(this); - m_pView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_pView->setWordWrap(true); - m_pView->setMinimumSize(0,125); - m_pView->resize(0,125); - m_pView->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding)); -// m_pView->setMaximumSize(99999999,125); - m_pView->setVisible(false); - - connect(m_pView,&QAbstractItemView::doubleClicked,this,&SecurityLevelWidget::dblClicked); - l->addWidget(m_pView,2,0); -// QSize prog = m_pLevel->sizeHint(); -// setMinimumSize(0,prog.height()+125); - setLayout(l); - reloadCount(); -} - -SecurityLevelWidget::~SecurityLevelWidget() -{ - -} - -void SecurityLevelWidget::setModel(SecurityEvaluationModel* model) -{ - m_pView->setModel(model); - m_pModel = model; - - //Resize the columns - if (m_pView->horizontalHeader()) { - m_pView->horizontalHeader()->setSectionResizeMode(0,QHeaderView::Stretch); - for (int i =1;icolumnCount();i++) - m_pView->horizontalHeader()->setSectionResizeMode(i,QHeaderView::ResizeToContents); - m_pView->horizontalHeader()->setVisible(false); - m_pView->hideColumn(2); - } - - if (m_pView->verticalHeader()) - m_pView->verticalHeader()->setVisible(false); - - - if (m_pModel) { - connect(m_pModel,&QAbstractItemModel::layoutChanged,this,&SecurityLevelWidget::reloadCount); - connect(m_pModel,&SecurityEvaluationModel::informationCountChanged , this, &SecurityLevelWidget::reloadCount); - connect(m_pModel,&SecurityEvaluationModel::warningCountChanged , this, &SecurityLevelWidget::reloadCount); - connect(m_pModel,&SecurityEvaluationModel::issueCountChanged , this, &SecurityLevelWidget::reloadCount); - connect(m_pModel,&SecurityEvaluationModel::errorCountChanged , this, &SecurityLevelWidget::reloadCount); - connect(m_pModel,&SecurityEvaluationModel::fatalWarningCountChanged , this, &SecurityLevelWidget::reloadCount); - connect(m_pModel,&SecurityEvaluationModel::securityLevelChanged , this, &SecurityLevelWidget::reloadCount); - } - - reloadCount(); -} - -QTableView* SecurityLevelWidget::view() const -{ - return m_pView; -} - -void SecurityLevelWidget::mouseReleaseEvent(QMouseEvent * event) -{ - Q_UNUSED(event) - m_pView->setVisible(!m_pView->isVisible()); -} - -void SecurityLevelWidget::reloadCount() -{ - if (! m_pModel) return; - - m_pInfoL ->setText(i18np("%1 tip","%1 tips",m_pModel->informationCount())); - m_pWarningL->setText(i18np("%1 warning","%1 warnings", m_pModel->warningCount() + m_pModel->fatalWarningCount())); - m_pIssueL ->setText(i18np("%1 issue","%1 issues",m_pModel->issueCount())); - m_pErrorL ->setText(i18np("%1 error","%1 errors",m_pModel->errorCount())); - - m_pLevel->m_Level = m_pModel->securityLevel(); - - //Visually None == 1 == red - m_pLevel->setValue((int)m_pLevel->m_Level+1); - - m_pView->resizeRowsToContents(); -} - -void SecurityLevelWidget::dblClicked(const QModelIndex& idx) -{ - Q_UNUSED(idx) -// if (idx.isValid()) { -// m_pModel->currentFlaws()[idx.row()]->requestHighlight(); -// } -} - -class IssueButton : public QToolButton -{ - Q_OBJECT -public: - IssueButton(const SecurityFlaw* flaw, QWidget* parent); - const SecurityFlaw* m_pFlaw; -public Q_SLOTS: - void slotHighlightFlaw(); -}; - -IssueButton::IssueButton(const SecurityFlaw* flaw, QWidget* parent): -QToolButton(parent),m_pFlaw(flaw) -{ - connect(flaw,&SecurityFlaw::highlight,this,&IssueButton::slotHighlightFlaw); -} - -IssuesIcon::IssuesIcon(QWidget* parent) : QWidget(parent), -m_pLayout(new QHBoxLayout(this)),m_pBuddy(nullptr),m_pModel(nullptr) -{ - -} - -IssuesIcon::~IssuesIcon() -{ - -} - -QWidget* IssuesIcon::buddy() const -{ - return m_pBuddy; -} - -void IssueButton::slotHighlightFlaw() -{ - SecurityFlaw* flaw = qobject_cast(sender()); - if (flaw == m_pFlaw) { - IssuesIcon* par = static_cast(parentWidget()); - if (par->buddy()) { - par->buddy()->setFocus(Qt::OtherFocusReason); - } - else { - par->parentWidget()->setFocus(Qt::OtherFocusReason); - } - } -} - -void IssuesIcon::setModel(SecurityEvaluationModel* model) -{ - reset(); - m_pModel = model; -} - -void IssuesIcon::setBuddy(QWidget* buddy) -{ - m_pBuddy = buddy; -} - -void IssuesIcon::addFlaw(const SecurityFlaw* flaw) -{ - Q_UNUSED(flaw) - IssueButton* btn = new IssueButton(flaw,this); - switch (flaw->severity()) { - case SecurityEvaluationModel::Severity::INFORMATION: - btn->setIcon(QIcon::fromTheme(QStringLiteral("dialog-information"))); - break; - case SecurityEvaluationModel::Severity::WARNING: - case SecurityEvaluationModel::Severity::FATAL_WARNING: - btn->setIcon(QIcon::fromTheme(QStringLiteral("dialog-warning"))); - break; - case SecurityEvaluationModel::Severity::ISSUE: - btn->setIcon(QIcon::fromTheme(QStringLiteral("task-attempt"))); - break; - case SecurityEvaluationModel::Severity::ERROR: - btn->setIcon(QIcon::fromTheme(QStringLiteral("dialog-error"))); - break; - case SecurityEvaluationModel::Severity::UNSUPPORTED: - case SecurityEvaluationModel::Severity::COUNT__: - break; - }; - - btn->setToolButtonStyle(Qt::ToolButtonIconOnly); - btn->setStyleSheet(QStringLiteral("border:0px;background-color:transparent;margin:0px;padding:0px;")); - m_pLayout->addWidget(btn); - connect(flaw,&SecurityFlaw::solved,this,&IssuesIcon::slotSolved); - connect(btn,&QAbstractButton::clicked,this,&IssuesIcon::slotFlawClicked); - - QLineEdit* le = qobject_cast(parentWidget()); - if (le) { - static const int margin = style()->pixelMetric(QStyle::PM_FocusFrameHMargin)/2; - const QSize s = sizeHint(); - resize(s.width(),le->height()-2*margin); - move(le->width()-s.width(),margin); - } -} - -void IssuesIcon::slotFlawClicked() -{ - IssueButton* btn = qobject_cast(sender()); - if (btn) { - emit selectFlaw(m_pModel->getIndex(btn->m_pFlaw)); - } -} - -void IssuesIcon::setupForLineEdit(QLineEdit* le) -{ - le->installEventFilter(this); -} - -void IssuesIcon::reset() -{ - while (layout()->count()) { - QWidget* w = layout()->takeAt(0)->widget(); - if (w) { - delete w; - } - } -} - -bool IssuesIcon::eventFilter(QObject *obj, QEvent *event) -{ - QLineEdit* le = qobject_cast(obj); - if (le && event->type() == QEvent::Resize) { - static const int margin = style()->pixelMetric(QStyle::PM_FocusFrameHMargin)/2; - const QSize s = sizeHint(); - resize(s.width(),le->height()-2*margin); - move(le->width()-s.width(),margin); - } - return false; -} - - -void IssuesIcon::slotSolved() -{ - SecurityFlaw* f = qobject_cast(sender()); - if (f) { - //TODO - } -} - -#include "moc_securityprogress.cpp" -#include "securityprogress.moc" -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/securityprogress.h b/src/widgets/securityprogress.h deleted file mode 100644 index 8d0fc297..00000000 --- a/src/widgets/securityprogress.h +++ /dev/null @@ -1,99 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2014-2015 by Savoir-Faire Linux * - * Author : Emmanuel Lepage Vallee * - * * - * 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 SECURITYPROGRESS_H -#define SECURITYPROGRESS_H - -#include - -//Qt -class QTableView; -class QLabel; -class QHBoxLayout; -class QLineEdit; - -//Ring -#include -class SecurityProgress; -class SecurityFlaw; - -class IssuesIcon final : public QWidget { - Q_OBJECT -public: - explicit IssuesIcon(QWidget* parent = nullptr); - ~IssuesIcon(); - - //Setter - void setBuddy(QWidget* buddy); - void setModel(SecurityEvaluationModel* model); - - //Getter - QWidget* buddy() const; - - //Mutator - void addFlaw(const SecurityFlaw* flaw); - void setupForLineEdit(QLineEdit* le); - void reset(); -protected: - virtual bool eventFilter(QObject *obj, QEvent *event) override; - -private: - QHBoxLayout* m_pLayout; - QWidget* m_pBuddy; - SecurityEvaluationModel* m_pModel; -private Q_SLOTS: - void slotSolved(); - void slotFlawClicked(); -Q_SIGNALS: - void selectFlaw(const QModelIndex idx); -}; - -class SecurityLevelWidget final : public QWidget -{ - Q_OBJECT -public: - explicit SecurityLevelWidget(QWidget* parent = nullptr); - virtual ~SecurityLevelWidget(); - - //Getter - QTableView* view() const; - - //Setter - void setModel(SecurityEvaluationModel* model); -protected: - //Virtual events - virtual void mouseReleaseEvent ( QMouseEvent * event ) override; -private: - //Attributes - SecurityProgress* m_pLevel; - QTableView* m_pView; - SecurityEvaluationModel* m_pModel; - - //Widgets - QLabel* m_pInfoL ; - QLabel* m_pWarningL; - QLabel* m_pIssueL ; - QLabel* m_pErrorL ; - -private Q_SLOTS: - void reloadCount(); - void dblClicked(const QModelIndex& idx); -}; - -#endif - -// kate: space-indent on; indent-width 3; replace-tabs on; diff --git a/src/widgets/ui/accountcreator.ui b/src/widgets/ui/accountcreator.ui deleted file mode 100644 index f39952c7..00000000 --- a/src/widgets/ui/accountcreator.ui +++ /dev/null @@ -1,195 +0,0 @@ - - - AccountCreatorWidget - - - - 0 - 0 - 322 - 481 - - - - - - - &Confirm password: - - - true - - - confirmPasswordEdit - - - - - - - QLineEdit::Password - - - - - - - &Password: - - - true - - - passwordEdit - - - - - - - Register public username (experimental) - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Preferred - - - - 304 - 40 - - - - - - - - Choose your username: - - - true - - - - - - - Create an account - - - - .. - - - - - - - QLineEdit::Password - - - - - - - - 0 - 0 - - - - - 128 - 128 - - - - - 16777215 - 128 - - - - Create your account - - - Qt::AlignCenter - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 304 - 80 - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Preferred - - - - 304 - 40 - - - - - - - - Searching... - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0 - - - -1 - - - - - - - usernameEdit - signUpCheckBox - passwordEdit - confirmPasswordEdit - createAccountButton - - - - diff --git a/src/widgets/ui/directoryview.ui b/src/widgets/ui/directoryview.ui deleted file mode 100644 index 93c4e840..00000000 --- a/src/widgets/ui/directoryview.ui +++ /dev/null @@ -1,108 +0,0 @@ - - - DirectoryView - - - - 0 - 0 - 707 - 615 - - - - Dialog - - - - - - Qt::Horizontal - - - QDialogButtonBox::NoButton - - - - - - - true - - - - - - - - - - Qt::Horizontal - - - - 558 - 20 - - - - - - - - This dialog is an overview of Ring-KDE phonebook. Some elements may exist multiple times if they are associated with multiple accounts or contacts. The elements present in this table come from the history, contacts and other sources. - - - true - - - - - - - - FilterLineEdit - QLineEdit -
widgets/filterlineedit.h
-
-
- - lineEdit - tableView - - - - - buttonBox - accepted() - DirectoryView - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - DirectoryView - reject() - - - 316 - 260 - - - 286 - 274 - - - - -
diff --git a/src/widgets/ui/fileselect.ui b/src/widgets/ui/fileselect.ui deleted file mode 100644 index 046e67bc..00000000 --- a/src/widgets/ui/fileselect.ui +++ /dev/null @@ -1,55 +0,0 @@ - - - FileSelect - - - - 0 - 0 - 400 - 44 - - - - - - - true - - - - - - - ... - - - - - - - - - - - - m_pOpenFile - clicked() - FileSelect - slotOpenFile() - - - 372 - 25 - - - 348 - 5 - - - - - - slotOpenFile() - -