File indexing completed on 2024-04-28 04:44:14

0001 /*
0002     SnoreNotify is a Notification Framework based on Qt
0003     Copyright (C) 2014-2015  Hannah von Reth <vonreth@kde.org>
0004 
0005     SnoreNotify is free software: you can redistribute it and/or modify
0006     it under the terms of the GNU Lesser General Public License as published by
0007     the Free Software Foundation, either version 3 of the License, or
0008     (at your option) any later version.
0009 
0010     SnoreNotify is distributed in the hope that it will be useful,
0011     but WITHOUT ANY WARRANTY; without even the implied warranty of
0012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013     GNU Lesser General Public License for more details.
0014 
0015     You should have received a copy of the GNU Lesser General Public License
0016     along with SnoreNotify.  If not, see <http://www.gnu.org/licenses/>.
0017 */
0018 
0019 #ifndef ALERT_H
0020 #define ALERT_H
0021 
0022 #include "snore_exports.h"
0023 #include "notification/icon.h"
0024 
0025 #include <QSharedData>
0026 
0027 namespace Snore
0028 {
0029 
0030 class AlertData;
0031 
0032 /**
0033  *  Alert contains all relevant data to manage different alerts registered with the notification backend.
0034  *  Application uses a shared datamodel, its content is never copied and automatically released.
0035  *
0036  * @author Hannah von Reth \<vonreth at kde.org\>
0037  */
0038 
0039 class SNORE_EXPORT Alert
0040 {
0041 public:
0042     Alert();
0043 
0044     /**
0045      * Creates an alert.
0046      * @param name the name of the Alert.
0047      * @param icon the Icon of the Alert.
0048      */
0049     explicit Alert(const QString &name, const Icon &icon);
0050 
0051     /**
0052      * Creates an alert.
0053      * @param name the key of the Alert used in Application::alerts().
0054      * @param name the name of the Alert.
0055      * @param icon the Icon of the Alert.
0056      */
0057     explicit Alert(const QString &key, const QString &name, const Icon &icon);
0058 
0059     /**
0060      * Creates a copy of other
0061      * @param other
0062      */
0063     Alert(const Alert &other);
0064 
0065     /**
0066      * Creates a copy of other.
0067      * @param other
0068      */
0069     Alert &operator= (const Alert &other);
0070     ~Alert();
0071 
0072     /**
0073      * Returns the key of the Alert, used in Application::alerts().
0074      * Might be identically to name().
0075      */
0076     QString key() const;
0077 
0078     /**
0079      * Returns the name of the Alert.
0080      */
0081     QString name() const;
0082 
0083     /**
0084      * Returns the icon of the Alert.
0085      */
0086     const Icon &icon() const;
0087 
0088     /**
0089      * Returns whether the Alert is valid.
0090      */
0091     bool isValid() const;
0092 
0093 private:
0094     QExplicitlySharedDataPointer<AlertData> d;
0095 
0096 };
0097 }
0098 
0099 QDebug SNORE_EXPORT operator<< (QDebug debug, const Snore::Alert &alert);
0100 
0101 #endif // ALERT_H