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

krdc

  • sources
  • kde-4.12
  • kdenetwork
  • krdc
remotedesktopsmodel.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2008 Urs Wolfer <uwolfer @ kde.org>
4 ** Copyright (C) 2009 Tony Murray <murraytony@gmail.com>
5 **
6 ** This file is part of KDE.
7 **
8 ** This program is free software; you can redistribute it and/or modify
9 ** it under the terms of the GNU General Public License as published by
10 ** the Free Software Foundation; either version 2 of the License, or
11 ** (at your option) any later version.
12 **
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with this program; see the file COPYING. If not, write to
20 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ** Boston, MA 02110-1301, USA.
22 **
23 ****************************************************************************/
24 
25 #ifndef REMOTEDESKTOPSMODEL_H
26 #define REMOTEDESKTOPSMODEL_H
27 
28 #include <QAbstractTableModel>
29 #include <KDateTime>
30 
31 #ifdef BUILD_ZEROCONF
32 #include <dnssd/servicebrowser.h>
33 #endif
34 
35 class KBookmarkGroup;
36 class KBookmarkManager;
37 
38 struct RemoteDesktop {
39 public:
40  enum Source { None = 0x0, Bookmarks = 0x1, History = 0x2, Zeroconf = 0x4 };
41  Q_DECLARE_FLAGS(Sources, Source)
42  QString title;
43  QString url;
44  KDateTime lastConnected;
45  KDateTime created;
46  int visits;
47  RemoteDesktop::Source source;
48  bool favorite;
49  bool operator<(const RemoteDesktop &rd) const {
50  if (lastConnected == rd.lastConnected)
51  return url < rd.url;
52  return rd.lastConnected < lastConnected; // seems backward but gets the desired result
53  }
54  bool operator==(const RemoteDesktop &rd) const {
55  return url == rd.url;
56  }
57 };
58 
59 class RemoteDesktopsModel : public QAbstractTableModel
60 {
61  Q_OBJECT
62 
63 public:
64  explicit RemoteDesktopsModel(QObject *parent);
65  ~RemoteDesktopsModel();
66 
67  enum DisplayItems { Favorite, Title, LastConnected, VisitCount, Created, Source };
68  int rowCount(const QModelIndex &parent = QModelIndex()) const;
69  int columnCount(const QModelIndex &parent = QModelIndex()) const;
70  Qt::ItemFlags flags(const QModelIndex &index) const;
71  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
72  QVariant data(const QModelIndex &index, int role) const;
73  QVariant headerData(int section, Qt::Orientation orientation,
74  int role = Qt::DisplayRole) const;
75 
76 private:
77  QList<RemoteDesktop> remoteDesktops;
78  QString getLastConnectedString(KDateTime lastConnected, bool fuzzy = false) const;
79  void removeAllItemsFromSources(RemoteDesktop::Sources sources);
80  void buildModelFromBookmarkGroup(const KBookmarkGroup &group);
81  KBookmarkManager *m_manager;
82 
83 #ifdef BUILD_ZEROCONF
84  DNSSD::ServiceBrowser *zeroconfBrowser;
85  QHash<QString, QString> m_protocols;
86 #endif
87 
88 private slots:
89  void bookmarksChanged();
90 #ifdef BUILD_ZEROCONF
91  void servicesChanged();
92 #endif
93 };
94 
95 Q_DECLARE_OPERATORS_FOR_FLAGS(RemoteDesktop::Sources)
96 
97 #endif
RemoteDesktopsModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Definition: remotedesktopsmodel.cpp:173
RemoteDesktopsModel::LastConnected
Definition: remotedesktopsmodel.h:67
RemoteDesktop::visits
int visits
Definition: remotedesktopsmodel.h:46
RemoteDesktopsModel::~RemoteDesktopsModel
~RemoteDesktopsModel()
Definition: remotedesktopsmodel.cpp:52
RemoteDesktopsModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: remotedesktopsmodel.cpp:56
RemoteDesktopsModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const
Definition: remotedesktopsmodel.cpp:66
RemoteDesktop::None
Definition: remotedesktopsmodel.h:40
QObject
RemoteDesktopsModel::Favorite
Definition: remotedesktopsmodel.h:67
RemoteDesktopsModel::Title
Definition: remotedesktopsmodel.h:67
RemoteDesktop::title
QString title
Definition: remotedesktopsmodel.h:42
RemoteDesktop::lastConnected
KDateTime lastConnected
Definition: remotedesktopsmodel.h:44
RemoteDesktop::url
QString url
Definition: remotedesktopsmodel.h:43
RemoteDesktop::History
Definition: remotedesktopsmodel.h:40
RemoteDesktopsModel
Definition: remotedesktopsmodel.h:59
RemoteDesktopsModel::Created
Definition: remotedesktopsmodel.h:67
RemoteDesktopsModel::DisplayItems
DisplayItems
Definition: remotedesktopsmodel.h:67
RemoteDesktop::operator==
bool operator==(const RemoteDesktop &rd) const
Definition: remotedesktopsmodel.h:54
RemoteDesktop::Source
Source
Definition: remotedesktopsmodel.h:40
RemoteDesktopsModel::VisitCount
Definition: remotedesktopsmodel.h:67
RemoteDesktop::Zeroconf
Definition: remotedesktopsmodel.h:40
RemoteDesktopsModel::data
QVariant data(const QModelIndex &index, int role) const
Definition: remotedesktopsmodel.cpp:95
RemoteDesktopsModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: remotedesktopsmodel.cpp:61
RemoteDesktop::favorite
bool favorite
Definition: remotedesktopsmodel.h:48
RemoteDesktopsModel::setData
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Definition: remotedesktopsmodel.cpp:76
RemoteDesktopsModel::Source
Definition: remotedesktopsmodel.h:67
RemoteDesktop::source
RemoteDesktop::Source source
Definition: remotedesktopsmodel.h:47
RemoteDesktop::Bookmarks
Definition: remotedesktopsmodel.h:40
RemoteDesktopsModel::RemoteDesktopsModel
RemoteDesktopsModel(QObject *parent)
Definition: remotedesktopsmodel.cpp:32
RemoteDesktop::created
KDateTime created
Definition: remotedesktopsmodel.h:45
QAbstractTableModel
RemoteDesktop
Definition: remotedesktopsmodel.h:38
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:54:04 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

krdc

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

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

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