File indexing completed on 2024-04-28 13:45:34
0001 /* 0002 * Copyright 2010-2012 Bart Kroon <bart@tarmack.eu> 0003 * 0004 * Redistribution and use in source and binary forms, with or without 0005 * modification, are permitted provided that the following conditions 0006 * are met: 0007 * 0008 * 1. Redistributions of source code must retain the above copyright 0009 * notice, this list of conditions and the following disclaimer. 0010 * 2. Redistributions in binary form must reproduce the above copyright 0011 * notice, this list of conditions and the following disclaimer in the 0012 * documentation and/or other materials provided with the distribution. 0013 * 0014 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0015 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0017 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0019 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0020 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0021 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0023 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0024 */ 0025 0026 #ifndef Provider_H 0027 #define Provider_H 0028 0029 #include <QObject> 0030 #include <QVariant> 0031 0032 struct Popularity 0033 { 0034 qint64 lastUse; 0035 qint64 count; 0036 QStringList matchStrings; 0037 }; 0038 0039 struct ProviderResult; 0040 0041 // Abstract base class of providers. 0042 class Provider : public QObject 0043 { 0044 Q_OBJECT 0045 0046 public: 0047 explicit Provider (QObject *parent); 0048 Provider() = delete; 0049 0050 virtual ~Provider() {} 0051 0052 public slots: 0053 virtual QList<ProviderResult*> getResults(QString query) = 0; 0054 virtual int launch(const QString &exec) = 0; 0055 }; 0056 0057 // Struct stored in AppList. 0058 struct ProviderResult : public QObject 0059 { 0060 Q_OBJECT 0061 0062 Q_PROPERTY(QString name MEMBER name CONSTANT) 0063 Q_PROPERTY(QString completion MEMBER completion CONSTANT) 0064 Q_PROPERTY(QString icon MEMBER icon CONSTANT) 0065 Q_PROPERTY(QString type MEMBER type CONSTANT) 0066 Q_PROPERTY(int priority MEMBER priority CONSTANT) 0067 0068 public: 0069 bool isCalculation = false; 0070 QString name; 0071 QString completion; 0072 QString icon; 0073 long priority = 0;//INT_MAX; 0074 QString program; 0075 Provider *object{}; //Pointer to the search provider that provided this result. 0076 QString type; 0077 0078 public slots: 0079 void launch() { 0080 object->launch(program); 0081 } 0082 }; 0083 0084 #endif // Provider_H 0085 // kate: indent-mode cstyle; space-indent on; indent-width 4;