Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
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
videolan
vlc-2-2
Commits
dd29c917
Commit
dd29c917
authored
Jun 23, 2013
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Qt: Extensions: fullfill usage of data abstraction model
parent
8d19eace
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
50 deletions
+85
-50
modules/gui/qt4/dialogs/plugins.cpp
modules/gui/qt4/dialogs/plugins.cpp
+60
-48
modules/gui/qt4/dialogs/plugins.hpp
modules/gui/qt4/dialogs/plugins.hpp
+25
-2
No files found.
modules/gui/qt4/dialogs/plugins.cpp
View file @
dd29c917
...
...
@@ -280,38 +280,58 @@ void ExtensionTab::keyPressEvent( QKeyEvent *keyEvent )
void
ExtensionTab
::
moreInformation
()
{
QModelIndex
index
=
extList
->
selectionModel
()
->
selectedIndexes
().
first
();
ExtensionCopy
*
ext
=
(
ExtensionCopy
*
)
index
.
internalPointer
();
if
(
!
ext
)
if
(
!
index
.
isValid
()
)
return
;
ExtensionInfoDialog
dlg
(
*
ext
,
p_intf
,
this
);
ExtensionInfoDialog
dlg
(
index
,
p_intf
,
this
);
dlg
.
exec
();
}
/* Safe copy of the extension_t struct */
class
ExtensionCopy
ExtensionListModel
::
ExtensionCopy
::
ExtensionCopy
(
extension_t
*
p_ext
)
{
name
=
qfu
(
p_ext
->
psz_name
);
description
=
qfu
(
p_ext
->
psz_description
);
shortdesc
=
qfu
(
p_ext
->
psz_shortdescription
);
if
(
description
.
isEmpty
()
)
description
=
shortdesc
;
if
(
shortdesc
.
isEmpty
()
&&
!
description
.
isEmpty
()
)
shortdesc
=
description
;
title
=
qfu
(
p_ext
->
psz_title
);
author
=
qfu
(
p_ext
->
psz_author
);
version
=
qfu
(
p_ext
->
psz_version
);
url
=
qfu
(
p_ext
->
psz_url
);
icon
=
loadPixmapFromData
(
p_ext
->
p_icondata
,
p_ext
->
i_icondata_size
);
}
ExtensionListModel
::
ExtensionCopy
::~
ExtensionCopy
()
{
delete
icon
;
}
QVariant
ExtensionListModel
::
ExtensionCopy
::
data
(
int
role
)
const
{
public:
ExtensionCopy
(
extension_t
*
p_ext
)
switch
(
role
)
{
name
=
qfu
(
p_ext
->
psz_name
);
description
=
qfu
(
p_ext
->
psz_description
);
shortdesc
=
qfu
(
p_ext
->
psz_shortdescription
);
if
(
description
.
isEmpty
()
)
description
=
shortdesc
;
if
(
shortdesc
.
isEmpty
()
&&
!
description
.
isEmpty
()
)
shortdesc
=
description
;
title
=
qfu
(
p_ext
->
psz_title
);
author
=
qfu
(
p_ext
->
psz_author
);
version
=
qfu
(
p_ext
->
psz_version
);
url
=
qfu
(
p_ext
->
psz_url
);
icon
=
loadPixmapFromData
(
p_ext
->
p_icondata
,
p_ext
->
i_icondata_size
);
case
Qt
:
:
DisplayRole
:
return
title
;
case
Qt
:
:
DecorationRole
:
return
*
icon
;
case
DescriptionRole
:
return
shortdesc
;
case
VersionRole
:
return
version
;
case
AuthorRole
:
return
author
;
case
LinkRole
:
return
url
;
case
NameRole
:
return
name
;
default:
return
QVariant
();
}
~
ExtensionCopy
()
{
delete
icon
;
}
QString
name
,
title
,
description
,
shortdesc
,
author
,
version
,
url
;
QPixmap
*
icon
;
};
}
/* Extensions list model for the QListView */
...
...
@@ -385,17 +405,10 @@ QVariant ExtensionListModel::data( const QModelIndex& index, int role ) const
if
(
!
index
.
isValid
()
)
return
QVariant
();
switch
(
role
)
{
case
Qt
:
:
DisplayRole
:
return
((
ExtensionCopy
*
)
index
.
internalPointer
())
->
title
;
case
Qt
:
:
DecorationRole
:
return
*
((
ExtensionCopy
*
)
index
.
internalPointer
())
->
icon
;
case
DescriptionRole
:
return
((
ExtensionCopy
*
)
index
.
internalPointer
())
->
shortdesc
;
default:
return
QVariant
();
}
ExtensionCopy
*
extension
=
static_cast
<
ExtensionCopy
*>
(
index
.
internalPointer
());
return
extension
->
data
(
role
);
}
QModelIndex
ExtensionListModel
::
index
(
int
row
,
int
column
,
...
...
@@ -501,7 +514,7 @@ QSize ExtensionItemDelegate::sizeHint( const QStyleOptionViewItem &option,
/* "More information" dialog */
ExtensionInfoDialog
::
ExtensionInfoDialog
(
const
ExtensionCopy
&
extension
,
ExtensionInfoDialog
::
ExtensionInfoDialog
(
const
QModelIndex
&
index
,
intf_thread_t
*
p_intf
,
QWidget
*
parent
)
:
QVLCDialog
(
parent
,
p_intf
)
...
...
@@ -510,28 +523,25 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
setWindowModality
(
Qt
::
WindowModal
);
// Window title
setWindowTitle
(
qtr
(
"About"
)
+
" "
+
extension
.
title
);
setWindowTitle
(
qtr
(
"About"
)
+
" "
+
index
.
data
(
Qt
::
DisplayRole
).
toString
()
);
// Layout
QGridLayout
*
layout
=
new
QGridLayout
(
this
);
// Icon
QLabel
*
icon
=
new
QLabel
(
this
);
if
(
!
extension
.
icon
)
QPixmap
pix
=
index
.
data
(
Qt
::
DecorationRole
).
value
<
QPixmap
>
();
if
(
pix
.
isNull
()
)
{
QPixmap
pix
(
":/logo/vlc48.png"
);
pix
=
QPixmap
(
":/logo/vlc48.png"
);
icon
->
setPixmap
(
pix
);
}
else
{
icon
->
setPixmap
(
*
extension
.
icon
);
}
icon
->
setAlignment
(
Qt
::
AlignCenter
);
icon
->
setFixedSize
(
48
,
48
);
layout
->
addWidget
(
icon
,
1
,
0
,
2
,
1
);
// Title
QLabel
*
label
=
new
QLabel
(
extension
.
title
,
this
);
QLabel
*
label
=
new
QLabel
(
index
.
data
(
Qt
::
DisplayRole
).
toString
()
,
this
);
QFont
font
=
label
->
font
();
font
.
setBold
(
true
);
font
.
setPointSizeF
(
font
.
pointSizeF
()
*
1.3
f
);
...
...
@@ -541,19 +551,19 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
// Version
label
=
new
QLabel
(
"<b>"
+
qtr
(
"Version"
)
+
":</b>"
,
this
);
layout
->
addWidget
(
label
,
1
,
1
,
1
,
1
,
Qt
::
AlignBottom
);
label
=
new
QLabel
(
extension
.
version
,
this
);
label
=
new
QLabel
(
index
.
data
(
ExtensionListModel
::
VersionRole
).
toString
()
,
this
);
layout
->
addWidget
(
label
,
1
,
2
,
1
,
2
,
Qt
::
AlignBottom
);
// Author
label
=
new
QLabel
(
"<b>"
+
qtr
(
"Author"
)
+
":</b>"
,
this
);
layout
->
addWidget
(
label
,
2
,
1
,
1
,
1
,
Qt
::
AlignTop
);
label
=
new
QLabel
(
extension
.
author
,
this
);
label
=
new
QLabel
(
index
.
data
(
ExtensionListModel
::
AuthorRole
).
toString
()
,
this
);
layout
->
addWidget
(
label
,
2
,
2
,
1
,
2
,
Qt
::
AlignTop
);
// Description
label
=
new
QLabel
(
this
);
label
->
setText
(
extension
.
description
);
label
->
setText
(
index
.
data
(
ExtensionListModel
::
DescriptionRole
).
toString
()
);
label
->
setWordWrap
(
true
);
label
->
setOpenExternalLinks
(
true
);
layout
->
addWidget
(
label
,
4
,
0
,
1
,
-
1
);
...
...
@@ -562,7 +572,8 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
label
=
new
QLabel
(
"<b>"
+
qtr
(
"Website"
)
+
":</b>"
,
this
);
layout
->
addWidget
(
label
,
5
,
0
,
1
,
2
);
label
=
new
QLabel
(
QString
(
"<a href=
\"
%1
\"
>%2</a>"
)
.
arg
(
extension
.
url
).
arg
(
extension
.
url
)
.
arg
(
index
.
data
(
ExtensionListModel
::
LinkRole
).
toString
()
)
.
arg
(
index
.
data
(
ExtensionListModel
::
LinkRole
).
toString
()
)
,
this
);
label
->
setOpenExternalLinks
(
true
);
layout
->
addWidget
(
label
,
5
,
2
,
1
,
-
1
);
...
...
@@ -570,7 +581,8 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
// Script file
label
=
new
QLabel
(
"<b>"
+
qtr
(
"File"
)
+
":</b>"
,
this
);
layout
->
addWidget
(
label
,
6
,
0
,
1
,
2
);
QLineEdit
*
line
=
new
QLineEdit
(
extension
.
name
,
this
);
QLineEdit
*
line
=
new
QLineEdit
(
index
.
data
(
ExtensionListModel
::
NameRole
).
toString
(),
this
);
line
->
setReadOnly
(
true
);
layout
->
addWidget
(
line
,
6
,
2
,
1
,
-
1
);
...
...
modules/gui/qt4/dialogs/plugins.hpp
View file @
dd29c917
...
...
@@ -132,10 +132,32 @@ class ExtensionListModel : public QAbstractListModel
Q_OBJECT
public:
/* Safe copy of the extension_t struct */
class
ExtensionCopy
{
public:
ExtensionCopy
(
extension_t
*
);
~
ExtensionCopy
();
QVariant
data
(
int
role
)
const
;
private:
QString
name
,
title
,
description
,
shortdesc
,
author
,
version
,
url
;
QPixmap
*
icon
;
};
ExtensionListModel
(
QListView
*
view
,
intf_thread_t
*
p_intf
);
virtual
~
ExtensionListModel
();
static
const
Qt
::
ItemDataRole
DescriptionRole
=
Qt
::
UserRole
;
enum
{
DescriptionRole
=
Qt
::
UserRole
,
VersionRole
,
AuthorRole
,
LinkRole
,
NameRole
};
virtual
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
virtual
QModelIndex
index
(
int
row
,
int
column
=
0
,
const
QModelIndex
&
=
QModelIndex
()
)
const
;
...
...
@@ -145,6 +167,7 @@ private slots:
void
updateList
();
private:
intf_thread_t
*
p_intf
;
QList
<
ExtensionCopy
*>
extensions
;
};
...
...
@@ -169,7 +192,7 @@ private:
class
ExtensionInfoDialog
:
public
QVLCDialog
{
public:
ExtensionInfoDialog
(
const
ExtensionCopy
&
extension
,
ExtensionInfoDialog
(
const
QModelIndex
&
index
,
intf_thread_t
*
p_intf
,
QWidget
*
parent
);
};
...
...
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