]> gitweb.hamatoma.de Git - reqt/commitdiff
ReFind: windows: drag&drop+clipboard copy works master-2
authorHamatoma <git.tortouse@hm.f-r-e-i.de>
Tue, 2 Jun 2015 23:00:46 +0000 (01:00 +0200)
committerHamatoma <git.tortouse@hm.f-r-e-i.de>
Tue, 2 Jun 2015 23:00:46 +0000 (01:00 +0200)
appl/refind/mainwindow.cpp

index c7ec31bf11b78e55ea3502986fd8fb0a3b816a45..bd9579cc7bd57c1024e08511792fc86a005cbc5c 100644 (file)
@@ -38,133 +38,134 @@ const QString VERSION("2015.06.01");
  * @param parent    NULL or the parent widget
  */
 MainWindow::MainWindow(const QString& startDir, const QString& homeDir,
-   QWidget *parent) :
-            QMainWindow(parent),
-            ui(new Ui::MainWindow),
-            m_statusMessage(NULL),
-            m_stdLabelBackgroundRole(NULL),
-            m_textFinder(),
-            m_lastBaseDir(),
-            m_horizontalHeader(NULL),
-            m_lastOrder(Qt::DescendingOrder),
-            m_homeDir(homeDir),
-            m_storageFile(),
-            m_contextHandlers(){
-   ui->setupUi(this);
-   initializeHome();
-   m_statusMessage = new QLabel(tr("Welcome at refind"));
-   if (!startDir.isEmpty())
-      ui->comboBoxDirectory->setCurrentText(startDir);
-   if (ui->comboBoxDirectory->currentText().isEmpty())
-      ui->comboBoxDirectory->setCurrentText(QDir::currentPath());
-   ui->tableWidget->setMainWindow(this);
-   statusBar()->addWidget(m_statusMessage);
-   connect(ui->actionSearch, SIGNAL(triggered()), this, SLOT(search()));
-   connect(ui->pushButtonSearch, SIGNAL(clicked()), this, SLOT(search()));
-   connect(ui->pushButtonSearch2, SIGNAL(clicked()), this, SLOT(search()));
-   connect(ui->actionUp, SIGNAL(triggered()), this, SLOT(up()));
-   connect(ui->pushButtonUp, SIGNAL(clicked()), this, SLOT(up()));
-   connect(ui->actionSelectDirectory, SIGNAL(triggered()), this,
-      SLOT(selectDirectory()));
-   connect(ui->actionSaveProgramState, SIGNAL(triggered()), this,
-      SLOT(saveState()));
-   connect(ui->pushButtonDirectory, SIGNAL(clicked()), this,
-      SLOT(selectDirectory()));
-   connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
-   connect(ui->actionOptions, SIGNAL(triggered()), this, SLOT(options()));
-   connect(ui->actionGetAbsPath, SIGNAL(triggered()), this,
-      SLOT(absPathToClipboard()));
-   connect(ui->actionGetFullName, SIGNAL(triggered()), this,
-      SLOT(fullNameToClipboard()));
-   connect(ui->actionGetFullName, SIGNAL(triggered()), this,
-      SLOT(fullNameToClipboard()));
-   connect(ui->actionReset, SIGNAL(triggered()), this, SLOT(resetParameters()));
-   connect(ui->tableWidget, SIGNAL(cellClicked(int,int)), this, SLOT(cellEntered(int, int)));
-   connect(ui->actionExport, SIGNAL(triggered()), this, SLOT(exportFiles()));
-   connect(ui->pushButtonExport, SIGNAL(clicked()), this, SLOT(exportFiles()));
-   connect(ui->pushButtonExportFile, SIGNAL(clicked()), this,
-      SLOT(selectExportFile()));
-   connect(ui->pushButtonFilePlaceholder, SIGNAL(clicked()), this,
-      SLOT(filePlaceholder()));
-   connect(ui->pushButtonHeaderPlaceholder, SIGNAL(clicked()), this,
-      SLOT(headerPlaceholder()));
-   connect(ui->pushButtonFooterPlaceholder, SIGNAL(clicked()), this,
-      SLOT(footerPlaceholder()));
-   connect(ui->actionPreview, SIGNAL(triggered()), this, SLOT(preview()));
-   connect(ui->pushButtonPreview, SIGNAL(clicked()), this, SLOT(preview()));
-
-   m_horizontalHeader = ui->tableWidget->horizontalHeader();
-   connect(m_horizontalHeader, SIGNAL(sectionClicked ( int ) ),
-            this, SLOT(headerClicked ( int ) ));
-   ui->tableWidget->setColumnWidth(TC_NODE, 200);
-   ui->tableWidget->setColumnWidth(TC_EXT, 40);
-   ui->tableWidget->setColumnWidth(TC_SIZE, 125);
-   ui->tableWidget->setColumnWidth(TC_MODIFIED, 175);
-   ui->tableWidget->setColumnWidth(TC_TYPE, 75);
-   prepareContextMenu();
+       QWidget *parent) :
+               QMainWindow(parent),
+               ui(new Ui::MainWindow),
+               m_statusMessage(NULL),
+               m_stdLabelBackgroundRole(NULL),
+               m_textFinder(),
+               m_lastBaseDir(),
+               m_horizontalHeader(NULL),
+               m_lastOrder(Qt::DescendingOrder),
+               m_homeDir(homeDir),
+               m_storageFile(),
+               m_contextHandlers() {
+       ui->setupUi(this);
+       initializeHome();
+       m_statusMessage = new QLabel(tr("Welcome at refind"));
+       if (!startDir.isEmpty())
+               ui->comboBoxDirectory->setCurrentText(startDir);
+       if (ui->comboBoxDirectory->currentText().isEmpty())
+               ui->comboBoxDirectory->setCurrentText(QDir::currentPath());
+       ui->tableWidget->setMainWindow(this);
+       statusBar()->addWidget(m_statusMessage);
+       connect(ui->actionSearch, SIGNAL(triggered()), this, SLOT(search()));
+       connect(ui->pushButtonSearch, SIGNAL(clicked()), this, SLOT(search()));
+       connect(ui->pushButtonSearch2, SIGNAL(clicked()), this, SLOT(search()));
+       connect(ui->actionUp, SIGNAL(triggered()), this, SLOT(up()));
+       connect(ui->pushButtonUp, SIGNAL(clicked()), this, SLOT(up()));
+       connect(ui->actionSelectDirectory, SIGNAL(triggered()), this,
+               SLOT(selectDirectory()));
+       connect(ui->actionSaveProgramState, SIGNAL(triggered()), this,
+               SLOT(saveState()));
+       connect(ui->pushButtonDirectory, SIGNAL(clicked()), this,
+               SLOT(selectDirectory()));
+       connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
+       connect(ui->actionOptions, SIGNAL(triggered()), this, SLOT(options()));
+       connect(ui->actionGetAbsPath, SIGNAL(triggered()), this,
+               SLOT(absPathToClipboard()));
+       connect(ui->actionGetFullName, SIGNAL(triggered()), this,
+               SLOT(fullNameToClipboard()));
+       connect(ui->actionGetFullName, SIGNAL(triggered()), this,
+               SLOT(fullNameToClipboard()));
+       connect(ui->actionReset, SIGNAL(triggered()), this,
+               SLOT(resetParameters()));
+       connect(ui->tableWidget, SIGNAL(cellClicked(int,int)), this, SLOT(cellEntered(int, int)));
+       connect(ui->actionExport, SIGNAL(triggered()), this, SLOT(exportFiles()));
+       connect(ui->pushButtonExport, SIGNAL(clicked()), this, SLOT(exportFiles()));
+       connect(ui->pushButtonExportFile, SIGNAL(clicked()), this,
+               SLOT(selectExportFile()));
+       connect(ui->pushButtonFilePlaceholder, SIGNAL(clicked()), this,
+               SLOT(filePlaceholder()));
+       connect(ui->pushButtonHeaderPlaceholder, SIGNAL(clicked()), this,
+               SLOT(headerPlaceholder()));
+       connect(ui->pushButtonFooterPlaceholder, SIGNAL(clicked()), this,
+               SLOT(footerPlaceholder()));
+       connect(ui->actionPreview, SIGNAL(triggered()), this, SLOT(preview()));
+       connect(ui->pushButtonPreview, SIGNAL(clicked()), this, SLOT(preview()));
+
+       m_horizontalHeader = ui->tableWidget->horizontalHeader();
+       connect(m_horizontalHeader, SIGNAL(sectionClicked ( int ) ),
+               this, SLOT(headerClicked ( int ) ));
+       ui->tableWidget->setColumnWidth(TC_NODE, 200);
+       ui->tableWidget->setColumnWidth(TC_EXT, 40);
+       ui->tableWidget->setColumnWidth(TC_SIZE, 125);
+       ui->tableWidget->setColumnWidth(TC_MODIFIED, 175);
+       ui->tableWidget->setColumnWidth(TC_TYPE, 75);
+       prepareContextMenu();
 }
 
 /**
  * @brief Destructor.
  */
