File indexing completed on 2024-05-05 04:49:22
0001 /**************************************************************************************** 0002 * Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #ifndef COMPOUNDPROGRESSBAR_H 0018 #define COMPOUNDPROGRESSBAR_H 0019 0020 #include "statusbar/ProgressBar.h" 0021 #include "statusbar/PopupWidget.h" 0022 0023 #include <QList> 0024 #include <QMap> 0025 #include <QMouseEvent> 0026 #include <QMutex> 0027 0028 /** 0029 * A progress bar that wraps a number of simple progress bars and displays their 0030 * overall progress. Also features an expanded mode that allows the user to view 0031 * and canceled individual operations 0032 */ 0033 class AMAROK_EXPORT CompoundProgressBar : public ProgressBar 0034 { 0035 Q_OBJECT 0036 public: 0037 explicit CompoundProgressBar( QWidget *parent ); 0038 0039 ~CompoundProgressBar() override; 0040 0041 void addProgressBar( ProgressBar *progressBar, QObject *owner ); 0042 0043 void incrementProgress( const QObject *owner ); 0044 void setProgressTotalSteps( const QObject *owner, int value ); 0045 void setProgressStatus( const QObject *owner, const QString &text ); 0046 void setProgress( const QObject *owner, int steps ); 0047 0048 /* reimplemented from QWidget to open/close the details widget */ 0049 void mousePressEvent( QMouseEvent *event ) override; 0050 0051 public Q_SLOTS: 0052 void endProgressOperation( QObject *owner ); 0053 void slotIncrementProgress(); 0054 0055 Q_SIGNALS: 0056 void allDone(); 0057 0058 protected Q_SLOTS: 0059 void cancelAll(); 0060 void toggleDetails(); 0061 0062 void childPercentageChanged( ); 0063 void childBarCancelled( ProgressBar *progressBar ); 0064 void childBarComplete( ProgressBar *progressBar ); 0065 0066 void slotObjectDestroyed( QObject *object ); 0067 0068 private: 0069 void showDetails(); 0070 void hideDetails(); 0071 0072 void childBarFinished( ProgressBar *bar ); 0073 0074 int calcCompoundPercentage(); 0075 0076 QMap< const QObject *, ProgressBar *> m_progressMap; 0077 PopupWidget *m_progressDetailsWidget; 0078 QMutex m_mutex; // protecting m_progressMap consistency 0079 }; 0080 0081 #endif