• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

PlasmaExtraComponents

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • plasmaextracomponents
fallbackcomponent.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Marco Martin <mart@kde.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2, or
7  * (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
12  * GNU Library General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #include "fallbackcomponent.h"
21 
22 #include <QDir>
23 #include <QFile>
24 
25 #include <KStandardDirs>
26 #include <KDebug>
27 
28 
29 FallbackComponent::FallbackComponent(QObject *parent)
30  : QObject(parent)
31 {
32 }
33 
34 QString FallbackComponent::basePath() const
35 {
36  return m_basePath;
37 }
38 
39 void FallbackComponent::setBasePath(const QString &basePath)
40 {
41  if (basePath != m_basePath) {
42  m_basePath = basePath;
43  emit basePathChanged();
44  }
45 }
46 
47 QStringList FallbackComponent::candidates() const
48 {
49  return m_candidates;
50 }
51 
52 void FallbackComponent::setCandidates(const QStringList &candidates)
53 {
54  m_candidates = candidates;
55  emit candidatesChanged();
56 }
57 
58 QString FallbackComponent::filePath(const QString &key)
59 {
60  QString resolved;
61 
62  foreach (const QString &path, m_candidates) {
63  kDebug() << "Searching for:" << path + path;
64  if (m_possiblePaths.contains(path + key)) {
65  resolved = *m_possiblePaths.object(path + key);
66  if (!resolved.isEmpty()) {
67  break;
68  } else {
69  continue;
70  }
71  }
72 
73  QDir tmpPath(m_basePath);
74 
75  if (tmpPath.isAbsolute()) {
76  resolved = m_basePath + path + key;
77  } else {
78 
79  resolved = KStandardDirs::locate("data", m_basePath + '/' + path + key);
80  }
81 
82  m_possiblePaths.insert(path + key, new QString(resolved));
83  if (!resolved.isEmpty()) {
84  break;
85  }
86  }
87 
88  return resolved;
89 }
90 
91 #include "fallbackcomponent.moc"
FallbackComponent::candidates
QStringList candidates() const
FallbackComponent::FallbackComponent
FallbackComponent(QObject *parent=0)
Definition: fallbackcomponent.cpp:29
FallbackComponent::candidatesChanged
void candidatesChanged()
QCache::contains
bool contains(const Key &key) const
QCache::object
T * object(const Key &key) const
QObject
QString::isEmpty
bool isEmpty() const
QCache::insert
bool insert(const Key &key, T *object, int cost)
QDir::isAbsolute
bool isAbsolute() const
QString
QStringList
FallbackComponent::basePath
QString basePath() const
fallbackcomponent.h
QDir
FallbackComponent::setCandidates
void setCandidates(const QStringList &candidates)
Definition: fallbackcomponent.cpp:52
FallbackComponent::setBasePath
void setBasePath(const QString &basePath)
Definition: fallbackcomponent.cpp:39
FallbackComponent::filePath
Q_INVOKABLE QString filePath(const QString &key=QString())
This method must be called after the the basePath and the candidates property This method resolves a ...
Definition: fallbackcomponent.cpp:58
FallbackComponent::basePathChanged
void basePathChanged()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:46 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

PlasmaExtraComponents

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

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

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