本文整理汇总了C++中plasma::DataEngine类的典型用法代码示例。如果您正苦于以下问题:C++ DataEngine类的具体用法?C++ DataEngine怎么用?C++ DataEngine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dataEngine
void
TabsApplet::saveSettings()
{
DEBUG_BLOCK
KConfigGroup config = Amarok::config("Tabs Applet");
bool fetchGuitar = ui_Settings.cbFetchGuitar->isChecked();
bool fetchBass = ui_Settings.cbFetchBass->isChecked();
// check if any setting has changed
bool forceUpdate = false;
if( m_fetchGuitar != fetchGuitar || m_fetchBass != fetchBass )
forceUpdate = true;
if( forceUpdate )
{
m_fetchGuitar = fetchGuitar;
m_fetchBass = fetchBass;
config.writeEntry( "FetchGuitar", m_fetchGuitar );
config.writeEntry( "FetchBass", m_fetchBass );
Plasma::DataEngine *engine = dataEngine( "amarok-tabs" );
engine->setProperty( "fetchGuitarTabs", m_fetchGuitar );
engine->setProperty( "fetchBassTabs", m_fetchBass );
engine->query( QLatin1String( "tabs:forceUpdate" ) );
}
}
示例2: urlChanged
void WebBrowser::urlChanged(const QUrl &url)
{
//ask for a favicon
Plasma::DataEngine *engine = dataEngine( "favicons" );
if (engine) {
//engine->disconnectSource( url.toString(), this );
engine->connectSource( url.toString(), this );
engine->query( url.toString() );
}
m_url = KUrl(url);
if (m_bookmarkModel->match(m_bookmarkModel->index(0,0), BookmarkItem::UrlRole, m_url.prettyUrl()).isEmpty()) {
m_addBookmark->setAction(m_addBookmarkAction);
} else {
m_addBookmark->setAction(m_removeBookmarkAction);
}
m_nativeHistoryCombo->addToHistory(m_url.prettyUrl());
m_nativeHistoryCombo->setCurrentIndex(0);
m_go->setAction(m_reloadAction);
KConfigGroup cg = config();
saveState(cg);
m_back->setEnabled(m_browser->page()->history()->canGoBack());
m_forward->setEnabled(m_browser->page()->history()->canGoForward());
setAssociatedApplicationUrls(KUrl(url));
}
示例3: updateTipContent
void ClockApplet::updateTipContent()
{
Plasma::ToolTipContent tipData;
QString subText("<table>");
QList<Plasma::DataEngine::Data> tzs;
Plasma::DataEngine *engine = dataEngine("time");
Plasma::DataEngine::Data data = engine->query("Local");
const QDate localDate = data["Date"].toDate();
const QString localTz = data["Timezone"].toString();
tzs.append(data);
bool highlightLocal = false;
const bool hasEvents = d->calendarWidget ? d->calendarWidget->dateHasDetails(localDate) : false;
tipData.setMainText(hasEvents ? i18n("Current Time and Events") : i18n("Current Time"));
foreach (const QString &tz, d->selectedTimezones) {
if (tz != "UTC") {
highlightLocal = true;
}
data = engine->query(tz);
tzs.append(data);
}
qSort(tzs.begin(), tzs.end(), sortTzByData);
QDate currentDate;
foreach (const Plasma::DataEngine::Data &data, tzs) {
bool shouldHighlight = highlightLocal && (data["Timezone"].toString() == localTz);
currentDate = d->addTzToTipText(subText, data, currentDate, shouldHighlight);
}
示例4: foreach
/**
* Loads an ion plugin given a plugin name found via KService.
*/
Plasma::DataEngine *WeatherEngine::loadIon(const QString& plugName)
{
KPluginInfo foundPlugin;
foreach(const KPluginInfo &info, Plasma::DataEngineManager::listEngineInfo("weatherengine")) {
if (info.pluginName() == plugName) {
foundPlugin = info;
break;
}
}
if (!foundPlugin.isValid()) {
return NULL;
}
// Load the Ion plugin, store it into a QMap to handle multiple ions.
Plasma::DataEngine *ion = Plasma::DataEngineManager::self()->loadEngine(foundPlugin.pluginName());
ion->setObjectName(plugName);
connect(ion, SIGNAL(sourceAdded(QString)), this, SLOT(newIonSource(QString)));
connect(ion, SIGNAL(forceUpdate(IonInterface*,QString)), this, SLOT(forceUpdate(IonInterface*,QString)));
m_ions << plugName;
return ion;
}
示例5: 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);
}
}
示例6: if
void
PhotosApplet::init()
{
DEBUG_BLOCK
// Call the base implementation.
Context::Applet::init();
// Create label
enableHeader( true );
setHeaderText( i18n( "Photos" ) );
// Set the collapse size
setCollapseHeight( m_header->height() );
setCollapseOffHeight( 220 );
setMaximumHeight( 220 );
setMinimumHeight( collapseHeight() );
setPreferredHeight( collapseHeight() );
// Icon
QAction* settingsAction = new QAction( this );
settingsAction->setIcon( KIcon( "preferences-system" ) );
settingsAction->setVisible( true );
settingsAction->setEnabled( true );
settingsAction->setText( i18n( "Settings" ) );
m_settingsIcon = addRightHeaderAction( settingsAction );
connect( m_settingsIcon, SIGNAL( clicked() ), this, SLOT( showConfigurationInterface() ) );
m_widget = new PhotosScrollWidget( this );
m_widget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_widget->setContentsMargins( 0, 0, 0, 0 );
connect( m_widget, SIGNAL(photoAdded()), SLOT(photoAdded()) );
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical, this );
layout->addItem( m_header );
layout->addItem( m_widget );
// Read config and inform the engine.
KConfigGroup config = Amarok::config("Photos Applet");
m_nbPhotos = config.readEntry( "NbPhotos", "10" ).toInt();
m_Animation = config.readEntry( "Animation", "Fading" );
m_KeyWords = config.readEntry( "KeyWords", QStringList() );
if( m_Animation == i18nc( "animation type", "Automatic" ) )
m_widget->setMode( 0 );
else if( m_Animation == i18n( "Interactive" ) )
m_widget->setMode( 1 );
else // fading
m_widget->setMode( 2 );
Plasma::DataEngine *engine = dataEngine( "amarok-photos" );
engine->setProperty( "fetchSize", m_nbPhotos );
engine->setProperty( "keywords", m_KeyWords );
engine->connectSource( "photos", this );
}
示例7: enableHeader
/**
* \brief Initialization
*
* Initializes the TabsApplet with default parameters
*/
void
TabsApplet::init()
{
// applet base initialization
Context::Applet::init();
// create the header label
enableHeader( true );
setHeaderText( i18nc( "Guitar tablature", "Tabs" ) );
// creates the tab view
m_tabsView = new TabsView( this );
// Set the collapse size
setCollapseOffHeight( -1 );
setCollapseHeight( m_header->height() );
setMinimumHeight( collapseHeight() );
setPreferredHeight( collapseHeight() );
// create the reload icon
QAction* reloadAction = new QAction( this );
reloadAction->setIcon( KIcon( "view-refresh" ) );
reloadAction->setVisible( true );
reloadAction->setEnabled( true );
reloadAction->setText( i18nc( "Guitar tablature", "Reload tabs" ) );
m_reloadIcon = addLeftHeaderAction( reloadAction );
m_reloadIcon.data()->setEnabled( false );
connect( m_reloadIcon.data(), SIGNAL(clicked()), this, SLOT(reloadTabs()) );
// create the settings icon
QAction* settingsAction = new QAction( this );
settingsAction->setIcon( KIcon( "preferences-system" ) );
settingsAction->setEnabled( true );
settingsAction->setText( i18n( "Settings" ) );
QWeakPointer<Plasma::IconWidget> settingsIcon = addRightHeaderAction( settingsAction );
connect( settingsIcon.data(), SIGNAL(clicked()), this, SLOT(showConfigurationInterface()) );
m_layout = new QGraphicsLinearLayout( Qt::Vertical );
m_layout->addItem( m_header );
m_layout->addItem( m_tabsView );
setLayout( m_layout );
// read configuration data and update the engine.
KConfigGroup config = Amarok::config("Tabs Applet");
m_fetchGuitar = config.readEntry( "FetchGuitar", true );
m_fetchBass = config.readEntry( "FetchBass", true );
Plasma::DataEngine *engine = dataEngine( "amarok-tabs" );
engine->setProperty( "fetchGuitarTabs", m_fetchGuitar );
engine->setProperty( "fetchBassTabs", m_fetchBass );
engine->connectSource( "tabs", this );
updateInterface( InitState );
}
示例8: addVisualization
bool Hdd::addVisualization(const QString& source)
{
Plasma::Meter *w;
Plasma::DataEngine *engine = dataEngine("soliddevice");
Plasma::DataEngine::Data data;
if (!engine) {
return false;
}
if (!isValidDevice(source, &data)) {
// do not try to show hard drives and swap partitions.
return false;
}
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal);
layout->setContentsMargins(3, 3, 3, 3);
layout->setSpacing(5);
w = new Plasma::Meter(this);
w->setMeterType(Plasma::Meter::BarMeterHorizontal);
if (mode() != SM::Applet::Panel) {
MonitorIcon *icon = new MonitorIcon(this);
m_icons.insert(source, icon);
icon->setImage("drive-harddisk");
if (data["Accessible"].toBool()) {
QStringList overlays;
overlays << QString("emblem-mounted");
icon->setOverlays(overlays);
}
layout->addItem(icon);
} else {
w->setSvg("system-monitor/hdd_panel");
}
w->setLabel(0, hddTitle(source, data));
w->setLabelAlignment(0, Qt::AlignVCenter | Qt::AlignLeft);
w->setLabelAlignment(1, Qt::AlignVCenter | Qt::AlignRight);
w->setLabelAlignment(2, Qt::AlignVCenter | Qt::AlignCenter);
w->setMaximum(data["Size"].toULongLong() / (1024 * 1024));
applyTheme(w);
appendVisualization(source, w);
layout->addItem(w);
mainLayout()->addItem(layout);
dataUpdated(source, data);
setPreferredItemHeight(layout->preferredSize().height());
QString disk = data["Parent UDI"].toString();
m_diskMap[disk] << w;
if (!connectedSources().contains(disk)) {
data = engine->query(disk);
dataUpdated(disk, data);
connectSource(disk);
}
return true;
}
示例9: connectToEngine
void Clock::connectToEngine()
{
resetLastTimeSeen();
Plasma::DataEngine* timeEngine = dataEngine("time");
timeEngine->disconnectSource(m_oldTimezone, this);
m_oldTimezone = currentTimezone();
if (m_showSecondHand) {
timeEngine->connectSource(currentTimezone(), this, 500);
} else {
timeEngine->connectSource(currentTimezone(), this, 6000, Plasma::AlignToMinute);
}
}
示例10: createNotification
void FdoSelectionManagerPrivate::createNotification(WId winId)
{
if (!tasks.contains(winId)) {
kDebug() << "message request from unknown task" << winId;
return;
}
MessageRequest &request = messageRequests[winId];
Task *task = tasks[winId];
QString message = QString::fromUtf8(request.message);
message = QTextDocument(message).toHtml();
if (!notificationsEngine) {
notificationsEngine = Plasma::DataEngineManager::self()->loadEngine("notifications");
}
//FIXME: who is the source in this case?
Plasma::Service *service = notificationsEngine->serviceForSource("notification");
KConfigGroup op = service->operationDescription("createNotification");
if (op.isValid()) {
op.writeEntry("appName", task->name());
//FIXME: find a way to pass icons trough here
op.writeEntry("appIcon", task->name());
//op.writeEntry("summary", task->name());
op.writeEntry("body", message);
op.writeEntry("timeout", (int)request.timeout);
KJob *job = service->startOperationCall(op);
QObject::connect(job, SIGNAL(finished(KJob*)), service, SLOT(deleteLater()));
} else {
delete service;
kDebug() << "invalid operation";
}
}
示例11: changeEngineTimezone
void Clock::changeEngineTimezone(const QString &oldTimezone, const QString &newTimezone)
{
dataEngine("time")->disconnectSource(oldTimezone, this);
Plasma::DataEngine* timeEngine = dataEngine("time");
if (m_showSecondHand) {
timeEngine->connectSource(newTimezone, this, 500);
} else {
timeEngine->connectSource(newTimezone, this, 6000, Plasma::AlignToMinute);
}
if (m_showingTimezone != (m_showTimezoneString || shouldDisplayTimezone())) {
m_showingTimezone = !m_showingTimezone;
constraintsEvent(Plasma::SizeConstraint);
}
m_repaintCache = RepaintAll;
}
示例12: dataUpdated
void PoTD::dataUpdated(const QString &source, const Plasma::DataEngine::Data &data)
{
if (source == QLatin1String("Providers")) {
m_providers = data;
if (!m_provider.isEmpty() && !m_providers.contains(m_provider)) {
Plasma::DataEngine *engine = dataEngine(QLatin1String("potd"));
engine->disconnectSource(m_provider, this);
m_provider = DEFAULT_PROVIDER;
engine->connectSource(m_provider, this);
}
} else if (source == m_provider) {
QImage image = data["Image"].value<QImage>();
render(image, boundingRect().size().toSize(), MaxpectResize);
} else {
dataEngine(QLatin1String("potd"))->disconnectSource(source, this);
}
}
示例13: 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);
}
示例14: 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;
}
}
示例15: dataEngine
void
PhotosApplet::saveSettings()
{
DEBUG_BLOCK
KConfigGroup config = Amarok::config("Photos Applet");
m_nbPhotos = ui_Settings.photosSpinBox->value();
m_Animation = ui_Settings.animationComboBox->currentText();
m_KeyWords = ui_Settings.additionalkeywordsLineEdit->text().split(", ");
config.writeEntry( "NbPhotos", m_nbPhotos );
config.writeEntry( "Animation", m_Animation );
config.writeEntry( "KeyWords", m_KeyWords );
m_widget->setMode( ui_Settings.animationComboBox->currentIndex() );
m_widget->clear();
Plasma::DataEngine *engine = dataEngine( "amarok-photos" );
engine->setProperty( "fetchSize", m_nbPhotos );
engine->setProperty( "keywords", m_KeyWords );
engine->query( QLatin1String( "photos:forceUpdate" ) );
}