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 )
...
@@ -280,38 +280,58 @@ void ExtensionTab::keyPressEvent( QKeyEvent *keyEvent )
void
ExtensionTab
::
moreInformation
()
void
ExtensionTab
::
moreInformation
()
{
{
QModelIndex
index
=
extList
->
selectionModel
()
->
selectedIndexes
().
first
();
QModelIndex
index
=
extList
->
selectionModel
()
->
selectedIndexes
().
first
();
ExtensionCopy
*
ext
=
(
ExtensionCopy
*
)
index
.
internalPointer
();
if
(
!
ext
)
if
(
!
index
.
isValid
()
)
return
;
return
;
ExtensionInfoDialog
dlg
(
*
ext
,
p_intf
,
this
);
ExtensionInfoDialog
dlg
(
index
,
p_intf
,
this
);
dlg
.
exec
();
dlg
.
exec
();
}
}
/* Safe copy of the extension_t struct */
/* 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:
switch
(
role
)
ExtensionCopy
(
extension_t
*
p_ext
)
{
{
name
=
qfu
(
p_ext
->
psz_name
);
case
Qt
:
:
DisplayRole
:
description
=
qfu
(
p_ext
->
psz_description
);
return
title
;
shortdesc
=
qfu
(
p_ext
->
psz_shortdescription
);
case
Qt
:
:
DecorationRole
:
if
(
description
.
isEmpty
()
)
return
*
icon
;
description
=
shortdesc
;
case
DescriptionRole
:
if
(
shortdesc
.
isEmpty
()
&&
!
description
.
isEmpty
()
)
return
shortdesc
;
shortdesc
=
description
;
case
VersionRole
:
title
=
qfu
(
p_ext
->
psz_title
);
return
version
;
author
=
qfu
(
p_ext
->
psz_author
);
case
AuthorRole
:
version
=
qfu
(
p_ext
->
psz_version
);
return
author
;
url
=
qfu
(
p_ext
->
psz_url
);
case
LinkRole
:
icon
=
loadPixmapFromData
(
p_ext
->
p_icondata
,
p_ext
->
i_icondata_size
);
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 */
/* Extensions list model for the QListView */
...
@@ -385,17 +405,10 @@ QVariant ExtensionListModel::data( const QModelIndex& index, int role ) const
...
@@ -385,17 +405,10 @@ QVariant ExtensionListModel::data( const QModelIndex& index, int role ) const
if
(
!
index
.
isValid
()
)
if
(
!
index
.
isValid
()
)
return
QVariant
();
return
QVariant
();
switch
(
role
)
ExtensionCopy
*
extension
=
{
static_cast
<
ExtensionCopy
*>
(
index
.
internalPointer
());
case
Qt
:
:
DisplayRole
:
return
((
ExtensionCopy
*
)
index
.
internalPointer
())
->
title
;
return
extension
->
data
(
role
);
case
Qt
:
:
DecorationRole
:
return
*
((
ExtensionCopy
*
)
index
.
internalPointer
())
->
icon
;
case
DescriptionRole
:
return
((
ExtensionCopy
*
)
index
.
internalPointer
())
->
shortdesc
;
default:
return
QVariant
();
}
}
}
QModelIndex
ExtensionListModel
::
index
(
int
row
,
int
column
,
QModelIndex
ExtensionListModel
::
index
(
int
row
,
int
column
,
...
@@ -501,7 +514,7 @@ QSize ExtensionItemDelegate::sizeHint( const QStyleOptionViewItem &option,
...
@@ -501,7 +514,7 @@ QSize ExtensionItemDelegate::sizeHint( const QStyleOptionViewItem &option,
/* "More information" dialog */
/* "More information" dialog */
ExtensionInfoDialog
::
ExtensionInfoDialog
(
const
ExtensionCopy
&
extension
,
ExtensionInfoDialog
::
ExtensionInfoDialog
(
const
QModelIndex
&
index
,
intf_thread_t
*
p_intf
,
intf_thread_t
*
p_intf
,
QWidget
*
parent
)
QWidget
*
parent
)
:
QVLCDialog
(
parent
,
p_intf
)
:
QVLCDialog
(
parent
,
p_intf
)
...
@@ -510,28 +523,25 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
...
@@ -510,28 +523,25 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
setWindowModality
(
Qt
::
WindowModal
);
setWindowModality
(
Qt
::
WindowModal
);
// Window title
// Window title
setWindowTitle
(
qtr
(
"About"
)
+
" "
+
extension
.
title
);
setWindowTitle
(
qtr
(
"About"
)
+
" "
+
index
.
data
(
Qt
::
DisplayRole
).
toString
()
);
// Layout
// Layout
QGridLayout
*
layout
=
new
QGridLayout
(
this
);
QGridLayout
*
layout
=
new
QGridLayout
(
this
);
// Icon
// Icon
QLabel
*
icon
=
new
QLabel
(
this
);
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
);
icon
->
setPixmap
(
pix
);
}
}
else
{
icon
->
setPixmap
(
*
extension
.
icon
);
}
icon
->
setAlignment
(
Qt
::
AlignCenter
);
icon
->
setAlignment
(
Qt
::
AlignCenter
);
icon
->
setFixedSize
(
48
,
48
);
icon
->
setFixedSize
(
48
,
48
);
layout
->
addWidget
(
icon
,
1
,
0
,
2
,
1
);
layout
->
addWidget
(
icon
,
1
,
0
,
2
,
1
);
// Title
// Title
QLabel
*
label
=
new
QLabel
(
extension
.
title
,
this
);
QLabel
*
label
=
new
QLabel
(
index
.
data
(
Qt
::
DisplayRole
).
toString
()
,
this
);
QFont
font
=
label
->
font
();
QFont
font
=
label
->
font
();
font
.
setBold
(
true
);
font
.
setBold
(
true
);
font
.
setPointSizeF
(
font
.
pointSizeF
()
*
1.3
f
);
font
.
setPointSizeF
(
font
.
pointSizeF
()
*
1.3
f
);
...
@@ -541,19 +551,19 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
...
@@ -541,19 +551,19 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
// Version
// Version
label
=
new
QLabel
(
"<b>"
+
qtr
(
"Version"
)
+
":</b>"
,
this
);
label
=
new
QLabel
(
"<b>"
+
qtr
(
"Version"
)
+
":</b>"
,
this
);
layout
->
addWidget
(
label
,
1
,
1
,
1
,
1
,
Qt
::
AlignBottom
);
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
);
layout
->
addWidget
(
label
,
1
,
2
,
1
,
2
,
Qt
::
AlignBottom
);
// Author
// Author
label
=
new
QLabel
(
"<b>"
+
qtr
(
"Author"
)
+
":</b>"
,
this
);
label
=
new
QLabel
(
"<b>"
+
qtr
(
"Author"
)
+
":</b>"
,
this
);
layout
->
addWidget
(
label
,
2
,
1
,
1
,
1
,
Qt
::
AlignTop
);
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
);
layout
->
addWidget
(
label
,
2
,
2
,
1
,
2
,
Qt
::
AlignTop
);
// Description
// Description
label
=
new
QLabel
(
this
);
label
=
new
QLabel
(
this
);
label
->
setText
(
extension
.
description
);
label
->
setText
(
index
.
data
(
ExtensionListModel
::
DescriptionRole
).
toString
()
);
label
->
setWordWrap
(
true
);
label
->
setWordWrap
(
true
);
label
->
setOpenExternalLinks
(
true
);
label
->
setOpenExternalLinks
(
true
);
layout
->
addWidget
(
label
,
4
,
0
,
1
,
-
1
);
layout
->
addWidget
(
label
,
4
,
0
,
1
,
-
1
);
...
@@ -562,7 +572,8 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
...
@@ -562,7 +572,8 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
label
=
new
QLabel
(
"<b>"
+
qtr
(
"Website"
)
+
":</b>"
,
this
);
label
=
new
QLabel
(
"<b>"
+
qtr
(
"Website"
)
+
":</b>"
,
this
);
layout
->
addWidget
(
label
,
5
,
0
,
1
,
2
);
layout
->
addWidget
(
label
,
5
,
0
,
1
,
2
);
label
=
new
QLabel
(
QString
(
"<a href=
\"
%1
\"
>%2</a>"
)
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
);
,
this
);
label
->
setOpenExternalLinks
(
true
);
label
->
setOpenExternalLinks
(
true
);
layout
->
addWidget
(
label
,
5
,
2
,
1
,
-
1
);
layout
->
addWidget
(
label
,
5
,
2
,
1
,
-
1
);
...
@@ -570,7 +581,8 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
...
@@ -570,7 +581,8 @@ ExtensionInfoDialog::ExtensionInfoDialog( const ExtensionCopy& extension,
// Script file
// Script file
label
=
new
QLabel
(
"<b>"
+
qtr
(
"File"
)
+
":</b>"
,
this
);
label
=
new
QLabel
(
"<b>"
+
qtr
(
"File"
)
+
":</b>"
,
this
);
layout
->
addWidget
(
label
,
6
,
0
,
1
,
2
);
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
);
line
->
setReadOnly
(
true
);
layout
->
addWidget
(
line
,
6
,
2
,
1
,
-
1
);
layout
->
addWidget
(
line
,
6
,
2
,
1
,
-
1
);
...
...
modules/gui/qt4/dialogs/plugins.hpp
View file @
dd29c917
...
@@ -132,10 +132,32 @@ class ExtensionListModel : public QAbstractListModel
...
@@ -132,10 +132,32 @@ class ExtensionListModel : public QAbstractListModel
Q_OBJECT
Q_OBJECT
public:
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
);
ExtensionListModel
(
QListView
*
view
,
intf_thread_t
*
p_intf
);
virtual
~
ExtensionListModel
();
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
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
virtual
QModelIndex
index
(
int
row
,
int
column
=
0
,
virtual
QModelIndex
index
(
int
row
,
int
column
=
0
,
const
QModelIndex
&
=
QModelIndex
()
)
const
;
const
QModelIndex
&
=
QModelIndex
()
)
const
;
...
@@ -145,6 +167,7 @@ private slots:
...
@@ -145,6 +167,7 @@ private slots:
void
updateList
();
void
updateList
();
private:
private:
intf_thread_t
*
p_intf
;
intf_thread_t
*
p_intf
;
QList
<
ExtensionCopy
*>
extensions
;
QList
<
ExtensionCopy
*>
extensions
;
};
};
...
@@ -169,7 +192,7 @@ private:
...
@@ -169,7 +192,7 @@ private:
class
ExtensionInfoDialog
:
public
QVLCDialog
class
ExtensionInfoDialog
:
public
QVLCDialog
{
{
public:
public:
ExtensionInfoDialog
(
const
ExtensionCopy
&
extension
,
ExtensionInfoDialog
(
const
QModelIndex
&
index
,
intf_thread_t
*
p_intf
,
QWidget
*
parent
);
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