Index: src/globals.h
===================================================================
--- src/globals.h	(revision 281303f1f7b967fd51b5ed994dc8305e849198d9)
+++ src/globals.h	(revision 2fb523720a40ca7777955370fe8f1c0f396b7e50)
@@ -43,4 +43,18 @@
 #define DEF_FONT_COLOR Qt::black
 
+// Maximum available number of cities
+#define MAX_NUM_CITIES 30
+// Maximum for random generation limit settings
+#define MAX_RAND_VALUE 1000
+
+// Paths
+#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
+	#define PATH_I18N "/usr/share/tspsg/i18n"
+	#define PATH_DOCS "/usr/share/doc/tspsg"
+#else
+	#define PATH_I18N "i18n"
+	#define PATH_DOCS "help"
+#endif // Q_OS_LINUX
+
 // TSPSG Task file signature - letters TSPT
 #define TSPT quint32(0x54535054)
@@ -56,6 +70,4 @@
 #define ZKT_VERSION quint8(1)
 
-// Maximum available number of cities
-#define MAX_NUM_CITIES 30
 // This value means infinity :-)
 #ifndef INFINITY
@@ -65,9 +77,19 @@
 #define INFSTR "---"
 
-// Let's check that default number of cities is sane (<= MAX_NUM_CITIES)
+// Check that default number of cities is sane (<= MAX_NUM_CITIES)
 #if DEF_NUM_CITIES > MAX_NUM_CITIES
 	#undef DEF_NUM_CITIES
 	#define DEF_NUM_CITIES MAX_NUM_CITIES
 #endif
+// Check that maximum for random generation is sane (<= MAX_RAND_VALUE)
+#if DEF_RAND_MAX > MAX_RAND_VALUE
+	#undef DEF_RAND_MAX
+	#define DEF_RAND_MAX MAX_RAND_VALUE
+#endif
+// Check that DEF_RAND_MIN <= DEF_RAND_MAX
+#if DEF_RAND_MIN > DEF_RAND_MAX
+	#undef DEF_RAND_MIN
+	#define DEF_RAND_MIN DEF_RAND_MAX
+#endif
 
 #endif // GLOBALS_H
Index: src/main.cpp
===================================================================
--- src/main.cpp	(revision 281303f1f7b967fd51b5ed994dc8305e849198d9)
+++ src/main.cpp	(revision 2fb523720a40ca7777955370fe8f1c0f396b7e50)
@@ -43,4 +43,5 @@
 	app.setOrganizationDomain("l-homes.org");
 	app.setApplicationName("TSPSG");
+	app.setApplicationVersion(BUILD_VERSION);
 MainWindow mainwindow;
 	mainwindow.show();
Index: src/mainwindow.cpp
===================================================================
--- src/mainwindow.cpp	(revision 281303f1f7b967fd51b5ed994dc8305e849198d9)
+++ src/mainwindow.cpp	(revision 2fb523720a40ca7777955370fe8f1c0f396b7e50)
@@ -96,5 +96,5 @@
 	taskView->setModel(tspmodel);
 	connect(tspmodel,SIGNAL(numCitiesChanged(int)),this,SLOT(numCitiesChanged(int)));
-	connect(tspmodel,SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),this,SLOT(dataChanged()));
+	connect(tspmodel,SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),this,SLOT(dataChanged(const QModelIndex &, const QModelIndex &)));
 	connect(tspmodel,SIGNAL(layoutChanged()),this,SLOT(dataChanged()));
 	if ((QCoreApplication::arguments().count() > 1) && (tspmodel->loadTask(QCoreApplication::arguments().at(1))))
@@ -148,5 +148,5 @@
 		else
 			// No luck. Let's try to load bundled one.
-			if (qtTranslator->load("qt_" + lang,"i18n"))
+			if (qtTranslator->load("qt_" + lang,PATH_I18N))
 				qApp->installTranslator(qtTranslator);
 			else {
@@ -156,5 +156,5 @@
 			}
 		// Now let's load application translation.
-		if (translator->load(lang,"i18n"))
+		if (translator->load(lang,PATH_I18N))
 			qApp->installTranslator(translator);
 		else {
@@ -191,5 +191,5 @@
 int count = tspmodel->numCities();
 	tspmodel->setNumCities(n);
-	if (n > count)
+	if ((n > count) && settings->value("Autosize",true).toBool())
 		for (int k = count; k < n; k++) {
 			taskView->resizeColumnToContents(k);
@@ -217,6 +217,4 @@
 	QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 	tspmodel->clear();
-	taskView->resizeColumnsToContents();
-	taskView->resizeRowsToContents();
 	setFileName();
 	setWindowModified(false);
@@ -250,6 +248,4 @@
 	}
 	setFileName(files.first());
-	taskView->resizeColumnsToContents();
-	taskView->resizeRowsToContents();
 	tabWidget->setCurrentIndex(0);
 	setWindowModified(false);
@@ -411,7 +407,4 @@
 	QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 	tspmodel->randomize();
-	setWindowModified(true);
-	taskView->resizeColumnsToContents();
-	taskView->resizeRowsToContents();
 	QApplication::restoreOverrideCursor();
 }
