Index: README
===================================================================
--- README	(revision bc1b8837b6cb440813c47acacfaa5460e6fe3fc1)
+++ README	(revision caef58b531b15aae84d82e4151b605f89a9b7877)
@@ -7,5 +7,5 @@
 TSPSG is intended to generate and solve Travelling Salesman Problem
 (TSP) tasks. It uses Branch and Bound method for solving. An input
-is number of cities and matrix of city-to-city travel prices.
+is number of cities and matrix of city-to-city travel costs.
 The matrix can be populated with random values in a given range
 (useful for generating tasks). The result is an optimal route, its
Index: src/mainwindow.cpp
===================================================================
--- src/mainwindow.cpp	(revision bc1b8837b6cb440813c47acacfaa5460e6fe3fc1)
+++ src/mainwindow.cpp	(revision caef58b531b15aae84d82e4151b605f89a9b7877)
@@ -24,4 +24,11 @@
 #include "mainwindow.h"
 
+/*!
+ * \brief Class constructor.
+ * \param parent Main Window parent widget.
+ *
+ *  Initializes Main Window and creates its layout based on target OS.
+ *  Loads TSPSG settings and opens a task file if it was specified as a commandline parameter.
+ */
 MainWindow::MainWindow(QWidget *parent)
 	: QMainWindow(parent)
@@ -484,6 +491,13 @@
 		output.append("<p>" + trUtf8("<b>WARNING!!!</b><br>This result is a record, but it may not be optimal.<br>Iterations need to be continued to check whether this result is optimal or get an optimal one.") + "</p>");
 	}
+	output.append("<p></p>");
 	solutionText->setHtml(output.join(""));
 	solutionText->setDocumentTitle(trUtf8("Solution of Variant #%1 task").arg(spinVariant->value()));
+
+	// Scrolling to the end of text.
+QTextCursor cursor(solutionText->textCursor());
+	cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
+	solutionText->setTextCursor(cursor);
+
 	enableSolutionActions();
 	tabWidget->setCurrentIndex(1);
@@ -493,5 +507,5 @@
 void MainWindow::actionHelpAboutTriggered()
 {
-	// TODO: Normal about window :-)
+//! \todo TODO: Normal about window :-)
 QString about = QString::fromUtf8("TSPSG: TSP Solver and Generator\n");
 	about += QString::fromUtf8("    Version: "BUILD_VERSION"\n");
@@ -569,4 +583,11 @@
 }
 
+/*!
+ * \brief Handles Main Window close event.
+ * \param event Close event.
+ *
+ *  Checks whether or not a current task was saved and asks for saving if not.
+ *  Saves TSPSG settings.
+ */
 void MainWindow::closeEvent(QCloseEvent *event)
 {
Index: src/mainwindow.h
===================================================================
--- src/mainwindow.h	(revision bc1b8837b6cb440813c47acacfaa5460e6fe3fc1)
+++ src/mainwindow.h	(revision caef58b531b15aae84d82e4151b605f89a9b7877)
@@ -1,8 +1,11 @@
-/*
- *  TSPSG: TSP Solver and Generator
- *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
+/*!
+ * \class MainWindow
+ * \brief Class for handling Main Window UI and logic.
+ * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
  *
  *  $Id$
  *  $URL$
+ *
+ *  <b>TSPSG: TSP Solver and Generator</b>
  *
  *  This file is part of TSPSG.
@@ -54,5 +57,5 @@
 	void dataChanged(const QModelIndex &, const QModelIndex &);
 #ifndef QT_NO_PRINTER
-	void printPreview(QPrinter *);
+	void printPreview(QPrinter *printer);
 	void actionFilePrintPreviewTriggered();
 	void actionFilePrintTriggered();
Index: src/settingsdialog.cpp
===================================================================
--- src/settingsdialog.cpp	(revision bc1b8837b6cb440813c47acacfaa5460e6fe3fc1)
+++ src/settingsdialog.cpp	(revision caef58b531b15aae84d82e4151b605f89a9b7877)
@@ -24,4 +24,10 @@
 #include "settingsdialog.h"
 
+/*!
+ * \brief Class constructor.
+ * \param parent Settings Dialog parent widget.
+ *
+ * Initializes Settings Dialog and creates its layout based on target OS.
+ */
 SettingsDialog::SettingsDialog(QWidget *parent)
 	: QDialog(parent), newFont(false), newColor(false)
@@ -218,4 +224,7 @@
 }
 
