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

selectpart.ui.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   selectpart.ui.h                                                               *
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 /****************************************************************************
00018 ** ui.h extension file, included from the uic-generated form implementation.
00019 **
00020 ** If you wish to add, delete or rename functions or slots use
00021 ** Qt Designer which will update this file, preserving your code. Create an
00022 ** init() function in place of a constructor, and a destroy() function in
00023 ** place of a destructor.
00024 *****************************************************************************/
00025 #include "liturl.h"
00026 
00027 struct partrec {
00028   int     no;
00029   QString title;
00030   int     type;
00031   int     publication_no;
00032 };
00033 
00034 void SelectPart::init()
00035 {
00036    parts->clear();
00037    QPtrList<partrec> n;
00038    QSqlQuery query("select no, title from publication order by title");
00039     while(query.next()) {
00040       partrec *r=new partrec;
00041       r->no=query.value(0).toInt();
00042       r->title=query.value(1).toString();
00043       r->type=1;
00044       r->publication_no=0;
00045       n.append(r);
00046     }
00047 
00048       query.exec("select part.no, part.title, part.publication_no from part order by title");
00049       while(query.next()) {
00050         partrec *r=new partrec;
00051         r->no=query.value(0).toInt();
00052         r->title=query.value(1).toString();
00053         r->type=2,
00054         r->publication_no=query.value(2).toInt();
00055         n.append(r);
00056       }
00057 
00058     addItem(n, 0, 0L);
00059     parts->geometry();
00060 }
00061 
00062 void SelectPart::addItem(QPtrList<partrec>& n, int parentoid, NoteTreeItem *parentitem) {
00063   QPtrListIterator<partrec> it(n);
00064   partrec *rec;
00065   while ((rec = it.current()) != 0 ) {
00066     ++it;
00067     if(rec->publication_no==parentoid) {
00068         NoteTreeItem *i;
00069           if(parentitem)
00070               i=new NoteTreeItem(parentitem, LitUrl("lit://part/part?no="+QString().number(rec->no)), rec->title, loadPixmap("showpart.png"));
00071               else
00072                   i=new NoteTreeItem(parts, LitUrl("lit://publication/publication?no="+QString().number(rec->no)), rec->title, loadPixmap("showpubl.png"));
00073        addItem(n, rec->no, i);
00074         n.remove(rec);
00075     }
00076   }
00077 }
00078 
00079 
00080 LitUrl SelectPart::url() {
00081     if(!parts->currentItem()) return LitUrl();
00082     NoteTreeItem *i=dynamic_cast<NoteTreeItem*>(parts->currentItem());
00083     Q_ASSERT(i);
00084     return i->url();
00085 }
00086 
00087 

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