diff --git a/mainwindow.cpp b/mainwindow.cpp index 865162f..219048c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -297,11 +297,23 @@ void MainWindow::findItems() { } } +void MainWindow::fetchItems() { + showStatusMessage(tr("Invoked 'Server|Fetch items'")); + emit m_core->fetchItemsFromServer(); +} + +void MainWindow::postItems() { + showStatusMessage(tr("Invoked 'Server|Post items'")); + const int currentRow = ui->tableView->currentIndex().row(); + emit m_core->sendItemToServer(currentRow); +} + void MainWindow::createActions() { // TODO add generic menu actions (file/new, edit/cut, ...) createFileActions(); createUndoActions(); createEditActions(); + createServerActions(); } void MainWindow::createFileActions() { @@ -433,7 +445,7 @@ void MainWindow::createEditActions() { ui->menu_Edit->addAction(m_openEditItemDialogAct.get()); m_deleteItemAct = make_unique(tr("&Delete item(s)"), this); - m_deleteItemAct->setShortcuts(QKeySequence::Delete); + m_deleteItemAct->setShortcut(QKeySequence::Delete); m_deleteItemAct->setStatusTip(tr("Delete currently selected item(s)")); // connect(m_deleteItemAct.get(), &QAction::triggered, this, &MainWindow::deleteSelectedtItems); connect(m_deleteItemAct.get(), &QAction::triggered, this, &MainWindow::deleteCurrentItem); @@ -448,6 +460,21 @@ void MainWindow::createEditActions() { ui->menu_Edit->addAction(m_findItemAct.get()); } +void MainWindow::createServerActions() { + m_fetchItemsAct = make_unique(tr("&Fetch item(s)"), this); + m_fetchItemsAct->setShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Down)); + m_fetchItemsAct->setStatusTip(tr("Fetches all item on configured server")); + connect(m_fetchItemsAct.get(), &QAction::triggered, this, &MainWindow::fetchItems); + ui->menu_Server->addAction(m_fetchItemsAct.get()); + + m_postItemsAct = make_unique(tr("&Post item(s)"), this); + m_postItemsAct->setShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Up)); + // m_postItemsAct->setStatusTip(tr("Posts the selected items on configured server")); + m_postItemsAct->setStatusTip(tr("Posts the current item on configured server")); + connect(m_postItemsAct.get(), &QAction::triggered, this, &MainWindow::postItems); + ui->menu_Server->addAction(m_postItemsAct.get()); +} + void MainWindow::createHelpMenu() { QMenu* helpMenu = ui->menu_Help; helpMenu->addSeparator(); diff --git a/mainwindow.h b/mainwindow.h index 18858f7..fb79def 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -63,6 +63,10 @@ class MainWindow : public QMainWindow { /// 'Edit' slots void findItems(); + /// 'Server' slots + void fetchItems(); + void postItems(); + private: Ui::MainWindow* ui; @@ -89,6 +93,10 @@ class MainWindow : public QMainWindow { unique_ptr m_openEditItemDialogAct; unique_ptr m_deleteItemAct; unique_ptr m_findItemAct; + /// Server actions + unique_ptr m_fetchItemsAct; + unique_ptr m_postItemsAct; + /// View actions unique_ptr m_showModelUndoViewAct; @@ -101,6 +109,7 @@ class MainWindow : public QMainWindow { void createFileActions(); void createUndoActions(); void createEditActions(); + void createServerActions(); void createHelpMenu(); void createGuiDialogs(); }; diff --git a/mainwindow.ui b/mainwindow.ui index 93251a2..3a28e71 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -40,7 +40,7 @@ 0 0 800 - 25 + 22 @@ -64,9 +64,15 @@ + + + &Server + + +