diff options
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp')
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp | 70 |
1 files changed, 53 insertions, 17 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp index ec35d521..257d2f23 100644 --- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp +++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp @@ -275,27 +275,63 @@ void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo *info){ int num = 0; if(listWidget!=0){ //LIST WIDGET - name and icon only - if(!listWidget->findItems(info->fileName(), Qt::MatchExactly).isEmpty()){ - //Update existing item - QListWidgetItem *it = listWidget->findItems(info->fileName(), Qt::MatchExactly).first(); - it->setText(info->fileName()); - it->setWhatsThis(info->absoluteFilePath()); - it->setIcon(ico); + if(info->isDesktopFile()){ + QList<QListWidgetItem*> items = listWidget->findItems(info->XDG()->name, Qt::MatchExactly); + //Could be multiple items with the same text in this case - check paths as well + bool found = false; + for(int i=0; i<items.length() && !found; i++){ + if(items[i]->whatsThis()==info->absoluteFilePath()){ + found = true; + items[i]->setText(info->XDG()->name); + items[i]->setIcon(ico); + } + } + if(!found){ + //New Item + QListWidgetItem *it = new CQListWidgetItem(ico, info->XDG()->name, listWidget); + it->setWhatsThis(info->absoluteFilePath()); + it->setData(Qt::UserRole, (info->isDir() ? "dir" : "file")); //used for sorting + listWidget->addItem(it); + } }else{ - //New item - QListWidgetItem *it = new CQListWidgetItem(ico, info->fileName(), listWidget); + //non-desktop entry + if(!listWidget->findItems(info->fileName(), Qt::MatchExactly).isEmpty()){ + //Update existing item + QListWidgetItem *it = listWidget->findItems(info->fileName(), Qt::MatchExactly).first(); + it->setText(info->fileName()); it->setWhatsThis(info->absoluteFilePath()); - it->setData(Qt::UserRole, (info->isDir() ? "dir" : "file")); //used for sorting - listWidget->addItem(it); - } - num = listWidget->count(); + it->setIcon(ico); + + }else{ + //New item + QListWidgetItem *it = new CQListWidgetItem(ico, info->fileName(), listWidget); + it->setWhatsThis(info->absoluteFilePath()); + it->setData(Qt::UserRole, (info->isDir() ? "dir" : "file")); //used for sorting + listWidget->addItem(it); + } + num = listWidget->count(); + } //end non-desktop entry }else if(treeWidget!=0){ QTreeWidgetItem *it = 0; - if( ! treeWidget->findItems(info->fileName(), Qt::MatchExactly, 0).isEmpty() ){ it = treeWidget->findItems(info->fileName(), Qt::MatchExactly, 0).first(); } - else{ - it = new CQTreeWidgetItem(treeWidget); - it->setText(0, info->fileName() ); //name (0) - treeWidget->addTopLevelItem(it); + if(info->isDesktopFile()){ + QList<QTreeWidgetItem*> items = treeWidget->findItems(info->XDG()->name, Qt::MatchExactly, 0); + for(int i=0; i<items.length() && it==0; i++){ + //Can be multiple with the same name - check paths too + if(items[i]->whatsThis(0)==info->absoluteFilePath()){ it = items[i]; } + } + if(it==0){ + //New item + it = new CQTreeWidgetItem(treeWidget); + it->setText(0, info->XDG()->name ); //name (0) + treeWidget->addTopLevelItem(it); + } + }else{ + if( ! treeWidget->findItems(info->fileName(), Qt::MatchExactly, 0).isEmpty() ){ it = treeWidget->findItems(info->fileName(), Qt::MatchExactly, 0).first(); } + else{ + it = new CQTreeWidgetItem(treeWidget); + it->setText(0, info->fileName() ); //name (0) + treeWidget->addTopLevelItem(it); + } } //Now set/update all the data it->setIcon(0, ico); |