Page MenuHomePhabricator

No OneTemporary

Size
32 KB
Referenced Files
None
Subscribers
None
diff --git a/trunk/fred.pro b/trunk/fred.pro
index a7f2a44..7b49b11 100644
--- a/trunk/fred.pro
+++ b/trunk/fred.pro
@@ -1,115 +1,119 @@
#*******************************************************************************
# fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
# *
# Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
# with special feautures useful during forensic analysis. *
# *
# This program is free software: you can redistribute it and/or modify it *
# under the terms of the GNU General Public License as published by the Free *
# Software Foundation, either version 3 of the License, or (at your option) *
# any later version. *
# *
# This program is distributed in the hope that it will be useful, but WITHOUT *
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
# more details. *
# *
# You should have received a copy of the GNU General Public License along with *
# this program. If not, see <http://www.gnu.org/licenses/>. *
#******************************************************************************/
# Generate compileinfo.h
system(bash compileinfo.sh > compileinfo.h)
#compileinfo.target = compileinfo.h
#compileinfo.commands = $$PWD/compileinfo.sh > compileinfo.h
#QMAKE_EXTRA_TARGETS += compileinfo
#PRE_TARGETDEPS += compileinfo.h
# Build fred
QMAKE_CXXFLAGS += -Wall
QT += core \
gui \
script \
webkit
CONFIG += console
TARGET = fred
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
registrynode.cpp \
registrynodetreemodel.cpp \
registrykey.cpp \
registrykeytablemodel.cpp \
dlgabout.cpp \
dlgkeydetails.cpp \
qhexedit/qhexedit_p.cpp \
qhexedit/qhexedit.cpp \
reporttemplate.cpp \
datareporter.cpp \
datareporterengine.cpp \
registryhive.cpp \
qtscript_types/bytearray.cpp \
qtscript_types/bytearrayprototype.cpp \
qtscript_types/bytearrayiterator.cpp \
dlgreportviewer.cpp \
registrykeytable.cpp \
registrynodetree.cpp \
dlgsearch.cpp \
threadsearch.cpp \
searchresultwidget.cpp \
tabwidget.cpp \
argparser.cpp \
datainterpretertable.cpp \
datainterpreterwidget.cpp \
hexeditwidget.cpp \
- settings.cpp
+ settings.cpp \
+ searchresulttabledelegate.cpp \
+ registrynodetreemodelproxy.cpp
HEADERS += mainwindow.h \
registrynode.h \
registrynodetreemodel.h \
registrykey.h \
registrykeytablemodel.h \
dlgabout.h \
dlgkeydetails.h \
qhexedit/qhexedit_p.h \
qhexedit/qhexedit.h \
reporttemplate.h \
datareporter.h \
datareporterengine.h \
registryhive.h \
qtscript_types/bytearray.h \
qtscript_types/bytearrayprototype.h \
qtscript_types/bytearrayiterator.h \
dlgreportviewer.h \
registrykeytable.h \
registrynodetree.h \
dlgsearch.h \
threadsearch.h \
searchresultwidget.h \
tabwidget.h \
argparser.h \
datainterpretertable.h \
datainterpreterwidget.h \
hexeditwidget.h \
- settings.h
+ settings.h \
+ searchresulttabledelegate.h \
+ registrynodetreemodelproxy.h
FORMS += mainwindow.ui \
dlgabout.ui \
dlgkeydetails.ui \
dlgreportviewer.ui \
dlgsearch.ui
#LIBS += -lhivex
LIBS += $$PWD/hivex/lib/.libs/libhivex.a
#DEFINES += __STDC_FORMAT_MACROS
RESOURCES += fred.qrc
RC_FILE = fred.rc
ICON = resources/fred.icns
diff --git a/trunk/registrynodetree.cpp b/trunk/registrynodetree.cpp
index f3d64fe..2eb63a1 100644
--- a/trunk/registrynodetree.cpp
+++ b/trunk/registrynodetree.cpp
@@ -1,130 +1,144 @@
/*******************************************************************************
* fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
* *
* Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
* with special feautures useful during forensic analysis. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation, either version 3 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
#include "registrynodetree.h"
#include "registrynodetreemodel.h"
#include <QHeaderView>
#include <QApplication>
#include <QClipboard>
RegistryNodeTree::RegistryNodeTree(QWidget *p_parent) : QTreeView(p_parent) {
// Configure widget
this->setTextElideMode(Qt::ElideNone);
+// this->sortByColumn(0,Qt::AscendingOrder);
+// this->setSortingEnabled(true);
+
+ // Create proxy model
+ this->p_model_proxy=new RegistryNodeTreeModelProxy(this);
// Create context menu
this->p_menu_copy=new QMenu(tr("Copy"),this);
this->p_action_copy_node_name=new QAction(tr("Node name"),
this->p_menu_copy);
this->p_menu_copy->addAction(this->p_action_copy_node_name);
this->connect(this->p_action_copy_node_name,
SIGNAL(triggered()),
this,
SLOT(SlotCopyNodeName()));
this->p_action_copy_node_path=new QAction(tr("Node path"),
this->p_menu_copy);
this->p_menu_copy->addAction(this->p_action_copy_node_path);
this->connect(this->p_action_copy_node_path,
SIGNAL(triggered()),
this,
SLOT(SlotCopyNodePath()));
}
RegistryNodeTree::~RegistryNodeTree() {
+ // Delete our proxy model
+ delete this->p_model_proxy;
// Delete context menu
delete this->p_action_copy_node_name;
delete this->p_action_copy_node_path;
delete this->p_menu_copy;
}
void RegistryNodeTree::setModel(QAbstractItemModel *p_model) {
- QTreeView::setModel(p_model);
+ if(p_model!=NULL) {
+ // Assign model to our proxy model
+ this->p_model_proxy->setSourceModel(p_model);
+ // Then assign proxy as our own model
+ QTreeView::setModel(p_model);
+ } else {
+ QTreeView::setModel(p_model);
+ }
this->header()->setResizeMode(0,QHeaderView::ResizeToContents);
this->header()->setStretchLastSection(false);
if(p_model!=NULL && p_model->index(0,0).isValid()) {
// Select first tree item
this->setCurrentIndex(p_model->index(0,0));
}
}
//int RegistryNodeTree::sizeHintForColumn(int column) const {}
void RegistryNodeTree::contextMenuEvent(QContextMenuEvent *p_event) {
// Only show context menu when a node is selected
if(this->selectedIndexes().count()!=1) return;
// Only show context menu when user clicked on selected row
if(this->indexAt(p_event->pos())!=this->selectedIndexes().at(0)) return;
// Emit a click signal
emit(this->clicked(this->indexAt(p_event->pos())));
// Create context menu and add actions
QMenu context_menu(this);
context_menu.addMenu(this->p_menu_copy);
context_menu.exec(p_event->globalPos());
}
void RegistryNodeTree::keyPressEvent(QKeyEvent *p_event) {
// Only react if a node is selected and user pressed Key_Left
if(this->selectedIndexes().count()==1 &&
p_event->key()==Qt::Key_Left)
{
QModelIndex cur_index=this->selectedIndexes().at(0);
if(this->model()->hasChildren(cur_index) && this->isExpanded(cur_index)) {
// Current node is expanded. Only collapse this one
this->collapse(cur_index);
return;
}
if(!cur_index.parent().isValid()) {
// Do no try to collapse anything above root node
return;
}
this->collapse(cur_index.parent());
this->setCurrentIndex(cur_index.parent());
return;
}
// If we didn't handle the key event, let our parent handle it
QTreeView::keyPressEvent(p_event);
}
void RegistryNodeTree::currentChanged(const QModelIndex &current,
const QModelIndex &previous)
{
// Call parent class's currentChanged first
QTreeView::currentChanged(current,previous);
// Now emit our signal
QModelIndex current_item=QModelIndex(current);
emit(RegistryNodeTree::CurrentItemChanged(current_item));
}
void RegistryNodeTree::SlotCopyNodeName() {
QApplication::clipboard()->
setText(this->selectedIndexes().at(0).data().toString(),
QClipboard::Clipboard);
}
void RegistryNodeTree::SlotCopyNodePath() {
QString path=((RegistryNodeTreeModel*)(this->model()))->
GetNodePath(this->selectedIndexes().at(0));
QApplication::clipboard()->setText(path,QClipboard::Clipboard);
}
diff --git a/trunk/registrynodetree.h b/trunk/registrynodetree.h
index 216f016..7e3c96d 100644
--- a/trunk/registrynodetree.h
+++ b/trunk/registrynodetree.h
@@ -1,59 +1,62 @@
/*******************************************************************************
* fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
* *
* Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
* with special feautures useful during forensic analysis. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation, either version 3 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
#ifndef REGISTRYNODETREE_H
#define REGISTRYNODETREE_H
#include <QTreeView>
#include <QAbstractItemModel>
#include <QContextMenuEvent>
#include <QMenu>
#include <QAction>
+#include "registrynodetreemodelproxy.h"
+
class RegistryNodeTree : public QTreeView {
Q_OBJECT
public:
RegistryNodeTree(QWidget *p_parent=0);
~RegistryNodeTree();
void setModel(QAbstractItemModel *p_model);
Q_SIGNALS:
void CurrentItemChanged(QModelIndex current);
protected:
// int sizeHintForColumn(int column) const;
void contextMenuEvent(QContextMenuEvent *p_event);
void keyPressEvent(QKeyEvent *p_event);
private:
+ RegistryNodeTreeModelProxy *p_model_proxy;
QMenu *p_menu_copy;
QAction *p_action_copy_node_name;
QAction *p_action_copy_node_path;
void currentChanged(const QModelIndex &current,
const QModelIndex &previous);
private slots:
void SlotCopyNodeName();
void SlotCopyNodePath();
};
#endif // REGISTRYNODETREE_H
diff --git a/trunk/searchresultwidget.h b/trunk/registrynodetreemodelproxy.cpp
similarity index 65%
copy from trunk/searchresultwidget.h
copy to trunk/registrynodetreemodelproxy.cpp
index d7040ca..065ae3f 100644
--- a/trunk/searchresultwidget.h
+++ b/trunk/registrynodetreemodelproxy.cpp
@@ -1,45 +1,42 @@
/*******************************************************************************
* fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
* *
* Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
* with special feautures useful during forensic analysis. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation, either version 3 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
-#ifndef SEARCHRESULTWIDGET_H
-#define SEARCHRESULTWIDGET_H
-
-#include <QTableWidget>
-
-#include "threadsearch.h"
-
-class SearchResultWidget : public QTableWidget {
- Q_OBJECT
-
- public:
- SearchResultWidget(QWidget *p_parent=0);
-
- public slots:
- void SlotFoundMatch(ThreadSearch::eMatchType match_type,
- QString path,
- QString key,
- QString value);
- void SlotSearchFinished();
-
- protected:
- int sizeHintForColumn(int column) const;
-};
-
-#endif // SEARCHRESULTWIDGET_H
+#include "registrynodetreemodelproxy.h"
+
+RegistryNodeTreeModelProxy::RegistryNodeTreeModelProxy(QObject *p_parent) :
+ QSortFilterProxyModel(p_parent)
+{
+}
+
+bool RegistryNodeTreeModelProxy::lessThan(const QModelIndex &left,
+ const QModelIndex &right) const
+{
+ QVariant leftData=this->sourceModel()->data(left);
+ QVariant rightData=this->sourceModel()->data(right);
+
+ if(leftData.type()==QVariant::String && rightData.type()==QVariant::String) {
+ // Sort strings case insensitive
+// return QString::localeAwareCompare(leftData.toString().toLower(),
+// rightData.toString().toLower());
+ return QSortFilterProxyModel::lessThan(left,right);
+ } else {
+ return QSortFilterProxyModel::lessThan(left,right);
+ }
+}
diff --git a/trunk/searchresultwidget.h b/trunk/registrynodetreemodelproxy.h
similarity index 71%
copy from trunk/searchresultwidget.h
copy to trunk/registrynodetreemodelproxy.h
index d7040ca..f5aaf73 100644
--- a/trunk/searchresultwidget.h
+++ b/trunk/registrynodetreemodelproxy.h
@@ -1,45 +1,36 @@
/*******************************************************************************
-* fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
+* fred Copyright (c) 2011 by Gillen Daniel <gillen.dan@pinguin.lu> *
* *
* Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
* with special feautures useful during forensic analysis. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation, either version 3 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
-#ifndef SEARCHRESULTWIDGET_H
-#define SEARCHRESULTWIDGET_H
+#ifndef REGISTRYNODETREEMODELPROXY_H
+#define REGISTRYNODETREEMODELPROXY_H
-#include <QTableWidget>
+#include <QSortFilterProxyModel>
-#include "threadsearch.h"
-
-class SearchResultWidget : public QTableWidget {
+class RegistryNodeTreeModelProxy : public QSortFilterProxyModel {
Q_OBJECT
public:
- SearchResultWidget(QWidget *p_parent=0);
-
- public slots:
- void SlotFoundMatch(ThreadSearch::eMatchType match_type,
- QString path,
- QString key,
- QString value);
- void SlotSearchFinished();
+ explicit RegistryNodeTreeModelProxy(QObject *p_parent=0);
protected:
- int sizeHintForColumn(int column) const;
+ bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
};
-#endif // SEARCHRESULTWIDGET_H
+#endif // REGISTRYNODETREEMODELPROXY_H
diff --git a/trunk/searchresultwidget.h b/trunk/searchresulttabledelegate.cpp
similarity index 73%
copy from trunk/searchresultwidget.h
copy to trunk/searchresulttabledelegate.cpp
index d7040ca..77fd779 100644
--- a/trunk/searchresultwidget.h
+++ b/trunk/searchresulttabledelegate.cpp
@@ -1,45 +1,38 @@
/*******************************************************************************
* fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
* *
* Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
* with special feautures useful during forensic analysis. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation, either version 3 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
-#ifndef SEARCHRESULTWIDGET_H
-#define SEARCHRESULTWIDGET_H
-
-#include <QTableWidget>
-
-#include "threadsearch.h"
-
-class SearchResultWidget : public QTableWidget {
- Q_OBJECT
-
- public:
- SearchResultWidget(QWidget *p_parent=0);
-
- public slots:
- void SlotFoundMatch(ThreadSearch::eMatchType match_type,
- QString path,
- QString key,
- QString value);
- void SlotSearchFinished();
-
- protected:
- int sizeHintForColumn(int column) const;
-};
-
-#endif // SEARCHRESULTWIDGET_H
+#include "searchresulttabledelegate.h"
+
+SearchResultTableDelegate::SearchResultTableDelegate(QObject *parent) :
+ QStyledItemDelegate(parent)
+{
+}
+
+void SearchResultTableDelegate::paint(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+{
+ if(index.isValid() && index.column()==2) {
+ // TODO: Render match string different
+ QStyledItemDelegate::paint(painter,option,index);
+ } else {
+ QStyledItemDelegate::paint(painter,option,index);
+ }
+}
diff --git a/trunk/searchresultwidget.h b/trunk/searchresulttabledelegate.h
similarity index 71%
copy from trunk/searchresultwidget.h
copy to trunk/searchresulttabledelegate.h
index d7040ca..d1f4f2f 100644
--- a/trunk/searchresultwidget.h
+++ b/trunk/searchresulttabledelegate.h
@@ -1,45 +1,36 @@
/*******************************************************************************
-* fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
+* fred Copyright (c) 2011 by Gillen Daniel <gillen.dan@pinguin.lu> *
* *
* Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
* with special feautures useful during forensic analysis. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation, either version 3 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
-#ifndef SEARCHRESULTWIDGET_H
-#define SEARCHRESULTWIDGET_H
+#ifndef SEARCHRESULTTABLEDELEGATE_H
+#define SEARCHRESULTTABLEDELEGATE_H
-#include <QTableWidget>
+#include <QStyledItemDelegate>
-#include "threadsearch.h"
-
-class SearchResultWidget : public QTableWidget {
+class SearchResultTableDelegate : public QStyledItemDelegate {
Q_OBJECT
public:
- SearchResultWidget(QWidget *p_parent=0);
-
- public slots:
- void SlotFoundMatch(ThreadSearch::eMatchType match_type,
- QString path,
- QString key,
- QString value);
- void SlotSearchFinished();
-
- protected:
- int sizeHintForColumn(int column) const;
+ explicit SearchResultTableDelegate(QObject *parent = 0);
+ void paint(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
};
-#endif // SEARCHRESULTWIDGET_H
+#endif // SEARCHRESULTTABLEDELEGATE_H
diff --git a/trunk/searchresultwidget.cpp b/trunk/searchresultwidget.cpp
index 13854e5..45ddbcc 100644
--- a/trunk/searchresultwidget.cpp
+++ b/trunk/searchresultwidget.cpp
@@ -1,126 +1,133 @@
/*******************************************************************************
* fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
* *
* Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
* with special feautures useful during forensic analysis. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation, either version 3 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
#include "searchresultwidget.h"
#include <QHeaderView>
#include <QAbstractItemView>
#include <QStringList>
#include <QTableWidgetItem>
#include <QFontMetrics>
//#include <QTextEdit>
SearchResultWidget::SearchResultWidget(QWidget *p_parent)
: QTableWidget(p_parent)
{
+ // Create our delegate instance
+ this->p_delegate=new SearchResultTableDelegate();
+ this->setItemDelegate(this->p_delegate);
this->setColumnCount(3);
this->setRowCount(0);
this->setTextElideMode(Qt::ElideNone);
this->verticalHeader()->setHidden(true);
this->setSelectionBehavior(QAbstractItemView::SelectRows);
this->setSelectionMode(QAbstractItemView::SingleSelection);
this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
this->setHorizontalHeaderLabels(QStringList()<<tr("Path")
<<tr("Match type")
<<tr("Match text"));
}
+SearchResultWidget::~SearchResultWidget() {
+ delete this->p_delegate;
+}
+
void SearchResultWidget::SlotFoundMatch(ThreadSearch::eMatchType match_type,
QString path,
QString key,
QString value)
{
QTableWidgetItem *p_item;
// QTextEdit* p_te;
QString full_path;
QString type;
QString match;
switch(match_type) {
case ThreadSearch::eMatchType_NodeName:
type=tr("Node name");
full_path=path;
match=key;
break;
case ThreadSearch::eMatchType_KeyName:
type=tr("Key name");
full_path=path;
match=key;
break;
case ThreadSearch::eMatchType_KeyValue:
type=tr("Key value");
full_path=path+"\\"+key;
//if(value.length()<6934) match=value;
//else
//match=value.left(5610);
//match=QString(value);
match=value;
break;
}
int rows=this->rowCount();
this->setRowCount(rows+1);
// TODO: Use setCellWidget to add QTextEdit and then use insertText and
// insertHtml to format match
p_item=new QTableWidgetItem(full_path=="" ? "\\" : full_path);
p_item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
this->setItem(rows,0,p_item);
p_item=new QTableWidgetItem(type);
p_item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
this->setItem(rows,1,p_item);
p_item=new QTableWidgetItem(match);
p_item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
this->setItem(rows,2,p_item);
// p_te=new QTextEdit(match);
// p_te->setReadOnly(true);
// this->setCellWidget(rows,2,p_te);
}
int SearchResultWidget::sizeHintForColumn(int column) const {
int size_hint=0;
int i=0;
int item_width=0;
QFontMetrics fm(this->fontMetrics());
// if(column<0 || column>=this->columnCount()) return -1;
// Find string that needs the most amount of space
for(i=0;i<this->rowCount();i++) {
// if(column!=2) {
item_width=fm.width(this->item(i,column)->text())+10;
//item_width=this->item(i,column)->sizeHint().width();
// } else {
// // Column 2 has special cell widgets
// item_width=fm.width(((QTextEdit*)(this->cellWidget(i,column)))->toPlainText())+10;
// }
if(item_width>size_hint) size_hint=item_width;
}
// Qt seems to be very unhappy with size hints bigger then 30000.
- if(size_hint>30000) size_hint=30000;
+// if(size_hint>30000) size_hint=30000;
return size_hint;
}
void SearchResultWidget::SlotSearchFinished() {
this->resizeColumnsToContents();
this->resizeRowsToContents();
}
diff --git a/trunk/searchresultwidget.h b/trunk/searchresultwidget.h
index d7040ca..b53446b 100644
--- a/trunk/searchresultwidget.h
+++ b/trunk/searchresultwidget.h
@@ -1,45 +1,48 @@
/*******************************************************************************
* fred Copyright (c) 2011-2013 by Gillen Daniel <gillen.dan@pinguin.lu> *
* *
* Forensic Registry EDitor (fred) is a cross-platform M$ registry hive editor *
* with special feautures useful during forensic analysis. *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation, either version 3 of the License, or (at your option) *
* any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
* more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************/
#ifndef SEARCHRESULTWIDGET_H
#define SEARCHRESULTWIDGET_H
#include <QTableWidget>
#include "threadsearch.h"
+#include "searchresulttabledelegate.h"
class SearchResultWidget : public QTableWidget {
Q_OBJECT
public:
SearchResultWidget(QWidget *p_parent=0);
+ ~SearchResultWidget();
public slots:
void SlotFoundMatch(ThreadSearch::eMatchType match_type,
QString path,
QString key,
QString value);
void SlotSearchFinished();
protected:
int sizeHintForColumn(int column) const;
+ SearchResultTableDelegate *p_delegate;
};
#endif // SEARCHRESULTWIDGET_H

File Metadata

Mime Type
text/x-diff
Expires
Wed, Dec 25, 4:07 AM (1 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1176867
Default Alt Text
(32 KB)

Event Timeline