Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

mainwindowimpl.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   mainwindowimpl.cpp                                                            *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   Read the file COPYING for details.                                    *
00011  *                                                                         *
00012  *   copyright: (C) 2003 by Jan Mueller                                    *
00013  *   email: janmueller7@hotmail.com                                        *
00014  *                                                                         *
00015  ***************************************************************************/
00016 
00017 #include "mainwindowimpl.h"
00018 #include <qapplication.h>
00019 #include <qlineedit.h>
00020 #include <qaction.h>
00021 #include <qevent.h>
00022 #include "global.h"
00023 #include "urlevent.h"
00024 #include "author.h"
00025 #include "publication.h"
00026 #include "bibliography.h"
00027 #include "authoroverview.h"
00028 #include "publoverview.h"
00029 #include "noteoverview.h"
00030 #include "journaloverview.h"
00031 #include "publisheroverview.h"
00032 #include "projectoverview.h"
00033 #include "project.h"
00034 #include "part.h"
00035 #include "partmemo.h"
00036 #include "note.h"
00037 #include "file.h"
00038 #include "createhtml.h"
00039 #include "state.h"
00040 #include "search.h"
00041 #include "journal.h"
00042 #include "publisher.h"
00043 #include <qsettings.h>
00044 
00045 MainWindowImpl::MainWindowImpl(QWidget *parent, const char *name): MainWindow(parent, name), widget(0L) {
00046   backAction->setEnabled(false);    
00047   forwardAction->setEnabled(false);
00048 
00049 
00050   QSettings s;
00051   s.setPath("www.test.de", "Literature");
00052   //  s.writeEntry("/literature/mimetotext/application/pdf", "t=/tmp/`date +%H%M%S`$RANDOM; pdftohtml -iFd $t -o - #in# | html2text -o #out#; rm -r $t");
00053   s.writeEntry("/literature/mimetotext/application/pdf", "pdftotext #in# #out#");
00054   s.writeEntry("/literature/mimetotext/text/html", "cat #in# | /usr/bin/html2text -o #out#");
00055   s.writeEntry("/literature/mimetotext/text/plain", "#direct#");
00056   bool ok;
00057   QString b=s.readEntry("/literature/mime2text/application/pdf", QString::null, &ok);
00058   debug("Befehl ist: "+b);
00059 
00060 
00061 }
00062 
00063 MainWindowImpl::~MainWindowImpl() {
00064 }
00065 
00066 void MainWindowImpl::closeEvent(QCloseEvent *e) {
00067   if(widget)
00068     widget->close(true);
00069   e->accept();
00070 }
00071 
00072 void MainWindowImpl::setupBackForward() {
00073   if(widget && widget->isValid() &&
00074      !(stforward.top() && stforward.top()->url()==widget->url()) &&
00075      !(stback.top() && stback.top()->url()==widget->url())) {
00076     stback.push(new UrlEvent(widget->url(), false));
00077     backAction->setEnabled(true);
00078     stforward.clear();
00079     forwardAction->setEnabled(false);
00080   }
00081 }
00082 
00083 void MainWindowImpl::customEvent(QCustomEvent *e) {
00084   UrlEvent *u=dynamic_cast<UrlEvent*>(e);    
00085   if(u) {    
00086     LitUrl url=u->url();
00087     debug("MainWindowImpl::customEvent"+QString(url));
00088     if(u->newWin()) {
00089       MainWindowImpl* new_window= new MainWindowImpl();
00090       u->setNewWin(false);
00091       qApp->postEvent(new_window, new UrlEvent(*u));
00092       new_window->show();
00093     } else {
00094       setupBackForward();
00095       urlline->setText(url);
00096       if(widget) widget->close(true);
00097       widget=0L;
00098       if(url.form()=="author") showAuthor(url);
00099       else if(url.form()=="publication") showPublication(url);
00100       else if(url.form()=="part") showPart(url);            
00101       else if(url.form()=="partmemo") showPartMemo(url);
00102       else if(url.form()=="note") showNote(url);            
00103       else if(url.form()=="file") showFile(url);                    
00104       else if(url.form()=="bibliography") showBibliography(url);            
00105       else if(url.form()=="state") showState(url);
00106       else if(url.form()=="search") showSearch(url);      
00107       else if(url.form()=="authoroverview") showAuthorOverview(url);
00108       else if(url.form()=="publicationoverview") showPublOverview(url);
00109       else if(url.form()=="noteoverview") showNoteOverview(url);
00110       else if(url.form()=="journaloverview") showJournalOverview(url); 
00111       else if(url.form()=="publisheroverview") showPublisherOverview(url);       
00112       else if(url.form()=="publisher") showPublisher(url);     
00113       else if(url.form()=="projectoverview") showProjectOverview(url);       
00114       else if(url.form()=="project") showProject(url);     
00115       else if(url.form()=="journal") showJournal(url);           
00116       else showState(url);
00117     }
00118   }
00119 }
00120 
00121 void MainWindowImpl::setupWidget(QWidget *widget) {
00122   widget->setFocus();
00123   setCentralWidget(widget);
00124   widget->show();
00125 }
00126 
00127 void MainWindowImpl::showNote( LitUrl url )
00128 {
00129   widget=new Note(url, this, SLOT(setWorkingGui(bool)), this,"noteframe");
00130   setupWidget(widget);
00131 }
00132 
00133 void MainWindowImpl::showAuthor( LitUrl url )
00134 {
00135   widget=new Author(url, this, SLOT(setWorkingGui(bool)), this,"authorframe");
00136   setupWidget(widget);
00137 }
00138 
00139 void MainWindowImpl::showPublication( LitUrl url )
00140 {
00141   widget=new Publication(url, this, SLOT(setWorkingGui(bool)), this,"publframe");
00142   setupWidget(widget);
00143 }
00144 
00145 void MainWindowImpl::showPart( LitUrl url )
00146 {
00147   widget=new Part(url, this, SLOT(setWorkingGui(bool)), this,"partframe");
00148   setupWidget(widget);
00149 }
00150 
00151 void MainWindowImpl::showPartMemo( LitUrl url )
00152 {
00153   widget=new PartMemo(url, this, SLOT(setWorkingGui(bool)), this,"partmemoframe");
00154   setupWidget(widget);
00155 }
00156 
00157 
00158 void MainWindowImpl::showBibliography( LitUrl url )
00159 {
00160   widget=new Bibliography(url, this, SLOT(setWorkingGui(bool)), this,"biblioframe");
00161   setupWidget(widget);
00162 }
00163 
00164 
00165 void MainWindowImpl::showFile( LitUrl url )
00166 {
00167   widget=new File(url, this, SLOT(setWorkingGui(bool)), this,"fileframe");
00168   setupWidget(widget);
00169 }
00170 
00171 void MainWindowImpl::showAuthorOverview( LitUrl url )
00172 {
00173   widget=new  AuthorOverview(url, this, SLOT(setWorkingGui(bool)), this, "authoroverview");
00174   setupWidget(widget);
00175 }
00176 
00177 void MainWindowImpl::showNoteOverview( LitUrl url )
00178 {
00179   widget=new  NoteOverview(url, this, SLOT(setWorkingGui(bool)),  this, "noteoverview");
00180   setupWidget(widget);
00181 }
00182 
00183 void MainWindowImpl::showPublOverview( LitUrl url )
00184 {
00185   widget=new PublOverview(url, this, SLOT(setWorkingGui(bool)), this, "publoverview");
00186   setupWidget(widget);
00187 }
00188 
00189 void MainWindowImpl::showJournalOverview( LitUrl url )
00190 {
00191   widget=new JournalOverview(url, this, SLOT(setWorkingGui(bool)), this, "publoverview");
00192   setupWidget(widget);
00193 }
00194 
00195 void MainWindowImpl::showPublisherOverview( LitUrl url )
00196 {
00197   widget=new PublisherOverview(url, this, SLOT(setWorkingGui(bool)), this, "publoverview");
00198   setupWidget(widget);
00199 }
00200 
00201 void MainWindowImpl::showState(LitUrl url)
00202 {
00203   widget=new State(url, this, SLOT(setWorkingGui(bool)), this, "state");
00204   setupWidget(widget);
00205 }
00206 
00207 void MainWindowImpl::showSearch(LitUrl url)
00208 {
00209   widget=new Search(url, this, SLOT(setWorkingGui(bool)), this, "search");
00210   setupWidget(widget);
00211 }
00212 
00213 void MainWindowImpl::showJournal(LitUrl url)
00214 {
00215   widget=new Journal(url, this, SLOT(setWorkingGui(bool)), this, "journal");
00216   setupWidget(widget);
00217 }
00218 
00219 void MainWindowImpl::showPublisher(LitUrl url)
00220 {
00221   widget=new Publisher(url, this, SLOT(setWorkingGui(bool)), this, "publisher");
00222   setupWidget(widget);
00223 }
00224 
00225 void MainWindowImpl::showProject(LitUrl url)
00226 {
00227   widget=new Project(url, this, SLOT(setWorkingGui(bool)), this, "project");
00228   setupWidget(widget);
00229 }
00230 
00231 void MainWindowImpl::showProjectOverview(LitUrl url)
00232 {
00233   widget=new ProjectOverview(url, this, SLOT(setWorkingGui(bool)), this, "projectoverview");
00234   setupWidget(widget);
00235 }
00236 
00237 
00238 void MainWindowImpl::forward()
00239 {
00240   qDebug("forward");
00241   if(stforward.isEmpty())
00242     return;
00243   
00244   if(widget && widget->isValid()) {
00245     stback.push(new UrlEvent(widget->url(), false));
00246     if(!stback.isEmpty()) backAction->setEnabled(true);
00247   }
00248   
00249   qApp->postEvent(this, stforward.pop());   
00250   if(stforward.isEmpty())
00251     forwardAction->setEnabled(false);
00252 }
00253 
00254 void MainWindowImpl::back()
00255 {
00256   if(stback.isEmpty())
00257     return;
00258   if(widget && widget->isValid()) {
00259     stforward.push(new UrlEvent(widget->url(), false));
00260     if(!stforward.isEmpty())
00261       forwardAction->setEnabled(true);
00262   }
00263   qApp->postEvent(this, stback.pop());       
00264   if(stback.isEmpty())
00265     backAction->setEnabled(false);
00266 }

Generated on Sat Mar 27 19:20:40 2004 for Literature by doxygen 1.3.6-20040222