src/MessageLog.h

changeset 690
9e9c52ca955e
parent 650
db7146a87ae4
--- a/src/MessageLog.h	Sun Mar 09 14:04:06 2014 +0200
+++ b/src/MessageLog.h	Sun Mar 09 14:59:46 2014 +0200
@@ -16,9 +16,7 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef LDFORGE_MESSAGELOG_H
-#define LDFORGE_MESSAGELOG_H
-
+#pragma once
 #include <QObject>
 #include <QDate>
 #include "Main.h"
@@ -27,27 +25,38 @@
 class GLRenderer;
 class QTimer;
 
-/* The message manager is an object which keeps track of messages that appear
- * on the renderer's screen. Each line is contained in a separate object which
- * contains the text, expiry time and alpha. The message manager is doubly
- * linked to its corresponding renderer.
- *
- * Message manager calls its tick() function regularly to update the messages,
- * where each line's expiry is checked for. Lines begin to fade out when nearing
- * their expiry. If the message manager's lines change, the renderer undergoes
- * repainting.
- */
+//!
+//! \brief Manages the list of messages at the top-left of the renderer.
+//!
+//! The message manager is an object which keeps track of messages that appear
+//! on the renderer's screen. Each line is contained in a separate object which
+//! contains the text, expiry time and alpha. The message manager is doubly
+//! linked to its corresponding renderer.
+//!
+//! Message manager calls its \c tick() function regularly to update the messages,
+//! where each line's expiry is checked for. Lines begin to fade out when nearing
+//! their expiry. If the message manager's lines change, the renderer undergoes
+//! repainting.
+//!
 class MessageManager : public QObject
 {
 	Q_OBJECT
-	PROPERTY (public,	GLRenderer*,	Renderer,	NO_OPS,	STOCK_WRITE)
+	PROPERTY (public, GLRenderer*, renderer, setRenderer, STOCK_WRITE)
 
 	public:
-		// Single line of the message log.
+		//! \class MessageManager::Line
+		//! A single line of the message log.
 		class Line
 		{
 			public:
+				//! Constructs a line with the given \c text
 				Line (QString text);
+
+				//! Check this line's expiry and update alpha accordingly.
+				//! \c changed is updated to whether the line has somehow
+				//! changed since the last update.
+				//! \returns true if the line is to still stick around, false
+				//! \returns if it expired.
 				bool update (bool& changed);
 
 				QString text;
@@ -55,16 +64,21 @@
 				QDateTime expiry;
 		};
 
-		explicit MessageManager (QObject* parent = 0);
+		//! Constructs the message manager.
+		explicit MessageManager (QObject* parent = null);
+
+		//! Adds a line with the given \c text to the message manager.
 		void addLine (QString line);
+
+		//! \returns all active lines in the message manager.
 		const QList<Line>& getLines() const;
 
 	private:
-		QList<Line> m_lines;
-		QTimer* m_ticker;
+		QList<Line>	m_lines;
+		QTimer*		m_ticker;
 
 	private slots:
+		//! Ticks the manager. This is called by the timer to update
+		//! the messages.
 		void tick();
 };
-
-#endif // LDFORGE_MESSAGELOG_H

mercurial