aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-06-04 00:12:05 +0200
committerJean-Baptiste Mardelle <[email protected]>2015-06-04 00:12:05 +0200
commit555119fe9555597ce08ee9904eaafcf1b886c6eb (patch)
tree06b207e91e0c6f918adf6cfc81f4083e67f38171
parent8b3895c919285a8030bfd1195fb4a63333f3a038 (diff)
Add date & description(useless for now) columns
-rw-r--r--src/bin/abstractprojectitem.cpp6
-rw-r--r--src/bin/abstractprojectitem.h11
-rw-r--r--src/bin/bin.cpp43
-rw-r--r--src/bin/bin.h7
-rw-r--r--src/bin/projectclip.cpp2
-rw-r--r--src/bin/projectitemmodel.cpp39
-rw-r--r--src/bin/projectitemmodel.h2
-rw-r--r--src/bin/projectsortproxymodel.cpp5
-rw-r--r--src/mltcontroller/clipcontroller.cpp2
-rw-r--r--src/mltcontroller/clipcontroller.h6
10 files changed, 104 insertions, 19 deletions
diff --git a/src/bin/abstractprojectitem.cpp b/src/bin/abstractprojectitem.cpp
index e1631b8..4a913bd 100644
--- a/src/bin/abstractprojectitem.cpp
+++ b/src/bin/abstractprojectitem.cpp
@@ -167,6 +167,7 @@ AbstractProjectItem::PROJECTITEMTYPE AbstractProjectItem::itemType() const
QVariant AbstractProjectItem::data(DataType type) const
{
QVariant data;
+ QLocale locale;
switch (type) {
case SortRole:
if (m_itemType == SubClipItem) data = QVariant(m_duration);
@@ -184,6 +185,9 @@ QVariant AbstractProjectItem::data(DataType type) const
case DataDuration:
data = QVariant(m_duration);
break;
+ case DataDate:
+ data = QVariant(m_date);
+ break;
case ItemTypeRole:
data = QVariant(m_itemType);
break;
@@ -213,7 +217,7 @@ QVariant AbstractProjectItem::data(DataType type) const
int AbstractProjectItem::supportedDataCount() const
{
- return 1;
+ return 3;
}
QString AbstractProjectItem::name() const
diff --git a/src/bin/abstractprojectitem.h b/src/bin/abstractprojectitem.h
index 6dc5dab..d299267 100644
--- a/src/bin/abstractprojectitem.h
+++ b/src/bin/abstractprojectitem.h
@@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QObject>
#include <QPixmap>
-
+#include <QDateTime>
class ProjectClip;
class ProjectFolder;
@@ -119,18 +119,18 @@ public:
enum DataType {
DataName = Qt::DisplayRole,
DataThumbnail = Qt::DecorationRole,
+ ClipToolTip = Qt::ToolTipRole,
DataId = Qt::UserRole,
- SortRole,
- DataDescription,
DataDate,
+ DataDescription,
+ SortRole,
IconOverlay,
ItemTypeRole,
DataDuration,
JobType,
JobProgress,
JobMessage,
- ClipStatus,
- ClipToolTip = Qt::ToolTipRole
+ ClipStatus
};
enum CLIPSTATUS {
@@ -183,6 +183,7 @@ protected:
QString m_description;
QIcon m_thumbnail;
QString m_duration;
+ QDateTime m_date;
QString m_id;
CLIPSTATUS m_clipStatus;
AbstractClipJob::JOBTYPE m_jobType;
diff --git a/src/bin/bin.cpp b/src/bin/bin.cpp
index 4051d2b..5db51af 100644
--- a/src/bin/bin.cpp
+++ b/src/bin/bin.cpp
@@ -291,6 +291,16 @@ Bin::Bin(QWidget* parent) :
sliderMenu->setIcon(QIcon::fromTheme("file-zoom-in"));
sliderMenu->addAction(widgetslider);
settingsMenu->addMenu(sliderMenu);
+
+ // Column show / hide actions
+ m_showDate = new QAction(i18n("Show date"), this);
+ m_showDate->setCheckable(true);
+ connect(m_showDate, SIGNAL(triggered(bool)), this, SLOT(slotShowDateColumn(bool)));
+ m_showDesc = new QAction(i18n("Show description"), this);
+ m_showDesc->setCheckable(true);
+ connect(m_showDesc, SIGNAL(triggered(bool)), this, SLOT(slotShowDescColumn(bool)));
+ settingsMenu->addAction(m_showDate);
+ settingsMenu->addAction(m_showDesc);
QToolButton *button = new QToolButton;
button->setIcon(QIcon::fromTheme("configure"));
button->setMenu(settingsMenu);
@@ -899,13 +909,17 @@ void Bin::slotInitView(QAction *action)
m_itemView->setItemDelegate(m_binTreeViewDelegate);
QTreeView *view = static_cast<QTreeView*>(m_itemView);
view->setSortingEnabled(true);
- view->setHeaderHidden(true);
+ connect(m_proxyModel, SIGNAL(layoutAboutToBeChanged()), this, SLOT(slotSetSorting()));
+ m_proxyModel->setDynamicSortFilter(true);
if (!m_headerInfo.isEmpty()) {
view->header()->restoreState(m_headerInfo);
} else {
view->header()->resizeSections(QHeaderView::ResizeToContents);
+ view->resizeColumnToContents(0);
+ view->setColumnHidden(2, true);
}
- view->resizeColumnToContents(0);
+ m_showDate->setChecked(!view->isColumnHidden(1));
+ m_showDesc->setChecked(!view->isColumnHidden(2));
connect(view->header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(slotSaveHeaders()));
}
else if (m_listType == BinIconView) {
@@ -2099,3 +2113,28 @@ void Bin::slotAbortAudioThumb(const QString &id)
clip->abortAudioThumbs();
}
+void Bin::slotSetSorting()
+{
+ QTreeView *view = static_cast<QTreeView*>(m_itemView);
+ if (view) {
+ int ix = view->header()->sortIndicatorSection();
+ m_proxyModel->setFilterKeyColumn(ix);
+ }
+}
+
+void Bin::slotShowDateColumn(bool show)
+{
+ QTreeView *view = static_cast<QTreeView*>(m_itemView);
+ if (view) {
+ view->setColumnHidden(1, !show);
+ }
+}
+
+void Bin::slotShowDescColumn(bool show)
+{
+ QTreeView *view = static_cast<QTreeView*>(m_itemView);
+ if (view) {
+ view->setColumnHidden(2, !show);
+ }
+}
+
diff --git a/src/bin/bin.h b/src/bin/bin.h
index d026df1..9665aed 100644
--- a/src/bin/bin.h
+++ b/src/bin/bin.h
@@ -435,6 +435,11 @@ public:
private slots:
void slotAddClip();
void slotReloadClip();
+ /** @brief Set sorting column */
+ void slotSetSorting();
+ /** @brief Show/hide date column */
+ void slotShowDateColumn(bool show);
+ void slotShowDescColumn(bool show);
/** @brief Setup the bin view type (icon view, tree view, ...).
* @param action The action whose data defines the view type or NULL to keep default view */
@@ -521,6 +526,8 @@ private:
QMenu *m_extractAudioAction;
QMenu *m_transcodeAction;
QMenu *m_clipsActionsMenu;
+ QAction *m_showDate;
+ QAction *m_showDesc;
QSplitter *m_splitter;
/** @brief Holds an available unique id for a clip to be created */
int m_clipCounter;
diff --git a/src/bin/projectclip.cpp b/src/bin/projectclip.cpp
index bc2b5b7..95475fd 100644
--- a/src/bin/projectclip.cpp
+++ b/src/bin/projectclip.cpp
@@ -53,6 +53,7 @@ ProjectClip::ProjectClip(const QString &id, QIcon thumb, ClipController *control
m_thumbnail = thumb;
m_name = m_controller->clipName();
m_duration = m_controller->getStringDuration();
+ m_date = m_controller->date;
getFileHash();
setParent(parent);
bin()->loadSubClips(id, m_controller->getSubClips());
@@ -268,6 +269,7 @@ void ProjectClip::setProducer(ClipController *controller, bool replaceProducer)
m_controller = controller;
if (m_name.isEmpty()) m_name = m_controller->clipName();
m_duration = m_controller->getStringDuration();
+ m_date = m_controller->date;
m_temporaryUrl.clear();
}
m_clipStatus = StatusReady;
diff --git a/src/bin/projectitemmodel.cpp b/src/bin/projectitemmodel.cpp
index 4af7288..1afb422 100644
--- a/src/bin/projectitemmodel.cpp
+++ b/src/bin/projectitemmodel.cpp
@@ -47,6 +47,23 @@ ProjectItemModel::~ProjectItemModel()
{
}
+int ProjectItemModel::mapToColumn(int column) const
+{
+ switch (column) {
+ case 0:
+ return AbstractProjectItem::DataName;
+ break;
+ case 1:
+ return AbstractProjectItem::DataDate;
+ break;
+ case 2:
+ return AbstractProjectItem::DataDescription;
+ break;
+ default:
+ return AbstractProjectItem::DataName;
+ }
+}
+
QVariant ProjectItemModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid()) {
@@ -54,9 +71,12 @@ QVariant ProjectItemModel::data(const QModelIndex& index, int role) const
}
if (role == Qt::DisplayRole || role == Qt::EditRole) {
AbstractProjectItem *item = static_cast<AbstractProjectItem *>(index.internalPointer());
- return item->data(static_cast<AbstractProjectItem::DataType>(index.column()));
+ return item->data(static_cast<AbstractProjectItem::DataType>(mapToColumn(index.column())));
}
- if (role == Qt::DecorationRole && index.column() == 0) {
+ if (role == Qt::DecorationRole) {
+ if (index.column() != 0) {
+ return QVariant();
+ }
// Data has to be returned as icon to allow the view to scale it
AbstractProjectItem *item = static_cast<AbstractProjectItem *>(index.internalPointer());
QIcon icon = item->data(AbstractProjectItem::DataThumbnail).value<QIcon>();
@@ -141,23 +161,22 @@ QVariant ProjectItemModel::headerData(int section, Qt::Orientation orientation,
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
QVariant columnName;
- switch ((AbstractProjectItem::DataType)section) {
- case AbstractProjectItem::DataName:
+ switch (section) {
+ case 0:
columnName = i18n("Name");
break;
- case AbstractProjectItem::DataDescription:
- columnName = i18n("Description");
- break;
- case AbstractProjectItem::DataDate:
+ case 1:
columnName = i18n("Date");
break;
+ case 2:
+ columnName = i18n("Description");
+ break;
default:
columnName = i18n("Unknown");
break;
}
return columnName;
}
-
return QAbstractItemModel::headerData(section, orientation, role);
}
@@ -242,7 +261,7 @@ QMimeData* ProjectItemModel::mimeData(const QModelIndexList& indices) const
QStringList list;
for (int i = 0; i < indices.count(); i++) {
QModelIndex ix = indices.at(i);
- if (!ix.isValid()) continue;
+ if (!ix.isValid() || !ix.column() == 0) continue;
AbstractProjectItem *item = static_cast<AbstractProjectItem*>(ix.internalPointer());
AbstractProjectItem::PROJECTITEMTYPE type = item->itemType();
if (type == AbstractProjectItem::ClipItem) {
diff --git a/src/bin/projectitemmodel.h b/src/bin/projectitemmodel.h
index 3906908..f311925 100644
--- a/src/bin/projectitemmodel.h
+++ b/src/bin/projectitemmodel.h
@@ -83,6 +83,8 @@ public slots:
private:
/** @brief Reference to the project bin */
Bin *m_bin;
+ /** @brief Return reference to column specific data */
+ int mapToColumn(int column) const;
signals:
//TODO
diff --git a/src/bin/projectsortproxymodel.cpp b/src/bin/projectsortproxymodel.cpp
index 930e885..275b903 100644
--- a/src/bin/projectsortproxymodel.cpp
+++ b/src/bin/projectsortproxymodel.cpp
@@ -86,6 +86,11 @@ bool ProjectSortProxyModel::lessThan(const QModelIndex & left, const QModelIndex
int rightType = sourceModel()->data(right, AbstractProjectItem::ItemTypeRole).toInt();
if (leftType == rightType) {
// Let the normal alphabetical sort happen
+ QVariant leftData = sourceModel()->data(left, Qt::DisplayRole);
+ QVariant rightData = sourceModel()->data(right, Qt::DisplayRole);
+ if (leftData.type() == QVariant::DateTime) {
+ return leftData.toDateTime() < rightData.toDateTime();
+ }
return QSortFilterProxyModel::lessThan(right, left);
}
return leftType > rightType;
diff --git a/src/mltcontroller/clipcontroller.cpp b/src/mltcontroller/clipcontroller.cpp
index 6f59b9b..327c1a1 100644
--- a/src/mltcontroller/clipcontroller.cpp
+++ b/src/mltcontroller/clipcontroller.cpp
@@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QUrl>
#include <QDebug>
#include <QPixmap>
+#include <QFileInfo>
#include <KLocalizedString>
@@ -118,6 +119,7 @@ void ClipController::getProducerXML(QDomDocument& document)
void ClipController::getInfoForProducer()
{
+ date = QFileInfo(m_properties->get("resource")).created();
m_audioIndex = int_property("audio_index");
m_videoIndex = int_property("video_index");
if (m_service == "avformat" || m_service == "avformat-novalidate") {
diff --git a/src/mltcontroller/clipcontroller.h b/src/mltcontroller/clipcontroller.h
index fab64a7..3d00b7a 100644
--- a/src/mltcontroller/clipcontroller.h
+++ b/src/mltcontroller/clipcontroller.h
@@ -29,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QString>
#include <QObject>
#include <QUrl>
+#include <QDateTime>
class QPixmap;
class BinController;
@@ -62,6 +63,9 @@ public:
/** @brief Returns true if the master producer is valid */
bool isValid();
+ /** @brief Stores the file's creation time */
+ QDateTime date;
+
/** @brief Replaces the master producer and (TODO) the track producers with an updated producer, for example a proxy */
void updateProducer(const QString &id, Mlt::Producer *producer);
@@ -85,7 +89,7 @@ public:
/** @brief Returns the clip's type as defined in definitions.h */
ClipType clipType() const;
-
+
/** @brief Returns the clip's duration */
GenTime getPlaytime() const;
/**