]> gitweb.hamatoma.de Git - reqt/commitdiff
Icons, toolbar, clipboard actions
authorhama <hama@siduction.net>
Mon, 20 Apr 2015 22:09:30 +0000 (00:09 +0200)
committerhama <hama@siduction.net>
Mon, 20 Apr 2015 22:09:30 +0000 (00:09 +0200)
15 files changed:
appl/refind/icons/action_go.gif [new file with mode: 0644]
appl/refind/icons/action_paste.gif [new file with mode: 0644]
appl/refind/icons/arrow_turn_left.png [new file with mode: 0644]
appl/refind/icons/bullet_go.png [new file with mode: 0644]
appl/refind/icons/door_in.png [new file with mode: 0644]
appl/refind/icons/layout_add.png [new file with mode: 0644]
appl/refind/icons/resultset_next.png [new file with mode: 0644]
appl/refind/icons/sitemap_color.png [new file with mode: 0644]
appl/refind/icons/table.gif [new file with mode: 0644]
appl/refind/icons/tables.gif [new file with mode: 0644]
appl/refind/mainwindow.cpp
appl/refind/mainwindow.hpp
appl/refind/mainwindow.ui
appl/refind/refind.pro
appl/refind/refind.qrc [new file with mode: 0644]

diff --git a/appl/refind/icons/action_go.gif b/appl/refind/icons/action_go.gif
new file mode 100644 (file)
index 0000000..82ae7ed
Binary files /dev/null and b/appl/refind/icons/action_go.gif differ
diff --git a/appl/refind/icons/action_paste.gif b/appl/refind/icons/action_paste.gif
new file mode 100644 (file)
index 0000000..bffd6b0
Binary files /dev/null and b/appl/refind/icons/action_paste.gif differ
diff --git a/appl/refind/icons/arrow_turn_left.png b/appl/refind/icons/arrow_turn_left.png
new file mode 100644 (file)
index 0000000..a3d6c9e
Binary files /dev/null and b/appl/refind/icons/arrow_turn_left.png differ
diff --git a/appl/refind/icons/bullet_go.png b/appl/refind/icons/bullet_go.png
new file mode 100644 (file)
index 0000000..bc4faa7
Binary files /dev/null and b/appl/refind/icons/bullet_go.png differ
diff --git a/appl/refind/icons/door_in.png b/appl/refind/icons/door_in.png
new file mode 100644 (file)
index 0000000..41676a0
Binary files /dev/null and b/appl/refind/icons/door_in.png differ
diff --git a/appl/refind/icons/layout_add.png b/appl/refind/icons/layout_add.png
new file mode 100644 (file)
index 0000000..6203722
Binary files /dev/null and b/appl/refind/icons/layout_add.png differ
diff --git a/appl/refind/icons/resultset_next.png b/appl/refind/icons/resultset_next.png
new file mode 100644 (file)
index 0000000..e252606
Binary files /dev/null and b/appl/refind/icons/resultset_next.png differ
diff --git a/appl/refind/icons/sitemap_color.png b/appl/refind/icons/sitemap_color.png
new file mode 100644 (file)
index 0000000..c64582b
Binary files /dev/null and b/appl/refind/icons/sitemap_color.png differ
diff --git a/appl/refind/icons/table.gif b/appl/refind/icons/table.gif
new file mode 100644 (file)
index 0000000..e5daec4
Binary files /dev/null and b/appl/refind/icons/table.gif differ
diff --git a/appl/refind/icons/tables.gif b/appl/refind/icons/tables.gif
new file mode 100644 (file)
index 0000000..87246be
Binary files /dev/null and b/appl/refind/icons/tables.gif differ
index fa5075af1117ea9cc9a0d40a66ba7b2bc2667d13..37b8ec65a6f68db1402112dbcb0a9c49a3e31f7d 100644 (file)
@@ -11,6 +11,8 @@
 
 #include <QDir>
 #include <QFileDialog>
+#include <QClipboard>
+#include <QLineEdit>
 #include "base/rebase.hpp"
 #include "textfinder.hpp"
 #include "mainwindow.hpp"
@@ -45,6 +47,9 @@ MainWindow::MainWindow(const QString& startDir, QWidget *parent) :
    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);
@@ -69,6 +74,69 @@ void MainWindow::about(){
    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.
  *
@@ -206,42 +274,50 @@ void MainWindow::prepareTextFind(){
 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);
+       }
    }
 }
 /**
index 48696015f3fb0a1315f2ce37897dc52fae8fdfeb..15ee7519d25497b37f81c58fdeab4ca08de80c01 100644 (file)
@@ -38,12 +38,17 @@ public:
 
 private slots:
    void about();
+   void absPathToClipboard();
+   void baseDirToClipboard();
+   void fullNameToClipboard();
    void search();
    void up();
    void selectDirectory();
 
 private:
+   QString buildAbsPath(int row);
    QDir::Filters buildFileTypes();
+   QString cellAsText(int row, int col);
    QDateTime comboDate(QComboBox* combo);
    int comboInt(QComboBox* combo, int defaultValue);
    int64_t comboSize(QComboBox* combo);
@@ -58,6 +63,8 @@ private:
    QPalette::ColorRole* m_stdLabelBackgroundRole;
    int m_errors;
    TextFinder m_textFinder;
+   // the directory of the last search
+   QDir m_lastBaseDir;
 };
 
 #endif // MAINWINDOW_HPP
index 0acc5a7986f615a0e7ceded1621c251723b1bf0d..e24827b8122db0d6096139fd2bd9cce0737c32e3 100644 (file)
               <property name="text">
                <string>&amp;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>&amp;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>&amp;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>&amp;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&amp;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>&amp;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>&amp;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>&amp;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 &amp;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 &amp;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 &amp;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>
index 1b3fe1a59483110b4c4cb1c5e35469f843f1d8b9..b139d1f551f566f7d5a4e4fed9abe801e7f8c244 100644 (file)
@@ -33,3 +33,6 @@ HEADERS  += mainwindow.hpp \
 
 FORMS    += mainwindow.ui \
     aboutdialog.ui
+
+RESOURCES += \
+    refind.qrc
diff --git a/appl/refind/refind.qrc b/appl/refind/refind.qrc
new file mode 100644 (file)
index 0000000..96c5aff
--- /dev/null
@@ -0,0 +1,14 @@
+<RCC>
+    <qresource prefix="/main">
+        <file>icons/bullet_go.png</file>
+        <file>icons/door_in.png</file>
+        <file>icons/layout_add.png</file>
+        <file>icons/resultset_next.png</file>
+        <file>icons/sitemap_color.png</file>
+        <file>icons/arrow_turn_left.png</file>
+        <file>icons/table.gif</file>
+        <file>icons/tables.gif</file>
+        <file>icons/action_go.gif</file>
+        <file>icons/action_paste.gif</file>
+    </qresource>
+</RCC>