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

publisher.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   publisher.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 "publisher.h"
00018 #include "liturl.h"
00019 #include <qlayout.h>
00020 #include <qtoolbar.h>
00021 #include <qaction.h>
00022 #include <qpixmap.h>
00023 #include <qmessagebox.h>
00024 #include <qlineedit.h>
00025 #include <qlabel.h>
00026 #include <qapplication.h>
00027 #include <qsqldatabase.h>
00028 #include <qsqlcursor.h>
00029 #include <qevent.h>
00030 #include <qsettings.h>
00031 #include "error.h"
00032 #include "global.h"
00033 #include "mainwindowimpl.h"
00034 #include "linklistbox.h"
00035 #include "filllinklistbox.h"
00036 
00037 Publisher::Publisher(LitUrl url, QObject *receiver, QString slot, MainWindow *parent, const char *name): ReadWriteFormBase(url, receiver, slot, parent, name) {    
00038     publisherform=new PublisherForm(this, "publisherform");
00039     QHBoxLayout *l=new QHBoxLayout(this);
00040     l->addWidget(publisherform);
00041     
00042     QSettings settings;
00043     QString backgr = settings.readEntry(QString("/literature/backgr_")+name, "");
00044     if(!backgr.isEmpty()) publisherform->setErasePixmap(QPixmap(backgr));
00045 
00046     setData();
00047 }
00048 
00049 
00050 Publisher::~Publisher() {
00051     write();
00052 }
00053 
00054 bool Publisher::setData()
00055 {
00056     try {
00057         ReadWriteFormBase::setData();
00058         LitUrl u=url();
00059         setWorkingGui(true);
00060         
00061         form.clear();
00062         formcursor.clear();
00063         formcursor.setMode(QSqlCursor::Writable);
00064         formcursor.setName("publisher");
00065         if(!formcursor.select(u.query()))
00066             throw(Error(formcursor.lastError()));
00067         if(formcursor.size()!=1) throw Error("Invalid Record!");
00068         formcursor.first();
00069         form.setRecord(formcursor.primeUpdate());
00070         form.insert(publisherform->pname, "name");      
00071         form.insert(publisherform->city, "city");
00072         form.insert(publisherform->modified, "modified");
00073         form.insert(publisherform->created, "created");
00074         form.readFields();
00075 
00076         publisherform->publications->clear();
00077         fillpubl=new FillLinkListBox(this, "publisherpublfllb", publisherform->publications, "select publication.no, publication.title as title from publication where publication.publisher_no="+no(url())+" or publication.orgpublisher_no="+no(url())+" union select journal.no, journal.name as title from journal where journal.publisher_no="+no(url())+" order by title desc", "publication/publication", loadPixmap("showpubl"));
00078         fillpubl->start();
00079         threads.append(fillpubl);
00080 
00081         waitForThreads();
00082 
00083         
00084         setValid(true);
00085     } catch(Error &e) {
00086         setValid(false);
00087         setReadonlyGui(true);
00088         QMessageBox::warning(this, "Error", e.message());
00089         return false;
00090     }
00091     setValid(true);
00092     return true;
00093 }
00094 
00095 void Publisher::setWorkingGui(bool work) {
00096              ReadWriteFormBase::setInvalidGui(work);
00097  }
00098 
00099 void Publisher::setReadonlyGui(bool ro) {
00100     ReadWriteFormBase::setReadonlyGui(ro);
00101 }
00102 
00103 void Publisher::setInvalidGui(bool inv) {
00104     ReadWriteFormBase::setInvalidGui(inv);      
00105     setWorkingGui(false);
00106     setReadonlyGui(inv);
00107 }
00108 

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