Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PIM Messagelib
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
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
PIM
PIM Messagelib
Commits
9e7ea6da
Commit
9e7ea6da
authored
May 22, 2016
by
Daniel Vrátil
🤖
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Model: port to more efficient Qt5-style QObject::connect
parent
ced3c496
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
42 deletions
+42
-42
messagelist/src/core/model.cpp
messagelist/src/core/model.cpp
+37
-33
messagelist/src/core/model.h
messagelist/src/core/model.h
+0
-9
messagelist/src/core/model_p.h
messagelist/src/core/model_p.h
+5
-0
No files found.
messagelist/src/core/model.cpp
View file @
9e7ea6da
...
...
@@ -68,6 +68,8 @@
#include <QLocale>
#include <QElapsedTimer>
#include <algorithm>
namespace
MessageList
{
...
...
@@ -309,8 +311,8 @@ Model::Model(View *pParent)
d
->
mFillStepTimer
.
setSingleShot
(
true
);
d
->
mInvariantRowMapper
=
new
ModelInvariantRowMapper
();
d
->
mModelForItemFunctions
=
this
;
connect
(
&
d
->
mFillStepTimer
,
SIGNAL
(
timeout
())
,
SLOT
(
viewItemJobStep
())
);
connect
(
&
d
->
mFillStepTimer
,
&
QTimer
::
timeout
,
this
,
[
this
]()
{
d
->
viewItemJobStep
();
}
);
d
->
mCachedTodayLabel
=
i18n
(
"Today"
);
d
->
mCachedYesterdayLabel
=
i18n
(
"Yesterday"
);
...
...
@@ -324,8 +326,8 @@ Model::Model(View *pParent)
d
->
mCachedWatchedOrIgnoredStatusBits
=
Akonadi
::
MessageStatus
::
statusIgnored
().
toQInt32
()
|
Akonadi
::
MessageStatus
::
statusWatched
().
toQInt32
();
connect
(
_k_heartBeatTimer
,
SIGNAL
(
timeout
())
,
this
,
SLOT
(
checkIfDateChanged
())
);
connect
(
_k_heartBeatTimer
,
&
QTimer
::
timeout
,
this
,
[
this
]()
{
d
->
checkIfDateChanged
();
}
);
if
(
!
_k_heartBeatTimer
->
isActive
())
{
// First model starts it
_k_heartBeatTimer
->
start
(
60000
);
// 1 minute
...
...
@@ -378,7 +380,7 @@ void Model::setFilter(const Filter *filter)
d
->
mFilter
=
filter
;
if
(
d
->
mFilter
)
{
connect
(
d
->
mFilter
,
SIGNAL
(
finished
()),
this
,
SLOT
(
slotApplyFilter
())
);
connect
(
d
->
mFilter
,
&
Filter
::
finished
,
this
,
[
this
]()
{
d
->
slotApplyFilter
();
}
);
}
d
->
slotApplyFilter
();
...
...
@@ -734,20 +736,10 @@ void Model::setStorageModel(StorageModel *storageModel, PreSelectionMode preSele
d
->
clear
();
if
(
d
->
mStorageModel
)
{
disconnect
(
d
->
mStorageModel
,
SIGNAL
(
rowsInserted
(
QModelIndex
,
int
,
int
)),
this
,
SLOT
(
slotStorageModelRowsInserted
(
QModelIndex
,
int
,
int
)));
disconnect
(
d
->
mStorageModel
,
SIGNAL
(
rowsRemoved
(
QModelIndex
,
int
,
int
)),
this
,
SLOT
(
slotStorageModelRowsRemoved
(
QModelIndex
,
int
,
int
)));
disconnect
(
d
->
mStorageModel
,
SIGNAL
(
layoutChanged
()),
this
,
SLOT
(
slotStorageModelLayoutChanged
()));
disconnect
(
d
->
mStorageModel
,
SIGNAL
(
modelReset
()),
this
,
SLOT
(
slotStorageModelLayoutChanged
()));
disconnect
(
d
->
mStorageModel
,
SIGNAL
(
dataChanged
(
QModelIndex
,
QModelIndex
)),
this
,
SLOT
(
slotStorageModelDataChanged
(
QModelIndex
,
QModelIndex
)));
disconnect
(
d
->
mStorageModel
,
SIGNAL
(
headerDataChanged
(
Qt
::
Orientation
,
int
,
int
)),
this
,
SLOT
(
slotStorageModelHeaderDataChanged
(
Qt
::
Orientation
,
int
,
int
)));
// Disconnect all signals from old storageModel
std
::
for_each
(
d
->
mStorageModelConnections
.
cbegin
(),
d
->
mStorageModelConnections
.
cend
(),
[](
const
QMetaObject
::
Connection
&
c
)
->
bool
{
return
QObject
::
disconnect
(
c
);
});
d
->
mStorageModelConnections
.
clear
();
}
d
->
mStorageModel
=
storageModel
;
...
...
@@ -762,20 +754,32 @@ void Model::setStorageModel(StorageModel *storageModel, PreSelectionMode preSele
d
->
mPreSelectionMode
=
preSelectionMode
;
d
->
mStorageModelContainsOutboundMessages
=
d
->
mStorageModel
->
containsOutboundMessages
();
connect
(
d
->
mStorageModel
,
SIGNAL
(
rowsInserted
(
QModelIndex
,
int
,
int
)),
this
,
SLOT
(
slotStorageModelRowsInserted
(
QModelIndex
,
int
,
int
)));
connect
(
d
->
mStorageModel
,
SIGNAL
(
rowsRemoved
(
QModelIndex
,
int
,
int
)),
this
,
SLOT
(
slotStorageModelRowsRemoved
(
QModelIndex
,
int
,
int
)));
connect
(
d
->
mStorageModel
,
SIGNAL
(
layoutChanged
()),
this
,
SLOT
(
slotStorageModelLayoutChanged
()));
connect
(
d
->
mStorageModel
,
SIGNAL
(
modelReset
()),
this
,
SLOT
(
slotStorageModelLayoutChanged
()));
connect
(
d
->
mStorageModel
,
SIGNAL
(
dataChanged
(
QModelIndex
,
QModelIndex
)),
this
,
SLOT
(
slotStorageModelDataChanged
(
QModelIndex
,
QModelIndex
)));
connect
(
d
->
mStorageModel
,
SIGNAL
(
headerDataChanged
(
Qt
::
Orientation
,
int
,
int
)),
this
,
SLOT
(
slotStorageModelHeaderDataChanged
(
Qt
::
Orientation
,
int
,
int
)));
d
->
mStorageModelConnections
=
{
connect
(
d
->
mStorageModel
,
&
StorageModel
::
rowsInserted
,
this
,
[
this
](
const
QModelIndex
&
parent
,
int
first
,
int
last
)
{
d
->
slotStorageModelRowsInserted
(
parent
,
first
,
last
);
}),
connect
(
d
->
mStorageModel
,
&
StorageModel
::
rowsRemoved
,
this
,
[
this
](
const
QModelIndex
&
parent
,
int
first
,
int
last
)
{
d
->
slotStorageModelRowsRemoved
(
parent
,
first
,
last
);
}),
connect
(
d
->
mStorageModel
,
&
StorageModel
::
layoutChanged
,
this
,
[
this
]()
{
d
->
slotStorageModelLayoutChanged
();
}),
connect
(
d
->
mStorageModel
,
&
StorageModel
::
modelReset
,
this
,
[
this
]()
{
d
->
slotStorageModelLayoutChanged
();
}),
connect
(
d
->
mStorageModel
,
&
StorageModel
::
dataChanged
,
this
,
[
this
](
const
QModelIndex
&
topLeft
,
const
QModelIndex
&
bottomRight
)
{
d
->
slotStorageModelDataChanged
(
topLeft
,
bottomRight
);
}),
connect
(
d
->
mStorageModel
,
&
StorageModel
::
headerDataChanged
,
this
,
[
this
](
Qt
::
Orientation
orientation
,
int
first
,
int
last
)
{
d
->
slotStorageModelHeaderDataChanged
(
orientation
,
first
,
last
);
})
};
if
(
d
->
mStorageModel
->
rowCount
()
==
0
)
{
return
;
// folder empty: nothing to fill
...
...
messagelist/src/core/model.h
View file @
9e7ea6da
...
...
@@ -223,15 +223,6 @@ Q_SIGNALS:
void
statusMessage
(
const
QString
&
message
);
private:
Q_PRIVATE_SLOT
(
d
,
void
checkIfDateChanged
())
Q_PRIVATE_SLOT
(
d
,
void
viewItemJobStep
())
Q_PRIVATE_SLOT
(
d
,
void
slotStorageModelRowsInserted
(
const
QModelIndex
&
,
int
,
int
))
Q_PRIVATE_SLOT
(
d
,
void
slotStorageModelRowsRemoved
(
const
QModelIndex
&
,
int
,
int
))
Q_PRIVATE_SLOT
(
d
,
void
slotStorageModelDataChanged
(
const
QModelIndex
&
,
const
QModelIndex
&
))
Q_PRIVATE_SLOT
(
d
,
void
slotStorageModelHeaderDataChanged
(
Qt
::
Orientation
,
int
,
int
))
Q_PRIVATE_SLOT
(
d
,
void
slotStorageModelLayoutChanged
())
Q_PRIVATE_SLOT
(
d
,
void
slotApplyFilter
())
friend
class
ModelPrivate
;
ModelPrivate
*
const
d
;
};
...
...
messagelist/src/core/model_p.h
View file @
9e7ea6da
...
...
@@ -430,6 +430,11 @@ public:
* virtual (so it's always an indirect function call). Caching makes sense.
*/
bool
mStorageModelContainsOutboundMessages
;
/**
* Vector of signal-slot connections between StorageModel and us
*/
QVector
<
QMetaObject
::
Connection
>
mStorageModelConnections
;
};
}
// namespace Core
...
...
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