This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
ThumbnailListwidget.cpp
108 lines (97 loc) · 2.66 KB
/
ThumbnailListwidget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/***************************************************************************//**
* @brief Thumbnail me 3.0
* Thumbnail me is a user interface for Movie thumbnailer.
* Generate thumbnails from any movie is now easier !
*
* @file ThumbnailListwidget.h
* @class ThumbnailListwidget
* QListWidget de ThumbnailItem.
*
* @author Quentin Rousseau\n
* @note Copyright (C) 2011-2012 Quentin Rousseau\n
* License: GNU General Public License version 2 (GPLv2) - http://www.gnu.org/licenses/gpl-2.0.html\n
* Site web: www.thumbnailme.com\n
* Email: quentin.rousseau@thumbnailme.com
*
* @since 3.0
* @version 3.0
* @date 2011-2012
*******************************************************************************/
#include "ThumbnailListwidget.h"
#include "defines.h"
#include "QtHelper.h"
#include "ThumbnailItem.h"
/**
*@brief Constructeur.
*/
ThumbnailListWidget::ThumbnailListWidget(QWidget * parent) : QListWidget(parent)
{
this->setDragDropMode(QAbstractItemView::NoDragDrop);
this->setSelectionMode(QAbstractItemView::ExtendedSelection);
}
/**
*@brief Destructeur.
*/
ThumbnailListWidget::~ThumbnailListWidget()
{
}
/**
*@brief KeyPressEvent.
*@param e Evenement.
*/
void ThumbnailListWidget::keyPressEvent ( QKeyEvent * e )
{
if (e->key() == Qt::Key_Delete)
{
emit itemDeleted();
}
QListWidget::keyPressEvent(e);
}
/**
*@brief Ajout d'un ThumbnailItem.
*@param item Item à ajouter.
*/
void ThumbnailListWidget::addItem(ThumbnailItem* item)
{
QListWidget::addItem(item);
}
/**
*@brief Création et ajout d'un ThumbnailItem.
*@param item Item à ajouter.
*/
void ThumbnailListWidget::addItem(QString item)
{
ThumbnailItem *i = new ThumbnailItem(QUrl(item));
QListWidget::addItem(i);
}
/**
*@brief Création et ajout de ThumbnailItem.
*@param items Items à ajouter.
*/
void ThumbnailListWidget::addItems(QStringList items)
{
foreach(QString path, items)
{
this->addItem(path);
}
this->setCurrentRow(0,QItemSelectionModel::SelectCurrent);
}
/**
*@brief Retourne la liste des ThumbnailItem.
*@return QLinkedList <ThumbnailItem*> - Liste des ThumbnailItem.
*/
QLinkedList <ThumbnailItem*> ThumbnailListWidget::getItemsListWidget()
{
QLinkedList <ThumbnailItem*> l;
for(int i = 0 ; i < this->count() ; i++)
l << static_cast <ThumbnailItem*> (this->item(i));
return l;
}
/**
*@brief Supprime les items sélectionnés
*/
void ThumbnailListWidget::removeItemSelection()
{
if(!QtHelper::removeSelectedItems(qobject_cast<QListWidget *>(this)))
QMessageBox::information(this, _ERROR_, tr("You must select a file to remove it from the list"));
}