aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/Browser.cpp6
-rw-r--r--src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp124
-rw-r--r--src-qt5/desktop-utils/lumina-fm/BrowserWidget.h17
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h50
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.cpp2
-rw-r--r--src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h45
6 files changed, 181 insertions, 63 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/Browser.cpp b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
index 1312aca0..8c9b27c3 100644
--- a/src-qt5/desktop-utils/lumina-fm/Browser.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/Browser.cpp
@@ -78,7 +78,7 @@ void Browser::dirChanged(QString dir){
void Browser::futureFinished(QString name, QByteArray icon){
//Note: this will be called once for every item that loads
- qDebug() << "Future Finished" << name;
+ //qDebug() << "Future Finished" << name;
//for(int i=0; i<fwatchers.length(); i++){
//if(fwatchers[i]->isFinished()){
//FileItem FI = fwatchers[i]->result();
@@ -96,7 +96,7 @@ void Browser::futureFinished(QString name, QByteArray icon){
}
if(ico.isNull()){ ico = LXDG::findIcon( info.mimetype(), "unknown" ); }
this->emit itemDataAvailable( ico, info );
- qDebug() << "- done";
+ //qDebug() << "- done";
//i--;
//return;
//}
@@ -105,7 +105,7 @@ void Browser::futureFinished(QString name, QByteArray icon){
// PUBLIC SLOTS
void Browser::loadDirectory(QString dir){
- qDebug() << "Load Directory" << dir;
+ //qDebug() << "Load Directory" << dir;
if(dir.isEmpty()){ dir = currentDir; } //reload current directory
if(dir.isEmpty()){ return; } //nothing to do - nothing previously loaded
//clean up the watcher first
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
index e6017e77..bec99667 100644
--- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.cpp
@@ -8,11 +8,15 @@
#include <QVBoxLayout>
#include <QTimer>
+#include <QSettings>
+
+#include <LuminaUtils.h>
BrowserWidget::BrowserWidget(QString objID, QWidget *parent) : QWidget(parent){
//Setup the Widget/UI
this->setLayout( new QVBoxLayout(this) );
- this->setWhatsThis(objID);
+ ID = objID;
+ //this->setWhatsThis(objID);
//Setup the backend browser object
BROWSER = new Browser(this);
connect(BROWSER, SIGNAL(clearItems()), this, SLOT(clearItems()) );
@@ -22,6 +26,7 @@ BrowserWidget::BrowserWidget(QString objID, QWidget *parent) : QWidget(parent){
connect(this, SIGNAL(dirChange(QString)), BROWSER, SLOT(loadDirectory(QString)) );
listWidget = 0;
treeWidget = 0;
+ readDateFormat();
}
BrowserWidget::~BrowserWidget(){
@@ -47,6 +52,7 @@ void BrowserWidget::showDetails(bool show){
if(show && treeWidget == 0){
treeWidget = new DDTreeWidget(this);
this->layout()->addWidget(treeWidget);
+ retranslate();
if(!BROWSER->currentDirectory().isEmpty()){ emit dirChange(""); }
}else if(!show && listWidget==0){
listWidget = new DDListWidget(this);
@@ -59,6 +65,74 @@ bool BrowserWidget::hasDetails(){
return (treeWidget!=0);
}
+void BrowserWidget::setThumbnailSize(int px){
+ bool larger = true;
+ if(listWidget!=0){
+ larger = listWidget->iconSize().height() < px;
+ listWidget->setIconSize(QSize(px,px));
+ }else if(treeWidget!=0){
+ larger = treeWidget->iconSize().height() < px;
+ treeWidget->setIconSize(QSize(px,px));
+ }
+ if(BROWSER->currentDirectory().isEmpty() || !larger ){ return; } //don't need to reload icons unless the new size is larger
+ emit dirChange("");
+}
+
+QStringList BrowserWidget::getDateFormat() {
+ return date_format;
+}
+
+// This function is only called if user changes sessionsettings. By doing so, operations like sorting by date
+// are faster because the date format is already stored in DirWidget::date_format static variable
+void BrowserWidget::readDateFormat() {
+ if(!date_format.isEmpty())
+ date_format.clear();
+ QSettings settings("lumina-desktop","sessionsettings");
+ // If value doesn't exist or is not setted, empty string is returned
+ date_format << settings.value("DateFormat").toString();
+ date_format << settings.value("TimeFormat").toString();
+}
+
+// =================
+// PUBLIC SLOTS
+// =================
+void BrowserWidget::retranslate(){
+ if(listWidget!=0){
+
+ }else if(treeWidget!=0){
+ QTreeWidgetItem *it = new QTreeWidgetItem();
+ it->setText(0,tr("Name"));
+ it->setText(1,tr("Size"));
+ it->setText(2, tr("Type"));
+ it->setText(3, tr("Date Modified") );
+ it->setText(4, tr("Date Created") );
+ treeWidget->setHeaderItem(it);
+ //Now reset the sorting (alphabetically, dirs first)
+ treeWidget->sortItems(0, Qt::AscendingOrder); // sort by name
+ treeWidget->sortItems(1, Qt::AscendingOrder); //sort by type
+ }
+}
+
+// =================
+// PRIVATE
+// =================
+QString BrowserWidget::DTtoString(QDateTime dt){
+ QStringList fmt = getDateFormat();
+ if(fmt.isEmpty() || fmt.length()!=2 || (fmt[0].isEmpty() && fmt[1].isEmpty()) ){
+ //Default formatting
+ return dt.toString(Qt::DefaultLocaleShortDate);
+ }else if(fmt[0].isEmpty()){
+ //Time format only
+ return (dt.date().toString(Qt::DefaultLocaleShortDate)+" "+dt.time().toString(fmt[1]));
+ }else if(fmt[1].isEmpty()){
+ //Date format only
+ return (dt.date().toString(fmt[0])+" "+dt.time().toString(Qt::DefaultLocaleShortDate));
+ }else{
+ //both date/time formats set
+ return dt.toString(fmt.join(" "));
+ }
+}
+
// =================
// PRIVATE SLOTS
// =================
@@ -68,23 +142,53 @@ void BrowserWidget::clearItems(){
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]; //only update the first match (should only ever be one - duplicate file names are disallowed)
- //it->setText(
+void BrowserWidget::itemRemoved(QString item){
+ //qDebug() << "item removed" << item;
+ if(treeWidget!=0){
+ QList<QTreeWidgetItem*> found = treeWidget->findItems(item.section("/",-1), Qt::MatchExactly, 0); //look for exact name match
+ if(found.isEmpty()){ return; } //no match
+ delete found[0];
+ }else if(listWidget!=0){
+ QList<QListWidgetItem*> found = listWidget->findItems(item.section("/",-1), Qt::MatchExactly); //look for exact name match
+ if(found.isEmpty()){ return; }
+ delete found[0];
+ }
}
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) );
+ //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);
+ }else{
+ //New item
+ listWidget->addItem( new QListWidgetItem(ico, info.fileName(), listWidget) );
+ }
num = listWidget->count();
}else if(treeWidget!=0){
- //TODO
+ 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);
+ }
+ //Now set/update all the data
+ it->setText(1, LUtils::BytesToDisplaySize(info.size()) ); //size (1)
+ it->setText(2, info.mimetype() ); //type (2)
+ it->setText(3, DTtoString(info.lastModified() )); //modification date (3)
+ it->setText(4, DTtoString(info.created()) ); //creation date (4)
+ //Now all the hidden data
+ it->setWhatsThis(0, info.absoluteFilePath());
+ it->setWhatsThis(3, info.lastModified().toString("yyyyMMddhhmmsszzz") ); //sorts by this actually
+ it->setWhatsThis(4, info.created().toString("yyyyMMddhhmmsszzz") ); //sorts by this actually
+ num = treeWidget->topLevelItemCount();
}
if(num < numItems){
//Still loading items
diff --git a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
index e438c4dc..84b68b2c 100644
--- a/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
+++ b/src-qt5/desktop-utils/lumina-fm/BrowserWidget.h
@@ -19,29 +19,40 @@ class BrowserWidget : public QWidget{
private:
Browser *BROWSER;
int numItems; //used for checking if all the items have loaded yet
- bool details; //show details or not
+ QString ID;
+ QStringList date_format;
//The drag and drop brower widgets
DDListWidget *listWidget;
DDTreeWidget *treeWidget;
+ QString DTtoString(QDateTime dt); //QDateTime to string simplification routine
+
public:
BrowserWidget(QString objID, QWidget *parent = 0);
~BrowserWidget();
- QString id(){ return this->whatsThis(); }
+ QString id(){ return ID; }
void changeDirectory(QString dir);
+ QString currentDirectory(){ return BROWSER->currentDirectory(); }
void showDetails(bool show);
bool hasDetails();
+ void setThumbnailSize(int px);
+
+ //Date format for show items
+ QStringList getDateFormat();
+ void readDateFormat();
+
public slots:
+ void retranslate();
private slots:
//Browser connections
void clearItems();
- void itemUpdated(QString);
+ void itemRemoved(QString);
void itemDataAvailable(QIcon, LFileInfo);
void itemsLoading(int total);
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h
index e3de9b0e..e7dfb4d1 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DDListWidgets.h
@@ -24,6 +24,8 @@
#include <QUrl>
#include <QDir>
+#include <LuminaUtils.h>
+
//==============
// LIST WIDGET
//==============
@@ -237,4 +239,50 @@ protected:
else{ QTreeWidget::mouseMoveEvent(ev); } //pass it along to the widget
}*/
};
-#endif \ No newline at end of file
+
+/*
+ * 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 == 3 || column == 4)
+ return this->whatsThis(column) < tmp.whatsThis(column);
+ // We are in size text
+ else if(column == 1) {
+ 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 d5f15a50..d729d608 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.cpp
@@ -181,7 +181,7 @@ QStringList DirWidget::getDateFormat() {
void DirWidget::setDateFormat() {
if(!date_format.isEmpty())
date_format.clear();
- QSettings settings("LuminaDE","sessionsettings");
+ QSettings settings("lumina-desktop","sessionsettings");
// If value doesn't exist or is not setted, empty string is returned
date_format << settings.value("DateFormat").toString();
date_format << settings.value("TimeFormat").toString();
diff --git a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h
index afbb98cc..fecd6180 100644
--- a/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h
+++ b/src-qt5/desktop-utils/lumina-fm/widgets/DirWidget.h
@@ -181,49 +181,4 @@ protected:
};
-/*
- * 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
bgstack15