mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 02:55:44 +08:00
Allow to clear, insert, and push values of the model.
This commit is contained in:
committed by
Mathew Sutcliffe
parent
f476388f8b
commit
576952b690
@@ -4,6 +4,7 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "listmodelbase.h"
|
#include "listmodelbase.h"
|
||||||
|
#include "blackmisc/statusmessagelist.h"
|
||||||
#include "blackmisc/avatcstationlist.h"
|
#include "blackmisc/avatcstationlist.h"
|
||||||
#include "blackmisc/avaircraftlist.h"
|
#include "blackmisc/avaircraftlist.h"
|
||||||
#include "blackmisc/nwserverlist.h"
|
#include "blackmisc/nwserverlist.h"
|
||||||
@@ -103,6 +104,39 @@ namespace BlackGui
|
|||||||
return this->m_list.size();
|
return this->m_list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Push back
|
||||||
|
*/
|
||||||
|
template <typename ObjectType, typename ListType>
|
||||||
|
void CListModelBase<ObjectType, ListType>::push_back(const ObjectType &object)
|
||||||
|
{
|
||||||
|
beginInsertRows(QModelIndex(), this->m_list.size(), this->m_list.size());
|
||||||
|
this->m_list.push_back(object);
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Push back
|
||||||
|
*/
|
||||||
|
template <typename ObjectType, typename ListType>
|
||||||
|
void CListModelBase<ObjectType, ListType>::insert(const ObjectType &object)
|
||||||
|
{
|
||||||
|
beginInsertRows(QModelIndex(), 0, 0);
|
||||||
|
this->m_list.insert(this->m_list.begin(), object);
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clear
|
||||||
|
*/
|
||||||
|
template <typename ObjectType, typename ListType>
|
||||||
|
void CListModelBase<ObjectType, ListType>::clear()
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
this->m_list.clear();
|
||||||
|
endResetModel();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sort
|
* Sort
|
||||||
*/
|
*/
|
||||||
@@ -145,6 +179,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
// see here for the reason of thess forward instantiations
|
// see here for the reason of thess forward instantiations
|
||||||
// http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html
|
// http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html
|
||||||
|
template class CListModelBase<BlackMisc::CStatusMessage, BlackMisc::CStatusMessageList>;
|
||||||
template class CListModelBase<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
template class CListModelBase<BlackMisc::Aviation::CAtcStation, BlackMisc::Aviation::CAtcStationList>;
|
||||||
template class CListModelBase<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
template class CListModelBase<BlackMisc::Aviation::CAircraft, BlackMisc::Aviation::CAircraftList>;
|
||||||
template class CListModelBase<BlackMisc::Network::CServer, BlackMisc::Network::CServerList>;
|
template class CListModelBase<BlackMisc::Network::CServer, BlackMisc::Network::CServerList>;
|
||||||
|
|||||||
@@ -155,6 +155,14 @@ namespace BlackGui
|
|||||||
*/
|
*/
|
||||||
virtual void sort(int column, Qt::SortOrder order);
|
virtual void sort(int column, Qt::SortOrder order);
|
||||||
|
|
||||||
|
//! \brief Similar to ListType::push_back
|
||||||
|
virtual void push_back(const ObjectType &object);
|
||||||
|
|
||||||
|
//! \brief Similar to ListType::insert here inserts at first position
|
||||||
|
virtual void insert(const ObjectType &object);
|
||||||
|
|
||||||
|
//! \brief clear the list
|
||||||
|
virtual void clear();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
Reference in New Issue
Block a user