#include <QDir>
#include <QFileDialog>
+#include <QClipboard>
+#include <QLineEdit>
#include "base/rebase.hpp"
#include "textfinder.hpp"
#include "mainwindow.hpp"
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()));
ui->tableWidget->setColumnWidth(TC_NODE, 200);
ui->tableWidget->setColumnWidth(TC_EXT, 40);
ui->tableWidget->setColumnWidth(TC_SIZE, 125);
dialog.show();
}
+/**
+ * Gets the absolute path of the file in the given row.
+ *
+ * @param row the row number
+ * @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;
+}
+
+/**
+ * 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));
+ }
+}
+
+/**
+ * Puts the base directory into the clipboard.
+ */
+void MainWindow::baseDirToClipboard()
+{
+ QClipboard *clipboard = QApplication::clipboard();
+ clipboard->setText(m_lastBaseDir.absolutePath());
+}
+
+/**
+ * Gets the content of the given cell as string.
+ *
+ * @param row the row number: 0..R-1
+ * @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;
+}
+
+/**
+ * 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);
+ }
+}
+
/**
* Returns the date given as formula in a combobox.
*
void MainWindow::search(){
m_errors = 0;
QString path = ui->comboBoxDirectory->currentText();
- 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);
+ 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);
+ }
}
}
/**
<property name="text">
<string>&Search</string>
</property>
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/action_go.gif</normaloff>:/main/icons/action_go.gif</iconset>
+ </property>
<property name="shortcut">
<string>Ctrl+F</string>
</property>
<string>Change to the parent directory</string>
</property>
<property name="text">
- <string>⇑</string>
+ <string>&Up</string>
+ </property>
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/arrow_turn_left.png</normaloff>:/main/icons/arrow_turn_left.png</iconset>
</property>
</widget>
</item>
<property name="text">
<string>...</string>
</property>
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/sitemap_color.png</normaloff>:/main/icons/sitemap_color.png</iconset>
+ </property>
</widget>
</item>
</layout>
<property name="text">
<string>&Search</string>
</property>
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/action_go.gif</normaloff>:/main/icons/action_go.gif</iconset>
+ </property>
</widget>
</item>
</layout>
<addaction name="actionUp"/>
<addaction name="actionSelectDirectory"/>
</widget>
+ <widget class="QMenu" name="menu_Edit">
+ <property name="title">
+ <string>&Edit</string>
+ </property>
+ <addaction name="actionGetAbsPath"/>
+ <addaction name="actionGetFullName"/>
+ <addaction name="actionGetBaseDirectory"/>
+ <addaction name="separator"/>
+ </widget>
<addaction name="menuFile"/>
+ <addaction name="menu_Edit"/>
<addaction name="menuNavigation"/>
<addaction name="menuHelp"/>
</widget>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
+ <addaction name="actionSearch"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
+ <widget class="QToolBar" name="toolBar">
+ <property name="windowTitle">
+ <string>toolBar</string>
+ </property>
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ <addaction name="actionUp"/>
+ <addaction name="actionSelectDirectory"/>
+ <addaction name="separator"/>
+ <addaction name="actionGetAbsPath"/>
+ <addaction name="actionGetFullName"/>
+ <addaction name="actionGetBaseDirectory"/>
+ <addaction name="separator"/>
+ <addaction name="actionExit"/>
+ </widget>
<action name="actionExit">
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/door_in.png</normaloff>:/main/icons/door_in.png</iconset>
+ </property>
<property name="text">
<string>E&xit</string>
</property>
</property>
</action>
<action name="actionSearch">
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/action_go.gif</normaloff>:/main/icons/action_go.gif</iconset>
+ </property>
<property name="text">
<string>&Search</string>
</property>
</property>
</action>
<action name="actionUp">
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/arrow_turn_left.png</normaloff>:/main/icons/arrow_turn_left.png</iconset>
+ </property>
<property name="text">
<string>&Up</string>
</property>
</property>
</action>
<action name="actionSelectDirectory">
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/sitemap_color.png</normaloff>:/main/icons/sitemap_color.png</iconset>
+ </property>
<property name="text">
<string>&Select directory</string>
</property>
<string>Ctrl+D</string>
</property>
</action>
+ <action name="actionGetAbsPath">
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/tables.gif</normaloff>:/main/icons/tables.gif</iconset>
+ </property>
+ <property name="text">
+ <string>Get absolute &path</string>
+ </property>
+ <property name="toolTip">
+ <string>Puts the absolute path of the selected file into the clipboard</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+P</string>
+ </property>
+ </action>
+ <action name="actionGetFullName">
+ <property name="icon">
+ <iconset>
+ <normaloff>icons/table.gif</normaloff>
+ <normalon>:/main/icons/table.gif</normalon>icons/table.gif</iconset>
+ </property>
+ <property name="text">
+ <string>Get &full name</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+N</string>
+ </property>
+ </action>
+ <action name="actionGetBaseDirectory">
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/action_paste.gif</normaloff>:/main/icons/action_paste.gif</iconset>
+ </property>
+ <property name="text">
+ <string>Get &base directory</string>
+ </property>
+ <property name="toolTip">
+ <string>Puts the base directory into the clipboard</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+B</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>comboBoxMaxDepth</tabstop>
<tabstop>comboBoxExcludedDirs</tabstop>
</tabstops>
- <resources/>
+ <resources>
+ <include location="refind.qrc"/>
+ </resources>
<connections>
<connection>
<sender>actionExit</sender>