+/*!
+ * \brief Indicates whether or not the font color has been changed.
+ */
 bool SettingsDialog::colorChanged() const
 {
@@ -223,7 +232,14 @@
 }
 
+/*!
+ * \brief Indicates whether or not the font properties have been changed.
+ */
 bool SettingsDialog::fontChanged() const
 {
 	return newFont;
+}
+
+void SettingsDialog::spinRandMinValueChanged(int val) {
+	spinRandMax->setMinimum(val);
 }
 
Index: src/settingsdialog.h
===================================================================
--- src/settingsdialog.h	(revision bc1b8837b6cb440813c47acacfaa5460e6fe3fc1)
+++ src/settingsdialog.h	(revision caef58b531b15aae84d82e4151b605f89a9b7877)
@@ -1,8 +1,11 @@
-/*
- *  TSPSG: TSP Solver and Generator
- *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
+/*!
+ * \class SettingsDialog
+ * \brief Class for handling Settings Dialog UI and logic.
+ * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
  *
  *  $Id$
  *  $URL$
+ *
+ *  <b>TSPSG: TSP Solver and Generator</b>
  *
  *  This file is part of TSPSG.
@@ -29,5 +32,5 @@
 #include "ui_settingsdialog.h"
 
-class SettingsDialog: public QDialog, public Ui::SettingsDialog
+class SettingsDialog: public QDialog, Ui::SettingsDialog
 {
 	Q_OBJECT
@@ -36,11 +39,4 @@
 	bool colorChanged() const;
 	bool fontChanged() const;
-
-#ifndef Q_OS_WINCE
-	QCheckBox *cbSaveState;
-	QLabel *imgIcon;
-	QLabel *labelHint;
-	QFrame *lineVertical;
-#endif // Q_OS_WINCE
 
 private:
@@ -52,5 +48,10 @@
 #ifndef Q_OS_WINCE
 	bool event(QEvent *);
-#endif
+
+	QCheckBox *cbSaveState;
+	QLabel *imgIcon;
+	QLabel *labelHint;
+	QFrame *lineVertical;
+#endif // Q_OS_WINCE
 
 private slots:
@@ -58,5 +59,5 @@
 	void buttonColorClicked();
 	void buttonFontClicked();
-	void spinRandMinValueChanged(int val) { spinRandMax->setMinimum(val); }
+	void spinRandMinValueChanged(int);
 };
 
Index: src/tspmodel.h
===================================================================
--- src/tspmodel.h	(revision bc1b8837b6cb440813c47acacfaa5460e6fe3fc1)
+++ src/tspmodel.h	(revision caef58b531b15aae84d82e4151b605f89a9b7877)
@@ -1,8 +1,11 @@
-/*
- *  TSPSG: TSP Solver and Generator
- *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
+/*!
+ * \class CTSPModel
+ * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
+ * \brief This class implements table model for manipulating a task.
  *
  *  $Id$
  *  $URL$
+ *
+ *  <b>TSPSG: TSP Solver and Generator</b>
  *
  *  This file is part of TSPSG.
Index: src/tspsolver.cpp
===================================================================
--- src/tspsolver.cpp	(revision bc1b8837b6cb440813c47acacfaa5460e6fe3fc1)
+++ src/tspsolver.cpp	(revision caef58b531b15aae84d82e4151b605f89a9b7877)
@@ -24,4 +24,5 @@
 #include "tspsolver.h"
 
+//! Class constructor
 CTSPSolver::CTSPSolver()
 	: nCities(0)
@@ -125,5 +126,12 @@
 }
 
-// TODO: Comment the algorithm
+/*!
+ * \brief Solves the given task.
+ * \param numCities Number of cities in the task.
+ * \param task The matrix of city-to-city travel costs.
+ * \param parent The parent widget for displaying messages and dialogs.
+ *
+ * \todo TODO: Comment the algorithm.
+ */
 sStep *CTSPSolver::solve(int numCities, tMatrix task, QWidget *parent)
 {
@@ -226,4 +234,7 @@
 }
 
