gapchich 13 rokov pred
rodič
commit
f510d51bbb
3 zmenil súbory, kde vykonal 31 pridanie a 36 odobranie
  1. 13 12
      ImageLabeler.cpp
  2. 7 3
      OptionsForm.h
  3. 11 21
      functions.cpp

+ 13 - 12
ImageLabeler.cpp

@@ -53,10 +53,11 @@
 ImageLabeler::ImageLabeler(QWidget *aParent, QString aSettingsPath) :
 	QMainWindow(aParent)
 {
+	setFocusPolicy(Qt::StrongFocus);
+
 	/*
 	 * Variables
 	 */
-
 	list_images_ = new QList< Image >;
 
 	main_label_ = -1;
@@ -835,7 +836,7 @@ ImageLabeler::addImage(Image *anImage)
 
 	QString itemText = QString("%1: %2").
 		arg(list_images_widget_->count()).
-		arg(getFilenameFromPath(&(anImage->image_)));
+		arg(removePath(anImage->image_));
 	if (anImage->labeled_)
 		itemText.append(" #labeled");
 	if (anImage->pas_)
@@ -1507,7 +1508,7 @@ ImageLabeler::nextImage()
 		/* NOTREACHED */
 	}
 
-	if (askForUnsavedData()) {
+	if (!askForUnsavedData()) {
 		return;
 		/* NOTREACHED */
 	}
@@ -1563,7 +1564,7 @@ ImageLabeler::prevImage()
 		/* NOTREACHED */
 	}
 
-	if (askForUnsavedData()) {
+	if (!askForUnsavedData()) {
 		return;
 		/* NOTREACHED */
 	}
@@ -1681,7 +1682,7 @@ ImageLabeler::saveAllInfo()
 	fileDialog.setAcceptMode(QFileDialog::AcceptSave);
 	fileDialog.setDefaultSuffix("dat");
 	fileDialog.setFileMode(QFileDialog::AnyFile);
-	QString dir = getDirFromPath(&current_image_);
+	QString dir = getPathFromFilename(current_image_);
 
 	/* altering the name of a new file */
 	QString newFileName = alterFileName(current_image_, "_labeled");
@@ -1740,7 +1741,7 @@ ImageLabeler::saveSegmentedPicture()
 	fileDialog.setAcceptMode(QFileDialog::AcceptSave);
 	fileDialog.setDefaultSuffix("png");
 	fileDialog.setFileMode(QFileDialog::AnyFile);
-	QString dir = getDirFromPath(&current_image_);
+	QString dir = getPathFromFilename(current_image_);
 
 	/* altering the name of a new file */
 	QString newFileName = alterFileName(current_image_, "_segmented");
@@ -1845,7 +1846,7 @@ ImageLabeler::saveLegend()
 	fileDialog.setAcceptMode(QFileDialog::AcceptSave);
 	fileDialog.setDefaultSuffix("dat");
 	fileDialog.setFileMode(QFileDialog::AnyFile);
-	QString dir = getDirFromPath(&current_image_);
+	QString dir = getPathFromFilename(current_image_);
 
 	/* altering the name of a new file */
 	QString newFileName = alterFileName(current_image_, "_legend");
@@ -1888,7 +1889,7 @@ ImageLabeler::saveLegend()
 void
 ImageLabeler::loadInfo()
 {
-	if (askForUnsavedData()) {
+	if (!askForUnsavedData()) {
 		return;
 		/* NOTREACHED */
 	}
@@ -2068,7 +2069,7 @@ ImageLabeler::loadInfo(QString filename)
 void
 ImageLabeler::loadPascalFile()
 {
-	if (askForUnsavedData()) {
+	if (!askForUnsavedData()) {
 		return;
 		/* NOTREACHED */
 	}
@@ -2463,7 +2464,7 @@ ImageLabeler::loadPascalPolys(QString aFilename)
 void
 ImageLabeler::loadImage()
 {
-	if (askForUnsavedData()) {
+	if (!askForUnsavedData()) {
 		return;
 		/* NOTREACHED */
 	}
@@ -2557,7 +2558,7 @@ ImageLabeler::loadImage()
 void
 ImageLabeler::loadImages()
 {
-	if (askForUnsavedData()) {
+	if (!askForUnsavedData()) {
 		return;
 		/* NOTREACHED */
 	}
@@ -3908,7 +3909,7 @@ ImageLabeler::removeImage()
 	list_images_->takeAt(num);
 
 	for (int i = num ; i < list_images_widget_->count(); i++) {
-		QString newStr = getFilenameFromPath(&(list_images_->at(i).image_));
+		QString newStr = removePath(list_images_->at(i).image_);
 		newStr.prepend(QString("%1: ").arg(i));
 		list_images_widget_->item(i)->setText(newStr);
 	}

+ 7 - 3
OptionsForm.h

@@ -1,5 +1,5 @@
-/*
- * ImageDescriptionForm.h
+/*!
+ * \file OptionsForm.h
  *
  *  Created on: Oct 11, 2011
  *      Author: Gapchich Vlad
@@ -17,7 +17,11 @@ class QLabel;
 class QVBoxLayout;
 class QHBoxLayout;
 class QKeyEvent;
-
+//! A widget for changing options
+/*!
+ * For now it contains automatic color generation switcher
+ * and path to the PASCAL "root" folder setter
+ */
 class OptionsForm : public QWidget {
 	Q_OBJECT
 protected:

+ 11 - 21
functions.cpp

@@ -64,8 +64,10 @@ getNumFromString(
 	return num;
 }
 
+
+//! Adds given suffix to the file name
 /*
- * adds given suffix to the file name
+ * example: /home/user/file.dot -> /home/user/file_altered.dot
  */
 QString
 alterFileName(const QString &aFilename, const QString &aSuffix)
@@ -84,6 +86,10 @@ alterFileName(const QString &aFilename, const QString &aSuffix)
 	return newFileName;
 }
 
+//! Removes the path from filename
+/*!
+ * example: /home/user/file -> file
+ */
 QString
 removePath(const QString &aFilename)
 {
@@ -95,6 +101,10 @@ removePath(const QString &aFilename)
 	return newFileName;
 }
 
+//! Gets path from filename
+/*!
+ *  example: /home/user/file.dot -> /home/user
+ */
 QString
 getPathFromFilename(const QString &aFilename)
 {
@@ -106,26 +116,6 @@ getPathFromFilename(const QString &aFilename)
 	return path;
 }
 
-QString
-getDirFromPath(const QString *aPath)
-{
-	int lastSlash = aPath->lastIndexOf("/");
-	int symbolCount = aPath->size() - (aPath->size() - lastSlash);
-
-	QString dir = aPath->mid(0, symbolCount);
-	return dir;
-}
-
-QString
-getFilenameFromPath(const QString *aPath)
-{
-	int lastSlash = aPath->lastIndexOf("/") + 1;
-	int strLen = aPath->size() - lastSlash;
-
-	QString dir = aPath->mid(lastSlash, strLen);
-	return dir;
-}
-
 /*
  *
  */