-
-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CSV loader date-time format help dialog (#731)
- Loading branch information
1 parent
30d424e
commit 5edd5f0
Showing
7 changed files
with
734 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "datetimehelp.h" | ||
#include "ui_datetimehelp.h" | ||
|
||
#include <QScrollBar> | ||
|
||
//Source: https://stackoverflow.com/a/42458736 | ||
void verticalResizeTableViewToContents(QTableView *tableView) | ||
{ | ||
int count=tableView->verticalHeader()->count(); | ||
int scrollBarHeight = 0; | ||
if(tableView->horizontalScrollBar()->isVisible()) | ||
{ | ||
scrollBarHeight=tableView->horizontalScrollBar()->height(); | ||
} | ||
int horizontalHeaderHeight=tableView->horizontalHeader()->height(); | ||
int rowTotalHeight=0; | ||
for (int i = 0; i < count; ++i) { | ||
// 2018-03 edit: only account for row if it is visible | ||
if (!tableView->verticalHeader()->isSectionHidden(i)) { | ||
rowTotalHeight+=tableView->verticalHeader()->sectionSize(i); | ||
} | ||
} | ||
tableView->setMinimumHeight(horizontalHeaderHeight+rowTotalHeight+scrollBarHeight); | ||
} | ||
|
||
DateTimeHelp::DateTimeHelp(QDialog *parent) : | ||
QDialog(parent), ui(new Ui::DateTimeHelp), _parent(parent) | ||
{ | ||
ui->setupUi(this); | ||
|
||
verticalResizeTableViewToContents(ui->dateFormatTable); | ||
verticalResizeTableViewToContents(ui->timeFormatTable); | ||
|
||
refreshExample(); | ||
|
||
connect(ui->exampleDateTimeDateTimeEdit,&QDateTimeEdit::dateTimeChanged,this, [this](){ | ||
refreshExample(); | ||
}); | ||
|
||
connect(ui->exampleFormatStringLineEdit,&QLineEdit::textChanged,this, [this](){ | ||
refreshExample(); | ||
}); | ||
|
||
connect(_parent,&QDialog::finished,this,[this](){ | ||
if(ui->autoCloseCheckBox->isChecked()) | ||
{ | ||
accept(); | ||
} | ||
|
||
}); | ||
|
||
} | ||
|
||
DateTimeHelp::~DateTimeHelp() | ||
{ | ||
delete ui; | ||
} | ||
|
||
void DateTimeHelp::refreshExample() | ||
{ | ||
auto dateTime = ui->exampleDateTimeDateTimeEdit->dateTime(); | ||
auto formatString = ui->exampleFormatStringLineEdit->text(); | ||
ui->resultLineEdit->setText(dateTime.toString(formatString)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef DATETIMEHELP_H | ||
#define DATETIMEHELP_H | ||
|
||
#include <QDialog> | ||
|
||
namespace Ui { | ||
class DateTimeHelp; | ||
} | ||
|
||
class DateTimeHelp : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit DateTimeHelp(QDialog *parent = nullptr); | ||
~DateTimeHelp(); | ||
|
||
void refreshExample(); | ||
|
||
private: | ||
Ui::DateTimeHelp *ui; | ||
|
||
QDialog* _parent; | ||
}; | ||
|
||
#endif // DATETIMEHELP_H |
Oops, something went wrong.