mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 02:45:33 +08:00
Ref T529, view improvements
* protected slots -> protected * removed unused functions * load indicator timeout slot
This commit is contained in:
committed by
Mat Sutcliffe
parent
4e6437db4e
commit
91050e198c
@@ -786,7 +786,7 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
template <class T>
|
||||
CStatusMessage CViewBase<T>::ps_loadJson(const QString &directory)
|
||||
CStatusMessage CViewBase<T>::loadJson(const QString &directory)
|
||||
{
|
||||
const QString fileName = QFileDialog::getOpenFileName(nullptr,
|
||||
tr("Load data file"),
|
||||
@@ -796,7 +796,7 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
template <class T>
|
||||
CStatusMessage CViewBase<T>::ps_saveJson(bool selectedOnly, const QString &directory)
|
||||
CStatusMessage CViewBase<T>::saveJson(bool selectedOnly, const QString &directory)
|
||||
{
|
||||
const QString fileName = QFileDialog::getSaveFileName(nullptr,
|
||||
tr("Save data file"),
|
||||
@@ -899,27 +899,27 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void CViewBase<T>::ps_clicked(const QModelIndex &index)
|
||||
void CViewBase<T>::onClicked(const QModelIndex &index)
|
||||
{
|
||||
if (!m_acceptClickSelection) { return; }
|
||||
if (!index.isValid()) { return; }
|
||||
emit objectClicked(CVariant::fromValue(at(index)));
|
||||
emit this->objectClicked(CVariant::fromValue(at(index)));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void CViewBase<T>::ps_doubleClicked(const QModelIndex &index)
|
||||
void CViewBase<T>::onDoubleClicked(const QModelIndex &index)
|
||||
{
|
||||
if (!m_acceptDoubleClickSelection) { return; }
|
||||
if (!index.isValid()) { return; }
|
||||
emit objectDoubleClicked(CVariant::fromValue(at(index)));
|
||||
emit this->objectDoubleClicked(CVariant::fromValue(at(index)));
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void CViewBase<T>::ps_rowSelected(const QModelIndex &index)
|
||||
void CViewBase<T>::onRowSelected(const QModelIndex &index)
|
||||
{
|
||||
if (!m_acceptRowSelection) { return; }
|
||||
if (!index.isValid()) { return; }
|
||||
emit objectSelected(CVariant::fromValue(at(index)));
|
||||
emit this->objectSelected(CVariant::fromValue(at(index)));
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -517,6 +517,21 @@ namespace BlackGui
|
||||
virtual void paste() = 0;
|
||||
//! @}
|
||||
|
||||
//! Index clicked
|
||||
virtual void onClicked(const QModelIndex &index) = 0;
|
||||
|
||||
//! Index double clicked
|
||||
virtual void onDoubleClicked(const QModelIndex &index) = 0;
|
||||
|
||||
//! Row selected
|
||||
virtual void onRowSelected(const QModelIndex &index) = 0;
|
||||
|
||||
//! Load JSON
|
||||
virtual BlackMisc::CStatusMessage loadJson(const QString &directory = {}) = 0;
|
||||
|
||||
//! Save JSON
|
||||
virtual BlackMisc::CStatusMessage saveJson(bool selectedOnly = false, const QString &directory = {}) = 0;
|
||||
|
||||
//! Trigger reload from backend by signal requestUpdate();
|
||||
void triggerReload();
|
||||
|
||||
@@ -565,28 +580,6 @@ namespace BlackGui
|
||||
BlackMisc::CSetting<BlackMisc::Settings::TDirectorySettings> m_dirSettings { this }; //!< directory for load/save
|
||||
BlackMisc::CSettingReadOnly<Settings::TGeneralGui> m_guiSettings { this, &CViewBaseNonTemplate::settingsChanged }; //!< general GUI settings
|
||||
|
||||
protected slots:
|
||||
//! Index clicked
|
||||
virtual void ps_clicked(const QModelIndex &index) = 0;
|
||||
|
||||
//! Index double clicked
|
||||
virtual void ps_doubleClicked(const QModelIndex &index) = 0;
|
||||
|
||||
//! Row selected
|
||||
virtual void ps_rowSelected(const QModelIndex &index) = 0;
|
||||
|
||||
//! Load JSON
|
||||
virtual BlackMisc::CStatusMessage ps_loadJson(const QString &directory = {}) = 0;
|
||||
|
||||
//! Save JSON
|
||||
virtual BlackMisc::CStatusMessage ps_saveJson(bool selectedOnly = false, const QString &directory = {}) = 0;
|
||||
|
||||
// ------------ slots of CViewDbObjects ----------------
|
||||
// need to be declared here and overridden, as this is the only part with valid Q_OBJECT
|
||||
|
||||
//! Highlight DB data
|
||||
virtual void ps_toggleHighlightDbData() {}
|
||||
|
||||
private:
|
||||
//! Remove selected rows if enabled
|
||||
void removeSelectedRowsChecked();
|
||||
@@ -597,8 +590,8 @@ namespace BlackGui
|
||||
//! Custom menu was requested
|
||||
void customMenuRequested(const QPoint &pos);
|
||||
|
||||
//! Indicator has been updated
|
||||
void updatedIndicator();
|
||||
//! Indicator timed out
|
||||
void onLoadIndicatorTimedOut();
|
||||
|
||||
//! Toggle the resize mode
|
||||
void toggleResizeMode(bool checked);
|
||||
@@ -820,15 +813,13 @@ namespace BlackGui
|
||||
//! Display the container as JSON popup
|
||||
virtual void displayContainerAsJsonPopup(bool selectedOnly);
|
||||
|
||||
// --------------------------------------------- SLOTS start here -----------------------------------------
|
||||
|
||||
//! \name Slot overrides from base class
|
||||
//! \name Overrides from base class
|
||||
//! @{
|
||||
virtual void ps_clicked(const QModelIndex &index) override;
|
||||
virtual void ps_doubleClicked(const QModelIndex &index) override;
|
||||
virtual void ps_rowSelected(const QModelIndex &index) override;
|
||||
virtual BlackMisc::CStatusMessage ps_loadJson(const QString &directory = {}) override;
|
||||
virtual BlackMisc::CStatusMessage ps_saveJson(bool selectedOnly = false, const QString &directory = {}) override;
|
||||
virtual void onClicked(const QModelIndex &index) override;
|
||||
virtual void onDoubleClicked(const QModelIndex &index) override;
|
||||
virtual void onRowSelected(const QModelIndex &index) override;
|
||||
virtual BlackMisc::CStatusMessage loadJson(const QString &directory = {}) override;
|
||||
virtual BlackMisc::CStatusMessage saveJson(bool selectedOnly = false, const QString &directory = {}) override;
|
||||
//! @}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -43,8 +43,8 @@ namespace BlackGui
|
||||
{
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, &QWidget::customContextMenuRequested, this, &CViewBaseNonTemplate::customMenuRequested);
|
||||
connect(this, &QTableView::clicked, this, &CViewBaseNonTemplate::ps_clicked);
|
||||
connect(this, &QTableView::doubleClicked, this, &CViewBaseNonTemplate::ps_doubleClicked);
|
||||
connect(this, &QTableView::clicked, this, &CViewBaseNonTemplate::onClicked);
|
||||
connect(this, &QTableView::doubleClicked, this, &CViewBaseNonTemplate::onDoubleClicked);
|
||||
this->horizontalHeader()->setSortIndicatorShown(true);
|
||||
|
||||
// setting resize mode rowsResizeModeToContent() causes extremly slow views
|
||||
@@ -166,7 +166,7 @@ namespace BlackGui
|
||||
QTableView::setSelectionModel(model);
|
||||
if (this->selectionModel())
|
||||
{
|
||||
connect(this->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &CViewBaseNonTemplate::ps_rowSelected);
|
||||
connect(this->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &CViewBaseNonTemplate::onRowSelected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,12 +177,12 @@ namespace BlackGui
|
||||
|
||||
CStatusMessage CViewBaseNonTemplate::showFileLoadDialog(const QString &directory)
|
||||
{
|
||||
return this->ps_loadJson(directory);
|
||||
return this->loadJson(directory);
|
||||
}
|
||||
|
||||
CStatusMessage CViewBaseNonTemplate::showFileSaveDialog(bool selectedOnly, const QString &directory)
|
||||
{
|
||||
return this->ps_saveJson(selectedOnly, directory);
|
||||
return this->saveJson(selectedOnly, directory);
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::setHorizontalHeaderSectionResizeMode(QHeaderView::ResizeMode mode)
|
||||
@@ -616,7 +616,7 @@ namespace BlackGui
|
||||
void CViewBaseNonTemplate::loadJsonAction()
|
||||
{
|
||||
if (!m_menus.testFlag(MenuLoad)) { return; }
|
||||
const CStatusMessage m = this->ps_loadJson();
|
||||
const CStatusMessage m = this->loadJson();
|
||||
if (!m.isEmpty())
|
||||
{
|
||||
CLogMessage::preformatted(m);
|
||||
@@ -627,7 +627,7 @@ namespace BlackGui
|
||||
{
|
||||
if (this->isEmpty()) { return; }
|
||||
if (!m_menus.testFlag(MenuSave)) { return; }
|
||||
const CStatusMessage m = this->ps_saveJson(false);
|
||||
const CStatusMessage m = this->saveJson(false);
|
||||
if (!m.isEmpty())
|
||||
{
|
||||
CLogMessage::preformatted(m);
|
||||
@@ -638,7 +638,7 @@ namespace BlackGui
|
||||
{
|
||||
if (this->isEmpty()) { return; }
|
||||
if (!m_menus.testFlag(MenuSave)) { return; }
|
||||
const CStatusMessage m = this->ps_saveJson(true);
|
||||
const CStatusMessage m = this->saveJson(true);
|
||||
if (!m.isEmpty())
|
||||
{
|
||||
CLogMessage::preformatted(m);
|
||||
@@ -712,6 +712,7 @@ namespace BlackGui
|
||||
if (!m_loadIndicator)
|
||||
{
|
||||
m_loadIndicator = new CLoadIndicator(64, 64, this);
|
||||
connect(m_loadIndicator, &CLoadIndicator::timedOut, this, &CViewBaseNonTemplate::onLoadIndicatorTimedOut);
|
||||
}
|
||||
this->centerLoadIndicator();
|
||||
return m_loadIndicator->startAnimation(timeoutMs > 0 ? timeoutMs : m_loadIndicatorTimeoutMsDefault, processEvents);
|
||||
@@ -808,6 +809,11 @@ namespace BlackGui
|
||||
menu.exec(globalPos);
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::onLoadIndicatorTimedOut()
|
||||
{
|
||||
m_showingLoadIndicator = false;
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::toggleResizeMode(bool checked)
|
||||
{
|
||||
m_resizeMode = checked ? ResizingAuto : ResizingOff;
|
||||
@@ -848,11 +854,6 @@ namespace BlackGui
|
||||
this->removeSelectedRows();
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::updatedIndicator()
|
||||
{
|
||||
this->update();
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::dragEnterEvent(QDragEnterEvent *event)
|
||||
{
|
||||
if (!event || !this->acceptDrop(event->mimeData())) { return; }
|
||||
|
||||
Reference in New Issue
Block a user