diff options
author | Ken Moore <ken@ixsystems.com> | 2016-09-26 15:03:53 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2016-09-26 15:03:53 -0400 |
commit | c7bf3bdd2a9781b6a3eee701f61708cad8213c9e (patch) | |
tree | bbd171d12cf5ad10d56eadf3a6da5a23fed0a05e /src-qt5/desktop-utils/lumina-fm | |
parent | Fix a syntax issue with the new i18n option in the FreeBSD makefile. (diff) | |
download | lumina-c7bf3bdd2a9781b6a3eee701f61708cad8213c9e.tar.gz lumina-c7bf3bdd2a9781b6a3eee701f61708cad8213c9e.tar.bz2 lumina-c7bf3bdd2a9781b6a3eee701f61708cad8213c9e.zip |
Commit some more work on a new backend/frontend to the lumina-fm browser.
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm')
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.cpp | 14 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/Browser.h | 2 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp | 70 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/BrowserWidget.h | 97 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.cpp | 2 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h | 2 |
6 files changed, 179 insertions, 8 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp index 0aeb5648..b207604c 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp +++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp @@ -17,6 +17,8 @@ Browser::~Browser(){ watcher->deleteLater(); } +QString Browser::currentDirectory(){ return currentDir; } + void Browser::showHiddenFiles(bool show){ if(show !=showHidden){ showHidden = show; @@ -24,7 +26,7 @@ void Browser::showHiddenFiles(bool show){ } } bool Browser::showingHiddenFiles(){ - + return showHidden; } // PRIVATE @@ -45,12 +47,14 @@ void Browser::loadItem(QFileInfo info){ } // PRIVATE SLOTS -void Browser::fileChanged(QString){ - +void Browser::fileChanged(QString file){ + if(file.startsWith(currentDir+"/")){ emit itemUpdated(file); } + else if(file==currentDir){ QTimer::singleShot(0, this, SLOT(loadDirectory()) ); } } -void Browser::dirChanged(QString){ - +void Browser::dirChanged(QString dir){ + if(dir==currentDir){ QTimer::singleShot(0, this, SLOT(loadDirectory()) ); } + else if(dir.startsWith(currentDir)){ emit itemUpdated(dir); } } // PUBLIC SLOTS diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.h b/src-qt5/desktop-utils/lumina-fm/Browser.h index 21dd7789..ccc10c02 100644 --- a/src-qt5/desktop-utils/lumina-fm/Browser.h +++ b/src-qt5/desktop-utils/lumina-fm/Browser.h @@ -15,6 +15,7 @@ public: Browser(QObject *parent = 0); ~Browser(); + QString currentDirectory(); void showHiddenFiles(bool); bool showingHiddenFiles(); @@ -40,7 +41,6 @@ signals: //Start/Stop signals for loading of data void itemsLoading(int); //number of items which are getting loaded - void itemsDoneLoading(); //emitted when all items are done loading }; diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp new file mode 100644 index 00000000..12fd36fe --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp @@ -0,0 +1,70 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2016, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "BrowserWidget.h" +BrowserWidget::BrowserWidget(QString objID, QWidget *parent) : QWidget(parent){ + //Setup the Widget/UI + this->setLayout( new QVBoxLayout(this) ); + + //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)) ); + + listWidget = 0; + treeWidget = 0; +} + +BrowserWidget::~BrowserWidget(){ + +} + +void BrowserWidget::changeDirectory(QString dir){ + if(BROWSER->currentDirectory()==dir){ return; } //already on this directory + BROWSER->loadDirectory(dir); +} + +// ================= +// PRIVATE SLOTS +// ================= +void BrowserWidget::clearItems(){ + if(listWidget!=0){ listWidget->clear(); } + else if(treeWidget!=0){ treeWidget->clear(); } + this->setEnabled(false); +} + +void BrowserWidget::itemUpdated(QString item){ + if(treeWidget==0){ return; } //only used for the tree widget/details + 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) + //it->setText( +} + +void BrowserWidget::itemDataAvailable(QIcon ico, LFileInfo info){ + int num = 0; + if(listWidget!=0){ + listWidget->addItem( new QListWidgetItem(ico, info.fileName(), listWidget) ); + num = listWidget->count(); + }else if(treeWidget!=0){ + //TODO + } + if(num < numItems){ + //Still loading items + //this->setEnabled(false); + }else{ + //Done loading items + this->setEnabled(true); + } +} + +void BrowserWidget::itemsLoading(int total){ + numItems = total; //save this for later +} + diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h new file mode 100644 index 00000000..a0dc535a --- /dev/null +++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h @@ -0,0 +1,97 @@ +// Lumina-DE source code +// Copyright (c) 2016, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This is the main browsing frontend for the file manager +//=========================================== +#ifndef _LUMINA_FM_BROWSE_FRONTEND_H +#define _LUMINA_FM_BROWSE_FRONTEND_H + +#include "Browser.h" +#include "widgets/DDListWidgets.h" + +class BrowserWidget : public QWidget{ + Q_OBJECT +private: + Browser *DIR: + QString ID; + int numItems; //used for checking if all the items have loaded yet + bool details; //show details or not + + //The drag and drop brower widgets + DDListWidget *listWidget; + DDTreeWidget *treeWidget; + +public: + BrowserWidget(QString objID, QWidget *parent = 0); + ~BrowserWidget(); + + QString id(){ return ID; } + + void changeDirectory(QString dir); + + void showDetails(bool show); + bool hasDetails(); + +public slots: + +private slots: + //Brower connections + void clearItems(); + void itemUpdated(QString); + void itemDataAvailable(QIcon, LFileInfo); + void itemsLoading(int total); + +signals: + //void activated(QString); //current dir path + void dirChanged(QString); //current dir path + +}; + +/* + * Virtual class for managing the sort of folders/files items. The problem with base class is that it only manages texts fields and + * we have dates and sizes. + * + * On this class, we overwrite the function operator<. + */ + +class CQTreeWidgetItem : public QTreeWidgetItem { +public: + CQTreeWidgetItem(int type = Type) : QTreeWidgetItem(type) {} + CQTreeWidgetItem(const QStringList & strings, int type = Type) : QTreeWidgetItem(strings, type) {} + CQTreeWidgetItem(QTreeWidget * parent, int type = Type) : QTreeWidgetItem(parent, type) {} + CQTreeWidgetItem(QTreeWidget * parent, const QStringList & strings, int type = Type) : QTreeWidgetItem(parent, strings, type) {} + CQTreeWidgetItem(QTreeWidget * parent, QTreeWidgetItem * preceding, int type = Type) : QTreeWidgetItem(parent, preceding, type) {} + CQTreeWidgetItem(QTreeWidgetItem * parent, int type = Type) : QTreeWidgetItem(parent, type) {} + CQTreeWidgetItem(QTreeWidgetItem * parent, const QStringList & strings, int type = Type) : QTreeWidgetItem(parent, strings, type) {} + CQTreeWidgetItem(QTreeWidgetItem * parent, QTreeWidgetItem * preceding, int type = Type) : QTreeWidgetItem(parent, preceding, type) {} + virtual ~CQTreeWidgetItem() {} + inline virtual bool operator<(const QTreeWidgetItem &tmp) const { + int column = this->treeWidget()->sortColumn(); + // We are in date text + if(column == DirWidget::DATEMOD || column == DirWidget::DATECREATE) + return this->whatsThis(column) < tmp.whatsThis(column); + // We are in size text + else if(column == DirWidget::SIZE) { + QString text = this->text(column); + QString text_tmp = tmp.text(column); + double filesize, filesize_tmp; + // On folders, text is empty so we check for that + // In case we are in folders, we put -1 for differentiate of regular files with 0 bytes. + // Doing so, all folders we'll be together instead of mixing with files with 0 bytes. + if(text.isEmpty()) + filesize = -1; + else + filesize = LUtils::DisplaySizeToBytes(text); + if(text_tmp.isEmpty()) + filesize_tmp = -1; + else + filesize_tmp = LUtils::DisplaySizeToBytes(text_tmp); + return filesize < filesize_tmp; + } + // In other cases, we trust base class implementation + return QTreeWidgetItem::operator<(tmp); + } +}; +#endif diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.cpp b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.cpp index b8b4da0b..d5f15a50 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.cpp +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.cpp @@ -26,7 +26,7 @@ #define DEBUG 0 -const QString sessionsettings_config_file = QDir::homePath() + "/.lumina/LuminaDE/sessionsettings.conf"; +const QString sessionsettings_config_file = QDir::homePath() + "/.config/lumina-desktop/sessionsettings.conf"; DirWidget::DirWidget(QString objID, QWidget *parent) : QWidget(parent), ui(new Ui::DirWidget){ ui->setupUi(this); //load the designer file diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h index 3ef9940b..afbb98cc 100644 --- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h +++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h @@ -73,7 +73,7 @@ public slots: void UpdateButtons(); //Keyboard Shortcuts triggered - void TryRenameSelection(); + void TryRenameSelection(); void TryCutSelection(); void TryCopySelection(); void TryPasteSelection(); |