# # # add_file "src/view/DatabaseWindow.cpp" # content [e9da975bc114dd040d49bcffcca3632aabe9ecd3] # # add_file "src/view/DatabaseWindow.h" # content [333f972d3729115180b24d997ce11a7caa4301b5] # ============================================================ --- src/view/DatabaseWindow.cpp e9da975bc114dd040d49bcffcca3632aabe9ecd3 +++ src/view/DatabaseWindow.cpp e9da975bc114dd040d49bcffcca3632aabe9ecd3 @@ -0,0 +1,107 @@ +/*************************************************************************** + * Copyright (C) 2007 by Thomas Keller * + * address@hidden * + * * + * 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; either version 2 of the License, or * + * (at your option) any later version. * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "DatabaseWindow.h" +#include "DatabaseMenuBar.h" +#include "DatabaseDialogManager.h" +#include "Guitone.h" +#include "Settings.h" + +#include + +DatabaseWindow::DatabaseWindow() : MainWindow() +{ + connect( + dialogManager, SIGNAL(revisionCheckedOut(const QString &)), + APP, SLOT(loadWorkspace(const QString &)) + ); + + connect( + menuBar, SIGNAL(showChangesetBrowser()), + dialogManager, SLOT(showChangesetBrowser()) + ); + + connect( + menuBar, SIGNAL(showCheckoutRevision()), + dialogManager, SLOT(showCheckoutRevision()) + ); + + connect( + menuBar, SIGNAL(showKeyManagement()), + dialogManager, SLOT(showKeyManagement()) + ); +} + +DatabaseWindow::~DatabaseWindow() {} + +void DatabaseWindow::init() +{ + cleanup(); + menuBar = new DatabaseMenuBar(this); + dialogManager = new DatabaseDialogManager(this); + + layout = new QHBoxLayout(); + layout->setSpacing(0); + layout->setContentsMargins(0, 0, 0, 0); + + loadedDatabase = new QLabel(tr("nothing loaded"), this); + loadedDatabase->setTextFormat(Qt::PlainText); + loadedDatabase->setAlignment(Qt::AlignCenter); + + layout->addWidget(loadedDatabase); + setLayout(layout); +} + +bool DatabaseWindow::load(const QString & path) +{ + try + { + APP->manager()->getThreadForDatabase(path); + } + catch (GuitoneException e) + { + QMessageBox::critical( + this, + tr("Failed to load database"), + tr("The database could not be loaded:\n%1").arg(e), + QMessageBox::Ok + ); + + Settings::removeItemFromList("RecentDatabaseList", path); + return false; + } + + databaseFile = path; + + // initialize the dialog manager + reinterpret_cast(dialogManager)->init(path); + + loadedDatabase->setText(tr("Loaded database: %1").arg(path)); + + QFileInfo fi(path); + setWindowTitle( + tr("%1 - database mode - guitone").arg(fi.fileName()) + ); + + Settings::addItemToList("RecentDatabaseList", path, 5); + + return true; +} + ============================================================ --- src/view/DatabaseWindow.h 333f972d3729115180b24d997ce11a7caa4301b5 +++ src/view/DatabaseWindow.h 333f972d3729115180b24d997ce11a7caa4301b5 @@ -0,0 +1,47 @@ +/*************************************************************************** + * Copyright (C) 2007 by Thomas Keller * + * address@hidden * + * * + * 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; either version 2 of the License, or * + * (at your option) any later version. * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef DATABASEWINDOW_H +#define DATABASEWINDOW_H + +#include "MainWindow.h" +#include "vocab.h" + +#include +#include + +class DatabaseWindow : public MainWindow +{ + Q_OBJECT +public: + DatabaseWindow(); + ~DatabaseWindow(); + + void init(); + bool load(const QString &); + +private: + DatabaseFile databaseFile; + QLabel * loadedDatabase; + QHBoxLayout * layout; + +}; + +#endif