@@ -521,10 +514,10 @@
 void MainWindow::loadLangList()
 {
-QSettings langinfo("i18n/languages.ini",QSettings::IniFormat);
+QSettings langinfo(PATH_I18N"/languages.ini",QSettings::IniFormat);
 #if QT_VERSION >= 0x040500
 	// In Qt < 4.5 QSettings doesn't have method setIniCodec.
 	langinfo.setIniCodec("UTF-8");
 #endif
-QDir dir("i18n","*.qm",QDir::Name | QDir::IgnoreCase,QDir::Files);
+QDir dir(PATH_I18N,"*.qm",QDir::Name | QDir::IgnoreCase,QDir::Files);
 	if (!dir.exists())
 		return;
@@ -606,4 +599,15 @@
 }
 
+void MainWindow::dataChanged(const QModelIndex &tl, const QModelIndex &br)
+{
+	setWindowModified(true);
+	if (settings->value("Autosize",true).toBool()) {
+		for (int k = tl.row(); k <= br.row(); k++)
+			taskView->resizeRowToContents(k);
+		for (int k = tl.column(); k <= br.column(); k++)
+			taskView->resizeColumnToContents(k);
+	}
+}
+
 void MainWindow::numCitiesChanged(int nCities)
 {
Index: src/mainwindow.h
===================================================================
--- src/mainwindow.h	(revision 281303f1f7b967fd51b5ed994dc8305e849198d9)
+++ src/mainwindow.h	(revision 2fb523720a40ca7777955370fe8f1c0f396b7e50)
@@ -50,4 +50,5 @@
 	void actionHelpAboutTriggered();
 	void dataChanged();
+	void dataChanged(const QModelIndex &, const QModelIndex &);
 #ifndef QT_NO_PRINTER
 	void printPreview(QPrinter *);
Index: src/settingsdialog.cpp
===================================================================
--- src/settingsdialog.cpp	(revision 281303f1f7b967fd51b5ed994dc8305e849198d9)
+++ src/settingsdialog.cpp	(revision 2fb523720a40ca7777955370fe8f1c0f396b7e50)
@@ -44,4 +44,5 @@
 	spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding);
 	vbox2->addItem(spacer);
+	vbox2->addWidget(cbAutosize);
 
 	// Output settings group
@@ -92,5 +93,5 @@
 	labelHint->setObjectName("labelHint");
 	labelHint->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
-	labelHint->setMinimumSize(QSize(175,28));
+	labelHint->setMinimumSize(QSize(190,28));
 	labelHint->setMaximumSize(QSize(0xFFFFFF,28));
 	labelHint->setTextFormat(Qt::PlainText);
@@ -130,4 +131,5 @@
 	vbox2->addItem(spacer);
 	vbox2->addLayout(hbox2);
+	vbox2->addWidget(cbAutosize);
 	vbox2->addWidget(cbSaveState);
 	spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding);
@@ -164,6 +166,9 @@
 #endif // Q_OS_WINCE
 	settings = new QSettings(QSettings::IniFormat,QSettings::UserScope,"TSPSG","tspsg");
+	spinRandMin->setMaximum(MAX_RAND_VALUE);
 	spinRandMin->setValue(settings->value("MinCost",DEF_RAND_MIN).toInt());
+	spinRandMax->setMaximum(MAX_RAND_VALUE);
 	spinRandMax->setValue(settings->value("MaxCost",DEF_RAND_MAX).toInt());
+	cbAutosize->setChecked(settings->value("Autosize",true).toBool());
 #ifndef Q_OS_WINCE
 	cbSaveState->setChecked(settings->value("SavePos",false).toBool());
@@ -180,4 +185,5 @@
 	settings->setValue("SavePos",cbSaveState->isChecked());
 #endif // Q_OS_WINCE
+	settings->setValue("Autosize",cbAutosize->isChecked());
 	settings->setValue("MinCost",spinRandMin->value());
 	settings->setValue("MaxCost",spinRandMax->value());
Index: src/settingsdialog.h
===================================================================
--- src/settingsdialog.h	(revision 281303f1f7b967fd51b5ed994dc8305e849198d9)
+++ src/settingsdialog.h	(revision 2fb523720a40ca7777955370fe8f1c0f396b7e50)
@@ -57,5 +57,5 @@
 	void buttonColorClicked();
 	void buttonFontClicked();
-	void spinRandMinValueChanged(int val) { spinRandMax->setMinimum(val + 1); }
+	void spinRandMinValueChanged(int val) { spinRandMax->setMinimum(val); }
 };
 