+/*!
+ * \brief Returns the sorted optimal path, starting from City 1.
+ */
 QString CTSPSolver::getSortedPath() const
 {
@@ -242,4 +253,9 @@
 }
 
+/*!
+ * \brief Returns CTSPSolver's version ID.
+ *
+ *  Current version ID is <b>\$Id$</b>.
+ */
 QString CTSPSolver::getVersionId()
 {
@@ -247,4 +263,10 @@
 }
 
+/*!
+ * \brief Returns whether or not the solution is definitely optimal.
+ *
+ *  The solution may need some further interations to determine whether it is optimal.
+ *  In such cases this function returns \p false.
+ */
 bool CTSPSolver::isOptimal() const
 {
Index: src/tspsolver.h
===================================================================
--- src/tspsolver.h	(revision bc1b8837b6cb440813c47acacfaa5460e6fe3fc1)
+++ src/tspsolver.h	(revision caef58b531b15aae84d82e4151b605f89a9b7877)
@@ -1,8 +1,11 @@
-/*
- *  TSPSG: TSP Solver and Generator
- *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
+/*!
+ * \class CTSPSolver
+ * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
+ * \brief This class solves Travelling Salesman Problem task.
  *
  *  $Id$
  *  $URL$
+ *
+ *  <b>TSPSG: TSP Solver and Generator</b>
  *
  *  This file is part of TSPSG.
@@ -20,4 +23,6 @@
  *  You should have received a copy of the GNU General Public License
  *  along with TSPSG.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * \todo TODO: Deletion of solution tree on destroy and cleanup.
  */
 
@@ -29,18 +34,32 @@
 #include "tspmodel.h"
 
+//! A matrix of city-to-city travel costs.
 typedef QList<QList<double> > tMatrix;
 
-// This structure represents one step of solving
-// The tree of such elements will represent the solving process
+/*!
+ * \brief This structure represents one step of solving.
+ *
+ *  A tree of such elements will represent the solving process.
+ */
+//! \todo TODO: List alternative candidates.
 struct sStep {
-	tMatrix matrix; // Steps's matrix
-	double price; // Price of travel to this step
-	struct {int nRow; int nCol;} candidate; // Candiadate for branching in current matrix
-	bool alts; // This matrix has alternative candidates
-	sStep *plNode, *prNode; // Pointers to left and right branch steps
-	sStep() { price = candidate.nRow = candidate.nCol = -1; alts = false; plNode = prNode = NULL; } // Default values
+	tMatrix matrix; //!< This step's matrix
+	double price; //!< The price of travel to this step
+	struct {
+		int nRow; //!< A zero-based row number of the candidate
+		int nCol; //!< A zero-based column number of the candidate
+	} candidate; //!< A candiadate for branching in the current matrix
+	bool alts; //!< Indicates whether or not matrix has alternative candidates
+	sStep *plNode; //!< Pointer to the left branch step
+	sStep *prNode; //!< Pointer to the right branch step
+
+	//! Assigns default values
+	sStep() {
+		price = candidate.nRow = candidate.nCol = -1;
+		alts = false;
+		plNode = prNode = NULL;
+	}
 };
 
-// TSP Solver class
 class CTSPSolver
 {
