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

kremotecontrol

  • sources
  • kde-4.12
  • kdeutils
  • kremotecontrol
  • kcmremotecontrol
selectprofile.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) <2009> <Frank Scheffold (fscheffold@googlemail.com)>
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public License as
6  published by the Free Software Foundation; either version 2 of
7  the License or (at your option) version 3 or any later version
8  accepted by the membership of KDE e.V. (or its successor approved
9  by the membership of KDE e.V.), which shall act as a proxy
10  defined in Section 14 of version 3 of the license.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #include "selectprofile.h"
22 
23 #include <klocale.h>
24 #include <kdebug.h>
25 
26 SelectProfileWidget::SelectProfileWidget (QWidget *parent) : QWidget(parent) {
27  selectionLabel = new QLabel();
28  selectionLabel->setWordWrap(true);
29 
30  profilesWidget = new QTreeWidget();
31  layout = new QVBoxLayout(this);
32  QLabel *headerLabel = new QLabel(i18n("Select a profile to automatically generate actions for your remote control:"));
33  headerLabel->setWordWrap(true);
34  layout->addWidget(headerLabel);
35  profilesWidget->setHeaderLabel(i18n("Available profiles"));
36  layout->addWidget(profilesWidget);
37  layout->addWidget(selectionLabel);
38 
39 }
40 
41 SelectProfile::SelectProfile(Remote *remote, QWidget *parent, const bool &modal): KDialog(parent) {
42  selectProfileWidget = new SelectProfileWidget;
43 
44  setMainWidget(selectProfileWidget);
45  setButtons( Ok | Cancel);
46  setDefaultButton(Ok);
47  setModal(modal);
48  setMainWidget(selectProfileWidget);
49  setWindowTitle(i18n("Auto-Populate"));
50 
51  connect(selectProfileWidget->profilesWidget,SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(checkForUpdate(QTreeWidgetItem*,int)));
52  kDebug()<< "remote " << remote->name();
53  QList<Profile*> profiles = ProfileServer::allProfiles();
54  foreach(Profile* profile, profiles) {
55  ProfileServer::ProfileSupportedByRemote tSupported = ProfileServer::isProfileAvailableForRemote(profile, *remote);
56  kDebug()<< "support "<< tSupported;
57  if ( tSupported != ProfileServer::NO_ACTIONS_DEFINED) {
58  ProfileWrapper wrapper = ProfileWrapper(profile, tSupported);
59  QTreeWidgetItem* tTreewidget = new QTreeWidgetItem(selectProfileWidget->profilesWidget,QStringList()<< profile->name());
60  tTreewidget->setData(0,Qt::UserRole,qVariantFromValue<ProfileWrapper>(wrapper));
61  KIcon tIcon;
62  switch (tSupported) {
63  case ProfileServer::FULL_SUPPORTED:
64  tIcon = KIcon( QLatin1String( "flag-green" ));
65  break;
66  case ProfileServer::PARTIAL_SUPPORTED:
67  tIcon = KIcon( QLatin1String( "flag-yellow" ));
68  break;
69  default:
70  tIcon = KIcon( QLatin1String( "flag-red" ));
71  }
72  tTreewidget->setIcon(0, tIcon);
73  }
74  }
75  enableButtonOk(false);
76 }
77 
78 void SelectProfile::checkForUpdate(QTreeWidgetItem* widgetItem, int col) {
79  if (col == -1) {
80  selectProfileWidget->selectionLabel->setText(QString());
81  enableButtonOk(false);
82  return;
83  }
84  ProfileServer::ProfileSupportedByRemote tSupported = widgetItem->data(0, Qt::UserRole).value<ProfileWrapper>().getSupported();
85 
86  switch (tSupported) {
87  case ProfileServer::FULL_SUPPORTED:
88  selectProfileWidget->selectionLabel->setText(i18n("Remote supports all defined buttons in selected profile"));
89  enableButtonOk(true);
90  break;
91  case ProfileServer::PARTIAL_SUPPORTED:
92  selectProfileWidget->selectionLabel->setText(i18n("Remote does not support all defined buttons in selected profile"));
93  enableButtonOk(true);
94  break;
95  case ProfileServer::NOT_SUPPORTED:
96  selectProfileWidget->selectionLabel->setText(i18n("Remote supports none of the defined buttons in selected profile"));
97  enableButtonOk(false);
98  break;
99  default:
100  selectProfileWidget->selectionLabel->setText(QString());
101  enableButtonOk(false);
102  }
103 }
104 
105 Profile* SelectProfile::getSelectedProfile() {
106  return selectProfileWidget->profilesWidget->currentItem()->data(0, Qt::UserRole).value<ProfileWrapper>().getProfile();
107 }
108 
selectprofile.h
Remote::name
QString name() const
Definition: remote.cpp:247
ProfileServer::FULL_SUPPORTED
Definition: profileserver.h:36
SelectProfileWidget::selectionLabel
QLabel * selectionLabel
Definition: selectprofile.h:38
QWidget
SelectProfile::SelectProfile
SelectProfile(Remote *remote, QWidget *parent=0, const bool &modal=false)
Definition: selectprofile.cpp:41
SelectProfile::checkForUpdate
void checkForUpdate(QTreeWidgetItem *, int)
Definition: selectprofile.cpp:78
KDialog
ProfileServer::allProfiles
QList< Profile * > allProfiles()
Definition: profileserver.cpp:89
ProfileServer::ProfileSupportedByRemote
ProfileSupportedByRemote
Definition: profileserver.h:35
ProfileServer::NOT_SUPPORTED
Definition: profileserver.h:38
ProfileWrapper
Definition: selectprofile.h:62
ProfileServer::isProfileAvailableForRemote
ProfileServer::ProfileSupportedByRemote isProfileAvailableForRemote(Profile *profile, const Remote &remote)
Definition: profileserver.cpp:145
SelectProfile::getSelectedProfile
Profile * getSelectedProfile()
Definition: selectprofile.cpp:105
ProfileServer::NO_ACTIONS_DEFINED
Definition: profileserver.h:39
SelectProfileWidget
Definition: selectprofile.h:34
ProfileServer::profile
Profile * profile(const QString &profileId)
Definition: profileserver.cpp:93
SelectProfileWidget::SelectProfileWidget
SelectProfileWidget(QWidget *parent=0)
Definition: selectprofile.cpp:26
ProfileServer::PARTIAL_SUPPORTED
Definition: profileserver.h:37
Profile
Definition: profile.h:26
Profile::name
QString name() const
Definition: profile.cpp:56
SelectProfileWidget::layout
QVBoxLayout * layout
Definition: selectprofile.h:39
SelectProfileWidget::profilesWidget
QTreeWidget * profilesWidget
Definition: selectprofile.h:37
Remote
Definition: remote.h:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:43 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kremotecontrol

Skip menu "kremotecontrol"
  • Main Page
  • Namespace List
  • Namespace Members
  • 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
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • 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