-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ Contact KDAB at <[email protected]> for commercial licensing options. | |
#include <QHBoxLayout> | ||
#include <QHeaderView> | ||
#include <QLineEdit> | ||
#include <QPainter> | ||
#include <QToolButton> | ||
#include <QTreeWidget> | ||
#include <QTreeWidgetItem> | ||
|
@@ -24,10 +25,23 @@ namespace Gui { | |
|
||
enum { LineRole = Qt::UserRole + 1, ColumnRole }; | ||
|
||
class FindInFilesTreeWidget : public QTreeWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit FindInFilesTreeWidget(QWidget *parent = nullptr); | ||
|
||
protected: | ||
void paintEvent(QPaintEvent *) override; | ||
|
||
private: | ||
const bool m_findInFilesAvailable; | ||
}; | ||
|
||
FindInFilesPanel::FindInFilesPanel(QWidget *parent) | ||
: QWidget(parent) | ||
, m_toolBar(new QWidget(this)) | ||
, m_resultsDisplay(new QTreeWidget(this)) | ||
, m_resultsDisplay(new FindInFilesTreeWidget(this)) | ||
{ | ||
setWindowTitle(tr("Find in Files")); | ||
setObjectName("FindInFilesPanel"); | ||
|
@@ -45,6 +59,8 @@ FindInFilesPanel::FindInFilesPanel(QWidget *parent) | |
connect(m_resultsDisplay, &QTreeWidget::itemActivated, this, [this](QTreeWidgetItem *item, int) { | ||
openFileAtItem(item); | ||
}); | ||
const bool available = Core::Project::instance()->isFindInFilesAvailable(); | ||
m_searchInput->setEnabled(available); | ||
} | ||
|
||
QWidget *FindInFilesPanel::toolBar() const | ||
|
@@ -146,4 +162,28 @@ void FindInFilesPanel::openFileAtItem(QTreeWidgetItem *item) | |
} | ||
} | ||
|
||
FindInFilesTreeWidget::FindInFilesTreeWidget(QWidget *parent) | ||
: QTreeWidget(parent) | ||
, m_findInFilesAvailable(Core::Project::instance()->isFindInFilesAvailable()) | ||
{ | ||
} | ||
|
||
void FindInFilesTreeWidget::paintEvent(QPaintEvent *event) | ||
{ | ||
if (!m_findInFilesAvailable) { | ||
QPainter p(viewport()); | ||
|
||
QFont font = p.font(); | ||
font.setItalic(true); | ||
p.setFont(font); | ||
|
||
p.drawText(QRect(0, 0, width(), height()), Qt::AlignCenter, | ||
tr("Ripgrep (rg) executable not found.\nPlease ensure that ripgrep is installed and its location is " | ||
"included in the PATH environment variable.")); | ||
} else { | ||
QTreeWidget::paintEvent(event); | ||
} | ||
} | ||
|
||
} // namespace Gui | ||
#include "findinfilespanel.moc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,9 @@ Contact KDAB at <[email protected]> for commercial licensing options. | |
|
||
class QLineEdit; | ||
class QToolButton; | ||
class QTreeWidget; | ||
class QTreeWidgetItem; | ||
|
||
#include <QWidget> | ||
#include <QTreeWidget> | ||
|
||
namespace Gui { | ||
|
||
|
@@ -35,7 +34,7 @@ class FindInFilesPanel : public QWidget | |
void setupToolBar(); | ||
|
||
QWidget *const m_toolBar; | ||
QTreeWidget *m_resultsDisplay; | ||
QTreeWidget *m_resultsDisplay = nullptr; | ||
QLineEdit *m_searchInput; | ||
}; | ||
|
||
|