diff --git a/applets/comic/comic.h b/applets/comic/comic.h index b46b1d1c5..0007200cf 100644 --- a/applets/comic/comic.h +++ b/applets/comic/comic.h @@ -1,224 +1,224 @@ /*************************************************************************** * Copyright (C) 2007 by Tobias Koenig * * Copyright (C) 2008 by Marco Martin * * Copyright (C) 2008-2010 Matthias Fuchs * * Copyright (C) 2012 Reza Fatahilah Shah * * Copyright (C) 2015 Marco Martin * * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #ifndef COMIC_H #define COMIC_H #include "comicdata.h" #include #include #include #include #include #include "activecomicmodel.h" class CheckNewStrips; class ComicModel; class ConfigWidget; class QAction; class KJob; class QAction; class QSortFilterProxyModel; class QTimer; class SavingDir; namespace KNS3 { class DownloadDialog; } class ComicApplet : public Plasma::Applet, public Plasma::DataEngineConsumer { Q_OBJECT Q_PROPERTY(QObject *comicsModel READ comicsModel NOTIFY comicModelChanged) Q_PROPERTY(QObject *availableComicsModel READ availableComicsModel CONSTANT) Q_PROPERTY(bool showComicUrl READ showComicUrl WRITE setShowComicUrl NOTIFY showComicUrlChanged) Q_PROPERTY(bool showComicAuthor READ showComicAuthor WRITE setShowComicAuthor NOTIFY showComicAuthorChanged) Q_PROPERTY(bool showComicTitle READ showComicTitle WRITE setShowComicTitle NOTIFY showComicTitleChanged) Q_PROPERTY(bool showComicIdentifier READ showComicIdentifier WRITE setShowComicIdentifier NOTIFY showComicIdentifierChanged) Q_PROPERTY(bool showErrorPicture READ showErrorPicture WRITE setShowErrorPicture NOTIFY showErrorPictureChanged) Q_PROPERTY(bool arrowsOnHover READ arrowsOnHover WRITE setArrowsOnHover NOTIFY arrowsOnHoverChanged) Q_PROPERTY(bool middleClick READ middleClick WRITE setMiddleClick NOTIFY middleClickChanged) Q_PROPERTY(QVariantMap comicData READ comicData NOTIFY comicDataChanged) Q_PROPERTY(bool showActualSize READ showActualSize WRITE setShowActualSize NOTIFY showActualSizeChanged) Q_PROPERTY(QStringList tabIdentifiers READ tabIdentifiers WRITE setTabIdentifiers NOTIFY tabIdentifiersChanged) Q_PROPERTY(int checkNewComicStripsInterval READ checkNewComicStripsInterval WRITE setCheckNewComicStripsInterval NOTIFY checkNewComicStripsIntervalChanged) Q_PROPERTY(int providerUpdateInterval READ providerUpdateInterval WRITE setProviderUpdateInterval NOTIFY providerUpdateIntervalChanged) - Q_PROPERTY(int maxComicLimit READ maxComicLimit WRITE setMaxComicLimit NOTIFY maxComicLimitChanged); + Q_PROPERTY(int maxComicLimit READ maxComicLimit WRITE setMaxComicLimit NOTIFY maxComicLimitChanged) public: ComicApplet( QObject *parent, const QVariantList &args ); ~ComicApplet() override; void init() override; QList contextualActions() override; //For QML QObject *comicsModel() const; QObject *availableComicsModel() const; QVariantMap comicData() const; QStringList tabIdentifiers() const; void setTabIdentifiers(const QStringList &tabs); bool showComicUrl() const; void setShowComicUrl(bool show); bool showComicAuthor() const; void setShowComicAuthor(bool show); bool showComicTitle() const; void setShowComicTitle(bool show); bool showComicIdentifier() const; void setShowComicIdentifier(bool show); bool showErrorPicture() const; void setShowErrorPicture(bool show); bool arrowsOnHover() const; void setArrowsOnHover(bool show); bool middleClick() const; void setMiddleClick(bool show); bool showActualSize() const; void setShowActualSize(bool show); int checkNewComicStripsInterval() const; void setCheckNewComicStripsInterval(int interval); int providerUpdateInterval() const; void setProviderUpdateInterval(int interval); void setMaxComicLimit(int limit); int maxComicLimit() const; //End for QML Q_SIGNALS: void comicModelChanged(); void showComicUrlChanged(); void showComicAuthorChanged(); void showComicTitleChanged(); void showComicIdentifierChanged(); void showErrorPictureChanged(); void arrowsOnHoverChanged(); void middleClickChanged(); void comicDataChanged(); void tabHighlightRequest(const QString &id, bool highlight); void showNextNewStrip(); void showActualSizeChanged(); void tabIdentifiersChanged(); void checkNewComicStripsIntervalChanged(); void providerUpdateIntervalChanged(); void maxComicLimitChanged(); public Q_SLOTS: void dataUpdated( const QString &name, const Plasma::DataEngine::Data &data ); private Q_SLOTS: void slotTabChanged( const QString &newIdentifier ); void slotNextDay(); void slotPreviousDay(); void slotFirstDay(); void slotCurrentDay(); void slotFoundLastStrip( int index, const QString &identifier, const QString &suffix ); void slotGoJump(); void slotSaveComicAs(); void slotScaleToContent(); void slotShop(); void slotStorePosition(); void checkDayChanged(); void createComicBook(); void slotArchive( int archiveType, const QUrl &dest, const QString &fromIdentifier, const QString &toIdentifier ); void slotArchiveFinished( KJob *job ); public Q_SLOTS: void configChanged() override; void saveConfig(); Q_INVOKABLE void updateComic(const QString &identifierSuffix = QString()); Q_INVOKABLE void goJump() { slotGoJump();} Q_INVOKABLE void shop() { slotShop();} Q_INVOKABLE void tabChanged(const QString &newIdentifier) { slotTabChanged(newIdentifier);} Q_INVOKABLE void getNewComics(); Q_INVOKABLE void positionFullView(QWindow *window); private: void changeComic( bool differentComic ); void updateUsedComics(); void updateContextMenu(); void updateView(); void refreshComicData(); void setTabHighlighted(const QString &id, bool highlight); bool isTabHighlighted(const QString &id) const; private: static const int CACHE_LIMIT; ComicModel *mModel; QSortFilterProxyModel *mProxy; ActiveComicModel *mActiveComicModel; QVariantMap mComicData; QDate mCurrentDay; QString mIdentifierError; QString mOldSource; ConfigWidget *mConfigWidget; bool mDifferentComic; bool mShowComicUrl; bool mShowComicAuthor; bool mShowComicTitle; bool mShowComicIdentifier; bool mShowErrorPicture; bool mArrowsOnHover; bool mMiddleClick; int mCheckNewComicStripsInterval; int mMaxComicLimit; CheckNewStrips *mCheckNewStrips; QTimer *mDateChangedTimer; QList mActions; QAction *mActionGoFirst; QAction *mActionGoLast; QAction *mActionGoJump; QAction *mActionScaleContent; QAction *mActionShop; QAction *mActionStorePosition; QAction *mActionNextNewStripTab; QSizeF mMaxSize; QSizeF mLastSize; QSizeF mIdealSize; Plasma::DataEngine *mEngine; QPointer m_newStuffDialog; //Tabs bool mTabAdded; QStringList mTabIdentifier; ComicData mCurrent; SavingDir *mSavingDir; }; #endif diff --git a/applets/grouping/container/groupedappletscontainer.h b/applets/grouping/container/groupedappletscontainer.h index b12d65ba9..9cb477799 100644 --- a/applets/grouping/container/groupedappletscontainer.h +++ b/applets/grouping/container/groupedappletscontainer.h @@ -1,54 +1,54 @@ /*************************************************************************** * Copyright (C) 2015 Marco Martin * * Copyright (C) 2016 David Edmundson * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #ifndef GROUPEDAPPLETSCONTAINER_H #define GROUPEDAPPLETSCONTAINER_H #include class QQuickItem; class GroupedAppletsContainer : public Plasma::Applet { Q_OBJECT Q_PROPERTY(QQuickItem *internalContainmentItem READ internalContainmentItem NOTIFY internalContainmentItemChanged) public: - GroupedAppletsContainer(QObject *parent, const QVariantList &args); + explicit GroupedAppletsContainer(QObject *parent, const QVariantList &args); ~GroupedAppletsContainer() override; void init() override; QQuickItem *internalContainmentItem(); protected: void constraintsEvent(Plasma::Types::Constraints constraints) override; void ensureSystrayExists(); Q_SIGNALS: void internalContainmentItemChanged(); private: QPointer m_innerContainment; QPointer m_internalContainmentItem; }; #endif diff --git a/applets/grouping/groupingcontainment.h b/applets/grouping/groupingcontainment.h index 050addef5..66fdd612c 100644 --- a/applets/grouping/groupingcontainment.h +++ b/applets/grouping/groupingcontainment.h @@ -1,71 +1,71 @@ /*************************************************************************** * Copyright (C) 2015 Marco Martin * * Copyright (C) 2016 David Edmundson * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ #ifndef GROUPINGCONTAINMENT_H #define GROUPINGCONTAINMENT_H #include class QQuickItem; class GroupingContainment : public Plasma::Containment { Q_OBJECT public: - GroupingContainment( QObject *parent, const QVariantList &args ); + explicit GroupingContainment( QObject *parent, const QVariantList &args ); ~GroupingContainment() override; void init() override; //Creates an applet Q_INVOKABLE void newTask(const QString &task); //cleans all instances of a given applet void cleanupTask(const QString &task); /** * Given an AppletInterface pointer, shows a proper context menu for it */ Q_INVOKABLE void showPlasmoidMenu(QQuickItem *appletInterface, int x, int y); /** * Find out global coordinates for a popup given local MouseArea * coordinates */ Q_INVOKABLE QPointF popupPosition(QQuickItem* visualParent, int x, int y); /** * Reparent the item "before" with the same parent as the item "after", * then restack it before it, using QQuickITem::stackBefore. * used to quickly reorder icons in the systray (or hidden popup) * @see QQuickITem::stackBefore */ Q_INVOKABLE void reorderItemBefore(QQuickItem* before, QQuickItem* after); /** * Reparent the item "after" with the same parent as the item "before", * then restack it after it, using QQuickITem::stackAfter. * used to quickly reorder icons in the systray (or hidden popup) * @see QQuickITem::stackAfter */ Q_INVOKABLE void reorderItemAfter(QQuickItem* after, QQuickItem* before); }; #endif diff --git a/applets/mediaframe/plugin/mediaframe.cpp b/applets/mediaframe/plugin/mediaframe.cpp index 7a81fdbde..0ee66100d 100644 --- a/applets/mediaframe/plugin/mediaframe.cpp +++ b/applets/mediaframe/plugin/mediaframe.cpp @@ -1,409 +1,408 @@ /* * Copyright 2015 Lars Pontoppidan * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. */ #include "mediaframe.h" #include #include #include #include #include #include #include #include #include #include -//#include #include #include MediaFrame::MediaFrame(QObject *parent) : QObject(parent) { qsrand(QTime::currentTime().msec()); const auto imageMimeTypeNames = QImageReader::supportedMimeTypes(); QMimeDatabase mimeDb; for (const auto& imageMimeTypeName : imageMimeTypeNames) { const auto mimeType = mimeDb.mimeTypeForName(QLatin1String(imageMimeTypeName)); m_filters << mimeType.globPatterns(); } qDebug() << "Added" << m_filters.count() << "filters"; //qDebug() << m_filters; m_next = 0; connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &MediaFrame::slotItemChanged); connect(&m_watcher, &QFileSystemWatcher::fileChanged, this, &MediaFrame::slotItemChanged); } MediaFrame::~MediaFrame() = default; int MediaFrame::count() const { return m_allFiles.count(); } bool MediaFrame::random() const { return m_random; } void MediaFrame::setRandom(bool random) { if (random != m_random) { m_random = random; emit randomChanged(); } } int MediaFrame::random(int min, int max) { if (min > max) { int temp = min; min = max; max = temp; } //qDebug() << "random" << min << "<->" << max << "=" << ((qrand()%(max-min+1))+min); return ((qrand() % (max - min + 1) ) + min); } QString MediaFrame::getCacheDirectory() { return QDir::temp().absolutePath(); } QString MediaFrame::hash(const QString &str) { return QString::fromLatin1(QCryptographicHash::hash(str.toUtf8(), QCryptographicHash::Md5).toHex()); } bool MediaFrame::isDir(const QString &path) { return QDir(path).exists(); } bool MediaFrame::isDirEmpty(const QString &path) { return (isDir(path) && QDir(path).entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries).isEmpty()); } bool MediaFrame::isFile(const QString &path) { // Check if the file exists and is not a directory return (QFileInfo::exists(path) && QFileInfo(path).isFile()); } void MediaFrame::add(const QString &path) { add(path, AddOption::NON_RECURSIVE); } void MediaFrame::add(const QString &path, AddOption option) { if(isAdded(path)) { qWarning() << "Path" << path << "already added"; return; } QUrl url = QUrl(path); QString localPath = url.toString(QUrl::PreferLocalFile); //qDebug() << "Local path" << localPath << "Path" << path; QStringList paths; QString filePath; if(isDir(localPath)) { if(!isDirEmpty(localPath)) { QDirIterator dirIterator(localPath, m_filters, QDir::Files, (option == AddOption::RECURSIVE ? QDirIterator::Subdirectories | QDirIterator::FollowSymlinks : QDirIterator::NoIteratorFlags)); while (dirIterator.hasNext()) { dirIterator.next(); filePath = dirIterator.filePath(); paths.append(filePath); m_allFiles.append(filePath); //qDebug() << "Appended" << filePath; emit countChanged(); } if(paths.count() > 0) { m_pathMap.insert(path, paths); qDebug() << "Added" << paths.count() << "files from" << path; } else { qWarning() << "No images found in directory" << path; } } else { qWarning() << "Not adding empty directory" << path; } // the pictures have to be sorted before adding them to the list, // because the QDirIterator sorts them in a different way than QDir::entryList //paths.sort(); } else if(isFile(localPath)) { paths.append(path); m_pathMap.insert(path, paths); m_allFiles.append(path); qDebug() << "Added" << paths.count() << "files from" << path; emit countChanged(); } else { if (url.isValid() && !url.isLocalFile()) { qDebug() << "Adding" << url.toString() << "as remote file"; paths.append(path); m_pathMap.insert(path, paths); m_allFiles.append(path); emit countChanged(); } else { qWarning() << "Path" << path << "is not a valid file url or directory"; } } } void MediaFrame::clear() { m_pathMap.clear(); m_allFiles.clear(); emit countChanged(); } void MediaFrame::watch(const QString &path) { QUrl url = QUrl(path); QString localPath = url.toString(QUrl::PreferLocalFile); if(isFile(localPath)) { if(!m_watchFile.isEmpty()) { //qDebug() << "Removing" << m_watchFile << "from watch list"; m_watcher.removePath(m_watchFile); } else { qDebug() << "Nothing in watch list"; } //qDebug() << "watching" << localPath << "for changes"; m_watcher.addPath(localPath); m_watchFile = localPath; } else { qWarning() << "Can't watch remote file" << path << "for changes"; } } bool MediaFrame::isAdded(const QString &path) { return (m_pathMap.contains(path)); } void MediaFrame::get(QJSValue successCallback) { get(successCallback, QJSValue::UndefinedValue); } void MediaFrame::get(QJSValue successCallback, QJSValue errorCallback) { int size = m_allFiles.count() - 1; QString path; QString errorMessage; QJSValueList args; if(size < 1) { if(size == 0) { path = m_allFiles.at(0); if(successCallback.isCallable()) { args << QJSValue(path); successCallback.call(args); } return; } else { errorMessage = QStringLiteral("No files available"); qWarning() << errorMessage; args << QJSValue(errorMessage); errorCallback.call(args); return; } } if(m_random) { path = m_allFiles.at(this->random(0, size)); } else { path = m_allFiles.at(m_next); m_next++; if(m_next > size) { qDebug() << "Resetting next count from" << m_next << "due to queue size" << size; m_next = 0; } } QUrl url = QUrl(path); if(url.isValid()) { QString localPath = url.toString(QUrl::PreferLocalFile); if (!isFile(localPath)) { m_filename = path.section(QLatin1Char('/'), -1); QString cachedFile = getCacheDirectory()+QLatin1Char('/')+hash(path)+QLatin1Char('_')+m_filename; if(isFile(cachedFile)) { // File has been cached qDebug() << path << "is cached as" << cachedFile; if(successCallback.isCallable()) { args << QJSValue(cachedFile); successCallback.call(args); } return; } m_successCallback = successCallback; m_errorCallback = errorCallback; m_filename = cachedFile; qDebug() << path << "doesn't exist locally, trying remote."; KIO::StoredTransferJob * job = KIO::storedGet( url, KIO::NoReload, KIO::HideProgressInfo); connect(job, SIGNAL(finished(KJob*)), this, SLOT(slotFinished(KJob*))); } else { if(successCallback.isCallable()) { args << QJSValue(path); successCallback.call(args); } return; } } else { errorMessage = path + QLatin1String(" is not a valid URL"); qCritical() << errorMessage; if(errorCallback.isCallable()) { args << QJSValue(errorMessage); errorCallback.call(args); } return; } } void MediaFrame::pushHistory(const QString &string) { m_history.prepend(string); // Keep a sane history size if(m_history.length() > 50) m_history.removeLast(); } QString MediaFrame::popHistory() { if(m_history.isEmpty()) return QString(); return m_history.takeFirst(); } int MediaFrame::historyLength() { return m_history.length(); } void MediaFrame::pushFuture(const QString &string) { m_future.prepend(string); } QString MediaFrame::popFuture() { if(m_future.isEmpty()) return QString(); return m_future.takeFirst(); } int MediaFrame::futureLength() { return m_future.length(); } void MediaFrame::slotItemChanged(const QString &path) { emit itemChanged(path); } void MediaFrame::slotFinished(KJob *job) { QString errorMessage; QJSValueList args; if (job->error()) { errorMessage = QLatin1String("Error loading image: ") + job->errorString(); qCritical() << errorMessage; if(m_errorCallback.isCallable()) { args << QJSValue(errorMessage); m_errorCallback.call(args); } } else if (KIO::StoredTransferJob *transferJob = qobject_cast(job)) { QImage image; // TODO make proper caching calls QString path = m_filename; qDebug() << "Saving download to" << path; image.loadFromData(transferJob->data()); image.save(path); qDebug() << "Saved to" << path; if(m_successCallback.isCallable()) { args << QJSValue(path); m_successCallback.call(args); } } else { errorMessage = QStringLiteral("Unknown error occurred"); qCritical() << errorMessage; if(m_errorCallback.isCallable()) { args << QJSValue(errorMessage); m_errorCallback.call(args); } } } diff --git a/dataengines/konsoleprofiles/konsoleprofilesengine.h b/dataengines/konsoleprofiles/konsoleprofilesengine.h index d52f41442..6bd4eeba8 100644 --- a/dataengines/konsoleprofiles/konsoleprofilesengine.h +++ b/dataengines/konsoleprofiles/konsoleprofilesengine.h @@ -1,46 +1,46 @@ /***************************************************************************** * Copyright (C) 2011 by Shaun Reich * * Copyright (C) 2008 by Montel Laurent * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * *****************************************************************************/ #ifndef KONSOLEPROFILESENGINE_H #define KONSOLEPROFILESENGINE_H #include class KDirWatch; class KonsoleProfilesEngine : public Plasma::DataEngine { Q_OBJECT public: - KonsoleProfilesEngine(QObject *parent, const QVariantList &args); + explicit KonsoleProfilesEngine(QObject *parent, const QVariantList &args); ~KonsoleProfilesEngine() override; void init(); Plasma::Service *serviceForSource(const QString &source) override; private Q_SLOTS: void profilesChanged(); private: void loadProfiles(); KDirWatch *m_dirWatch; }; #endif diff --git a/dataengines/potd/apodprovider.h b/dataengines/potd/apodprovider.h index 7f8eb9bb7..09588ac8a 100644 --- a/dataengines/potd/apodprovider.h +++ b/dataengines/potd/apodprovider.h @@ -1,73 +1,73 @@ /* * Copyright (C) 2007 Tobias Koenig * Copyright 2008 by Anne-Marie Mahfouf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef APODPROVIDER_H #define APODPROVIDER_H #include "potdprovider.h" #include class KJob; /** * This class provides the image for APOD * "Astronomy Picture Of the Day" * located at http://antwrp.gsfc.nasa.gov/apod. * Direct link to the picture of the day page is * http://antwrp.gsfc.nasa.gov/apod/apYYMMDD.html * where YY is the year last 2 digits, * MM is the month and DD the day, in 2 digits. */ class ApodProvider : public PotdProvider { Q_OBJECT public: /** * Creates a new APOD provider. * * @param date The date for which the image shall be fetched. * @param parent The parent object. */ - ApodProvider( QObject *parent, const QVariantList &args ); + explicit ApodProvider( QObject *parent, const QVariantList &args ); /** * Destroys the APOD provider. */ ~ApodProvider() override; /** * Returns the requested image. * * Note: This method returns only a valid image after the * finished() signal has been emitted. */ QImage image() const override; private: void pageRequestFinished(KJob *job); void imageRequestFinished(KJob *job); private: QImage mImage; }; #endif diff --git a/dataengines/potd/flickrprovider.h b/dataengines/potd/flickrprovider.h index 9b9046549..de62edb55 100644 --- a/dataengines/potd/flickrprovider.h +++ b/dataengines/potd/flickrprovider.h @@ -1,80 +1,80 @@ /* * Copyright (C) 2007 Tobias Koenig * Copyright 2008 by Anne-Marie Mahfouf * Copyright 2008 by Georges Toth * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FLICKRPROVIDER_H #define FLICKRPROVIDER_H #include "potdprovider.h" // Qt #include #include #include class KJob; /** * This class grabs a random image from the flickr * interestingness stream of pictures, for the given date. * Should there be no image for the current date, it tries * to grab one from the day before yesterday. */ class FlickrProvider : public PotdProvider { Q_OBJECT public: /** * Creates a new flickr provider. * * @param date The date for which the image shall be fetched. * @param parent The parent object. */ - FlickrProvider( QObject *parent, const QVariantList &args ); + explicit FlickrProvider( QObject *parent, const QVariantList &args ); /** * Destroys the flickr provider. */ ~FlickrProvider() override; /** * Returns the requested image. * * Note: This method returns only a valid image after the * finished() signal has been emitted. */ QImage image() const override; private: void pageRequestFinished(KJob *job); void imageRequestFinished(KJob *job); private: QDate mActualDate; QImage mImage; QXmlStreamReader xml; int mFailureNumber = 0; QStringList m_photoList; }; #endif diff --git a/dataengines/potd/potd.cpp b/dataengines/potd/potd.cpp index 8194e79ff..96405dd4a 100644 --- a/dataengines/potd/potd.cpp +++ b/dataengines/potd/potd.cpp @@ -1,205 +1,205 @@ /* * Copyright (C) 2007 Tobias Koenig * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "potd.h" #include #include #include #include #include #include #include #include #include #include "cachedprovider.h" namespace { namespace DataKeys { inline QString image() { return QStringLiteral("Image"); } inline QString url() { return QStringLiteral("Url"); } } } PotdEngine::PotdEngine( QObject* parent, const QVariantList& args ) : Plasma::DataEngine( parent, args ) { // set polling to every 5 minutes setMinimumPollingInterval(5 * 60 * 1000); m_checkDatesTimer = new QTimer( this );//change picture after 24 hours connect( m_checkDatesTimer, SIGNAL(timeout()), this, SLOT(checkDayChanged()) ); //FIXME: would be nice to stop and start this timer ONLY as needed, e.g. only when there are // time insensitive sources to serve; still, this is better than how i found it, checking // every 2 seconds (!) m_checkDatesTimer->setInterval( 10 * 60 * 1000 ); // check every 10 minutes m_checkDatesTimer->start(); const QVector plugins = KPluginLoader::findPlugins(QStringLiteral("potd"), [](const KPluginMetaData & md) { return md.serviceTypes().contains(QStringLiteral("PlasmaPoTD/Plugin")); }); for (const auto &metadata : plugins) { QString provider = metadata.value(QLatin1String( "X-KDE-PlasmaPoTDProvider-Identifier" )); if (provider.isEmpty()) { continue; } mFactories.insert(provider, metadata); setData( QLatin1String( "Providers" ), provider, metadata.name() ); } } PotdEngine::~PotdEngine() { } bool PotdEngine::updateSourceEvent( const QString &identifier ) { return updateSource( identifier, false ); } bool PotdEngine::updateSource( const QString &identifier, bool loadCachedAlways ) { // check whether it is cached already... if ( CachedProvider::isCached( identifier, loadCachedAlways ) ) { QVariantList args; args << QLatin1String( "String" ) << identifier; CachedProvider *provider = new CachedProvider( identifier, this ); connect( provider, SIGNAL(finished(PotdProvider*)), this, SLOT(finished(PotdProvider*)) ); connect( provider, SIGNAL(error(PotdProvider*)), this, SLOT(error(PotdProvider*)) ); m_canDiscardCache = loadCachedAlways; if (!loadCachedAlways) { return true; } } const QStringList parts = identifier.split( QLatin1Char( ':' ), QString::SkipEmptyParts ); if (parts.empty()) { qDebug() << "invalid identifier"; return false; } const QString providerName = parts[ 0 ]; if ( !mFactories.contains( providerName ) ) { qDebug() << "invalid provider: " << parts[ 0 ]; return false; } QVariantList args; args << providerName; if ( parts.count() > 1 ) { const QDate date = QDate::fromString( parts[ 1 ], Qt::ISODate ); if ( !date.isValid() ) { qDebug() << "invalid date:" << parts[1]; return false; } args << date; } auto factory = KPluginLoader(mFactories[ providerName ].fileName()).factory(); PotdProvider *provider = nullptr; if (factory) { provider = factory->create(this, args); } if (provider) { connect( provider, SIGNAL(finished(PotdProvider*)), this, SLOT(finished(PotdProvider*)) ); connect( provider, SIGNAL(error(PotdProvider*)), this, SLOT(error(PotdProvider*)) ); return true; } return false; } bool PotdEngine::sourceRequestEvent( const QString &identifier ) { if ( updateSource( identifier, true ) ) { setData(identifier, DataKeys::image(), QImage()); return true; } return false; } void PotdEngine::finished( PotdProvider *provider ) { if ( m_canDiscardCache && qobject_cast( provider ) ) { Plasma::DataContainer *source = containerForSource( provider->identifier() ); if ( source && !source->data().value(DataKeys::image()).value().isNull() ) { provider->deleteLater(); return; } } QImage img(provider->image()); // store in cache if it's not the response of a CachedProvider - if ( qobject_cast( provider ) == 0 && !img.isNull() ) { + if ( qobject_cast( provider ) == nullptr && !img.isNull() ) { SaveImageThread *thread = new SaveImageThread( provider->identifier(), img ); connect(thread, SIGNAL(done(QString,QString,QImage)), this, SLOT(cachingFinished(QString,QString,QImage))); QThreadPool::globalInstance()->start(thread); } else { setData(provider->identifier(), DataKeys::image(), img); setData(provider->identifier(), DataKeys::url(), CachedProvider::identifierToPath( provider->identifier())); } provider->deleteLater(); } void PotdEngine::cachingFinished( const QString &source, const QString &path, const QImage &img ) { setData(source, DataKeys::image(), img); setData(source, DataKeys::url(), path); } void PotdEngine::error( PotdProvider *provider ) { provider->disconnect(this); provider->deleteLater(); } void PotdEngine::checkDayChanged() { SourceDict dict = containerDict(); QHashIterator it( dict ); while ( it.hasNext() ) { it.next(); if (it.key() == QLatin1String("Providers")) { continue; } if ( !it.key().contains(QLatin1Char(':')) ) { const QString path = CachedProvider::identifierToPath( it.key() ); if ( !QFile::exists(path) ) { updateSourceEvent( it.key() ); } else { QFileInfo info( path ); if ( info.lastModified().daysTo( QDateTime::currentDateTime() ) > 1 ) { updateSourceEvent( it.key() ); } } } } } K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(potdengine, PotdEngine, "plasma-dataengine-potd.json") #include "potd.moc" diff --git a/dataengines/potd/potdprovider.h b/dataengines/potd/potdprovider.h index 18bd14cf6..6a4ababe3 100644 --- a/dataengines/potd/potdprovider.h +++ b/dataengines/potd/potdprovider.h @@ -1,99 +1,99 @@ /* * Copyright (C) 2007 Tobias Koenig * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef POTDPROVIDER_H #define POTDPROVIDER_H #include #include #include "plasma_potd_export.h" class QImage; class QDate; /** * This class is an interface for PoTD providers. */ class PLASMA_POTD_EXPORT PotdProvider : public QObject { Q_OBJECT public: /** * Creates a new PoTD provider. * * @param parent The parent object. */ explicit PotdProvider(QObject *parent, const QVariantList &args = QVariantList()); /** * Destroys the PoTD provider. */ ~PotdProvider() override; /** * Returns the requested image. * * Note: This method returns only a valid image after the * finished() signal has been emitted. */ virtual QImage image() const = 0; /** * Returns the identifier of the PoTD request (name + date). */ virtual QString identifier() const; /** * @return the name of this provider (equiv to X-KDE-PlasmaPoTDProvider-Identifier) */ QString name() const; /** - * @reutrn the date to load for this item, if any + * @return the date to load for this item, if any */ QDate date() const; /** * @return if the date is fixed, or if it should always be "today" */ bool isFixedDate() const; Q_SIGNALS: /** * This signal is emitted whenever a request has been finished * successfully. * * @param provider The provider which emitted the signal. */ void finished( PotdProvider *provider ); /** * This signal is emitted whenever an error has occurred. * * @param provider The provider which emitted the signal. */ void error( PotdProvider *provider ); private: const QScopedPointer d; }; #endif diff --git a/runners/converter/converterrunner.cpp b/runners/converter/converterrunner.cpp index 0c3e673f8..cc96db08c 100644 --- a/runners/converter/converterrunner.cpp +++ b/runners/converter/converterrunner.cpp @@ -1,288 +1,288 @@ /* * Copyright (C) 2007,2008 Petri Damstén * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "converterrunner.h" #include #include #include #include #include #include #include #include #include #define CONVERSION_CHAR QLatin1Char( '>' ) K_EXPORT_PLASMA_RUNNER(converterrunner, ConverterRunner) class StringParser { public: enum GetType { GetString = 1, GetDigit = 2 }; - StringParser(const QString &s) : m_index(0), m_s(s) {}; - ~StringParser() {}; + StringParser(const QString &s) : m_index(0), m_s(s) {} + ~StringParser() {} QString get(int type) { QChar current; QString result; passWhiteSpace(); while (true) { current = next(); if (current.isNull()) { break; } if (current.isSpace()) { break; } bool number = isNumber(current); if (type == GetDigit && !number) { break; } if (type == GetString && number) { break; } if(current == QLatin1Char( CONVERSION_CHAR )) { break; } ++m_index; result += current; } return result; } bool isNumber(const QChar &ch) { if (ch.isNumber()) { return true; } if (QStringLiteral(".,-+").contains(ch)) { return true; } return false; } QString rest() { return m_s.mid(m_index).simplified(); } void pass(const QStringList &strings) { passWhiteSpace(); const QString temp = m_s.mid(m_index); foreach (const QString& s, strings) { if (temp.startsWith(s)) { m_index += s.length(); return; } } } private: void passWhiteSpace() { while (next().isSpace()) { ++m_index; } } QChar next() { if (m_index >= m_s.size()) { return QChar::Null; } return m_s.at(m_index); } int m_index; QString m_s; }; ConverterRunner::ConverterRunner(QObject* parent, const QVariantList &args) : Plasma::AbstractRunner(parent, args) { Q_UNUSED(args) setObjectName(QLatin1String( "Converter" )); m_separators << QString( CONVERSION_CHAR ); m_separators << i18nc("list of words that can used as amount of 'unit1' [in|to|as] 'unit2'", "in;to;as").split(QLatin1Char( ';' )); //can not ignore commands: we have things like m4 setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | Plasma::RunnerContext::NetworkLocation); QString description = i18n("Converts the value of :q: when :q: is made up of " "\"value unit [>, to, as, in] unit\". You can use the " "Unit converter applet to find all available units."); addSyntax(Plasma::RunnerSyntax(QLatin1String(":q:"), description)); } ConverterRunner::~ConverterRunner() { } void ConverterRunner::match(Plasma::RunnerContext &context) { const QString term = context.query(); if (term.size() < 2) { return; } StringParser cmd(term); QString unit1; QString value; QString unit2; unit1 = cmd.get(StringParser::GetString); value = cmd.get(StringParser::GetDigit); if (value.isEmpty()) { return; } if (unit1.isEmpty()) { unit1 = cmd.get(StringParser::GetString | StringParser::GetDigit); if (unit1.isEmpty()) { return; } } const QString s = cmd.get(StringParser::GetString); if (!s.isEmpty() && !m_separators.contains(s)) { unit1 += QLatin1Char( ' ' ) + s; } if (s.isEmpty() || !m_separators.contains(s)) { cmd.pass(m_separators); } unit2 = cmd.rest(); KUnitConversion::Converter converter; KUnitConversion::UnitCategory category = converter.categoryForUnit(unit1); bool found = false; if (category.id() == KUnitConversion::InvalidCategory) { foreach (category, converter.categories()) { foreach (const QString& s, category.allUnits()) { if (s.compare(unit1, Qt::CaseInsensitive) == 0) { unit1 = s; found = true; break; } } if (found) { break; } } if (!found) { return; } } QList units; if (!unit2.isEmpty()) { KUnitConversion::Unit u = category.unit(unit2); if (!u.isNull() && u.isValid()) { units.append(u); config().writeEntry(category.name(), u.symbol()); } else { const QStringList unitStrings = category.allUnits(); QList matchingUnits; foreach (const QString& s, unitStrings) { if (s.startsWith(unit2, Qt::CaseInsensitive)) { matchingUnits << category.unit(s); } } units = matchingUnits; if (units.count() == 1) { config().writeEntry(category.name(), units[0].symbol()); } } } else { units = category.mostCommonUnits(); KUnitConversion::Unit u = category.unit(config().readEntry(category.name())); if (!u.isNull() && units.indexOf(u) < 0) { units << u; } // suggest converting to the user's local currency if (category.id() == KUnitConversion::CurrencyCategory) { const QString ¤cyIsoCode = QLocale().currencySymbol(QLocale::CurrencyIsoCode); KUnitConversion::Unit localCurrency = category.unit(currencyIsoCode); if (localCurrency.isValid() && !units.contains(localCurrency)) { units << localCurrency; } } } QList matches; QLocale locale; KUnitConversion::Unit u1 = category.unit(unit1); foreach (const KUnitConversion::Unit& u, units) { if (u1 == u) { continue; } bool ok; double numberValue = locale.toDouble(value, &ok); if (!ok) { numberValue = value.toDouble(&ok); if (!ok) { continue; } } KUnitConversion::Value v = category.convert(KUnitConversion::Value(numberValue, u1), u); if (!v.isValid()) { continue; } Plasma::QueryMatch match(this); match.setType(Plasma::QueryMatch::InformationalMatch); match.setIconName(QStringLiteral("edit-copy")); match.setText(QStringLiteral("%1 (%2)").arg(v.toString(), u.symbol())); match.setData(v.number()); match.setRelevance(1.0 - std::abs(std::log10(v.number())) / 50.0); matches.append(match); } context.addMatches(matches); } void ConverterRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) { Q_UNUSED(context) const QString data = match.data().toString(); if (data.startsWith(QLatin1String("http://"))) { QDesktopServices::openUrl(QUrl(data)); } else { QGuiApplication::clipboard()->setText(data); } } #include "converterrunner.moc" diff --git a/runners/dictionary/dictionaryrunner.h b/runners/dictionary/dictionaryrunner.h index 29d52f3d2..dc987d454 100644 --- a/runners/dictionary/dictionaryrunner.h +++ b/runners/dictionary/dictionaryrunner.h @@ -1,29 +1,29 @@ /* * Copyright (C) 2010, 2012 Jason A. Donenfeld */ #ifndef DICTIONARYRUNNER_H #define DICTIONARYRUNNER_H #include #include "dictionarymatchengine.h" class DictionaryRunner : public Plasma::AbstractRunner { Q_OBJECT public: - DictionaryRunner(QObject *parent, const QVariantList &args); + explicit DictionaryRunner(QObject *parent, const QVariantList &args); void match(Plasma::RunnerContext &context) override; void reloadConfiguration() override; private: QString m_triggerWord; DictionaryMatchEngine *m_engine; protected Q_SLOTS: void init() override; }; #endif diff --git a/runners/katesessions/katesessions.cpp b/runners/katesessions/katesessions.cpp index ce3850b15..eac438468 100644 --- a/runners/katesessions/katesessions.cpp +++ b/runners/katesessions/katesessions.cpp @@ -1,173 +1,172 @@ /* * Copyright 2008 Sebastian Kügler * Copyright 2017 Kai Uwe Broulik * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "katesessions.h" #include #include #include #include #include #include #include K_EXPORT_PLASMA_RUNNER(katesessionsrunner, KateSessions) KateSessions::KateSessions(QObject *parent, const QVariantList& args) - : Plasma::AbstractRunner(parent, args), - m_sessionWatch(nullptr) + : Plasma::AbstractRunner(parent, args) { setObjectName(QLatin1String("Kate Sessions")); setIgnoredTypes(Plasma::RunnerContext::File | Plasma::RunnerContext::Directory | Plasma::RunnerContext::NetworkLocation); Plasma::RunnerSyntax s(QLatin1String(":q:"), i18n("Finds Kate sessions matching :q:.")); s.addExampleQuery(QLatin1String("kate :q:")); addSyntax(s); setDefaultSyntax(Plasma::RunnerSyntax(QLatin1String("kate"), i18n("Lists all the Kate editor sessions in your account."))); m_sessionsFolderPath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/kate/sessions"); connect(this, SIGNAL(prepare()), SLOT(slotPrepare())); connect(this, SIGNAL(teardown()), SLOT(slotTeardown())); } KateSessions::~KateSessions() { } void KateSessions::slotPrepare() { loadSessions(); // listen for changes to the list of kate sessions if (!m_sessionWatch) { m_sessionWatch = new KDirWatch(this); m_sessionWatch->addDir(m_sessionsFolderPath); connect(m_sessionWatch, &KDirWatch::dirty, this, &KateSessions::loadSessions); connect(m_sessionWatch, &KDirWatch::created, this, &KateSessions::loadSessions); connect(m_sessionWatch, &KDirWatch::deleted, this, &KateSessions::loadSessions); } } void KateSessions::slotTeardown() { delete m_sessionWatch; m_sessionWatch = nullptr; m_sessions.clear(); } void KateSessions::loadSessions() { QStringList sessions; QDir sessionsDir(m_sessionsFolderPath); const auto &sessionFiles = sessionsDir.entryInfoList({QStringLiteral("*.katesession")}, QDir::Files); for (const QFileInfo &sessionFile : sessionFiles) { const QString name = QUrl::fromPercentEncoding(sessionFile.baseName().toLocal8Bit()); // is this the right encoding? sessions.append(name); } QCollator collator; collator.setCaseSensitivity(Qt::CaseInsensitive); std::sort(sessions.begin(), sessions.end(), [&collator](const QString &a, const QString &b) { return collator.compare(a, b) < 0; }); m_sessions = sessions; } void KateSessions::match(Plasma::RunnerContext &context) { if (m_sessions.isEmpty()) { return; } QString term = context.query(); if (term.length() < 3) { return; } bool listAll = false; if (term.startsWith(QLatin1String("kate"), Qt::CaseInsensitive)) { if (term.trimmed().compare(QLatin1String("kate"), Qt::CaseInsensitive) == 0) { listAll = true; term.clear(); } else if (term.at(4) == QLatin1Char(' ') ) { term.remove(QLatin1String("kate"), Qt::CaseInsensitive); term = term.trimmed(); } else { term.clear(); } } if (term.isEmpty() && !listAll) { return; } foreach (const QString &session, m_sessions) { if (!context.isValid()) { return; } if (listAll || (!term.isEmpty() && session.contains(term, Qt::CaseInsensitive))) { Plasma::QueryMatch match(this); if (listAll) { // All sessions listed, but with a low priority match.setType(Plasma::QueryMatch::ExactMatch); match.setRelevance(0.8); } else { if (session.compare(term, Qt::CaseInsensitive) == 0) { // parameter to kate matches session exactly, bump it up! match.setType(Plasma::QueryMatch::ExactMatch); match.setRelevance(1.0); } else { // fuzzy match of the session in "kate $session" match.setType(Plasma::QueryMatch::PossibleMatch); match.setRelevance(0.8); } } match.setIconName(QStringLiteral("kate")); match.setData(session); match.setText(session); match.setSubtext(i18n("Open Kate Session")); context.addMatch(match); } } } void KateSessions::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) { Q_UNUSED(context) QString session = match.data().toString(); if (!session.isEmpty()) { QStringList args; args << QLatin1String("--start") << session << QLatin1String("-n"); KToolInvocation::kdeinitExec(QLatin1String("kate"), args); } } #include "katesessions.moc" diff --git a/runners/katesessions/katesessions.h b/runners/katesessions/katesessions.h index 9fef11aad..c667e2298 100644 --- a/runners/katesessions/katesessions.h +++ b/runners/katesessions/katesessions.h @@ -1,49 +1,49 @@ /* * Copyright 2008 Sebastian Kügler * Copyright 2017 Kai Uwe Broulik * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KATESESSIONS_H #define KATESESSIONS_H #include class KDirWatch; class KateSessions : public Plasma::AbstractRunner { Q_OBJECT public: - KateSessions( QObject *parent, const QVariantList& args ); + explicit KateSessions( QObject *parent, const QVariantList& args ); ~KateSessions() override; void match(Plasma::RunnerContext &context) override; void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override; private Q_SLOTS: void loadSessions(); void slotPrepare(); void slotTeardown(); private: - KDirWatch* m_sessionWatch; + KDirWatch* m_sessionWatch = nullptr; QString m_sessionsFolderPath; QStringList m_sessions; }; #endif diff --git a/runners/konsoleprofiles/konsoleprofiles.h b/runners/konsoleprofiles/konsoleprofiles.h index ad5ad8302..cf8e4b630 100644 --- a/runners/konsoleprofiles/konsoleprofiles.h +++ b/runners/konsoleprofiles/konsoleprofiles.h @@ -1,57 +1,57 @@ /* * Copyright 2008 Montel Laurent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KONSOLEPROFILES_H #define KONSOLEPROFILES_H #include class KDirWatch; struct KonsoleProfileData { QString displayName; QString iconName; }; Q_DECLARE_TYPEINFO(KonsoleProfileData, Q_MOVABLE_TYPE); class KonsoleProfiles : public Plasma::AbstractRunner { Q_OBJECT public: - KonsoleProfiles( QObject *parent, const QVariantList& args ); + explicit KonsoleProfiles( QObject *parent, const QVariantList& args ); ~KonsoleProfiles() override; void match(Plasma::RunnerContext &context) override; void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override; private Q_SLOTS: void loadProfiles(); void slotPrepare(); void slotTeardown(); private: KDirWatch* m_profileFilesWatch = nullptr; QHash m_profiles; }; #endif diff --git a/runners/mediawiki/mediawiki.h b/runners/mediawiki/mediawiki.h index 5e42743cf..5093066fd 100644 --- a/runners/mediawiki/mediawiki.h +++ b/runners/mediawiki/mediawiki.h @@ -1,142 +1,142 @@ /* * Copyright 2009 by Richard Moore * Copyright 2009 by Sebastian K?gler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MEDIAWIKI_H #define MEDIAWIKI_H // Qt #include #include #include class QNetworkReply; class QIODevice; /** * Searches MediaWiki based wikis like wikipedia and techbase. * * @author Richard Moore, rich@kde.org */ class MediaWiki : public QObject { Q_OBJECT public: /** * Contains information about a single match from the search. */ class Result { public: Result() { - }; + } Result( const Result &r ) { this->title = r.title; this->url = r.url; - }; + } Result &operator= (const Result &other) { this->title = other.title; this->url = other.url; return *this; - }; + } /** The page title of the match. */ QString title; /** The URL of the page containing the match. */ QUrl url; }; /** * Create a media wiki querying object with the specified parent. The querying * object can be used for multple queries, though only one can be performed at * a time. * @param parent The parent object */ explicit MediaWiki(QObject *parent = nullptr); ~MediaWiki() override; /** * @returns a list of matches. */ QList results() const; /** @returns the currently specified maximum number of results to return. */ int maxItems() const; /** Sets the maximum number of results to return. * * @param limit Maximumber number of results to retrieve */ void setMaxItems( int limit ); /** @returns the currently specified API URL. */ QUrl apiUrl() const; /** * Sets the URL at which the wikis API page can be found. For example, wikipedia * has the API file at http://en.wikipedia.org/w/api.php whilst techbase has the * * @param url The URL of the api.php file, for example http://techbase.kde.org/api.php */ void setApiUrl( const QUrl &url ); /** @returns the currently specified timeout in milliseconds. */ int timeout() const; /** * Sets timeout in milliseconds. Once the specified time has elapsed, the current * query is aborted. * * @param millis Query timeout in milliseconds */ void setTimeout( int millis ); Q_SIGNALS: /** * Emitted when a search has been completed. * @param success true if the search was completed successfully. */ void finished( bool success ); public Q_SLOTS: /** * Search the wiki for the specified search term. */ void search( const QString &searchTerm ); /** * Aborts the currently running request. */ void abort(); private Q_SLOTS: void onNetworkRequestFinished(QNetworkReply *reply); private: void findBase(); bool processBaseResult( QIODevice *source ); bool processSearchResult( QIODevice *source ); struct MediaWikiPrivate * const d; }; #endif // MEDIAWIKI_H diff --git a/runners/mediawiki/mediawikirunner.h b/runners/mediawiki/mediawikirunner.h index 6556176b9..095a2e0ae 100644 --- a/runners/mediawiki/mediawikirunner.h +++ b/runners/mediawiki/mediawikirunner.h @@ -1,49 +1,49 @@ /* * Copyright 2008 Sebastian K?gler * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MEDIAWIKIRUNNER_H #define MEDIAWIKIRUNNER_H // KF #include // Qt #include class MediaWikiRunner : public Plasma::AbstractRunner { Q_OBJECT public: - MediaWikiRunner(QObject *parent, const QVariantList &args); + explicit MediaWikiRunner(QObject *parent, const QVariantList &args); ~MediaWikiRunner() override; void match(Plasma::RunnerContext &context) override; void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override; private: QString m_iconName; QString m_name; QString m_comment; QUrl m_apiUrl; QNetworkConfigurationManager m_networkConfigurationManager; }; #endif