Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
DSerial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
apps
DSerial
Commits
ce3a105d
Commit
ce3a105d
authored
9 years ago
by
Isabella Skořepová
Browse files
Options
Downloads
Patches
Plain Diff
Emit propertiesChanged signal when portal list changes
parent
e124698b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dserial-server/controller.cpp
+19
-1
19 additions, 1 deletion
dserial-server/controller.cpp
dserial-server/controller.h
+3
-0
3 additions, 0 deletions
dserial-server/controller.h
with
22 additions
and
1 deletion
dserial-server/controller.cpp
+
19
−
1
View file @
ce3a105d
...
@@ -10,6 +10,7 @@ Controller::Controller(QObject *parent) : QObject(parent), connection(QDBusConne
...
@@ -10,6 +10,7 @@ Controller::Controller(QObject *parent) : QObject(parent), connection(QDBusConne
port
->
dbusPath
.
setPath
(
"/fake/test0"
);
port
->
dbusPath
.
setPath
(
"/fake/test0"
);
connection
.
registerObject
(
port
->
dbusPath
.
path
(),
port
);
connection
.
registerObject
(
port
->
dbusPath
.
path
(),
port
);
ports
.
append
(
port
);
ports
.
append
(
port
);
notifyPropertyChanged
(
"PortList"
);
}
}
QStringList
Controller
::
PortList
()
const
QStringList
Controller
::
PortList
()
const
...
@@ -37,9 +38,10 @@ void Controller::CreateFilePort(QString)
...
@@ -37,9 +38,10 @@ void Controller::CreateFilePort(QString)
void
Controller
::
Autodetect
()
void
Controller
::
Autodetect
()
{
{
qDebug
()
<<
"Autodetect"
;
qDebug
()
<<
"Autodetect"
;
bool
changed
=
false
;
// Remove nonexistent
// Remove nonexistent
for
(
Port
*
port
:
ports
)
{
for
(
Port
*
port
:
ports
)
{
port
->
Exists
();
if
(
!
port
->
Exists
()
)
changed
=
true
;
}
}
// Detect new
// Detect new
...
@@ -54,6 +56,7 @@ void Controller::Autodetect()
...
@@ -54,6 +56,7 @@ void Controller::Autodetect()
}
}
if
(
!
isInList
)
{
if
(
!
isInList
)
{
changed
=
true
;
Port
*
port
=
new
Port
(
info
.
systemLocation
());
Port
*
port
=
new
Port
(
info
.
systemLocation
());
new
PortAdaptor
(
port
);
new
PortAdaptor
(
port
);
port
->
dbusPath
.
setPath
(
"/autodetected"
+
info
.
systemLocation
());
port
->
dbusPath
.
setPath
(
"/autodetected"
+
info
.
systemLocation
());
...
@@ -63,6 +66,7 @@ void Controller::Autodetect()
...
@@ -63,6 +66,7 @@ void Controller::Autodetect()
ports
.
append
(
port
);
ports
.
append
(
port
);
}
}
}
}
if
(
changed
)
notifyPropertyChanged
(
"PortList"
);
qDebug
()
<<
"Autodetect done"
;
qDebug
()
<<
"Autodetect done"
;
}
}
...
@@ -85,3 +89,17 @@ void Controller::removePort(QDBusObjectPath id)
...
@@ -85,3 +89,17 @@ void Controller::removePort(QDBusObjectPath id)
}
}
}
}
}
}
void
Controller
::
notifyPropertyChanged
(
const
char
*
propertyName
)
{
QDBusMessage
signal
=
QDBusMessage
::
createSignal
(
"/controller"
,
"org.freedesktop.DBus.Properties"
,
"PropertiesChanged"
);
signal
<<
QString
(
"info.skorepa.DSerial.controller"
);
QVariantMap
changedProps
;
changedProps
.
insert
(
propertyName
,
property
(
propertyName
));
signal
<<
changedProps
;
signal
<<
QStringList
();
QDBusConnection
::
sessionBus
().
send
(
signal
);
}
This diff is collapsed.
Click to expand it.
dserial-server/controller.h
+
3
−
0
View file @
ce3a105d
...
@@ -33,6 +33,9 @@ class Controller : public QObject
...
@@ -33,6 +33,9 @@ class Controller : public QObject
public:
public:
QDBusConnection
connection
;
QDBusConnection
connection
;
private:
void
notifyPropertyChanged
(
const
char
*
propertyName
);
};
};
#endif // CONTROLLER_H
#endif // CONTROLLER_H
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