• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

kwallet

  • sources
  • kde-4.14
  • kdeutils
  • kwalletmanager
  • src
  • manager
connectedapplicationstable.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 Valentin Rusu <kde@rusu.info>
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; see the file COPYING. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 
21 #include "connectedapplicationstable.h"
22 #include "disconnectappbutton.h"
23 #include "connectedappmodel.h"
24 
25 #include <klocalizedstring.h>
26 #include <QPushButton>
27 
28 ConnectedApplicationsTable::ConnectedApplicationsTable(QWidget* parent):
29  QTableView(parent),
30  _wallet(0)
31 {
32 }
33 
34 void ConnectedApplicationsTable::setWallet(KWallet::Wallet* wallet)
35 {
36  _wallet = wallet;
37 }
38 
39 void ConnectedApplicationsTable::setModel(QAbstractItemModel* model)
40 {
41  Q_ASSERT(_wallet != 0);
42 
43  ConnectedAppModel *appModel = qobject_cast<ConnectedAppModel*>(model);
44  Q_ASSERT(appModel != 0);
45 
46  QTableView::setModel(model);
47  for (int row =0; row < model->rowCount(); row++) {
48  DisconnectAppButton *btn = new DisconnectAppButton( model->index(row, 0).data().toString() , _wallet);
49  btn->setFixedHeight(btn->sizeHint().height());
50  setRowHeight(row, btn->height());
51  setIndexWidget( model->index(row, 1), btn);
52  connect(btn, SIGNAL(appDisconnected(QString)), appModel, SLOT(removeApp(QString)));
53  }
54 }
55 
56 void ConnectedApplicationsTable::resizeEvent(QResizeEvent* resizeEvent)
57 {
58  // this will keep disconnect buttons column at it's minimum size and
59  // make the application names take the reminder of the horizontal space
60  resizeColumnsToContents();
61  int appColumnSize = contentsRect().width() - columnWidth(1) - 50;
62  setColumnWidth(0, appColumnSize);
63  QAbstractItemView::resizeEvent(resizeEvent);
64 }
65 
66 #include "connectedapplicationstable.moc"
QTableView::setColumnWidth
void setColumnWidth(int column, int width)
QResizeEvent
QWidget
QAbstractItemModel::rowCount
virtual int rowCount(const QModelIndex &parent) const =0
QAbstractItemModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
QPushButton::sizeHint
virtual QSize sizeHint() const
QTableView::resizeColumnsToContents
void resizeColumnsToContents()
QWidget::contentsRect
QRect contentsRect() const
connectedappmodel.h
ConnectedApplicationsTable::ConnectedApplicationsTable
ConnectedApplicationsTable(QWidget *parent)
Definition: connectedapplicationstable.cpp:28
ConnectedApplicationsTable::setWallet
void setWallet(KWallet::Wallet *wallet)
Definition: connectedapplicationstable.cpp:34
QAbstractItemView::resizeEvent
virtual void resizeEvent(QResizeEvent *event)
QTableView::setRowHeight
void setRowHeight(int row, int height)
QTableView::setModel
virtual void setModel(QAbstractItemModel *model)
disconnectappbutton.h
connectedapplicationstable.h
QTableView::columnWidth
int columnWidth(int column) const
QString
ConnectedApplicationsTable::resizeEvent
virtual void resizeEvent(QResizeEvent *resizeEvent)
Definition: connectedapplicationstable.cpp:56
QTableView
QRect::width
int width() const
ConnectedApplicationsTable::setModel
virtual void setModel(QAbstractItemModel *model)
Definition: connectedapplicationstable.cpp:39
QModelIndex::data
QVariant data(int role) const
QWidget::setFixedHeight
void setFixedHeight(int h)
QSize::height
int height() const
QAbstractItemView::setIndexWidget
void setIndexWidget(const QModelIndex &index, QWidget *widget)
QAbstractItemModel
DisconnectAppButton
Definition: disconnectappbutton.h:29
QAbstractItemView::model
QAbstractItemModel * model() const
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QVariant::toString
QString toString() const
QWidget::height
height
ConnectedAppModel
Definition: connectedappmodel.h:29
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:42:01 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kwallet

Skip menu "kwallet"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal