Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flatpak-qt-creator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
331effc2
Commit
331effc2
authored
Sep 29, 2009
by
Roberto Raggi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduced checkable results.
parent
3d62363f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
104 additions
and
3 deletions
+104
-3
src/plugins/cpptools/cppfindreferences.cpp
src/plugins/cpptools/cppfindreferences.cpp
+2
-0
src/plugins/find/searchresulttreeitemdelegate.cpp
src/plugins/find/searchresulttreeitemdelegate.cpp
+13
-0
src/plugins/find/searchresulttreeitems.cpp
src/plugins/find/searchresulttreeitems.cpp
+26
-2
src/plugins/find/searchresulttreeitems.h
src/plugins/find/searchresulttreeitems.h
+9
-1
src/plugins/find/searchresulttreemodel.cpp
src/plugins/find/searchresulttreemodel.cpp
+49
-0
src/plugins/find/searchresulttreemodel.h
src/plugins/find/searchresulttreemodel.h
+4
-0
src/plugins/find/searchresultwindow.cpp
src/plugins/find/searchresultwindow.cpp
+1
-0
No files found.
src/plugins/cpptools/cppfindreferences.cpp
View file @
331effc2
...
...
@@ -439,7 +439,9 @@ static void find_helper(QFutureInterface<Core::Utils::FileSearchResult> &future,
void
CppFindReferences
::
findAll
(
Symbol
*
symbol
)
{
const
bool
wasInReplaceMode
=
_resultWindow
->
isShowingReplaceUI
();
_resultWindow
->
clearContents
();
_resultWindow
->
setShowReplaceUI
(
true
);
_resultWindow
->
popup
(
true
);
const
Snapshot
snapshot
=
_modelManager
->
snapshot
();
...
...
src/plugins/find/searchresulttreeitemdelegate.cpp
View file @
331effc2
...
...
@@ -35,6 +35,7 @@
#include <QPainter>
#include <QAbstractTextDocumentLayout>
#include <QApplication>
#include <QDebug>
#include <math.h>
...
...
@@ -67,6 +68,18 @@ void SearchResultTreeItemDelegate::paint(QPainter *painter, const QStyleOptionVi
QItemDelegate
::
drawDisplay
(
painter
,
opt
,
resultRowRect
,
displayString
);
QItemDelegate
::
drawFocus
(
painter
,
opt
,
opt
.
rect
);
QVariant
value
=
index
.
data
(
Qt
::
CheckStateRole
);
if
(
value
.
isValid
())
{
Qt
::
CheckState
checkState
=
Qt
::
Unchecked
;
checkState
=
static_cast
<
Qt
::
CheckState
>
(
value
.
toInt
());
QRect
checkRect
=
check
(
opt
,
opt
.
rect
,
value
);
QRect
emptyRect
;
doLayout
(
opt
,
&
checkRect
,
&
emptyRect
,
&
emptyRect
,
false
);
QItemDelegate
::
drawCheck
(
painter
,
opt
,
opt
.
rect
,
checkState
);
}
painter
->
restore
();
}
}
...
...
src/plugins/find/searchresulttreeitems.cpp
View file @
331effc2
...
...
@@ -32,7 +32,7 @@
using
namespace
Find
::
Internal
;
SearchResultTreeItem
::
SearchResultTreeItem
(
SearchResultTreeItem
::
ItemType
type
,
const
SearchResultTreeItem
*
parent
)
:
m_type
(
type
),
m_parent
(
parent
)
:
m_type
(
type
),
m_parent
(
parent
)
,
m_isUserCheckable
(
false
),
m_checkState
(
Qt
::
Unchecked
)
{
}
...
...
@@ -41,6 +41,26 @@ SearchResultTreeItem::~SearchResultTreeItem()
clearChildren
();
}
bool
SearchResultTreeItem
::
isUserCheckable
()
const
{
return
m_isUserCheckable
;
}
void
SearchResultTreeItem
::
setIsUserCheckable
(
bool
isUserCheckable
)
{
m_isUserCheckable
=
isUserCheckable
;
}
Qt
::
CheckState
SearchResultTreeItem
::
checkState
()
const
{
return
m_checkState
;
}
void
SearchResultTreeItem
::
setCheckState
(
Qt
::
CheckState
checkState
)
{
m_checkState
=
checkState
;
}
void
SearchResultTreeItem
::
clearChildren
()
{
qDeleteAll
(
m_children
);
...
...
@@ -62,7 +82,7 @@ int SearchResultTreeItem::rowOfItem() const
return
(
m_parent
?
m_parent
->
m_children
.
indexOf
(
const_cast
<
SearchResultTreeItem
*>
(
this
))
:
0
);
}
const
SearchResultTreeItem
*
SearchResultTreeItem
::
childAt
(
int
index
)
const
SearchResultTreeItem
*
SearchResultTreeItem
::
childAt
(
int
index
)
const
{
return
m_children
.
at
(
index
);
}
...
...
@@ -131,5 +151,9 @@ void SearchResultFile::appendResultLine(int index, int lineNumber, const QString
{
SearchResultTreeItem
*
child
=
new
SearchResultTextRow
(
index
,
lineNumber
,
rowText
,
searchTermStart
,
searchTermLength
,
this
);
if
(
isUserCheckable
())
{
child
->
setIsUserCheckable
(
true
);
child
->
setCheckState
(
Qt
::
Checked
);
}
appendChild
(
child
);
}
src/plugins/find/searchresulttreeitems.h
View file @
331effc2
...
...
@@ -54,16 +54,24 @@ public:
ItemType
itemType
()
const
;
const
SearchResultTreeItem
*
parent
()
const
;
const
SearchResultTreeItem
*
childAt
(
int
index
)
const
;
SearchResultTreeItem
*
childAt
(
int
index
)
const
;
void
appendChild
(
SearchResultTreeItem
*
child
);
int
childrenCount
()
const
;
int
rowOfItem
()
const
;
void
clearChildren
();
bool
isUserCheckable
()
const
;
void
setIsUserCheckable
(
bool
isUserCheckable
);
Qt
::
CheckState
checkState
()
const
;
void
setCheckState
(
Qt
::
CheckState
checkState
);
private:
ItemType
m_type
;
const
SearchResultTreeItem
*
m_parent
;
QList
<
SearchResultTreeItem
*>
m_children
;
bool
m_isUserCheckable
;
Qt
::
CheckState
m_checkState
;
};
class
SearchResultTextRow
:
public
SearchResultTreeItem
...
...
src/plugins/find/searchresulttreemodel.cpp
View file @
331effc2
...
...
@@ -36,12 +36,14 @@
#include <QtGui/QColor>
#include <QtGui/QPalette>
#include <QtCore/QDir>
#include <QtCore/QDebug>
using
namespace
Find
::
Internal
;
SearchResultTreeModel
::
SearchResultTreeModel
(
QObject
*
parent
)
:
QAbstractItemModel
(
parent
)
,
m_lastAppendedResultFile
(
0
)
,
m_showReplaceUI
(
false
)
{
m_rootItem
=
new
SearchResultTreeItem
();
m_textEditorFont
=
QFont
(
"Courier"
);
...
...
@@ -52,11 +54,31 @@ SearchResultTreeModel::~SearchResultTreeModel()
delete
m_rootItem
;
}
void
SearchResultTreeModel
::
setShowReplaceUI
(
bool
show
)
{
m_showReplaceUI
=
show
;
}
void
SearchResultTreeModel
::
setTextEditorFont
(
const
QFont
&
font
)
{
m_textEditorFont
=
font
;
}
Qt
::
ItemFlags
SearchResultTreeModel
::
flags
(
const
QModelIndex
&
index
)
const
{
Qt
::
ItemFlags
flags
=
QAbstractItemModel
::
flags
(
index
);
if
(
index
.
isValid
())
{
if
(
const
SearchResultTreeItem
*
item
=
static_cast
<
const
SearchResultTreeItem
*>
(
index
.
internalPointer
()))
{
if
(
item
->
itemType
()
==
SearchResultTreeItem
::
ResultRow
&&
item
->
isUserCheckable
())
{
flags
|=
Qt
::
ItemIsUserCheckable
;
}
}
}
return
flags
;
}
QModelIndex
SearchResultTreeModel
::
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
)
const
{
...
...
@@ -135,12 +157,28 @@ QVariant SearchResultTreeModel::data(const QModelIndex &index, int role) const
return
result
;
}
bool
SearchResultTreeModel
::
setData
(
const
QModelIndex
&
index
,
const
QVariant
&
value
,
int
role
)
{
if
(
role
==
Qt
::
CheckStateRole
)
{
SearchResultTreeItem
*
item
=
static_cast
<
SearchResultTreeItem
*>
(
index
.
internalPointer
());
SearchResultTextRow
*
row
=
static_cast
<
SearchResultTextRow
*>
(
item
);
Qt
::
CheckState
checkState
=
static_cast
<
Qt
::
CheckState
>
(
value
.
toInt
());
row
->
setCheckState
(
checkState
);
return
true
;
}
return
QAbstractItemModel
::
setData
(
index
,
value
,
role
);
}
QVariant
SearchResultTreeModel
::
data
(
const
SearchResultTextRow
*
row
,
int
role
)
const
{
QVariant
result
;
switch
(
role
)
{
case
Qt
::
CheckStateRole
:
if
(
row
->
isUserCheckable
())
result
=
row
->
checkState
();
break
;
case
Qt
::
ToolTipRole
:
result
=
row
->
rowText
().
trimmed
();
break
;
...
...
@@ -188,6 +226,12 @@ QVariant SearchResultTreeModel::data(const SearchResultFile *file, int role) con
switch
(
role
)
{
#if 0
case Qt::CheckStateRole:
if (file->isUserCheckable())
result = file->checkState();
break;
#endif
case
Qt
::
BackgroundRole
:
{
const
QColor
baseColor
=
QApplication
::
palette
().
base
().
color
();
result
=
baseColor
.
darker
(
105
);
...
...
@@ -228,6 +272,11 @@ void SearchResultTreeModel::appendResultFile(const QString &fileName)
{
m_lastAppendedResultFile
=
new
SearchResultFile
(
fileName
,
m_rootItem
);
if
(
m_showReplaceUI
)
{
m_lastAppendedResultFile
->
setIsUserCheckable
(
true
);
m_lastAppendedResultFile
->
setCheckState
(
Qt
::
Checked
);
}
const
int
childrenCount
=
m_rootItem
->
childrenCount
();
beginInsertRows
(
QModelIndex
(),
childrenCount
,
childrenCount
);
m_rootItem
->
appendChild
(
m_lastAppendedResultFile
);
...
...
src/plugins/find/searchresulttreemodel.h
View file @
331effc2
...
...
@@ -48,13 +48,16 @@ public:
SearchResultTreeModel
(
QObject
*
parent
=
0
);
~
SearchResultTreeModel
();
void
setShowReplaceUI
(
bool
show
);
void
setTextEditorFont
(
const
QFont
&
font
);
Qt
::
ItemFlags
flags
(
const
QModelIndex
&
index
)
const
;
QModelIndex
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
QModelIndex
parent
(
const
QModelIndex
&
child
)
const
;
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
int
columnCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
;
bool
setData
(
const
QModelIndex
&
index
,
const
QVariant
&
value
,
int
role
=
Qt
::
EditRole
);
QVariant
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
)
const
;
QModelIndex
next
(
const
QModelIndex
&
idx
)
const
;
...
...
@@ -81,6 +84,7 @@ private:
SearchResultTreeItem
*
m_rootItem
;
SearchResultFile
*
m_lastAppendedResultFile
;
QFont
m_textEditorFont
;
bool
m_showReplaceUI
;
};
}
// namespace Internal
...
...
src/plugins/find/searchresultwindow.cpp
View file @
331effc2
...
...
@@ -109,6 +109,7 @@ SearchResultWindow::~SearchResultWindow()
void
SearchResultWindow
::
setShowReplaceUI
(
bool
show
)
{
m_searchResultTreeView
->
model
()
->
setShowReplaceUI
(
show
);
m_replaceLabel
->
setVisible
(
show
);
m_replaceTextEdit
->
setVisible
(
show
);
m_replaceButton
->
setVisible
(
show
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment