aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-01-11 19:05:44 +0100
committerJean-Baptiste Mardelle <[email protected]>2015-01-11 19:05:44 +0100
commit66d85b0e8bd4f04eb10d13488b943e505a144d90 (patch)
treec28df049e5ebe7896b48948c381837a2e7e70b5b
parent8b803ede3ff8795d8d6fa8467b8b085e4210e92b (diff)
Bin cleanup
-rw-r--r--src/bin/abstractprojectitem.cpp3
-rw-r--r--src/bin/abstractprojectitem.h5
-rw-r--r--src/bin/bin.cpp35
-rw-r--r--src/bin/bin.h2
-rw-r--r--src/bin/projectclip.cpp20
-rw-r--r--src/bin/projectclip.h1
-rw-r--r--src/bin/projectfolder.cpp2
-rw-r--r--src/bin/projectitemmodel.cpp2
-rw-r--r--src/dialogs/clipcreationdialog.cpp1
9 files changed, 44 insertions, 27 deletions
diff --git a/src/bin/abstractprojectitem.cpp b/src/bin/abstractprojectitem.cpp
index 44b2666..51a1051 100644
--- a/src/bin/abstractprojectitem.cpp
+++ b/src/bin/abstractprojectitem.cpp
@@ -207,6 +207,9 @@ QVariant AbstractProjectItem::data(DataType type) const
case ClipToolTip:
data = QVariant(getToolTip());
break;
+ case DataId:
+ data = QVariant(m_id);
+ break;
default:
break;
}
diff --git a/src/bin/abstractprojectitem.h b/src/bin/abstractprojectitem.h
index 27d6207..8869715 100644
--- a/src/bin/abstractprojectitem.h
+++ b/src/bin/abstractprojectitem.h
@@ -118,7 +118,8 @@ public:
enum DataType {
DataName = Qt::DisplayRole,
DataThumbnail = Qt::DecorationRole,
- DataDescription = Qt::UserRole,
+ DataId = Qt::UserRole,
+ DataDescription,
DataDate,
ItemTypeRole,
DataDuration,
@@ -177,7 +178,7 @@ protected:
AbstractProjectItem *m_parent;
QString m_name;
QString m_description;
- QPixmap m_thumbnail;
+ QIcon m_thumbnail;
QString m_duration;
QPoint m_zone;
QString m_id;
diff --git a/src/bin/bin.cpp b/src/bin/bin.cpp
index c4a60bc..f47863c 100644
--- a/src/bin/bin.cpp
+++ b/src/bin/bin.cpp
@@ -205,7 +205,11 @@ Monitor *Bin::monitor()
const QStringList Bin::getFolderInfo()
{
QStringList folderInfo;
- QModelIndex ix = m_proxyModel->selectionModel()->currentIndex();
+ QModelIndexList indexes = m_proxyModel->selectionModel()->selectedIndexes();
+ if (indexes.isEmpty()) {
+ return folderInfo;
+ }
+ QModelIndex ix = indexes.first();
if (ix.isValid() && m_proxyModel->selectionModel()->isSelected(ix)) {
AbstractProjectItem *currentItem = static_cast<AbstractProjectItem *>(m_proxyModel->mapToSource(ix).internalPointer());
while (!currentItem->isFolder()) {
@@ -214,8 +218,8 @@ const QStringList Bin::getFolderInfo()
if (currentItem == m_rootFolder) {
// clip was added to root folder, leave folder info empty
} else {
- folderInfo << currentItem->name();
folderInfo << currentItem->clipId();
+ folderInfo << currentItem->name();
}
}
return folderInfo;
@@ -382,11 +386,30 @@ void Bin::slotAddFolder()
QString newId = QString::number(getFreeFolderId());
AddBinFolderCommand *command = new AddBinFolderCommand(this, newId, i18n("Folder"), parentFolder->clipId());
m_doc->commandStack()->push(command);
-
+
// Edit folder name
- QModelIndexList indexes = m_proxyModel->selectionModel()->selectedIndexes();
- if (indexes.isEmpty()) return;
- m_itemView->edit(indexes.first());
+ ix = getIndexForId(newId, true);
+ if (ix.isValid()) {
+ m_proxyModel->selectionModel()->select(m_proxyModel->mapFromSource(ix), QItemSelectionModel::ClearAndSelect);
+ m_itemView->edit(m_proxyModel->mapFromSource(ix));
+ }
+}
+
+QModelIndex Bin::getIndexForId(const QString &id, bool folderWanted) const
+{
+ QModelIndexList items = m_itemModel->match(m_itemModel->index(0, 0), AbstractProjectItem::DataId, QVariant::fromValue(id), 2, Qt::MatchRecursive);
+ for (int i = 0; i < items.count(); i++) {
+ AbstractProjectItem *currentItem = static_cast<AbstractProjectItem *>(items.at(i).internalPointer());
+ if (folderWanted && currentItem->isFolder()) {
+ // We found our folder
+ return items.at(i);
+ }
+ else if (!folderWanted && !currentItem->isFolder()) {
+ // We found our clip
+ return items.at(i);
+ }
+ }
+ return QModelIndex();
}
void Bin::doAddFolder(const QString &id, const QString &name, const QString &parentId)
diff --git a/src/bin/bin.h b/src/bin/bin.h
index e370271..2797c06 100644
--- a/src/bin/bin.h
+++ b/src/bin/bin.h
@@ -387,6 +387,8 @@ private:
void showClipProperties(ProjectClip *clip);
void selectModel(const QModelIndex &id);
const QStringList getFolderInfo();
+ /** @brief Get the QModelIndex value for an item in the Bin. */
+ QModelIndex getIndexForId(const QString &id, bool folderWanted) const;
signals:
void itemUpdated(AbstractProjectItem*);
diff --git a/src/bin/projectclip.cpp b/src/bin/projectclip.cpp
index 618e830..3ca18e2 100644
--- a/src/bin/projectclip.cpp
+++ b/src/bin/projectclip.cpp
@@ -203,25 +203,14 @@ QDomElement ProjectClip::toXml(QDomDocument& document)
return QDomElement();
}
-QPixmap ProjectClip::thumbnail(bool force)
-{
-/* if ((force || m_thumbnail.isNull()) && m_baseProducer) {
- int width = 80 * bin()->project()->displayRatio();
- if (width % 2 == 1) width++;
- bin()->project()->monitorManager()->requestThumbnails(m_id, QList <int>() << 0);
- }
- */
- return m_thumbnail;
-}
-
void ProjectClip::setThumbnail(QImage img)
{
- m_thumbnail = roundedPixmap(QPixmap::fromImage(img));
- if (hasProxy() && !m_thumbnail.isNull()) {
+ QPixmap thumb = roundedPixmap(QPixmap::fromImage(img));
+ if (hasProxy() && !thumb.isNull()) {
// Overlay proxy icon
- QPainter p(&m_thumbnail);
+ QPainter p(&thumb);
QColor c(220, 220, 10, 200);
- QRect r(0, 0, m_thumbnail.height() / 2.5, m_thumbnail.height() / 2.5);
+ QRect r(0, 0, thumb.height() / 2.5, thumb.height() / 2.5);
p.fillRect(r, c);
QFont font = p.font();
font.setPixelSize(r.height());
@@ -230,6 +219,7 @@ void ProjectClip::setThumbnail(QImage img)
p.setPen(Qt::black);
p.drawText(r, Qt::AlignCenter, i18nc("The first letter of Proxy, used as abbreviation", "P"));
}
+ m_thumbnail = QIcon(thumb);
bin()->emitItemUpdated(this);
}
diff --git a/src/bin/projectclip.h b/src/bin/projectclip.h
index 87cfef1..ec7dfb3 100644
--- a/src/bin/projectclip.h
+++ b/src/bin/projectclip.h
@@ -171,7 +171,6 @@ public:
public slots:
//TODO
- QPixmap thumbnail(bool force = false);
void updateAudioThumbnail(const audioByteArray& data);
protected:
diff --git a/src/bin/projectfolder.cpp b/src/bin/projectfolder.cpp
index 2d08af3..be2144c 100644
--- a/src/bin/projectfolder.cpp
+++ b/src/bin/projectfolder.cpp
@@ -34,7 +34,7 @@ ProjectFolder::ProjectFolder(const QString &id, const QString &name, ProjectFold
//loadChildren(description);
m_name = name;
m_clipStatus = StatusReady;
- m_thumbnail = QIcon::fromTheme("folder").pixmap(40, 40);
+ m_thumbnail = QIcon::fromTheme("folder");
setParent(parent);
}
diff --git a/src/bin/projectitemmodel.cpp b/src/bin/projectitemmodel.cpp
index 5a4d4c2..99f5601 100644
--- a/src/bin/projectitemmodel.cpp
+++ b/src/bin/projectitemmodel.cpp
@@ -66,7 +66,7 @@ QVariant ProjectItemModel::data(const QModelIndex& index, int role) const
if (role == Qt::DecorationRole && index.column() == 0) {
// Data has to be returned as icon to allow the view to scale it
AbstractProjectItem *item = static_cast<AbstractProjectItem *>(index.internalPointer());
- QIcon icon = QIcon(item->data(AbstractProjectItem::DataThumbnail).value<QPixmap>());
+ QIcon icon = item->data(AbstractProjectItem::DataThumbnail).value<QIcon>();
if (icon.isNull()) {
QPixmap pix(m_iconSize);
pix.fill(Qt::lightGray);
diff --git a/src/dialogs/clipcreationdialog.cpp b/src/dialogs/clipcreationdialog.cpp
index 46bd6d4..2e23dc6 100644
--- a/src/dialogs/clipcreationdialog.cpp
+++ b/src/dialogs/clipcreationdialog.cpp
@@ -354,7 +354,6 @@ void ClipCreationDialogDialog::createClipsCommand(KdenliveDoc *doc, QStringList
int count = list.count();
if (count > 1) {
delete d;
- /*QStringList groupInfo = getGroup(); */
// get image sequence base name
while (fileName.at(fileName.size() - 1).isDigit()) {
fileName.chop(1);