00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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