m_statusMessage(NULL),
m_stdLabelBackgroundRole(NULL),
m_errors(0),
- m_textFinder(){
+ m_textFinder(),
+ m_lastBaseDir(),
+ m_horizontalHeader(NULL),
+ m_lastOrder(Qt::DescendingOrder){
ui->setupUi(this);
m_statusMessage = new QLabel(tr("Willkommen bei refind"));
ui->comboBoxDirectory->setCurrentText(
connect(ui->pushButtonDirectory, SIGNAL(clicked()), this,
SLOT(selectDirectory()));
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
- connect(ui->actionGetAbsPath, SIGNAL(triggered()), this, SLOT(absPathToClipboard()));
- connect(ui->actionGetFullName, SIGNAL(triggered()), this, SLOT(fullNameToClipboard()));
- connect(ui->actionGetBaseDirectory, SIGNAL(triggered()), this, SLOT(baseDirToClipboard()));
+ connect(ui->actionGetAbsPath, SIGNAL(triggered()), this,
+ SLOT(absPathToClipboard()));
+ connect(ui->actionGetFullName, SIGNAL(triggered()), this,
+ SLOT(fullNameToClipboard()));
+ connect(ui->actionGetBaseDirectory, SIGNAL(triggered()), this,
+ SLOT(baseDirToClipboard()));
+ connect(ui->tableWidget, SIGNAL(cellClicked(int,int)), this, SLOT(cellEntered(int, int)));
+ 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->horizontalHeader()->setStretchLastSection(true);
}
+/**
+ * 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);
+}
+
/**
* @brief Destructor.
*/
* @return the absolute path of the file given by the row
*/
QString MainWindow::buildAbsPath(int row){
- QString rc(m_lastBaseDir.absolutePath());
- QString value = cellAsText(row, TC_PATH);
- if (! value.isEmpty())
- rc += "/" + value + "/";
- return rc;
+ QString rc(m_lastBaseDir.absolutePath());
+ QString value = cellAsText(row, TC_PATH);
+ if (!value.isEmpty())
+ rc += "/" + value + "/";
+ return rc;
}
/**
* 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));
- }
+ 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());
}
/**
* @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;
+ QTableWidgetItem* widget = ui->tableWidget->item(row, col);
+ QString rc;
+ if (widget != NULL)
+ rc = widget->text();
+ return rc;
}
/**
* 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);
+ }
}
/**
m_errors = 0;
QString path = ui->comboBoxDirectory->currentText();
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 = ui->comboBoxFilePatterns->currentText();
- if (!value.isEmpty())
- patterns = value.split(",");
- finder.setPatterns(patterns);
- value = ui->comboBoxExcludedDirs->currentText();
- 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 (!ui->comboBoxTextPattern->currentText().isEmpty())
- finder.setTextFinder(&m_textFinder);
- clock_t start = clock();
- finder.fillTable(path, 0, ui->tableWidget);
- QString msg;
- msg.sprintf(
- QObject::tr(
- "Found: %d dir(s) and %d file(s) with %.6f MByte. Duration of the search: %.3f sec").toUtf8(),
- finder.countDirs(), finder.countFiles(), finder.bytes() / 1000000.0,
- (double) (clock() - start) / CLOCKS_PER_SEC);
- setStatusMessage(false, msg);
- }
+ 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 = ui->comboBoxFilePatterns->currentText();
+ if (!value.isEmpty())
+ patterns = value.split(",");
+ finder.setPatterns(patterns);
+ value = ui->comboBoxExcludedDirs->currentText();
+ 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 (!ui->comboBoxTextPattern->currentText().isEmpty())
+ finder.setTextFinder(&m_textFinder);
+ clock_t start = clock();
+ finder.fillTable(path, 0, ui->tableWidget);
+ QString msg;
+ msg.sprintf(
+ QObject::tr(
+ "Found: %d dir(s) and %d file(s) with %.6f MByte. Duration of the search: %.3f sec").toUtf8(),
+ finder.countDirs(), finder.countFiles(), finder.bytes() / 1000000.0,
+ (double) (clock() - start) / CLOCKS_PER_SEC);
+ setStatusMessage(false, msg);
+ }
}
}
/**