本文整理汇总了C++中plasma::DataEngine::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ DataEngine::isValid方法的具体用法?C++ DataEngine::isValid怎么用?C++ DataEngine::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plasma::DataEngine
的用法示例。
在下文中一共展示了DataEngine::isValid方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DisconnectSource
void ControlWidget::DisconnectSource()
{
Plasma::DataEngine* engine = m_parent->getDataEngine();
if (engine && engine->isValid())
{
Logger::Log(DEBUG, "Disconnecting source %s", m_unit.address());
engine->disconnectSource(m_unit.address(), this);
}
}
示例2: ConnectSource
void ControlWidget::ConnectSource()
{
Plasma::DataEngine* engine = m_parent->getDataEngine();
if (engine && engine->isValid())
{
Logger::Log(DEBUG, "Connecting source %s", m_unit.address());
engine->connectSource(m_unit.address(), this, 0);
m_serviceUnit = engine->serviceForSource(m_unit.address());
if (!m_serviceUnit)
Logger::Log(ERROR, "Connecting source %s: Null Service", m_unit.address());
}
else
{
Logger::Log(ERROR, "Connecting source %s: Null Data Engine", m_unit.address());
m_serviceUnit = 0;
}
}
示例3: init
void RtdScheduleApplet::init()
{
QString sourceName = QLatin1String("NextStops [B/BF/BX-E:Broadway - 16th St (University of Colorado)"
",DASH-E:Broadway - 16th St (University of Colorado)"
",204-S:Broadway - 16th St (University of Colorado)"
",AB-E:Broadway - 16th St (University of Colorado)"
"] 4");
// NextStops [B/BF/BX-E:Broadway - 16th St (University of Colorado),DASH-E:Broadway - 16th St (University of Colorado),204-S:Broadway - 16th St (University of Colorado),AB-E:Broadway - 16th St (University of Colorado)] 4 TEXT
Plasma::DataEngine *de = dataEngine("rtddenver");
if (!de->isValid()) {
setFailedToLaunch(true, i18n("Cannot connect to RTD Denver data engine"));
return;
}
setBusy(true);
de->connectSource(sourceName, this, 60*1000, Plasma::AlignToMinute);
}
示例4: makeMenu
void SwitchWindow::makeMenu()
{
m_menu->clear();
Plasma::DataEngine *tasks = dataEngine("tasks");
if (!tasks->isValid()) {
return;
}
QMultiHash<int, QAction*> desktops;
//make all the window actions
foreach (const QString &source, tasks->sources()) {
Plasma::DataEngine::Data window = tasks->query(source);
if (window.value("startup").toBool()) {
//kDebug() << "skipped fake task" << source;
continue;
}
if (!window.value("onCurrentActivity").toBool()) {
continue;
}
QString name = window.value("visibleNameWithState").toString();
if (name.isEmpty()) {
kDebug() << "failed source" << source;
continue;
}
QAction *action = new QAction(name, m_menu);
action->setIcon(window.value("icon").value<QIcon>());
action->setData(source);
desktops.insert(window.value("desktop").toInt(), action);
}
//sort into menu
if (m_mode == CurrentDesktop) {
int currentDesktop = KWindowSystem::currentDesktop();
m_menu->addTitle(i18n("Windows"));
m_menu->addActions(desktops.values(currentDesktop));
m_menu->addActions(desktops.values(-1));
} else {
int numDesktops = KWindowSystem::numberOfDesktops();
if (m_mode == AllFlat) {
for (int i = 1; i <= numDesktops; ++i) {
if (desktops.contains(i)) {
QString name = KWindowSystem::desktopName(i);
name = QString("%1: %2").arg(i).arg(name);
m_menu->addTitle(name);
m_menu->addActions(desktops.values(i));
}
}
if (desktops.contains(-1)) {
m_menu->addTitle(i18n("All Desktops"));
m_menu->addActions(desktops.values(-1));
}
} else { //submenus
for (int i = 1; i <= numDesktops; ++i) {
if (desktops.contains(i)) {
QString name = KWindowSystem::desktopName(i);
name = QString("%1: %2").arg(i).arg(name);
KMenu *subMenu = new KMenu(name, m_menu);
subMenu->addActions(desktops.values(i));
m_menu->addMenu(subMenu);
}
}
if (desktops.contains(-1)) {
KMenu *subMenu = new KMenu(i18n("All Desktops"), m_menu);
subMenu->addActions(desktops.values(-1));
m_menu->addMenu(subMenu);
}
}
}
m_menu->adjustSize();
}
示例5: init
void WicdApplet::init()
{
m_theme->resize(contentsRect().size());
Plasma::ToolTipManager::self()->registerWidget(this);
//load dataengine
Plasma::DataEngine *engine = dataEngine("wicd");
if (!engine->isValid()) {
setFailedToLaunch(true, i18n("Unable to load the Wicd data engine."));
return;
}
setupActions();
//build the popup dialog
QGraphicsWidget *appletDialog = new QGraphicsWidget(this);
m_dialoglayout = new QGraphicsLinearLayout(Qt::Vertical);
//Network list
m_scrollWidget = new Plasma::ScrollWidget(appletDialog);
m_scrollWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_scrollWidget->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
m_scrollWidget->setMaximumHeight(400);
m_networkView = new NetworkView(m_scrollWidget);
m_scrollWidget->setWidget(m_networkView);
m_busyWidget = new Plasma::BusyWidget(m_scrollWidget);
m_busyWidget->hide();
m_dialoglayout->addItem(m_scrollWidget);
//Separator
m_dialoglayout->addItem(new Plasma::Separator(appletDialog));
//Bottom bar
QGraphicsLinearLayout* bottombarLayout = new QGraphicsLinearLayout(Qt::Horizontal);
m_messageBox = new Plasma::Label(appletDialog);
m_messageBox->setWordWrap(false);
bottombarLayout->addItem(m_messageBox);
bottombarLayout->addStretch();
m_abortButton = new Plasma::ToolButton(appletDialog);
m_abortButton->setIcon(KIcon("dialog-cancel"));
m_abortButton->nativeWidget()->setToolTip(i18n("Abort"));
connect(m_abortButton, SIGNAL(clicked()), this, SLOT(cancelConnect()));
bottombarLayout->addItem(m_abortButton);
Plasma::ToolButton *reloadButton = new Plasma::ToolButton(appletDialog);
reloadButton->nativeWidget()->setToolTip(i18n("Reload"));
reloadButton->setAction(action("reload"));
bottombarLayout->addItem(reloadButton);
m_dialoglayout->addItem(bottombarLayout);
appletDialog->setLayout(m_dialoglayout);
setGraphicsWidget(appletDialog);
setHasConfigurationInterface(true);
// read config
configChanged();
connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), SLOT(updateColors()));
//prevent notification on startup
m_status.State = 10;
m_isScanning = false;
//connect dataengine
m_wicdService = engine->serviceForSource("");
engine->connectSource("status", this);
engine->connectSource("daemon", this);
}