Ensured events were processed regularly while the elements panel is being reloaded.

Also disabled the "Reload" button during that same process.


git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2018 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2013-01-29 23:03:09 +00:00
parent 31b34ce4ca
commit 70b7cd7d16
5 changed files with 23 additions and 2 deletions

View File

@@ -602,6 +602,8 @@ void ElementsPanel::reload(bool reload_collections) {
// the first time, expand the first level of collections // the first time, expand the first level of collections
if (first_reload_) first_reload_ = false; if (first_reload_) first_reload_ = false;
emit(loadingFinished());
} }
/** /**

View File

@@ -72,6 +72,7 @@ class ElementsPanel : public GenericPanel {
void readingAboutToBegin(); void readingAboutToBegin();
void readingFinished(); void readingFinished();
void loadingProgressed(int, int); void loadingProgressed(int, int);
void loadingFinished();
public slots: public slots:
void slot_doubleClick(QTreeWidgetItem *, int); void slot_doubleClick(QTreeWidgetItem *, int);

View File

@@ -141,6 +141,7 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
connect(elements_panel, SIGNAL(loadingProgressed(int, int)), this, SLOT(updateProgressBar(int, int))); connect(elements_panel, SIGNAL(loadingProgressed(int, int)), this, SLOT(updateProgressBar(int, int)));
connect(elements_panel, SIGNAL(readingAboutToBegin()), this, SLOT(collectionsRead())); connect(elements_panel, SIGNAL(readingAboutToBegin()), this, SLOT(collectionsRead()));
connect(elements_panel, SIGNAL(readingFinished()), this, SLOT(collectionsReadFinished())); connect(elements_panel, SIGNAL(readingFinished()), this, SLOT(collectionsReadFinished()));
connect(elements_panel, SIGNAL(loadingFinished()), this, SLOT(loadingFinished()));
// initialise la barre d'outils // initialise la barre d'outils
toolbar = new QToolBar(this); toolbar = new QToolBar(this);
@@ -167,6 +168,9 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
vlayout -> addWidget(progress_bar_); vlayout -> addWidget(progress_bar_);
vlayout -> setStretchFactor(elements_panel, 75000); vlayout -> setStretchFactor(elements_panel, 75000);
setLayout(vlayout); setLayout(vlayout);
// by default, the reload button is disabled
reload -> setEnabled(false);
} }
/** /**
@@ -190,12 +194,16 @@ void ElementsPanelWidget::clearFilterTextField() {
*/ */
void ElementsPanelWidget::reloadAndFilter() { void ElementsPanelWidget::reloadAndFilter() {
// recharge tous les elements // recharge tous les elements
reload -> setEnabled(false);
elements_panel -> reload(true); elements_panel -> reload(true);
// the reload button was enabled again through loadingFinished()
reload -> setEnabled(false);
// reapplique le filtre // reapplique le filtre
if (!filter_textfield -> text().isEmpty()) { if (!filter_textfield -> text().isEmpty()) {
elements_panel -> filter(filter_textfield -> text()); elements_panel -> filter(filter_textfield -> text());
} }
reload -> setEnabled(true);
} }
/** /**
@@ -617,12 +625,20 @@ void ElementsPanelWidget::updateProgressBar(int current, int maximum) {
if (!current) { if (!current) {
progress_bar_ -> setFormat(tr("Chargement : %p%", "Visual rendering of elements/categories files - %p is the progress percentage")); progress_bar_ -> setFormat(tr("Chargement : %p%", "Visual rendering of elements/categories files - %p is the progress percentage"));
progress_bar_ -> setVisible(true); progress_bar_ -> setVisible(true);
} else if (current == provided_maximum) {
QTimer::singleShot(500, progress_bar_, SLOT(hide()));
} }
progress_bar_ -> setValue(current); 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) { void ElementsPanelWidget::filterEdited(const QString &next_text) {
if (previous_filter_.isEmpty() && next_text.length() == 1) { if (previous_filter_.isEmpty() && next_text.length() == 1) {
// the field is not empty anymore: begin filtering // the field is not empty anymore: begin filtering

View File

@@ -101,6 +101,7 @@ class ElementsPanelWidget : public QWidget {
void collectionsRead(); void collectionsRead();
void collectionsReadFinished(); void collectionsReadFinished();
void updateProgressBar(int, int); void updateProgressBar(int, int);
void loadingFinished();
void filterEdited(const QString &); void filterEdited(const QString &);
private: private:

View File

@@ -910,6 +910,7 @@ QTreeWidgetItem *GenericPanel::updateItem(QTreeWidgetItem *qtwi, PanelOptions op
Q_UNUSED(qtwi); Q_UNUSED(qtwi);
Q_UNUSED(options); Q_UNUSED(options);
Q_UNUSED(freshly_created); Q_UNUSED(freshly_created);
QApplication::processEvents();
return(qtwi); return(qtwi);
} }