id
int64
0
877k
file_name
stringlengths
3
109
file_path
stringlengths
13
185
content
stringlengths
31
9.38M
size
int64
31
9.38M
language
stringclasses
1 value
extension
stringclasses
11 values
total_lines
int64
1
340k
avg_line_length
float64
2.18
149k
max_line_length
int64
7
2.22M
alphanum_fraction
float64
0
1
repo_name
stringlengths
6
66
repo_stars
int64
94
47.3k
repo_forks
int64
0
12k
repo_open_issues
int64
0
3.4k
repo_license
stringclasses
11 values
repo_extraction_date
stringclasses
197 values
exact_duplicates_redpajama
bool
2 classes
near_duplicates_redpajama
bool
2 classes
exact_duplicates_githubcode
bool
2 classes
exact_duplicates_stackv2
bool
1 class
exact_duplicates_stackv1
bool
2 classes
near_duplicates_githubcode
bool
2 classes
near_duplicates_stackv1
bool
2 classes
near_duplicates_stackv2
bool
1 class
1,540,642
PlanFlightDialog.cpp
qutescoop_qutescoop/src/dialogs/PlanFlightDialog.cpp
#include "PlanFlightDialog.h" #include "src/dialogs/Window.h" #include "src/helpers.h" #include "src/NavData.h" #include "src/Net.h" #include "src/Route.h" #include "src/Settings.h" #include "src/Airac.h" #include <QtXml/QDomDocument> //singleton instance PlanFlightDialog* planFlightDialogInstance = 0; PlanFlightDialog* PlanFlightDialog::instance(bool createIfNoInstance, QWidget* parent) { if (planFlightDialogInstance == 0) { if (createIfNoInstance) { if (parent == 0) { parent = Window::instance(); } planFlightDialogInstance = new PlanFlightDialog(parent); } } return planFlightDialogInstance; } PlanFlightDialog::PlanFlightDialog(QWidget* parent) : QDialog(parent), selectedRoute(0) { setupUi(this); setWindowFlags(windowFlags() ^= Qt::WindowContextHelpButtonHint); auto preferences = Settings::dialogPreferences(m_preferencesName); if (!preferences.size.isNull()) { resize(preferences.size); } if (!preferences.pos.isNull()) { move(preferences.pos); } if (!preferences.geometry.isNull()) { restoreGeometry(preferences.geometry); } bDepDetails->hide(); bDestDetails->hide(); edCycle->setText(Airac::effectiveCycle()); _routesSortModel = new QSortFilterProxyModel(this); _routesSortModel->setDynamicSortFilter(true); _routesSortModel->setSourceModel(&_routesModel); treeRoutes->setModel(_routesSortModel); treeRoutes->header()->setSectionResizeMode(QHeaderView::Interactive); treeRoutes->sortByColumn(0, Qt::AscendingOrder); connect(treeRoutes, &QAbstractItemView::clicked, this, &PlanFlightDialog::routeSelected); lblPlotStatus->setText(QString("")); linePlotStatus->setVisible(false); gbResults->setTitle("Results"); } void PlanFlightDialog::on_buttonRequest_clicked() { // get routes from selected providers _routes.clear(); _routesModel.setClients(_routes); gbResults->setTitle( QString("Results [%1-%2] (%3)") .arg(edDep->text(), edDest->text()) .arg(_routes.size()) ); lblGeneratedStatus->setText(""); lblVrouteStatus->setText(""); edDep->setText(edDep->text().toUpper()); edDest->setText(edDest->text().toUpper()); if (cbGenerated->isChecked()) { requestGenerated(); } if (cbVroute->isChecked()) { requestVroute(); } } void PlanFlightDialog::requestGenerated() { if (edDep->text().length() != 4 || edDest->text().length() != 4) { lblGeneratedStatus->setText(QString("bad request")); return; } edGenerated->setText(edGenerated->text().toUpper()); Route* r = new Route(); r->provider = "user"; r->dep = edDep->text(); r->dest = edDest->text(); r->route = edGenerated->text(); r->comments = "your route"; r->lastChange = QString(); r->calculateWaypointsAndDistance(); _routes.append(r); lblGeneratedStatus->setText("1 route"); _routesModel.setClients(_routes); _routesSortModel->invalidate(); treeRoutes->header()->resizeSections(QHeaderView::ResizeToContents); gbResults->setTitle( QString("Results [%1-%2] (%3)") .arg(edDep->text(), edDest->text()) .arg(_routes.size()) ); } void PlanFlightDialog::requestVroute() { // We need to find some way to manage that this code is not abused // 'cause if it is - we are all blocked from vroute access! QString authCode("12f2c7fd6654be40037163242d87e86f"); //fixme if (authCode == "") { lblVrouteStatus->setText(QString("auth code unavailable. add it in the source")); return; } QUrl url("http://data.vroute.net/internal/query.php"); QUrlQuery urlQuery(url); urlQuery.addQueryItem(QString("auth_code"), authCode); if (!edCycle->text().trimmed().isEmpty()) { urlQuery.addQueryItem( QString("cycle"), edCycle->text().trimmed() ); // defaults to the last freely available } urlQuery.addQueryItem("type", "query"); urlQuery.addQueryItem("level", "0"); // details level, so far only 0 supported urlQuery.addQueryItem("dep", edDep->text().trimmed()); urlQuery.addQueryItem("arr", edDest->text().trimmed()); url.setQuery(urlQuery); _replyVroute = Net::g(url); connect(_replyVroute, &QNetworkReply::finished, this, &PlanFlightDialog::vrouteDownloaded); lblVrouteStatus->setText(QString("request sent...")); } void PlanFlightDialog::vrouteDownloaded() { disconnect(_replyVroute, &QNetworkReply::finished, this, &PlanFlightDialog::vrouteDownloaded); _replyVroute->deleteLater(); if (_replyVroute->error() != QNetworkReply::NoError) { lblVrouteStatus->setText( QString("error: %1") .arg(_replyVroute->errorString()) ); return; } if (_replyVroute->bytesAvailable() == 0) { lblVrouteStatus->setText("nothing returned"); } QList<Route*> newroutes; QString msg; QDomDocument domdoc = QDomDocument(); if (!domdoc.setContent(_replyVroute->readAll())) { return; } QDomElement root = domdoc.documentElement(); if (root.nodeName() != "flightplans") { return; } QDomElement e = root.firstChildElement(); while (!e.isNull()) { if (e.nodeName() == "result") { if (e.firstChildElement("num_objects").text() != "") { msg = QString("%1 route%2").arg( e.firstChildElement("num_objects").text(), e.firstChildElement("num_objects").text() == "1"? "": "s" ); } if (e.firstChildElement("version").text() != "1") { msg = QString("unknown version: %1").arg(e.firstChildElement("version").text()); } if (e.firstChildElement("result_code").text() != "200") { if (e.firstChildElement("result_code").text() == "400") { msg = (QString("bad request")); } else if (e.firstChildElement("result_code").text() == "403") { msg = (QString("unauthorized / maximum queries reached")); } else if (e.firstChildElement("result_code").text() == "404") { msg = (QString("flightplan not found / server error")); // should not be.. } // ..signaled for non-privileged queries (signals a server error) else if (e.firstChildElement("result_code").text() == "405") { msg = (QString("method not allowed")); } else if (e.firstChildElement("result_code").text() == "500") { msg = (QString("internal database error")); } else if (e.firstChildElement("result_code").text() == "501") { msg = (QString("level not implemented")); } else if (e.firstChildElement("result_code").text() == "503") { msg = (QString("allowed queries from one IP reached - try later")); } else if (e.firstChildElement("result_code").text() == "505") { msg = (QString("query mal-formed")); } else { msg = (QString("unknown error: #%1") .arg(e.firstChildElement("result_code").text())); } } } else if (e.nodeName() == "flightplan") { Route* r = new Route(); r->provider = QString("vroute"); r->routeDistance = QString("%1 NM").arg(e.firstChildElement("distance").text()); r->dep = edDep->text(); r->dest = edDest->text(); r->minFl = e.firstChildElement("min_fl").text(); r->maxFl = e.firstChildElement("max_fl").text(); r->route = e.firstChildElement("full_route").text(); r->lastChange = e.firstChildElement("last_change").text(); r->comments = e.firstChildElement("comments").text(); r->calculateWaypointsAndDistance(); newroutes.append(r); } e = e.nextSiblingElement(); } if (msg.isEmpty()) { msg = QString("%1 route%2").arg(newroutes.size()).arg(newroutes.size() == 1? "": "s"); } lblVrouteStatus->setText(msg); _routes += newroutes; _routesModel.setClients(_routes); _routesSortModel->invalidate(); treeRoutes->header()->resizeSections(QHeaderView::ResizeToContents); gbResults->setTitle( QString("Results [%1-%2] (%3)") .arg(edDep->text(), edDest->text()) .arg(_routes.size()) ); } void PlanFlightDialog::on_edDep_textChanged(QString str) { int cursorPosition = edDep->cursorPosition(); edDep->setText(str.toUpper()); edDep->setCursorPosition(cursorPosition); bDepDetails->setVisible(NavData::instance()->airports.contains(str.toUpper())); Airport* airport = NavData::instance()->airports.value(str.toUpper()); if (airport != 0) { bDepDetails->setText(airport->mapLabel()); bDepDetails->setToolTip(airport->toolTip()); } bDepDetails->setVisible(airport != 0); } void PlanFlightDialog::on_edDest_textChanged(QString str) { int cursorPosition = edDest->cursorPosition(); edDest->setText(str.toUpper()); edDest->setCursorPosition(cursorPosition); Airport* airport = NavData::instance()->airports.value(str.toUpper()); if (airport != 0) { bDestDetails->setText(airport->mapLabel()); bDestDetails->setToolTip(airport->toolTip()); } bDestDetails->setVisible(airport != 0); } void PlanFlightDialog::on_bDepDetails_clicked() { Airport* airport = NavData::instance()->airports.value(edDep->text().toUpper()); if (airport != 0 && airport->hasPrimaryAction()) { airport->primaryAction(); } } void PlanFlightDialog::on_bDestDetails_clicked() { Airport* airport = NavData::instance()->airports.value(edDest->text().toUpper()); if (airport != 0 && airport->hasPrimaryAction()) { airport->primaryAction(); } } void PlanFlightDialog::routeSelected(const QModelIndex& index) { if (!index.isValid()) { selectedRoute = 0; return; } if (selectedRoute != _routes[_routesSortModel->mapToSource(index).row()]) { selectedRoute = _routes[_routesSortModel->mapToSource(index).row()]; if (cbPlot->isChecked()) { on_cbPlot_toggled(true); } } } void PlanFlightDialog::plotPlannedRoute() const { if (selectedRoute == 0 || !cbPlot->isChecked()) { lblPlotStatus->setText("<span style='color: " + Settings::lightTextColor().name(QColor::HexArgb) + "'>no route to plot</span>"); return; } lblPlotStatus->setText(QString("<span style='color: " + Settings::lightTextColor().name(QColor::HexArgb) + "'>waypoints (calculated): <code>%1</code></span>").arg(selectedRoute->waypointsStr)); if (selectedRoute->waypoints.size() < 2) { return; } QList<DoublePair> points; foreach (const Waypoint* wp, selectedRoute->waypoints) { points.append(DoublePair(wp->lat, wp->lon)); } // @todo: make plot line color adjustable // @todo: are we GLing here ouside a GL context?! glColor4f((GLfloat) .7, (GLfloat) 1., (GLfloat) .4, (GLfloat) .8); glLineWidth(2.); glBegin(GL_LINE_STRIP); NavData::plotGreatCirclePoints(points); glEnd(); glPointSize(4.); glColor4f(.5, .5, .5, .5); glBegin(GL_POINTS); foreach (const DoublePair p, points) { VERTEX(p.first, p.second); } glEnd(); } void PlanFlightDialog::on_cbPlot_toggled(bool checked) { if (Window::instance(false) != 0) { Window::instance()->mapScreen->glWidget->invalidatePilots(); } lblPlotStatus->setVisible(checked); linePlotStatus->setVisible(checked); } void PlanFlightDialog::on_pbCopyToClipboard_clicked() { if (selectedRoute != 0) { QApplication::clipboard()->setText(selectedRoute->route); } } void PlanFlightDialog::on_pbVatsimPrefile_clicked() { if (selectedRoute != 0) { QUrl url = QUrl( QString("https://my.vatsim.net/pilots/flightplan?departure=%1&arrival=%2&route=%3&rmk=%4") .arg( QUrl::toPercentEncoding(selectedRoute->dep), QUrl::toPercentEncoding(selectedRoute->dest), QUrl::toPercentEncoding(selectedRoute->route), QUrl::toPercentEncoding("TCAS Simbrief lol no") ) , QUrl::TolerantMode ); if (url.isValid()) { if (!QDesktopServices::openUrl(url)) { QMessageBox::critical(qApp->activeWindow(), tr("Error"), tr("Could not invoke browser")); } } else { QMessageBox::critical(qApp->activeWindow(), tr("Error"), tr("URL %1 is invalid").arg(url.toString())); } } } void PlanFlightDialog::closeEvent(QCloseEvent* event) { Settings::setDialogPreferences( m_preferencesName, Settings::DialogPreferences { .size = size(), .pos = pos(), .geometry = saveGeometry() } ); event->accept(); }
13,213
C++
.cpp
328
32.716463
197
0.618606
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,643
ClientDetails.cpp
qutescoop_qutescoop/src/dialogs/ClientDetails.cpp
#include "ClientDetails.h" #include "Window.h" #include "../Client.h" #include "../Settings.h" ClientDetails::ClientDetails(QWidget* parent) : QDialog(parent) { setModal(false); } void ClientDetails::setMapObject(MapObject* object) { _lat = object->lat; _lon = object->lon; Client* c = dynamic_cast<Client*>(object); if (c != 0) { userId = c->userId; callsign = c->callsign; } else { userId = QString(); callsign = QString(); } } void ClientDetails::showOnMap() const { if ((!qFuzzyIsNull(_lat) || !qFuzzyIsNull(_lon)) && Window::instance(false) != 0) { Window::instance()->mapScreen->glWidget->setMapPosition(_lat, _lon, .06); } } void ClientDetails::friendClicked() const { if (!userId.isEmpty()) { if (Settings::friends().contains(userId)) { Settings::removeFriend(userId); } else { Settings::addFriend(userId); } if (Window::instance(false) != 0) { Window::instance()->refreshFriends(); Window::instance()->mapScreen->glWidget->newWhazzupData(true); } } }
1,142
C++
.cpp
38
24.263158
87
0.603825
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,644
BookedAtcDialog.cpp
qutescoop_qutescoop/src/dialogs/BookedAtcDialog.cpp
#include "BookedAtcDialog.h" #include "Window.h" #include "../models/BookedAtcDialogModel.h" #include "../models/filters/BookedAtcSortFilter.h" #include "../Settings.h" #include "../Whazzup.h" // singleton instance BookedAtcDialog* bookedAtcDialogInstance = 0; BookedAtcDialog* BookedAtcDialog::instance(bool createIfNoInstance, QWidget* parent) { if (bookedAtcDialogInstance == 0) { if (createIfNoInstance) { if (parent == 0) { parent = Window::instance(); } bookedAtcDialogInstance = new BookedAtcDialog(parent); } } return bookedAtcDialogInstance; } // destroys a singleton instance void BookedAtcDialog::destroyInstance() { delete bookedAtcDialogInstance; bookedAtcDialogInstance = 0; } BookedAtcDialog::BookedAtcDialog(QWidget* parent) : QDialog(parent) { setupUi(this); setWindowFlags(windowFlags() ^= Qt::WindowContextHelpButtonHint); _bookedAtcModel = new BookedAtcDialogModel; _bookedAtcSortModel = new BookedAtcSortFilter; _bookedAtcSortModel->setDynamicSortFilter(true); _bookedAtcSortModel->setSourceModel(_bookedAtcModel); _bookedAtcSortModel->setSortRole(Qt::UserRole); treeBookedAtc->setUniformRowHeights(true); treeBookedAtc->setModel(_bookedAtcSortModel); treeBookedAtc->sortByColumn(0, Qt::AscendingOrder); // disconnect to set DateTime without being disturbed // fixes https://sourceforge.net/p/qutescoop/tickets/5/ disconnect(dateTimeFilter, &QDateTimeEdit::dateTimeChanged, this, &BookedAtcDialog::on_dateTimeFilter_dateTimeChanged); _dateTimeFilter_old = QDateTime::currentDateTimeUtc(); dateTimeFilter->setDateTime(_dateTimeFilter_old); connect(dateTimeFilter, &QDateTimeEdit::dateTimeChanged, this, &BookedAtcDialog::on_dateTimeFilter_dateTimeChanged); connect(&_editFilterTimer, &QTimer::timeout, this, &BookedAtcDialog::performSearch); QFont font = lblStatusInfo->font(); font.setPointSize(lblStatusInfo->fontInfo().pointSize() - 1); lblStatusInfo->setFont(font); //make it a bit smaller than standard text connect(this, &BookedAtcDialog::needBookings, Whazzup::instance(), &Whazzup::downloadBookings); auto preferences = Settings::dialogPreferences(m_preferencesName); if (!preferences.size.isNull()) { resize(preferences.size); } if (!preferences.pos.isNull()) { move(preferences.pos); } if (!preferences.geometry.isNull()) { restoreGeometry(preferences.geometry); } refresh(); } void BookedAtcDialog::refresh() { qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); if ( Settings::downloadBookings() && !Whazzup::instance()->realWhazzupData().bookingsTime.isValid() ) { emit needBookings(); } const WhazzupData &data = Whazzup::instance()->realWhazzupData(); qDebug() << "BookedAtcDialog/refresh(): setting clients"; _bookedAtcModel->setClients(data.bookedControllers); QString msg = QString("Bookings %1 updated") .arg( data.bookingsTime.date() == QDateTime::currentDateTimeUtc().date() // is today? ? QString("today %1").arg(data.bookingsTime.time().toString("HHmm'z'")) : (data.bookingsTime.isValid() ? data.bookingsTime.toString("ddd MM/dd HHmm'z'") : "never") ); lblStatusInfo->setText(msg); _editFilterTimer.start(5); qApp->restoreOverrideCursor(); qDebug() << "BookedAtcDialog/refresh() -- finished"; } void BookedAtcDialog::setDateTime(const QDateTime &dateTime) { dateTimeFilter->setDateTime(dateTime); } void BookedAtcDialog::on_dateTimeFilter_dateTimeChanged(QDateTime dateTime) { // some niceify on the default behaviour, making the sections depend on each other disconnect(dateTimeFilter, &QDateTimeEdit::dateTimeChanged, this, &BookedAtcDialog::on_dateTimeFilter_dateTimeChanged); _editFilterTimer.stop(); // make year change if M 12+ or 0- if ( (_dateTimeFilter_old.date().month() == 12) && (dateTime.date().month() == 1) ) { dateTime = dateTime.addYears(1); } if ( (_dateTimeFilter_old.date().month() == 1) && (dateTime.date().month() == 12) ) { dateTime = dateTime.addYears(-1); } // make month change if d lastday+ or 0- if ( (_dateTimeFilter_old.date().day() == _dateTimeFilter_old.date().daysInMonth()) && (dateTime.date().day() == 1) ) { dateTime = dateTime.addMonths(1); } if ( (_dateTimeFilter_old.date().day() == 1) && (dateTime.date().day() == dateTime.date().daysInMonth()) ) { dateTime = dateTime.addMonths(-1); dateTime = dateTime.addDays( // compensate for month lengths dateTime.date().daysInMonth() - _dateTimeFilter_old.date().daysInMonth() ); } // make day change if h 23+ or 00- if ( (_dateTimeFilter_old.time().hour() == 23) && (dateTime.time().hour() == 0) ) { dateTime = dateTime.addDays(1); } if ( (_dateTimeFilter_old.time().hour() == 0) && (dateTime.time().hour() == 23) ) { dateTime = dateTime.addDays(-1); } // make hour change if m 59+ or 0- if ( (_dateTimeFilter_old.time().minute() == 59) && (dateTime.time().minute() == 0) ) { dateTime = dateTime.addSecs(60 * 60); } if ( (_dateTimeFilter_old.time().minute() == 0) && (dateTime.time().minute() == 59) ) { dateTime = dateTime.addSecs(-60 * 60); } _dateTimeFilter_old = dateTime; if ( dateTime.isValid() && (dateTime != dateTimeFilter->dateTime()) ) { dateTimeFilter->setDateTime(dateTime); } connect(dateTimeFilter, &QDateTimeEdit::dateTimeChanged, this, &BookedAtcDialog::on_dateTimeFilter_dateTimeChanged); _editFilterTimer.start(1000); } void BookedAtcDialog::on_editFilter_textChanged(QString) { _editFilterTimer.start(1000); } void BookedAtcDialog::on_spinHours_valueChanged(int) { _editFilterTimer.start(1000); } void BookedAtcDialog::performSearch() { qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); _editFilterTimer.stop(); // Text qDebug() << "BookedAtcDialog/performSearch(): building RegExp"; QRegExp regex; // @todo this tries to cater for both ways (wildcards and regexp) but it does a bad job at that. QStringList tokens = editFilter->text() .replace(QRegExp("\\*"), ".*") .split(QRegExp("[ \\,]+"), Qt::SkipEmptyParts); if (tokens.size() == 1) { regex = QRegExp("^" + tokens.first() + ".*", Qt::CaseInsensitive); } else if (tokens.size() == 0) { regex = QRegExp(""); } else { QString regExpStr = "^(" + tokens.first(); for (int i = 1; i < tokens.size(); i++) { regExpStr += "|" + tokens[i]; } regExpStr += ".*)"; regex = QRegExp(regExpStr, Qt::CaseInsensitive); } _bookedAtcSortModel->setFilterKeyColumn(-1); _bookedAtcSortModel->setFilterRegExp(regex); //Date, Time, TimeSpan QDateTime from = dateTimeFilter->dateTime().toUTC(); QDateTime to = from.addSecs(spinHours->value() * 3600); _bookedAtcSortModel->setDateTimeRange(from, to); boxResults->setTitle(QString("Results (%1)").arg(_bookedAtcSortModel->rowCount())); qApp->restoreOverrideCursor(); qDebug() << "BookedAtcDialog/performSearch() -- finished"; } void BookedAtcDialog::on_tbPredict_clicked() { close(); Window::instance()->actionPredict->setChecked(true); Window::instance()->dateTimePredict->setDateTime( dateTimeFilter->dateTime() ); } void BookedAtcDialog::closeEvent(QCloseEvent* event) { Settings::setDialogPreferences( m_preferencesName, Settings::DialogPreferences { .size = size(), .pos = pos(), .geometry = saveGeometry() } ); event->accept(); }
8,109
C++
.cpp
213
31.661972
123
0.650471
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,645
PreferencesDialog.cpp
qutescoop_qutescoop/src/dialogs/PreferencesDialog.cpp
#include "PreferencesDialog.h" #include "Window.h" #include "../Settings.h" //singleton instance PreferencesDialog* preferencesDialogInstance = 0; PreferencesDialog* PreferencesDialog::instance(bool createIfNoInstance, QWidget* parent) { if (preferencesDialogInstance == 0) { if (createIfNoInstance) { if (parent == 0) { parent = Window::instance(); } preferencesDialogInstance = new PreferencesDialog(parent); } } return preferencesDialogInstance; } PreferencesDialog::PreferencesDialog(QWidget* parent) : QDialog(parent), _settingsLoaded(false) { setupUi(this); setWindowFlags(windowFlags() ^= Qt::WindowContextHelpButtonHint); auto preferences = Settings::dialogPreferences(m_preferencesName); if (!preferences.size.isNull()) { resize(preferences.size); } if (!preferences.pos.isNull()) { move(preferences.pos); } if (!preferences.geometry.isNull()) { restoreGeometry(preferences.geometry); } tabs->setCurrentIndex(0); loadSettings(); } void PreferencesDialog::loadSettings() { _settingsLoaded = false; QColor color; spinBoxDownloadInterval->setValue(Settings::downloadInterval()); cbDownloadOnStartup->setChecked(Settings::downloadOnStartup()); cbDownloadPeriodically->setChecked(Settings::downloadPeriodically()); cbNetwork->setCurrentIndex(Settings::downloadNetwork()); editUserDefinedLocation->setText(Settings::userDownloadLocation()); editUserDefinedLocation->setEnabled(Settings::downloadNetwork() == 1); lbluserDefinedLocation->setEnabled(Settings::downloadNetwork() == 1); cbSaveWhazzupData->setChecked(Settings::saveWhazzupData()); gbDownloadBookings->setChecked( Settings::downloadBookings() ); // must be after cbNetwork editBookingsLocation->setText(Settings::bookingsLocation()); cbBookingsPeriodically->setChecked(Settings::bookingsPeriodically()); sbBookingsInterval->setValue(Settings::bookingsInterval()); sbMaxTextLabels->setValue(Settings::maxLabels()); groupBoxProxy->setChecked(Settings::useProxy()); editProxyServer->setText(Settings::proxyServer()); editProxyPort->setText(QString("%1").arg(Settings::proxyPort())); editProxyUser->setText(Settings::proxyUser()); editProxyPassword->setText(Settings::proxyPassword()); // directories lblDownloadedDirectory->setText(Settings::dataDirectory("downloaded/")); // XPlane-Navdata editNavdir->setText(Settings::navdataDirectory()); editNavdir->setEnabled(Settings::useNavdata()); browseNavdirButton->setEnabled(Settings::useNavdata()); cbUseNavDatabase->setChecked(Settings::useNavdata()); // Display cbRememberMapPositionOnClose->setChecked(Settings::rememberMapPositionOnClose()); spinBoxTimeline->setValue(Settings::timelineSeconds()); // Display -> labels cbLabelAlwaysBackdrop->setChecked(Settings::labelAlwaysBackdropped()); color = Settings::labelHoveredBgColor(); pbLabelHoveredBgColor->setText(color.name()); pbLabelHoveredBgColor->setPalette(QPalette(color)); color = Settings::labelHoveredBgDarkColor(); pbLabelHoveredBgDarkColor->setText(color.name()); pbLabelHoveredBgDarkColor->setPalette(QPalette(color)); // Display -> labels sbHoverDebounce->setValue(Settings::hoverDebounceMs()); // OpenGL glTextures->setChecked(Settings::glTextures()); // textures QDir texDir = QDir(Settings::dataDirectory("textures/")); QStringList nameFilters; foreach (const QByteArray fmt, QImageReader::supportedImageFormats()) { nameFilters.append("*." + fmt); } texDir.setNameFilters(nameFilters); qDebug() << "Supported texture formats:" << QImageReader::supportedImageFormats() << ". See" << Settings::dataDirectory("textures/+notes.txt") << "for more information."; glTextureEarth->setToolTip( QString( "Shows all textures from\n%1\n in the supported formats\n" "See +notes.txt in the texture directory for more information." ). arg(Settings::dataDirectory("textures")) ); glTextureEarth->addItems(texDir.entryList()); // first without icons, use lazy-load QTimer::singleShot(100, this, SLOT(lazyloadTextureIcons())); glTextureEarth->setCurrentIndex(glTextureEarth->findText(Settings::glTextureEarth())); glStippleLines->setChecked(Settings::glStippleLines()); cbBlend->setChecked(Settings::glBlending()); cbLineSmoothing->setChecked(Settings::displaySmoothLines()); cbDotSmoothing->setChecked(Settings::displaySmoothDots()); cbLighting->setChecked(Settings::glLighting()); glEarthShininess->setValue(Settings::earthShininess()); glLights->setValue(Settings::glLights()); glLightsSpread->setValue(Settings::glLightsSpread()); color = Settings::sunLightColor(); pbSunLightColor->setText(color.name()); pbSunLightColor->setPalette(QPalette(color)); color = Settings::specularColor(); pbSpecularLightColor->setText(color.name()); pbSpecularLightColor->setPalette(QPalette(color)); // stylesheet tedStylesheet->setPlainText(Settings::stylesheet()); // earthspace sbEarthGridEach->setValue(Settings::earthGridEach()); color = Settings::backgroundColor(); pbBackgroundColor->setText(color.name()); pbBackgroundColor->setPalette(QPalette(color)); color = Settings::globeColor(); pbGlobeColor->setText(color.name()); pbGlobeColor->setPalette(QPalette(color)); color = Settings::gridLineColor(); pbGridLineColor->setText(color.name()); pbGridLineColor->setPalette(QPalette(color)); sbGridLineStrength->setValue(Settings::gridLineStrength()); color = Settings::coastLineColor(); pbCoastLineColor->setText(color.name()); pbCoastLineColor->setPalette(QPalette(color)); sbCoastLineStrength->setValue(Settings::coastLineStrength()); color = Settings::countryLineColor(); pbCountryLineColor->setText(color.name()); pbCountryLineColor->setPalette(QPalette(color)); sbCountryLineStrength->setValue(Settings::countryLineStrength()); color = Settings::firBorderLineColor(); pbFirBorderLineColor->setText(color.name()); pbFirBorderLineColor->setPalette(QPalette(color)); sbFirBorderLineStrength->setValue(Settings::firBorderLineStrength()); color = Settings::firFillColor(); pbFirFillColor->setText(color.name()); pbFirFillColor->setPalette(QPalette(color)); color = Settings::firFontColor(); pbFirFontColor->setText(color.name()); pbFirFontColor->setPalette(QPalette(color)); pbFirFont->setFont(Settings::firFont()); color = Settings::firFontSecondaryColor(); pbFirFontSecondaryColor->setText(color.name()); pbFirFontSecondaryColor->setPalette(QPalette(color)); pbFirFontSecondary->setFont(Settings::firFontSecondary()); lineEditFirPrimaryContent->setText(Settings::firPrimaryContent()); lineEditFirPrimaryContentHovered->setText(Settings::firPrimaryContentHovered()); plainTextEditFirSecondaryContent->setPlainText(Settings::firSecondaryContent()); plainTextEditFirSecondaryContentHovered->setPlainText(Settings::firSecondaryContentHovered()); color = Settings::firHighlightedBorderLineColor(); pbFirHighlightedBorderLineColor->setText(color.name()); pbFirHighlightedBorderLineColor->setPalette(QPalette(color)); sbFirHighlightedBorderLineStrength->setValue(Settings::firHighlightedBorderLineStrength()); color = Settings::firHighlightedFillColor(); pbFirHighlightedFillColor->setText(color.name()); pbFirHighlightedFillColor->setPalette(QPalette(color)); // airport traffic settings cbFilterTraffic->setChecked(Settings::filterTraffic()); spFilterDistance->setValue(Settings::filterDistance()); spFilterArriving->setValue(Settings::filterArriving()); cbShowCongestion->setChecked(Settings::showAirportCongestion()); btnCongestionShowRing->setChecked(Settings::showAirportCongestionRing()); btnCongestionShowGlow->setChecked(Settings::showAirportCongestionGlow()); sbCongestionMovementsMin->setValue(Settings::airportCongestionMovementsMin()); sbCongestionRadiusMin->setValue(Settings::airportCongestionRadiusMin()); color = Settings::airportCongestionColorMin(); pbCongestionColorMin->setText(color.name()); pbCongestionColorMin->setPalette(QPalette(color)); sbCongestionBorderLineStrengthMin->setValue(Settings::airportCongestionBorderLineStrengthMin()); sbCongestionMovementsMax->setValue(Settings::airportCongestionMovementsMax()); sbCongestionRadiusMax->setValue(Settings::airportCongestionRadiusMax()); color = Settings::airportCongestionColorMax(); pbCongestionColorMax->setText(color.name()); pbCongestionColorMax->setPalette(QPalette(color)); sbCongestionBorderLineStrengthMax->setValue(Settings::airportCongestionBorderLineStrengthMax()); // airport settings color = Settings::inactiveAirportFontColor(); pbInactAirportFontColor->setText(color.name()); pbInactAirportFontColor->setPalette(QPalette(color)); pbInactAirportFont->setFont(Settings::inactiveAirportFont()); color = Settings::airportFontColor(); pbAirportFontColor->setText(color.name()); pbAirportFontColor->setPalette(QPalette(color)); pbAirportFont->setFont(Settings::airportFont()); color = Settings::airportFontSecondaryColor(); pbAirportFontSecondaryColor->setText(color.name()); pbAirportFontSecondaryColor->setPalette(QPalette(color)); pbAirportFontSecondary->setFont(Settings::airportFontSecondary()); lineEditAirportPrimaryContent->setText(Settings::airportPrimaryContent()); lineEditAirportPrimaryContentHovered->setText(Settings::airportPrimaryContentHovered()); plainTextEditAirportSecondaryContent->setPlainText(Settings::airportSecondaryContent()); plainTextEditAirportSecondaryContentHovered->setPlainText(Settings::airportSecondaryContentHovered()); color = Settings::appBorderLineColor(); pbAppBorderLineColor->setText(color.name()); pbAppBorderLineColor->setPalette(QPalette(color)); sbAppBorderLineStrength->setValue(Settings::appBorderLineWidth()); color = Settings::appCenterColor(); pbAppColorCenter->setText(color.name()); pbAppColorCenter->setPalette(QPalette(color)); color = Settings::appMarginColor(); pbAppColorMargin->setText(color.name()); pbAppColorMargin->setPalette(QPalette(color)); color = Settings::twrBorderLineColor(); pbTwrBorderLineColor->setText(color.name()); pbTwrBorderLineColor->setPalette(QPalette(color)); sbTwrBorderLineStrength->setValue(Settings::twrBorderLineWidth()); color = Settings::twrCenterColor(); pbTwrColorCenter->setText(color.name()); pbTwrColorCenter->setPalette(QPalette(color)); color = Settings::twrMarginColor(); pbTwrColorMargin->setText(color.name()); pbTwrColorMargin->setPalette(QPalette(color)); color = Settings::gndBorderLineColor(); pbGndBorderLineColor->setText(color.name()); pbGndBorderLineColor->setPalette(QPalette(color)); sbGndBorderLineStrength->setValue(Settings::gndBorderLineWidth()); color = Settings::gndFillColor(); pbGndFillColor->setText(color.name()); pbGndFillColor->setPalette(QPalette(color)); color = Settings::delBorderLineColor(); pbDelBorderLineColor->setText(color.name()); pbDelBorderLineColor->setPalette(QPalette(color)); sbDelBorderLineStrength->setValue(Settings::delBorderLineWidth()); color = Settings::delFillColor(); pbDelFillColor->setText(color.name()); pbDelFillColor->setPalette(QPalette(color)); color = Settings::airportDotColor(); pbAirportDotColor->setText(color.name()); pbAirportDotColor->setPalette(QPalette(color)); sbAirportDotSize->setValue(Settings::airportDotSize()); color = Settings::inactiveAirportDotColor(); pbInactAirportDotColor->setText(color.name()); pbInactAirportDotColor->setPalette(QPalette(color)); sbInactAirportDotSize->setValue(Settings::inactiveAirportDotSize()); // pilot settings color = Settings::pilotFontColor(); pbPilotFontColor->setText(color.name()); pbPilotFontColor->setPalette(QPalette(color)); pbPilotFont->setFont(Settings::pilotFont()); color = Settings::pilotFontSecondaryColor(); pbPilotFontSecondaryColor->setText(color.name()); pbPilotFontSecondaryColor->setPalette(QPalette(color)); pbPilotFontSecondary->setFont(Settings::pilotFontSecondary()); lineEditPilotPrimaryContent->setText(Settings::pilotPrimaryContent()); lineEditPilotPrimaryContentHovered->setText(Settings::pilotPrimaryContentHovered()); plainTextEditPilotSecondaryContent->setPlainText(Settings::pilotSecondaryContent()); plainTextEditPilotSecondaryContentHovered->setPlainText(Settings::pilotSecondaryContentHovered()); color = Settings::pilotDotColor(); pbPilotDotColor->setText(color.name()); pbPilotDotColor->setPalette(QPalette(color)); sbPilotDotSize->setValue(Settings::pilotDotSize()); color = Settings::leaderLineColor(); pbTimeLineColor->setText(color.name()); pbTimeLineColor->setPalette(QPalette(color)); sbTimeLineStrength->setValue(Settings::timeLineStrength()); color = Settings::depLineColor(); pbDepLineColor->setText(color.name()); pbDepLineColor->setPalette(QPalette(color)); sbDepLineStrength->setValue(Settings::depLineStrength()); cbDepLineDashed->setChecked(Settings::depLineDashed()); color = Settings::destImmediateLineColor(); pbDestImmediateLineColor->setText(color.name()); pbDestImmediateLineColor->setPalette(QPalette(color)); sbDestImmediateDuration->setValue(Settings::destImmediateDurationMin()); sbDestImmediateLineStrength->setValue(Settings::destImmediateLineStrength()); color = Settings::destLineColor(); pbDestLineColor->setText(color.name()); pbDestLineColor->setPalette(QPalette(color)); sbDestLineStrength->setValue(Settings::destLineStrength()); cbDestLineDashed->setChecked(Settings::destLineDashed()); color = Settings::waypointsDotColor(); waypointsDotColor->setText(color.name()); waypointsDotColor->setPalette(QPalette(color)); waypointsDotSize->setValue(Settings::waypointsDotSize()); color = Settings::waypointsFontColor(); waypointsFontColor->setText(color.name()); waypointsFontColor->setPalette(QPalette(color)); waypointsFont->setFont(Settings::waypointsFont()); // updates + feedback cbCheckForUpdates->setChecked(Settings::checkForUpdates()); // zooming sbZoomFactor->setValue(Settings::zoomFactor()); useSelectionRectangle->setChecked(Settings::useSelectionRectangle()); //highlight Friends sb_highlightFriendsLineWidth->setValue(Settings::highlightLineWidth()); pb_highlightFriendsColor->setPalette(QPalette(Settings::friendsHighlightColor())); pb_highlightFriendsColor->setText(Settings::friendsHighlightColor().name()); cb_Animation->setChecked(Settings::animateFriendsHighlight()); // FINISHED _settingsLoaded = true; } // icons: this might be time-consuming because all textures are loaded, but it is // also very "Qute" ;) // memory seems to be handled fine and released directly after painting. It // expands to +40MB though while loading. void PreferencesDialog::lazyloadTextureIcons() { for (int i = 0; i < glTextureEarth->count(); i++) { if (glTextureEarth->itemIcon(i).isNull()) { qDebug() << "PreferencesDialog::lazyloadTextureIcons()" << Settings::dataDirectory( QString("textures/%1").arg(glTextureEarth->itemText(i)) ); QPixmap* pm = new QPixmap( Settings::dataDirectory( QString("textures/%1").arg(glTextureEarth->itemText(i)) ) ); QIcon icon = QIcon( // smooth transform uses ~2x the CPU.. pm->scaled( 128, 64, Qt::KeepAspectRatio, // ..cycles compared to.. //Qt::SmoothTransformation)); // fast transform Qt::FastTransformation ) ); glTextureEarth->setItemIcon(i, icon); delete pm; QTimer::singleShot(100, this, SLOT(lazyloadTextureIcons())); return; } } } // airport traffic settings void PreferencesDialog::on_cbFilterTraffic_stateChanged(int state) { if (!_settingsLoaded) { return; } Settings::setFilterTraffic(state); } void PreferencesDialog::on_spFilterDistance_valueChanged(int value) { if (!_settingsLoaded) { return; } Settings::setFilterDistance(value); } void PreferencesDialog::on_spFilterArriving_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setFilterArriving(value); } void PreferencesDialog::on_sbCongestionMovementsMin_valueChanged(int value) { if (!_settingsLoaded) { return; } Settings::setAirportCongestionMovementsMin(value); } void PreferencesDialog::on_sbCongestionMovementsMax_valueChanged(int value) { if (!_settingsLoaded) { return; } Settings::setAirportCongestionMovementsMax(value); } void PreferencesDialog::on_sbMaxTextLabels_valueChanged(int value) { if (!_settingsLoaded) { return; } Settings::setMaxLabels(value); } void PreferencesDialog::on_spinBoxDownloadInterval_valueChanged(int value) { if (!_settingsLoaded) { return; } Settings::setDownloadInterval(value); } void PreferencesDialog::on_cbDownloadPeriodically_stateChanged(int state) { if (!_settingsLoaded) { return; } Settings::setDownloadPeriodically(state == Qt::Checked); } void PreferencesDialog::on_cbUseNavDatabase_stateChanged(int state) { if (!_settingsLoaded) { return; } Settings::setUseNavdata(state == Qt::Checked); } void PreferencesDialog::on_cbResetConfiguration_stateChanged(int state) { if (!_settingsLoaded) { return; } Settings::setResetOnNextStart(state == Qt::Checked); } void PreferencesDialog::on_cbCheckForUpdates_stateChanged(int state) { if (!_settingsLoaded) { return; } Settings::setCheckForUpdates(state == Qt::Checked); } void PreferencesDialog::on_cbDownloadOnStartup_stateChanged(int state) { if (!_settingsLoaded) { return; } Settings::setDownloadOnStartup(state == Qt::Checked); } void PreferencesDialog::on_cbNetwork_currentIndexChanged(int index) { if (!_settingsLoaded) { return; } Settings::setDownloadNetwork(index); switch (index) { case 0: // VATSIM gbDownloadBookings->setChecked(true); break; case 1: // user defined gbDownloadBookings->setChecked(false); break; } editUserDefinedLocation->setEnabled(index == 1); lbluserDefinedLocation->setEnabled(index == 1); } void PreferencesDialog::on_editUserDefinedLocation_editingFinished() { if (!_settingsLoaded) { return; } Settings::setUserDownloadLocation(editUserDefinedLocation->text()); Settings::setDownloadNetwork(Settings::downloadNetwork()); // To force a reload of the status data } void PreferencesDialog::on_cbSaveWhazzupData_stateChanged(int state) { if (!_settingsLoaded) { return; } Settings::setSaveWhazzupData(state == Qt::Checked); } void PreferencesDialog::on_groupBoxProxy_toggled(bool checked) { if (!_settingsLoaded) { return; } Settings::setUseProxy(checked); } void PreferencesDialog::on_editProxyServer_editingFinished() { if (!_settingsLoaded) { return; } Settings::setProxyServer(editProxyServer->text()); } void PreferencesDialog::on_editProxyPort_editingFinished() { if (!_settingsLoaded) { return; } Settings::setProxyPort(editProxyPort->text().toInt()); } void PreferencesDialog::on_editProxyUser_editingFinished() { if (!_settingsLoaded) { return; } Settings::setProxyUser(editProxyUser->text()); } void PreferencesDialog::on_editProxyPassword_editingFinished() { if (!_settingsLoaded) { return; } Settings::setProxyPassword(editProxyPassword->text()); } void PreferencesDialog::on_spinBoxTimeline_valueChanged(int value) { if (!_settingsLoaded) { return; } Settings::setTimelineSeconds(value); } void PreferencesDialog::on_cbLineSmoothing_stateChanged(int state) { if (!_settingsLoaded) { return; } Settings::setDisplaySmoothLines(state == Qt::Checked); } void PreferencesDialog::on_cbDotSmoothing_stateChanged(int state) { if (!_settingsLoaded) { return; } Settings::setDisplaySmoothDots(state == Qt::Checked); } void PreferencesDialog::on_editNavdir_editingFinished() { if (!_settingsLoaded) { return; } Settings::setNavdataDirectory(editNavdir->text()); } void PreferencesDialog::on_browseNavdirButton_clicked() { QFileDialog* dialog = new QFileDialog( this, "Select Database Directory", Settings::navdataDirectory() ); dialog->setFileMode(QFileDialog::Directory); dialog->setOption(QFileDialog::ShowDirsOnly); int result = dialog->exec(); if (result == QDialog::Rejected) { delete dialog; return; } QString dir = dialog->directory().absolutePath(); editNavdir->setText(dir); Settings::setNavdataDirectory(dir); delete dialog; } void PreferencesDialog::on_pbBackgroundColor_clicked() { QColor color = QColorDialog::getColor( Settings::backgroundColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbBackgroundColor->setText(color.name()); pbBackgroundColor->setPalette(QPalette(color)); Settings::setBackgroundColor(color); } } void PreferencesDialog::on_pbGlobeColor_clicked() { QColor color = QColorDialog::getColor( Settings::globeColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbGlobeColor->setText(color.name()); pbGlobeColor->setPalette(QPalette(color)); Settings::setGlobeColor(color); } } void PreferencesDialog::on_pbGridLineColor_clicked() { QColor color = QColorDialog::getColor( Settings::gridLineColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbGridLineColor->setText(color.name()); pbGridLineColor->setPalette(QPalette(color)); Settings::setGridLineColor(color); } } void PreferencesDialog::on_sbGridLineStrength_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setGridLineStrength(value); } void PreferencesDialog::on_pbCountryLineColor_clicked() { QColor color = QColorDialog::getColor( Settings::countryLineColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbCountryLineColor->setText(color.name()); pbCountryLineColor->setPalette(QPalette(color)); Settings::setCountryLineColor(color); } } void PreferencesDialog::on_sbCountryLineStrength_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setCountryLineStrength(value); } void PreferencesDialog::on_pbCoastLineColor_clicked() { QColor color = QColorDialog::getColor( Settings::coastLineColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbCoastLineColor->setText(color.name()); pbCoastLineColor->setPalette(QPalette(color)); Settings::setCoastLineColor(color); } } void PreferencesDialog::on_sbCoastLineStrength_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setCoastLineStrength(value); } void PreferencesDialog::on_pbFirBorderLineColor_clicked() { QColor color = QColorDialog::getColor( Settings::firBorderLineColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbFirBorderLineColor->setText(color.name()); pbFirBorderLineColor->setPalette(QPalette(color)); Settings::setFirBorderLineColor(color); } } void PreferencesDialog::on_sbFirBorderLineStrength_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setFirBorderLineStrength(value); } void PreferencesDialog::on_pbFirFontColor_clicked() { QColor color = QColorDialog::getColor( Settings::firFontColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbFirFontColor->setText(color.name()); pbFirFontColor->setPalette(QPalette(color)); Settings::setFirFontColor(color); } } void PreferencesDialog::on_pbFirFont_clicked() { bool ok; QFont font = QFontDialog::getFont(&ok, Settings::firFont(), this); if (ok) { pbFirFont->setFont(font); Settings::setFirFont(font); } } void PreferencesDialog::on_pbFirFillColor_clicked() { QColor color = QColorDialog::getColor( Settings::firFillColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbFirFillColor->setText(color.name()); pbFirFillColor->setPalette(QPalette(color)); Settings::setFirFillColor(color); } } void PreferencesDialog::on_pbFirHighlightedBorderLineColor_clicked() { QColor color = QColorDialog::getColor( Settings::firHighlightedBorderLineColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbFirHighlightedBorderLineColor->setText(color.name()); pbFirHighlightedBorderLineColor->setPalette(QPalette(color)); Settings::setFirHighlightedBorderLineColor(color); } } void PreferencesDialog::on_sbFirHighlightedBorderLineStrength_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setFirHighlightedBorderLineStrength(value); } void PreferencesDialog::on_pbFirHighlightedFillColor_clicked() { QColor color = QColorDialog::getColor( Settings::firHighlightedFillColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbFirHighlightedFillColor->setText(color.name()); pbFirHighlightedFillColor->setPalette(QPalette(color)); Settings::setFirHighlightedFillColor(color); } } void PreferencesDialog::on_pbAirportFontColor_clicked() { QColor color = QColorDialog::getColor( Settings::airportFontColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbAirportFontColor->setText(color.name()); pbAirportFontColor->setPalette(QPalette(color)); Settings::setAirportFontColor(color); } } void PreferencesDialog::on_pbAirportFont_clicked() { bool ok; QFont font = QFontDialog::getFont(&ok, Settings::airportFont(), this); if (ok) { pbAirportFont->setFont(font); Settings::setAirportFont(font); } } void PreferencesDialog::on_pbAppBorderLineColor_clicked() { QColor color = QColorDialog::getColor( Settings::appBorderLineColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbAppBorderLineColor->setText(color.name()); pbAppBorderLineColor->setPalette(QPalette(color)); Settings::setAppBorderLineColor(color); } } void PreferencesDialog::on_sbAppBorderLineStrength_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setAppBorderLineStrength(value); } void PreferencesDialog::on_pbAppColorCenter_clicked() { QColor color = QColorDialog::getColor( Settings::appCenterColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbAppColorCenter->setText(color.name()); pbAppColorCenter->setPalette(QPalette(color)); Settings::setAppCenterColor(color); } } void PreferencesDialog::on_pbAppColorMargin_clicked() { QColor color = QColorDialog::getColor( Settings::appMarginColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbAppColorMargin->setText(color.name()); pbAppColorMargin->setPalette(QPalette(color)); Settings::setAppMarginColor(color); } } void PreferencesDialog::on_pbTwrColorCenter_clicked() { QColor color = QColorDialog::getColor( Settings::twrCenterColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbTwrColorCenter->setText(color.name()); pbTwrColorCenter->setPalette(QPalette(color)); Settings::setTwrCenterColor(color); } } void PreferencesDialog::on_pbTwrColorMargin_clicked() { QColor color = QColorDialog::getColor( Settings::twrMarginColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbTwrColorMargin->setText(color.name()); pbTwrColorMargin->setPalette(QPalette(color)); Settings::setTwrMarginColor(color); } } void PreferencesDialog::on_pbGndBorderLineColor_clicked() { QColor color = QColorDialog::getColor( Settings::gndBorderLineColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbGndBorderLineColor->setText(color.name()); pbGndBorderLineColor->setPalette(QPalette(color)); Settings::setGndBorderLineColor(color); } } void PreferencesDialog::on_sbGndBorderLineStrength_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setGndBorderLineStrength(value); } void PreferencesDialog::on_pbGndFillColor_clicked() { QColor color = QColorDialog::getColor( Settings::gndFillColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbGndFillColor->setText(color.name()); pbGndFillColor->setPalette(QPalette(color)); Settings::setGndFillColor(color); } } void PreferencesDialog::on_pbAirportDotColor_clicked() { QColor color = QColorDialog::getColor( Settings::airportDotColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbAirportDotColor->setText(color.name()); pbAirportDotColor->setPalette(QPalette(color)); Settings::setAirportDotColor(color); } } void PreferencesDialog::on_sbAirportDotSize_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setAirportDotSize(value); } void PreferencesDialog::on_pbPilotFontColor_clicked() { QColor color = QColorDialog::getColor( Settings::pilotFontColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbPilotFontColor->setText(color.name()); pbPilotFontColor->setPalette(QPalette(color)); Settings::setPilotFontColor(color); } } void PreferencesDialog::on_pbPilotFont_clicked() { bool ok; QFont font = QFontDialog::getFont(&ok, Settings::pilotFont(), this); if (ok) { pbPilotFont->setFont(font); Settings::setPilotFont(font); } } void PreferencesDialog::on_pbPilotDotColor_clicked() { QColor color = QColorDialog::getColor( Settings::pilotDotColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbPilotDotColor->setText(color.name()); pbPilotDotColor->setPalette(QPalette(color)); Settings::setPilotDotColor(color); } } void PreferencesDialog::on_sbPilotDotSize_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setPilotDotSize(value); } void PreferencesDialog::on_pbTimeLineColor_clicked() { QColor color = QColorDialog::getColor( Settings::leaderLineColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbTimeLineColor->setText(color.name()); pbTimeLineColor->setPalette(QPalette(color)); Settings::setLeaderLineColor(color); } } void PreferencesDialog::on_sbTimeLineStrength_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setTimeLineStrength(value); } void PreferencesDialog::on_pbDepLineColor_clicked() { QColor color = QColorDialog::getColor( Settings::depLineColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbDepLineColor->setText(color.name()); pbDepLineColor->setPalette(QPalette(color)); Settings::setDepLineColor(color); } } void PreferencesDialog::on_sbDepLineStrength_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setDepLineStrength(value); } void PreferencesDialog::on_pbDestLineColor_clicked() { QColor color = QColorDialog::getColor( Settings::destLineColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbDestLineColor->setText(color.name()); pbDestLineColor->setPalette(QPalette(color)); Settings::setDestLineColor(color); } } void PreferencesDialog::on_sbDestLineStrength_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setDestLineStrength(value); } void PreferencesDialog::on_cbDepLineDashed_toggled(bool checked) { if (!_settingsLoaded) { return; } Settings::setDepLineDashed(checked); } void PreferencesDialog::on_cbDestLineDashed_toggled(bool checked) { if (!_settingsLoaded) { return; } Settings::setDestLineDashed(checked); } void PreferencesDialog::on_waypointsDotSize_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setWaypointsDotSize(value); } void PreferencesDialog::on_waypointsDotColor_clicked() { QColor color = QColorDialog::getColor( Settings::waypointsDotColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { waypointsDotColor->setText(color.name()); waypointsDotColor->setPalette(QPalette(color)); Settings::setWaypointsDotColor(color); } } void PreferencesDialog::on_waypointsFontColor_clicked() { QColor color = QColorDialog::getColor( Settings::waypointsFontColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { waypointsFontColor->setText(color.name()); waypointsFontColor->setPalette(QPalette(color)); Settings::setWaypointsFontColor(color); } } void PreferencesDialog::on_waypointsFont_clicked() { bool ok; QFont font = QFontDialog::getFont(&ok, Settings::waypointsFont(), this); if (ok) { waypointsFont->setFont(font); Settings::setWaypointsFont(font); } } void PreferencesDialog::on_pbInactAirportFontColor_clicked() { QColor color = QColorDialog::getColor( Settings::inactiveAirportFontColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbInactAirportFontColor->setText(color.name()); pbInactAirportFontColor->setPalette(QPalette(color)); Settings::setInactiveAirportFontColor(color); } } void PreferencesDialog::on_pbInactAirportFont_clicked() { bool ok; QFont font = QFontDialog::getFont(&ok, Settings::inactiveAirportFont(), this); if (ok) { pbInactAirportFont->setFont(font); Settings::setInactiveAirportFont(font); } } void PreferencesDialog::on_pbInactAirportDotColor_clicked() { QColor color = QColorDialog::getColor( Settings::inactiveAirportDotColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbInactAirportDotColor->setText(color.name()); pbInactAirportDotColor->setPalette(QPalette(color)); Settings::setInactiveAirportDotColor(color); } } void PreferencesDialog::on_sbInactAirportDotSize_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setInactiveAirportDotSize(value); } void PreferencesDialog::on_cbShowCongestion_clicked(bool checked) { if (!_settingsLoaded) { return; } Settings::setAirportCongestion(checked); } void PreferencesDialog::on_pbCongestionColorMin_clicked() { QColor color = QColorDialog::getColor( Settings::airportCongestionColorMin(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbCongestionColorMin->setText(color.name()); pbCongestionColorMin->setPalette(QPalette(color)); Settings::setAirportCongestionColorMin(color); } } void PreferencesDialog::on_pbCongestionColorMax_clicked() { QColor color = QColorDialog::getColor( Settings::airportCongestionColorMax(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbCongestionColorMax->setText(color.name()); pbCongestionColorMax->setPalette(QPalette(color)); Settings::setAirportCongestionColorMax(color); } } void PreferencesDialog::on_sbCongestionBorderLineStrengthMin_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setAirportCongestionBorderLineStrengthMin(value); } void PreferencesDialog::on_sbCongestionBorderLineStrengthMax_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setAirportCongestionBorderLineStrengthMax(value); } void PreferencesDialog::on_cbBlend_toggled(bool checked) { if (!_settingsLoaded) { return; } Settings::setGlBlending(checked); } void PreferencesDialog::on_editBookingsLocation_editingFinished() { if (!_settingsLoaded) { return; } Settings::setBookingsLocation(editBookingsLocation->text()); } void PreferencesDialog::on_cbBookingsPeriodically_toggled(bool checked) { if (!_settingsLoaded) { return; } Settings::setBookingsPeriodically(checked); } void PreferencesDialog::on_sbBookingsInterval_valueChanged(int value) { if (!_settingsLoaded) { return; } Settings::setBookingsInterval(value); } // zooming void PreferencesDialog::on_pbWheelCalibrate_clicked() { QSettings settings; settings.beginGroup("mouseWheel"); settings.remove(""); settings.endGroup(); loadSettings(); } void PreferencesDialog::on_sbZoomFactor_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setZoomFactor(value); } void PreferencesDialog::on_gbDownloadBookings_toggled(bool checked) { if (!_settingsLoaded) { return; } Settings::setDownloadBookings(checked); qobject_cast<Window*>(this->parent())->setEnableBookedAtc(checked); } //import & export void PreferencesDialog::on_pbImportFromFile_clicked() { QString fileName = QFileDialog::getOpenFileName( this, "Import from File", QApplication::applicationDirPath(), "Settings Files (*.ini);; All Files (*.*)" ); if (!fileName.isEmpty()) { Settings::importFromFile(fileName); QMessageBox::information( this, "Settings loaded. Restart required.", "QuteScoop closes now. Please restart" "for the settings to take effect." ); loadSettings(); qApp->quit(); } } void PreferencesDialog::on_pbExportToFile_clicked() { QString fileName = QFileDialog::getSaveFileName( this, "Export to File", QApplication::applicationDirPath(), "Settings Files (*.ini);; All Files (*.*)" ); if (!fileName.isEmpty()) { Settings::exportToFile(fileName); QMessageBox::information(this, "Success", "Settings exported."); } } void PreferencesDialog::on_pbStylesheetUpdate_clicked() { qobject_cast<Window*>(this->parent())->setStyleSheet(tedStylesheet->toPlainText()); Settings::setStylesheet(tedStylesheet->toPlainText()); } void PreferencesDialog::on_pbStylesheetExample1_clicked() { if ( QMessageBox::question( this, "Overwrite stylesheet?", "Are you sure?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::Yes ) { tedStylesheet->setPlainText(QLatin1String("\ QCheckBox::indicator:hover, QDateTimeEdit, QSpinBox, QComboBox, QAbstractItemView, QLineEdit, QSpinBox, QDoubleSpinBox, QTabWidget::pane, QGroupBox {\n\ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n\ stop: 0 #f6f7fa, stop: 1 #dadbde);\n\ }\n\ QDateTimeEdit::drop-down, QToolButton, QAbstractSpinBox::up-button, QAbstractSpinBox::down-button, QComboBox::drop-down, QTabBar::tab:selected, QPushButton, QMenuBar:selected, QMenu:selected, QComboBox:selected, QMenuBar, QMenu, QTabBar::tab {\n\ border: 1px solid #aaa;\n\ padding: 3px;\n\ background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n\ stop: 0 #dadbde, stop: 1 #f6f7fa);\n\ }\n\ QDialog, QMainWindow {\n\ background: qradialgradient(spread:repeat, cx:0.55, cy:0.5, radius:0.077, fx:0.5, fy:0.5, stop:0 rgba(200, 239, 255, 255), stop:0.497326 rgba(200, 230, 230, 47), stop:1 rgba(200, 239, 235, 255))\n\ }\n\ QMenuBar, QMenu, QTabBar::tab {\n\ background: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #eee, stop: 1 #fff);\n\ }\n\ ")); } } void PreferencesDialog::on_pbStylesheetExample2_clicked() { if ( QMessageBox::question( this, "Overwrite stylesheet?", "Are you sure?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::Yes ) { tedStylesheet->setPlainText(QLatin1String("\ QDialog, QMainWindow {\n\ background: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #bef, stop: 1 #eff);\n\ }\n\ QMenuBar, QMenu, QTabBar::tab {\n\ background: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #eff, stop: 1 #bef);\n\ }\n\ QDateTimeEdit::drop-down, QToolButton, QAbstractSpinBox::up-button, QAbstractSpinBox::down-button, QComboBox::drop-down, QTabBar::tab:selected, QPushButton, QMenuBar:selected, QMenu:selected, QComboBox:selected {\n\ color: white;\n\ background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #88d, stop: 0.1 #99e, stop: 0.49 #77c, stop: 0.5 #66b, stop: 1 #77c);\n\ border: 1px solid #339;\n\ border-radius: 5px;\n\ padding: 3px;\n\ padding-left: 5px;\n\ padding-right: 5px;\n\ }\n\ QCheckBox::indicator:hover, QDateTimeEdit, QSpinBox, QComboBox, QAbstractItemView, QLineEdit, QSpinBox, QDoubleSpinBox, QTabWidget::pane, QGroupBox {\n\ border-style: solid;\n\ border: 1px solid gray;\n\ border-radius: 5px;\n\ }\n\ QLabel {\n\ background: rgba(0,0,0,0);\n\ }\n\ ")); } } void PreferencesDialog::on_cbLighting_toggled(bool checked) { if (!_settingsLoaded) { return; } Settings::setEnableLighting(checked); } void PreferencesDialog::on_pbSunLightColor_clicked() { QColor color = QColorDialog::getColor( Settings::sunLightColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbSunLightColor->setText(color.name()); pbSunLightColor->setPalette(QPalette(color)); Settings::setSunLightColor(color); } } void PreferencesDialog::on_pbSpecularLightColor_clicked() { QColor color = QColorDialog::getColor( Settings::specularColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbSpecularLightColor->setText(color.name()); pbSpecularLightColor->setPalette(QPalette(color)); Settings::setSpecularColor(color); } } void PreferencesDialog::on_glLights_valueChanged(int value) { if (!_settingsLoaded) { return; } Settings::setGlLights(value); if (value == 1) { glLightsSpread->setEnabled(false); } else { glLightsSpread->setEnabled(true); } } void PreferencesDialog::on_glEarthShininess_valueChanged(int value) { if (!_settingsLoaded) { return; } Settings::setEarthShininess(value); } void PreferencesDialog::on_glLightsSpread_valueChanged(int value) { if (!_settingsLoaded) { return; } Settings::setGlLightsSpread(value); } void PreferencesDialog::on_pbReinitOpenGl_clicked() { if (Window::instance(false) != 0) { Window::instance()->mapScreen->glWidget->initializeGL(); Window::instance()->mapScreen->glWidget->update(); } } void PreferencesDialog::on_sbEarthGridEach_valueChanged(int value) { if (!_settingsLoaded) { return; } Settings::setEarthGridEach(value); } void PreferencesDialog::on_applyAirports_clicked() { if (Window::instance(false) != 0) { Window::instance()->mapScreen->glWidget->invalidateAirports(); Window::instance()->mapScreen->glWidget->update(); } } void PreferencesDialog::on_applyPilots_clicked() { if (Window::instance(false) != 0) { Window::instance()->mapScreen->glWidget->invalidatePilots(); Window::instance()->mapScreen->glWidget->update(); } } void PreferencesDialog::on_glStippleLines_toggled(bool checked) { if (!_settingsLoaded) { return; } Settings::setGlStippleLines(checked); } void PreferencesDialog::on_glTextures_toggled(bool checked) { if (!_settingsLoaded) { return; } Settings::setGlTextures(checked); } void PreferencesDialog::on_glTextureEarth_currentIndexChanged(QString tex) { if (!_settingsLoaded) { return; } Settings::setGlTextureEarth(tex); } void PreferencesDialog::on_useSelectionRectangle_toggled(bool checked) { if (!_settingsLoaded) { return; } Settings::setUseSelctionRectangle(checked); } void PreferencesDialog::closeEvent(QCloseEvent* event) { Settings::setDialogPreferences( m_preferencesName, Settings::DialogPreferences { .size = size(), .pos = pos(), .geometry = saveGeometry() } ); event->accept(); } void PreferencesDialog::on_sb_highlightFriendsLineWidth_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setHighlightLineWidth(value); } void PreferencesDialog::on_cb_Animation_stateChanged(int state) { if (!_settingsLoaded) { return; } Settings::setAnimateFriendsHighlight(state == Qt::Checked); if (Window::instance(false) != 0) { Window::instance()->mapScreen->glWidget->configureUpdateTimer(); } } void PreferencesDialog::on_pb_highlightFriendsColor_clicked() { QColor color = QColorDialog::getColor( Settings::friendsHighlightColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pb_highlightFriendsColor->setText(color.name()); pb_highlightFriendsColor->setPalette(QPalette(color)); Settings::setFriendsHighlightColor(color); } } void PreferencesDialog::on_cbRememberMapPositionOnClose_toggled(bool checked) { if (!_settingsLoaded) { return; } Settings::setRememberMapPositionOnClose(checked); } void PreferencesDialog::on_pbPilotFontSecondaryColor_clicked() { QColor color = QColorDialog::getColor( Settings::pilotFontSecondaryColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbPilotFontSecondaryColor->setText(color.name()); pbPilotFontSecondaryColor->setPalette(QPalette(color)); Settings::setPilotFontSecondaryColor(color); } } void PreferencesDialog::on_pbPilotFontSecondary_clicked() { bool ok; QFont font = QFontDialog::getFont(&ok, Settings::pilotFontSecondary(), this); if (ok) { pbPilotFontSecondary->setFont(font); Settings::setPilotFontSecondary(font); } } void PreferencesDialog::on_plainTextEditPilotSecondaryContent_textChanged() { Settings::setPilotSecondaryContent(plainTextEditPilotSecondaryContent->toPlainText()); } void PreferencesDialog::on_plainTextEditPilotSecondaryContentHovered_textChanged() { Settings::setPilotSecondaryContentHovered(plainTextEditPilotSecondaryContentHovered->toPlainText()); } void PreferencesDialog::on_lineEditPilotPrimaryContent_editingFinished() { Settings::setPilotPrimaryContent(lineEditPilotPrimaryContent->text()); } void PreferencesDialog::on_lineEditPilotPrimaryContentHovered_editingFinished() { Settings::setPilotPrimaryContentHovered(lineEditPilotPrimaryContentHovered->text()); } void PreferencesDialog::on_applyAirports_2_clicked() { on_applyAirports_clicked(); } void PreferencesDialog::on_lineEditAirportPrimaryContent_editingFinished() { Settings::setAirportPrimaryContent(lineEditAirportPrimaryContent->text()); } void PreferencesDialog::on_lineEditAirportPrimaryContentHovered_editingFinished() { Settings::setAirportPrimaryContentHovered(lineEditAirportPrimaryContentHovered->text()); } void PreferencesDialog::on_pbAirportFontSecondaryColor_clicked() { QColor color = QColorDialog::getColor( Settings::airportFontSecondaryColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbAirportFontSecondaryColor->setText(color.name()); pbAirportFontSecondaryColor->setPalette(QPalette(color)); Settings::setAirportFontSecondaryColor(color); } } void PreferencesDialog::on_pbAirportFontSecondary_clicked() { bool ok; QFont font = QFontDialog::getFont(&ok, Settings::airportFontSecondary(), this); if (ok) { pbAirportFontSecondary->setFont(font); Settings::setAirportFontSecondary(font); } } void PreferencesDialog::on_plainTextEditAirportSecondaryContentHovered_textChanged() { Settings::setAirportSecondaryContentHovered(plainTextEditAirportSecondaryContentHovered->toPlainText()); } void PreferencesDialog::on_plainTextEditAirportSecondaryContent_textChanged() { Settings::setAirportSecondaryContent(plainTextEditAirportSecondaryContent->toPlainText()); } void PreferencesDialog::on_pbLabelHoveredBgColor_clicked() { QColor color = QColorDialog::getColor( Settings::labelHoveredBgColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbLabelHoveredBgColor->setText(color.name()); pbLabelHoveredBgColor->setPalette(QPalette(color)); Settings::setLabelHoveredBgColor(color); } } void PreferencesDialog::on_applyLabelHover_clicked() { if (Window::instance(false) != 0) { Window::instance()->mapScreen->glWidget->update(); } } void PreferencesDialog::on_pbLabelHoveredBgDarkColor_clicked() { QColor color = QColorDialog::getColor( Settings::labelHoveredBgDarkColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbLabelHoveredBgDarkColor->setText(color.name()); pbLabelHoveredBgDarkColor->setPalette(QPalette(color)); Settings::setLabelHoveredBgDarkColor(color); } } void PreferencesDialog::on_pbFirApply_clicked() { if (Window::instance(false) != 0) { Window::instance()->mapScreen->glWidget->invalidateControllers(); Window::instance()->mapScreen->glWidget->update(); } } void PreferencesDialog::on_lineEditFirPrimaryContent_editingFinished() { Settings::setFirPrimaryContent(lineEditFirPrimaryContent->text()); } void PreferencesDialog::on_lineEditFirPrimaryContentHovered_editingFinished() { Settings::setFirPrimaryContentHovered(lineEditFirPrimaryContentHovered->text()); } void PreferencesDialog::on_plainTextEditFirSecondaryContent_textChanged() { Settings::setFirSecondaryContent(plainTextEditFirSecondaryContent->toPlainText()); } void PreferencesDialog::on_plainTextEditFirSecondaryContentHovered_textChanged() { Settings::setFirSecondaryContentHovered(plainTextEditFirSecondaryContentHovered->toPlainText()); } void PreferencesDialog::on_pbFirFontSecondaryColor_clicked() { QColor color = QColorDialog::getColor( Settings::firFontSecondaryColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbFirFontSecondaryColor->setText(color.name()); pbFirFontSecondaryColor->setPalette(QPalette(color)); Settings::setFirFontSecondaryColor(color); } } void PreferencesDialog::on_pbFirFontSecondary_clicked() { bool ok; QFont font = QFontDialog::getFont(&ok, Settings::firFontSecondary(), this); if (ok) { pbFirFontSecondary->setFont(font); Settings::setFirFontSecondary(font); } } void PreferencesDialog::on_pbDelBorderLineColor_clicked() { QColor color = QColorDialog::getColor( Settings::delBorderLineColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbDelBorderLineColor->setText(color.name()); pbDelBorderLineColor->setPalette(QPalette(color)); Settings::setDelBorderLineColor(color); } } void PreferencesDialog::on_pbDelFillColor_clicked() { QColor color = QColorDialog::getColor( Settings::delFillColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbDelFillColor->setText(color.name()); pbDelFillColor->setPalette(QPalette(color)); Settings::setDelFillColor(color); } } void PreferencesDialog::on_sbDelBorderLineStrength_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setDelBorderLineStrength(value); } void PreferencesDialog::on_pbTwrBorderLineColor_clicked() { QColor color = QColorDialog::getColor( Settings::twrBorderLineColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbTwrBorderLineColor->setText(color.name()); pbTwrBorderLineColor->setPalette(QPalette(color)); Settings::setTwrBorderLineColor(color); } } void PreferencesDialog::on_sbTwrBorderLineStrength_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setTwrBorderLineStrength(value); } void PreferencesDialog::on_pbDestImmediateLineColor_clicked() { QColor color = QColorDialog::getColor( Settings::destImmediateLineColor(), this, "Select color", QColorDialog::ShowAlphaChannel ); if (color.isValid()) { pbDestImmediateLineColor->setText(color.name()); pbDestImmediateLineColor->setPalette(QPalette(color)); Settings::setDestImmediateLineColor(color); } } void PreferencesDialog::on_sbDestImmediateLineStrength_valueChanged(double value) { if (!_settingsLoaded) { return; } Settings::setDestImmediateLineStrength(value); } void PreferencesDialog::on_sbDestImmediateDuration_valueChanged(int value) { if (!_settingsLoaded) { return; } Settings::setDestImmediateDurationMin(value); } void PreferencesDialog::on_applyPilotsRoute_clicked() { if (Window::instance(false) != 0) { Window::instance()->mapScreen->glWidget->invalidatePilots(); Window::instance()->mapScreen->glWidget->update(); } } void PreferencesDialog::on_sbCongestionRadiusMin_valueChanged(int v) { if (!_settingsLoaded) { return; } Settings::setAirportCongestionRadiusMin(v); } void PreferencesDialog::on_sbCongestionRadiusMax_valueChanged(int v) { if (!_settingsLoaded) { return; } Settings::setAirportCongestionRadiusMax(v); } void PreferencesDialog::on_btnCongestionShowRing_toggled(bool checked) { Settings::setAirportCongestionRing(checked); } void PreferencesDialog::on_btnCongestionShowGlow_toggled(bool checked) { Settings::setAirportCongestionGlow(checked); } void PreferencesDialog::on_cbLabelAlwaysBackdrop_toggled(bool checked) { if (!_settingsLoaded) { return; } Settings::setLabelAlwaysBackdropped(checked); } void PreferencesDialog::on_sbHoverDebounce_valueChanged(int v) { Settings::setHoverDebounceMs(v); } void PreferencesDialog::on_pbApplyHover_clicked() { if (Window::instance(false) != 0) { Window::instance(false)->mapScreen->glWidget->configureHoverDebounce(); } }
57,027
C++
.cpp
1,501
32.542971
247
0.718412
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,646
ListClientsDialog.cpp
qutescoop_qutescoop/src/dialogs/ListClientsDialog.cpp
#include "ListClientsDialog.h" #include "Window.h" #include "../Controller.h" #include "../models/ListClientsDialogModel.h" #include "../Pilot.h" #include "../Ping.h" #include "../Settings.h" #include "../Whazzup.h" // singleton instance ListClientsDialog* listClientsDialogInstance = 0; ListClientsDialog* ListClientsDialog::instance(bool createIfNoInstance, QWidget* parent) { if (listClientsDialogInstance == 0 && createIfNoInstance) { if (parent == 0) { parent = Window::instance(); } listClientsDialogInstance = new ListClientsDialog(parent); } return listClientsDialogInstance; } // destroys a singleton instance void ListClientsDialog::destroyInstance() { delete listClientsDialogInstance; listClientsDialogInstance = 0; } ListClientsDialog::ListClientsDialog(QWidget* parent) : QDialog(parent) { setupUi(this); setWindowFlags(windowFlags() ^= Qt::WindowContextHelpButtonHint); // clients _clientsModel = new ListClientsDialogModel; _clientsProxyModel = new QSortFilterProxyModel(this); _clientsProxyModel->setDynamicSortFilter(true); _clientsProxyModel->setSourceModel(_clientsModel); treeListClients->setUniformRowHeights(true); treeListClients->setModel(_clientsProxyModel); treeListClients->sortByColumn(0, Qt::AscendingOrder); treeListClients->setColumnWidth(0, 100); treeListClients->setColumnWidth(1, 100); treeListClients->setColumnWidth(2, 200); treeListClients->setColumnWidth(3, 100); treeListClients->setColumnWidth(12, 800); // FP remarks treeListClients->setColumnWidth(13, 800); // controller info treeListClients->header()->setMinimumHeight(fontMetrics().lineSpacing() * 3); connect(treeListClients, &QAbstractItemView::clicked, this, &ListClientsDialog::modelSelected); // servers QStringList serverHeaders; serverHeaders << "ident" << "URL" << "ping[ms]" << "ping[ms]" << "ping[ms]" << QString::fromUtf8("Ø ping[ms]") << "connected\nclients" << "location" << "description"; serversTable->setColumnCount(serverHeaders.size()); serversTable->setHorizontalHeaderLabels(serverHeaders); // General QFont font = lblStatusInfo->font(); font.setPointSize(lblStatusInfo->fontInfo().pointSize() - 1); lblStatusInfo->setFont(font); //make it a bit smaller than standard text connect(&_editFilterTimer, &QTimer::timeout, this, &ListClientsDialog::performSearch); QTimer::singleShot(100, this, SLOT(refresh())); // delayed insertion of clients to open the window now auto preferences = Settings::dialogPreferences(m_preferencesName); if (!preferences.size.isNull()) { resize(preferences.size); } if (!preferences.pos.isNull()) { move(preferences.pos); } if (!preferences.geometry.isNull()) { restoreGeometry(preferences.geometry); } } void ListClientsDialog::refresh() { qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); const WhazzupData &data = Whazzup::instance()->whazzupData(); // Clients QHash<QString, int> serversConnected; QList<Client*> clients; foreach (Pilot* p, data.pilots) { clients << dynamic_cast<Client*> (p); if (p != 0) { serversConnected[p->server] = serversConnected.value(p->server, 0) + 1; // count clients } } foreach (Controller* c, data.controllers) { clients << dynamic_cast<Client*> (c); if (c != 0) { serversConnected[c->server] = serversConnected.value(c->server, 0) + 1; // count clients } } _clientsModel->setClients(clients); // Servers serversTable->clearContents(); serversTable->setRowCount(data.servers.size()); for (int row = 0; row < data.servers.size(); row++) { for (int col = 0; col < serversTable->columnCount(); col++) { switch (col) { case 0: serversTable->setItem(row, col, new QTableWidgetItem(data.servers[row][0])); break; // ident case 1: serversTable->setItem(row, col, new QTableWidgetItem(data.servers[row][1])); break; // hostname_or_IP case 6: serversTable->setItem( row, col, new QTableWidgetItem( QString::number( serversConnected[data.servers[row][0]] ) ) ); break; // connected case 7: serversTable->setItem(row, col, new QTableWidgetItem(data.servers[row][2])); break; // location case 8: serversTable->setItem(row, col, new QTableWidgetItem(data.servers[row][3])); break; // name default: serversTable->setItem(row, col, new QTableWidgetItem()); } } // styles QFont font; font.setBold(true); serversTable->item(row, 5)->setData(Qt::FontRole, font); serversTable->item(row, 2)->setTextAlignment(Qt::AlignCenter); serversTable->item(row, 3)->setTextAlignment(Qt::AlignCenter); serversTable->item(row, 4)->setTextAlignment(Qt::AlignCenter); serversTable->item(row, 5)->setTextAlignment(Qt::AlignCenter); serversTable->item(row, 6)->setTextAlignment(Qt::AlignCenter); } serversTable->resizeColumnsToContents(); // Status QString msg = QString("Whazzup %1 updated") .arg( data.whazzupTime.date() == QDateTime::currentDateTimeUtc().date() // is today? ? QString("today %1").arg(data.whazzupTime.time().toString("HHmm'z'")) : (data.whazzupTime.isValid() ? data.whazzupTime.toString("ddd yyyy/MM/dd HHmm'z'") : "never") ); lblStatusInfo->setText(msg); // Set Item Titles toolBox->setItemText(0, QString("C&lients (%1)").arg(clients.size())); toolBox->setItemText(1, QString("&Servers (%1)").arg(data.servers.size())); toolBox->setItemEnabled(1, data.servers.size() > 0); performSearch(); qApp->restoreOverrideCursor(); } void ListClientsDialog::on_editFilter_textChanged(QString) { _editFilterTimer.start(1000); } void ListClientsDialog::performSearch() { _editFilterTimer.stop(); qApp->setOverrideCursor(QCursor(Qt::WaitCursor)); qDebug(); QRegExp regex; // @todo this tries to cater for both ways (wildcards and regexp) but it does a bad job at that. QStringList tokens = editFilter->text() .replace(QRegExp("\\*"), ".*") .split(QRegExp("[ \\,]+"), Qt::SkipEmptyParts); if (tokens.size() == 1) { regex = QRegExp("^" + tokens.first() + ".*", Qt::CaseInsensitive); } else if (tokens.size() == 0) { regex = QRegExp(""); } else { QString regExpStr = "^(" + tokens.first(); for (int i = 1; i < tokens.size(); i++) { regExpStr += "|" + tokens[i]; } regExpStr += ".*)"; regex = QRegExp(regExpStr, Qt::CaseInsensitive); } _clientsProxyModel->setFilterRegExp(regex); _clientsProxyModel->setFilterKeyColumn(-1); // General boxResults->setTitle(QString("Results (%1)").arg(_clientsProxyModel->rowCount())); qApp->restoreOverrideCursor(); qDebug() << "-- finished"; } void ListClientsDialog::modelSelected(const QModelIndex& index) { _clientsModel->modelSelected(_clientsProxyModel->mapToSource(index)); } void ListClientsDialog::pingReceived(QString server, int ms) { // Servers for (int row = 0; row < serversTable->rowCount(); row++) { if (serversTable->item(row, 1)->data(Qt::DisplayRole) == QVariant(server)) { for (int col = 2; col < 5; col++) { if (serversTable->item(row, col)->data(Qt::DisplayRole).isNull()) { // has no data serversTable->item(row, col)->setBackground(QBrush(mapPingToColor(ms))); serversTable->item(row, col)->setData(Qt::DisplayRole, (ms == -1? QVariant("n/a"): QVariant(ms))); pingNextFromStack(); int addForAverage = 0; for (int pingCol = 2; pingCol <= col; pingCol++) { if (serversTable->item(row, pingCol)->data(Qt::DisplayRole).toInt() == 0) { serversTable->item(row, 5)->setBackground(QBrush(mapPingToColor(-1))); serversTable->item(row, 5)->setData(Qt::DisplayRole, QVariant("n/a")); break; } else { addForAverage += serversTable->item(row, pingCol)->data(Qt::DisplayRole).toInt(); } int average = addForAverage / (pingCol - 1); serversTable->item(row, 5)->setBackground(QBrush(mapPingToColor(average))); serversTable->item(row, 5)->setData(Qt::DisplayRole, QString("%1").arg(average)); } break; } } } } } void ListClientsDialog::on_pbPingServers_clicked() { for (int row = 0; row < serversTable->rowCount(); row++) { // reset Ping columns for (int col = 2; col < 6; col++) { serversTable->item(row, col)->setData(Qt::DisplayRole, QVariant()); serversTable->item(row, col)->setBackground(QBrush()); } _pingStack.prepend(serversTable->item(row, 1)->data(Qt::DisplayRole).toString()); _pingStack.prepend(serversTable->item(row, 1)->data(Qt::DisplayRole).toString()); _pingStack.prepend(serversTable->item(row, 1)->data(Qt::DisplayRole).toString()); } pingNextFromStack(); } void ListClientsDialog::pingNextFromStack() { if (!_pingStack.empty()) { Ping* ping = new Ping(); connect(ping, &Ping::havePing, this, &ListClientsDialog::pingReceived); ping->startPing(_pingStack.pop()); } } QColor ListClientsDialog::mapPingToColor(int ms) { #define BEST 50 // ping in ms we consider best #define WORST 250 if (ms == -1) { // "n/a" return QColor(255, 0, 0, 70); } int red = qMin(230, qMax(0, (ms - BEST) * 255 / (WORST - BEST))); return QColor(red, 230 - red, 0, 70); } void ListClientsDialog::closeEvent(QCloseEvent* event) { Settings::setDialogPreferences( m_preferencesName, Settings::DialogPreferences { .size = size(), .pos = pos(), .geometry = saveGeometry() } ); event->accept(); } void ListClientsDialog::showEvent(QShowEvent* event) { editFilter->setFocus(); event->accept(); }
10,729
C++
.cpp
244
35.352459
118
0.617225
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,647
ControllerDetails.cpp
qutescoop_qutescoop/src/dialogs/ControllerDetails.cpp
#include "ControllerDetails.h" #include "Window.h" #include "../Settings.h" #include "../Whazzup.h" //singleton instance ControllerDetails* controllerDetails = 0; ControllerDetails* ControllerDetails::instance(bool createIfNoInstance, QWidget* parent) { if (controllerDetails == 0) { if (createIfNoInstance) { if (parent == 0) { parent = Window::instance(); } controllerDetails = new ControllerDetails(parent); } } return controllerDetails; } // destroys a singleton instance void ControllerDetails::destroyInstance() { delete controllerDetails; controllerDetails = 0; } ControllerDetails::ControllerDetails(QWidget* parent) : ClientDetails(parent), _controller(0) { setupUi(this); setWindowFlags(windowFlags() ^= Qt::WindowContextHelpButtonHint); connect(buttonShowOnMap, &QAbstractButton::clicked, this, &ClientDetails::showOnMap); auto preferences = Settings::dialogPreferences(m_preferencesName); if (!preferences.size.isNull()) { resize(preferences.size); } if (!preferences.pos.isNull()) { move(preferences.pos); } if (!preferences.geometry.isNull()) { restoreGeometry(preferences.geometry); } } void ControllerDetails::refresh(Controller* newController) { if (newController != 0) { _controller = newController; } else { _controller = Whazzup::instance()->whazzupData().controllers[callsign]; } if (_controller == 0) { close(); return; } setMapObject(_controller); setWindowTitle(_controller->toolTipShort()); // Controller Information QString controllerInfo = QString("<strong>%1</strong>").arg(_controller->displayName(true)); QString details = _controller->detailInformation(); if (!details.isEmpty()) { controllerInfo += details.toHtmlEscaped(); } lblControllerInfo->setText(controllerInfo); lblOnline->setText(QString("On %1 for %2").arg(_controller->server, _controller->onlineTime())); if (_controller->sector != 0) { lblCallsign->setText(_controller->sector->name.toHtmlEscaped()); } lblCallsign->setVisible(_controller->sector != 0); auto isActive = !_controller->isObserver() && _controller->frequency.length() != 0; lblFreqLabel->setVisible(isActive); lblFrequency->setText(isActive? QString("<h1><pre>%1</pre></h1>").arg(_controller->frequency): ""); // airports foreach (const auto _w, gridAirports->findChildren<QWidget*>(QString(), Qt::FindDirectChildrenOnly)) { _w->disconnect(); _w->deleteLater(); } delete gridAirportsLayout; gridAirportsLayout = new QGridLayout(gridAirports); gridAirports->setLayout(gridAirportsLayout); int i = 0; foreach (const auto _a, _controller->airportsSorted()) { if (_a == 0) { continue; } auto* _airportPb = new QPushButton(gridAirports); _airportPb->setText(_a->shortLabel()); _airportPb->setToolTip(_a->toolTip()); auto _font = _airportPb->font(); _font.setBold(_a->congestion() != 0); _airportPb->setFont(_font); connect( _airportPb, &QPushButton::clicked, this, [=](bool) { if (_a->hasPrimaryAction()) { _a->primaryAction(); } } ); gridAirportsLayout->addWidget(_airportPb, floor(i / 4), i % 4); i++; } gridAirportsLayout->update(); // ATIS / controller info QString atis = QString("<code style='margin: 50px; padding: 50px'>%1</code>").arg( QString(_controller->atisMessage.toHtmlEscaped()).replace("\n", "<br>") ); if (_controller->assumeOnlineUntil.isValid()) { atis += QString("<p><i>QuteScoop assumes from this information that this controller will be online until %1z</i></p>") .arg(_controller->assumeOnlineUntil.toString("HHmm")); } lblAtis->setText(atis); gbInfo->setTitle(_controller->callsign.endsWith("_ATIS")? "ATIS": "Controller info"); if (_controller->isFriend()) { buttonAddFriend->setText("remove &friend"); } else { buttonAddFriend->setText("add &friend"); } buttonAddFriend->setEnabled(_controller->hasValidID() && !_controller->isAtis()); pbAlias->setEnabled(_controller->hasValidID()); // show on map buttonShowOnMap->setDisabled(qFuzzyIsNull(_controller->lat) && qFuzzyIsNull(_controller->lon)); } void ControllerDetails::on_buttonAddFriend_clicked() { friendClicked(); refresh(); } void ControllerDetails::closeEvent(QCloseEvent* event) { Settings::setDialogPreferences( m_preferencesName, Settings::DialogPreferences { .size = size(), .pos = pos(), .geometry = saveGeometry() } ); event->accept(); } void ControllerDetails::on_pbAlias_clicked() { if (_controller->showAliasDialog(this)) { refresh(); } }
5,072
C++
.cpp
139
29.834532
126
0.642086
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,648
StaticSectorsDialog.cpp
qutescoop_qutescoop/src/dialogs/StaticSectorsDialog.cpp
#include "StaticSectorsDialog.h" #include "Window.h" #include "../MapScreen.h" #include "../NavData.h" #include "../Settings.h" //singleton instance StaticSectorsDialog* staticSectorsDialogInstance = 0; StaticSectorsDialog* StaticSectorsDialog::instance(bool createIfNoInstance, QWidget* parent) { if (staticSectorsDialogInstance == 0 && createIfNoInstance) { staticSectorsDialogInstance = new StaticSectorsDialog(parent); } return staticSectorsDialogInstance; } StaticSectorsDialog::StaticSectorsDialog(QWidget* parent) : QDialog(parent) { setupUi(this); setModal(false); setWindowFlags(windowFlags() ^= Qt::WindowContextHelpButtonHint); auto preferences = Settings::dialogPreferences(m_preferencesName); if (!preferences.size.isNull()) { resize(preferences.size); } if (!preferences.pos.isNull()) { move(preferences.pos); } if (!preferences.geometry.isNull()) { restoreGeometry(preferences.geometry); } connect(listWidgetSectors, &QListWidget::itemChanged, this, &StaticSectorsDialog::itemChanged); connect(listWidgetSectors, &QListWidget::itemDoubleClicked, this, &StaticSectorsDialog::itemDoubleClicked); connect(btnSelectAll, &QPushButton::clicked, this, &StaticSectorsDialog::btnSelectAllTriggered); connect(btnSelectNone, &QPushButton::clicked, this, &StaticSectorsDialog::btnSelectNoneTriggered); loadSectorList(); } void StaticSectorsDialog::loadSectorList() { qDebug(); foreach (const auto sector, NavData::instance()->sectors.values()) { QListWidgetItem* item = new QListWidgetItem(); item->setText( QString("%1 %2 (ID %3, %4)").arg( sector->icao, (sector->controllerSuffixes().isEmpty() ? "" : "(" + sector->controllerSuffixes().join(", ") + ")" ), sector->id, sector->name ) ); item->setToolTip( QString( "controller prefix: %1\n" "controller suffixes: %2\n" "sector ID: %3\n" "sector name: %4\n" "number of polygon points: %5\n" "controller defined in line #%6 in data/firlist.dat\n" "sector defined in line #%7 in data/firdisplay.dat" ) .arg( sector->icao, (sector->controllerSuffixes().isEmpty() ? "[any]" : sector->controllerSuffixes().join("/") ), sector->id, sector->name ) .arg(sector->points().size()) .arg(sector->debugControllerLineNumber()) .arg(sector->debugSectorLineNumber()) ); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(Qt::Unchecked); item->setData(Qt::UserRole, QVariant::fromValue(static_cast<void*>(sector))); listWidgetSectors->addItem(item); } listWidgetSectors->sortItems(); qDebug() << "-- finsished"; } void StaticSectorsDialog::closeEvent(QCloseEvent* event) { Window::instance()->mapScreen->glWidget->setStaticSectors(QList<Sector*>()); Settings::setDialogPreferences( m_preferencesName, Settings::DialogPreferences { .size = size(), .pos = pos(), .geometry = saveGeometry() } ); event->accept(); deleteLater(); staticSectorsDialogInstance = 0; } void StaticSectorsDialog::btnSelectAllTriggered() { foreach (const auto item, listWidgetSectors->findItems("", Qt::MatchStartsWith)) { item->setCheckState(Qt::Checked); } } void StaticSectorsDialog::btnSelectNoneTriggered() { foreach (const auto item, listWidgetSectors->findItems("", Qt::MatchStartsWith)) { item->setCheckState(Qt::Unchecked); } } void StaticSectorsDialog::itemChanged() { QList<Sector*> renderSectors; foreach (const auto item, listWidgetSectors->findItems("", Qt::MatchStartsWith)) { if (item->checkState() == Qt::Checked) { auto sector = static_cast<Sector*>(item->data(Qt::UserRole).value<void*>()); if (sector != 0) { renderSectors.append(sector); } } } Window::instance()->mapScreen->glWidget->setStaticSectors(renderSectors); } void StaticSectorsDialog::itemDoubleClicked(QListWidgetItem* item) { item->setCheckState( item->checkState() == Qt::Checked ? Qt::Unchecked : Qt::Checked ); }
4,685
C++
.cpp
123
29.349593
111
0.617569
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,649
AirportDetails.cpp
qutescoop_qutescoop/src/dialogs/AirportDetails.cpp
#include "AirportDetails.h" #include "PilotDetails.h" #include "Window.h" #include "../NavData.h" #include "../Settings.h" #include "../Whazzup.h" //singleton instance AirportDetails* airportDetails = 0; AirportDetails* AirportDetails::instance(bool createIfNoInstance, QWidget* parent) { if (airportDetails == 0) { if (createIfNoInstance) { if (parent == 0) { parent = Window::instance(); } airportDetails = new AirportDetails(parent); } } return airportDetails; } // destroys a singleton instance void AirportDetails::destroyInstance() { delete airportDetails; airportDetails = 0; } AirportDetails::AirportDetails(QWidget* parent) : ClientDetails(parent), _airport(0) { setupUi(this); setWindowFlags(windowFlags() ^= Qt::WindowContextHelpButtonHint); connect(btnShowOnMap, &QAbstractButton::clicked, this, &ClientDetails::showOnMap); connect(pbMetar, &QAbstractButton::clicked, this, &AirportDetails::refreshMetar); connect(cbPlotRoutes, &QCheckBox::clicked, this, &AirportDetails::togglePlotRoutes); connect(cbOtherAtc, &QCheckBox::clicked, this, &AirportDetails::toggleShowOtherAtc); // ATC list _atcModel = new AirportDetailsAtcModel(this); _atcSortModel = new QSortFilterProxyModel(this); _atcSortModel->setDynamicSortFilter(true); _atcSortModel->setSourceModel(_atcModel); _atcSortModel->setSortRole(Qt::UserRole); treeAtc->setModel(_atcSortModel); connect( // prevent sorting on other columns treeAtc->header(), &QHeaderView::sortIndicatorChanged, this, [this](int logicalIndex, Qt::SortOrder) { if (logicalIndex != 0) { treeAtc->header()->setSortIndicator( 0, _atcSortModel->sortOrder() ); } } ); treeAtc->header()->setSortIndicator(0, Settings::airportDialogAtcSortOrder()); treeAtc->header()->setSectionResizeMode(QHeaderView::Interactive); // keep track of the expanded state of items (API is bad) connect( treeAtc, &QTreeView::expanded, this, [this](const QModelIndex &index) { _atcModel->writeExpandedState(_atcSortModel->mapToSource(index), true); treeAtc->header()->resizeSections(QHeaderView::ResizeToContents); } ); connect( treeAtc, &QTreeView::collapsed, this, [this](const QModelIndex &index) { _atcModel->writeExpandedState(_atcSortModel->mapToSource(index), false); treeAtc->header()->resizeSections(QHeaderView::ResizeToContents); } ); connect(treeAtc, &QAbstractItemView::clicked, this, &AirportDetails::atcSelected); // arrivals _arrivalsSortModel = new QSortFilterProxyModel(this); _arrivalsSortModel->setDynamicSortFilter(true); _arrivalsSortModel->setSourceModel(&_arrivalsModel); _arrivalsSortModel->setSortRole(Qt::UserRole); treeArrivals->setModel(_arrivalsSortModel); treeArrivals->sortByColumn(8, Qt::AscendingOrder); treeArrivals->header()->setSectionResizeMode(QHeaderView::Interactive); connect(treeArrivals, &QAbstractItemView::clicked, this, &AirportDetails::arrivalSelected); // departures _departuresSortModel = new QSortFilterProxyModel(this); _departuresSortModel->setDynamicSortFilter(true); _departuresSortModel->setSourceModel(&_departuresModel); _departuresSortModel->setSortRole(Qt::UserRole); treeDepartures->setModel(_departuresSortModel); treeDepartures->sortByColumn(6, Qt::AscendingOrder); treeDepartures->header()->setSectionResizeMode(QHeaderView::Interactive); connect(treeDepartures, &QAbstractItemView::clicked, this, &AirportDetails::departureSelected); // METAR _metarModel = new MetarModel(qobject_cast<Window*>(this->parent())); // Geometry auto preferences = Settings::dialogPreferences(m_preferencesName); if (!preferences.size.isNull()) { resize(preferences.size); } if (!preferences.pos.isNull()) { move(preferences.pos); } if (!preferences.geometry.isNull()) { restoreGeometry(preferences.geometry); } refresh(); } void AirportDetails::refresh(Airport* newAirport) { if (newAirport != 0) { if (newAirport != _airport) { // scroll Boxes to top on new Data treeAtc->scrollTo(_atcSortModel->index(0, 0)); treeArrivals->scrollTo(_arrivalsSortModel->index(0, 0)); treeDepartures->scrollTo(_departuresSortModel->index(0, 0)); } _airport = newAirport; } if (_airport == 0) { return; } setMapObject(_airport); setWindowTitle(_airport->toolTip()); // info panel lblCity->setText(_airport->city); lblCity->setHidden(_airport->city.isEmpty()); lblCityLabel->setHidden(_airport->city.isEmpty()); lblName->setText(_airport->name); lblName->setHidden(_airport->name.isEmpty()); lblNameLabel->setHidden(_airport->name.isEmpty()); lblCountry->setText( QString("%1 (%2)") .arg(_airport->countryCode, NavData::instance()->countryCodes[_airport->countryCode]) ); lblCharts->setText(QString("[chartfox.org/%1](https://chartfox.org/%1)").arg(_airport->id)); // fetch METAR connect(_metarModel, &MetarModel::gotMetar, this, &AirportDetails::onGotMetar); refreshMetar(); // arrivals _arrivalsModel.setClients(_airport->arrivals.values()); _arrivalsSortModel->invalidate(); treeArrivals->header()->resizeSections(QHeaderView::ResizeToContents); // departures _departuresModel.setClients(_airport->departures.values()); _departuresSortModel->invalidate(); treeDepartures->header()->resizeSections(QHeaderView::ResizeToContents); // set titles if (Settings::filterTraffic()) { groupBoxArrivals->setTitle( QString("Arrivals (%1 filtered, %2 total)"). arg(_airport->nMaybeFilteredArrivals).arg(_airport->arrivals.size()) ); groupBoxDepartures->setTitle( QString("Departures (%1 filtered, %2 total)"). arg(_airport->nMaybeFilteredDepartures).arg(_airport->departures.size()) ); } else { groupBoxArrivals->setTitle(QString("Arrivals (%1)").arg(_airport->arrivals.size())); groupBoxDepartures->setTitle(QString("Departures (%1)").arg(_airport->departures.size())); } QSet<Controller*> atcContent = _airport->allControllers() + checkSectors(); if (cbOtherAtc->isChecked()) { foreach (Controller* c, Whazzup::instance()->whazzupData().controllers) { // add those within visual range or max. 20 NM away if (NavData::distance(_airport->lat, _airport->lon, c->lat, c->lon) < qMax(20, c->visualRange)) { atcContent.insert(c); } } } // ATC _atcModel->setClients(atcContent.values()); _atcSortModel->invalidate(); for (int i = 0; i < _atcSortModel->rowCount(); i++) { auto index = _atcSortModel->index(i, 0); if (!index.isValid()) { continue; } auto* item = static_cast<AirportDetailsAtcModelItem*>(_atcSortModel->mapToSource(index).internalPointer()); if (item->m_controller == nullptr) { continue; } if (_atcModel->isExpanded(item)) { treeAtc->expand(index); } else { treeAtc->collapse(index); } } groupBoxAtc->setTitle(QString("ATC (%1)").arg(atcContent.size())); treeAtc->header()->resizeSections(QHeaderView::ResizeToContents); bool isShowRouteExternal = Settings::showRoutes(); if (!isShowRouteExternal && !_airport->showRoutes) { cbPlotRoutes->setCheckState(Qt::Unchecked); } if (isShowRouteExternal && !_airport->showRoutes) { cbPlotRoutes->setCheckState(Qt::PartiallyChecked); } if (_airport->showRoutes) { cbPlotRoutes->setCheckState(Qt::Checked); } } void AirportDetails::atcSelected(const QModelIndex& index) { _atcModel->modelSelected(_atcSortModel->mapToSource(index)); } void AirportDetails::arrivalSelected(const QModelIndex& index) { _arrivalsModel.modelSelected(_arrivalsSortModel->mapToSource(index)); } void AirportDetails::departureSelected(const QModelIndex& index) { _departuresModel.modelSelected(_departuresSortModel->mapToSource(index)); } void AirportDetails::togglePlotRoutes(bool checked) { _airport->showRoutes = checked; if (Window::instance(false) != 0) { Window::instance()->mapScreen->glWidget->invalidatePilots(); } if (PilotDetails::instance(false) != 0) { PilotDetails::instance()->refresh(); } refresh(); } void AirportDetails::refreshMetar() { qDebug() << _airport; lblMetar->setText("…"); QList<Airport*> airports; if (_airport != 0) { airports += _airport; _metarModel->setAirports(airports); } } void AirportDetails::onGotMetar(const QString &airportId, const QString &encoded, const QString &humanHtml) { qDebug() << _airport << airportId << encoded; if (_airport->id == airportId) { lblMetar->setText(encoded); lblMetar->setToolTip(humanHtml); } } QSet<Controller*> AirportDetails::checkSectors() const { QSet<Controller*> result; foreach (Controller* c, Whazzup::instance()->whazzupData().controllersWithSectors()) { if (c->sector->containsPoint(QPointF(_airport->lat, _airport->lon))) { result.insert(c); } } return result; } void AirportDetails::closeEvent(QCloseEvent* event) { Settings::setDialogPreferences( m_preferencesName, Settings::DialogPreferences { .size = size(), .pos = pos(), .geometry = saveGeometry() } ); Settings::setAirportDialogAtcSortOrder(_atcSortModel->sortOrder()); event->accept(); } void AirportDetails::toggleShowOtherAtc(bool) { refresh(); }
10,126
C++
.cpp
260
32.257692
115
0.666768
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,650
Window.cpp
qutescoop_qutescoop/src/dialogs/Window.cpp
#include "Window.h" #include "AirportDetails.h" #include "BookedAtcDialog.h" #include "ControllerDetails.h" #include "ListClientsDialog.h" #include "PilotDetails.h" #include "PlanFlightDialog.h" #include "PreferencesDialog.h" #include "StaticSectorsDialog.h" #include "../FriendsVisitor.h" #include "../GLWidget.h" #include "../GuiMessage.h" #include "../MetarDelegate.h" #include "../MetarSearchVisitor.h" #include "../NavData.h" #include "../Platform.h" #include "../Settings.h" #include "../SearchVisitor.h" #include "../Whazzup.h" #include <QModelIndex> // singleton instance Window* windowInstance = 0; Window* Window::instance(bool createIfNoInstance) { if (windowInstance == 0 && createIfNoInstance) { windowInstance = new Window(); } return windowInstance; } Window::Window(QWidget* parent) : QMainWindow(parent) { GuiMessages::progress("mainwindow", "Setting up main window..."); setupUi(this); setAttribute(Qt::WA_AlwaysShowToolTips, true); setWindowTitle( QString("QuteScoop %1%2").arg( Platform::version(), Platform::compileMode() == "debug"? " [debug]": "" ) ); // apply styleSheet if (!Settings::stylesheet().isEmpty()) { qDebug() << "applying styleSheet:" << Settings::stylesheet(); setStyleSheet(Settings::stylesheet()); } // map (GLWidget) mapScreen = new MapScreen(this); centralwidget->layout()->addWidget(mapScreen); // Status- & ProgressBar _progressBar = new QProgressBar(statusbar); _progressBar->setMaximumWidth(200); _progressBar->hide(); _lblStatus = new QLabel(statusbar); statusbar->addWidget(_lblStatus, 5); statusbar->addWidget(_progressBar, 3); statusbar->addPermanentWidget(tbZoomIn, 0); statusbar->addPermanentWidget(tbZoomOut, 0); // actions connect(actionAbout, &QAction::triggered, this, &Window::about); connect(actionToggleFullscreen, &QAction::triggered, this, &Window::toggleFullscreen); connect(actionPreferences, &QAction::triggered, this, &Window::openPreferences); connect(actionPlanFlight, &QAction::triggered, this, &Window::openPlanFlight); connect(actionBookedAtc, &QAction::triggered, this, &Window::openBookedAtc); connect(actionListClients, &QAction::triggered, this, &Window::openListClients); connect(actionOpenStaticSectorsDialog, &QAction::triggered, this, &Window::openStaticSectorsDialog); actionShowInactiveAirports->setChecked(Settings::showInactiveAirports()); connect(actionShowInactiveAirports, &QAction::toggled, this, &Window::showInactiveAirports); pb_highlightFriends->setChecked(Settings::highlightFriends()); actionHighlight_Friends->setChecked(Settings::highlightFriends()); setEnableBookedAtc(Settings::downloadBookings()); actionShowWaypoints->setChecked(Settings::showUsedWaypoints()); actionShowRoutes->setChecked(Settings::showRoutes()); connect( actionShowRoutes, &QAction::toggled, this, [this](const bool &newValue) { actionShowRoutes_triggered(newValue); } ); actionShowRoutes_triggered(Settings::showRoutes(), false); actionShowImmediateRoutes->setChecked(Settings::onlyShowImmediateRoutePart()); connect( actionShowImmediateRoutes, &QAction::toggled, this, [this](const bool &newValue) { actionShowImmediateRoutes_triggered(newValue); } ); actionShowImmediateRoutes_triggered(Settings::onlyShowImmediateRoutePart(), false); actionHideLabels->setChecked(Settings::onlyShowHoveredLabels()); connect( actionHideLabels, &QAction::toggled, this, [this](const bool &newValue) { actionHideLabels_triggered(newValue); } ); actionHideLabels_triggered(Settings::onlyShowHoveredLabels(), false); Whazzup* whazzup = Whazzup::instance(); connect(actionDownload, &QAction::triggered, whazzup, &Whazzup::downloadJson3); // these 2 get disconnected and connected again to inhibit unnecessary updates: connect(whazzup, &Whazzup::newData, mapScreen->glWidget, &GLWidget::newWhazzupData); connect(whazzup, &Whazzup::newData, this, &Window::processWhazzup); // search result widget searchResult->setModel(&_modelSearchResult); connect(searchResult, &QAbstractItemView::clicked, &_modelSearchResult, &SearchResultModel::modelClicked); searchResult->sortByColumn(0, Qt::AscendingOrder); // METAR widget _sortmodelMetar = new QSortFilterProxyModel(this); _sortmodelMetar->setDynamicSortFilter(true); _sortmodelMetar->setSourceModel(&_metarModel); metarList->setModel(_sortmodelMetar); MetarDelegate* metarDelegate = new MetarDelegate(); metarDelegate->setParent(metarList); metarList->setItemDelegate(metarDelegate); //metarList->setWordWrap(true); // some say this causes sizeHint() to be called on resize, but it does not connect(metarList, &QAbstractItemView::clicked, this, &Window::metarClicked); metarList->sortByColumn(0, Qt::AscendingOrder); // friends widget _sortmodelFriends = new QSortFilterProxyModel(this); _sortmodelFriends->setDynamicSortFilter(true); _sortmodelFriends->setSourceModel(&_modelFriends); friendsList->setModel(_sortmodelFriends); connect(friendsList, &QAbstractItemView::clicked, this, &Window::friendClicked); friendsList->sortByColumn(0, Qt::AscendingOrder); // debounce input timers connect(&_timerSearch, &QTimer::timeout, this, &Window::performSearch); connect(&_timerMetar, &QTimer::timeout, this, &Window::updateMetars); // Whazzup download timer connect(&_timerWatchdog, &QTimer::timeout, this, &Window::downloadWatchdogTriggered); // dock layout connect( metarDock, &QDockWidget::dockLocationChanged, this, &Window::metarDockMoved ); connect( searchDock, &QDockWidget::dockLocationChanged, this, &Window::searchDockMoved ); connect( friendsDock, &QDockWidget::dockLocationChanged, this, &Window::friendsDockMoved ); // Forecast / Predict settings framePredict->hide(); _timerEditPredict.stop(); connect(&_timerEditPredict, &QTimer::timeout, this, &Window::performWarp); _timerRunPredict.stop(); connect(&_timerRunPredict, &QTimer::timeout, this, &Window::runPredict); widgetRunPredict->hide(); connect(dateTimePredict, &QDateTimeEdit::dateTimeChanged, this, &Window::dateTimePredict_dateTimeChanged); QFont font = lblWarpInfo->font(); font.setPointSize(lblWarpInfo->fontInfo().pointSize() - 1); lblWarpInfo->setFont(font); //make it a bit smaller than standard text font = cbUseDownloaded->font(); font.setPointSize(cbUseDownloaded->fontInfo().pointSize() - 1); cbUseDownloaded->setFont(font); //make it a bit smaller than standard text font = cbOnlyUseDownloaded->font(); font.setPointSize(cbOnlyUseDownloaded->fontInfo().pointSize() - 1); cbOnlyUseDownloaded->setFont(font); //make it a bit smaller than standard text // GuiMessages GuiMessages::instance()->addProgressBar(_progressBar, true); GuiMessages::instance()->addStatusLabel(_lblStatus, false); GuiMessages::remove("mainwindow"); qDebug() << "--finished"; } Window::~Window() {} void Window::restore() { qDebug() << "restoring window state, geometry and position"; if (!Settings::savedSize().isNull()) { resize(Settings::savedSize()); } if (!Settings::savedPosition().isNull()) { move(Settings::savedPosition()); } if (!Settings::savedGeometry().isNull()) { restoreGeometry(Settings::savedGeometry()); } if (!Settings::savedState().isNull()) { restoreState(Settings::savedState()); } if (Settings::maximized()) { showMaximized(); } else { show(); } emit restored(); } void Window::toggleFullscreen() { if (isFullScreen()) { showNormal(); statusBar()->show(); } else { statusBar()->hide(); showFullScreen(); } } void Window::about() { QMessageBox::about( this, "About QuteScoop", QString( R"html( <h3>QuteScoop <small style="font-weight: normal">%1</small></h3> <p> QuteScoop is free (libre) software. Find downloads, get help, voice your wishes, contribute and join the discussion here: <a href="https://github.com/qutescoop/qutescoop">QuteScoop on Github</a>. </p> <h3>License</h3> <p> QuteScoop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. </p> <p> QuteScoop is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. </p> )html" ) .arg(Platform::version()) ); } void Window::processWhazzup(bool isNew) { qDebug() << "isNew =" << isNew; const WhazzupData &realdata = Whazzup::instance()->realWhazzupData(); const WhazzupData &data = Whazzup::instance()->whazzupData(); QString msg = QString(tr("%1%2 – %3: %4 clients")) .arg( Settings::downloadNetworkName(), Whazzup::instance()->predictedTime.isValid()? " - <b>W A R P E D</b> to": "" ) .arg( data.whazzupTime.date() == QDateTime::currentDateTimeUtc().date() // is today? ? QString("today %1").arg(data.whazzupTime.time().toString("HH:mm:ss'z'")) : data.whazzupTime.toString("ddd MM/dd HH:mm:ss'z'") ) .arg(data.pilots.size() + data.controllers.size()); GuiMessages::status(msg, "status"); msg = QString("Whazzup %1, bookings %2 updated") .arg( realdata.whazzupTime.date() == QDateTime::currentDateTimeUtc().date() // is today? ? QString("today %1").arg(realdata.whazzupTime.time().toString("HH:mm:ss'z'")) : (realdata.whazzupTime.isValid() ? realdata.whazzupTime.toString("ddd MM/dd HH:mm:ss'z'") : "never" ), realdata.bookingsTime.date() == QDateTime::currentDateTimeUtc().date() // is today? ? QString("today %1").arg(realdata.bookingsTime.time().toString("HH:mm:ss'z'")) : (realdata.bookingsTime.isValid() ? realdata.bookingsTime.toString("ddd MM/dd HH:mm:ss'z'") : "never" ) ); lblWarpInfo->setText(msg); if (Whazzup::instance()->predictedTime.isValid()) { framePredict->show(); dateTimePredict->setDateTime(Whazzup::instance()->predictedTime); if (isNew) { // recalculate prediction on new data arrived if ( data.predictionBasedOnTime != realdata.whazzupTime || data.predictionBasedOnBookingsTime != realdata.bookingsTime ) { Whazzup::instance()->setPredictedTime(dateTimePredict->dateTime()); } } } if (isNew) { mapScreen->glWidget->clientSelection->close(); mapScreen->glWidget->clientSelection->clearObjects(); performSearch(); if (AirportDetails::instance(false) != 0) { if (AirportDetails::instance()->isVisible()) { AirportDetails::instance()->refresh(); } else { // not visible -> delete it... AirportDetails::instance()->destroyInstance(); } } if (PilotDetails::instance(false) != 0) { if (PilotDetails::instance()->isVisible()) { PilotDetails::instance()->refresh(); } else { // not visible -> delete it... PilotDetails::instance()->destroyInstance(); } } if (ControllerDetails::instance(false) != 0) { if (ControllerDetails::instance()->isVisible()) { ControllerDetails::instance()->refresh(); } else { // not visible -> delete it... ControllerDetails::instance()->destroyInstance(); } } if (ListClientsDialog::instance(false) != 0) { if (ListClientsDialog::instance()->isVisible()) { ListClientsDialog::instance()->refresh(); } else { // not visible -> delete it... ListClientsDialog::instance()->destroyInstance(); } } if (realdata.bookingsTime.isValid()) { if (BookedAtcDialog::instance(false) != 0) { if (BookedAtcDialog::instance()->isVisible()) { BookedAtcDialog::instance()->refresh(); } else { // not visible -> delete it... BookedAtcDialog::instance()->destroyInstance(); } } } refreshFriends(); } _timerWatchdog.stop(); if (Settings::downloadPeriodically()) { _timerWatchdog.start(Settings::downloadInterval() * 1000 * 4); } qDebug() << "-- finished"; } void Window::refreshFriends() { // update friends list FriendsVisitor* visitor = new FriendsVisitor(); Whazzup::instance()->whazzupData().accept(visitor); _modelFriends.setSearchResults(visitor->result()); delete visitor; friendsList->reset(); } void Window::openPreferences() { PreferencesDialog::instance(true, this)->show(); PreferencesDialog::instance()->raise(); PreferencesDialog::instance()->activateWindow(); PreferencesDialog::instance()->setFocus(); } void Window::openPlanFlight() { PlanFlightDialog::instance(true, this)->show(); PlanFlightDialog::instance()->raise(); PlanFlightDialog::instance()->activateWindow(); PlanFlightDialog::instance()->setFocus(); } void Window::openBookedAtc() { BookedAtcDialog::instance(true, this)->show(); if (actionPredict->isChecked()) { BookedAtcDialog::instance()->setDateTime(dateTimePredict->dateTime().toUTC()); } BookedAtcDialog::instance()->raise(); BookedAtcDialog::instance()->activateWindow(); BookedAtcDialog::instance()->setFocus(); } void Window::openListClients() { ListClientsDialog::instance(true, this)->show(); ListClientsDialog::instance()->raise(); ListClientsDialog::instance()->activateWindow(); //ListClientsDialog::instance()->setFocus(); } void Window::on_searchEdit_textChanged(const QString& text) { if (text.length() < 1) { _timerSearch.stop(); _modelSearchResult.setSearchResults({}); searchResult->reset(); return; } _timerSearch.start(400); } void Window::performSearch() { if (searchEdit->text().length() < 1) { return; } _timerSearch.stop(); _modelSearchResult.m_isSearching = true; searchResult->reset(); searchResult->repaint(); qApp->processEvents(); SearchVisitor* visitor = new SearchVisitor(searchEdit->text()); NavData::instance()->accept(visitor); Whazzup::instance()->whazzupData().accept(visitor); _modelSearchResult.setSearchResults(visitor->result()); delete visitor; _modelSearchResult.m_isSearching = false; searchResult->reset(); } void Window::closeEvent(QCloseEvent* event) { // save window statii Settings::saveState(saveState()); Settings::saveGeometry(saveGeometry()); // added this 'cause maximized wasn't saved Settings::saveSize(size()); // readded as Mac OS had problems with geometry only Settings::savePosition(pos()); Settings::saveMaximized(isMaximized()); if (Settings::rememberMapPositionOnClose()) { mapScreen->glWidget->rememberPosition(9); } event->accept(); } void Window::on_actionHideAllWindows_triggered() { if (PilotDetails::instance(false) != 0) { PilotDetails::instance()->close(); } if (ControllerDetails::instance(false) != 0) { ControllerDetails::instance()->close(); } if (AirportDetails::instance(false) != 0) { AirportDetails::instance()->close(); } if (PreferencesDialog::instance(false) != 0) { PreferencesDialog::instance()->close(); } if (PlanFlightDialog::instance(false) != 0) { PlanFlightDialog::instance()->close(); } if (BookedAtcDialog::instance(false) != 0) { BookedAtcDialog::instance()->close(); } if (ListClientsDialog::instance(false) != 0) { ListClientsDialog::instance()->close(); } if (StaticSectorsDialog::instance(false) != 0) { StaticSectorsDialog::instance()->close(); } if (searchDock->isFloating()) { searchDock->hide(); } if (metarDock->isFloating()) { metarDock->hide(); } if (friendsDock->isFloating()) { friendsDock->hide(); } mapScreen->glWidget->clientSelection->close(); } void Window::on_metarEdit_textChanged(const QString& text) { if (text.length() < 1) { _timerMetar.stop(); _metarModel.setAirports(QList<Airport*>()); metarList->reset(); return; } _timerMetar.start(500); } void Window::on_btnRefreshMetar_clicked() { _metarModel.refresh(); } void Window::updateMetars() { if (metarEdit->text().length() < 1) { return; } _timerMetar.stop(); MetarSearchVisitor* visitor = new MetarSearchVisitor(metarEdit->text()); NavData::instance()->accept(visitor); // search airports only _metarModel.setAirports(visitor->airports()); delete visitor; metarList->reset(); } void Window::friendClicked(const QModelIndex& index) { _modelFriends.modelClicked(_sortmodelFriends->mapToSource(index)); } void Window::metarClicked(const QModelIndex& index) { _metarModel.modelClicked(_sortmodelMetar->mapToSource(index)); } void Window::metarDockMoved(Qt::DockWidgetArea area) { updateTitlebarAfterMove(area, metarDock); } void Window::searchDockMoved(Qt::DockWidgetArea area) { updateTitlebarAfterMove(area, searchDock); } void Window::friendsDockMoved(Qt::DockWidgetArea area) { updateTitlebarAfterMove(area, friendsDock); } void Window::updateTitlebarAfterMove(Qt::DockWidgetArea area, QDockWidget* dock) { switch (area) { case Qt::LeftDockWidgetArea: case Qt::RightDockWidgetArea: // set horizontal title bar dock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); break; case Qt::TopDockWidgetArea: case Qt::BottomDockWidgetArea: // set vertical title bar dock->setFeatures(searchDock->features() | QDockWidget::DockWidgetVerticalTitleBar); break; default: {} } } void Window::downloadWatchdogTriggered() { _timerWatchdog.stop(); Whazzup::instance()->setStatusLocation(Settings::statusLocation()); GuiMessages::errorUserAttention( "Failed to download network data for a while. " "Maybe a Whazzup location went offline. " "I try to get the Network Status again.", "Whazzup-download failed." ); } void Window::setEnableBookedAtc(bool enable) { actionBookedAtc->setEnabled(enable); } void Window::performWarp() { _timerEditPredict.stop(); QDateTime warpToTime = dateTimePredict->dateTime(); auto realWhazzupTime = Whazzup::instance()->realWhazzupData().whazzupTime; qDebug() << "warpToTime=" << warpToTime << " realWhazzupTime=" << realWhazzupTime; if (cbUseDownloaded->isChecked() && warpToTime < realWhazzupTime) { qDebug() << "Looking for downloaded Whazzups"; QList<QPair<QDateTime, QString> > downloaded = Whazzup::instance()->downloadedWhazzups(); for (int i = downloaded.size() - 1; i > -1; i--) { if ((downloaded[i].first <= warpToTime && realWhazzupTime < downloaded[i].first) || (i == 0)) { // only if different if (downloaded[i].first != realWhazzupTime) { // disconnect to inhibit update because will be updated later disconnect(Whazzup::instance(), &Whazzup::newData, mapScreen->glWidget, &GLWidget::newWhazzupData); disconnect(Whazzup::instance(), &Whazzup::newData, this, &Window::processWhazzup); Whazzup::instance()->fromFile(downloaded[i].second); connect(Whazzup::instance(), &Whazzup::newData, mapScreen->glWidget, &GLWidget::newWhazzupData); connect(Whazzup::instance(), &Whazzup::newData, this, &Window::processWhazzup); } break; } } } Whazzup::instance()->setPredictedTime(warpToTime); } void Window::on_cbUseDownloaded_toggled(bool checked) { qDebug() << "checked=" << checked; if (!checked) { // I currently don't understand why we had this // QList<QPair<QDateTime, QString> > downloaded = Whazzup::instance()->downloadedWhazzups(); // if(!downloaded.isEmpty()) // Whazzup::instance()->fromFile(downloaded.last().second); cbOnlyUseDownloaded->setChecked(false); } performWarp(); } void Window::on_cbOnlyUseDownloaded_toggled(bool checked) { if (checked) { // if newly selected, set dateTime to valid Whazzup dateTimePredict_dateTimeChanged(dateTimePredict->dateTime()); } } void Window::on_tbDisablePredict_clicked() { qDebug(); actionPredict->setChecked(false); } void Window::on_actionPredict_toggled(bool enabled) { if (enabled) { _dateTimePredict_old = QDateTime::currentDateTimeUtc() .addSecs(-QDateTime::currentDateTimeUtc().time().second()); // remove seconds dateTimePredict->setDateTime(_dateTimePredict_old); framePredict->show(); } else { tbRunPredict->setChecked(false); cbUseDownloaded->setChecked(false); Whazzup::instance()->setPredictedTime(QDateTime()); // remove time warp framePredict->hide(); widgetRunPredict->hide(); } } void Window::on_tbRunPredict_toggled(bool checked) { if (checked) { dateTimePredict->setEnabled(false); widgetRunPredict->show(); if (!Whazzup::instance()->predictedTime.isValid()) { performWarp(); } _timerRunPredict.start(1000); } else { _timerRunPredict.stop(); widgetRunPredict->hide(); dateTimePredict->setEnabled(true); } } void Window::runPredict() { _timerRunPredict.stop(); QDateTime to; if (dsRunPredictStep->value() == 0) { // real time selected to = QDateTime::currentDateTimeUtc(); } else { to = Whazzup::instance()->predictedTime.addSecs(static_cast<int>(dsRunPredictStep->value() * 60)); } // when only using downloaded Whazzups, select the next available if (cbOnlyUseDownloaded->isChecked()) { qDebug() << "restricting Warp target to downloaded Whazzups"; QList<QPair<QDateTime, QString> > downloaded = Whazzup::instance()->downloadedWhazzups(); for (int i = 0; i < downloaded.size(); i++) { if ((downloaded[i].first >= to) || (i == downloaded.size() - 1)) { to = downloaded[i].first; break; } } } qDebug() << to; // setting dateTimePredict without "niceify" disconnect(dateTimePredict, &QDateTimeEdit::dateTimeChanged, this, &Window::dateTimePredict_dateTimeChanged); dateTimePredict->setDateTime(to); connect(dateTimePredict, &QDateTimeEdit::dateTimeChanged, this, &Window::dateTimePredict_dateTimeChanged); qDebug() << dateTimePredict->dateTime(); performWarp(); _timerRunPredict.start(static_cast<int>(spinRunPredictInterval->value() * 1000)); } void Window::dateTimePredict_dateTimeChanged(QDateTime dateTime) { // some niceify on the default behaviour, making the sections depend on each other // + only allow selecting downloaded Whazzups if respective option is selected disconnect(dateTimePredict, &QDateTimeEdit::dateTimeChanged, this, &Window::dateTimePredict_dateTimeChanged); _timerEditPredict.stop(); // make year change if M 12+ or 0- if ( (_dateTimePredict_old.date().month() == 12) && (dateTime.date().month() == 1) ) { dateTime = dateTime.addYears(1); } if ( (_dateTimePredict_old.date().month() == 1) && (dateTime.date().month() == 12) ) { dateTime = dateTime.addYears(-1); } // make month change if d lastday+ or 0- if ( (_dateTimePredict_old.date().day() == _dateTimePredict_old.date().daysInMonth()) && (dateTime.date().day() == 1) ) { dateTime = dateTime.addMonths(1); } if ( (_dateTimePredict_old.date().day() == 1) && (dateTime.date().day() == dateTime.date().daysInMonth()) ) { dateTime = dateTime.addMonths(-1); dateTime = dateTime.addDays( // compensate for month lengths dateTime.date().daysInMonth() - _dateTimePredict_old.date().daysInMonth() ); } // make day change if h 23+ or 00- if ( (_dateTimePredict_old.time().hour() == 23) && (dateTime.time().hour() == 0) ) { dateTime = dateTime.addDays(1); } if ( (_dateTimePredict_old.time().hour() == 0) && (dateTime.time().hour() == 23) ) { dateTime = dateTime.addDays(-1); } // make hour change if m 59+ or 0- if ( (_dateTimePredict_old.time().minute() == 59) && (dateTime.time().minute() == 0) ) { dateTime = dateTime.addSecs(60 * 60); } if ( (_dateTimePredict_old.time().minute() == 0) && (dateTime.time().minute() == 59) ) { dateTime = dateTime.addSecs(-60 * 60); } // when only using downloaded Whazzups, select the next available if (cbOnlyUseDownloaded->isChecked()) { qDebug() << "restricting Warp target to downloaded Whazzups"; QList<QPair<QDateTime, QString> > downloaded = Whazzup::instance()->downloadedWhazzups(); if (dateTime > _dateTimePredict_old) { // selecting a later date for (int i = 0; i < downloaded.size(); i++) { if ((downloaded[i].first >= dateTime) || (i == downloaded.size() - 1)) { dateTime = downloaded[i].first; break; } } } else { // selecting an earlier date for (int i = downloaded.size() - 1; i > -1; i--) { if ((downloaded[i].first <= dateTime) || (i == 0)) { dateTime = downloaded[i].first; break; } } } } _dateTimePredict_old = dateTime; if (dateTime.isValid() && (dateTime != dateTimePredict->dateTime())) { dateTimePredict->setDateTime(dateTime); } connect(dateTimePredict, &QDateTimeEdit::dateTimeChanged, this, &Window::dateTimePredict_dateTimeChanged); _timerEditPredict.start(1000); } void Window::on_actionRecallMapPosition9_triggered() { mapScreen->glWidget->restorePosition(9); } void Window::on_actionRecallMapPosition1_triggered() { mapScreen->glWidget->restorePosition(1); } void Window::on_actionRecallMapPosition7_triggered() { mapScreen->glWidget->restorePosition(7); } void Window::on_actionRecallMapPosition6_triggered() { mapScreen->glWidget->restorePosition(6); } void Window::on_actionRecallMapPosition5_triggered() { mapScreen->glWidget->restorePosition(5); } void Window::on_actionRecallMapPosition4_triggered() { mapScreen->glWidget->restorePosition(4); } void Window::on_actionRecallMapPosition3_triggered() { mapScreen->glWidget->restorePosition(3); } void Window::on_actionRecallMapPosition2_triggered() { mapScreen->glWidget->restorePosition(2); } void Window::on_actionRememberMapPosition9_triggered() { if (Settings::rememberMapPositionOnClose()) { if ( QMessageBox::question( this, "Startup position will be overridden on close", "You have just set the startup map position. " "Anyhow this will be overridden on close because " "you have set 'remember startup map position on close' " "in preferences.\n\n" "Do you want to disable 'remember startup map position " "on close' now?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes ) == QMessageBox::Yes ) { Settings::setRememberMapPositionOnClose(false); if (PreferencesDialog::instance(false) != 0) { PreferencesDialog::instance()-> cbRememberMapPositionOnClose->setChecked(false); } } } mapScreen->glWidget->rememberPosition(9); } void Window::on_actionRememberMapPosition1_triggered() { mapScreen->glWidget->rememberPosition(1); } void Window::on_actionRememberMapPosition7_triggered() { mapScreen->glWidget->rememberPosition(7); } void Window::on_actionRememberMapPosition6_triggered() { mapScreen->glWidget->rememberPosition(6); } void Window::on_actionRememberMapPosition5_triggered() { mapScreen->glWidget->rememberPosition(5); } void Window::on_actionRememberMapPosition4_triggered() { mapScreen->glWidget->rememberPosition(4); } void Window::on_actionRememberMapPosition3_triggered() { mapScreen->glWidget->rememberPosition(3); } void Window::on_actionRememberMapPosition2_triggered() { mapScreen->glWidget->rememberPosition(2); } void Window::on_actionMoveLeft_triggered() { mapScreen->glWidget->scrollBy(-1, 0); } void Window::on_actionMoveRight_triggered() { mapScreen->glWidget->scrollBy(1, 0); } void Window::on_actionMoveUp_triggered() { mapScreen->glWidget->scrollBy(0, -1); } void Window::on_actionMoveDown_triggered() { mapScreen->glWidget->scrollBy(0, 1); } void Window::on_tbZoomIn_clicked() { mapScreen->glWidget->zoomIn(.6); } void Window::on_tbZoomOut_clicked() { mapScreen->glWidget->zoomIn(-.6); } // we use this to catch right-clicks on the buttons void Window::on_tbZoomOut_customContextMenuRequested(QPoint) { mapScreen->glWidget->zoomTo(2.); } void Window::on_tbZoomIn_customContextMenuRequested(QPoint) { mapScreen->glWidget->zoomTo(2.); } void Window::on_actionZoomReset_triggered() { mapScreen->glWidget->zoomTo(2.); } void Window::actionShowRoutes_triggered(bool checked, bool showStatus) { Settings::setShowRoutes(checked); if (showStatus) { GuiMessages::message(QString("toggled routes [%1]").arg(checked? "on": "off"), "routeToggle"); } actionShowImmediateRoutes->setEnabled(checked); if (!checked) { foreach (Airport* a, NavData::instance()->airports.values()) { a->showRoutes = checked; } foreach (Pilot* p, Whazzup::instance()->whazzupData().allPilots()) { p->showRoute = checked; } // adjust the "plot route" tick in dialogs if (AirportDetails::instance(false) != 0) { AirportDetails::instance()->refresh(); } if (PilotDetails::instance(false) != 0) { PilotDetails::instance()->refresh(); } } mapScreen->glWidget->invalidatePilots(); } void Window::actionShowImmediateRoutes_triggered(bool checked, bool showStatus) { Settings::setOnlyShowImmediateRoutePart(checked); if (showStatus) { GuiMessages::message(QString("toggled short-term routes [%1]").arg(checked? "on": "off"), "routeToggle"); } mapScreen->glWidget->invalidatePilots(); } void Window::actionHideLabels_triggered(bool checked, bool showStatus) { Settings::setOnlyShowHoveredLabels(checked); if (showStatus) { GuiMessages::message(QString("toggled labels [%1]").arg(checked? "hidden": "shown"), "showHoveredLabelsToggle"); } mapScreen->glWidget->update(); } void Window::showInactiveAirports(bool checked) { GuiMessages::message( QString("toggled inactive airports [%1]").arg(checked? "on": "off"), "toggleInactiveAirports" ); Settings::setShowInactiveAirports(checked); mapScreen->glWidget->invalidateAirports(); } void Window::on_actionShowWaypoints_triggered(bool checked) { GuiMessages::message( QString("toggled active waypoints [%1]").arg(checked? "on": "off"), "toggleWaypoints" ); Settings::setShowUsedWaypoints(checked); mapScreen->glWidget->invalidatePilots(); } void Window::on_actionHighlight_Friends_triggered(bool checked) { Settings::setHighlightFriends(checked); pb_highlightFriends->setChecked(checked); mapScreen->glWidget->configureUpdateTimer(); } void Window::on_pb_highlightFriends_toggled(bool checked) { GuiMessages::message( QString("toggled highlight friends [%1]").arg(checked? "on": "off"), "toggleHighlightFriends" ); actionHighlight_Friends->setChecked(checked); on_actionHighlight_Friends_triggered(checked); } void Window::openStaticSectorsDialog() { StaticSectorsDialog::instance(true, this)->show(); StaticSectorsDialog::instance()->raise(); StaticSectorsDialog::instance()->setFocus(); StaticSectorsDialog::instance()->activateWindow(); }
33,675
C++
.cpp
858
32.602564
131
0.658261
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,651
AirportDetailsArrivalsModel.cpp
qutescoop_qutescoop/src/models/AirportDetailsArrivalsModel.cpp
#include "AirportDetailsArrivalsModel.h" #include "src/Airport.h" #include "src/Settings.h" #include <QFont> void AirportDetailsArrivalsModel::setClients(const QList<Pilot*>& pilots) { beginResetModel(); this->_pilots = pilots; endResetModel(); } QVariant AirportDetailsArrivalsModel::headerData(int section, enum Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { switch (section) { case 0: return QString("Callsign"); case 1: return QString("Type"); case 2: return QString("Name"); case 3: return QString("Arriving From"); case 4: return QString("T"); case 5: return QString("Via"); case 6: return QString("Alt"); case 7: return QString("Dist"); case 8: return QString("TTG"); case 9: return QString("Delay"); case 10: return QString("Status"); } } return QVariant(); } int AirportDetailsArrivalsModel::columnCount(const QModelIndex&) const { return 11; } int AirportDetailsArrivalsModel::rowCount(const QModelIndex&) const { return _pilots.count(); } QVariant AirportDetailsArrivalsModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() >= _pilots.size()) { return QVariant(); } Pilot* p = _pilots.value(index.row(), nullptr); if (p == nullptr) { return QVariant(); } if (index.column() == 8) { const bool isFilteredArrival = Settings::filterTraffic() && ( (p->distanceToDestination() < Settings::filterDistance()) || (p->eet().hour() + p->eet().minute() / 60. < Settings::filterArriving()) ) && (p->flightStatus() != Pilot::FlightStatus::BLOCKED && p->flightStatus() != Pilot::FlightStatus::GROUND_ARR); if (isFilteredArrival) { if (role == Qt::ForegroundRole) { return QGuiApplication::palette().window(); } else if (role == Qt::BackgroundRole) { return QGuiApplication::palette().text(); } } } if (role == Qt::FontRole) { QFont result; if (p->flightStatus() == Pilot::PREFILED) { result.setItalic(true); } if (p->isFriend()) { result.setBold(true); } return result; } if (role == Qt::TextAlignmentRole) { switch (index.column()) { case 6: case 7: case 8: case 9: return Qt::AlignRight; case 4: case 10: return Qt::AlignHCenter; } return Qt::AlignLeft; } if (role == Qt::DisplayRole) { switch (index.column()) { case 0: return p->callsign; case 1: return p->planAircraftShort; case 2: return p->displayName(); case 3: return p->depAirport() != 0? p->depAirport()->toolTip(): ""; case 4: return p->planFlighttype; case 5: return p->waypoints().isEmpty()? "": p->waypoints().constLast(); case 6: return p->altitude == 0? QString(""): p->humanAlt(); case 7: if (p->distanceToDestination() < 3) { return "-"; } else { return QString("%1 NM").arg((int) p->distanceToDestination()); } case 8: if (p->flightStatus() == Pilot::GROUND_ARR || p->flightStatus() == Pilot::BLOCKED) { return "--:-- hrs"; } else if (!p->eet().toString("H:mm").isEmpty()) { return QString("%1 hrs").arg(p->eet().toString("H:mm")); } else { return ""; } case 9: return p->delayString(); case 10: return p->flightStatusShortString(); } return QVariant(); } if (role == Qt::UserRole) { // used for sorting switch (index.column()) { case 7: return p->distanceToDestination(); case 8: auto eta = p->eta(); if (!eta.isValid()) { return 0; } return eta.toSecsSinceEpoch(); } return data(index, Qt::DisplayRole); } return QVariant(); } void AirportDetailsArrivalsModel::modelSelected(const QModelIndex& index) const { Pilot* p = _pilots.value(index.row(), nullptr); if (p == nullptr) { return; } if (p->hasPrimaryAction()) { p->primaryAction(); } }
4,824
C++
.cpp
139
24.266187
123
0.517471
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,652
AirportDetailsAtcModel.cpp
qutescoop_qutescoop/src/models/AirportDetailsAtcModel.cpp
#include "AirportDetailsAtcModel.h" #include <src/Settings.h> AirportDetailsAtcModel::AirportDetailsAtcModel(QObject* parent) : QAbstractItemModel(parent) { rootItem = new AirportDetailsAtcModelItem(); m_atcExpandedByType = Settings::airportDialogAtcExpandedByType(); } AirportDetailsAtcModel::~AirportDetailsAtcModel() { delete rootItem; } void AirportDetailsAtcModel::setClients(QList<Controller*> controllers) { beginResetModel(); QMultiMap<QString, Controller*> _all; std::sort( controllers.begin(), controllers.end(), [](const Controller* a, const Controller* b)-> bool { return a->callsign > b->callsign; } ); foreach (const auto c, controllers) { _all.insert(c->typeString(), c); } auto types = _all.uniqueKeys(); rootItem->removeChildren(); foreach (const auto type, types) { auto* typeItem = new AirportDetailsAtcModelItem({ type }, nullptr, rootItem); rootItem->m_childItems.append(typeItem); foreach (const auto c, _all.values(type)) { if (typeItem->m_controller == nullptr) { typeItem->m_controller = c; } else { auto* atcItem = new AirportDetailsAtcModelItem({}, c, typeItem); typeItem->m_childItems.append(atcItem); } } } endResetModel(); } QModelIndex AirportDetailsAtcModel::index(int row, int column, const QModelIndex &parent) const { if (!hasIndex(row, column, parent)) { return QModelIndex(); } AirportDetailsAtcModelItem* parentItem; if (!parent.isValid()) { parentItem = rootItem; } else { parentItem = static_cast<AirportDetailsAtcModelItem*>(parent.internalPointer()); } AirportDetailsAtcModelItem* childItem = parentItem->m_childItems.value(row, nullptr); if (childItem) { return createIndex(row, column, childItem); } return QModelIndex(); } QModelIndex AirportDetailsAtcModel::parent(const QModelIndex &index) const { if (!index.isValid()) { return QModelIndex(); } AirportDetailsAtcModelItem* childItem = static_cast<AirportDetailsAtcModelItem*>(index.internalPointer()); AirportDetailsAtcModelItem* parentItem = childItem->m_parentItem; if (parentItem == rootItem) { return QModelIndex(); } return createIndex(parentItem->row(), 0, parentItem); } int AirportDetailsAtcModel::rowCount(const QModelIndex &parent) const { if (parent.column() > 0) { return 0; } AirportDetailsAtcModelItem* parentItem; if (!parent.isValid()) { parentItem = rootItem; } else { parentItem = static_cast<AirportDetailsAtcModelItem*>(parent.internalPointer()); } return parentItem->m_childItems.count(); } int AirportDetailsAtcModel::columnCount(const QModelIndex&) const { return nColumns; } QVariant AirportDetailsAtcModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) { return QVariant(); } AirportDetailsAtcModelItem* item = static_cast<AirportDetailsAtcModelItem*>(index.internalPointer()); if (index.column() < 0 || index.column() >= AirportDetailsAtcModel::nColumns) { return QVariant(); } if (index.column() == 0) { if (role == Qt::ForegroundRole) { return QGuiApplication::palette().window(); } else if (role == Qt::BackgroundRole) { return QGuiApplication::palette().text(); } } // group row if (!item->m_columnTexts.isEmpty() && index.column() == 0) { if (role == Qt::TextAlignmentRole) { return Qt::AlignCenter; } else if (role == Qt::DisplayRole) { return item->m_columnTexts.value(index.column(), QString()); } else if (role == Qt::UserRole) { // for sorting const auto _value = item->m_columnTexts.value(index.column(), QString()); const auto _index = typesSorted.indexOf(_value); return _index != -1? QVariant(_index): _value; } return QVariant(); } // controller if (role == Qt::FontRole) { if (item->m_controller->isFriend()) { QFont result; result.setBold(true); return result; } return QFont(); } if (role == Qt::TextAlignmentRole) { switch (index.column()) { case 1: case 6: return int(Qt::AlignRight | Qt::AlignVCenter); case 3: case 5: return Qt::AlignCenter; } return int(Qt::AlignLeft | Qt::AlignVCenter); } if (role == Qt::DisplayRole) { switch (index.column()) { case 1: return isExpanded(item)? item->m_controller->callsign: ""; case 2: { if (!isExpanded(item)) { QStringList freqs { item->m_controller->frequency }; foreach (const auto* i, item->m_childItems) { freqs << i->m_controller->frequency; } freqs.removeDuplicates(); freqs.sort(); return freqs.join(", "); } return item->m_controller->frequency; } case 3: return isExpanded(item)? item->m_controller->atisCode: ""; case 4: return isExpanded(item)? item->m_controller->realName(): ""; case 5: return isExpanded(item)? item->m_controller->rank(): ""; case 6: return isExpanded(item)? item->m_controller->onlineTime(): ""; case 7: return isExpanded(item)? item->m_controller->assumeOnlineUntil.time().toString("HHmm'z'"): ""; } } if (role == Qt::UserRole) { // for sorting return item->m_controller->callsign; } return QVariant(); } Qt::ItemFlags AirportDetailsAtcModel::flags(const QModelIndex &index) const { if (!index.isValid()) { return Qt::NoItemFlags; } return QAbstractItemModel::flags(index); } QVariant AirportDetailsAtcModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { switch (section) { case 0: return QString(); case 1: return "Login"; case 2: return "Freq"; case 3: return "ATIS"; case 4: return "Name"; case 5: return "Rank"; case 6: return "Online"; case 7: return "Until"; } } return QVariant(); } void AirportDetailsAtcModel::modelSelected(const QModelIndex& index) const { if (!index.isValid()) { return; } auto* item = static_cast<AirportDetailsAtcModelItem*>(index.internalPointer()); if (!isExpanded(item)) { return; } if (item->m_controller != nullptr && item->m_controller->hasPrimaryAction()) { item->m_controller->primaryAction(); } } void AirportDetailsAtcModel::writeExpandedState(const QModelIndex &index, bool isExpanded) { if (!index.isValid()) { return; } auto* item = static_cast<AirportDetailsAtcModelItem*>(index.internalPointer()); if (item == nullptr) { return; } if (item->m_childItems.isEmpty()) { return; } m_atcExpandedByType.insert(item->m_controller->typeString(), isExpanded); Settings::setAirportDialogAtcExpandedByType(m_atcExpandedByType); } bool AirportDetailsAtcModel::isExpanded(AirportDetailsAtcModelItem* item) const { if (item->m_parentItem && item->m_parentItem != rootItem) { return isExpanded(item->m_parentItem); } return item->m_childItems.isEmpty() || m_atcExpandedByType.value(item->m_controller->typeString(), false).toBool(); }
7,823
C++
.cpp
207
29.908213
119
0.620922
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,653
ListClientsDialogModel.cpp
qutescoop_qutescoop/src/models/ListClientsDialogModel.cpp
#include "ListClientsDialogModel.h" #include "../Airport.h" #include "../NavData.h" void ListClientsDialogModel::setClients(const QList<Client*>& clients) { qDebug(); beginResetModel(); _clients = clients; endResetModel(); qDebug() << "-- finished"; } QVariant ListClientsDialogModel::headerData(int section, enum Qt::Orientation orientation, int role) const { if (role != Qt::DisplayRole) { return QVariant(); } if (orientation == Qt::Vertical) { return QVariant(); } // orientation is Qt::Horizontal switch (section) { case 0: return "Callsign"; case 1: return "Rating"; case 2: return "Name"; case 3: return "Online"; case 4: return "Livestream"; case 5: return "ATC:\nvisibility\nrange [NM]"; case 6: return "Pilot:\nTTG"; case 7: return "Pilot:\nroute DEP"; case 8: return "Pilot:\nroute DEST"; case 9: return "Pilot:\naircraft"; case 10: return "Pilot:\nflight type"; case 11: return "Pilot:\nroute dist [NM]"; case 12: return "Pilot:\naircraft (FP)"; case 13: return "Pilot:\nFP remarks"; case 14: return "ATC:\ncontroller\ninfo"; } return QVariant(); } QVariant ListClientsDialogModel::data(const QModelIndex &index, int role) const { // unnecessary due to the c == 0 check below //if(!index.isValid()) // return QVariant(); Client* c = _clients.value(index.row(), 0); if (c == 0) { return QVariant(); } if (role == Qt::FontRole) { if (c->isFriend()) { QFont result; result.setBold(true); return result; } return QFont(); } else if (role == Qt::DisplayRole) { Controller* co = dynamic_cast <Controller*> (c); Pilot* p = dynamic_cast <Pilot*> (c); switch (index.column()) { case 0: return c->callsign; case 1: return c->rank(); case 2: return c->realName(); case 3: return c->onlineTime(); case 4: return c->livestreamString(); case 5: return co != 0? QString("%1").arg(co->visualRange, 4, 'f', 0, ' '): ""; case 6: if (co != 0) { if (co->assumeOnlineUntil.isValid()) { return QString("%1 hrs").arg( QTime().addSecs(QDateTime::currentDateTimeUtc().secsTo(co->assumeOnlineUntil)).toString("H:mm") ); } return ""; } if (p != 0) { return QString("%1 hrs").arg(p->eet().toString("H:mm")); } break; case 7: if (p != 0 && p->depAirport() != 0) { return p->depAirport()->id; } return ""; case 8: if (p != 0 && p->destAirport() != 0) { return p->destAirport()->id; } return ""; case 9: return p != 0? p->planAircraftShort: ""; case 10: return p != 0? p->planFlighttypeString(): ""; case 11: if (p != 0 && p->depAirport() != 0 && p->destAirport() != 0) { return QString("%1").arg( NavData::distance( p->depAirport()->lat, p->depAirport()->lon, p->destAirport()->lat, p->destAirport()->lon ), 5, 'f', 0, ' ' ); } return ""; case 12: return p != 0? p->planAircraftShort: ""; case 13: return p != 0? p->planRemarks: ""; case 14: return co != 0? QString(co->atisMessage).replace("\n", " – "): ""; } } return QVariant(); } int ListClientsDialogModel::rowCount(const QModelIndex&) const { return _clients.count(); } int ListClientsDialogModel::columnCount(const QModelIndex&) const { return 15; } void ListClientsDialogModel::modelSelected(const QModelIndex& index) { Client* c = _clients.value(index.row(), nullptr); if (c == nullptr) { return; } MapObject* m = dynamic_cast<MapObject*>(c); if (m != 0 && m->hasPrimaryAction()) { m->primaryAction(); } }
4,409
C++
.cpp
121
25.876033
123
0.50386
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,654
BookedAtcDialogModel.cpp
qutescoop_qutescoop/src/models/BookedAtcDialogModel.cpp
#include "BookedAtcDialogModel.h" #include <QApplication> #include <QDesktopServices> #include <QMessageBox> void BookedAtcDialogModel::setClients(const QList<BookedController*> &controllers) { qDebug() << "BookedAtcDialogModel/setClients()"; beginResetModel(); this->_controllers = controllers; endResetModel(); } QVariant BookedAtcDialogModel::headerData(int section, enum Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { switch (section) { case 0: return QString("Callsign"); case 1: return QString("Facility"); case 2: return QString("Name"); case 3: return QString("Date"); case 4: return QString("From"); case 5: return QString("Until"); case 6: return QString("Info"); } } return QVariant(); } int BookedAtcDialogModel::columnCount(const QModelIndex&) const { return 7; } QVariant BookedAtcDialogModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || (index.row() >= rowCount(index))) { return QVariant(); } BookedController* c = _controllers.value(index.row(), nullptr); if (c == nullptr) { return QVariant(); } if (role == Qt::FontRole) { QFont result; result.setBold(c->isFriend()); return result; } if (role == Qt::DisplayRole) { switch (index.column()) { case 0: return c->callsign; case 1: return c->facilityString(); case 2: return c->realName(); case 3: return c->starts().toString("MM/dd (ddd)"); case 4: return c->starts().time().toString("HHmm'z'"); case 5: return c->ends().time().toString("HHmm'z'"); case 6: return c->bookingInfoStr; } return QVariant(); } if (role == Qt::UserRole) { // for sorting switch (index.column()) { case 3: return c->starts(); case 4: return c->starts(); case 5: return c->ends(); } return data(index, Qt::DisplayRole); } return QVariant(); } int BookedAtcDialogModel::rowCount(const QModelIndex&) const { return _controllers.count(); }
2,275
C++
.cpp
65
27.8
106
0.60573
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,655
PlanFlightRoutesModel.cpp
qutescoop_qutescoop/src/models/PlanFlightRoutesModel.cpp
#include "PlanFlightRoutesModel.h" #include <QPixmap> void PlanFlightRoutesModel::setClients(const QList<Route*>& routes) { beginResetModel(); _routes = routes; endResetModel(); } QVariant PlanFlightRoutesModel::headerData(int section, enum Qt::Orientation orientation, int role) const { if (role != Qt::DisplayRole) { return QVariant(); } if (orientation == Qt::Vertical) { return QVariant(); } // orientation is Qt::Horizontal switch (section) { case 0: return ""; break; case 1: return "Provider"; break; case 2: return "Route"; break; case 3: return "Dist"; break; case 4: return "FL>"; break; case 5: return "FL<"; break; case 6: return "Remarks"; break; case 7: return "Last changed"; break; } return QVariant(); } PlanFlightRoutesModel::PlanFlightRoutesModel(QObject* parent) : QAbstractTableModel(parent) {} int PlanFlightRoutesModel::rowCount(const QModelIndex&) const { return _routes.count(); } int PlanFlightRoutesModel::columnCount(const QModelIndex&) const { return 8; } QVariant PlanFlightRoutesModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() >= _routes.size()) { return QVariant(); } Route* r = _routes.value(index.row(), nullptr); if (r == nullptr) { return QVariant(); } if (role == Qt::DecorationRole) { switch (index.column()) { case 0: return QPixmap( r->provider == "user" ? ":/icons/qutescoop.png" : ":/routeproviders/images/vroute.png" ) .scaled(QSize(50, 25), Qt::KeepAspectRatio, Qt::SmoothTransformation); } return QVariant(); } if (role == Qt::DisplayRole) { Route* r = _routes[index.row()]; switch (index.column()) { case 1: return r->provider; case 2: return QString("%1").arg(r->route); case 3: return QString("%1").arg(r->routeDistance); case 4: return r->minFl; case 5: return r->maxFl; case 6: return r->comments; case 7: QDateTime lastChange = QDateTime::fromString(r->lastChange, "yyyyMMddHHmmss"); if (lastChange.isValid()) { return lastChange.date(); } return r->lastChange; } return QVariant(); } return QVariant(); } bool PlanFlightRoutesModel::setData(const QModelIndex&, const QVariant&, int) { return true; } Qt::ItemFlags PlanFlightRoutesModel::flags(const QModelIndex&) const { return Qt::ItemIsSelectable | Qt::ItemIsEnabled; }
2,797
C++
.cpp
81
26.382716
107
0.592003
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,656
SearchResultModel.cpp
qutescoop_qutescoop/src/models/SearchResultModel.cpp
#include "SearchResultModel.h" #include "../Pilot.h" #include <QFont> SearchResultModel::SearchResultModel(QObject* parent) : QAbstractListModel(parent) {} int SearchResultModel::rowCount(const QModelIndex&) const { return _content.count(); } int SearchResultModel::columnCount(const QModelIndex&) const { return 1; } QVariant SearchResultModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() >= _content.size()) { return QVariant(); } if (role == Qt::DisplayRole || role == Qt::ToolTipRole) { MapObject* o = _content.value(index.row(), nullptr); if (o == nullptr) { return QVariant(); } switch (index.column()) { case 0: return o->toolTip(); break; } return QVariant(); } if (role == Qt::FontRole) { QFont result; MapObject* o = _content.value(index.row(), nullptr); if (o == nullptr) { return result; } // prefiled italic Pilot* p = dynamic_cast<Pilot*>(o); if (p != 0 && p->flightStatus() == Pilot::PREFILED) { result.setItalic(true); } // friends bold Client* c = dynamic_cast<Client*>(o); if (c != 0 && c->isFriend()) { result.setBold(true); } return result; } return QVariant(); } QVariant SearchResultModel::headerData(int section, enum Qt::Orientation orientation, int role) const { if (role != Qt::DisplayRole) { return QVariant(); } if (orientation == Qt::Vertical) { return QVariant(); } if (section != 0) { return QVariant(); } if (m_isSearching) { return "…"; } if (_content.isEmpty()) { return "No Results"; } return QString("%1 Result%2").arg(_content.size()).arg(_content.size() == 1? "": "s"); } void SearchResultModel::setSearchResults(const QList<MapObject*> searchResult) { beginResetModel(); _content = searchResult; endResetModel(); } void SearchResultModel::modelClicked(const QModelIndex& index) { MapObject* o = _content.value(index.row(), nullptr); if (o == nullptr) { return; } if (o->hasPrimaryAction()) { o->primaryAction(); } }
2,310
C++
.cpp
77
23.649351
103
0.591505
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,657
MetarModel.cpp
qutescoop_qutescoop/src/models/MetarModel.cpp
#include "MetarModel.h" #include "../Net.h" #include "../Whazzup.h" #include "../dialogs/Window.h" #define MAX_METARS 60 MetarModel::MetarModel(QObject* parent) : QAbstractListModel(parent), _metarReply(0) {} int MetarModel::rowCount(const QModelIndex&) const { if (_airportList.size() > MAX_METARS) { return 1; } return _metarList.size(); } int MetarModel::columnCount(const QModelIndex&) const { return 1; } QVariant MetarModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) { return QVariant(); } if (role == Qt::DisplayRole) { if (_airportList.size() > MAX_METARS) { return QString("Too many airports match your search (%1)").arg(_airportList.size()); } Airport* a = _metarList.value(index.row(), nullptr); if (a == nullptr) { return QVariant(); } switch (index.column()) { case 0: return a->metar.encoded; break; } } if (role == Qt::ToolTipRole) { if (_airportList.size() > MAX_METARS) { return QString("Too many airports match your search (%1)").arg(_airportList.size()); } Airport* a = _metarList.value(index.row(), nullptr); if (a == nullptr) { return QVariant(); } switch (index.column()) { case 0: return a->metar.humanHtml(); break; } } return QVariant(); } QVariant MetarModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role != Qt::DisplayRole) { return QVariant(); } if (orientation != Qt::Horizontal) { return QVariant(); } if (section != 0) { return QVariant(); } QString ret; if (_metarList.isEmpty()) { ret.append("No METARs"); } else if (_metarList.size() == 1) { ret.append("1 METAR"); } else { ret.append(QString("%1 METARs").arg(_metarList.size())); } if (_metarReply != 0 && _metarReply->isRunning()) { ret.append(" …"); } return ret; } void MetarModel::setAirports(const QList<Airport*>& airports) { _airportList = airports; _metarList = airports; // remove all entries from metarList with invalid or dead METARs for (int i = _metarList.size() - 1; i >= 0; i--) { Airport* a = _metarList.value(i, nullptr); if (a == nullptr) { continue; } if (a->metar.needsRefresh() || a->metar.doesNotExist()) { _metarList.removeAt(i); } } refresh(); } void MetarModel::modelClicked(const QModelIndex& index) { Airport* a = _metarList[index.row()]; if (a != 0 && a->hasPrimaryAction() && Window::instance(false) != 0) { a->primaryAction(); } } void MetarModel::refresh() { _downloadQueue.clear(); if (_airportList.size() > MAX_METARS) { // avoid hammering the server with gazillions of metar requests return; } foreach (Airport* airport, _airportList) { if (airport == 0) { continue; } if (!airport->metar.doesNotExist() && airport->metar.needsRefresh()) { downloadMetarFor(airport); } else { emit gotMetar(airport->id, airport->metar.encoded, airport->metar.humanHtml()); } } } void MetarModel::downloadMetarFor(Airport* airport) { QString location = Whazzup::instance()->metarUrl(airport->id); if (location.isEmpty()) { return; } QUrl url(location); qDebug() << airport->id << url; _downloadQueue.insert(url, airport); downloadNextFromQueue(); emit headerDataChanged(Qt::Horizontal, 0, 0); } void MetarModel::downloadNextFromQueue() { qDebug() << "queue.count=" << _downloadQueue.count(); if (_downloadQueue.isEmpty()) { return; } if (_metarReply != 0 && !_metarReply->isFinished()) { qDebug() << "_metarReply still running"; return; // we will be called via downloaded() later } _metarReply = Net::g(_downloadQueue.constBegin().key()); connect(_metarReply, &QNetworkReply::redirected, this, &MetarModel::metarReplyRedirected); connect(_metarReply, &QNetworkReply::finished, this, &MetarModel::metarReplyFinished); } void MetarModel::metarReplyFinished() { disconnect(_metarReply, &QNetworkReply::finished, this, &MetarModel::metarReplyFinished); if (_metarReply->error() != QNetworkReply::NoError) { qWarning() << "error during fetch:" << _metarReply->url(); } else { qDebug() << _metarReply->url() << _metarReply->bytesAvailable() << "bytes"; QString line = _metarReply->readAll().trimmed(); Airport* airport = _downloadQueue.take(_metarReply->url()); if (airport != 0) { if (!line.isEmpty()) { airport->metar = Metar(line, airport->id); } if (!airport->metar.isNull() && airport->metar.isValid()) { gotMetarFor(airport); } emit headerDataChanged(Qt::Horizontal, 0, 0); } } downloadNextFromQueue(); } void MetarModel::metarReplyRedirected(const QUrl &url) { qDebug() << url; QUrl oldUrl = _downloadQueue.constBegin().key(); _downloadQueue.insert(url, _downloadQueue.constBegin().value()); _downloadQueue.remove(oldUrl); } void MetarModel::gotMetarFor(Airport* airport) { qDebug() << airport->id << _airportList; if (_airportList.contains(airport)) { beginResetModel(); if (!_metarList.contains(airport)) { _metarList.append(airport); } qDebug() << airport->id << ":" << airport->metar.encoded; emit gotMetar(airport->id, airport->metar.encoded, airport->metar.humanHtml()); endResetModel(); } }
5,836
C++
.cpp
170
27.629412
96
0.603519
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,658
AirportDetailsDeparturesModel.cpp
qutescoop_qutescoop/src/models/AirportDetailsDeparturesModel.cpp
#include "AirportDetailsDeparturesModel.h" #include "src/Airport.h" #include "src/Settings.h" #include <QFont> void AirportDetailsDeparturesModel::setClients(const QList<Pilot*>& pilots) { beginResetModel(); this->_pilots = pilots; endResetModel(); } QVariant AirportDetailsDeparturesModel::headerData(int section, enum Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { switch (section) { case 0: return QString("Callsign"); case 1: return QString("Type"); case 2: return QString("Name"); case 3: return QString("Outbound To"); case 4: return QString("T"); case 5: return QString("Via"); case 6: return QString("Dist"); case 7: return QString("Delay"); case 8: return QString("Status"); } } return QVariant(); } int AirportDetailsDeparturesModel::columnCount(const QModelIndex&) const { return 9; } int AirportDetailsDeparturesModel::rowCount(const QModelIndex&) const { return _pilots.count(); } QVariant AirportDetailsDeparturesModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() >= _pilots.size()) { return QVariant(); } Pilot* p = _pilots.value(index.row(), nullptr); if (p == nullptr) { return QVariant(); } if (index.column() == 6) { const bool isFilteredDep = Settings::filterTraffic() && p->distanceFromDeparture() < Settings::filterDistance(); if (isFilteredDep) { if (role == Qt::ForegroundRole) { return QGuiApplication::palette().window(); } else if (role == Qt::BackgroundRole) { return QGuiApplication::palette().text(); } } } if (role == Qt::FontRole) { QFont result; if (p->flightStatus() == Pilot::PREFILED) { result.setItalic(true); } if (p->isFriend()) { result.setBold(true); } return result; } else if (role == Qt::TextAlignmentRole) { switch (index.column()) { case 6: case 7: return Qt::AlignRight; case 4: case 8: return Qt::AlignHCenter; } return Qt::AlignLeft; } else if (role == Qt::DisplayRole) { switch (index.column()) { case 0: return p->callsign; case 1: return p->planAircraftShort; case 2: return p->displayName(); case 3: return p->destAirport() != 0? p->destAirport()->toolTip(): ""; case 4: return p->planFlighttype; case 5: return p->waypoints().isEmpty()? "": p->waypoints().constFirst(); case 6: if (p->flightStatus() == Pilot::PREFILED || p->flightStatus() == Pilot::BOARDING || p->flightStatus() == Pilot::GROUND_DEP) { return "SOBT " + p->etd().toString("HH:mm"); // p->planDeptime.mid(0, p->planDeptime.length() - 2) + // ":" + p->planDeptime.right(2); } else { return QString("%1 NM").arg(p->distanceFromDeparture() < 3? 0: (int) p->distanceFromDeparture()); } case 7: return p->delayString(); case 8: return p->flightStatusShortString(); } } else if (role == Qt::UserRole) { // used for sorting switch (index.column()) { case 6: { if (p->flightStatus() == Pilot::BUSH) { return "0"; } if (p->flightStatus() == Pilot::PREFILED || p->flightStatus() == Pilot::BOARDING) { return "1" + p->etd().toString("dd HHmm"); } if (p->flightStatus() == Pilot::GROUND_DEP) { return "2" + p->etd().toString("dd HHmm");; } return QString("3%1").arg(p->distanceFromDeparture(), 10, 'f', 1, '0'); } } return data(index, Qt::DisplayRole); } return QVariant(); } void AirportDetailsDeparturesModel::modelSelected(const QModelIndex& index) const { Pilot* p = _pilots.value(index.row(), nullptr); if (p == nullptr) { return; } if (p->hasPrimaryAction()) { p->primaryAction(); } }
4,585
C++
.cpp
123
26.674797
141
0.526541
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,659
BookedAtcSortFilter.cpp
qutescoop_qutescoop/src/models/filters/BookedAtcSortFilter.cpp
#include "BookedAtcSortFilter.h" bool BookedAtcSortFilter::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const { if (this->_from.isValid() && this->_to.isValid()) { if (sourceModel()->index(source_row, 0, source_parent).isValid()) { QDateTime starts = sourceModel()->index(source_row, 4, source_parent).data(Qt::UserRole).toDateTime().toUTC(); QDateTime ends = sourceModel()->index(source_row, 5, source_parent).data(Qt::UserRole).toDateTime().toUTC(); if ( (_to == _from && _from <= ends) // _to == _from means for: ever || (_from <= starts && _to >= starts) || (_from <= ends && _to >= starts) ) { return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); } return false; } } else { return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); } return false; } bool BookedAtcSortFilter::lessThan(const QModelIndex &left, const QModelIndex &right) const { auto leftData = sourceModel()->data(left, Qt::UserRole); auto rightData = sourceModel()->data(right, Qt::UserRole); if (leftData.userType() == QMetaType::QDateTime) { return leftData.toDateTime() < rightData.toDateTime(); } return QString::localeAwareCompare(leftData.toString(), rightData.toString()) < 0; } void BookedAtcSortFilter::setDateTimeRange(QDateTime& from, QDateTime& to) { this->_from = from; this->_to = to; this->invalidateFilter(); }
1,580
C++
.cpp
33
40.212121
122
0.635126
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,660
AirportDetailsAtcModelItem.cpp
qutescoop_qutescoop/src/models/items/AirportDetailsAtcModelItem.cpp
#include "AirportDetailsAtcModelItem.h" #include <src/models/AirportDetailsAtcModel.h> AirportDetailsAtcModelItem::AirportDetailsAtcModelItem(const QStringList &columnTexts, Controller* controller, AirportDetailsAtcModelItem* parent) : m_parentItem(parent), m_columnTexts(columnTexts), m_controller(controller) {} AirportDetailsAtcModelItem::~AirportDetailsAtcModelItem() { qDeleteAll(m_childItems); } void AirportDetailsAtcModelItem::removeChildren() { qDeleteAll(m_childItems); m_childItems.clear(); } int AirportDetailsAtcModelItem::row() const { if (m_parentItem) { return m_parentItem->m_childItems.indexOf(const_cast<AirportDetailsAtcModelItem*>(this)); } return 0; }
716
C++
.cpp
17
38.647059
146
0.793651
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,661
Renderer.cpp
qutescoop_qutescoop/src/mustache/Renderer.cpp
#include "Renderer.h" #include "src/Airport.h" namespace MustacheQs { Renderer* renderer = nullptr; Renderer* Renderer::instance() { if (renderer == nullptr) { renderer = new Renderer(); } return renderer; } QString Renderer::render(const QString &_template, QObject* _o) { return instance()->m_render(_template, _o); } void Renderer::teardownContext(QObject* _o) { instance()->m_teardownContext(_o); } Renderer::Renderer() { m_renderer = Mustache::Renderer(); // we only use single braces m_renderer.setTagMarkers("{", "}"); } QString Renderer::m_render(const QString &_template, QObject* _o) { return m_renderer.render(_template, m_context(_o)); } void Renderer::m_teardownContext(QObject* _o) { if (!m_contexts.contains(_o)) { return; } auto context = m_contexts.take(_o); delete context; } Mustache::Context* Renderer::m_context(QObject* _o) { if (m_contexts.contains(_o)) { return m_contexts.value(_o); } Mustache::Context* context; ::Airport* a = qobject_cast<::Airport*>(_o); if (a != 0) { context = new MustacheQs::Airport::Context(a); } else { ::Controller* c = qobject_cast<::Controller*>(_o); if (c != 0) { context = new MustacheQs::Controller::Context(c); } else { ::Pilot* p = qobject_cast<::Pilot*>(_o); if (p != 0) { context = new MustacheQs::Pilot::Context(p); } else { context = new Mustache::QtVariantContext((QVariantHash())); } } } m_contexts.insert(_o, context); return context; } }
1,867
C++
.cpp
56
24.071429
79
0.532222
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,662
ControllerContext.cpp
qutescoop_qutescoop/src/mustache/contexts/ControllerContext.cpp
#include "ControllerContext.h" #include "src/Controller.h" namespace MustacheQs::Controller { PartialResolver* PartialResolver::inst = nullptr; PartialResolver* PartialResolver::instance() { if (inst == nullptr) { inst = new PartialResolver(); } return inst; } QString PartialResolver::getPartial(const QString &name) { return QString("[> %1]").arg(name); } PartialResolver::PartialResolver() {} Context::Context(const class Controller* a) : Mustache::Context(PartialResolver::instance()), m_o(a) {} Context::~Context() {} QString Context::stringValue(const QString &key) const { if (key == "sectorOrLogin") { if (m_o->sector != 0) { return m_o->controllerSectorName(); } return m_o->callsign; } if (key == "sector") { if (m_o->sector != 0) { return m_o->sector->name; } return ""; } if (key == "name") { return m_o->aliasOrName(); } if (key == "nameIfFriend") { return m_o->isFriend()? m_o->aliasOrName(): ""; } if (key == "rating") { return m_o->rank(); } if (key == "frequency") { return m_o->frequency.length() > 1? m_o->frequency: ""; } if (key == "cpdlc") { return m_o->cpdlcString(); } if (key == "livestream") { return m_o->livestreamString(); } return QString("{%1}").arg(key); } bool Context::isFalse(const QString &key) const { return stringValue(key).isEmpty(); } int Context::listCount(const QString&) const { return 0; } void Context::push(const QString&, int) {} void Context::pop() {} }
1,861
C++
.cpp
59
22.779661
67
0.524609
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,663
PilotContext.cpp
qutescoop_qutescoop/src/mustache/contexts/PilotContext.cpp
#include "PilotContext.h" #include "src/Pilot.h" namespace MustacheQs::Pilot { PartialResolver* PartialResolver::inst = nullptr; PartialResolver* PartialResolver::instance() { if (inst == nullptr) { inst = new PartialResolver(); } return inst; } QString PartialResolver::getPartial(const QString &name) { return QString("[> %1]").arg(name); } PartialResolver::PartialResolver() {} Context::Context(const class Pilot* a) : Mustache::Context(PartialResolver::instance()), m_o(a) {} Context::~Context() {} QString Context::stringValue(const QString &key) const { if (key == "debug:nextWp") { QList<Waypoint*> waypoints = ((class Pilot*) m_o)->routeWaypointsWithDepDest(); int next = m_o->nextPointOnRoute(waypoints); Waypoint* w = waypoints.value(next, nullptr); if (w == nullptr) { return ""; } return w->id; } if (key == "login") { return m_o->callsign; } if (key == "name") { return m_o->aliasOrName(); } if (key == "nameIfFriend") { return m_o->isFriend()? m_o->aliasOrName(): ""; } if (key == "rating") { return m_o->rank(); } if (key == "dep") { return m_o->planDep; } if (key == "dest") { return m_o->planDest; } if (key == "FL") { return m_o->flOrEmpty(); } if (key == "GS") { auto _gs = m_o->groundspeed; if (_gs == 0) { return ""; } return QString("N%1").arg(m_o->groundspeed); } if (key == "GS10") { auto _gs = m_o->groundspeed; if (_gs == 0) { return ""; } return QString("N%1").arg(round(m_o->groundspeed / 10.)); } if (key == "rules") { return m_o->planFlighttype; } if (key == "rulesIfNotIfr") { return m_o->planFlighttype != "I"? m_o->planFlighttype: ""; } if (key == "type") { return m_o->planAircraftShort; } if (key == "livestream") { return m_o->livestreamString(); } return QString("{%1}").arg(key); } bool Context::isFalse(const QString &key) const { return stringValue(key).isEmpty(); } int Context::listCount(const QString&) const { return 0; } void Context::push(const QString&, int) {} void Context::pop() {} }
2,659
C++
.cpp
85
21.752941
91
0.490043
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,664
AirportContext.cpp
qutescoop_qutescoop/src/mustache/contexts/AirportContext.cpp
#include "AirportContext.h" #include "src/Airport.h" namespace MustacheQs::Airport { PartialResolver* PartialResolver::inst = nullptr; PartialResolver* PartialResolver::instance() { if (inst == nullptr) { inst = new PartialResolver(); } return inst; } QString PartialResolver::getPartial(const QString &name) { if (name == "traffic") { return "{#arrs}{arrs}{/arrs}{^arrs}-{/arrs}/{#deps}{deps}{/deps}{^deps}-{/deps}"; } if (name == "trafficArrows") { return "{#arrs}{arrs}↘{/arrs}{#deps}↗{deps}{/deps}"; } if (name == "controllerSymbols") { return "{#app}📡{/app}{#twr}🛨{/twr}{#gnd}⛕{/gnd}{#del}🗈{/del}"; } return QString("[> %1]").arg(name); } PartialResolver::PartialResolver() {} Context::Context(const class Airport* a) : Mustache::Context(PartialResolver::instance()), m_o(a) {} Context::~Context() {} QString Context::stringValue(const QString &key) const { if (key == "code") { return m_o->id; } if (key == "arrs") { return QString::number(m_o->nMaybeFilteredArrivals); } if (key == "deps") { return QString::number(m_o->nMaybeFilteredDepartures); } if (key == "allArrs") { return QString::number(m_o->arrivals.count()); } if (key == "allDeps") { return QString::number(m_o->departures.count()); } if (key == "del") { if (m_o->dels.isEmpty()) { return ""; } return "D"; } if (key == "gnd") { if (m_o->gnds.isEmpty()) { return ""; } return "G"; } if (key == "twr") { if (m_o->twrs.isEmpty()) { return ""; } return "T"; } if (key == "app") { if (m_o->appDeps.isEmpty()) { return ""; } return "A"; } if (key == "controllers") { return m_o->controllersString(); } if (key == "atis") { return m_o->atisCodeString(); } if (key == "country") { return m_o->countryCode; } if (key == "prettyName") { return m_o->prettyName(); } if (key == "name") { return m_o->name; } if (key == "city") { return m_o->city; } if (key == "frequencies") { return m_o->frequencyString(); } if (key == "pdc") { return m_o->pdcString(""); } if (key == "livestream") { return m_o->livestreamString(); } return QString("{%1}").arg(key); } bool Context::isFalse(const QString &key) const { auto v = stringValue(key); return v.isEmpty() || v == "0"; } int Context::listCount(const QString&) const { return 0; } void Context::push(const QString&, int) {} void Context::pop() {} }
3,174
C++
.cpp
105
20.580952
93
0.464181
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,666
WhazzupData.h
qutescoop_qutescoop/src/WhazzupData.h
#ifndef WHAZZUPDATA_H_ #define WHAZZUPDATA_H_ #include "MapObjectVisitor.h" class Pilot; class Controller; class BookedController; class Client; class WhazzupData { public: enum WhazzupType { NONE, WHAZZUP, ATCBOOKINGS, UNIFIED }; WhazzupData(); WhazzupData(QByteArray* bytes, WhazzupType type); WhazzupData(const QDateTime predictTime, const WhazzupData &data); // predict whazzup data WhazzupData(const WhazzupData &data); ~WhazzupData(); WhazzupData &operator=(const WhazzupData &data); bool isNull() const; void updateFrom(const WhazzupData &data); QSet<Controller*> controllersWithSectors() const; QHash<QString, Pilot*> pilots, bookedPilots; QHash<QString, Controller*> controllers; QList<Pilot*> allPilots() const; QList<BookedController*> bookedControllers; QList<QPair<double, double> > friendsLatLon() const; Pilot* findPilot(const QString& callsign) const; QList<QStringList> servers; QHash<int, QString> ratings; QHash<int, QString> pilotRatings; QHash<int, QString> militaryRatings; QDateTime updateEarliest, whazzupTime, bookingsTime, predictionBasedOnTime, predictionBasedOnBookingsTime; void accept(MapObjectVisitor* visitor) const; private: void assignFrom(const WhazzupData &data); void updatePilotsFrom(const WhazzupData &data); void updateControllersFrom(const WhazzupData &data); void updateBookedControllersFrom(const WhazzupData &data); int _whazzupVersion; WhazzupType _dataType; }; #endif /*WHAZZUPDATA_H_*/
1,678
C++
.h
40
34.825
114
0.710769
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,667
NavData.h
qutescoop_qutescoop/src/NavData.h
#ifndef NAVDATA_H_ #define NAVDATA_H_ #include "Airline.h" #include "SearchVisitor.h" #include "Sector.h" struct ControllerAirportsMapping { QString prefix; QStringList suffixes; QSet<Airport*> airports; }; enum LatLngPrecission { Secs = 3, Mins = 2, Degrees = 1 }; class NavData : public QObject { Q_OBJECT public: static NavData* instance(bool createIfNoInstance = true); static QPair<double, double>* fromArinc(const QString &str); static QString toArinc(const float lat, const float lon); static QString toEurocontrol(const double lat, const double lon, const LatLngPrecission maxPrecision = LatLngPrecission::Secs); static double distance(double lat1, double lon1, double lat2, double lon2); static QPair<double, double> pointDistanceBearing( double lat, double lon, double dist, double heading ); static double courseTo(double lat1, double lon1, double lat2, double lon2); static QPair<double, double> greatCircleFraction( double lat1, double lon1, double lat2, double lon2, double fraction ); static QList<QPair<double, double> > greatCirclePoints( double lat1, double lon1, double lat2, double lon2, double intervalNm = 30. ); static void plotGreatCirclePoints(const QList<QPair<double, double> > &points, bool isReverseTextCoords = false); virtual ~NavData(); QHash<QString, Airport*> airports; QMultiMap<int, Airport*> activeAirports; // holds activeAirports sorted by congestion ascending QMultiMap<QString, Sector*> sectors; QHash<QString, QString> countryCodes; QString airline(const QString &airlineCode); QHash<QString, Airline*> airlines; Airport* airportAt(double lat, double lon, double maxDist) const; QSet<Airport*> additionalMatchedAirportsForController(QString prefix, QString suffix) const; void updateData(const WhazzupData& whazzupData); void accept(SearchVisitor* visitor); public slots: void load(); signals: void loaded(); private: NavData(); void loadAirports(const QString& filename); void loadControllerAirportsMapping(const QString& filename); QList<ControllerAirportsMapping> m_controllerAirportsMapping; void loadSectors(); void loadCountryCodes(const QString& filename); void loadAirlineCodes(const QString& filename); }; #endif /*NAVDATA_H_*/
2,662
C++
.h
69
30.57971
135
0.669249
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,668
GuiMessage.h
qutescoop_qutescoop/src/GuiMessage.h
#ifndef GUIMESSAGE_H #define GUIMESSAGE_H #include <QLabel> #include <QtCore> #include <QProgressBar> class GuiMessages : public QObject { Q_OBJECT public: static GuiMessages* instance(bool createIfNoInstance = true); /////////////////////////////////////////////////////////////////////////// // STATIC METHODS TO SEND MESSAGES /** temporary message: **/ static void message(const QString &msg, const QString &id = ""); /** also temporary, but with higher priority **/ static void warning(const QString &msg, const QString &id = ""); /** shown if no other messages available **/ static void status(const QString &msg, const QString &id = ""); /** just draw attention, no disturbance of the program flow **/ static void infoUserAttention(const QString &msg, const QString &id = ""); /** informational, user-confirmation required **/ static void infoUserInteraction(const QString &msg, const QString &titleAndId = ""); /** just draw attention, no disturbance of the program flow **/ static void errorUserAttention(const QString &msg, const QString &id = ""); /** user-confirmation required **/ static void criticalUserInteraction(const QString &msg, const QString &titleAndId); /** program needs to close **/ static void fatalUserInteraction(const QString &msg, const QString &titleAndId); /** set progress message **/ static void progress(const QString &id, const QString &msg); /** update progress value **/ static void progress(const QString &id, int value, int maximum = -1); /** remove message **/ static void remove(const QString &id); /////////////////////////////////////////////////////////////////////////// // METHODS TO SET ACTIVE OUTPUT WIDGETS void addStatusLabel(QLabel* label, bool hideIfNothingToDisplay = true); void removeStatusLabel(QLabel* label); void addProgressBar(QProgressBar* progressBar, bool hideIfNothingToDisplay = true); void removeProgressBar(QProgressBar* progressBar); /////////////////////////////////////////////////////////////////////////// // INTERNALLY USED CLASS class GuiMessage { public: enum Type { // type corresponding to priority All = 101, Uninitialized = 100, Persistent = 10, ProgressBar = 7, Temporary = 9, InformationUserInteraction = 6, InformationUserAttention = 5, Warning = 4, ErrorUserAttention = 3, CriticalUserInteraction = 1, FatalUserInteraction = 0 }; GuiMessage() : // needed for _METATYPE id(""), msg(""), type(Uninitialized), progressValue(-1), progressMaximum(-1), showMs(-1), shownSince(QDateTime()) {} GuiMessage( const QString &id, const Type &type, const QString &msg, int progressValue = -1, int progressMaximum = -1 ) : id(id), msg(msg), type(type), progressValue(progressValue), progressMaximum(progressMaximum), showMs(-1), shownSince(QDateTime()) {} bool operator==(const GuiMessage* gm) const { return id == gm->id && msg == gm->msg && type == gm->type && progressValue == gm->progressValue && progressMaximum == gm->progressMaximum && showMs == gm->showMs && shownSince == gm->shownSince; } ~GuiMessage(); // needed for _METATYPE QString id, msg; Type type; int progressValue, progressMaximum, showMs; QDateTime shownSince; }; /////////////////////////////////////////////////////////////////////////// // INTERNALLY USED METHODS (public to be callable out of static methods) void updateMessage(GuiMessage* gm); void removeMessageById(const QString &id); public slots: void labelDestroyed(QObject* obj); void progressBarDestroyed(QObject* obj); private slots: void update(); private: GuiMessages(); virtual ~GuiMessages(); void setStatusMessage( GuiMessage* gm, bool bold = false, bool italic = false, bool instantRepaint = true ); void setProgress(GuiMessage* gm, bool instantRepaint = true); GuiMessage* messageById(const QString &id, const GuiMessage::Type &type = GuiMessage::All); QHash<QLabel*, bool> _labels; // bool indicating hideIfNothingToDisplay QHash<QProgressBar*, bool> _bars; // bool indicating hideIfNothingToDisplay GuiMessage* _currentStatusMessage, * _currentProgressMessage; QMultiMap<int, GuiMessage*> _messages; // messages sorted by priority (= int of enum GuiMessage::Type) QTimer _timer; }; Q_DECLARE_METATYPE(GuiMessages::GuiMessage) // needed for QVariant and QDebug compatibility QDebug operator<<(QDebug dbg, const GuiMessages::GuiMessage* gm); #endif // GUIMESSAGE_H
5,340
C++
.h
102
40.911765
110
0.571483
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,669
Ping.h
qutescoop_qutescoop/src/Ping.h
#ifndef PING_H #define PING_H #include <QtCore> class Ping : public QObject { Q_OBJECT public: void startPing(QString server); signals: void havePing(QString, int); private slots: void pingReadyRead(); private: QProcess* _pingProcess; QString _server; }; #endif // PING_H
339
C++
.h
17
15
39
0.636364
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,670
Airac.h
qutescoop_qutescoop/src/Airac.h
#ifndef AIRAC_H_ #define AIRAC_H_ #include "Airway.h" #include "NavAid.h" #include "Waypoint.h" class Airac : public QObject { Q_OBJECT public: static Airac* instance(bool createIfNoInstance = true); static QString effectiveCycle(const QDate& date = QDate::currentDate()); // this is the longest legitimate route part that we can't resolve (yet) (PACOT entry-exit) constexpr static const double ifrMaxWaypointInterval = 5500.; constexpr static const double nonIfrMaxWaypointInterval = 300.; virtual ~Airac(); Waypoint* waypoint(const QString &id, const QString &regionCode, const int &type) const; Waypoint* waypointNearby(const QString &id, double lat, double lon, double maxDist); Airway* airway(const QString& name); Airway* airwayNearby(const QString& name, double lat, double lon) const; QList<Waypoint*> resolveFlightplan(QStringList plan, double lat, double lon, double maxDist); QSet<Waypoint*> allPoints; QHash<QString, QSet<Waypoint*> > fixes; QHash<QString, QSet<NavAid*> > navaids; QHash<QString, QList<Airway*> > airways; public slots: void load(); signals: void loaded(); private: Airac(); void readFixes(const QString &directory); void readNavaids(const QString &directory); void readAirways(const QString &directory); void addAirwaySegment(Waypoint* from, Waypoint* to, const QString &name); QString fpTokenToWaypoint(QString token) const; }; #endif /* AIRAC_H_ */
1,599
C++
.h
37
36.324324
101
0.684923
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,671
BookedController.h
qutescoop_qutescoop/src/BookedController.h
#ifndef BOOKEDCONTROLLER_H_ #define BOOKEDCONTROLLER_H_ #include <QJsonObject> /* * This is not a "Client" in the sense of a VATSIM client. This is rather a DTO to initialize * actual "Controller"s from. */ class BookedController { public: BookedController(const QJsonObject& json); QString facilityString() const; const QString realName() const; bool isFriend() const; QDateTime starts() const; QDateTime ends() const; int facilityType; QString bookingInfoStr, bookingType; QString callsign, userId; QDateTime timeConnected; protected: QDateTime m_starts, m_ends; }; #endif /*BOOKEDCONTROLLER_H_*/
705
C++
.h
23
25.043478
93
0.688889
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,672
Pilot.h
qutescoop_qutescoop/src/Pilot.h
#ifndef PILOT_H_ #define PILOT_H_ #include "Airline.h" #include "Client.h" #include "MapObject.h" #include "Waypoint.h" #include "src/mustache/contexts/PilotContext.h" #include <QJsonDocument> class Airport; class Pilot : public MapObject, public Client { Q_OBJECT public: static const int taxiTimeOutbound = 240; static int altToFl(int alt_ft, int qnh_mb); enum FlightStatus { BOARDING, GROUND_DEP, DEPARTING, EN_ROUTE, ARRIVING, GROUND_ARR, BLOCKED, CRASHED, BUSH, PREFILED }; Pilot(const QJsonObject& json, const WhazzupData* whazzup); virtual ~Pilot(); virtual QString toolTip() const override; virtual QString rank() const override; virtual QString mapLabel() const override; virtual QString mapLabelHovered() const override; virtual QStringList mapLabelSecondaryLines() const override; virtual QStringList mapLabelSecondaryLinesHovered() const override; virtual QString livestreamString() const override; virtual bool hasPrimaryAction() const override; virtual void primaryAction() override; void showDetailsDialog(); FlightStatus flightStatus() const; QString flightStatusString() const; QString flightStatusShortString() const; QString planFlighttypeString() const; Airport* depAirport() const; Airport* destAirport() const; Airport* altAirport() const; QStringList waypoints() const; double distanceToDestination() const; double distanceFromDeparture() const; QDateTime etd() const; // Estimated Time of Departure QDateTime eta() const; // Estimated Time of Arrival //QDateTime fixedEta; // ETA, written after creation as a workaround for Prediction (Warp) Mode QTime eet() const; // Estimated Enroute Time as remaining time to destination QDateTime etaPlan() const; // Estimated Time of Arrival as flightplanned QString delayString() const; int planTasInt() const; // defuck TAS for Mach numbers int defuckPlanAlt(QString alt) const; // returns an altitude from various flightplan strings QString humanAlt() const; // altitude as string, prefixed with FL if applicable QString flOrEmpty() const; // altitude prefixed with F QPair<double, double> positionInFuture(int seconds) const; int nextPointOnRoute(const QList<Waypoint*> &waypoints) const; QString routeWaypointsString(); QList<Waypoint*> routeWaypoints(); QList<Waypoint*> routeWaypointsWithDepDest(); void checkStatus(); // adjust label visibility from flight status QString planAircraftShort, planAircraftFaa, planAircraftFull, planTAS, planDep, planAlt, planDest, planAltAirport, planRevision, planFlighttype, planDeptime, transponder, transponderAssigned, planRemarks, planRoute, planActtime, routeWaypointsPlanDepCache, routeWaypointsPlanDestCache, routeWaypointsPlanRouteCache; QDate dayOfFlight; int altitude, groundspeed, planEnroute_hrs, planEnroute_mins, planFuel_hrs, planFuel_mins, qnh_mb; int pilotRating = -99, militaryRating = -99; double trueHeading, qnh_inHg; bool showRoute = false; QDateTime whazzupTime; // need some local reference to that QList<Waypoint*> routeWaypointsCache; // caching calculated routeWaypoints Airline* airline; }; #endif /*PILOT_H_*/
3,583
C++
.h
75
39.586667
103
0.697455
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,673
NavAid.h
qutescoop_qutescoop/src/NavAid.h
#ifndef NAVAID_H_ #define NAVAID_H_ #include "Waypoint.h" class NavAid : public Waypoint { public: enum Type { NDB = 2, VOR = 3, ILS_LOC = 4, LOC = 5, GS = 6, OM = 7, MM = 8, IM = 9, DME_NO_FREQ = 12, DME = 13, FAP_GBAS = 14, GBAS_GND = 15, GBAS_THR = 16, CUSTOM_VORDME = 99, }; static QString typeStr(Type _type); static const QHash<Type, QString> typeStrings; NavAid(const QStringList& stringList); virtual QString toolTip() const override; virtual QString mapLabelHovered() const override; virtual QStringList mapLabelSecondaryLinesHovered() const override; virtual int type() override; void upgradeToVorDme(); QString freqString() const; private: Type _type; int _freq; float _hdg; QString _name; }; #endif /* NAVAID_H_ */
1,034
C++
.h
38
18.131579
75
0.524772
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,674
Whazzup.h
qutescoop_qutescoop/src/Whazzup.h
#ifndef WHAZZUP_H_ #define WHAZZUP_H_ #include "WhazzupData.h" #include <QNetworkReply> class Whazzup : public QObject { Q_OBJECT public: static Whazzup* instance(); const WhazzupData& whazzupData() { return predictedTime.isValid()? _predictedData: _data; } // we fake it when predicting a certain time const WhazzupData& realWhazzupData() { return _data; } // this is always the really downloaded thing void setPredictedTime(QDateTime predictedTime); QString userUrl(const QString& id) const, metarUrl(const QString& id) const; QList <QPair <QDateTime, QString> > downloadedWhazzups() const; QDateTime predictedTime; signals: void newData(bool isNew); void whazzupDownloaded(); void needBookings(); public slots: void downloadJson3(); void fromFile(QString filename); void setStatusLocation(const QString& url); void downloadBookings(); private slots: void processStatus(); void whazzupProgress(qint64 prog, qint64 tot); void processWhazzup(); void bookingsProgress(qint64 prog, qint64 tot); void processBookings(); private: Whazzup(); virtual ~Whazzup(); WhazzupData _data, _predictedData; QStringList _json3Urls; QString _metar0Url, _user0Url; QTime _lastDownloadTime; QTimer* _downloadTimer, * _bookingsTimer; QNetworkReply* _replyStatus, * _replyWhazzup, * _replyBookings; }; #endif /*WHAZZUP_H_*/
1,618
C++
.h
47
26.723404
71
0.647698
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,675
Platform.h
qutescoop_qutescoop/src/Platform.h
#ifndef PLATFORM_H_ #define PLATFORM_H_ #include <QString> class Platform { public: static QString platformOS(); static QString compiler(); static QString compileMode(); static QString version(); }; #endif // PLATFORM_H
259
C++
.h
11
19
37
0.673469
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,676
Launcher.h
qutescoop_qutescoop/src/Launcher.h
#ifndef LAUNCHER_H_ #define LAUNCHER_H_ #include <QLabel> #include <QProgressBar> #include <QtGui> #include <QtNetwork> class Launcher : public QWidget { Q_OBJECT public: static Launcher* instance(bool createIfNoInstance = true); void fireUp(); public slots: void checkData(); protected: void mouseMoveEvent(QMouseEvent*); void mousePressEvent(QMouseEvent*); signals: void dataChecked(); private slots: void dataVersionsDownloaded(); void dataFileDownloaded(); void loadNavdata(); private: Launcher(QWidget* parent = 0); virtual ~Launcher(); QPixmap _map; QLabel* _image, * _text; QProgressBar* _progress; QPoint _dragPosition; QNetworkReply* _replyDataVersionsAndFiles; QList<QString> _dataFilesToDownload; QMap<QString, int> _localDataVersionsList, _serverDataVersionsList; }; #endif // LAUNCHER_H
979
C++
.h
35
21.857143
75
0.662062
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,677
Controller.h
qutescoop_qutescoop/src/Controller.h
#ifndef CONTROLLER_H_ #define CONTROLLER_H_ #include "Client.h" #include "MapObject.h" #include "Sector.h" #include "WhazzupData.h" #include "src/mustache/contexts/ControllerContext.h" #include <QJsonObject> class Airport; class Controller : public MapObject, public Client { Q_OBJECT public: static const QRegularExpression cpdlcRegExp; Controller(const QJsonObject& json, const WhazzupData* whazzup); virtual ~Controller(); virtual QString rank() const override; virtual bool isFriend() const override; virtual QString toolTip() const override; virtual QString mapLabel() const override; virtual QString mapLabelHovered() const override; virtual QStringList mapLabelSecondaryLines() const override; virtual QStringList mapLabelSecondaryLinesHovered() const override; virtual QString livestreamString() const override; virtual bool matches(const QRegExp& regex) const override; virtual bool hasPrimaryAction() const override; virtual void primaryAction() override; void showDetailsDialog(); QString toolTipShort() const; bool isObserver() const; bool isATC() const; QStringList atcLabelTokens() const; QString controllerSectorName() const; QString facilityString() const; QString typeString() const; bool isCtrFss() const; bool isAppDep() const; bool isTwr() const; bool isGnd() const; bool isDel() const; bool isAtis() const; QSet<Airport*> airports(bool withAdditionalMatches = true) const; QList<Airport*> airportsSorted() const; const QString cpdlcString(const QString& prepend = "", bool alwaysWithIdentifier = true) const; QString frequency, atisMessage, atisCode; int facilityType, visualRange; QDateTime assumeOnlineUntil; Sector* sector; }; #endif /*CONTROLLER_H_*/
1,985
C++
.h
50
32.52
103
0.698644
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,678
Route.h
qutescoop_qutescoop/src/Route.h
#ifndef ROUTE_H_ #define ROUTE_H_ #include "Waypoint.h" class Route : public QObject { Q_OBJECT public: Route(); virtual ~Route(); QString provider, dep, dest, route, minFl, maxFl, airacCycle, lastChange, comments, routeDistance, waypointsStr; QList<Waypoint*> waypoints; void calculateWaypointsAndDistance(); }; #endif // ROUTE_H
399
C++
.h
15
21.066667
81
0.655263
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,679
ClientSelectionWidget.h
qutescoop_qutescoop/src/ClientSelectionWidget.h
#ifndef CLIENTSELECTIONWIDGET_H_ #define CLIENTSELECTIONWIDGET_H_ #include "MapObject.h" #include <QFocusEvent> #include <QListWidget> class ClientSelectionWidget : public QListWidget { Q_OBJECT public: explicit ClientSelectionWidget(QWidget* parent = 0); virtual ~ClientSelectionWidget(); void setObjects(QList<MapObject*> objects); void clearObjects(); virtual QSize sizeHint() const override; public slots: void dialogForItem(QListWidgetItem* item); protected: void focusOutEvent(QFocusEvent* event) override; private: QList<MapObject*> _displayClients; }; #endif
664
C++
.h
22
24.772727
60
0.721959
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,680
LineReader.h
qutescoop_qutescoop/src/LineReader.h
#ifndef COASTLINEREADER_H_ #define COASTLINEREADER_H_ #include "FileReader.h" class LineReader : public FileReader { public: LineReader(const QString& filename) : FileReader(filename) {} const QList<QPair<double, double> >& readLine(); private: QList<QPair<double, double> > _currentLine; }; #endif /*COASTLINEREADER_H_*/
373
C++
.h
13
23.769231
56
0.680672
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,681
Settings.h
qutescoop_qutescoop/src/Settings.h
#ifndef SETTINGS_H_ #define SETTINGS_H_ #include <QtCore> class Settings { public: struct DialogPreferences { QSize size; QPoint pos; QByteArray geometry; }; static QString fileName(); // export/import static void exportToFile(QString fileName); static void importFromFile(QString fileName); // data directory static QString dataDirectory(const QString& composeFilePath = QString("")); // "constant" settings static const QColor lightTextColor(); // saved settings static void saveState(const QByteArray& state); static QByteArray savedState(); static void saveGeometry(const QByteArray& state); static QByteArray savedGeometry(); static void saveSize(const QSize& size); static QSize savedSize(); static void savePosition(const QPoint& pos); static QPoint savedPosition(); static int downloadInterval(); static void setDownloadInterval(int value); static bool downloadOnStartup(); static void setDownloadOnStartup(bool value); static bool downloadPeriodically(); static void setDownloadPeriodically(bool value); static int downloadNetwork(); static void setDownloadNetwork(int i); static QString downloadNetworkName(); static QString userDownloadLocation(); static void setUserDownloadLocation(const QString& location); static QString statusLocation(); static QString bookingsLocation(); static void setBookingsLocation(const QString& value); static bool downloadBookings(); static void setDownloadBookings(bool value); static bool bookingsPeriodically(); static void setBookingsPeriodically(bool value); static int bookingsInterval(); static void setBookingsInterval(int value); static bool useProxy(); static void setUseProxy(bool value); static QString proxyServer(); static void setProxyServer(const QString& server); static int proxyPort(); static void setProxyPort(int value); static QString proxyUser(); static void setProxyUser(QString user); static QString proxyPassword(); static void setProxyPassword(QString password); static bool filterTraffic(); static void setFilterTraffic(bool v); static int filterDistance(); static void setFilterDistance(int v); static double filterArriving(); static void setFilterArriving(double v); static bool showAirportCongestion(); static void setAirportCongestion(bool v); static bool showAirportCongestionRing(); static void setAirportCongestionRing(bool v); static bool showAirportCongestionGlow(); static void setAirportCongestionGlow(bool v); static int airportCongestionMovementsMin(); static void setAirportCongestionMovementsMin(int v); static int airportCongestionRadiusMin(); static void setAirportCongestionRadiusMin(int v); static QColor airportCongestionColorMin(); static void setAirportCongestionColorMin(const QColor& color); static double airportCongestionBorderLineStrengthMin(); static void setAirportCongestionBorderLineStrengthMin(double value); static int airportCongestionMovementsMax(); static void setAirportCongestionMovementsMax(int v); static int airportCongestionRadiusMax(); static void setAirportCongestionRadiusMax(int v); static QColor airportCongestionColorMax(); static void setAirportCongestionColorMax(const QColor& color); static double airportCongestionBorderLineStrengthMax(); static void setAirportCongestionBorderLineStrengthMax(double value); static int timelineSeconds(); static void setTimelineSeconds(int value); static bool displaySmoothLines(); static void setDisplaySmoothLines(bool value); static bool displaySmoothDots(); static void setDisplaySmoothDots(bool value); static QString navdataDirectory(); static void setNavdataDirectory(const QString& directory); static bool useNavdata(); static void setUseNavdata(bool value); static int metarDownloadInterval(); static void setMetarDownloadInterval(int minutes); static bool showCTR(); static void setShowCTR(bool value); static bool showAPP(); static void setShowAPP(bool value); static bool showTWR(); static void setShowTWR(bool value); static bool showGND(); static void setShowGND(bool value); static bool showRouteFix(); static void setShowRouteFix(bool value); static bool showPilotsLabels(); static void setShowPilotsLabels(bool value); static bool highlightFriends(); static void setHighlightFriends(bool value); // Display/OpenGL static bool showFps(); static void setShowFps(bool value); static bool glStippleLines(); static void setGlStippleLines(bool value); static bool glBlending(); static void setGlBlending(bool value); static bool glLighting(); static void setEnableLighting(bool value); static int glLights(); static void setGlLights(int value); static int glLightsSpread(); static void setGlLightsSpread(int value); static int glCirclePointEach(); static void setGlCirclePointEach(int value); static bool glTextures(); static void setGlTextures(bool value); static QString glTextureEarth(); static void setGlTextureEarth(QString value); static QColor sunLightColor(); static void setSunLightColor(const QColor& color); static QColor specularColor(); static void setSpecularColor(const QColor& color); static double earthShininess(); static void setEarthShininess(double strength); static QString stylesheet(); static void setStylesheet(const QString& value); static int earthGridEach(); static void setEarthGridEach(int value); static QColor backgroundColor(); static void setBackgroundColor(const QColor& color); static QColor globeColor(); static void setGlobeColor(const QColor& color); static QColor gridLineColor(); static void setGridLineColor(const QColor& color); static double gridLineStrength(); static void setGridLineStrength(double strength); static QColor coastLineColor(); static void setCoastLineColor(const QColor& color); static double coastLineStrength(); static void setCoastLineStrength(double strength); static QColor countryLineColor(); static void setCountryLineColor(const QColor& color); static double countryLineStrength(); static void setCountryLineStrength(double strength); // Display/hover static bool labelAlwaysBackdropped(); static void setLabelAlwaysBackdropped(const bool v); static QColor labelHoveredBgColor(); static void setLabelHoveredBgColor(const QColor& color); static QColor labelHoveredBgDarkColor(); static void setLabelHoveredBgDarkColor(const QColor& color); static bool showToolTips(); static void setShowToolTips(const bool value); static int hoverDebounceMs(); static void setHoverDebounceMs(int value); static bool onlyShowHoveredLabels(); static void setOnlyShowHoveredLabels(const bool value); // sectors static QColor firBorderLineColor(); static void setFirBorderLineColor(const QColor& color); static double firBorderLineStrength(); static void setFirBorderLineStrength(double strength); static QColor firFillColor(); static void setFirFillColor(const QColor& color); static QColor firHighlightedBorderLineColor(); static void setFirHighlightedBorderLineColor(const QColor& color); static double firHighlightedBorderLineStrength(); static void setFirHighlightedBorderLineStrength(double strength); static QColor firHighlightedFillColor(); static void setFirHighlightedFillColor(const QColor& color); static QColor firFontColor(); static void setFirFontColor(const QColor& color); static QFont firFont(); static void setFirFont(const QFont& font); static QColor firFontSecondaryColor(); static void setFirFontSecondaryColor(const QColor& color); static QFont firFontSecondary(); static void setFirFontSecondary(const QFont& font); static QString firPrimaryContent(); static void setFirPrimaryContent(const QString& value); static QString firPrimaryContentHovered(); static void setFirPrimaryContentHovered(const QString& value); static QString firSecondaryContent(); static void setFirSecondaryContent(const QString& value); static QString firSecondaryContentHovered(); static void setFirSecondaryContentHovered(const QString& value); // airports static QFont airportFont(); static void setAirportFont(const QFont& font); static QColor airportFontColor(); static void setAirportFontColor(const QColor& color); static QFont airportFontSecondary(); static void setAirportFontSecondary(const QFont& font); static QColor airportFontSecondaryColor(); static void setAirportFontSecondaryColor(const QColor& color); static QString airportPrimaryContent(); static void setAirportPrimaryContent(const QString& value); static QString airportPrimaryContentHovered(); static void setAirportPrimaryContentHovered(const QString& value); static QString airportSecondaryContent(); static void setAirportSecondaryContent(const QString& value); static QString airportSecondaryContentHovered(); static void setAirportSecondaryContentHovered(const QString& value); static QColor airportDotColor(); static void setAirportDotColor(const QColor& color); static double airportDotSize(); static void setAirportDotSize(double value); static bool showInactiveAirports(); static void setShowInactiveAirports(const bool& value); static QColor inactiveAirportFontColor(); static void setInactiveAirportFontColor(const QColor& color); static QColor inactiveAirportDotColor(); static void setInactiveAirportDotColor(const QColor& color); static double inactiveAirportDotSize(); static void setInactiveAirportDotSize(double value); static QFont inactiveAirportFont(); static void setInactiveAirportFont(const QFont& font); static QColor twrBorderLineColor(); static void setTwrBorderLineColor(const QColor& color); static double twrBorderLineWidth(); static void setTwrBorderLineStrength(double value); static QColor appBorderLineColor(); static void setAppBorderLineColor(const QColor& color); static double appBorderLineWidth(); static void setAppBorderLineStrength(double value); static QColor appCenterColor(); static void setAppCenterColor(const QColor& color); static QColor appMarginColor(); static void setAppMarginColor(const QColor& color); static QColor twrMarginColor(); static void setTwrMarginColor(const QColor& color); static QColor twrCenterColor(); static void setTwrCenterColor(const QColor& color); static QColor gndBorderLineColor(); static void setGndBorderLineColor(const QColor& color); static double gndBorderLineWidth(); static void setGndBorderLineStrength(double value); static QColor gndFillColor(); static void setGndFillColor(const QColor& color); static QColor delBorderLineColor(); static void setDelBorderLineColor(const QColor& color); static double delBorderLineWidth(); static void setDelBorderLineStrength(double value); static QColor delFillColor(); static void setDelFillColor(const QColor& color); static QColor pilotFontColor(); static void setPilotFontColor(const QColor& color); static QFont pilotFont(); static void setPilotFont(const QFont& font); static QColor pilotFontSecondaryColor(); static void setPilotFontSecondaryColor(const QColor& color); static QFont pilotFontSecondary(); static void setPilotFontSecondary(const QFont& font); static QString pilotPrimaryContent(); static void setPilotPrimaryContent(const QString& value); static QString pilotPrimaryContentHovered(); static void setPilotPrimaryContentHovered(const QString& value); static QString pilotSecondaryContent(); static void setPilotSecondaryContent(const QString& value); static QString pilotSecondaryContentHovered(); static void setPilotSecondaryContentHovered(const QString& value); static QColor pilotDotColor(); static void setPilotDotColor(const QColor& color); static double pilotDotSize(); static void setPilotDotSize(double value); static QColor leaderLineColor(); static void setLeaderLineColor(const QColor& color); static bool showUsedWaypoints(); static void setShowUsedWaypoints(bool value); static QColor waypointsFontColor(); static void setWaypointsFontColor(const QColor& color); static QColor waypointsDotColor(); static void setWaypointsDotColor(const QColor& color); static double waypointsDotSize(); static void setWaypointsDotSize(double value); static QFont waypointsFont(); static void setWaypointsFont(const QFont& font); static bool showRoutes(); static void setShowRoutes(bool value); static bool onlyShowImmediateRoutePart(); static void setOnlyShowImmediateRoutePart(bool value); static QColor depLineColor(); static void setDepLineColor(const QColor& color); static double depLineStrength(); static void setDepLineStrength(double value); static bool depLineDashed(); static void setDepLineDashed(bool value); static int destImmediateDurationMin(); static void setDestImmediateDurationMin(int value); static QColor destImmediateLineColor(); static void setDestImmediateLineColor(const QColor& color); static double destImmediateLineStrength(); static void setDestImmediateLineStrength(double value); static double destLineStrength(); static void setDestLineStrength(double value); static QColor destLineColor(); static void setDestLineColor(const QColor& color); static bool destLineDashed(); static void setDestLineDashed(bool value); static double timeLineStrength(); static void setTimeLineStrength(double value); static QColor friendsHighlightColor(); static void setFriendsHighlightColor(QColor& color); static QColor friendsPilotDotColor(); static void setFriendsPilotDotColor(QColor& color); static QColor friendsAirportDotColor(); static void setFriendsAirportDotColor(QColor& color); static QColor friendsPilotLabelRectColor(); static void setFriendsPilotLabelRectColor(QColor& color); static QColor friendsAirportLabelRectColor(); static void setFriendsAirportLabelRectColor(QColor& color); static QColor friendsSectorLabelRectColor(); static void setFriendsSectorLabelRectColor(QColor& color); static double highlightLineWidth(); static void setHighlightLineWidth(double value); static bool animateFriendsHighlight(); static void setAnimateFriendsHighlight(bool value); static bool checkForUpdates(); static void setCheckForUpdates(bool value); static void rememberedMapPosition(double* xrot, double* yrot, double* zrot, double* zoom, int nr); static void setRememberedMapPosition(double xrot, double yrot, double zrot, double zoom, int nr); static bool rememberMapPositionOnClose(); static void setRememberMapPositionOnClose(bool val); static int maxLabels(); static void setMaxLabels(int maxLabels); static const QStringList friends(); static void addFriend(const QString& friendId); static void removeFriend(const QString& friendId); static const QString clientAlias(const QString& userId); static void setClientAlias(const QString& userId, const QString& alias = QString()); static bool resetOnNextStart(); static void setResetOnNextStart(bool value); static bool saveWhazzupData(); static void setSaveWhazzupData(const bool value); static int wheelMax(); static void setWheelMax(const int value); static double zoomFactor(); static void setZoomFactor(const double value); static bool useSelectionRectangle(); static void setUseSelctionRectangle(const bool value); static DialogPreferences dialogPreferences(const QString& name); static void setDialogPreferences(const QString& name, const DialogPreferences& dialogPreferences); static bool maximized(); static void saveMaximized(const bool val); static Qt::SortOrder airportDialogAtcSortOrder(); static void setAirportDialogAtcSortOrder(Qt::SortOrder); static QMap<QString, QVariant> airportDialogAtcExpandedByType(); static void setAirportDialogAtcExpandedByType(const QMap<QString, QVariant>&); static QString remoteDataRepository(); private: static QSettings* instance(); static void migrate(QSettings*); }; #endif /*SETTINGS_H_*/
18,373
C++
.h
366
40.909836
106
0.714958
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,682
Airport.h
qutescoop_qutescoop/src/Airport.h
#ifndef AIRPORT_H_ #define AIRPORT_H_ #include "Controller.h" #include "MapObject.h" #include "Metar.h" #include "Pilot.h" #include "src/mustache/contexts/AirportContext.h" class Airport : public MapObject { Q_OBJECT public: const static int symbologyAppRadius_nm = 28; const static int symbologyTwrRadius_nm = 16; const static int symbologyGndRadius_nm = 13; const static int symbologyDelRadius_nm = 10; static const QRegularExpression pdcRegExp; Airport(const QStringList &list, unsigned int debugLineNumber = 0); virtual ~Airport(); virtual bool matches(const QRegExp& regex) const override; virtual QString mapLabel() const override; virtual QString mapLabelHovered() const override; virtual QStringList mapLabelSecondaryLines() const override; virtual QStringList mapLabelSecondaryLinesHovered() const override; virtual QString toolTip() const override; virtual bool hasPrimaryAction() const override; virtual void primaryAction() override; void showDetailsDialog(); QString livestreamString() const; const QString shortLabel() const; const QString prettyName() const; const QString trafficString() const; const QString controllersString() const; const QString atisCodeString() const; const QString frequencyString() const; const QString pdcString(const QString& prepend = "", bool alwaysWithIdentifier = true) const; void resetWhazzupStatus(); QSet<Controller*> allControllers() const; QSet<Controller*> appDeps, twrs, gnds, dels, atiss; QSet<Pilot*> arrivals, departures; void addArrival(Pilot* client); void addDeparture(Pilot* client); uint nMaybeFilteredArrivals, nMaybeFilteredDepartures; uint congestion() const; void addController(Controller* c); const GLuint& appDisplayList(); const GLuint& twrDisplayList(); const GLuint& gndDisplayList(); const GLuint& delDisplayList(); Metar metar; QString id, name, city, countryCode; bool showRoutes = false; bool active; private: void appGl(const QColor &middleColor, const QColor &marginColor, const QColor &borderColor, const GLfloat &borderLineWidth) const; void twrGl(const QColor &middleColor, const QColor &marginColor, const QColor &borderColor, const GLfloat &borderLineWidth) const; GLuint _appDisplayList = 0, _twrDisplayList = 0, _gndDisplayList = 0, _delDisplayList = 0; }; #endif
2,632
C++
.h
58
37.758621
138
0.70172
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,683
FriendsVisitor.h
qutescoop_qutescoop/src/FriendsVisitor.h
#ifndef FRIENDSVISITOR_H_ #define FRIENDSVISITOR_H_ #include "MapObjectVisitor.h" #include "MapObject.h" #include <QStringList> class FriendsVisitor : public MapObjectVisitor { public: FriendsVisitor(); virtual void visit(MapObject* object) override; virtual QList<MapObject*> result() const override; private: QList<MapObject*> m_friends; }; #endif /*FRIENDSVISITOR_H_*/
421
C++
.h
15
23.8
58
0.723192
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,684
JobList.h
qutescoop_qutescoop/src/JobList.h
#ifndef JOBLIST_H #define JOBLIST_H #include <QObject> /** * A list of jobs, connected through SIGNALs and SLOTs. Will emit finished() * when all jobs were executed **/ class JobList : public QObject { Q_OBJECT public: explicit JobList(QObject* parent = 0); class Job { public: Job(QObject* obj, const char* start, const char* finishSignal); QObject* obj; const char* start, * finishSignal; }; void append(Job job); signals: void started(); void finished(); public slots: void start(); private slots: void finish(); void advanceProgress(); private: QList<Job> m_jobs; int m_progress = 0; }; #endif // JOBLIST_H
793
C++
.h
32
18.09375
79
0.581794
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,686
Client.h
qutescoop_qutescoop/src/Client.h
#ifndef CLIENT_H_ #define CLIENT_H_ #include "WhazzupData.h" #include <QJsonDocument> class Client { public: static const QRegularExpression livestreamRegExp; static QString livestreamString(const QString& str); Client(const QJsonObject& json, const WhazzupData* whazzup); virtual bool matches(const QRegExp& regex) const; virtual QString rank() const; virtual QString livestreamString() const; virtual bool isFriend() const; virtual const QString realName() const; virtual const QString nameOrCid() const; virtual const QString aliasOrName() const; virtual const QString aliasOrNameOrCid() const; QString onlineTime() const; virtual QString displayName(bool withLink = false) const; virtual QString detailInformation() const; QString callsign, userId, homeBase, server; QDateTime timeConnected; bool showAliasDialog(QWidget* parent) const; int rating; static bool isValidID(const QString id); bool hasValidID() const; protected: QString m_nameOrCid; }; #endif /*CLIENT_H_*/
1,163
C++
.h
30
31.5
68
0.695807
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,687
Airway.h
qutescoop_qutescoop/src/Airway.h
#ifndef AIRWAY_H_ #define AIRWAY_H_ #include "Waypoint.h" class Airway { public: Airway(const QString& name); virtual ~Airway() {} QList<Waypoint*> waypoints() const; QList<Waypoint*> expand(const QString& startId, const QString& endId) const; Waypoint* closestPointTo(double lat, double lon) const; void addSegment(Waypoint* from, Waypoint* to); QList<Airway*> sort(); QString name; private: int index(const QString& id) const; class Segment { public: Segment(Waypoint* from, Waypoint* to); bool operator==(const Segment& other) const; Waypoint* from; Waypoint* to; }; QList<Segment> _segments; QList<Waypoint*> _waypoints; Airway* createFromSegments(); }; #endif /* AIRWAY_H_ */
886
C++
.h
27
24.222222
84
0.591765
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,688
Net.h
qutescoop_qutescoop/src/Net.h
#ifndef NET_H #define NET_H #include <QtCore> #include <QtNetwork> class Net : public QNetworkAccessManager { Q_OBJECT public: static Net* instance(bool createIfNoInstance = true); Net(); // convenience functions: Net::g() vs. Net::instance()->get() static QNetworkReply* h(QNetworkRequest &request); static QNetworkReply* g(const QUrl &url); static QNetworkReply* g(QNetworkRequest &request); static QNetworkReply* p(QNetworkRequest &request, QIODevice* data); static QNetworkReply* p(QNetworkRequest &request, const QByteArray &data); }; #endif // NET_H
636
C++
.h
18
29.888889
82
0.690554
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,689
GLWidget.h
qutescoop_qutescoop/src/GLWidget.h
#ifndef GLWIDGET_H_ #define GLWIDGET_H_ #include "ClientSelectionWidget.h" #include "Controller.h" #include "MapObject.h" #include "Sector.h" #include "src/helpers.h" #include <qglobal.h> #ifdef Q_OS_WIN #include <windows.h> #endif #ifdef __APPLE__ #include <OpenGL/glu.h> #else #include <GL/glu.h> #endif #include <QPoint> class GLWidget : public QGLWidget { Q_OBJECT public: GLWidget(QGLFormat format, QWidget* parent = 0); ~GLWidget(); DoublePair currentLatLon() const; ClientSelectionWidget* clientSelection; void invalidatePilots(); void invalidateAirports(); void invalidateControllers(); void setStaticSectors(QList<Sector*>); void savePosition(); struct FontRectangle { QRectF rect = QRectF(); MapObject* object = 0; }; public slots: virtual void initializeGL() override; void newWhazzupData(bool isNew); // could be solved more elegantly, but it gets called for // updating the statusbar as well - we do not want a full GL update here sometimes void setMapPosition(double lat, double lon, double newZoom); void scrollBy(int moveByX, int moveByY); void rightClick(const QPoint& pos); void zoomIn(double factor); void zoomTo(double _zoom); void rememberPosition(int nr); void restorePosition(int nr, bool isSilent = false); void configureHoverDebounce(); void configureUpdateTimer(); signals: void mapClicked(int x, int y, QPoint absolutePos); protected: virtual void paintGL() override; virtual void resizeGL(int width, int height) override; QList<MapObject*> objectsAt(int x, int y, double radius = 0) const; void mouseDoubleClickEvent(QMouseEvent* event) override; void mousePressEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override; void mouseMoveEvent(QMouseEvent* event) override; void wheelEvent(QWheelEvent* event) override; void leaveEvent(QEvent* event) override; bool event(QEvent* event) override; private: void resetZoom(); void handleRotation(QMouseEvent* event); bool local2latLon(int x, int y, double &lat, double &lon) const; bool latLon2local(double lat, double lon, int* px = 0, int* py = 0) const; QPair<DoublePair, DoublePair> shownLatLonExtent() const; void drawSelectionRectangle(); void drawCoordinateAxii() const; void drawCoordinateAxiiCurrentMatrix() const; const QPair<double, double> sunZenith(const QDateTime &dt) const; void createPilotsList(); void createAirportsList(); void createControllerLists(); void createStaticLists(); void createStaticSectorLists(); void createHoveredControllersLists(const QSet<Controller*>& controllers); void parseTexture(); void createLights(); QList<Sector*> m_staticSectors; QPoint _lastPos, _mouseDownPos; bool m_isMapMoving, m_isMapZooming, m_isMapRectSelecting, _lightsGenerated; bool m_isPilotsListDirty = true, m_isAirportsListDirty = true, m_isControllerListsDirty = true, m_isStaticSectorListsDirty = true, m_isAirportsMapObjectsDirty = true, m_isControllerMapObjectsDirty = true, m_isPilotMapObjectsDirty = true, m_isUsedWaypointMapObjectsDirty = true; GLUquadricObj* _earthQuad; GLuint _earthTex, _fadeOutTex, _earthList, _coastlinesList, _countriesList, _gridlinesList, _pilotsList, _activeAirportsList, _inactiveAirportsList, _usedWaypointsList, _plannedRouteList, _sectorPolygonsList, _sectorPolygonBorderLinesList, _congestionsList, _staticSectorPolygonsList, _staticSectorPolygonBorderLinesList, _hoveredSectorPolygonsList, _hoveredSectorPolygonBorderLinesList; QSet<Controller*> m_hoveredControllers; double _pilotLabelZoomTreshold, _activeAirportLabelZoomTreshold, _inactiveAirportLabelZoomTreshold, _controllerLabelZoomTreshold, _usedWaypointsLabelZoomThreshold, _xRot, _yRot, _zRot, _zoom, _aspectRatio; QTimer* m_updateTimer; QTimer* m_hoverDebounceTimer; QList< QPair<double, double> > m_friendPositions; QList<MapObject*> m_hoveredObjects, m_newHoveredObjects; QMultiHash<QPair<int, int>, MapObject*> m_inactiveAirportMapObjectsByLatLng; QList<MapObject*> m_activeAirportMapObjects, m_controllerMapObjects, m_pilotMapObjects, m_usedWaypointMapObjects; void renderLabels(); void renderLabels( const QList<MapObject*>& objects, const double zoomTreshold, const QFont& font, const QColor color, const QFont& secondaryFont = QFont(), const QColor secondaryColor = QColor(), const bool isFastBail = false, const unsigned short tryNOtherPositions = 3, const bool isHoverRenderPass = false ); bool shouldDrawLabel(const QRectF &rect); struct RenderLabelsCommand { QList<MapObject*> objects; double zoomTreshold; QFont font; QColor color; QFont secondaryFont; QColor secondaryColor; bool isFastBail; unsigned short tryNOtherPositions; }; QList<RenderLabelsCommand> m_prioritizedLabels; QList<FontRectangle>fontRectanglesPrioritized() const; QSet<FontRectangle> m_fontRectangles; void drawTestTextures(); void drawBillboardScreenSize(GLfloat lat, GLfloat lon, const QSize& size); void drawBillboardWorldSize(GLfloat lat, GLfloat lon, const QSizeF& size); inline void drawBillboard(GLfloat lat, GLfloat lon, GLfloat halfWidth, GLfloat halfHeight, GLfloat alpha = 1.); void orthoMatrix(GLfloat lat, GLfloat lon); private slots: void updateHoverState(); }; inline bool operator==(const GLWidget::FontRectangle &e1, const GLWidget::FontRectangle &e2) { return e1.object == e2.object && e1.rect == e2.rect; } inline uint qHash(const GLWidget::FontRectangle &key, uint seed) { return qHash(key.object, seed); } #endif
6,396
C++
.h
144
36.013889
158
0.684151
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,690
Waypoint.h
qutescoop_qutescoop/src/Waypoint.h
#ifndef WAYPOINT_H_ #define WAYPOINT_H_ #include "MapObject.h" #include <QStringList> class Waypoint : public MapObject { public: Waypoint() {} Waypoint(const QStringList& stringList); Waypoint(const QString& id, const double lat, const double lon); virtual ~Waypoint(); virtual QString mapLabel() const override; virtual QStringList mapLabelSecondaryLinesHovered() const override; virtual QString toolTip() const override; virtual int type(); const QString airwaysString() const; QString id, regionCode; }; #endif /*WAYPOINT_H_*/
627
C++
.h
19
26.947368
75
0.686667
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,691
MetarSearchVisitor.h
qutescoop_qutescoop/src/MetarSearchVisitor.h
#ifndef METARSEARCHVISITOR_H_ #define METARSEARCHVISITOR_H_ #include "SearchVisitor.h" class MetarSearchVisitor : public SearchVisitor { public: MetarSearchVisitor(const QString& search) : SearchVisitor(search) {} virtual void visit(MapObject* object) override; virtual QList<MapObject*> result() const override; QList<Airport*> airports() const; private: QHash<QString, Airport*> _airportMap; }; #endif /*METARSEARCHVISITOR_H_*/
498
C++
.h
15
27.666667
58
0.705637
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,692
Tessellator.h
qutescoop_qutescoop/src/Tessellator.h
#ifndef TESSELLATOR_H_ #define TESSELLATOR_H_ #include <QtCore> #ifdef Q_OS_WIN #include <windows.h> #endif #ifdef __APPLE__ #include <OpenGL/glu.h> #else #include <GL/glu.h> #endif // platform specific stuff. tessellator callback definitions are not the // same on all platforms #ifdef Q_OS_MAC #define CALLBACK_CAST (GLvoid (*)()) #define CALLBACK_DECL GLvoid #endif #ifdef Q_OS_LINUX #define CALLBACK_CAST (void (*)()) #define CALLBACK_DECL GLvoid #endif #ifdef Q_OS_WIN #define CALLBACK_CAST (GLvoid (*) ()) #define CALLBACK_DECL void CALLBACK #endif class Tessellator { public: Tessellator(); ~Tessellator(); void tessellate(const QList<QPair<double, double> >& points); private: GLUtesselator* _tess; QList<GLdouble*> _pointList; static CALLBACK_DECL tessBeginCB(GLenum which); static CALLBACK_DECL tessEndCB(); static CALLBACK_DECL tessVertexCB(const GLvoid* data); static CALLBACK_DECL tessErrorCB(GLenum errorCode); static CALLBACK_DECL tessCombineCB( const GLdouble newVertex[3], const GLdouble* neighborVertex[4], const GLfloat neighborWeight[4], GLdouble** outData ); }; #endif /*TESSELLATOR_H_*/
1,299
C++
.h
45
23.644444
72
0.674437
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,693
SearchVisitor.h
qutescoop_qutescoop/src/SearchVisitor.h
#ifndef SEARCHVISITOR_H_ #define SEARCHVISITOR_H_ #include "Airline.h" #include "Controller.h" #include "MapObject.h" #include "MapObjectVisitor.h" #include "Pilot.h" #include <QHash> class SearchVisitor : public MapObjectVisitor { public: SearchVisitor(const QString& search); virtual void visit(MapObject* object) override; virtual QList<MapObject*> result() const override; QHash<QString, Airline*> airlines; protected: QList<MapObject*> _resultFromVisitors; QRegExp _regex; QHash<QString, Pilot*> _pilots; QHash<QString, Controller*> _controllers, _observers; QHash<QString, MapObject*> _others; }; #endif /*SEARCHVISITOR_H_*/
719
C++
.h
23
26.434783
61
0.702312
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,694
helpers.h
qutescoop_qutescoop/src/helpers.h
#ifndef HELPERS_H_ #define HELPERS_H_ #include <math.h> #include <QList> #include <QPair> #include <QColor> #include <QPalette> // typedefs: needed to get the QPair template running inside foreach's typedef QPair<double, double> DoublePair; class Helpers { public: static QStringList linesFilteredTrimmed(const QString &str) { QStringList ret; foreach (const auto line, str.split("\n")) { const auto lineTrimmed = line.trimmed(); if (!lineTrimmed.isEmpty()) { ret << lineTrimmed; } } return ret; } static QColor highLightColor(const QColor& c) { QColor _c; if (c.lightnessF() * c.alphaF() > .6) { _c = c.darker(110); } else { _c = c.lighter(110); } _c.setAlpha(fmin(255, _c.alpha() * 1.3)); return _c; } static QColor shadowColorForBg(const QColor& c) { QPalette palette(c); return c.lightnessF() > .5? palette.dark().color(): palette.light().color(); } static QColor mixColor (const QColor& c1, const QColor& c2, float fraction) { return QColor( Helpers::lerp(c1.red(), c2.red(), fraction), Helpers::lerp(c1.green(), c2.green(), fraction), Helpers::lerp(c1.blue(), c2.blue(), fraction), Helpers::lerp(c1.alpha(), c2.alpha(), fraction) ); }; // modulo, but always positive, not like fmod() static float inline modPositive(float x, float y) { if (qFuzzyIsNull(y)) { return x; } return x - y * floor(x / y); } static float inline lerp(float v0, float v1, float t) { return v0 + t * (v1 - v0); } static float fraction(float min, float max, float v) { if (max == min) { return 1.; } return (v - min) / (max - min); } /* At 180 the longitude wraps around to -180 * Since this can cause problems in the computation this adjusts point B relative to point A * such that the difference in longitude is less than 180 * That is: Instead of going from a longitude of 179 in point A to a longitude of -179 in point B by going * westwards * we set the longitude of point B to 181 to indicate that we're going east */ static void adjustPoint(const DoublePair &a, DoublePair &b) { const double diff = a.second - b.second; if (std::abs(diff) > 180) { b.second += ((diff > 0) - (diff < 0)) * 360; } } /* * @return (-360., -360.) on error */ static DoublePair polygonCenter(const QList<DoublePair> points) { // https://en.wikipedia.org/wiki/Centroid#Of_a_polygon if (points.isEmpty()) { return DoublePair(-360., -360.); } double A = 0; DoublePair runningTotal; runningTotal.first = 0; runningTotal.second = 0; DoublePair previous = points[0]; const int count = points.size(); for (int i = 0; i < count; ++i) { DoublePair current = points[i]; DoublePair next = points[(i + 1) % count]; if (i > 0) { adjustPoint(previous, current); } adjustPoint(current, next); previous = current; A += (current.first * next.second - next.first * current.second); double multiplyBy = current.first * next.second - (next.first * current.second); runningTotal.first += (current.first + next.first) * multiplyBy; runningTotal.second += (current.second + next.second) * multiplyBy; } A /= 2; runningTotal.first /= 6 * A; runningTotal.second /= 6 * A; runningTotal.second = std::fmod(runningTotal.second + 180, 360) - 180; return runningTotal; } }; /* mathematical constants */ const double Pi180 = M_PI / 180.; /* 3D-calculations */ #define SX(lat, lon) (GLfloat) qCos((lat) * Pi180) * (GLfloat) qSin((lon) * Pi180) #define SY(lat, lon) (GLfloat) - qCos((lat) * Pi180) * (GLfloat) qCos((lon) * Pi180) #define SZ(lat, lon) (GLfloat) - qSin((lat) * Pi180) #define VERTEX(lat, lon) glVertex3f(SX(lat, lon), SY(lat, lon), SZ(lat, lon)) // higher VERTEX: 30km AGL (used for polygons to prevent intersecting with the globe) #define SXhigh(lat, lon) SX(lat, lon) * 1.005 #define SYhigh(lat, lon) SY(lat, lon) * 1.005 #define SZhigh(lat, lon) SZ(lat, lon) * 1.005 #define VERTEXhigh(lat, lon) glVertex3f(SXhigh(lat, lon), SYhigh(lat, lon), SZhigh(lat, lon)) /* units */ #define Nm2Deg(miles) (miles / 60.0) #define mToFt(m) (m * 3.28084) #endif /*HELPERS_H_*/
5,151
C++
.h
126
30.039683
114
0.538523
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,695
SectorReader.h
qutescoop_qutescoop/src/SectorReader.h
#ifndef SECTORREADER_H_ #define SECTORREADER_H_ #include "Sector.h" class SectorReader { public: SectorReader(); ~SectorReader(); void loadSectors(QMultiMap<QString, Sector*>& sectors); private: void loadSectorlist(QMultiMap<QString, Sector*>& sectors); void loadSectordisplay(QMultiMap<QString, Sector*>& sectors); }; #endif /*SECTORREADER_H_*/
398
C++
.h
13
25.615385
69
0.695538
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,696
Sector.h
qutescoop_qutescoop/src/Sector.h
#ifndef SECTOR_H_ #define SECTOR_H_ #include <QtCore> #include <QtOpenGL> class Sector { public: Sector(const QStringList &fields, const int debugControllerLineNumber, const int debugSectorLineNumber = -1); ~Sector(); bool isNull() const; bool containsPoint(const QPointF &pt) const; const QList<QPolygonF> &nonWrappedPolygons() const; const QList<QPair<double, double> > &points() const; void setPoints(const QList<QPair<double, double> >&); int debugControllerLineNumber(); int debugSectorLineNumber(); void setDebugSectorLineNumber(int newDebugSectorLineNumber); GLuint glPolygon(); GLuint glBorderLine(); GLuint glPolygonHighlighted(); GLuint glBorderLineHighlighted(); QPair<double, double> getCenter() const; const QStringList& controllerSuffixes() const; QString icao, name, id; private: int _debugControllerLineNumber = -1, _debugSectorLineNumber = -1; QStringList m_controllerSuffixes = QStringList(); QList<QPolygonF> m_nonWrappedPolygons; QList<QPair<double, double> > m_points; GLuint _polygon = 0, _borderline = 0, _polygonHighlighted = 0, _borderlineHighlighted = 0; }; #endif /*SECTOR_H_*/
1,302
C++
.h
31
34.645161
117
0.683625
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,697
MapObject.h
qutescoop_qutescoop/src/MapObject.h
#ifndef MAPOBJECT_H_ #define MAPOBJECT_H_ #include <QtCore> class MapObject : public QObject { Q_OBJECT public: MapObject(); MapObject(QString label, QString toolTip); MapObject(const MapObject& obj); MapObject& operator=(const MapObject& obj); virtual ~MapObject(); // @todo: move into TextSearchable interface virtual bool matches(const QRegExp& regex) const; virtual QString mapLabel() const; virtual QString mapLabelHovered() const; virtual QStringList mapLabelSecondaryLines() const; virtual QStringList mapLabelSecondaryLinesHovered() const; virtual QString toolTip() const; virtual bool hasPrimaryAction() const; virtual void primaryAction(); double lat, lon; bool drawLabel; protected: // @todo just meant for non-derived objects that we currently use for airlines in the search for example QString m_label; QString m_toolTip; }; #endif /*MAPOBJECT_H_*/
1,036
C++
.h
29
28.724138
112
0.679321
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,698
MapScreen.h
qutescoop_qutescoop/src/MapScreen.h
#ifndef MAPSCREEN_H #define MAPSCREEN_H #include "GLWidget.h" class MapScreen : public QWidget { Q_OBJECT public: MapScreen(QWidget* parent = 0); GLWidget* glWidget; static MapScreen* instance(bool createIfNoInstance = true); protected: void resizeEvent(QResizeEvent* event); }; #endif // MAPSCREEN_H
353
C++
.h
14
20.5
67
0.692537
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,699
Metar.h
qutescoop_qutescoop/src/Metar.h
#ifndef METAR_H_ #define METAR_H_ #include <QDateTime> #include <QString> class Metar { public: Metar(const QString& encodedString = QString(), const QString& airportLabel = QString()); bool isNull() const; bool isValid() const; bool doesNotExist() const; bool needsRefresh() const; QString encoded, airportLabel; QDateTime downloaded; QString humanHtml() const; private: QString decodeDate(QStringList& tokens) const; QString decodeWind(QStringList& tokens) const; QString decodeVisibility(QStringList& tokens) const; QString decodeSigWX(QStringList& tokens) const; QString decodeClouds(QStringList& tokens) const; QString decodeTemp(QStringList& tokens) const; QString decodeQNH(QStringList& tokens) const; QString decodePrediction(QStringList& tokens) const; }; #endif /*METAR_H_*/
927
C++
.h
25
30.4
97
0.69308
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,700
FileReader.h
qutescoop_qutescoop/src/FileReader.h
#ifndef FILEREADER_H_ #define FILEREADER_H_ #include <QtCore> class FileReader { public: FileReader(const QString& filename); virtual ~FileReader(); bool atEnd() const; QString nextLine() const; private: QFile* _file; QTextStream* _stream; }; #endif /*FILEREADER_H_*/
328
C++
.h
14
18.142857
44
0.63871
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,701
MapObjectVisitor.h
qutescoop_qutescoop/src/MapObjectVisitor.h
#ifndef MAPOBJECTVISITOR_H_ #define MAPOBJECTVISITOR_H_ #include "MapObject.h" #include <QList> class MapObjectVisitor { public: virtual ~MapObjectVisitor(); virtual void visit(MapObject* object) = 0; virtual QList<MapObject*> result() const = 0; }; #endif /*MAPOBJECTVISITOR_H_*/
314
C++
.h
11
24.545455
53
0.711409
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,702
Airline.h
qutescoop_qutescoop/src/Airline.h
#ifndef AIRLINE_H_ #define AIRLINE_H_ #include <QtCore> class Airline { public: Airline(const QString& code, const QString& name, const QString& callsign, const QString& country) : code(code), name(name), callsign(callsign), country(country) {} QString label() const { return QString("%1 \"%2\"").arg(code, callsign); } QString toolTip() const { return QString("%1 \"%2\", %3, %4").arg(code, callsign, name, country); } virtual ~Airline() {} QString code, name, callsign, country; }; #endif /* AIRLINE_H_ */
653
C++
.h
20
24.4
106
0.557508
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,703
PilotDetails.h
qutescoop_qutescoop/src/dialogs/PilotDetails.h
#ifndef PILOTDETAILS_H_ #define PILOTDETAILS_H_ #include "ui_PilotDetails.h" // file generated by UIC from PilotDetails.ui #include "ClientDetails.h" #include "../Pilot.h" class PilotDetails : public ClientDetails, private Ui::PilotDetails { Q_OBJECT public: static PilotDetails* instance(bool createIfNoInstance = true, QWidget* parent = 0); void destroyInstance(); void refresh(Pilot* pilot = 0); protected: void closeEvent(QCloseEvent* event); private slots: void on_cbPlotRoute_clicked(bool checked); void on_buttonAlt_clicked(); void on_buttonDest_clicked(); void on_buttonFrom_clicked(); void on_buttonAddFriend_clicked(); // @todo move to ClientDetails void on_pbAlias_clicked(); private: PilotDetails(QWidget* parent); Pilot* _pilot; constexpr static char m_preferencesName[] = "pilotDetails"; }; #endif /*PILOTDETAILS_H_*/
975
C++
.h
28
28.714286
91
0.679787
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,704
PlanFlightDialog.h
qutescoop_qutescoop/src/dialogs/PlanFlightDialog.h
#ifndef PLANFLIGHTDIALOG_H_ #define PLANFLIGHTDIALOG_H_ #include "ui_PlanFlightDialog.h" #include "../models/PlanFlightRoutesModel.h" #include <QtNetwork> class PlanFlightDialog : public QDialog, public Ui::PlanFlightDialog { Q_OBJECT public: static PlanFlightDialog* instance(bool createIfNoInstance = true, QWidget* parent = 0); void plotPlannedRoute() const; Route* selectedRoute; signals: void fpDownloaded(); protected: void closeEvent(QCloseEvent* event); private slots: void on_bDestDetails_clicked(); void on_bDepDetails_clicked(); void on_pbVatsimPrefile_clicked(); void on_pbCopyToClipboard_clicked(); void on_cbPlot_toggled(bool checked); void on_edDest_textChanged(QString str); void on_edDep_textChanged(QString str); void on_buttonRequest_clicked(); void vrouteDownloaded(); void routeSelected(const QModelIndex& index); private: PlanFlightDialog(QWidget* parent); void requestGenerated(); void requestVroute(); QNetworkReply* _replyVroute; QList<Route*> _routes; PlanFlightRoutesModel _routesModel; QSortFilterProxyModel* _routesSortModel; constexpr static char m_preferencesName[] = "planFlightDialog"; }; #endif // PLANFLIGHTDIALOG_H
1,377
C++
.h
38
29.289474
95
0.695094
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,705
PreferencesDialog.h
qutescoop_qutescoop/src/dialogs/PreferencesDialog.h
#ifndef PREFERENCESDIALOG_H_ #define PREFERENCESDIALOG_H_ #include "ui_PreferencesDialog.h" class PreferencesDialog : public QDialog, public Ui::PreferencesDialog { Q_OBJECT public: static PreferencesDialog* instance(bool createIfNoInstance = true, QWidget* parent = 0); protected: void closeEvent(QCloseEvent* event); private slots: void loadSettings(); void lazyloadTextureIcons(); void on_cbResetConfiguration_stateChanged(int state); // import/export to .ini void on_pbExportToFile_clicked(); void on_pbImportFromFile_clicked(); // UI slots: void on_glTextures_toggled(bool checked); void on_glTextureEarth_currentIndexChanged(QString); void on_glStippleLines_toggled(bool checked); void on_glEarthShininess_valueChanged(int value); void on_glLights_valueChanged(int value); void on_sbEarthGridEach_valueChanged(int); void on_cbBlend_toggled(bool checked); void on_glLightsSpread_valueChanged(int value); void on_pbSpecularLightColor_clicked(); void on_pbSunLightColor_clicked(); void on_cbLighting_toggled(bool checked); void on_pbReinitOpenGl_clicked(); void on_pbStylesheetUpdate_clicked(); void on_pbStylesheetExample2_clicked(); void on_pbStylesheetExample1_clicked(); void on_spinBoxDownloadInterval_valueChanged(int value); void on_cbDownloadPeriodically_stateChanged(int state); void on_cbDownloadOnStartup_stateChanged(int state); void on_cbNetwork_currentIndexChanged(int index); void on_editUserDefinedLocation_editingFinished(); void on_gbDownloadBookings_toggled(bool checked); void on_editBookingsLocation_editingFinished(); void on_sbBookingsInterval_valueChanged(int value); void on_cbBookingsPeriodically_toggled(bool checked); void on_cbSaveWhazzupData_stateChanged(int state); void on_groupBoxProxy_toggled(bool); void on_editProxyServer_editingFinished(); void on_editProxyPort_editingFinished(); void on_editProxyUser_editingFinished(); void on_editProxyPassword_editingFinished(); void on_cbFilterTraffic_stateChanged(int state); void on_spFilterDistance_valueChanged(int value); void on_spFilterArriving_valueChanged(double value); void on_btnCongestionShowRing_toggled(bool checked); void on_btnCongestionShowGlow_toggled(bool checked); void on_sbCongestionMovementsMin_valueChanged(int); void on_sbCongestionRadiusMin_valueChanged(int arg1); void on_sbCongestionBorderLineStrengthMin_valueChanged(double value); void on_pbCongestionColorMin_clicked(); void on_sbCongestionMovementsMax_valueChanged(int); void on_sbCongestionRadiusMax_valueChanged(int arg1); void on_sbCongestionBorderLineStrengthMax_valueChanged(double value); void on_pbCongestionColorMax_clicked(); void on_cbShowCongestion_clicked(bool checked); void on_cbLineSmoothing_stateChanged(int state); void on_cbDotSmoothing_stateChanged(int state); void on_sbMaxTextLabels_valueChanged(int value); void on_editNavdir_editingFinished(); void on_browseNavdirButton_clicked(); void on_cbUseNavDatabase_stateChanged(int state); void on_pbBackgroundColor_clicked(); void on_pbGlobeColor_clicked(); void on_pbGridLineColor_clicked(); void on_sbGridLineStrength_valueChanged(double value); void on_pbCoastLineColor_clicked(); void on_sbCoastLineStrength_valueChanged(double value); void on_pbCountryLineColor_clicked(); void on_sbCountryLineStrength_valueChanged(double value); void on_pbFirBorderLineColor_clicked(); void on_sbFirBorderLineStrength_valueChanged(double value); void on_pbFirFontColor_clicked(); void on_pbFirFont_clicked(); void on_pbFirFillColor_clicked(); void on_pbFirHighlightedBorderLineColor_clicked(); void on_sbFirHighlightedBorderLineStrength_valueChanged(double value); void on_pbFirHighlightedFillColor_clicked(); void on_pbAirportDotColor_clicked(); void on_sbAirportDotSize_valueChanged(double value); void on_pbAirportFontColor_clicked(); void on_pbAirportFont_clicked(); void on_pbAppBorderLineColor_clicked(); void on_sbAppBorderLineStrength_valueChanged(double value); void on_pbAppColorCenter_clicked(); void on_pbAppColorMargin_clicked(); void on_pbTwrColorCenter_clicked(); void on_pbTwrColorMargin_clicked(); void on_pbGndBorderLineColor_clicked(); void on_sbGndBorderLineStrength_valueChanged(double value); void on_pbGndFillColor_clicked(); void on_sbInactAirportDotSize_valueChanged(double value); void on_pbInactAirportDotColor_clicked(); void on_pbInactAirportFont_clicked(); void on_pbInactAirportFontColor_clicked(); void on_applyAirports_clicked(); void on_applyPilots_clicked(); void on_pbPilotFontColor_clicked(); void on_pbPilotFont_clicked(); void on_pbPilotDotColor_clicked(); void on_sbPilotDotSize_valueChanged(double value); void on_spinBoxTimeline_valueChanged(int value); void on_pbTimeLineColor_clicked(); void on_sbTimeLineStrength_valueChanged(double value); void on_pbDepLineColor_clicked(); void on_pbDestLineColor_clicked(); void on_sbDepLineStrength_valueChanged(double value); void on_sbDestLineStrength_valueChanged(double value); void on_cbDepLineDashed_toggled(bool checked); void on_cbDestLineDashed_toggled(bool checked); void on_waypointsFont_clicked(); void on_waypointsFontColor_clicked(); void on_waypointsDotColor_clicked(); void on_waypointsDotSize_valueChanged(double); void on_cbCheckForUpdates_stateChanged(int state); void on_pbWheelCalibrate_clicked(); void on_sbZoomFactor_valueChanged(double); void on_cb_Animation_stateChanged(int state); void on_sb_highlightFriendsLineWidth_valueChanged(double value); void on_pb_highlightFriendsColor_clicked(); void on_useSelectionRectangle_toggled(bool checked); void on_cbRememberMapPositionOnClose_toggled(bool checked); void on_pbPilotFontSecondaryColor_clicked(); void on_pbPilotFontSecondary_clicked(); void on_plainTextEditPilotSecondaryContent_textChanged(); void on_plainTextEditPilotSecondaryContentHovered_textChanged(); void on_lineEditPilotPrimaryContent_editingFinished(); void on_lineEditPilotPrimaryContentHovered_editingFinished(); void on_applyAirports_2_clicked(); void on_lineEditAirportPrimaryContent_editingFinished(); void on_lineEditAirportPrimaryContentHovered_editingFinished(); void on_pbAirportFontSecondaryColor_clicked(); void on_pbAirportFontSecondary_clicked(); void on_plainTextEditAirportSecondaryContentHovered_textChanged(); void on_plainTextEditAirportSecondaryContent_textChanged(); void on_pbLabelHoveredBgColor_clicked(); void on_applyLabelHover_clicked(); void on_pbLabelHoveredBgDarkColor_clicked(); void on_pbFirApply_clicked(); void on_lineEditFirPrimaryContent_editingFinished(); void on_lineEditFirPrimaryContentHovered_editingFinished(); void on_plainTextEditFirSecondaryContent_textChanged(); void on_plainTextEditFirSecondaryContentHovered_textChanged(); void on_pbFirFontSecondaryColor_clicked(); void on_pbFirFontSecondary_clicked(); void on_pbDelBorderLineColor_clicked(); void on_pbDelFillColor_clicked(); void on_sbDelBorderLineStrength_valueChanged(double arg1); void on_pbTwrBorderLineColor_clicked(); void on_sbTwrBorderLineStrength_valueChanged(double arg1); void on_pbDestImmediateLineColor_clicked(); void on_sbDestImmediateLineStrength_valueChanged(double arg1); void on_sbDestImmediateDuration_valueChanged(int arg1); void on_applyPilotsRoute_clicked(); void on_cbLabelAlwaysBackdrop_toggled(bool checked); void on_sbHoverDebounce_valueChanged(int arg1); void on_pbApplyHover_clicked(); private: PreferencesDialog(QWidget* parent); bool _settingsLoaded; constexpr static char m_preferencesName[] = "preferences"; }; #endif /*PREFERENCESDIALOG_H_*/
8,703
C++
.h
169
42.881657
96
0.726398
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,706
Window.h
qutescoop_qutescoop/src/dialogs/Window.h
#ifndef WINDOW_H_ #define WINDOW_H_ #include "ui_Window.h" #include "../MapScreen.h" #include "../models/SearchResultModel.h" #include "../models/MetarModel.h" class Window : public QMainWindow, public Ui::Window { Q_OBJECT public: static Window* instance(bool createIfNoInstance = true); void setEnableBookedAtc(bool enable); MapScreen* mapScreen; public slots: void refreshFriends(); void processWhazzup(bool isNew = true); void restore(); signals: void restored(); private slots: void actionShowRoutes_triggered(bool checked, bool showStatus = true); void actionShowImmediateRoutes_triggered(bool checked, bool showStatus = true); void actionHideLabels_triggered(bool checked, bool showStatus = true); void showInactiveAirports(bool value); void on_actionShowWaypoints_triggered(bool checked); void on_actionHighlight_Friends_triggered(bool checked); void on_pb_highlightFriends_toggled(bool checked); void on_actionZoomReset_triggered(); void on_tbZoomOut_clicked(); void on_tbZoomIn_clicked(); void on_tbZoomOut_customContextMenuRequested(QPoint pos); void on_tbZoomIn_customContextMenuRequested(QPoint pos); void on_actionMoveDown_triggered(); void on_actionMoveUp_triggered(); void on_actionMoveRight_triggered(); void on_actionMoveLeft_triggered(); void on_actionRememberMapPosition9_triggered(); void on_actionRememberMapPosition1_triggered(); void on_actionRememberMapPosition2_triggered(); void on_actionRememberMapPosition3_triggered(); void on_actionRememberMapPosition4_triggered(); void on_actionRememberMapPosition5_triggered(); void on_actionRememberMapPosition6_triggered(); void on_actionRememberMapPosition7_triggered(); void on_actionRecallMapPosition9_triggered(); void on_actionRecallMapPosition1_triggered(); void on_actionRecallMapPosition2_triggered(); void on_actionRecallMapPosition3_triggered(); void on_actionRecallMapPosition4_triggered(); void on_actionRecallMapPosition5_triggered(); void on_actionRecallMapPosition6_triggered(); void on_actionRecallMapPosition7_triggered(); void on_actionHideAllWindows_triggered(); void on_actionPredict_toggled(bool); void on_tbDisablePredict_clicked(); void on_tbRunPredict_toggled(bool checked); void on_cbUseDownloaded_toggled(bool checked); void on_cbOnlyUseDownloaded_toggled(bool checked); void dateTimePredict_dateTimeChanged(QDateTime date); void performWarp(); void runPredict(); void about(); void toggleFullscreen(); void openPreferences(); void openPlanFlight(); void openBookedAtc(); void openListClients(); void openStaticSectorsDialog(); void on_searchEdit_textChanged(const QString& text); void on_metarEdit_textChanged(const QString& text); void on_btnRefreshMetar_clicked(); void performSearch(); void updateMetars(); void metarClicked(const QModelIndex& index); void metarDockMoved(Qt::DockWidgetArea area); void searchDockMoved(Qt::DockWidgetArea area); void friendsDockMoved(Qt::DockWidgetArea area); void friendClicked(const QModelIndex& index); void downloadWatchdogTriggered(); protected: virtual void closeEvent(QCloseEvent* event) override; private: // singleton Window(QWidget* parent = 0); ~Window(); void updateTitlebarAfterMove(Qt::DockWidgetArea, QDockWidget* dock); SearchResultModel _modelSearchResult, _modelFriends; QTimer _timerSearch, _timerMetar, _timerEditPredict, _timerRunPredict, _timerWatchdog; QSortFilterProxyModel* _sortmodelMetar, * _sortmodelFriends; MetarModel _metarModel; QDateTime _dateTimePredict_old; QLabel* _lblStatus; QProgressBar* _progressBar; }; #endif /*WINDOW_H_*/
4,158
C++
.h
95
35.810526
94
0.701824
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,707
ControllerDetails.h
qutescoop_qutescoop/src/dialogs/ControllerDetails.h
#ifndef CONTROLLERDETAILS_H_ #define CONTROLLERDETAILS_H_ #include "ui_ControllerDetails.h" #include "ClientDetails.h" #include "../Controller.h" class ControllerDetails : public ClientDetails, private Ui::ControllerDetails { Q_OBJECT public: static ControllerDetails* instance(bool createIfNoInstance = true, QWidget* parent = 0); void destroyInstance(); void refresh(Controller* = 0); protected: void closeEvent(QCloseEvent* event); private slots: void on_buttonAddFriend_clicked(); // @todo move to ClientDetails void on_pbAlias_clicked(); private: ControllerDetails(QWidget* parent); Controller* _controller; constexpr static char m_preferencesName[] = "controllerDetails"; }; #endif /*CONTROLLERDETAILS_H_*/
824
C++
.h
24
28.708333
96
0.706179
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,708
ListClientsDialog.h
qutescoop_qutescoop/src/dialogs/ListClientsDialog.h
#ifndef LISTCLIENTSDIALOG_H_ #define LISTCLIENTSDIALOG_H_ #include "ui_ListClientsDialog.h" #include "../models/ListClientsDialogModel.h" class ListClientsDialog : public QDialog, private Ui::ListClientsDialog { Q_OBJECT public: static ListClientsDialog* instance(bool createIfNoInstance = true, QWidget* parent = 0); void destroyInstance(); public slots: void refresh(); void performSearch(); void pingReceived(QString, int); protected: void closeEvent(QCloseEvent* event); void showEvent(QShowEvent* event); private slots: void on_pbPingServers_clicked(); void modelSelected(const QModelIndex& index); void on_editFilter_textChanged(QString str); private: ListClientsDialog(QWidget* parent); ListClientsDialogModel* _clientsModel; QSortFilterProxyModel* _clientsProxyModel; QColor mapPingToColor(int ms); QStack <QString> _pingStack; void pingNextFromStack(); QTimer _editFilterTimer; constexpr static char m_preferencesName[] = "listClientsDialog"; }; #endif // LISTCLIENTSDIALOG_H
1,168
C++
.h
32
29.78125
96
0.704889
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,709
AirportDetails.h
qutescoop_qutescoop/src/dialogs/AirportDetails.h
#ifndef AIRPORTDETAILS_H_ #define AIRPORTDETAILS_H_ #include "ui_AirportDetails.h" #include "ClientDetails.h" #include "../Airport.h" #include "../models/MetarModel.h" #include "../models/AirportDetailsAtcModel.h" #include "../models/AirportDetailsArrivalsModel.h" #include "../models/AirportDetailsDeparturesModel.h" class AirportDetails : public ClientDetails, private Ui::AirportDetails { Q_OBJECT public: static AirportDetails* instance(bool createIfNoInstance = true, QWidget* parent = 0); void destroyInstance(); void refresh(Airport* _airport = 0); protected: void closeEvent(QCloseEvent* event); private slots: void onGotMetar(const QString &airportLabel, const QString &encoded, const QString &humanHtml); void refreshMetar(); void togglePlotRoutes(bool checked); void toggleShowOtherAtc(bool checked); void atcSelected(const QModelIndex &index); void arrivalSelected(const QModelIndex &index); void departureSelected(const QModelIndex &index); private: AirportDetails(QWidget* parent); AirportDetailsAtcModel* _atcModel; AirportDetailsArrivalsModel _arrivalsModel; AirportDetailsDeparturesModel _departuresModel; Airport* _airport; QSortFilterProxyModel* _atcSortModel, * _arrivalsSortModel, * _departuresSortModel; QSet<Controller*> checkSectors() const; MetarModel* _metarModel; constexpr static char m_preferencesName[] = "airportDetails"; }; #endif /*AIRPORTDETAILS_H_*/
1,579
C++
.h
38
35.447368
103
0.725669
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,710
BookedAtcDialog.h
qutescoop_qutescoop/src/dialogs/BookedAtcDialog.h
#ifndef BOOKEDATCDIALOG_H_ #define BOOKEDATCDIALOG_H_ #include "ui_BookedAtcDialog.h" #include "../models/BookedAtcDialogModel.h" #include "../models/filters/BookedAtcSortFilter.h" class BookedAtcDialog : public QDialog, private Ui::BookedAtcDialog { Q_OBJECT public: static BookedAtcDialog* instance(bool createIfNoInstance = true, QWidget* parent = 0); void destroyInstance(); void refresh(); void setDateTime(const QDateTime &dateTime); signals: void needBookings(); protected: void closeEvent(QCloseEvent* event); private slots: void on_dateTimeFilter_dateTimeChanged(QDateTime date); void performSearch(); void on_tbPredict_clicked(); void on_spinHours_valueChanged(int val); void on_editFilter_textChanged(QString str); private: BookedAtcDialog(QWidget* parent); BookedAtcDialogModel* _bookedAtcModel; BookedAtcSortFilter* _bookedAtcSortModel; QDateTime _dateTimeFilter_old; QTimer _editFilterTimer; constexpr static char m_preferencesName[] = "bookAtcDialog"; }; #endif // BOOKEDATCDIALOG_H
1,173
C++
.h
32
30.1875
94
0.709735
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,711
ClientDetails.h
qutescoop_qutescoop/src/dialogs/ClientDetails.h
#ifndef CLIENTDETAILS_H_ #define CLIENTDETAILS_H_ #include "../MapObject.h" #include <QDialog> class Client; class MapObject; class ClientDetails : public QDialog { Q_OBJECT public slots: void showOnMap() const; void friendClicked() const; protected: ClientDetails(QWidget*); void setMapObject(MapObject*); protected: double _lat, _lon; QString userId, callsign; }; #endif /*CLIENTDETAILS_H_*/
470
C++
.h
20
18.7
38
0.678733
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,712
StaticSectorsDialog.h
qutescoop_qutescoop/src/dialogs/StaticSectorsDialog.h
#ifndef STATICSECTORSDIALOG_H #define STATICSECTORSDIALOG_H #include "ui_StaticSectorsDialog.h" class StaticSectorsDialog : public QDialog, public Ui::StaticSectorsDialog { Q_OBJECT public: static StaticSectorsDialog* instance(bool createIfNoInstance = true, QWidget* parent = 0); protected: void closeEvent(QCloseEvent* event); private slots: void btnSelectAllTriggered(); void btnSelectNoneTriggered(); void itemChanged(); void itemDoubleClicked(QListWidgetItem* item); private: StaticSectorsDialog(QWidget* parent = 0); void loadSectorList(); constexpr const static char m_preferencesName[] = "StaticSectorsDialog"; }; #endif
730
C++
.h
21
28.952381
98
0.724432
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,713
ListClientsDialogModel.h
qutescoop_qutescoop/src/models/ListClientsDialogModel.h
#ifndef LISTCLIENTSDIALOGMODEL_H_ #define LISTCLIENTSDIALOGMODEL_H_ #include "../Client.h" class ListClientsDialogModel : public QAbstractTableModel { Q_OBJECT public: ListClientsDialogModel(QObject* parent = 0) : QAbstractTableModel(parent), _clients(QList<Client*>()) {} virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override; virtual QVariant data(const QModelIndex &index, int role) const override; virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; public slots: void setClients(const QList<Client*>& clients); void modelSelected(const QModelIndex& index); private: QList<Client*> _clients; }; #endif /*LISTCLIENTSDIALOGMODEL_H_*/
956
C++
.h
24
32.666667
90
0.690476
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,714
SearchResultModel.h
qutescoop_qutescoop/src/models/SearchResultModel.h
#ifndef SEARCHRESULTMODEL_H_ #define SEARCHRESULTMODEL_H_ #include "../MapObject.h" class SearchResultModel : public QAbstractListModel { Q_OBJECT public: SearchResultModel(QObject* parent = 0); virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override; virtual QVariant data(const QModelIndex &index, int role) const override; virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; bool m_isSearching = false; public slots: void setSearchResults(const QList<MapObject*> searchResult); void modelClicked(const QModelIndex& index); private: QList<MapObject*> _content; }; #endif /*SEARCHRESULTMODEL_H_*/
912
C++
.h
24
31
90
0.692045
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,718
AirportDetailsAtcModel.h
qutescoop_qutescoop/src/models/AirportDetailsAtcModel.h
#ifndef AIRPORTDETAILSATCMODEL_H_ #define AIRPORTDETAILSATCMODEL_H_ #include "../Controller.h" #include "items/AirportDetailsAtcModelItem.h" class AirportDetailsAtcModel : public QAbstractItemModel { Q_OBJECT public: static const int nColumns = 8; explicit AirportDetailsAtcModel(QObject* parent = 0); ~AirportDetailsAtcModel(); QVariant data(const QModelIndex &index, int role) const override; Qt::ItemFlags flags(const QModelIndex &index) const override; QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override; QModelIndex parent(const QModelIndex &index) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; void setClients(QList<Controller*> controllers); void modelSelected(const QModelIndex& index) const; void writeExpandedState(const QModelIndex& index, bool isExpanded); bool isExpanded(AirportDetailsAtcModelItem*) const; QMap<QString, QVariant> m_atcExpandedByType; private: const QStringList typesSorted { "FSS", "CTR", "DEP", "APP", "TWR", "GND", "DEL", "ATIS", "OBS" }; AirportDetailsAtcModelItem* rootItem; }; #endif /*CLIENTLISTMODEL_H_*/
1,567
C++
.h
36
35.583333
105
0.683761
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,719
MetarModel.h
qutescoop_qutescoop/src/models/MetarModel.h
#ifndef METARMODEL_H_ #define METARMODEL_H_ #include "../Airport.h" #include <QtNetwork> class MetarModel : public QAbstractListModel { Q_OBJECT public: MetarModel(QObject* parent = 0); virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override; virtual QVariant data(const QModelIndex &index, int role) const override; virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override; signals: void gotMetar(const QString &icao, const QString &encoded, const QString &decoded); public slots: void setAirports(const QList<Airport*>& airports); void modelClicked(const QModelIndex& index); void refresh(); private slots: void metarReplyFinished(); void metarReplyRedirected(const QUrl&); void gotMetarFor(Airport* airport); private: QHash<QUrl, Airport*> _downloadQueue; QNetworkReply* _metarReply; void downloadNextFromQueue(); void downloadMetarFor(Airport* airport); QList<Airport*> _airportList; QList<Airport*> _metarList; }; #endif /*METARMODEL_H_*/
1,337
C++
.h
36
29.777778
91
0.675466
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,721
BookedAtcSortFilter.h
qutescoop_qutescoop/src/models/filters/BookedAtcSortFilter.h
#ifndef BOOKEDATCSORTFILTER_H_ #define BOOKEDATCSORTFILTER_H_ #include <QtCore> class BookedAtcSortFilter : public QSortFilterProxyModel { public: BookedAtcSortFilter(QObject* parent = 0) : QSortFilterProxyModel(parent) {} void setDateTimeRange(QDateTime& dtfrom, QDateTime& dtto); protected: bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const; bool lessThan(const QModelIndex &left, const QModelIndex &right) const; private: QDateTime _from, _to; }; #endif // BOOKEDATCSORTFILTER_H
583
C++
.h
16
30.875
86
0.727758
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,722
AirportDetailsAtcModelItem.h
qutescoop_qutescoop/src/models/items/AirportDetailsAtcModelItem.h
#ifndef AIRPORTDETAILSATCMODELITEM_H_ #define AIRPORTDETAILSATCMODELITEM_H_ #include "../../Controller.h" class AirportDetailsAtcModelItem { public: explicit AirportDetailsAtcModelItem(const QStringList &columnTexts = {}, Controller* controller = nullptr, AirportDetailsAtcModelItem* parentItem = nullptr); ~AirportDetailsAtcModelItem(); void removeChildren(); int row() const; AirportDetailsAtcModelItem* m_parentItem; QStringList m_columnTexts; Controller* m_controller; QVector<AirportDetailsAtcModelItem*> m_childItems; }; #endif
607
C++
.h
15
34.6
165
0.744463
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,723
Renderer.h
qutescoop_qutescoop/src/mustache/Renderer.h
#ifndef MUSTACHEQS_RENDERER_H #define MUSTACHEQS_RENDERER_H #include "src/mustache/external/qt-mustache/mustache.h" namespace MustacheQs { class Renderer { public: static Renderer* instance(); // when using this, call teardownContext() to release memory static QString render(const QString& _template, QObject* _o); static void teardownContext(QObject* _o); private: Renderer(); QString m_render(const QString& _template, QObject* _o); void m_teardownContext(QObject* _o); Mustache::Context* m_context(QObject* o); Mustache::Renderer m_renderer; QHash<QObject*, Mustache::Context*> m_contexts; }; } #endif
755
C++
.h
20
29.3
73
0.635616
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,724
ControllerContext.h
qutescoop_qutescoop/src/mustache/contexts/ControllerContext.h
#ifndef MUSTACHEQS_CONTROLLER_CONTEXT_H #define MUSTACHEQS_CONTROLLER_CONTEXT_H #include "src/mustache/external/qt-mustache/mustache.h" class Controller; namespace MustacheQs::Controller { class PartialResolver : public Mustache::PartialResolver { public: static PartialResolver* instance(); virtual QString getPartial(const QString& name) override; private: PartialResolver(); static PartialResolver* inst; }; class Context : public Mustache::Context { public: Context(const class Controller*); virtual ~Context(); virtual QString stringValue(const QString &key) const override; virtual bool isFalse(const QString &key) const override; virtual int listCount(const QString &key) const override; virtual void push(const QString &key, int index) override; virtual void pop() override; private: const class Controller* m_o; }; } #endif
1,046
C++
.h
29
27.724138
75
0.656126
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,725
AirportContext.h
qutescoop_qutescoop/src/mustache/contexts/AirportContext.h
#ifndef MUSTACHEQS_AIRPORT_CONTEXT_H #define MUSTACHEQS_AIRPORT_CONTEXT_H #include "src/mustache/external/qt-mustache/mustache.h" class Airport; namespace MustacheQs::Airport { class PartialResolver : public Mustache::PartialResolver { public: static PartialResolver* instance(); virtual QString getPartial(const QString& name) override; private: PartialResolver(); static PartialResolver* inst; }; class Context : public Mustache::Context { public: Context(const class Airport*); virtual ~Context(); virtual QString stringValue(const QString &key) const override; virtual bool isFalse(const QString &key) const override; virtual int listCount(const QString &key) const override; virtual void push(const QString &key, int index) override; virtual void pop() override; private: const class Airport* m_o; }; } #endif
1,028
C++
.h
29
27.103448
75
0.649899
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,726
PilotContext.h
qutescoop_qutescoop/src/mustache/contexts/PilotContext.h
#ifndef MUSTACHEQS_PILOT_CONTEXT_H #define MUSTACHEQS_PILOT_CONTEXT_H #include "src/mustache/external/qt-mustache/mustache.h" class Pilot; namespace MustacheQs::Pilot { class PartialResolver : public Mustache::PartialResolver { public: static PartialResolver* instance(); virtual QString getPartial(const QString& name) override; private: PartialResolver(); static PartialResolver* inst; }; class Context : public Mustache::Context { public: Context(const class Pilot*); virtual ~Context(); virtual QString stringValue(const QString &key) const override; virtual bool isFalse(const QString &key) const override; virtual int listCount(const QString &key) const override; virtual void push(const QString &key, int index) override; virtual void pop() override; private: const class Pilot* m_o; }; } #endif
1,016
C++
.h
29
26.689655
75
0.645621
qutescoop/qutescoop
33
15
21
GPL-3.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,728
lru_cache_test.cc
nitnelave_lru_cache/test/lru_cache_test.cc
#include "lru_cache/lru_cache.h" #include <iostream> #include "catch_util.h" #include "key_type.h" #include "range_matcher_util.h" using ::Catch::Equals; namespace lru_cache { template <size_t Size> struct DynamicLruCacheTester { template <typename ValueProducer, typename DroppedCallback = decltype( &internal::no_op_dropped_entry_callback_deduced<ValueProducer>)> static decltype(auto) new_cache( ValueProducer p, DroppedCallback d = internal::no_op_dropped_entry_callback_deduced<ValueProducer>) { return make_dynamic_lru_cache_deduced(Size, p, d); } }; template <size_t Size> struct StaticLruCacheTester { template <typename ValueProducer, typename DroppedCallback = decltype( &internal::no_op_dropped_entry_callback_deduced<ValueProducer>)> static decltype(auto) new_cache( ValueProducer p, DroppedCallback d = internal::no_op_dropped_entry_callback_deduced<ValueProducer>) { return make_static_lru_cache_deduced<Size>(p, d); } }; template <size_t Size> struct NodeLruCacheTester { template <typename ValueProducer, typename DroppedCallback = decltype( &internal::no_op_dropped_entry_callback_deduced<ValueProducer>)> static decltype(auto) new_cache( ValueProducer p, DroppedCallback d = internal::no_op_dropped_entry_callback_deduced<ValueProducer>) { return make_node_lru_cache_deduced(Size, p, d); } }; TEMPLATE_TEST_CASE("LRU cache drops LRU entries", "[LRU]", DynamicLruCacheTester<3>, StaticLruCacheTester<3>, NodeLruCacheTester<3>) { std::vector<int> dropped; std::vector<int> fetched; auto my_lru_cache = TestType::new_cache( [&](const KeyType& i) { fetched.push_back(i.value); return i.value; }, [&](KeyType key, int val) { dropped.push_back(key.value); }); auto LruRangeEquals = &RangeEquals<decltype(my_lru_cache)>; REQUIRE(my_lru_cache.size() == 0); REQUIRE(my_lru_cache.empty()); SECTION("Fetching fewer elements than the cache doesn't drop anything") { REQUIRE(my_lru_cache[1] == 1); REQUIRE(my_lru_cache[2] == 2); REQUIRE(my_lru_cache[3] == 3); REQUIRE(dropped.empty()); REQUIRE_THAT(fetched, Equals(std::vector<int>{1, 2, 3})); REQUIRE_THAT(my_lru_cache, LruRangeEquals({{3, 3}, {2, 2}, {1, 1}})); SECTION("Fetching one more element drops the first") { REQUIRE(my_lru_cache[4] == 4); REQUIRE_THAT(fetched, Equals(std::vector<int>{1, 2, 3, 4})); REQUIRE_THAT(dropped, Equals(std::vector<int>{1})); REQUIRE_THAT(my_lru_cache, LruRangeEquals({{4, 4}, {3, 3}, {2, 2}})); } SECTION("Fetching an element already there doesn't fetch anything") { REQUIRE(my_lru_cache[1] == 1); REQUIRE(dropped.empty()); REQUIRE_THAT(fetched, Equals(std::vector<int>{1, 2, 3})); REQUIRE_THAT(my_lru_cache, LruRangeEquals({{1, 1}, {3, 3}, {2, 2}})); SECTION("Fetching one more element drops the second") { REQUIRE(my_lru_cache[4] == 4); REQUIRE_THAT(fetched, Equals(std::vector<int>{1, 2, 3, 4})); REQUIRE_THAT(dropped, Equals(std::vector<int>{2})); REQUIRE_THAT(my_lru_cache, LruRangeEquals({{4, 4}, {1, 1}, {3, 3}})); } } } SECTION( "Fetching two elements then accessing the first one keeps the " "pointers okay") { REQUIRE(my_lru_cache[1] == 1); REQUIRE(my_lru_cache[2] == 2); REQUIRE(my_lru_cache[1] == 1); REQUIRE(dropped.empty()); REQUIRE_THAT(fetched, Equals(std::vector<int>{1, 2})); REQUIRE_THAT(my_lru_cache, LruRangeEquals({{1, 1}, {2, 2}})); } } TEMPLATE_TEST_CASE("LRU cache works with move-only types", "[LRU]", DynamicLruCacheTester<3>, StaticLruCacheTester<3>, NodeLruCacheTester<3>) { std::vector<int> dropped; auto my_lru_cache = TestType::new_cache( [](KeyType i) { return std::make_unique<int>(i.value); }, [&](KeyType key, std::unique_ptr<int> val) { dropped.push_back(key.value); }); SECTION("Fetching fewer elements than the cache doesn't drop anything") { REQUIRE(*my_lru_cache[1] == 1); REQUIRE(*my_lru_cache[2] == 2); REQUIRE(*my_lru_cache[3] == 3); REQUIRE(dropped.empty()); SECTION("Fetching one more element drops the first") { REQUIRE(*my_lru_cache[4] == 4); REQUIRE_THAT(dropped, Equals(std::vector<int>{1})); } } } struct DestructionStats { int constructed = 0; int destroyed = 0; }; struct DestructorCounter { DestructorCounter(DestructionStats& stats) : stats_(&stats) { stats.constructed++; } DestructorCounter(const DestructorCounter&) = delete; DestructorCounter& operator=(const DestructorCounter&) = delete; DestructorCounter(DestructorCounter&& other) = default; DestructorCounter& operator=(DestructorCounter&& other) = default; ~DestructorCounter() { if (stats_) stats_->destroyed++; } private: DestructionStats* stats_ = nullptr; }; TEMPLATE_TEST_CASE("LRU cache works with non-default-constructible types", "[LRU]", DynamicLruCacheTester<3>, StaticLruCacheTester<3>, NodeLruCacheTester<3>) { DestructionStats stats; SECTION("No element get destroyed if none are constructed") { { auto my_lru_cache = TestType::new_cache( [&](KeyType i) { return DestructorCounter(stats); }); REQUIRE(stats.constructed == 0); } REQUIRE(stats.constructed == 0); REQUIRE(stats.destroyed == 0); } SECTION("Fetching a few elements makes only them destroyed.") { { auto my_lru_cache = TestType::new_cache( [&](KeyType i) { return DestructorCounter(stats); }); my_lru_cache[1]; my_lru_cache[2]; REQUIRE(stats.constructed == 2); } // Ideally we would check the number of destroyed items as well, but with // move constructors/move elision, that number is >2 and not stable between // the containers and optimization levels. REQUIRE(stats.constructed == 2); } } TEMPLATE_TEST_CASE("LRU cache can be moved", "[LRU]", DynamicLruCacheTester<3>, // StaticLruCacheTester is not moveable. NodeLruCacheTester<3>) { SECTION("No element get destroyed if none are constructed") { auto my_lru_cache = TestType::new_cache([](KeyType i) { return i.value; }); auto second_cache = std::move(my_lru_cache); } } void drop_callback(KeyType k, int v) {} int produce_callback(const KeyType& k) { return 3; } struct ValueProducer { ValueProducer(int i) : val_(i) {} int operator()(const KeyType& key) { return val_; } int val_; }; TEST_CASE("Explicit cache type") { // Dynamic. { DynamicLruCache<KeyType, int, std::function<int(const KeyType&)>> cache_function(42, [](const KeyType&) { return 3; }); DynamicLruCache<KeyType, int, int (*)(const KeyType&)> cache( 42, produce_callback); auto made_cache = make_dynamic_lru_cache<KeyType, int>(42, produce_callback); static_assert(std::is_same_v<decltype(cache), decltype(made_cache)>); DynamicLruCache<KeyType, int, ValueProducer> cache_producer = make_dynamic_lru_cache_deduced(42, ValueProducer{3}); } // Static. { StaticLruCache<KeyType, int, 42, std::function<int(const KeyType&)>> cache_function([](const KeyType&) { return 3; }); StaticLruCache<KeyType, int, 42, int (*)(const KeyType&)> cache( produce_callback); auto made_cache = make_static_lru_cache<KeyType, int, 42>(produce_callback); static_assert(std::is_same_v<decltype(cache), decltype(made_cache)>); StaticLruCache<KeyType, int, 42, ValueProducer> cache_producer = make_static_lru_cache_deduced<42>(ValueProducer{3}); } // Node. { NodeLruCache<KeyType, int, std::function<int(const KeyType&)>> cache_function(42, [](const KeyType&) { return 3; }); NodeLruCache<KeyType, int, int (*)(const KeyType&)> cache(42, produce_callback); auto made_cache = make_node_lru_cache<KeyType, int>(42, produce_callback); static_assert(std::is_same_v<decltype(cache), decltype(made_cache)>); static_assert(std::is_same_v<decltype(cache), decltype(memoize_function(42, produce_callback))>); static_assert(std::is_same_v<NodeLruCache<KeyType, int>, decltype(make_cache<KeyType, int>(42))>); NodeLruCache<KeyType, int, ValueProducer> cache_producer = make_node_lru_cache_deduced(42, ValueProducer{3}); } } } // namespace lru_cache
8,637
C++
.cc
213
34.760563
102
0.657622
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,729
throwing_provider_test.cc
nitnelave_lru_cache/test/throwing_provider_test.cc
#include "catch_util.h" #include "key_type.h" #include "lru_cache/lru_cache.h" #include "pointer_matcher_util.h" #include "range_matcher_util.h" namespace lru_cache { TEST_CASE("LRU cache without provider throws", "[LRU]") { auto cache = make_node_lru_cache<int, int>(3); auto LruRangeEquals = &RangeEquals<decltype(cache)>; REQUIRE(cache.size() == 0); REQUIRE(cache.empty()); SECTION("Fetching an element throws") { REQUIRE_THROWS_WITH(cache[1], "LRU cache: Key not found: 1"); REQUIRE(cache.size() == 0); REQUIRE(cache.empty()); } SECTION("Inserting an element works") { REQUIRE(cache.insert(1, 10) == 10); REQUIRE(cache.get(1) == 10); REQUIRE(cache[1] == 10); SECTION("get_or_null works correctly") { REQUIRE_THAT(cache.get_or_null(1), PointsTo(10)); REQUIRE(cache.get_or_null(2) == nullptr); } SECTION("get_or_null updates access order") { REQUIRE(cache.insert(2, 20) == 20); REQUIRE_THAT(cache, LruRangeEquals({{2, 20}, {1, 10}})); REQUIRE_THAT(cache.get_or_null(1), PointsTo(10)); REQUIRE_THAT(cache, LruRangeEquals({{1, 10}, {2, 20}})); } } } } // namespace lru_cache
1,171
C++
.cc
33
31.606061
65
0.652863
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,730
traits_util_test.cc
nitnelave_lru_cache/test/traits_util_test.cc
#include "lru_cache/traits_util.h" #include "catch_util.h" namespace lru_cache::internal { struct Return {}; struct Arg1 {}; struct Arg2 {}; Return simple(Arg1 a) { return {}; } Return two_arg(Arg1 a, Arg2 b) { return {}; } Return const_simple(const Arg1& a) { return {}; } Return const_two_arg(const Arg1& a, const Arg2& b) { return {}; } TEST_CASE("Result type works with functions", "[traits]") { STATIC_REQUIRE(std::is_same_v<return_t<decltype(&simple)>, Return>); STATIC_REQUIRE(std::is_same_v<args_t<decltype(&simple)>, std::tuple<Arg1>>); STATIC_REQUIRE(std::is_same_v<return_t<decltype(&two_arg)>, Return>); STATIC_REQUIRE( std::is_same_v<args_t<decltype(&two_arg)>, std::tuple<Arg1, Arg2>>); STATIC_REQUIRE(std::is_same_v<return_t<decltype(&const_simple)>, Return>); STATIC_REQUIRE( std::is_same_v<args_t<decltype(&const_simple)>, std::tuple<const Arg1&>>); STATIC_REQUIRE(std::is_same_v<return_t<decltype(&const_two_arg)>, Return>); STATIC_REQUIRE(std::is_same_v<args_t<decltype(&const_two_arg)>, std::tuple<const Arg1&, const Arg2&>>); STATIC_REQUIRE(std::is_same_v<single_arg_t<decltype(&simple)>, Arg1>); STATIC_REQUIRE(std::is_same_v<single_arg_t<decltype(&const_simple)>, Arg1>); } template <typename T> struct print_t; TEST_CASE("Result type works with lambdas", "[traits]") { { auto simple = [](Arg1 a) -> Return { return {}; }; auto two_arg = [](Arg1 a, Arg2 b) -> Return { return {}; }; auto const_simple = [](const Arg1& a) -> Return { return {}; }; auto const_two_arg = [](const Arg1& a, const Arg2& b) -> Return { return {}; }; STATIC_REQUIRE(std::is_same_v<return_t<decltype(simple)>, Return>); STATIC_REQUIRE(std::is_same_v<args_t<decltype(simple)>, std::tuple<Arg1>>); STATIC_REQUIRE(std::is_same_v<return_t<decltype(two_arg)>, Return>); STATIC_REQUIRE( std::is_same_v<args_t<decltype(two_arg)>, std::tuple<Arg1, Arg2>>); STATIC_REQUIRE(std::is_same_v<return_t<decltype(const_simple)>, Return>); STATIC_REQUIRE(std::is_same_v<args_t<decltype(const_simple)>, std::tuple<const Arg1&>>); STATIC_REQUIRE(std::is_same_v<return_t<decltype(const_two_arg)>, Return>); STATIC_REQUIRE(std::is_same_v<args_t<decltype(const_two_arg)>, std::tuple<const Arg1&, const Arg2&>>); } { Return ret; auto simple = [&](Arg1 a) -> Return& { return ret; }; auto two_arg = [&](Arg1 a, Arg2 b) -> Return& { return ret; }; auto const_simple = [&](const Arg1& a) -> Return& { return ret; }; auto const_two_arg = [&](const Arg1& a, const Arg2& b) -> Return& { return ret; }; STATIC_REQUIRE(std::is_same_v<return_t<decltype(simple)>, Return&>); STATIC_REQUIRE(std::is_same_v<args_t<decltype(simple)>, std::tuple<Arg1>>); STATIC_REQUIRE(std::is_same_v<return_t<decltype(two_arg)>, Return&>); STATIC_REQUIRE( std::is_same_v<args_t<decltype(two_arg)>, std::tuple<Arg1, Arg2>>); STATIC_REQUIRE(std::is_same_v<return_t<decltype(const_simple)>, Return&>); STATIC_REQUIRE(std::is_same_v<args_t<decltype(const_simple)>, std::tuple<const Arg1&>>); STATIC_REQUIRE(std::is_same_v<return_t<decltype(const_two_arg)>, Return&>); STATIC_REQUIRE(std::is_same_v<args_t<decltype(const_two_arg)>, std::tuple<const Arg1&, const Arg2&>>); } } struct Simple { Return operator()(Arg1 a) { return {}; } }; struct TwoArg { Return operator()(Arg1 a, Arg2 b) { return {}; } }; struct ConstSimple { Return operator()(const Arg1& a) { return {}; } }; struct ConstTwoArg { Return operator()(const Arg1& a, const Arg2& b) { return {}; } }; TEST_CASE("Result type works with non-const operator in classes", "[traits]") { STATIC_REQUIRE(std::is_same_v<return_t<Simple>, Return>); STATIC_REQUIRE(std::is_same_v<args_t<Simple>, std::tuple<Arg1>>); STATIC_REQUIRE(std::is_same_v<return_t<TwoArg>, Return>); STATIC_REQUIRE(std::is_same_v<args_t<TwoArg>, std::tuple<Arg1, Arg2>>); STATIC_REQUIRE(std::is_same_v<return_t<ConstSimple>, Return>); STATIC_REQUIRE(std::is_same_v<args_t<ConstSimple>, std::tuple<const Arg1&>>); STATIC_REQUIRE(std::is_same_v<return_t<ConstTwoArg>, Return>); STATIC_REQUIRE(std::is_same_v<args_t<ConstTwoArg>, std::tuple<const Arg1&, const Arg2&>>); } TEST_CASE("index_type_for picks the right type", "[traits]") { STATIC_REQUIRE(std::is_same_v<index_type_for<3>, uint8_t>); STATIC_REQUIRE(std::is_same_v<index_type_for<255>, uint8_t>); STATIC_REQUIRE(std::is_same_v<index_type_for<256>, uint16_t>); STATIC_REQUIRE(std::is_same_v<index_type_for<300>, uint16_t>); STATIC_REQUIRE(std::is_same_v<index_type_for<70'000>, uint32_t>); STATIC_REQUIRE(std::is_same_v<index_type_for<5'000'000'000>, uint64_t>); } } // namespace lru_cache::internal
4,951
C++
.cc
100
44.23
80
0.642813
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,731
node_lru_cache_test.cc
nitnelave_lru_cache/test/node_lru_cache_test.cc
#include <pthread.h> #include <iostream> #include "catch_util.h" #include "lru_cache/lru_cache.h" #include "range_matcher_util.h" using ::Catch::Equals; struct KeyType { KeyType() = default; KeyType(int i) : value(i) {} int value; template <typename H> friend H AbslHashValue(H h, const KeyType& n) { return H::combine(std::move(h), n.value); } bool operator==(const KeyType& other) const { return value == other.value; } bool operator!=(const KeyType& other) const { return !(*this == other); } }; std::ostream& operator<<(std::ostream& os, const KeyType& key) { return os << key.value; } struct NodeLruCacheTester { decltype(auto) new_cache(std::vector<KeyType>& dropped, std::vector<KeyType>& fetched) { return ::lru_cache::make_node_lru_cache<KeyType, int>( 3, [&](KeyType i) { fetched.push_back(i); return i.value; }, [&](KeyType key, int val) { dropped.push_back(key); }); } }; TEST_CASE("LRU cache drops LRU entries", "[LRU][dynamic]") { NodeLruCacheTester tester; std::vector<KeyType> dropped; std::vector<KeyType> fetched; auto my_lru_cache = tester.new_cache(dropped, fetched); auto LruRangeEquals = &RangeEquals<decltype(my_lru_cache)>; REQUIRE(my_lru_cache.size() == 0); REQUIRE(my_lru_cache.empty()); SECTION("Fetching fewer elements than the cache doesn't drop anything") { REQUIRE(my_lru_cache[1] == 1); REQUIRE(my_lru_cache[2] == 2); REQUIRE(my_lru_cache[3] == 3); REQUIRE(dropped.empty()); REQUIRE_THAT(fetched, Equals(std::vector<KeyType>{1, 2, 3})); REQUIRE_THAT(my_lru_cache, LruRangeEquals({{3, 3}, {2, 2}, {1, 1}})); SECTION("Fetching one more element drops the first") { REQUIRE(my_lru_cache[4] == 4); REQUIRE_THAT(fetched, Equals(std::vector<KeyType>{1, 2, 3, 4})); REQUIRE_THAT(dropped, Equals(std::vector<KeyType>{1})); REQUIRE_THAT(my_lru_cache, LruRangeEquals({{4, 4}, {3, 3}, {2, 2}})); } SECTION("Fetching an element already there doesn't fetch anything") { REQUIRE(my_lru_cache[1] == 1); REQUIRE(dropped.empty()); REQUIRE_THAT(fetched, Equals(std::vector<KeyType>{1, 2, 3})); REQUIRE_THAT(my_lru_cache, LruRangeEquals({{1, 1}, {3, 3}, {2, 2}})); SECTION("Fetching one more element drops the second") { REQUIRE(my_lru_cache[4] == 4); REQUIRE_THAT(fetched, Equals(std::vector<KeyType>{1, 2, 3, 4})); REQUIRE_THAT(dropped, Equals(std::vector<KeyType>{2})); REQUIRE_THAT(my_lru_cache, LruRangeEquals({{4, 4}, {1, 1}, {3, 3}})); } } } }
2,631
C++
.cc
67
34.268657
78
0.635225
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,732
itoa.cc
nitnelave_lru_cache/benchmarks/itoa.cc
#include <random> #include <sstream> #include <string> #include <vector> #include "adapters.h" #include "catch_util.h" #include "lru_cache/lru_cache.h" namespace lru_cache { std::string ToString(int v) { std::stringstream out; out << v; return std::move(out).str(); } template <size_t Value> struct IntWrapper {}; template <size_t Value> using Iterations = IntWrapper<Value>; template <size_t Value> using CacheSize = IntWrapper<Value>; template <typename MissRate /* in percentage */, typename BenchSize, typename CacheSize> struct BenchOptions; template <size_t MissRate /* in percentage */, size_t BenchSize, size_t CacheSize> struct BenchOptions<IntWrapper<MissRate>, IntWrapper<BenchSize>, IntWrapper<CacheSize>> { static constexpr size_t MISS_RATE = MissRate; static_assert(MISS_RATE >= 0 && MISS_RATE < 100); static constexpr size_t BENCH_SIZE = BenchSize; static constexpr size_t CACHE_SIZE = CacheSize; static constexpr double MISS_RATIO = MISS_RATE / 100.0; static constexpr size_t MAX_VALUE = CACHE_SIZE + (CACHE_SIZE * MISS_RATIO / (1 - MISS_RATIO)); }; template <typename BenchSize, typename CacheSize> using LowMissRateBenchOptions = BenchOptions<IntWrapper<5>, BenchSize, CacheSize>; template <typename BenchSize, typename CacheSize> using HighMissRateBenchOptions = BenchOptions<IntWrapper<50>, BenchSize, CacheSize>; TEMPLATE_PRODUCT_TEST_CASE("Benchmark itoa", "[benchmarks]", (LowMissRateBenchOptions, HighMissRateBenchOptions), ((Iterations<1'000>, CacheSize<100>), (Iterations<100'000>, CacheSize<10'000>))) { static constexpr size_t CACHE_SIZE = TestType::CACHE_SIZE; std::vector<int> keys(TestType::BENCH_SIZE); std::mt19937 gen(0); // Using constant seed. std::uniform_int_distribution<> dist(0, TestType::MAX_VALUE); std::generate(keys.begin(), keys.end(), [&]() { return dist(gen); }); BENCHMARK("baseline") { size_t total_size = 0; for (int key : keys) { total_size += ToString(key).size(); } return total_size; }; BENCHMARK("nitnelave/lru_cache/dynamic") { auto cache = make_dynamic_lru_cache<int, std::string>(CACHE_SIZE, ToString); size_t total_size = 0; for (int key : keys) { total_size += cache[key].size(); } return total_size; }; BENCHMARK("nitnelave/lru_cache/dynamic_reserve") { auto cache = make_dynamic_lru_cache<int, std::string>(CACHE_SIZE, ToString); cache.reserve(CACHE_SIZE); size_t total_size = 0; for (int key : keys) { total_size += cache[key].size(); } return total_size; }; BENCHMARK("nitnelave/lru_cache/static") { auto cache = make_static_lru_cache<int, std::string, CACHE_SIZE>(ToString); size_t total_size = 0; for (int key : keys) { total_size += cache[key].size(); } return total_size; }; BENCHMARK("nitnelave/lru_cache/node") { auto cache = make_node_lru_cache<int, std::string>(CACHE_SIZE, ToString); size_t total_size = 0; for (int key : keys) { total_size += cache[key].size(); } return total_size; }; BENCHMARK("lamerman/lrucache") { auto cache = make_lamerman_lru_cache<int, std::string, CACHE_SIZE>(ToString); size_t total_size = 0; for (int key : keys) { total_size += cache[key].size(); } return total_size; }; BENCHMARK("mohaps/LRUCache11") { auto cache = make_mohaps_lru_cache<int, std::string, CACHE_SIZE>(ToString); size_t total_size = 0; for (int key : keys) { total_size += cache[key].size(); } return total_size; }; BENCHMARK("vpetrigo/caches") { auto cache = make_vpetrigo_lru_cache<int, std::string, CACHE_SIZE>(ToString); size_t total_size = 0; for (int key : keys) { total_size += cache[key].size(); } return total_size; }; BENCHMARK("goldsborough/caches") { auto cache = make_goldsborough_lru_cache<int, std::string, CACHE_SIZE>(ToString); size_t total_size = 0; for (int key : keys) { total_size += cache[key].size(); } return total_size; }; } } // namespace lru_cache
4,217
C++
.cc
126
28.746032
80
0.658824
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,733
fibo.cc
nitnelave_lru_cache/benchmarks/fibo.cc
#include "adapters.h" #include "catch_util.h" #include "lru_cache/lru_cache.h" namespace lru_cache { size_t fibo(int n) { if (n < 2) return 1; return fibo(n - 1) + fibo(n - 2); } template <typename Cache> size_t cached_fibo(int n, Cache& cache) { if (n < 2) return 1; const size_t* maybe = cache.get_or_null(n); if (maybe) return *maybe; size_t result = cached_fibo(n - 1, cache) + cached_fibo(n - 2, cache); cache.insert(n, result); return result; } template <size_t N> struct FiboValue { static constexpr size_t value = N; }; TEMPLATE_TEST_CASE("Benchmark fibo", "[benchmarks]", FiboValue<60>, FiboValue<80>, FiboValue<92>) { static constexpr size_t CACHE_SIZE = 10; static constexpr size_t VALUE = TestType::value; BENCHMARK("nitnelave/lru_cache/dynamic") { auto cache = make_dynamic_lru_cache<int, size_t>(CACHE_SIZE); return cached_fibo(VALUE, cache); }; BENCHMARK("nitnelave/lru_cache/dynamic_reserve") { auto cache = make_dynamic_lru_cache<int, size_t>(CACHE_SIZE); cache.reserve(CACHE_SIZE); return cached_fibo(VALUE, cache); }; BENCHMARK("nitnelave/lru_cache/static") { auto cache = make_static_lru_cache<int, size_t, CACHE_SIZE>(); return cached_fibo(VALUE, cache); }; BENCHMARK("nitnelave/lru_cache/node") { auto cache = make_node_lru_cache<int, size_t>(CACHE_SIZE); return cached_fibo(VALUE, cache); }; BENCHMARK("lamerman/lrucache") { auto cache = make_lamerman_lru_cache<int, size_t, CACHE_SIZE>(); return cached_fibo(VALUE, cache); }; BENCHMARK("mohaps/LRUCache11") { auto cache = make_mohaps_lru_cache<int, size_t, CACHE_SIZE>(); return cached_fibo(VALUE, cache); }; BENCHMARK("vpetrigo/caches") { auto cache = make_vpetrigo_lru_cache<int, size_t, CACHE_SIZE>(); return cached_fibo(VALUE, cache); }; BENCHMARK("goldsborough/caches") { auto cache = make_goldsborough_lru_cache<int, size_t, CACHE_SIZE>(); return cached_fibo(VALUE, cache); }; } } // namespace lru_cache
2,013
C++
.cc
59
30.949153
99
0.687372
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,734
range_matcher_util.h
nitnelave_lru_cache/test/range_matcher_util.h
#ifndef LRU_CACHE_TEST_RANGE_MATCHER_UTIL_H_ #define LRU_CACHE_TEST_RANGE_MATCHER_UTIL_H_ #include <vector> #include "catch_util.h" template <typename T> class RangeMatcher : public Catch::MatcherBase<T> { public: using value_type = typename T::value_type; RangeMatcher(const std::vector<value_type>& expected) : vector_matcher_(expected) {} bool match(const T& actual) const override { std::vector<value_type> actual_vector(actual.begin(), actual.end()); return vector_matcher_.match(actual_vector); } std::string describe() const override { return vector_matcher_.describe(); } private: ::Catch::Matchers::Vector::EqualsMatcher< value_type, std::allocator<value_type>, std::allocator<value_type>> vector_matcher_; }; template <typename T> RangeMatcher<T> RangeEquals( const std::vector<typename T::value_type>& expected) { return RangeMatcher<T>(expected); } #endif // LRU_CACHE_TEST_RANGE_MATCHER_UTIL_H_
962
C++
.h
26
33.961538
78
0.733046
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,735
pointer_matcher_util.h
nitnelave_lru_cache/test/pointer_matcher_util.h
#ifndef LRU_CACHE_TEST_POINTER_MATCHER_UTIL_H_ #define LRU_CACHE_TEST_POINTER_MATCHER_UTIL_H_ #include <vector> #include "catch_util.h" template <typename T> class PointerMatcher : public Catch::MatcherBase<const T*> { public: PointerMatcher(const T& expected) : expected_(expected) {} bool match(const T* const& actual) const override { return actual != nullptr && *actual == expected_; } std::string describe() const override { std::ostringstream ss; ss << "is not null and points to " << expected_; return ss.str(); } private: T expected_; }; template <typename T> PointerMatcher<T> PointsTo(const T& expected) { return PointerMatcher<T>(expected); } #endif // LRU_CACHE_TEST_POINTER_MATCHER_UTIL_H_
743
C++
.h
24
28.333333
60
0.72191
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,736
catch_util.h
nitnelave_lru_cache/test/catch_util.h
#ifndef LRU_CACHE_TEST_CATCH_UTIL_ #define LRU_CACHE_TEST_CATCH_UTIL_ #include <iostream> template <typename T1, typename T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& value) { os << '{' << value.first << ", " << value.second << '}'; return os; } #include <catch2/catch.hpp> #endif // LRU_CACHE_TEST_CATCH_UTIL_
347
C++
.h
10
32.9
76
0.678679
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,737
key_type.h
nitnelave_lru_cache/test/key_type.h
#ifndef LRU_CACHE_TEST_KEY_TYPE_H_ #define LRU_CACHE_TEST_KEY_TYPE_H_ #include <functional> struct KeyType { KeyType() = default; KeyType(int i) : value(i) {} int value; template <typename H> friend H AbslHashValue(H h, const KeyType& n) { return H::combine(std::move(h), n.value); } bool operator==(const KeyType& other) const { return value == other.value; } bool operator!=(const KeyType& other) const { return !(*this == other); } }; namespace std { template <> struct hash<KeyType> { std::size_t operator()(const KeyType& k) const { return hash<int>()(k.value); } }; } // namespace std std::ostream& operator<<(std::ostream& os, const KeyType& key) { return os << key.value; } #endif // LRU_CACHE_TEST_KEY_TYPE_H_
758
C++
.h
26
26.730769
78
0.68
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,738
adapters.h
nitnelave_lru_cache/benchmarks/adapters.h
#ifndef LRU_CACHE_BENCHMARKS_ADAPTERS_ #define LRU_CACHE_BENCHMARKS_ADAPTERS_ #include "goldsborough_adapter.h" #include "lamerman_adapter.h" #include "mohaps_adapter.h" #include "vpetrigo_adapter.h" #endif // LRU_CACHE_BENCHMARKS_ADAPTERS_
244
C++
.h
7
33.571429
41
0.804255
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,739
lamerman_adapter.h
nitnelave_lru_cache/benchmarks/lamerman_adapter.h
#ifndef LRU_CACHE_BENCHMARKS_LAMERMAN_ADAPTER_ #define LRU_CACHE_BENCHMARKS_LAMERMAN_ADAPTER_ #include <lrucache.hpp> #include "lru_cache/default_providers.h" namespace lru_cache { template <typename Key, typename Value, size_t Size, typename ValueProvider> class LamermanLruCache { public: LamermanLruCache(ValueProvider callback) : callback_(std::move(callback)) {} const Value& operator[](const Key& key) { if (!cache_.exists(key)) { Value v = callback_(key); cache_.put(key, v); } return cache_.get(key); } const Value* get_or_null(const Key& key) { if (!cache_.exists(key)) return nullptr; return &cache_.get(key); } void insert(const Key& key, Value v) { cache_.put(key, std::move(v)); } private: ::cache::lru_cache<Key, Value> cache_{Size}; ValueProvider callback_; }; template <typename Key, typename Value, size_t Size, typename ValueProvider = decltype(&internal::throwing_value_producer<Key, Value>)> LamermanLruCache<Key, Value, Size, ValueProvider> make_lamerman_lru_cache( ValueProvider provider = internal::throwing_value_producer<Key, Value>) { return {std::move(provider)}; } } // namespace lru_cache #endif // LRU_CACHE_BENCHMARKS_LAMERMAN_ADAPTER_
1,260
C++
.h
34
33.382353
78
0.71358
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,740
vpetrigo_adapter.h
nitnelave_lru_cache/benchmarks/vpetrigo_adapter.h
#ifndef LRU_CACHE_BENCHMARKS_VPETRIGO_ADAPTER_ #define LRU_CACHE_BENCHMARKS_VPETRIGO_ADAPTER_ #include "cache.hpp" #include "lru_cache_policy.hpp" namespace lru_cache { template <typename Key, typename Value, size_t Size, typename ValueProvider> class VpetrigoLruCache { public: VpetrigoLruCache(ValueProvider callback) : callback_(std::move(callback)) {} const Value& operator[](const Key& key) { if (!cache_.Cached(key)) { Value v = callback_(key); cache_.Put(key, std::move(v)); } return cache_.Get(key); } const Value* get_or_null(const Key& key) { if (!cache_.Cached(key)) return nullptr; return &cache_.Get(key); } void insert(const Key& key, Value v) { cache_.Put(key, std::move(v)); } private: ::caches::fixed_sized_cache<Key, Value, ::caches::LRUCachePolicy<Key>> cache_{ Size}; ValueProvider callback_; }; template <typename Key, typename Value, size_t Size, typename ValueProvider = decltype(&internal::throwing_value_producer<Key, Value>)> VpetrigoLruCache<Key, Value, Size, ValueProvider> make_vpetrigo_lru_cache( ValueProvider provider = internal::throwing_value_producer<Key, Value>) { return {std::move(provider)}; } } // namespace lru_cache #endif // LRU_CACHE_BENCHMARKS_VPETRIGO_ADAPTER_
1,305
C++
.h
35
33.542857
80
0.709524
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,741
goldsborough_adapter.h
nitnelave_lru_cache/benchmarks/goldsborough_adapter.h
#ifndef LRU_CACHE_BENCHMARKS_GOLDSBOROUGH_ADAPTER_ #define LRU_CACHE_BENCHMARKS_GOLDSBOROUGH_ADAPTER_ #include "lru/lru.hpp" #include "lru_cache/default_providers.h" namespace lru_cache { template <typename Key, typename Value, size_t Size, typename ValueProvider> class GoldsboroughLruCache { public: GoldsboroughLruCache(ValueProvider callback) : callback_(std::move(callback)) {} const Value& operator[](const Key& key) { if (cache_.contains(key)) { return cache_.lookup(key); } return cache_.emplace(key, callback_(key)).second->value(); } const Value* get_or_null(const Key& key) { auto it = cache_.find(key); if (cache_.is_valid(it)) return &it->value(); return nullptr; } void insert(const Key& key, Value v) { cache_.insert(key, std::move(v)); } private: ::LRU::Cache<Key, Value> cache_{Size}; ValueProvider callback_; }; template <typename Key, typename Value, size_t Size, typename ValueProvider = decltype(&internal::throwing_value_producer<Key, Value>)> GoldsboroughLruCache<Key, Value, Size, ValueProvider> make_goldsborough_lru_cache( ValueProvider provider = internal::throwing_value_producer<Key, Value>) { return {std::move(provider)}; } } // namespace lru_cache #endif // LRU_CACHE_BENCHMARKS_GOLDSBOROUGH_ADAPTER_
1,329
C++
.h
36
33.305556
77
0.720187
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,742
mohaps_adapter.h
nitnelave_lru_cache/benchmarks/mohaps_adapter.h
#ifndef LRU_CACHE_BENCHMARKS_MOHAPS_ADAPTER_ #define LRU_CACHE_BENCHMARKS_MOHAPS_ADAPTER_ #include "LRUCache11.hpp" namespace lru_cache { template <typename Key, typename Value, size_t Size, typename ValueProvider> class MohapsLruCache { public: MohapsLruCache(ValueProvider callback) : callback_(std::move(callback)) {} const Value& operator[](const Key& key) { if (!cache_.contains(key)) { Value v = callback_(key); cache_.insert(key, std::move(v)); } return cache_.get(key); } const Value* get_or_null(const Key& key) { if (!cache_.contains(key)) return nullptr; return &cache_.get(key); } void insert(const Key& key, Value v) { cache_.insert(key, std::move(v)); } private: ::lru11::Cache<Key, Value> cache_{Size}; ValueProvider callback_; }; template <typename Key, typename Value, size_t Size, typename ValueProvider = decltype(&internal::throwing_value_producer<Key, Value>)> MohapsLruCache<Key, Value, Size, ValueProvider> make_mohaps_lru_cache( ValueProvider provider = internal::throwing_value_producer<Key, Value>) { return {std::move(provider)}; } } // namespace lru_cache #endif // LRU_CACHE_BENCHMARKS_MOHAPS_ADAPTER_
1,223
C++
.h
33
33.333333
77
0.709322
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,743
catch_util.h
nitnelave_lru_cache/benchmarks/catch_util.h
#ifndef LRU_CACHE_BENCHMARKS_CATCH_UTIL_ #define LRU_CACHE_BENCHMARKS_CATCH_UTIL_ #define CATCH_CONFIG_ENABLE_BENCHMARKING #include <catch2/catch.hpp> #endif // LRU_CACHE_BENCHMARKS_CATCH_UTIL_
197
C++
.h
5
38
43
0.810526
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,744
dynamic_lru_cache.h
nitnelave_lru_cache/lru_cache/dynamic_lru_cache.h
// LRU cache based on a vector. // // Pros: // - only uses as much memory as needed. // Cons: // - reallocation of the vector contents. #ifndef LRU_CACHE_DYNAMIC_LRU_CACHE_H_ #define LRU_CACHE_DYNAMIC_LRU_CACHE_H_ #include <unordered_map> #include "lru_cache_impl.h" #include "traits_util.h" #include "vector_node_container.h" namespace lru_cache { // Options for a dynamic LRU cache with a maximum size. // The index_type should be an unsigned integer. template <typename Key, typename Value, typename index_type = uint32_t, bool by_access_order = true> struct DynamicLruCacheOptions { using IndexType = index_type; static_assert(std::numeric_limits<IndexType>::is_integer, "IndexType should be an integer."); static_assert(!std::numeric_limits<IndexType>::is_signed, "IndexType should be unsigned."); using Map = std::unordered_map<Key, IndexType>; using NodeContainer = VectorNodeContainer<internal::Node<Key, Value, IndexType>>; static constexpr bool ByAccessOrder = by_access_order; }; // An LRU cache based on a vector that will grow until the max_size. template <typename Key, typename Value, typename ValueProvider = decltype(&internal::throwing_value_producer<Key, Value>), typename DroppedEntryCallback = void (*)(Key, Value)> class DynamicLruCache : public internal::LruCacheImpl< DynamicLruCache<Key, Value, ValueProvider, DroppedEntryCallback>, Key, Value, DynamicLruCacheOptions<Key, Value>, ValueProvider, DroppedEntryCallback> { using Base = typename DynamicLruCache::Impl; friend Base; using options_type = DynamicLruCacheOptions<Key, Value>; using IndexType = typename options_type::IndexType; using NodeContainer = typename options_type::NodeContainer; using Map = typename options_type::Map; public: static constexpr IndexType MAX_REPRESENTABLE_SIZE = std::numeric_limits<IndexType>::max() - 1; // The maximum size should be at most one less than the maximum representable // integer. DynamicLruCache(size_t max_size, ValueProvider value_provider = internal::throwing_value_producer<Key, Value>, DroppedEntryCallback dropped_entry_callback = internal::no_op_dropped_entry_callback<Key, Value>) : Base(std::move(value_provider), std::move(dropped_entry_callback)), max_size_(max_size) { assert(max_size <= MAX_REPRESENTABLE_SIZE); } size_t max_size() const { return max_size_; } void reserve(IndexType size) { assert(size <= max_size()); nodes_.reserve(size); } protected: NodeContainer& node_container() { return nodes_; } Map& map() { return map_; } const Map& map() const { return map_; } IndexType index_of(const Key& key) const { auto it = map_.find(key); if (it != map_.end()) { return it->second; } return NodeContainer::INVALID_INDEX; } private: const size_t max_size_; NodeContainer nodes_; Map map_; }; // Factory function for a dynamic LRU cache. // The maximum size should be at most one less than the maximum representable // integer. template <typename Key, typename Value, typename ValueProvider = decltype(&internal::throwing_value_producer<Key, Value>), typename DroppedEntryCallback = void (*)(Key, Value)> DynamicLruCache<Key, Value, ValueProvider, DroppedEntryCallback> make_dynamic_lru_cache( typename DynamicLruCacheOptions<Key, Value>::IndexType max_size, ValueProvider v = internal::throwing_value_producer<Key, Value>, DroppedEntryCallback c = internal::no_op_dropped_entry_callback<Key, Value>) { return {max_size, v, c}; } // Same as above, deducing Key and Value from the single-argument function // ValueProvider. template <typename ValueProvider, typename DroppedEntryCallback = decltype( &internal::no_op_dropped_entry_callback_deduced<ValueProvider>)> DynamicLruCache<internal::single_arg_t<ValueProvider>, internal::return_t<ValueProvider>, ValueProvider, DroppedEntryCallback> make_dynamic_lru_cache_deduced( size_t max_size, ValueProvider v, DroppedEntryCallback c = internal::no_op_dropped_entry_callback_deduced<ValueProvider>) { return {max_size, v, c}; } } // namespace lru_cache #endif // LRU_CACHE_DYNAMIC_LRU_CACHE_H_
4,441
C++
.h
110
35.209091
80
0.705009
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,745
default_providers.h
nitnelave_lru_cache/lru_cache/default_providers.h
#ifndef LRU_CACHE_DEFAULT_PROVIDERS_H_ #define LRU_CACHE_DEFAULT_PROVIDERS_H_ #include "exception.h" #include "traits_util.h" namespace lru_cache::internal { // To handle value creation manually, throw when a key is missing. template <typename Key, typename Value> Value throwing_value_producer(const Key& key) { throw KeyNotFound(key); } // If there is nothing to do when an entry is dropped, pass this as parameter. template <typename Key, typename Value> void no_op_dropped_entry_callback(Key key, Value value) {} // Same with argument deduction from a function-like type. template <typename F> void no_op_dropped_entry_callback_deduced(internal::single_arg_t<F> key, internal::return_t<F> value) {} } // namespace lru_cache::internal #endif // LRU_CACHE_DEFAULT_PROVIDERS_H_
831
C++
.h
19
40.105263
78
0.734491
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,746
array_node_container.h
nitnelave_lru_cache/lru_cache/array_node_container.h
#ifndef LRU_CACHE_ARRAY_NODE_CONTAINER_H_ #define LRU_CACHE_ARRAY_NODE_CONTAINER_H_ #include <limits> #include <type_traits> namespace lru_cache { // A node container based on a static array of size N, similarly to std::array. // The memory size is fixed, there is no insertion/deletion. template <typename Node, size_t N, typename index_type = typename Node::IndexType> struct ArrayNodeContainer { using node_type = Node; using key_type = typename node_type::key_type; using IndexType = index_type; static constexpr IndexType INVALID_INDEX = std::numeric_limits<IndexType>::max(); static_assert(N < INVALID_INDEX); ArrayNodeContainer() = default; // ArrayNodeContainer contains the whole array inline, therefore it can // neither be cheaply copied nor moved. If you need a static amount of // memory, but on the heap, use a VectorNodeContainer and call reserve(). ArrayNodeContainer(const ArrayNodeContainer& other) = delete; ArrayNodeContainer& operator=(const ArrayNodeContainer& other) = delete; IndexType emplace_back(node_type node) { IndexType index = size_; ++size_; new (&operator[](index)) node_type(std::move(node)); return index; } // Only destroy the ones that were initialized. ~ArrayNodeContainer() { for (size_t i = 0; i < size_; ++i) { operator[](i).~node_type(); } } IndexType replace_entry(IndexType index, const key_type& old_key, node_type new_node) { operator[](index) = std::move(new_node); return index; } node_type& operator[](IndexType index) { assert(index < size_); return list_content()[index]; } const node_type& operator[](IndexType index) const { assert(index < size_); return list_content()[index]; } private: node_type* list_content() { return reinterpret_cast<node_type*>(&storage_); } const node_type* list_content() const { return reinterpret_cast<node_type*>(&storage_); } // We need to keep track of the size to destroy only the elements that were // constructed. size_t size_ = 0; // We don't use an array or std::array because they call all the destructors // by default. std::aligned_storage_t<sizeof(node_type[N]), alignof(node_type[N])> storage_; static_assert(sizeof(storage_) >= N * sizeof(node_type)); }; } // namespace lru_cache #endif // LRU_CACHE_ARRAY_NODE_CONTAINER_H_
2,400
C++
.h
62
34.854839
79
0.701204
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,747
static_lru_cache.h
nitnelave_lru_cache/lru_cache/static_lru_cache.h
// LRU cache based on a static array. // // Pros: // - no reallocation. // Cons: // - uses the maximum memory from the start. #ifndef LRU_CACHE_STATIC_LRU_CACHE_H_ #define LRU_CACHE_STATIC_LRU_CACHE_H_ #include <unordered_map> #include "array_node_container.h" #include "lru_cache_impl.h" #include "traits_util.h" namespace lru_cache { // Options for a static (fixed-size) LRU cache, of size N. // The index_type should be an unsigned integer. template <typename Key, typename Value, size_t N, bool by_access_order = true> struct StaticLruCacheOptions { using IndexType = internal::index_type_for<N>; static_assert(std::numeric_limits<IndexType>::is_integer, "IndexType should be an integer."); static_assert(!std::numeric_limits<IndexType>::is_signed, "IndexType should be unsigned."); static constexpr IndexType MAX_SIZE = std::numeric_limits<IndexType>::max() - 1; static_assert(N <= MAX_SIZE); using Map = std::unordered_map<Key, IndexType>; using NodeContainer = ArrayNodeContainer<internal::Node<Key, Value, IndexType>, N>; static constexpr bool ByAccessOrder = by_access_order; }; // An LRU cache based on a static, fixed-size storage (no realloc). template <typename Key, typename Value, size_t N, typename ValueProvider = decltype(&internal::throwing_value_producer<Key, Value>), typename DroppedEntryCallback = void (*)(Key, Value)> class StaticLruCache : public internal::LruCacheImpl< StaticLruCache<Key, Value, N, ValueProvider, DroppedEntryCallback>, Key, Value, StaticLruCacheOptions<Key, Value, N>, ValueProvider, DroppedEntryCallback> { using Base = typename StaticLruCache::Impl; friend Base; using options_type = StaticLruCacheOptions<Key, Value, N>; using IndexType = typename options_type::IndexType; using NodeContainer = typename options_type::NodeContainer; using Map = typename options_type::Map; public: StaticLruCache(ValueProvider value_provider = internal::throwing_value_producer<Key, Value>, DroppedEntryCallback dropped_entry_callback = internal::no_op_dropped_entry_callback<Key, Value>) : Base(std::move(value_provider), std::move(dropped_entry_callback)) {} IndexType max_size() const { return N; } protected: NodeContainer& node_container() { return nodes_; } Map& map() { return map_; } const Map& map() const { return map_; } IndexType index_of(const Key& key) const { auto it = map_.find(key); if (it != map_.end()) { return it->second; } return NodeContainer::INVALID_INDEX; } private: NodeContainer nodes_; Map map_; }; // Factory function for a static LRU cache. template <typename Key, typename Value, size_t N, typename ValueProvider = decltype(&internal::throwing_value_producer<Key, Value>), typename DroppedEntryCallback = void (*)(Key, Value)> StaticLruCache<Key, Value, N, ValueProvider, DroppedEntryCallback> make_static_lru_cache( ValueProvider v = internal::throwing_value_producer<Key, Value>, DroppedEntryCallback c = internal::no_op_dropped_entry_callback<Key, Value>) { return {v, c}; } // Same as above, deducing Key and Value from the single-argument function // ValueProvider. template <size_t N, typename ValueProvider, typename DroppedEntryCallback = decltype( &internal::no_op_dropped_entry_callback_deduced<ValueProvider>)> StaticLruCache<internal::single_arg_t<ValueProvider>, internal::return_t<ValueProvider>, N, ValueProvider, DroppedEntryCallback> make_static_lru_cache_deduced( ValueProvider v, DroppedEntryCallback c = internal::no_op_dropped_entry_callback_deduced<ValueProvider>) { return {v, c}; } } // namespace lru_cache #endif // LRU_CACHE_STATIC_LRU_CACHE_H_
3,932
C++
.h
96
35.875
78
0.703354
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
1,540,748
vector_node_container.h
nitnelave_lru_cache/lru_cache/vector_node_container.h
#ifndef LRU_CACHE_VECTOR_NODE_CONTAINER_H_ #define LRU_CACHE_VECTOR_NODE_CONTAINER_H_ #include <vector> namespace lru_cache { // A node container based on a vector. // It doesn't define a maximum size. template <typename Node, typename index_type = typename Node::IndexType> struct VectorNodeContainer { using node_type = Node; using key_type = typename node_type::key_type; using IndexType = index_type; static constexpr IndexType INVALID_INDEX = std::numeric_limits<IndexType>::max(); IndexType emplace_back(node_type node) { list_content_.emplace_back(std::move(node)); return list_content_.size() - 1; } node_type& operator[](IndexType index) { return list_content_[index]; } const node_type& operator[](IndexType index) const { return list_content_[index]; } IndexType replace_entry(IndexType index, const key_type& old_key, node_type new_node) { list_content_[index] = std::move(new_node); return index; } // Reserve memory for the underlying vector, to avoid reallocations. void reserve(IndexType size) { assert(size < INVALID_INDEX); list_content_.reserve(size); } private: std::vector<node_type> list_content_; }; } // namespace lru_cache #endif // LRU_CACHE_VECTOR_NODE_CONTAINER_H_
1,297
C++
.h
36
32.194444
73
0.7136
nitnelave/lru_cache
33
12
1
MPL-2.0
9/20/2024, 10:45:08 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false