Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jami-libclient
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
savoirfairelinux
jami-libclient
Commits
0e79b741
Commit
0e79b741
authored
9 years ago
by
Alexandre Lision
Browse files
Options
Downloads
Patches
Plain Diff
ringtonemodel: improve switching
Tuleap:
#339
Change-Id: I921c16f103dcb7e3293cca82e83ca7f0f4156200
parent
228e9ba3
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/ringtone.cpp
+1
-13
1 addition, 13 deletions
src/ringtone.cpp
src/ringtone.h
+0
-2
0 additions, 2 deletions
src/ringtone.h
src/ringtonemodel.cpp
+20
-5
20 additions, 5 deletions
src/ringtonemodel.cpp
src/ringtonemodel.h
+2
-2
2 additions, 2 deletions
src/ringtonemodel.h
with
23 additions
and
22 deletions
src/ringtone.cpp
+
1
−
13
View file @
0e79b741
...
...
@@ -27,10 +27,9 @@ public:
RingtonePrivate
();
QString
m_Path
;
QString
m_Name
;
bool
m_IsPlaying
;
};
RingtonePrivate
::
RingtonePrivate
()
:
m_IsPlaying
(
false
)
RingtonePrivate
::
RingtonePrivate
()
{
}
...
...
@@ -55,7 +54,6 @@ QString Ringtone::name() const
return
d_ptr
->
m_Name
;
}
void
Ringtone
::
setPath
(
const
QString
&
path
)
{
d_ptr
->
m_Path
=
QDir
::
toNativeSeparators
(
path
);
...
...
@@ -65,13 +63,3 @@ void Ringtone::setName(const QString& name)
{
d_ptr
->
m_Name
=
name
;
}
bool
Ringtone
::
isPlaying
()
const
{
return
d_ptr
->
m_IsPlaying
;
}
void
Ringtone
::
setIsPlaying
(
const
bool
value
)
{
d_ptr
->
m_IsPlaying
=
value
;
}
This diff is collapsed.
Click to expand it.
src/ringtone.h
+
0
−
2
View file @
0e79b741
...
...
@@ -32,12 +32,10 @@ public:
//Getter
QString
path
()
const
;
QString
name
()
const
;
bool
isPlaying
()
const
;
//Setter
void
setPath
(
const
QString
&
path
);
void
setName
(
const
QString
&
name
);
void
setIsPlaying
(
const
bool
value
);
private:
RingtonePrivate
*
d_ptr
;
...
...
This diff is collapsed.
Click to expand it.
src/ringtonemodel.cpp
+
20
−
5
View file @
0e79b741
...
...
@@ -28,6 +28,7 @@
#include
"dbus/configurationmanager.h"
#include
"dbus/callmanager.h"
#include
"account.h"
#include
"accountmodel.h"
#include
"ringtone.h"
#include
<localringtonecollection.h>
...
...
@@ -46,6 +47,7 @@ public:
QHash
<
Account
*
,
QItemSelectionModel
*>
m_hSelectionModels
;
LocalRingtoneCollection
*
m_pCollection
;
QHash
<
const
Ringtone
*
,
Account
*>
m_hPendingSelection
;
bool
m_isPlaying
;
//Helpers
int
currentIndex
(
Account
*
a
)
const
;
...
...
@@ -62,6 +64,7 @@ RingtoneModelPrivate::RingtoneModelPrivate(RingtoneModel* parent)
:
q_ptr
(
parent
)
,
m_pTimer
(
nullptr
)
,
m_pCurrent
(
nullptr
)
,
m_isPlaying
(
false
)
{
}
...
...
@@ -72,6 +75,16 @@ RingtoneModel::RingtoneModel(QObject* parent)
,
d_ptr
(
new
RingtoneModelPrivate
(
this
))
{
d_ptr
->
m_pCollection
=
addCollection
<
LocalRingtoneCollection
>
();
QObject
::
connect
(
AccountModel
::
instance
().
selectionModel
(),
&
QItemSelectionModel
::
currentChanged
,
[
=
](
const
QModelIndex
&
current
,
const
QModelIndex
&
previous
)
{
Q_UNUSED
(
current
)
if
(
d_ptr
->
m_isPlaying
&&
previous
.
isValid
())
{
auto
acc
=
AccountModel
::
instance
().
getAccountByModelIndex
(
previous
);
auto
qIdx
=
d_ptr
->
m_hSelectionModels
[
acc
]
->
currentIndex
();
play
(
qIdx
);
}
});
}
RingtoneModel
&
RingtoneModel
::
instance
()
...
...
@@ -96,12 +109,16 @@ QHash<int,QByteArray> RingtoneModel::roleNames() const
static
bool
initRoles
=
false
;
if
(
!
initRoles
)
{
initRoles
=
true
;
roles
[
Role
::
IsPlaying
]
=
"IsPlaying"
;
roles
[
Role
::
FullPath
]
=
"FullPath"
;
}
return
roles
;
}
bool
RingtoneModel
::
isPlaying
()
{
return
d_ptr
->
m_isPlaying
;
}
QVariant
RingtoneModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
if
(
!
index
.
isValid
())
...
...
@@ -112,8 +129,6 @@ QVariant RingtoneModel::data( const QModelIndex& index, int role ) const
switch
(
role
)
{
case
Qt
::
DisplayRole
:
return
info
->
name
();
case
Role
::
IsPlaying
:
return
info
->
isPlaying
();
case
Role
::
FullPath
:
return
info
->
path
();
};
...
...
@@ -215,7 +230,7 @@ void RingtoneModel::play(const QModelIndex& idx)
d_ptr
->
m_pTimer
->
stop
();
}
d_ptr
->
m_pTimer
->
start
();
info
->
setI
sPlaying
(
true
)
;
d_ptr
->
m_i
sPlaying
=
true
;
emit
dataChanged
(
index
(
idx
.
row
(),
0
),
index
(
idx
.
row
(),
1
));
d_ptr
->
m_pCurrent
=
info
;
}
...
...
@@ -226,7 +241,7 @@ void RingtoneModelPrivate::slotStopTimer()
if
(
m_pCurrent
)
{
CallManagerInterface
&
callManager
=
CallManager
::
instance
();
callManager
.
stopRecordedFilePlayback
(
m_pCurrent
->
path
());
m_
pCurrent
->
setI
sPlaying
(
false
)
;
m_
i
sPlaying
=
false
;
const
QModelIndex
&
idx
=
q_ptr
->
index
(
m_lRingtone
.
indexOf
(
m_pCurrent
),
0
);
emit
q_ptr
->
dataChanged
(
idx
,
q_ptr
->
index
(
idx
.
row
(),
1
));
m_pCurrent
=
nullptr
;
...
...
This diff is collapsed.
Click to expand it.
src/ringtonemodel.h
+
2
−
2
View file @
0e79b741
...
...
@@ -37,8 +37,7 @@ class LIB_EXPORT RingtoneModel : public QAbstractTableModel, public CollectionMa
public:
enum
Role
{
IsPlaying
=
100
,
FullPath
=
101
,
FullPath
=
100
,
};
virtual
~
RingtoneModel
();
...
...
@@ -54,6 +53,7 @@ public:
//Getters
Ringtone
*
currentRingTone
(
Account
*
a
)
const
;
QItemSelectionModel
*
selectionModel
(
Account
*
a
)
const
;
bool
isPlaying
();
//Mutator
void
play
(
const
QModelIndex
&
index
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment