Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
324be6b4
Commit
324be6b4
authored
Dec 20, 2009
by
Max-Wilhelm Bruker
Browse files
reverted card search to initial behaviour
parent
ffe85962
Changes
3
Show whitespace changes
Inline
Side-by-side
cockatrice/src/carddatabasemodel.cpp
View file @
324be6b4
...
@@ -69,3 +69,20 @@ CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
...
@@ -69,3 +69,20 @@ CardDatabaseDisplayModel::CardDatabaseDisplayModel(QObject *parent)
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
setSortCaseSensitivity
(
Qt
::
CaseInsensitive
);
setSortCaseSensitivity
(
Qt
::
CaseInsensitive
);
}
}
bool
CardDatabaseDisplayModel
::
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
/*sourceParent*/
)
const
{
CardInfo
*
info
=
static_cast
<
CardDatabaseModel
*>
(
sourceModel
())
->
getCard
(
sourceRow
);
if
(
!
cardNameBeginning
.
isEmpty
())
if
(
!
info
->
getName
().
startsWith
(
cardNameBeginning
,
Qt
::
CaseInsensitive
))
return
false
;
return
true
;
}
void
CardDatabaseDisplayModel
::
setCardNameBeginning
(
const
QString
&
_beginning
)
{
cardNameBeginning
=
_beginning
;
invalidateFilter
();
}
cockatrice/src/carddatabasemodel.h
View file @
324be6b4
...
@@ -15,6 +15,7 @@ public:
...
@@ -15,6 +15,7 @@ public:
int
columnCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
int
columnCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
QVariant
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
=
Qt
::
DisplayRole
)
const
;
QVariant
headerData
(
int
section
,
Qt
::
Orientation
orientation
,
int
role
=
Qt
::
DisplayRole
)
const
;
CardInfo
*
getCard
(
int
index
)
const
{
return
cardList
[
index
];
}
private:
private:
QList
<
CardInfo
*>
cardList
;
QList
<
CardInfo
*>
cardList
;
CardDatabase
*
db
;
CardDatabase
*
db
;
...
@@ -22,8 +23,13 @@ private:
...
@@ -22,8 +23,13 @@ private:
class
CardDatabaseDisplayModel
:
public
QSortFilterProxyModel
{
class
CardDatabaseDisplayModel
:
public
QSortFilterProxyModel
{
Q_OBJECT
Q_OBJECT
private:
QString
cardNameBeginning
;
public:
public:
CardDatabaseDisplayModel
(
QObject
*
parent
=
0
);
CardDatabaseDisplayModel
(
QObject
*
parent
=
0
);
void
setCardNameBeginning
(
const
QString
&
_beginning
);
protected:
bool
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
sourceParent
)
const
;
};
};
#endif
#endif
cockatrice/src/window_deckeditor.cpp
View file @
324be6b4
...
@@ -31,6 +31,7 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
...
@@ -31,6 +31,7 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
databaseModel
=
new
CardDatabaseModel
(
db
,
this
);
databaseModel
=
new
CardDatabaseModel
(
db
,
this
);
databaseDisplayModel
=
new
CardDatabaseDisplayModel
(
this
);
databaseDisplayModel
=
new
CardDatabaseDisplayModel
(
this
);
databaseDisplayModel
->
setSourceModel
(
databaseModel
);
databaseDisplayModel
->
setSourceModel
(
databaseModel
);
databaseDisplayModel
->
setFilterKeyColumn
(
0
);
databaseDisplayModel
->
sort
(
0
,
Qt
::
AscendingOrder
);
databaseDisplayModel
->
sort
(
0
,
Qt
::
AscendingOrder
);
databaseView
=
new
QTreeView
();
databaseView
=
new
QTreeView
();
databaseView
->
setModel
(
databaseDisplayModel
);
databaseView
->
setModel
(
databaseDisplayModel
);
...
@@ -197,7 +198,7 @@ void WndDeckEditor::updateCardInfoRight(const QModelIndex ¤t, const QModel
...
@@ -197,7 +198,7 @@ void WndDeckEditor::updateCardInfoRight(const QModelIndex ¤t, const QModel
void
WndDeckEditor
::
updateSearch
(
const
QString
&
search
)
void
WndDeckEditor
::
updateSearch
(
const
QString
&
search
)
{
{
databaseDisplayModel
->
set
FilterFixedStr
ing
(
search
);
databaseDisplayModel
->
set
CardNameBeginn
ing
(
search
);
}
}
bool
WndDeckEditor
::
confirmClose
()
bool
WndDeckEditor
::
confirmClose
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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