/* Copyright (C) 2016 * swift project Community / Contributors * * This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, * including this file, may be copied, modified, propagated, or distributed except according to the terms * contained in the LICENSE file. */ //! \file #ifndef BLACKGUI_COMPONENTS_DBLOADOVERVIEWCOMPONENT_H #define BLACKGUI_COMPONENTS_DBLOADOVERVIEWCOMPONENT_H #include "blackgui/blackguiexport.h" #include "blackgui/loadindicator.h" #include "blackmisc/digestsignal.h" #include "blackmisc/network/entityflags.h" #include #include namespace Ui { class CDbLoadOverviewComponent; } namespace BlackGui { namespace Components { /*! * Overview about load state of DB data */ class BLACKGUI_EXPORT CDbLoadOverviewComponent : public QFrame, public BlackGui::CLoadIndicatorEnabled { Q_OBJECT public: //! Constructor explicit CDbLoadOverviewComponent(QWidget *parent = nullptr); //! Destructor virtual ~CDbLoadOverviewComponent(); //! Initialize void display(); //! Visible DB refresh buttons void showVisibleDbRefreshButtons(bool visible); //! Visible shared refresh buttons void showVisibleSharedRefreshButtons(bool visible); //! Show load all buttons void showVisibleLoadAllButtons(bool shared, bool db); //! Load all from DB void loadAllFromDb(); //! Load all from shared void loadAllFromShared(); protected: //! \copydoc QWidget::resizeEvent virtual void resizeEvent(QResizeEvent *event) override; private: QScopedPointer ui; BlackMisc::CDigestSignal m_dsTriggerGuiUpdate { this, &CDbLoadOverviewComponent::setGuiValues, 2500, 5 }; bool m_loadInProgress = false; //!< data loading in progress bool m_setValuesInProgress = false; //!< setting values in progress, needed because of CNetworkUtils::canConnect check (processing events) //! Trigger loading from DB void triggerLoadingFromDb(BlackMisc::Network::CEntityFlags::Entity entities); //! Trigger loading from shared files void triggerLoadingFromSharedFiles(BlackMisc::Network::CEntityFlags::Entity entities); //! Values at least set once bool isInitialized() const; //! Refresh directly from DB void refreshDbPressed(); //! Refresh directly from shared files void refreshSharedPressed(); //! Init the value panel void setGuiValues(); //! Data have been loaded void dataLoaded(BlackMisc::Network::CEntityFlags::Entity entities, BlackMisc::Network::CEntityFlags::ReadState state, int number); //! Load info objects if not already loaded void loadInfoObjects(); //! Timestamp static QString formattedTimestamp(const QDateTime &dateTime); //! Formatted ts for entity (cache) static QString cacheTimestampForEntity(BlackMisc::Network::CEntityFlags::Entity entity); //! Formatted count for entity (cache) static QString cacheCountForEntity(BlackMisc::Network::CEntityFlags::Entity entity); //! Formatted ts for entity (DB) static QString dbTimestampForEntity(BlackMisc::Network::CEntityFlags::Entity entity); //! Formatted count for entity (DB) static QString dbCountForEntity(BlackMisc::Network::CEntityFlags::Entity entity); //! Formatted ts for entity (shared) static QString sharedFileTimestampForEntity(BlackMisc::Network::CEntityFlags::Entity entity); //! Formatted count for entity (shared) static QString sharedCountForEntity(BlackMisc::Network::CEntityFlags::Entity entity); //! Admit caches static void admitCaches(); }; } // ns } // ns #endif // guard