-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainwindow.cpp
72 lines (55 loc) · 2.31 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "mainwindow.h"
#include <QMenuBar>
#include <QKeySequence>
#include <QFileDialog>
#include <QMessageBox>
#include "timetable.h"
#include "timetablefileimporter.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setWindowTitle("InfoVUZ Timetable Tool v0.2.2");
timetable_ = new TimeTable( "ContactBookV2.db",this);
groupWidget_ = new GroupTimeTableWidget( timetable_, this);
menu_ = new QMenu( QString::fromUtf8("Файл"), this);
QKeySequence saveKeySequence = Qt::CTRL + Qt::Key_S;
QKeySequence clearKeySequence = Qt::CTRL + Qt::Key_Q;
QKeySequence importKeySequence = Qt::CTRL + Qt::Key_I;
saveAction_ = new QAction( QString::fromUtf8("Сохранить занятие"), this);
clearAction_ = new QAction( QString::fromUtf8("Очистить"), this);
importAction_ = new QAction( QString::fromUtf8("Импортировать из файла"), this);
saveAction_->setShortcut( saveKeySequence);
clearAction_->setShortcut( clearKeySequence);
importAction_->setShortcut( importKeySequence);
menu_->addAction( saveAction_);
menu_->addAction( clearAction_);
menu_->addAction( importAction_);
menuBar()->addMenu( menu_);
scrollArea_ = new QScrollArea();
scrollArea_->setWidget( groupWidget_);
scrollArea_->setWidgetResizable(true);
setCentralWidget( scrollArea_);
resize( 1200, 800);
scrollArea_->setMinimumSize( size());
connect( saveAction_, SIGNAL(triggered()), groupWidget_, SLOT(saveTask()));
connect( clearAction_, SIGNAL(triggered()), groupWidget_, SLOT(clearAll()));
connect( importAction_, SIGNAL(triggered()), this, SLOT(chooseImportFile()));
}
MainWindow::~MainWindow()
{}
void MainWindow::resizeEvent(QResizeEvent* event)
{
QMainWindow::resizeEvent(event);
}
void MainWindow::chooseImportFile()
{
QString filename =
QFileDialog::getOpenFileName( this, QString::fromUtf8("Выберите файл для импорта расписания"), "", "Text Files(*.*)");
if( !filename.isEmpty())
{
TimetableFileImporter importer( timetable_, this);
importer.import( filename);
QMessageBox::information( this, QString::fromUtf8("Импорт"),
QString::fromUtf8("Импорт успешно завершен"));
}
}