[qet] [2018] Ensured events were processed regularly while the elements panel is being reloaded .

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 2018
Author:   xavier
Date:     2013-01-30 00:03:09 +0100 (Wed, 30 Jan 2013)
Log Message:
-----------
Ensured events were processed regularly while the elements panel is being reloaded.
Also disabled the "Reload" button during that same process.

Modified Paths:
--------------
    trunk/sources/elementspanel.cpp
    trunk/sources/elementspanel.h
    trunk/sources/elementspanelwidget.cpp
    trunk/sources/elementspanelwidget.h
    trunk/sources/genericpanel.cpp

Modified: trunk/sources/elementspanel.cpp
===================================================================
--- trunk/sources/elementspanel.cpp	2013-01-29 16:54:39 UTC (rev 2017)
+++ trunk/sources/elementspanel.cpp	2013-01-29 23:03:09 UTC (rev 2018)
@@ -602,6 +602,8 @@
 	
 	// the first time, expand the first level of collections
 	if (first_reload_) first_reload_ = false;
+	
+	emit(loadingFinished());
 }
 
 /**

Modified: trunk/sources/elementspanel.h
===================================================================
--- trunk/sources/elementspanel.h	2013-01-29 16:54:39 UTC (rev 2017)
+++ trunk/sources/elementspanel.h	2013-01-29 23:03:09 UTC (rev 2018)
@@ -72,6 +72,7 @@
 	void readingAboutToBegin();
 	void readingFinished();
 	void loadingProgressed(int, int);
+	void loadingFinished();
 	
 	public slots:
 	void slot_doubleClick(QTreeWidgetItem *, int);

Modified: trunk/sources/elementspanelwidget.cpp
===================================================================
--- trunk/sources/elementspanelwidget.cpp	2013-01-29 16:54:39 UTC (rev 2017)
+++ trunk/sources/elementspanelwidget.cpp	2013-01-29 23:03:09 UTC (rev 2018)
@@ -141,6 +141,7 @@
 	connect(elements_panel, SIGNAL(loadingProgressed(int, int)),  this, SLOT(updateProgressBar(int, int)));
 	connect(elements_panel, SIGNAL(readingAboutToBegin()),        this, SLOT(collectionsRead()));
 	connect(elements_panel, SIGNAL(readingFinished()),            this, SLOT(collectionsReadFinished()));
+	connect(elements_panel, SIGNAL(loadingFinished()),            this, SLOT(loadingFinished()));
 	
 	// initialise la barre d'outils
 	toolbar = new QToolBar(this);
@@ -167,6 +168,9 @@
 	vlayout -> addWidget(progress_bar_);
 	vlayout -> setStretchFactor(elements_panel, 75000);
 	setLayout(vlayout);
+	
+	// by default, the reload button is disabled
+	reload -> setEnabled(false);
 }
 
 /**
@@ -190,12 +194,16 @@
 */
 void ElementsPanelWidget::reloadAndFilter() {
 	// recharge tous les elements
+	reload -> setEnabled(false);
 	elements_panel -> reload(true);
 	
+	// the reload button was enabled again through loadingFinished()
+	reload -> setEnabled(false);
 	// reapplique le filtre
 	if (!filter_textfield -> text().isEmpty()) {
 		elements_panel -> filter(filter_textfield -> text());
 	}
+	reload -> setEnabled(true);
 }
 
 /**
@@ -617,12 +625,20 @@
 	if (!current) {
 		progress_bar_ -> setFormat(tr("Chargement : %p%", "Visual rendering of elements/categories files - %p is the progress percentage"));
 		progress_bar_ -> setVisible(true);
-	} else if (current == provided_maximum) {
-		QTimer::singleShot(500, progress_bar_, SLOT(hide()));
 	}
 	progress_bar_ -> setValue(current);
 }
 
+/**
+	Reflects the fact the whole panel content was loaded by hiding the progress
+	bar and enabling again the reload button.
+*/
+void ElementsPanelWidget::loadingFinished() {
+	QTimer::singleShot(500, progress_bar_, SLOT(hide()));
+	reload -> setEnabled(true);
+	
+}
+
 void ElementsPanelWidget::filterEdited(const QString &next_text) {
 	if (previous_filter_.isEmpty() && next_text.length() == 1) {
 		// the field is not empty anymore: begin filtering

Modified: trunk/sources/elementspanelwidget.h
===================================================================
--- trunk/sources/elementspanelwidget.h	2013-01-29 16:54:39 UTC (rev 2017)
+++ trunk/sources/elementspanelwidget.h	2013-01-29 23:03:09 UTC (rev 2018)
@@ -101,6 +101,7 @@
 	void collectionsRead();
 	void collectionsReadFinished();
 	void updateProgressBar(int, int);
+	void loadingFinished();
 	void filterEdited(const QString &);
 	
 	private:

Modified: trunk/sources/genericpanel.cpp
===================================================================
--- trunk/sources/genericpanel.cpp	2013-01-29 16:54:39 UTC (rev 2017)
+++ trunk/sources/genericpanel.cpp	2013-01-29 23:03:09 UTC (rev 2018)
@@ -910,6 +910,7 @@
 	Q_UNUSED(qtwi);
 	Q_UNUSED(options);
 	Q_UNUSED(freshly_created);
+	QApplication::processEvents();
 	return(qtwi);
 }
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/