mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
refs #300, moved views in subdirectory and namespace
This commit is contained in:
31
src/blackgui/views/aircraftview.cpp
Normal file
31
src/blackgui/views/aircraftview.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "aircraftview.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CAircraftView::CAircraftView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->m_model = new CAircraftListModel(this);
|
||||
this->setModel(this->m_model); // via QTableView
|
||||
this->m_model->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAircraft::IndexDistance);
|
||||
if (this->m_model->hasValidSortColumn())
|
||||
this->horizontalHeader()->setSortIndicator(
|
||||
this->m_model->getSortColumn(),
|
||||
this->m_model->getSortOrder());
|
||||
}
|
||||
}
|
||||
}
|
||||
33
src/blackgui/views/aircraftview.h
Normal file
33
src/blackgui/views/aircraftview.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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_AIRCRAFTVIEW_H
|
||||
#define BLACKGUI_AIRCRAFTVIEW_H
|
||||
|
||||
#include "viewbase.h"
|
||||
#include "../models/aircraftlistmodel.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Aircrafts view
|
||||
class CAircraftView : public CViewBase<Models::CAircraftListModel>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
explicit CAircraftView(QWidget *parent = nullptr);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // guard
|
||||
33
src/blackgui/views/airportview.cpp
Normal file
33
src/blackgui/views/airportview.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "airportview.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CAirportView::CAirportView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->m_model = new CAirportListModel(this);
|
||||
this->setModel(this->m_model); // via QTableView
|
||||
this->m_model->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAirport::IndexDistance);
|
||||
if (this->m_model->hasValidSortColumn())
|
||||
{
|
||||
this->horizontalHeader()->setSortIndicator(
|
||||
this->m_model->getSortColumn(),
|
||||
this->m_model->getSortOrder());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
src/blackgui/views/airportview.h
Normal file
33
src/blackgui/views/airportview.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef BLACKGUI_AIRPORTVIEW_H
|
||||
#define BLACKGUI_AIRPORTVIEW_H
|
||||
|
||||
//! \file
|
||||
|
||||
#include "viewbase.h"
|
||||
#include "../models/airportlistmodel.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Airports view
|
||||
class CAirportView : public CViewBase<Models::CAirportListModel>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
explicit CAirportView(QWidget *parent = nullptr);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // guard
|
||||
44
src/blackgui/views/atcstationview.cpp
Normal file
44
src/blackgui/views/atcstationview.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "atcstationview.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CAtcStationView::CAtcStationView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->m_model = new CAtcStationListModel(CAtcStationListModel::StationsOnline, this);
|
||||
this->setModel(this->m_model); // via QTableView
|
||||
this->m_model->setSortColumnByPropertyIndex(BlackMisc::Aviation::CAtcStation::IndexDistance);
|
||||
if (this->m_model->hasValidSortColumn())
|
||||
this->horizontalHeader()->setSortIndicator(
|
||||
this->m_model->getSortColumn(),
|
||||
this->m_model->getSortOrder());
|
||||
}
|
||||
|
||||
void CAtcStationView::setStationMode(CAtcStationListModel::AtcStationMode stationMode)
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
this->m_model->setStationMode(stationMode);
|
||||
}
|
||||
|
||||
void CAtcStationView::changedAtcStationConnectionStatus(const Aviation::CAtcStation &station, bool added)
|
||||
{
|
||||
this->m_model->changedAtcStationConnectionStatus(station, added);
|
||||
this->resizeColumnsToContents();
|
||||
this->resizeRowsToContents();
|
||||
}
|
||||
}
|
||||
}
|
||||
41
src/blackgui/views/atcstationview.h
Normal file
41
src/blackgui/views/atcstationview.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef BLACKGUI_ATCSTATIONVIEW_H
|
||||
#define BLACKGUI_ATCSTATIONVIEW_H
|
||||
|
||||
//! \file
|
||||
|
||||
#include "viewbase.h"
|
||||
#include "../models/atcstationlistmodel.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! ATC stations view
|
||||
class CAtcStationView : public CViewBase<Models::CAtcStationListModel>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
explicit CAtcStationView(QWidget *parent = nullptr);
|
||||
|
||||
//! Set station mode
|
||||
void setStationMode(Models::CAtcStationListModel::AtcStationMode stationMode);
|
||||
|
||||
public slots:
|
||||
//! \copydoc CAtcStationListModel::changedAtcStationConnectionStatus
|
||||
void changedAtcStationConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added);
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // guard
|
||||
32
src/blackgui/views/clientview.cpp
Normal file
32
src/blackgui/views/clientview.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "clientview.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CClientView::CClientView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->m_model = new CClientListModel(this);
|
||||
this->setModel(this->m_model); // via QTableView
|
||||
this->m_model->setSortColumnByPropertyIndex(BlackMisc::Network::CClient::IndexRealName);
|
||||
if (this->m_model->hasValidSortColumn())
|
||||
this->horizontalHeader()->setSortIndicator(
|
||||
this->m_model->getSortColumn(),
|
||||
this->m_model->getSortOrder());
|
||||
this->horizontalHeader()->setStretchLastSection(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
31
src/blackgui/views/clientview.h
Normal file
31
src/blackgui/views/clientview.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef BLACKGUI_CLIENTVIEW_H
|
||||
#define BLACKGUI_CLIENTVIEW_H
|
||||
|
||||
//! \file
|
||||
|
||||
#include "viewbase.h"
|
||||
#include "../models/clientlistmodel.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Client view
|
||||
class CClientView : public CViewBase<Models::CClientListModel>
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CClientView(QWidget *parent = nullptr);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // guard
|
||||
32
src/blackgui/views/keyboardkeyview.cpp
Normal file
32
src/blackgui/views/keyboardkeyview.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "keyboardkeyview.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CKeyboardKeyView::CKeyboardKeyView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->m_model = new CKeyboardKeyListModel(this);
|
||||
this->setModel(this->m_model); // via QTableView
|
||||
this->m_model->setSortColumnByPropertyIndex(BlackMisc::Hardware::CKeyboardKey::IndexFunctionAsString);
|
||||
if (this->m_model->hasValidSortColumn())
|
||||
this->horizontalHeader()->setSortIndicator(
|
||||
this->m_model->getSortColumn(),
|
||||
this->m_model->getSortOrder());
|
||||
this->setItemDelegate(new CKeyboardKeyItemDelegate(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
33
src/blackgui/views/keyboardkeyview.h
Normal file
33
src/blackgui/views/keyboardkeyview.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef BLACKGUI_KEYBOARDKEYVIEW_H
|
||||
#define BLACKGUI_KEYBOARDKEYVIEW_H
|
||||
|
||||
//! \file
|
||||
|
||||
#include "viewbase.h"
|
||||
#include "../models/keyboardkeylistmodel.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Keyboard key view
|
||||
class CKeyboardKeyView : public CViewBase<Models::CKeyboardKeyListModel>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
explicit CKeyboardKeyView(QWidget *parent = nullptr);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // guard
|
||||
37
src/blackgui/views/serverview.cpp
Normal file
37
src/blackgui/views/serverview.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "serverview.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CServerView::CServerView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->m_model = new CServerListModel(this);
|
||||
this->setModel(this->m_model); // via QTableView
|
||||
this->m_model->setSortColumnByPropertyIndex(BlackMisc::Network::CServer::IndexName);
|
||||
if (this->m_model->hasValidSortColumn())
|
||||
this->horizontalHeader()->setSortIndicator(
|
||||
this->m_model->getSortColumn(),
|
||||
this->m_model->getSortOrder());
|
||||
}
|
||||
|
||||
void CServerView::setSelectedServer(const Network::CServer &selectedServer)
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
this->m_model->setSelectedServer(selectedServer);
|
||||
}
|
||||
}
|
||||
}
|
||||
36
src/blackgui/views/serverview.h
Normal file
36
src/blackgui/views/serverview.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef BLACKGUI_SERVERVIEW_H
|
||||
#define BLACKGUI_SERVERVIEW_H
|
||||
|
||||
//! \file
|
||||
|
||||
#include "viewbase.h"
|
||||
#include "../models/serverlistmodel.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Network servers
|
||||
class CServerView : public CViewBase<Models::CServerListModel>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
explicit CServerView(QWidget *parent = nullptr);
|
||||
|
||||
//! \copydoc CServerListModel::setSelectedServer
|
||||
void setSelectedServer(const BlackMisc::Network::CServer &selectedServer);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // guard
|
||||
62
src/blackgui/views/statusmessageview.cpp
Normal file
62
src/blackgui/views/statusmessageview.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "statusmessageview.h"
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
/*
|
||||
* Constructor
|
||||
*/
|
||||
CStatusMessageView::CStatusMessageView(QWidget *parent) : CViewBase(parent), m_contextMenu(nullptr)
|
||||
{
|
||||
this->m_model = new CStatusMessageListModel(this);
|
||||
this->setModel(this->m_model); // QTableView
|
||||
this->m_model->setSortColumnByPropertyIndex(BlackMisc::CStatusMessage::IndexTimestamp);
|
||||
if (this->m_model->hasValidSortColumn())
|
||||
{
|
||||
this->horizontalHeader()->setSortIndicator(
|
||||
this->m_model->getSortColumn(),
|
||||
this->m_model->getSortOrder());
|
||||
}
|
||||
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
this->m_contextMenu = new QMenu(this);
|
||||
this->m_contextMenu->addAction("Clear");
|
||||
connect(this, &QTableView::customContextMenuRequested, this, &CStatusMessageView::contextMenu);
|
||||
}
|
||||
|
||||
/*
|
||||
* Message list context menu
|
||||
*/
|
||||
void CStatusMessageView::contextMenu(const QPoint &position)
|
||||
{
|
||||
// position for most widgets
|
||||
QPoint globalPosition = this->mapToGlobal(position);
|
||||
QAction *selectedItem = this->m_contextMenu->exec(globalPosition);
|
||||
if (selectedItem)
|
||||
{
|
||||
// http://forum.technical-assistance.co.uk/sndvol32exe-command-line-parameters-vt1348.html
|
||||
const QList<QAction *> actions = this->m_contextMenu->actions();
|
||||
if (selectedItem == actions.at(0))
|
||||
{
|
||||
this->clear();
|
||||
this->resizeColumnsToContents();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
40
src/blackgui/views/statusmessageview.h
Normal file
40
src/blackgui/views/statusmessageview.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef BLACKGUI_STATUSMESSAGEVIEW_H
|
||||
#define BLACKGUI_STATUSMESSAGEVIEW_H
|
||||
|
||||
//! \file
|
||||
|
||||
#include "viewbase.h"
|
||||
#include "../models/statusmessagelistmodel.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Status message view
|
||||
class CStatusMessageView : public CViewBase<Models::CStatusMessageListModel>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
explicit CStatusMessageView(QWidget *parent = nullptr);
|
||||
|
||||
private:
|
||||
QMenu *m_contextMenu;
|
||||
|
||||
private slots:
|
||||
//! Context menu for message list
|
||||
void contextMenu(const QPoint &position);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // guard
|
||||
38
src/blackgui/views/userview.cpp
Normal file
38
src/blackgui/views/userview.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "userview.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CUserView::CUserView(QWidget *parent) : CViewBase(parent)
|
||||
{
|
||||
this->m_model = new CUserListModel(CUserListModel::UserDetailed, this);
|
||||
this->setModel(this->m_model); // via QTableView
|
||||
this->m_model->setSortColumnByPropertyIndex(BlackMisc::Network::CUser::IndexRealName);
|
||||
if (this->m_model->hasValidSortColumn())
|
||||
this->horizontalHeader()->setSortIndicator(
|
||||
this->m_model->getSortColumn(),
|
||||
this->m_model->getSortOrder());
|
||||
this->horizontalHeader()->setStretchLastSection(true);
|
||||
}
|
||||
|
||||
void CUserView::setUserMode(CUserListModel::UserMode userMode)
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
this->m_model->setUserMode(userMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
36
src/blackgui/views/userview.h
Normal file
36
src/blackgui/views/userview.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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_USERVIEW_H
|
||||
#define BLACKGUI_USERVIEW_H
|
||||
|
||||
#include "viewbase.h"
|
||||
#include "../models/userlistmodel.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! User view
|
||||
class CUserView : public CViewBase<Models::CUserListModel>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor
|
||||
explicit CUserView(QWidget *parent = nullptr);
|
||||
|
||||
//! Set station mode
|
||||
void setUserMode(Models::CUserListModel::UserMode userMode);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // guard
|
||||
94
src/blackgui/views/viewbase.h
Normal file
94
src/blackgui/views/viewbase.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/* Copyright (C) 2013
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef BLACKGUI_VIEWBASE_H
|
||||
#define BLACKGUI_VIEWBASE_H
|
||||
|
||||
//! \file
|
||||
|
||||
#include <QTableView>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! List model
|
||||
template <class ModelClass> class CViewBase : public QTableView
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
//! Constructor
|
||||
CViewBase(QWidget *parent, ModelClass *model = nullptr) : QTableView(parent), m_model(model)
|
||||
{
|
||||
this->setSortingEnabled(true);
|
||||
this->horizontalHeader()->setStretchLastSection(true);
|
||||
}
|
||||
|
||||
//! Destructor
|
||||
virtual ~CViewBase() {}
|
||||
|
||||
ModelClass *m_model; //!< corresponding model
|
||||
|
||||
public:
|
||||
|
||||
//! Model
|
||||
ModelClass *derivedModel() { return this->m_model; }
|
||||
|
||||
//! Model
|
||||
const ModelClass *derivedModel() const { return this->m_model; }
|
||||
|
||||
//! Clear
|
||||
void clear() { Q_ASSERT(this->m_model); this->m_model->clear(); }
|
||||
|
||||
//! Update
|
||||
template<class ContainerType> int update(const ContainerType &container, bool resize = true)
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
int c = this->m_model->update(container);
|
||||
if (!resize) return c;
|
||||
this->resizeColumnsToContents();
|
||||
this->resizeRowsToContents();
|
||||
return c;
|
||||
}
|
||||
|
||||
//! Insert
|
||||
template<class ObjectType> void insert(const ObjectType &value, bool resize = true)
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
this->m_model->insert(value);
|
||||
if (!resize) return;
|
||||
this->resizeColumnsToContents();
|
||||
this->resizeRowsToContents();
|
||||
}
|
||||
|
||||
//! Value object at
|
||||
template<class ObjectType> const ObjectType &at(const QModelIndex &index) const
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
return this->m_model->at(index);
|
||||
}
|
||||
|
||||
//! Row count
|
||||
int rowCount() const
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
return this->m_model->rowCount();
|
||||
}
|
||||
|
||||
//! Any data?
|
||||
bool isEmpty() const
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
return this->m_model->rowCount() < 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user