konsoleprofiles.cpp   konsoleprofiles.cpp 
skipping to change at line 30 skipping to change at line 30
KonsoleProfiles::KonsoleProfiles(QObject *parent, const KPluginMetaData &me taData, const QVariantList &args) KonsoleProfiles::KonsoleProfiles(QObject *parent, const KPluginMetaData &me taData, const QVariantList &args)
: AbstractRunner(parent, metaData, args) : AbstractRunner(parent, metaData, args)
{ {
setObjectName(QStringLiteral("Konsole Profiles")); setObjectName(QStringLiteral("Konsole Profiles"));
RunnerSyntax s(QStringLiteral(":q:"), i18n("Finds Konsole profiles matc hing :q:.")); RunnerSyntax s(QStringLiteral(":q:"), i18n("Finds Konsole profiles matc hing :q:."));
s.addExampleQuery(QStringLiteral("konsole :q:")); s.addExampleQuery(QStringLiteral("konsole :q:"));
addSyntax(s); addSyntax(s);
addSyntax(RunnerSyntax(QStringLiteral("konsole"), i18n("Lists all the K onsole profiles in your account."))); addSyntax(RunnerSyntax(QStringLiteral("konsole"), i18n("Lists all the K onsole profiles in your account.")));
setMinLetterCount(3); setMinLetterCount(3);
m_model.setAppName(m_triggerWord);
} }
void KonsoleProfiles::match(RunnerContext &context) void KonsoleProfiles::match(RunnerContext &context)
{ {
QString term = context.query(); QString term = context.query();
term = term.remove(m_triggerWord).simplified(); term = term.remove(m_triggerWord).simplified();
for (int i = 0, count = m_model.rowCount(); i < count; ++i) { for (int i = 0, count = m_model->rowCount(); i < count; ++i) {
QModelIndex idx = m_model.index(i); QModelIndex idx = m_model->index(i);
const QString name = idx.data(ProfilesModel::NameRole).toString(); const QString name = idx.data(ProfilesModel::NameRole).toString();
if (name.contains(term, Qt::CaseInsensitive)) { if (name.contains(term, Qt::CaseInsensitive)) {
const QString profileIdentifier = idx.data(ProfilesModel::Profi leIdentifierRole).toString(); const QString profileIdentifier = idx.data(ProfilesModel::Profi leIdentifierRole).toString();
QueryMatch match(this); QueryMatch match(this);
match.setType(QueryMatch::PossibleMatch); match.setType(QueryMatch::PossibleMatch);
match.setIconName(idx.data(ProfilesModel::IconNameRole).toStrin g()); match.setIconName(idx.data(ProfilesModel::IconNameRole).toStrin g());
match.setData(profileIdentifier); match.setData(profileIdentifier);
match.setText(QStringLiteral("Konsole: ") + name); match.setText(QStringLiteral("Konsole: ") + name);
match.setRelevance((float)term.length() / (float)name.length()) ; match.setRelevance((float)term.length() / (float)name.length()) ;
context.addMatch(match); context.addMatch(match);
} }
} }
} }
void KonsoleProfiles::run(const RunnerContext &context, const QueryMatch &m atch) void KonsoleProfiles::run(const RunnerContext &context, const QueryMatch &m atch)
{ {
Q_UNUSED(context) Q_UNUSED(context)
const QString profile = match.data().toString(); const QString profile = match.data().toString();
m_model.openProfile(profile); m_model->openProfile(profile);
}
void KonsoleProfiles::init()
{
// Only create this in the correct thread. Inside we use KDirWatch whic
h is thread sensitive.
m_model = new ProfilesModel(this);
m_model->setAppName(m_triggerWord);
} }
K_PLUGIN_CLASS_WITH_JSON(KonsoleProfiles, "plasma-runner-konsoleprofiles.js on") K_PLUGIN_CLASS_WITH_JSON(KonsoleProfiles, "plasma-runner-konsoleprofiles.js on")
#include "konsoleprofiles.moc" #include "konsoleprofiles.moc"
 End of changes. 3 change blocks. 
5 lines changed or deleted 11 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/