]> git.sesse.net Git - kdenlive/commitdiff
Fix proxy problem with too fast computers (item not in layout when trying to update it)
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 12 Feb 2011 21:26:36 +0000 (21:26 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 12 Feb 2011 21:26:36 +0000 (21:26 +0000)
svn path=/trunk/kdenlive/; revision=5394

src/projectitem.cpp
src/projectitem.h
src/projectlist.cpp
src/projectlistview.cpp
src/projectlistview.h

index 9de4b8e814f0170019b87e9e5b26209d2d62138f..bf02065b2d8a4be2169d661b0b26d1e246c7c55b 100644 (file)
@@ -32,33 +32,27 @@ const int ProxyRole = Qt::UserRole + 5;
 const int itemHeight = 38;
 
 ProjectItem::ProjectItem(QTreeWidget * parent, DocClipBase *clip) :
+        m_clip(clip),
+        m_clipId(clip->getId()),
         QTreeWidgetItem(parent, PROJECTCLIPTYPE)
 {
-    setSizeHint(0, QSize(itemHeight * 3, itemHeight));
-    if (clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
-    else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
-    m_clip = clip;
-    m_clipId = clip->getId();
-    QString name = m_clip->getProperty("name");
-    if (name.isEmpty()) name = KUrl(m_clip->getProperty("resource")).fileName();
-    m_clipType = (CLIPTYPE) m_clip->getProperty("type").toInt();
-    if (m_clipType != UNKNOWN) slotSetToolTip();
-    setText(0, name);
-    setText(1, m_clip->description());
-    GenTime duration = m_clip->duration();
-    if (duration != GenTime()) setData(0, DurationRole, Timecode::getEasyTimecode(duration, KdenliveSettings::project_fps()));
-    //setFlags(Qt::NoItemFlags);
-    //kDebug() << "Constructed with clipId: " << m_clipId;
+    buildItem();
 }
 
 ProjectItem::ProjectItem(QTreeWidgetItem * parent, DocClipBase *clip) :
+        m_clip(clip),
+        m_clipId(clip->getId()),
         QTreeWidgetItem(parent, PROJECTCLIPTYPE)
+        
+{
+    buildItem();
+}
+
+void ProjectItem::buildItem()
 {
     setSizeHint(0, QSize(itemHeight * 3, itemHeight));
-    if (clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
+    if (m_clip->isPlaceHolder()) setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
     else setFlags(Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDropEnabled);
-    m_clip = clip;
-    m_clipId = clip->getId();
     QString name = m_clip->getProperty("name");
     if (name.isEmpty()) name = KUrl(m_clip->getProperty("resource")).fileName();
     m_clipType = (CLIPTYPE) m_clip->getProperty("type").toInt();
@@ -66,11 +60,8 @@ ProjectItem::ProjectItem(QTreeWidgetItem * parent, DocClipBase *clip) :
     setText(1, m_clip->description());
     GenTime duration = m_clip->duration();
     if (duration != GenTime()) setData(0, DurationRole, Timecode::getEasyTimecode(duration, KdenliveSettings::project_fps()));
-    //setFlags(Qt::NoItemFlags);
-    //kDebug() << "Constructed with clipId: " << m_clipId;
 }
 
-
 ProjectItem::~ProjectItem()
 {
 }
index 3e50a07d5a05729f1c8ea5157b7a11469f575e21..c4e5b1bc8e039f1c63d74c67f6299525eadf115b 100644 (file)
@@ -82,6 +82,8 @@ private:
     QString m_clipId;
     DocClipBase *m_clip;
 
+    void buildItem();
+
 };
 
 #endif
index 60be5446e882a16cf00f18451913d0396da5e60c..f93eb5c985aac44fbf4c14ea70ba80f9a26bc194 100644 (file)
@@ -960,11 +960,12 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
         if (parentitem)
             item = new ProjectItem(parentitem, clip);
     }
-    if (item == NULL)
+    if (item == NULL) {
         item = new ProjectItem(m_listView, clip);
+    }
     if (item->data(0, DurationRole).isNull()) item->setData(0, DurationRole, i18n("Loading"));
     if (getProperties) {
-        qApp->processEvents();
+        m_listView->processLayout();
         m_refreshed = false;
         // Proxy clips
         CLIPTYPE t = clip->clipType();
@@ -1731,6 +1732,7 @@ ProjectItem *ProjectList::getItemById(const QString &id)
 {
     ProjectItem *item;
     QTreeWidgetItemIterator it(m_listView);
+    kDebug()<<"-----------------  GET IT BY ID: "<<id;
     while (*it) {
         if ((*it)->type() != PROJECTCLIPTYPE) {
             // subitem or folder
@@ -1738,6 +1740,7 @@ ProjectItem *ProjectList::getItemById(const QString &id)
             continue;
         }
         item = static_cast<ProjectItem *>(*it);
+        kDebug()<<"/// /// PARSING ITEM............."<<item->clipId()<<"-"<<item->text(0);
         if (item->clipId() == id)
             return item;
         ++it;
index af8ccc2011f25ec30bea37f9fac6866038b58b3f..c6d6c40a757cea1070ed511f2b1f07e3e9893c70 100644 (file)
@@ -70,6 +70,11 @@ ProjectListView::~ProjectListView()
 {
 }
 
+void ProjectListView::processLayout()
+{
+    executeDelayedItemsLayout();
+}
+
 void ProjectListView::configureColumns(const QPoint& pos)
 {
     KMenu popup(this);
index 1c0824f902b149c5dee665f8b7bed25c10ca0cb9..62a632e677d2c6b6d4ba78eb984e51b82683aad4 100644 (file)
@@ -36,6 +36,7 @@ class ProjectListView : public QTreeWidget
 public:
     ProjectListView(QWidget *parent = 0);
     virtual ~ProjectListView();
+    void processLayout();
 
 protected:
     virtual void contextMenuEvent(QContextMenuEvent * event);