/* This file is part of whyblocked. * Copyright © 2018 tastytea * * This program 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, version 3. * * This program 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. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include "whyblocked.hpp" #include "interface_qt.hpp" MainWindow::MainWindow(QMainWindow *parent) : QMainWindow(parent) { setupUi(this); statusBar()->showMessage(tr("Ready")); QStandardItemModel *model = new QStandardItemModel; tableview->setModel(model); populate_tableview(*model); model->setHeaderData(0, Qt::Horizontal, tr("User/Instance")); model->setHeaderData(1, Qt::Horizontal, tr("Blocked/Silenced?")); model->setHeaderData(2, Qt::Horizontal, tr("Reason")); tableview->horizontalHeader()->resizeSection(0, 300); tableview->setSelectionBehavior(QAbstractItemView::SelectRows); connect(action_add, &QAction::triggered, this, &MainWindow::add); connect(action_remove, &QAction::triggered, this, &MainWindow::remove); connect(action_about, &QAction::triggered, this, &MainWindow::about); } void MainWindow::populate_tableview(QStandardItemModel &model) { model.clear(); result_view result; if (view(result)) { for (const std::tuple &line : result) { QList items; items.append(new QStandardItem(QString::fromStdString((std::get<0>(line))))); if (std::get<1>(line) == 1) { items.append(new QStandardItem(QString(tr("blocked")))); } else { items.append(new QStandardItem(QString(tr("silenced")))); } items.append(new QStandardItem(QString::fromStdString((std::get<2>(line))))); model.appendRow(items); } } } void MainWindow::add() { QDialog *dialog_add = new QDialog; Ui::DialogAdd ui; ui.setupUi(dialog_add); if (dialog_add->exec() == 1) { statusBar()->showMessage(tr("Added nothing. :-P")); } } void MainWindow::remove() { statusBar()->showMessage(tr("Removed nothing. :-P")); } void MainWindow::about() { QMessageBox::about(this, tr("About whyblocked"), tr("whyblocked reminds you why you blocked someone.

" "Copyright © 2018 tastytea.
" "Licence GPLv3: " "GNU GPL version 3.
" "This program comes with ABSOLUTELY NO WARRANTY. This is free software,\n" "and you are welcome to redistribute it under certain conditions.

" "Sourcecode: " "https://schlomp.space/tastytea/whyblocked")); } int main(int argc, char *argv[]) { QApplication app(argc, argv); QCoreApplication::setApplicationName("whyblocked"); MainWindow win; win.show(); return app.exec(); }