mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
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:
@@ -602,6 +602,8 @@ void ElementsPanel::reload(bool reload_collections) {
|
||||
|
||||
// the first time, expand the first level of collections
|
||||
if (first_reload_) first_reload_ = false;
|
||||
|
||||
emit(loadingFinished());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,6 +72,7 @@ class ElementsPanel : public GenericPanel {
|
||||
void readingAboutToBegin();
|
||||
void readingFinished();
|
||||
void loadingProgressed(int, int);
|
||||
void loadingFinished();
|
||||
|
||||
public slots:
|
||||
void slot_doubleClick(QTreeWidgetItem *, int);
|
||||
|
||||
@@ -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(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 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) {
|
||||
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::clearFilterTextField() {
|
||||
*/
|
||||
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 @@ void ElementsPanelWidget::updateProgressBar(int current, int maximum) {
|
||||
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
|
||||
|
||||
@@ -101,6 +101,7 @@ class ElementsPanelWidget : public QWidget {
|
||||
void collectionsRead();
|
||||
void collectionsReadFinished();
|
||||
void updateProgressBar(int, int);
|
||||
void loadingFinished();
|
||||
void filterEdited(const QString &);
|
||||
|
||||
private:
|
||||
|
||||
@@ -910,6 +910,7 @@ QTreeWidgetItem *GenericPanel::updateItem(QTreeWidgetItem *qtwi, PanelOptions op
|
||||
Q_UNUSED(qtwi);
|
||||
Q_UNUSED(options);
|
||||
Q_UNUSED(freshly_created);
|
||||
QApplication::processEvents();
|
||||
return(qtwi);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user