Commit 66d85b0e authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Bin cleanup

parent 8b803ede
......@@ -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;
}
......
......@@ -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;
......
......@@ -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)
......
......@@ -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*);
......
......@@ -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);
}
......
......@@ -171,7 +171,6 @@ public:
public slots:
//TODO
QPixmap thumbnail(bool force = false);
void updateAudioThumbnail(const audioByteArray& data);
protected:
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment