summaryrefslogtreecommitdiffstats
path: root/src/knutmessagemanager.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-19 18:17:02 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-19 18:17:02 +0000
commitf867212c1762e156553d039319b904a17f7b563d (patch)
tree461c1a743b3ff8291e03360742dbbfb4cc0087e4 /src/knutmessagemanager.cpp
downloadknutclient-f867212c1762e156553d039319b904a17f7b563d.tar.gz
knutclient-f867212c1762e156553d039319b904a17f7b563d.zip
Added KDE3 version of knutclient
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/knutclient@1092914 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/knutmessagemanager.cpp')
-rw-r--r--src/knutmessagemanager.cpp121
1 files changed, 121 insertions, 0 deletions
diff --git a/src/knutmessagemanager.cpp b/src/knutmessagemanager.cpp
new file mode 100644
index 0000000..4a5aa8a
--- /dev/null
+++ b/src/knutmessagemanager.cpp
@@ -0,0 +1,121 @@
+/***************************************************************************
+ knutmessagemanager.cpp - description
+ -------------------
+ begin : So led 24 2004
+ copyright : (C) 2004 by Daniel Prynych
+ email : Daniel.Prynych@alo.cz
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "knutmessagemanager.h"
+#include <qstring.h>
+
+KNutMessageManager::KNutMessageManager( QObject *parent, const char *name) : QObject (parent, name) {
+//qDebug("KNutMessageManager::KNutMessageManager");
+
+
+ m_myMess =0;
+ m_myMessLevel = knc::infoLevel;
+ m_xPos=0;
+ m_yPos=0;
+ }
+
+
+
+KNutMessageManager::~KNutMessageManager(){
+
+ deleteMessage ();
+ }
+
+
+void KNutMessageManager::deleteMessage (void) {
+
+ if (m_myMess) {
+ disconnect (m_myMess,SIGNAL(finished()),this,SLOT(slotFinishedMessage()));
+ disconnect (m_myMess,SIGNAL(endMessage()),this,SLOT(slotEndMessage()));
+ disconnect (m_myMess,SIGNAL(messageMoved(int,int)),this,SLOT(slotMessageMoved(int,int)));
+ m_myMess->hide();
+ delete m_myMess;
+ m_myMess = 0;
+ }
+ }
+
+void KNutMessageManager::addMessage (QString text, knc::LevelOfMessage messageLevel, bool useInfoIcon, bool useShortTimeOfValidity) {
+long int timeOfMessageValidity;
+
+ if (useShortTimeOfValidity) timeOfMessageValidity = ShortTimeOfValidity;
+ else timeOfMessageValidity = TimeOfValidity;
+//qDebug("KNutMessageManager::addMessage");
+
+ deleteMessage();
+ if (useInfoIcon) m_myMess = new KNutMessage(text,KNutMessage::infoMess,timeOfMessageValidity);
+ else {
+ switch (messageLevel) {
+ case knc::infoLevel:
+ m_myMess = new KNutMessage(text,KNutMessage::infoMess,timeOfMessageValidity);
+ break;
+ case knc::lowWarningLevel:
+ m_myMess = new KNutMessage(text,KNutMessage::warningMess,timeOfMessageValidity);
+ break;
+ case knc::warningLevel:
+ m_myMess = new KNutMessage(text,KNutMessage::warningMess,timeOfMessageValidity);
+ break;
+ case knc::errorLevel:
+ m_myMess = new KNutMessage(text,KNutMessage::criticalMess,timeOfMessageValidity);
+ break;
+ case knc::criticalLevel:
+ m_myMess = new KNutMessage(text,KNutMessage::criticalMess,TimeOfValidity); //validity time of critical message has to be standard time of Validity, this time doesn't be short time
+ break;
+ }
+ }
+ m_myMessLevel=messageLevel;
+ if ((m_xPos != 0) && (m_yPos !=0)) {
+ m_myMess->move (m_xPos, m_yPos);
+ }
+
+ m_myMess->show();
+ connect (m_myMess,SIGNAL(finished()),this,SLOT(slotFinishedMessage()));
+ connect (m_myMess,SIGNAL(endMessage()),this,SLOT(slotEndMessage()));
+ connect (m_myMess,SIGNAL(messageMoved(int,int)),this,SLOT(slotMessageMoved(int,int)));
+ }
+
+
+void KNutMessageManager::slotFinishedMessage (void) {
+
+ if (m_myMess) {
+ disconnect (m_myMess,SIGNAL(finished()),this,SLOT(slotFinishedMessage()));
+ disconnect (m_myMess,SIGNAL(endMessage()),this,SLOT(slotEndMessage()));
+ disconnect (m_myMess,SIGNAL(messageMoved(int,int)),this,SLOT(slotMessageMoved(int,int)));
+ m_myMess->hide();
+ m_myMess->deleteLater();
+ m_myMess=0;
+ }
+ }
+
+void KNutMessageManager::slotEndMessage (void) {
+ //kdyz dojde ke stisku tlacitka OK, nebo vyprsi doba platnosti (timeValidity)
+
+ deleteMessage();
+ }
+
+
+void KNutMessageManager::slotMessageMoved (int x,int y) {
+
+//qDebug("KNutMessageManager::slotMessageMoved");
+ m_xPos=x;
+ m_yPos=y;
+}
+
+
+
+
+
+#include "knutmessagemanager.moc"