}
return rc;
}
+static bool intLessThan(const int& v1, const int& v2)
+ {
+ return v1 < v2;
+ }
+/**
+ * General event handler.
+ *
+ * @param obj the receiver object
+ * @param event the event
+ * @return <i>true</i>: event is handled.<br>
+ * <i>false</i>: the event should be handled by another hander
+ */
+bool MainWindow::eventFilter(QObject *obj, QEvent *event)
+{
+ bool rc = false;
+ if (event->type() == QEvent::KeyPress && obj == ui->tableWidget){
+ // QWidget *widget = (QWidget*) obj;
+ // QString name = widget->objectName();
+ QKeyEvent* key = static_cast<QKeyEvent*>(event);
+ if ( (key->key()==Qt::Key_Delete)){
+ QList<QTableWidgetSelectionRange> ranges = ui->tableWidget->selectedRanges();
+ QList<int> rows;
+ for (int ix = 0; ix < ranges.size(); ++ix){
+ QTableWidgetSelectionRange range = ranges[ix];
+ for (int row = range.bottomRow(); row >= range.topRow(); row--){
+ rows.append(row);
+ }
+ }
+ if (rows.size() > 0){
+ qSort(rows.begin(), rows.end(), intLessThan);
+ for (int row = rows.size() - 1; row >= 0; --row){
+ ui->tableWidget->removeRow(row);
+ }
+ say(LOG_INFO, tr("%1 file(s) detached").arg(rows.size()));
+ logFiles();
+ ui->tableWidget->clearSelection();
+ }
+ rc = true;
+ } else {
+ rc = QObject::eventFilter(obj, event);
+ }
+ }
+ return rc;
+}
/**
* Initializes the Graphical User Interface.
this, SLOT(onCellEntered(int, int)));
connect(ui->listWidgetHits, SIGNAL(itemClicked(QListWidgetItem*)),
this, SLOT(onHitLineClicked(QListWidgetItem*)));
-
+ ui->tableWidget->installEventFilter(this);
connect(m_timer, SIGNAL(timeout()), this, SLOT(onTimerTask()));
}
}
+/**
+ * Logs the current number of files.
+ */
+void MainWindow::logFiles(){
+ ui->labelFileCount->setText(QString::number(ui->tableWidget->rowCount())
+ + " " + tr("file(s)"));
+}
+
/**
* Writes the known number of hits into the label.
*/
atoi(ui->lineEditMinDepth->text().toLocal8Bit().data()),
atoi(ui->lineEditMaxDepth->text().toLocal8Bit().data()));
int files = ui->tableWidget->rowCount();
- ui->labelFileCount->setText(QString::number(files)
- + " " + tr("file(s)"));
+ logFiles();
say(LOG_INFO, tr("files: %1 already found: %2 processed directories: %3")
.arg(m_fileFinder->foundFiles())
.arg(m_fileFinder->ignoredFiles())
/**
* Converts a number into a name containing only characters 'A' - 'Z' and '_'.
*
- * Negative numbers are marked with '_' at the end.
+ * Negative numbers are marked with first member of <i>charSet</i>.
*
* @param number the number to convert
+ * @param charSet the characters used for the name. The first character is
+ * used to mark negative numbers.
+ * If <i>NULL</i> a standard characater (A-Z0-9) set is used
* @return the name which is unique to the number
*/
-QString ReQStringUtils::numberToName(int number){
+QString ReQStringUtils::numberToName(int number, const char* charSet, int charSetSize){
QString rc;
+ if (charSet == NULL){
+ charSet = "-$ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ charSetSize = 37+1; // strlen(charSet)
+ }
if (number < 0){
number = -number;
- rc = '_';
+ rc = charSet[0];
}
+ ++charSet;
+ --charSetSize;
do {
- QChar cc('A' + number % 26);
- number /= 26;
+ QChar cc(charSet[number % charSetSize]);
+ number /= charSetSize;
rc.insert(0, cc);
} while(number > 0);
return rc;