diff options
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp')
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp index 12fd36fe..e6017e77 100644 --- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp +++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp @@ -5,17 +5,21 @@ // See the LICENSE file for full details //=========================================== #include "BrowserWidget.h" + +#include <QVBoxLayout> +#include <QTimer> + BrowserWidget::BrowserWidget(QString objID, QWidget *parent) : QWidget(parent){ //Setup the Widget/UI this->setLayout( new QVBoxLayout(this) ); - + this->setWhatsThis(objID); //Setup the backend browser object BROWSER = new Browser(this); connect(BROWSER, SIGNAL(clearItems()), this, SLOT(clearItems()) ); connect(BROWSER, SIGNAL(itemUpdated(QString)), this, SLOT(itemUpdated(QString)) ); - connect(BROWSER, SIGNAL(itemUpdated(QString)), this, SLOT(itemUpdated(QString)) ); - connect(BROWSER, SIGNAL(itemUpdated(QString)), this, SLOT(itemUpdated(QString)) ); - + connect(BROWSER, SIGNAL(itemDataAvailable(QIcon, LFileInfo)), this, SLOT(itemDataAvailable(QIcon, LFileInfo)) ); + connect(BROWSER, SIGNAL(itemsLoading(int)), this, SLOT(itemsLoading(int)) ); + connect(this, SIGNAL(dirChange(QString)), BROWSER, SLOT(loadDirectory(QString)) ); listWidget = 0; treeWidget = 0; } @@ -26,7 +30,33 @@ BrowserWidget::~BrowserWidget(){ void BrowserWidget::changeDirectory(QString dir){ if(BROWSER->currentDirectory()==dir){ return; } //already on this directory - BROWSER->loadDirectory(dir); + emit dirChange(dir); +} + +void BrowserWidget::showDetails(bool show){ + //Clean up widgets first + if(show && listWidget!=0){ + //Clean up list widget + listWidget->deleteLater(); + listWidget = 0; + }else if(!show && treeWidget!=0){ + treeWidget->deleteLater(); + treeWidget = 0; + } + //Now create any new widgets + if(show && treeWidget == 0){ + treeWidget = new DDTreeWidget(this); + this->layout()->addWidget(treeWidget); + if(!BROWSER->currentDirectory().isEmpty()){ emit dirChange(""); } + }else if(!show && listWidget==0){ + listWidget = new DDListWidget(this); + this->layout()->addWidget(listWidget); + if(!BROWSER->currentDirectory().isEmpty()){ emit dirChange(""); } + } +} + +bool BrowserWidget::hasDetails(){ + return (treeWidget!=0); } // ================= @@ -43,11 +73,12 @@ void BrowserWidget::itemUpdated(QString item){ qDebug() << "item updated" << item; QList<QTreeWidgetItem*> found = treeWidget->findItems(item.section("/",-1), Qt::MatchExactly, 0); //look for exact name match if(found.isEmpty()){ return; } //no match - QTreeWidgetItem *it = found[0]; //onlyp update the first match (should only ever be one - duplicate file names are disallowed) + QTreeWidgetItem *it = found[0]; //only update the first match (should only ever be one - duplicate file names are disallowed) //it->setText( } void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo info){ + qDebug() << "Item Data Available:" << info.fileName(); int num = 0; if(listWidget!=0){ listWidget->addItem( new QListWidgetItem(ico, info.fileName(), listWidget) ); @@ -67,4 +98,3 @@ void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo info){ void BrowserWidget::itemsLoading(int total){ numItems = total; //save this for later } - |