-MainWindow::~MainWindow(){
-   delete ui;
+MainWindow::~MainWindow() {
+       delete ui;
 }
 
 /**
  * initializeHomeializes the program home directory.
  */
-void MainWindow::initializeHome(){
-   if (m_homeDir.isEmpty()){
-      m_homeDir = QDir::home().absoluteFilePath(".refind");
-   }
+void MainWindow::initializeHome() {
+       if (m_homeDir.isEmpty()) {
+               m_homeDir = QDir::home().absoluteFilePath(".refind");
+       }
 
-   QDir home(m_homeDir);
-   if (!home.exists()){
-      if (!home.mkpath(m_homeDir)){
-         m_homeDir = home.tempPath() + "/.refind";
-         home.mkpath(m_homeDir);
-      }
-   }
-   if (!m_homeDir.endsWith("/"))
-      m_homeDir += "/";
-   m_storageFile = m_homeDir + "state.conf";
-   restoreState();
+       QDir home(m_homeDir);
+       if (!home.exists()) {
+               if (!home.mkpath(m_homeDir)) {
+                       m_homeDir = home.tempPath() + "/.refind";
+                       home.mkpath(m_homeDir);
+               }
+       }
+       if (!m_homeDir.endsWith("/"))
+               m_homeDir += "/";
+       m_storageFile = m_homeDir + "state.conf";
+       restoreState();
 }
 
 /**
  * Starts the about dialog.
  */
-void MainWindow::about(){
-   AboutDialog dialog(VERSION);
-   dialog.exec();
+void MainWindow::about() {
+       AboutDialog dialog(VERSION);
+       dialog.exec();
 }
 
 /**
  * Starts the options dialog.
  */
-void MainWindow::options(){
-   DialogOptions dialog(m_contextHandlers, NULL);
-   dialog.exec();
+void MainWindow::options() {
+       DialogOptions dialog(m_contextHandlers, NULL);
+       dialog.exec();
 }
 
 /**
  * Puts the absolute path of the current (selected) file into the clipboard.
  */
-void MainWindow::absPathToClipboard(){
-   int row = ui->tableWidget->currentRow();
-   if (row >= 0){
-      QClipboard *clipboard = QApplication::clipboard();
-      clipboard->setText(buildAbsPath(row));
-   }
+void MainWindow::absPathToClipboard() {
+       int row = ui->tableWidget->currentRow();
+       if (row >= 0) {
+               QClipboard *clipboard = QApplication::clipboard();
+               clipboard->setText(buildAbsPath(row));
+       }
 }
 
 /**
  * Puts the base directory into the clipboard.
  */
-void MainWindow::baseDirToClipboard(){
-   QClipboard *clipboard = QApplication::clipboard();
-   clipboard->setText(m_lastBaseDir.absolutePath());
+void MainWindow::baseDirToClipboard() {
+       QClipboard *clipboard = QApplication::clipboard();
+       clipboard->setText(m_lastBaseDir.absolutePath());
 }
 
 /**
@@ -176,41 +177,42 @@ void MainWindow::baseDirToClipboard(){
  *                  false: example: u:\tmp\file.txt
  * @return          the absolute path of the file given by the row
  */
-QString MainWindow::buildAbsPath(int row, bool withNode, bool uriFormat){
-   QString rc(m_lastBaseDir.absolutePath());
-   QString value = cellAsText(row, TC_PATH);
-   if (!value.isEmpty()){
-      ReQStringUtil::ensureLastChar(rc, '/');
-      rc += value;
-   }
-   if (withNode){
-      ReQStringUtil::ensureLastChar(rc, '/');
-      rc += cellAsText(row, TC_NODE);
-   }
-   if (uriFormat){
-      rc = "file://" + rc;
-#if defined WIN32
-      rc = rc.replace('\\', '/');
+QString MainWindow::buildAbsPath(int row, bool withNode, bool uriFormat) {
+       QString rc(m_lastBaseDir.absolutePath());
+       QString value = cellAsText(row, TC_PATH);
+       if (!value.isEmpty()) {
+               ReQStringUtil::ensureLastChar(rc, '/');
+               rc += value;
+       }
+       if (withNode) {
+               ReQStringUtil::ensureLastChar(rc, '/');
+               rc += cellAsText(row, TC_NODE);
+       }
+       if (uriFormat) {
+#if defined __linux__
+               rc = "file://" + rc;
+#elif defined WIN32
+               rc = "file:///" + rc.replace('\\', '/');
 #endif
-   }
-   return rc;
+       }
+       return rc;
 }
 
 /**
  * Converts the checkbox states to a filetype mask.
  * @return the filetypes selected by the checkboxes
  */
-QDir::Filters MainWindow::buildFileTypes(){
-   QDir::Filters rc = 0;
-   if (ui->checkBoxDirs->isChecked())
-      rc |= QDir::Dirs;
-   if (ui->checkBoxFiles->isChecked())
-      rc |= QDir::Files;
-   if (rc == 0)
-      rc |= QDir::Dirs | QDir::Files;
-   if (!ui->checkBoxLinks->isChecked())
-      rc |= QDir::NoSymLinks;
-   return rc;
+QDir::Filters MainWindow::buildFileTypes() {
+       QDir::Filters rc = 0;
+       if (ui->checkBoxDirs->isChecked())
+               rc |= QDir::Dirs;
+       if (ui->checkBoxFiles->isChecked())
+               rc |= QDir::Files;
+       if (rc == 0)
+               rc |= QDir::Dirs | QDir::Files;
+       if (!ui->checkBoxLinks->isChecked())
+               rc |= QDir::NoSymLinks;
+       return rc;
 }
 
 /**
@@ -220,12 +222,12 @@ QDir::Filters MainWindow::buildFileTypes(){
  * @param col   the column number: 0..C-1
  * @return      the text of the given cell
  */
-QString MainWindow::cellAsText(int row, int col){
-   QTableWidgetItem* widget = ui->tableWidget->item(row, col);
-   QString rc;
-   if (widget != NULL)
-      rc = widget->text();
-   return rc;
+QString MainWindow::cellAsText(int row, int col) {
+       QTableWidgetItem* widget = ui->tableWidget->item(row, col);
+       QString rc;
+       if (widget != NULL)
+               rc = widget->text();
+       return rc;
 }
 
 /**
@@ -234,69 +236,69 @@ QString MainWindow::cellAsText(int row, int col){
  * @param text  the text to convert
  * @return      <code>text</code> with the esc sequences replaced
  */
-QString replaceEscSequences(const QString& text){
-   QString rc = text;
-   int start = 0;
-   QString replacement;
-   while (start < rc.length()){
-      start = text.indexOf('\\', start);
-      if (start < 0)
-         break;
-      QChar replacement = 0;
-      switch (text[start + 1].toLatin1()) {
-      case 'n':
-         replacement = '\n';
-         break;
-      case 't':
-         replacement = '\t';
-         break;
-      case 'r':
-         replacement = '\r';
-         break;
-      default:
-         replacement = text[start + 1];
-         break;
-      }
-      rc.remove(start, 1);
-      rc[start] = replacement;
-      start++;
-   }
-   return rc;
-}
-
-void MainWindow::closing(){
-   saveState();
+QString replaceEscSequences(const QString& text) {
+       QString rc = text;
+       int start = 0;
+       QString replacement;
+       while (start < rc.length()) {
+               start = text.indexOf('\\', start);
+               if (start < 0)
+                       break;
+               QChar replacement = 0;
+               switch (text[start + 1].toLatin1()) {
+               case 'n':
+                       replacement = '\n';
+                       break;
+               case 't':
+                       replacement = '\t';
+                       break;
+               case 'r':
+                       replacement = '\r';
+                       break;
+               default:
+                       replacement = text[start + 1];
+                       break;
+               }
+               rc.remove(start, 1);
+               rc[start] = replacement;
+               start++;
+       }
+       return rc;
+}
+
+void MainWindow::closing() {
+       saveState();
 }
 
 /**
  * Handles the click of the "export" button.
  */
-void MainWindow::exportFiles(){
-   comboText(ui->comboBoxHeader);
-   comboText(ui->comboBoxTemplate);
-   comboText(ui->comboBoxExportFile);
-   comboText(ui->comboBoxFooter);
-   if (ui->radioButtonFile->isChecked()){
-      QString fn = ui->comboBoxExportFile->currentText();
-      FILE* fp = fopen(fn.toUtf8(), "w");
-      if (fp == NULL)
-         guiError(ui->comboBoxExportFile, tr("not a valid file: ") + fn);
-      else{
-         QTextStream stream(fp);
-         exportToStream(stream);
-         fclose(fp);
-         setStatusMessage(false, tr("result exported to ") + fn);
-      }
-   }else{
-      QString value;
-      QTextStream stream(&value);
-      m_errors = 0;
-      exportToStream(stream);
-      QClipboard* clipboard = QApplication::clipboard();
-      clipboard->setText(value);
-      if (m_errors == 0)
-         setStatusMessage(false, tr("result exported to the clipboard"));
-   }
+void MainWindow::exportFiles() {
+       comboText(ui->comboBoxHeader);
+       comboText(ui->comboBoxTemplate);
+       comboText(ui->comboBoxExportFile);
+       comboText(ui->comboBoxFooter);
+       if (ui->radioButtonFile->isChecked()) {
+               QString fn = ui->comboBoxExportFile->currentText();
+               FILE* fp = fopen(fn.toUtf8(), "w");
+               if (fp == NULL)
+                       guiError(ui->comboBoxExportFile, tr("not a valid file: ") + fn);
+               else {
+                       QTextStream stream(fp);
+                       exportToStream(stream);
+                       fclose(fp);
+                       setStatusMessage(false, tr("result exported to ") + fn);
+               }
+       } else {
+               QString value;
+               QTextStream stream(&value);
+               m_errors = 0;
+               exportToStream(stream);
+               QClipboard* clipboard = QApplication::clipboard();
+               clipboard->setText(value);
+               if (m_errors == 0)
+                       setStatusMessage(false, tr("result exported to the clipboard"));
+       }
 }
 
 /**
@@ -305,120 +307,121 @@ void MainWindow::exportFiles(){
  * @param stream    OUT: the stream for the export
  * @param maxRow    -1 or the maximum row to export
  */
-void MainWindow::exportToStream(QTextStream& stream, int maxRow){
-   QMap < QString, QString > placeholders;
-   buildGlobalPlaceholders (placeholders);
-   if (!ui->comboBoxHeader->currentText().isEmpty()){
-      stream << replaceGlobalPlaceholders(ui->comboBoxHeader, placeholders)
-         << endl;
-   }
-   int count = ui->tableWidget->rowCount();
-   if (count > 0 && maxRow > 0)
-      count = maxRow;
-   QString error;
-   for (int ii = 0; ii < count; ii++){
-      QString line = ui->comboBoxTemplate->currentText();
-      QMap < QString, QString > placeholders;
-      QString path = m_lastBaseDir.absoluteFilePath(
-         ReQStringUtil::pathAppend(ui->tableWidget->item(ii, TC_PATH)->text(),
-            ui->tableWidget->item(ii, TC_NODE)->text()));
-      placeholders.insert("full", ReQStringUtil::nativePath(path));
-      placeholders.insert("path", ui->tableWidget->item(ii, TC_PATH)->text());
-      placeholders.insert("ext", ui->tableWidget->item(ii, TC_EXT)->text());
-      placeholders.insert("node", ui->tableWidget->item(ii, TC_NODE)->text());
-      placeholders.insert("modified",
-         ui->tableWidget->item(ii, TC_MODIFIED)->text());
-      placeholders.insert("size", ui->tableWidget->item(ii, TC_SIZE)->text());
-      if (!ReQStringUtil::replacePlaceholders(line, placeholders, &error)){
-         guiError(ui->comboBoxTemplate, error);
-         break;
-      }
-      stream << replaceEscSequences(line) << endl;
-   }
-   if (!ui->comboBoxFooter->currentText().isEmpty()){
-      stream << replaceGlobalPlaceholders(ui->comboBoxFooter, placeholders)
-         << endl;
-   }
+void MainWindow::exportToStream(QTextStream& stream, int maxRow) {
+       QMap < QString, QString > placeholders;
+       buildGlobalPlaceholders (placeholders);
+       if (!ui->comboBoxHeader->currentText().isEmpty()) {
+               stream << replaceGlobalPlaceholders(ui->comboBoxHeader, placeholders)
+                       << endl;
+       }
+       int count = ui->tableWidget->rowCount();
+       if (count > 0 && maxRow > 0)
+               count = maxRow;
+       QString error;
+       for (int ii = 0; ii < count; ii++) {
+               QString line = ui->comboBoxTemplate->currentText();
+               QMap < QString, QString > placeholders;
+               QString path = m_lastBaseDir.absoluteFilePath(
+                       ReQStringUtil::pathAppend(
+                               ui->tableWidget->item(ii, TC_PATH)->text(),
+                               ui->tableWidget->item(ii, TC_NODE)->text()));
+               placeholders.insert("full", ReQStringUtil::nativePath(path));
+               placeholders.insert("path", ui->tableWidget->item(ii, TC_PATH)->text());
+               placeholders.insert("ext", ui->tableWidget->item(ii, TC_EXT)->text());
+               placeholders.insert("node", ui->tableWidget->item(ii, TC_NODE)->text());
+               placeholders.insert("modified",
+                       ui->tableWidget->item(ii, TC_MODIFIED)->text());
+               placeholders.insert("size", ui->tableWidget->item(ii, TC_SIZE)->text());
+               if (!ReQStringUtil::replacePlaceholders(line, placeholders, &error)) {
+                       guiError(ui->comboBoxTemplate, error);
+                       break;
+               }
+               stream << replaceEscSequences(line) << endl;
+       }
+       if (!ui->comboBoxFooter->currentText().isEmpty()) {
+               stream << replaceGlobalPlaceholders(ui->comboBoxFooter, placeholders)
+                       << endl;
+       }
 }
 
 /**
  * Processes the dragging operation of the selected files in the table widget.
  */
-void MainWindow::fileDragging(){
-
-   QDrag *drag = new QDrag(this);
-   QMimeData *mimeData = new QMimeData;
-   QList < QUrl > urls;
-   QList < QTableWidgetSelectionRange > ranges =
-      ui->tableWidget->selectedRanges();
-   QList <QTableWidgetSelectionRange>::iterator it;
-   int files = 0;
-   int dirs = 0;
-   bool isDir = false;
-   for (it = ranges.begin(); it != ranges.end(); ++it){
-      for (int row = (*it).topRow(); row <= (*it).bottomRow(); row++){
-         isDir = cellAsText(row, TC_SIZE).isEmpty();
-         QUrl url(buildAbsPath(row, true, true));
-         urls.append(url);
-         if (isDir)
-            dirs++;
-         else
-            files++;
-      }
-   }
-   if (urls.size() > 0){
-      mimeData->setUrls(urls);
-      drag->setMimeData(mimeData);
-      QPixmap image(200, 30);
-      QPainter painter(&image);
-      QString msg;
-      if (urls.size() == 1)
-         msg = tr("copy ") + ReQStringUtil::nodeOf(urls.at(0).toString());
-      else if (files > 0 && dirs > 0)
-         msg = tr("copy %1 file(s) and %2 dir(s)").arg(files).arg(dirs);
-      else if (files > 0)
-         msg = tr("copy %1 file(s)").arg(files);
-      else
-         msg = tr("copy %1 dirs(s)").arg(dirs);
-
-      painter.fillRect(image.rect(), Qt::white);
-      painter.drawText(10, 20, msg);
-      drag->setPixmap(image);
-
-      Qt::DropAction dropAction = drag->exec(Qt::CopyAction);
-   }
+void MainWindow::fileDragging() {
+
+       QDrag *drag = new QDrag(this);
+       QMimeData *mimeData = new QMimeData;
+       QList < QUrl > urls;
+       QList < QTableWidgetSelectionRange > ranges = ui->tableWidget
+               ->selectedRanges();
+       QList<QTableWidgetSelectionRange>::iterator it;
+       int files = 0;
+       int dirs = 0;
+       bool isDir = false;
+       for (it = ranges.begin(); it != ranges.end(); ++it) {
+               for (int row = (*it).topRow(); row <= (*it).bottomRow(); row++) {
+                       isDir = cellAsText(row, TC_SIZE).isEmpty();
+                       QUrl url(buildAbsPath(row, true, true));
+                       urls.append(url);
+                       if (isDir)
+                               dirs++;
+                       else
+                               files++;
+               }
+       }
+       if (urls.size() > 0) {
+               mimeData->setUrls(urls);
+               drag->setMimeData(mimeData);
+               QPixmap image(200, 30);
+               QPainter painter(&image);
+               QString msg;
+               if (urls.size() == 1)
+                       msg = tr("copy ") + ReQStringUtil::nodeOf(urls.at(0).toString());
+               else if (files > 0 && dirs > 0)
+                       msg = tr("copy %1 file(s) and %2 dir(s)").arg(files).arg(dirs);
+               else if (files > 0)
+                       msg = tr("copy %1 file(s)").arg(files);
+               else
+                       msg = tr("copy %1 dirs(s)").arg(dirs);
+
+               painter.fillRect(image.rect(), Qt::white);
+               painter.drawText(10, 20, msg);
+               drag->setPixmap(image);
+
+               Qt::DropAction dropAction = drag->exec(Qt::CopyAction);
+       }
 }
 
 /**
  * Handles the push of "select file placeholder".
  */
-void MainWindow::filePlaceholder(){
-   DialogFilePlaceholder dialog;
-   dialog.exec();
-   if (!dialog.var().isEmpty()){
-      QComboBox* target = ui->comboBoxTemplate;
-      target->setCurrentText(target->currentText() + dialog.var());
-   }
+void MainWindow::filePlaceholder() {
+       DialogFilePlaceholder dialog;
+       dialog.exec();
+       if (!dialog.var().isEmpty()) {
+               QComboBox* target = ui->comboBoxTemplate;
+               target->setCurrentText(target->currentText() + dialog.var());
+       }
 }
 
 /**
  * Handles the push of "select placeholder for the footer".
  */
-void MainWindow::footerPlaceholder(){
-   handlePlaceholder(ui->comboBoxFooter);
+void MainWindow::footerPlaceholder() {
+       handlePlaceholder(ui->comboBoxFooter);
 }
 
 /**
  * Puts the absolute full name of the current (selected) file into the clipboard.
  */
-void MainWindow::fullNameToClipboard(){
-   int row = ui->tableWidget->currentRow();
-   if (row >= 0){
-      QClipboard* clipboard = QApplication::clipboard();
-      QString path = buildAbsPath(row);
-      path += cellAsText(row, TC_NODE);
-      clipboard->setText(path);
-   }
+void MainWindow::fullNameToClipboard() {
+       int row = ui->tableWidget->currentRow();
+       if (row >= 0) {
+               QClipboard* clipboard = QApplication::clipboard();
+               QString path = buildAbsPath(row);
+               path += cellAsText(row, TC_NODE);
+               clipboard->setText(path);
+       }
 }
 
 /**
@@ -427,35 +430,35 @@ void MainWindow::fullNameToClipboard(){
  * @param currentRow    the row where the context menu is called
  * @param full          the full name of the current row
  */
-void MainWindow::handleCopyToClipboard(int currentRow, const QString& full){
-   QMimeData *mimeData = new QMimeData;
-   QList < QUrl > urls;
-   bool isInSelection = false;
-   QList < QTableWidgetSelectionRange > ranges =
-      ui->tableWidget->selectedRanges();
-   QList <QTableWidgetSelectionRange>::iterator it;
-   QString textList;
-   textList.reserve(ui->tableWidget->rowCount() * 80);
-   for (it = ranges.begin(); it != ranges.end(); ++it){
-      for (int row = (*it).topRow(); row <= (*it).bottomRow(); row++){
-         isInSelection = isInSelection || row == currentRow;
-         QString name(buildAbsPath(row, true));
-         QUrl url(name);
-         textList += name + '\n';
-         urls.append(url);
-      }
-   }
-   if (!isInSelection){
-      urls.clear();
-      urls.append(QUrl(full));
-      textList = full;
-   }
-   mimeData->setUrls(urls);
-   mimeData->setText(textList);
-   QClipboard *clipboard = QApplication::clipboard();
-   clipboard->setMimeData(mimeData);
-   setStatusMessage(false,
-      tr("%1 entry/entries copied to clipboard").arg(urls.length()));
+void MainWindow::handleCopyToClipboard(int currentRow, const QString& full) {
+       QMimeData *mimeData = new QMimeData;
+       QList < QUrl > urls;
+       bool isInSelection = false;
+       QList < QTableWidgetSelectionRange > ranges = ui->tableWidget
+               ->selectedRanges();
+       QList<QTableWidgetSelectionRange>::iterator it;
+       QString textList;
+       textList.reserve(ui->tableWidget->rowCount() * 80);
+       for (it = ranges.begin(); it != ranges.end(); ++it) {
+               for (int row = (*it).topRow(); row <= (*it).bottomRow(); row++) {
+                       isInSelection = isInSelection || row == currentRow;
+                       QString name(buildAbsPath(row, true, true));
+                       QUrl url(name);
+                       textList += name + '\n';
+                       urls.append(url);
+               }
+       }
+       if (!isInSelection) {
+               urls.clear();
+               urls.append(QUrl(full));
+               textList = full;
+       }
+       mimeData->setUrls(urls);
+       mimeData->setText(textList);
+       QClipboard *clipboard = QApplication::clipboard();
+       clipboard->setMimeData(mimeData);
+       setStatusMessage(false,
+               tr("%1 entry/entries copied to clipboard").arg(urls.length()));
 }
 
 /**
@@ -467,42 +470,42 @@ void MainWindow::handleCopyToClipboard(int currentRow, const QString& full){
  * @param node      the file name without path
  */
 void MainWindow::handleExternalCommand(ContextHandler* handler,
-   const QString& parent, const QString& full, const QString& node){
-   QString arguments = handler->m_arguments;
-   QString dir;
-   switch (handler->m_directoryMode) {
-   case ContextHandler::DM_TO_PARENT:
-      dir = parent;
-      break;
-   case ContextHandler::DM_TO_FILE:
-      dir = full;
-      break;
-   default:
-      dir = ui->comboBoxDirectory->currentText();
-      break;
-   }
-   QMap < QString, QString > placeholders;
-   placeholders.insert("full", full);
-   placeholders.insert("node", node);
-   placeholders.insert("path", parent);
-   placeholders.insert("ext", ReQStringUtil::extensionOf(node));
-   QString error;
-   QStringList args = arguments.split(' ');
-   bool hasErrors = false;
-   for (int ix = 0; ix < args.size(); ix++){
-      QString arg = args.at(ix);
-      if (!ReQStringUtil::replacePlaceholders(arg, placeholders, &error)){
-         guiError(NULL, error);
-         hasErrors = true;
-         break;
-      }
-      args.replace(ix, arg);
-   }
-   if (!hasErrors){
-      QProcess::startDetached(handler->m_program, args, dir, NULL);
-      setStatusMessage(false,
-         tr("started:") + " " + handler->m_program + " " + arguments);
-   }
+       const QString& parent, const QString& full, const QString& node) {
+       QString arguments = handler->m_arguments;
+       QString dir;
+       switch (handler->m_directoryMode) {
+       case ContextHandler::DM_TO_PARENT:
+               dir = parent;
+               break;
+       case ContextHandler::DM_TO_FILE:
+               dir = full;
+               break;
+       default:
+               dir = ui->comboBoxDirectory->currentText();
+               break;
+       }
+       QMap < QString, QString > placeholders;
+       placeholders.insert("full", full);
+       placeholders.insert("node", node);
+       placeholders.insert("path", parent);
+       placeholders.insert("ext", ReQStringUtil::extensionOf(node));
+       QString error;
+       QStringList args = arguments.split(' ');
+       bool hasErrors = false;
+       for (int ix = 0; ix < args.size(); ix++) {
+               QString arg = args.at(ix);
+               if (!ReQStringUtil::replacePlaceholders(arg, placeholders, &error)) {
+                       guiError(NULL, error);
+                       hasErrors = true;
+                       break;
+               }
+               args.replace(ix, arg);
+       }
+       if (!hasErrors) {
+               QProcess::startDetached(handler->m_program, args, dir, NULL);
+               setStatusMessage(false,
+                       tr("started:") + " " + handler->m_program + " " + arguments);
+       }
 }
 
 /**
@@ -510,11 +513,11 @@ void MainWindow::handleExternalCommand(ContextHandler* handler,
  *
  * @param target    OUT: the combobox where the result is appended
  */
-void MainWindow::handlePlaceholder(QComboBox* target){
-   DialogGlobalPlaceholder dialog;
-   dialog.exec();
-   if (!dialog.var().isEmpty())
-      target->setCurrentText(target->currentText() + dialog.var());
+void MainWindow::handlePlaceholder(QComboBox* target) {
+       DialogGlobalPlaceholder dialog;
+       dialog.exec();
+       if (!dialog.var().isEmpty())
+               target->setCurrentText(target->currentText() + dialog.var());
 }
 
 /**
@@ -527,18 +530,18 @@ void MainWindow::handlePlaceholder(QComboBox* target){
  * @return  the number of selected rows
  */
 static int countSelectedRows(QTableWidget* table, int currentRow,
-   bool& isInSelection){
-   int rc = 0;
-   isInSelection = false;
-   QList < QTableWidgetSelectionRange > ranges = table->selectedRanges();
-   QList <QTableWidgetSelectionRange>::iterator it;
-   for (it = ranges.begin(); it != ranges.end(); ++it){
-      for (int row = (*it).topRow(); row <= (*it).bottomRow(); row++){
-         isInSelection = isInSelection || row == currentRow;
-         rc++;
-      }
-   }
-   return rc;
+       bool& isInSelection) {
+       int rc = 0;
+       isInSelection = false;
+       QList < QTableWidgetSelectionRange > ranges = table->selectedRanges();
+       QList<QTableWidgetSelectionRange>::iterator it;
+       for (it = ranges.begin(); it != ranges.end(); ++it) {
+               for (int row = (*it).topRow(); row <= (*it).bottomRow(); row++) {
+                       isInSelection = isInSelection || row == currentRow;
+                       rc++;
+               }
+       }
+       return rc;
 }
 
 /**
@@ -546,114 +549,114 @@ static int countSelectedRows(QTableWidget* table, int currentRow,
  *
  * @param position  the position of a mouse click
  */
-void MainWindow::handleTableContextMenu(const QPoint& position){
-   int currentRow = ui->tableWidget->rowAt(position.y());
-   if (currentRow >= 0){
-      QMenu menu;
-
-      QString node = ui->tableWidget->item(currentRow, TC_NODE)->text();
-      QString parent = buildAbsPath(currentRow);
-      QString full = ReQStringUtil::pathAppend(parent, node);
-      QFileInfo file(full);
-      bool isDir = file.isDir();
-      QList <ContextHandler*>::const_iterator it;
-      QMap <QAction*, ContextHandler*> actions;
-      ContextHandler* handler;
-      bool hasSeparator = false;
-      for (it = m_contextHandlers.list().begin();
-               it != m_contextHandlers.list().end(); ++it){
-         handler = *it;
-         if ((isDir && handler->m_fileType == ContextHandler::FT_FILE)
-            || (!isDir && handler->m_fileType == ContextHandler::FT_DIR))
-            continue;
-         QString text = handler->m_text + " " + node;
-         if (handler->intrinsicType() != ContextHandler::IT_UNDEF){
-            if (!hasSeparator){
-               hasSeparator = true;
-               menu.addSeparator();
-            }
-            bool inSelection = false;
-            int count = countSelectedRows(ui->tableWidget, currentRow,
-               inSelection);
-            if (inSelection)
-               text = handler->m_text + tr(" %1 object(s)").arg(count);
-         }
-         actions.insert(menu.addAction(text), handler);
-      }
-      QAction* selectedItem = menu.exec(
-         ui->tableWidget->viewport()->mapToGlobal(position));
-      if (selectedItem != NULL){
-         handler = *actions.find(selectedItem);
-         switch (handler->intrinsicType()) {
-         case ContextHandler::IT_COPY:
-            handleCopyToClipboard(currentRow, full);
-            break;
-         case ContextHandler::IT_UNDEF:
-         default:
-            handleExternalCommand(handler, parent, full, node);
-            break;
-         }
-      }
-   }
+void MainWindow::handleTableContextMenu(const QPoint& position) {
+       int currentRow = ui->tableWidget->rowAt(position.y());
+       if (currentRow >= 0) {
+               QMenu menu;
+
+               QString node = ui->tableWidget->item(currentRow, TC_NODE)->text();
+               QString parent = buildAbsPath(currentRow);
+               QString full = ReQStringUtil::pathAppend(parent, node);
+               QFileInfo file(full);
+               bool isDir = file.isDir();
+               QList<ContextHandler*>::const_iterator it;
+               QMap<QAction*, ContextHandler*> actions;
+               ContextHandler* handler;
+               bool hasSeparator = false;
+               for (it = m_contextHandlers.list().begin();
+                       it != m_contextHandlers.list().end(); ++it) {
+                       handler = *it;
+                       if ((isDir && handler->m_fileType == ContextHandler::FT_FILE)
+                               || (!isDir && handler->m_fileType == ContextHandler::FT_DIR))
+                               continue;
+                       QString text = handler->m_text + " " + node;
+                       if (handler->intrinsicType() != ContextHandler::IT_UNDEF) {
+                               if (!hasSeparator) {
+                                       hasSeparator = true;
+                                       menu.addSeparator();
+                               }
+                               bool inSelection = false;
+                               int count = countSelectedRows(ui->tableWidget, currentRow,
+                                       inSelection);
+                               if (inSelection)
+                                       text = handler->m_text + tr(" %1 object(s)").arg(count);
+                       }
+                       actions.insert(menu.addAction(text), handler);
+               }
+               QAction* selectedItem = menu.exec(
+                       ui->tableWidget->viewport()->mapToGlobal(position));
+               if (selectedItem != NULL) {
+                       handler = *actions.find(selectedItem);
+                       switch (handler->intrinsicType()) {
+                       case ContextHandler::IT_COPY:
+                               handleCopyToClipboard(currentRow, full);
+                               break;
+                       case ContextHandler::IT_UNDEF:
+                       default:
+                               handleExternalCommand(handler, parent, full, node);
+                               break;
+                       }
+               }
+       }
 }
 /**
  * Handles the event "header column clicked".
  *
  * @param col   the col
  */
-void MainWindow::headerClicked(int col){
-   m_lastOrder =
-            m_lastOrder == Qt::AscendingOrder ?
-               Qt::DescendingOrder : Qt::AscendingOrder;
-   ui->tableWidget->sortItems(col, m_lastOrder);
-   m_horizontalHeader->setSortIndicatorShown(true);
-   m_horizontalHeader->setSortIndicator(col, m_lastOrder);
+void MainWindow::headerClicked(int col) {
+       m_lastOrder =
+               m_lastOrder == Qt::AscendingOrder ?
+                       Qt::DescendingOrder : Qt::AscendingOrder;
+       ui->tableWidget->sortItems(col, m_lastOrder);
+       m_horizontalHeader->setSortIndicatorShown(true);
+       m_horizontalHeader->setSortIndicator(col, m_lastOrder);
 }
 
 /**
  * Handles the push of "select placeholder for the header".
  */
-void MainWindow::headerPlaceholder(){
-   handlePlaceholder(ui->comboBoxHeader);
+void MainWindow::headerPlaceholder() {
+       handlePlaceholder(ui->comboBoxHeader);
 }
 
 /**
  * Prepares the context menu of the result table.
  *
  */
-void MainWindow::prepareContextMenu(){
-   ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
-connect(ui->tableWidget,
-         SIGNAL(customContextMenuRequested(const QPoint&)),
-         SLOT(handleTableContextMenu(const QPoint&)));
+void MainWindow::prepareContextMenu() {
+       ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
+       connect(ui->tableWidget,
+               SIGNAL(customContextMenuRequested(const QPoint&)),
+               SLOT(handleTableContextMenu(const QPoint&)));
 }
 
 /**
  * Prepares the text search.
  */
-void MainWindow::prepareTextFind(){
-m_textFinder.setSearchParameter(ui->comboBoxTextPattern->currentText(),
-   ui->checkBoxTextIgnoreCase->isChecked(), ui->checkBoxRegExpr->isChecked(),
-   !ui->checkBoxBinaryFiles->isChecked());
-QString error = m_textFinder.regExprError();
-if (!error.isEmpty()){
-   guiError(ui->comboBoxTextPattern, error);
-}
+void MainWindow::prepareTextFind() {
+       m_textFinder.setSearchParameter(ui->comboBoxTextPattern->currentText(),
+               ui->checkBoxTextIgnoreCase->isChecked(), ui->checkBoxRegExpr->isChecked(),
+               !ui->checkBoxBinaryFiles->isChecked());
+       QString error = m_textFinder.regExprError();
+       if (!error.isEmpty()) {
+               guiError(ui->comboBoxTextPattern, error);
+       }
 }
 
 /**
  * Shows a preview of the result export.
  */
-void MainWindow::preview(){
-QString value;
-QTextStream stream(&value);
-exportToStream(stream, 1);
-QMessageBox msgBox;
-msgBox.setText(value);
-msgBox.setInformativeText(tr("Preview of the Export"));
-msgBox.setStandardButtons(QMessageBox::Cancel);
-msgBox.setDefaultButton(QMessageBox::Save);
-msgBox.exec();
+void MainWindow::preview() {
+       QString value;
+       QTextStream stream(&value);
+       exportToStream(stream, 1);
+       QMessageBox msgBox;
+       msgBox.setText(value);
+       msgBox.setInformativeText(tr("Preview of the Export"));
+       msgBox.setStandardButtons(QMessageBox::Cancel);
+       msgBox.setDefaultButton(QMessageBox::Save);
+       msgBox.exec();
 }
 
 /**
@@ -661,19 +664,19 @@ msgBox.exec();
  *
  * @param hash  IN/OUT: the placeholders will be appended here
  */
-void MainWindow::buildGlobalPlaceholders(QMap <QString, QString>& hash){
+void MainWindow::buildGlobalPlaceholders(QMap<QString, QString>& hash) {
 
-hash.insert("filepatterns", ui->comboBoxFilePatterns->currentText());
-hash.insert("base", m_lastBaseDir.absolutePath());
-hash.insert("textpattern", ui->comboBoxTextPattern->currentText());
-hash.insert("dirs", QString::number(m_statistics.m_dirs));
-hash.insert("files", QString::number(m_statistics.m_files));
-hash.insert("runtime", QString::number(m_statistics.m_runtimeSeconds, 'g', 3));
-hash.insert("bytes", QString::number(m_statistics.m_bytes));
-hash.insert("megabytes",
-   QString::number((double) m_statistics.m_bytes / 1000000));
-hash.insert("datetime",
-   QDateTime::currentDateTime().toLocalTime().toString("yyyy.MM.dd/hh:mm:ss"));
+       hash.insert("filepatterns", ui->comboBoxFilePatterns->currentText());
+       hash.insert("base", m_lastBaseDir.absolutePath());
+       hash.insert("textpattern", ui->comboBoxTextPattern->currentText());
+       hash.insert("dirs", QString::number(m_statistics.m_dirs));
+       hash.insert("files", QString::number(m_statistics.m_files));
+       hash.insert("runtime", QString::number(m_statistics.m_runtimeSeconds, 'g', 3));
+       hash.insert("bytes", QString::number(m_statistics.m_bytes));
+       hash.insert("megabytes",
+               QString::number((double) m_statistics.m_bytes / 1000000));
+       hash.insert("datetime",
+               QDateTime::currentDateTime().toLocalTime().toString("yyyy.MM.dd/hh:mm:ss"));
 }
 /**
  * Replaces the placeholders valid in header and footer.
@@ -682,12 +685,12 @@ hash.insert("datetime",
  * @return      <code>text</code> with the esc sequences replaced
  */
 QString MainWindow::replaceGlobalPlaceholders(QComboBox* combo,
-QMap <QString, QString>& placeholders){
-QString rc = combo->currentText();
-QString error;
-if (!ReQStringUtil::replacePlaceholders(rc, placeholders, &error))
-   guiError(combo, error);
-return replaceEscSequences(rc);
+       QMap<QString, QString>& placeholders) {
+       QString rc = combo->currentText();
+       QString error;
+       if (!ReQStringUtil::replacePlaceholders(rc, placeholders, &error))
+               guiError(combo, error);
+       return replaceEscSequences(rc);
 }
 
 /**
@@ -695,146 +698,147 @@ return replaceEscSequences(rc);
  *
  * Most of the filter parameters will be set to the default.
  */
-void MainWindow::resetParameters(){
-ui->comboBoxFilePatterns->setCurrentText("");
-ui->comboBoxMaxDepth->setCurrentText("");
-ui->comboBoxMaxSize->setCurrentText("");
-ui->comboBoxMinDepth->setCurrentText("");
-ui->comboBoxMinSize->setCurrentText("");
-ui->comboBoxOlder->setCurrentText("");
-ui->comboBoxYounger->setCurrentText("");
-ui->comboBoxTextPattern->setCurrentText("");
-ui->checkBoxBinaryFiles->setChecked(false);
-ui->checkBoxDirs->setChecked(true);
-ui->checkBoxFiles->setChecked(true);
-ui->checkBoxLinks->setChecked(true);
-ui->checkBoxRegExpr->setChecked(false);
-ui->checkBoxTextIgnoreCase->setChecked(false);
+void MainWindow::resetParameters() {
+       ui->comboBoxFilePatterns->setCurrentText("");
+       ui->comboBoxMaxDepth->setCurrentText("");
+       ui->comboBoxMaxSize->setCurrentText("");
+       ui->comboBoxMinDepth->setCurrentText("");
+       ui->comboBoxMinSize->setCurrentText("");
+       ui->comboBoxOlder->setCurrentText("");
+       ui->comboBoxYounger->setCurrentText("");
+       ui->comboBoxTextPattern->setCurrentText("");
+       ui->checkBoxBinaryFiles->setChecked(false);
+       ui->checkBoxDirs->setChecked(true);
+       ui->checkBoxFiles->setChecked(true);
+       ui->checkBoxLinks->setChecked(true);
+       ui->checkBoxRegExpr->setChecked(false);
+       ui->checkBoxTextIgnoreCase->setChecked(false);
 }
 
 /**
  * Reads the history of the widget values and other parameters and set it.
  */
-void MainWindow::restoreState(){
-ReStateStorage storage(m_storageFile);
-storage.setForm("main");
-storage.restore(ui->comboBoxDirectory, "comboBoxDirectory", true);
-storage.restore(ui->comboBoxExcludedDirs, "comboBoxExcludedDirs", true);
-storage.restore(ui->comboBoxExportFile, "comboBoxExportFile", true);
-storage.restore(ui->comboBoxFilePatterns, "comboBoxFilePatterns");
-storage.restore(ui->comboBoxFooter, "comboBoxFooter", true);
-storage.restore(ui->comboBoxHeader, "comboBoxHeader", true);
-storage.restore(ui->comboBoxMaxDepth, "comboBoxMaxDepth");
-storage.restore(ui->comboBoxMaxSize, "comboBoxMaxSize");
-storage.restore(ui->comboBoxMinDepth, "comboBoxMinDepth");
-storage.restore(ui->comboBoxMinSize, "comboBoxMinSize");
-storage.restore(ui->comboBoxOlder, "comboBoxOlder");
-storage.restore(ui->comboBoxTemplate, "comboBoxTemplate", true);
-storage.restore(ui->comboBoxTextPattern, "comboBoxTextPattern");
-storage.restore(ui->comboBoxYounger, "comboBoxYounger");
-m_contextHandlers.restore(storage);
-storage.close();
+void MainWindow::restoreState() {
+       ReStateStorage storage(m_storageFile);
+       storage.setForm("main");
+       storage.restore(ui->comboBoxDirectory, "comboBoxDirectory", true);
+       storage.restore(ui->comboBoxExcludedDirs, "comboBoxExcludedDirs", true);
+       storage.restore(ui->comboBoxExportFile, "comboBoxExportFile", true);
+       storage.restore(ui->comboBoxFilePatterns, "comboBoxFilePatterns");
+       storage.restore(ui->comboBoxFooter, "comboBoxFooter", true);
+       storage.restore(ui->comboBoxHeader, "comboBoxHeader", true);
+       storage.restore(ui->comboBoxMaxDepth, "comboBoxMaxDepth");
+       storage.restore(ui->comboBoxMaxSize, "comboBoxMaxSize");
+       storage.restore(ui->comboBoxMinDepth, "comboBoxMinDepth");
+       storage.restore(ui->comboBoxMinSize, "comboBoxMinSize");
+       storage.restore(ui->comboBoxOlder, "comboBoxOlder");
+       storage.restore(ui->comboBoxTemplate, "comboBoxTemplate", true);
+       storage.restore(ui->comboBoxTextPattern, "comboBoxTextPattern");
+       storage.restore(ui->comboBoxYounger, "comboBoxYounger");
+       m_contextHandlers.restore(storage);
+       storage.close();
 }
 
 /**
  * Stores the history of the widget values and other parameters.
  */
-void MainWindow::saveState(){
-ReStateStorage storage(m_storageFile);
-storage.setForm("main");
-storage.store(ui->comboBoxDirectory, "comboBoxDirectory");
-storage.store(ui->comboBoxExcludedDirs, "comboBoxExcludedDirs");
-storage.store(ui->comboBoxExportFile, "comboBoxExportFile");
-storage.store(ui->comboBoxFilePatterns, "comboBoxFilePatterns");
-storage.store(ui->comboBoxFooter, "comboBoxFooter");
-storage.store(ui->comboBoxHeader, "comboBoxHeader");
-storage.store(ui->comboBoxMaxDepth, "comboBoxMaxDepth");
-storage.store(ui->comboBoxMaxSize, "comboBoxMaxSize");
-storage.store(ui->comboBoxMinDepth, "comboBoxMinDepth");
-storage.store(ui->comboBoxMinSize, "comboBoxMinSize");
-storage.store(ui->comboBoxOlder, "comboBoxOlder");
-storage.store(ui->comboBoxTemplate, "comboBoxTemplate");
-storage.store(ui->comboBoxTextPattern, "comboBoxTextPattern");
-storage.store(ui->comboBoxYounger, "comboBoxYounger");
-m_contextHandlers.save(storage);
-storage.close();
+void MainWindow::saveState() {
+       ReStateStorage storage(m_storageFile);
+       storage.setForm("main");
+       storage.store(ui->comboBoxDirectory, "comboBoxDirectory");
+       storage.store(ui->comboBoxExcludedDirs, "comboBoxExcludedDirs");
+       storage.store(ui->comboBoxExportFile, "comboBoxExportFile");
+       storage.store(ui->comboBoxFilePatterns, "comboBoxFilePatterns");
+       storage.store(ui->comboBoxFooter, "comboBoxFooter");
+       storage.store(ui->comboBoxHeader, "comboBoxHeader");
+       storage.store(ui->comboBoxMaxDepth, "comboBoxMaxDepth");
+       storage.store(ui->comboBoxMaxSize, "comboBoxMaxSize");
+       storage.store(ui->comboBoxMinDepth, "comboBoxMinDepth");
+       storage.store(ui->comboBoxMinSize, "comboBoxMinSize");
+       storage.store(ui->comboBoxOlder, "comboBoxOlder");
+       storage.store(ui->comboBoxTemplate, "comboBoxTemplate");
+       storage.store(ui->comboBoxTextPattern, "comboBoxTextPattern");
+       storage.store(ui->comboBoxYounger, "comboBoxYounger");
+       m_contextHandlers.save(storage);
+       storage.close();
 }
 
 /**
  * Handles the "search" button.
  */
-void MainWindow::search(){
-m_errors = 0;
-QApplication::setOverrideCursor (QCursor(Qt::WaitCursor));QString
-path = comboText(ui->comboBoxDirectory);
-QFileInfo dir(path);
-if (!dir.exists())
-   guiError(ui->comboBoxDirectory, tr("directory not found: ") + path);
-else if (!dir.isDir())
-   guiError(ui->comboBoxDirectory, tr("not a directory: ") + path);
-else{
-   m_lastBaseDir.cd(path);
-   FileFinder finder;
-   finder.setBaseDir(path);
-   finder.setMaxSize(comboSize(ui->comboBoxMaxSize));
-   finder.setMinSize(comboSize(ui->comboBoxMinSize));
-   finder.setOlderThan(comboDate(ui->comboBoxOlder));
-   finder.setYoungerThan(comboDate(ui->comboBoxYounger));
-   finder.setMinDepth(comboInt(ui->comboBoxMinDepth, 0));
-   finder.setMaxDepth(comboInt(ui->comboBoxMaxDepth, -1));
-   finder.setFiletypes(buildFileTypes());
-   QStringList patterns;
-   QString value = comboText(ui->comboBoxFilePatterns);
-   if (!value.isEmpty())
-      patterns = value.split(",");
-   finder.setPatterns(patterns);
-   value = comboText(ui->comboBoxExcludedDirs);
-   if (value.indexOf('/') >= 0 || value.indexOf('\\') >= 0)
-      guiError(ui->comboBoxExcludedDirs, tr("no path delimiter allowed"));
-   else if (value.indexOf('*') >= 0)
-      guiError(ui->comboBoxExcludedDirs,
-         tr("no patterns allowed. Do not use '*"));
-   else if (!value.isEmpty())
-      patterns = value.split(",");
-   finder.setExcludedDirs(patterns);
-   prepareTextFind();
-   if (m_errors == 0){
-      if (!comboText(ui->comboBoxTextPattern).isEmpty())
-         finder.setTextFinder(&m_textFinder);
-      m_statistics.clear();
-      clock_t start = clock();
-      finder.fillTable(path, 0, ui->tableWidget, m_statistics);
-      m_statistics.m_runtimeSeconds = (double) (clock() - start)
-         / CLOCKS_PER_SEC;
-      QString msg;
-      msg.sprintf(
-         QObject::tr(
-            "Found: %d dir(s) and %d file(s) with %.6f MByte. Duration of the search: %.3f sec").toUtf8(),
-         m_statistics.m_dirs, m_statistics.m_files,
-         m_statistics.m_bytes / 1000000.0, m_statistics.m_runtimeSeconds);
-      setStatusMessage(false, msg);
-   }
-}
-QApplication::restoreOverrideCursor();
+void MainWindow::search() {
+       m_errors = 0;
+       QApplication::setOverrideCursor (QCursor(Qt::WaitCursor));QString
+       path = comboText(ui->comboBoxDirectory);
+       QFileInfo dir(path);
+       if (!dir.exists())
+               guiError(ui->comboBoxDirectory, tr("directory not found: ") + path);
+       else if (!dir.isDir())
+               guiError(ui->comboBoxDirectory, tr("not a directory: ") + path);
+       else {
+               m_lastBaseDir.cd(path);
+               FileFinder finder;
+               finder.setBaseDir(path);
+               finder.setMaxSize(comboSize(ui->comboBoxMaxSize));
+               finder.setMinSize(comboSize(ui->comboBoxMinSize));
+               finder.setOlderThan(comboDate(ui->comboBoxOlder));
+               finder.setYoungerThan(comboDate(ui->comboBoxYounger));
+               finder.setMinDepth(comboInt(ui->comboBoxMinDepth, 0));
+               finder.setMaxDepth(comboInt(ui->comboBoxMaxDepth, -1));
+               finder.setFiletypes(buildFileTypes());
+               QStringList patterns;
+               QString value = comboText(ui->comboBoxFilePatterns);
+               if (!value.isEmpty())
+                       patterns = value.split(",");
+               finder.setPatterns(patterns);
+               value = comboText(ui->comboBoxExcludedDirs);
+               if (value.indexOf('/') >= 0 || value.indexOf('\\') >= 0)
+                       guiError(ui->comboBoxExcludedDirs, tr("no path delimiter allowed"));
+               else if (value.indexOf('*') >= 0)
+                       guiError(ui->comboBoxExcludedDirs,
+                               tr("no patterns allowed. Do not use '*"));
+               else if (!value.isEmpty())
+                       patterns = value.split(",");
+               finder.setExcludedDirs(patterns);
+               prepareTextFind();
+               if (m_errors == 0) {
+                       if (!comboText(ui->comboBoxTextPattern).isEmpty())
+                               finder.setTextFinder(&m_textFinder);
+                       m_statistics.clear();
+                       saveState();
+                       clock_t start = clock();
+                       finder.fillTable(path, 0, ui->tableWidget, m_statistics);
+                       m_statistics.m_runtimeSeconds = (double) (clock() - start)
+                       / CLOCKS_PER_SEC;
+                       QString msg;
+                       msg.sprintf(
+                               QObject::tr(
+                                       "Found: %d dir(s) and %d file(s) with %.6f MByte. Duration of the search: %.3f sec")
+                       .toUtf8(), m_statistics.m_dirs, m_statistics.m_files,
+                       m_statistics.m_bytes / 1000000.0, m_statistics.m_runtimeSeconds);
+                       setStatusMessage(false, msg);
+               }
+       }
+       QApplication::restoreOverrideCursor();
 }
 /**
  * Handles the push of the button "select directory".
  */
-void MainWindow::selectDirectory(){
-QString dir = QFileDialog::getExistingDirectory(this, tr("Select Directory"),
-   ui->comboBoxDirectory->currentText(), QFileDialog::ShowDirsOnly);
-if (!dir.isEmpty())
-   ui->comboBoxDirectory->setCurrentText(dir);
+void MainWindow::selectDirectory() {
+       QString dir = QFileDialog::getExistingDirectory(this, tr("Select Directory"),
+               ui->comboBoxDirectory->currentText(), QFileDialog::ShowDirsOnly);
+       if (!dir.isEmpty())
+               ui->comboBoxDirectory->setCurrentText(dir);
 }
 
 /**
  * Calls the file selection dialog.
  */
-void MainWindow::selectExportFile(){
-QString name = QFileDialog::getSaveFileName(this, tr("Select Export File"),
-   ui->comboBoxExportFile->currentText());
-if (!name.isEmpty())
-   ui->comboBoxExportFile->setCurrentText(name);
+void MainWindow::selectExportFile() {
+       QString name = QFileDialog::getSaveFileName(this, tr("Select Export File"),
+               ui->comboBoxExportFile->currentText());
+       if (!name.isEmpty())
+               ui->comboBoxExportFile->setCurrentText(name);
 
 }
 
@@ -844,27 +848,27 @@ if (!name.isEmpty())
  * @param error     <code>true</code>: the message is an error message
  * @param message   the text to set
  */
-void MainWindow::setStatusMessage(bool error, const QString& message){
-if (m_stdLabelBackgroundRole == NULL)
-   m_stdLabelBackgroundRole = new QPalette::ColorRole(
-      m_statusMessage->backgroundRole());
-m_statusMessage->setBackgroundRole(
-   error ? QPalette::HighlightedText : *m_stdLabelBackgroundRole);
-m_statusMessage->setText(message);
+void MainWindow::setStatusMessage(bool error, const QString& message) {
+       if (m_stdLabelBackgroundRole == NULL)
+               m_stdLabelBackgroundRole = new QPalette::ColorRole(
+                       m_statusMessage->backgroundRole());
+       m_statusMessage->setBackgroundRole(
+               error ? QPalette::HighlightedText : *m_stdLabelBackgroundRole);
+       m_statusMessage->setText(message);
 }
 
 /**
  * @brief Handles the "up" button: go to the parent directory.
  */
-void MainWindow::up(){
-QString path = ui->comboBoxDirectory->currentText();
-QDir dir(path);
-if (dir.exists()){
-   dir.cdUp();
-   if (dir.exists()){
-      path = dir.absolutePath();
-      ui->comboBoxDirectory->setEditText(path);
-      setInHistory(ui->comboBoxDirectory, path);
-   }
-}
+void MainWindow::up() {
+       QString path = ui->comboBoxDirectory->currentText();
+       QDir dir(path);
+       if (dir.exists()) {
+               dir.cdUp();
+               if (dir.exists()) {
+                       path = dir.absolutePath();
+                       ui->comboBoxDirectory->setEditText(path);
+                       setInHistory(ui->comboBoxDirectory, path);
+               }
+       }
 }