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

noteoverviewform.ui.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   noteoverviewform.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 struct noterec {
00026     int     no;
00027     QString title;
00028     int     type;
00029     int     publication_no;
00030     int     parent;
00031     int     sibling;
00032 };
00033 
00034 void NoteOverviewForm::init() {
00035     setFocusPolicy( QWidget::StrongFocus );
00036     setBackgroundMode( QWidget::PaletteBase );
00037     notesview->addColumn( "Notes" );
00038     notesview-> setRootIsDecorated(true);
00039     notesview->setAcceptDrops(true);
00040     pop.insertItem("Open", this, SLOT(slotOpen()));
00041     pop.insertItem("Open in new Window", this, SLOT(slotNewWindow()));
00042     pop.insertItem("New Item", this, SLOT(slotNewItem()));  
00043     
00044     connect(notesview, SIGNAL(rightButtonPressed(QListViewItem *, const QPoint &,int)),
00045             this, SLOT(slotPopupMenu(QListViewItem *, const QPoint &,int)));
00046     
00047     connect(notesview, SIGNAL(doubleClicked(QListViewItem *)),
00048             this, SLOT(slotSelected(QListViewItem*)));
00049     
00050     connect(notesview, SIGNAL(returnPressed(QListViewItem *)),
00051             this, SLOT(slotSelected(QListViewItem*)));
00052 }
00053 
00054 void NoteOverviewForm::setData(bool withpubls)
00055 {
00056     notesview->clear();
00057     QPtrList<noterec> n;
00058     QSqlQuery query("select no, title, type, publication_no, parent, sibling from note where type=0 order by title");
00059     while(query.next()) {
00060         noterec *r=new noterec;
00061         r->no=query.value(0).toInt();
00062         r->title=query.value(1).toString();
00063         r->type=query.value(2).toInt();
00064         r->publication_no=query.value(3).toInt();
00065         r->parent=query.value(4).toInt();
00066         r->sibling=query.value(5).toInt();
00067         n.append(r);
00068     }
00069     
00070     if(withpubls) {
00071         query.exec("select no into temporary table tmp_notetree from note where type=0");
00072         query.exec("select note.no, note.title, note.type, note.publication_no, link.obj_1 as parent, sibling from note, link, tmp_notetree where link.obj_2=note.no and link.obj_1 = tmp_notetree.no and note.type=1 union select note.no, note.title, note.type, note.publication_no, link.obj_2 as parent, sibling from note, link, tmp_notetree where link.obj_1=note.no and link.obj_2 = tmp_notetree.no and note.type=1");
00073         while(query.next()) {
00074             noterec *r=new noterec;
00075             r->no=query.value(0).toInt();
00076             r->title=query.value(1).toString();
00077             r->type=query.value(2).toInt();
00078             r->publication_no=query.value(3).toInt();
00079             r->parent=query.value(4).toInt();
00080             r->sibling=query.value(5).toInt();
00081             n.append(r);
00082         }
00083         query.exec("drop table tmp_notetree");
00084     }
00085     
00086     addItem(n, 0, 0L);
00087     notesview->geometry();
00088 }
00089 
00090 void NoteOverviewForm::addItem(QPtrList<noterec>& n, int parentoid, NoteTreeItem *parentitem) {
00091     QPtrListIterator<noterec> it(n);
00092     noterec *rec;
00093     while ((rec = it.current()) != 0 ) {
00094         ++it;
00095         if(rec->parent==parentoid) {
00096             NoteTreeItem *i;
00097             if(parentitem)
00098                 i=new NoteTreeItem(parentitem, LitUrl("lit://note/note?no="+QString().number(rec->no)), rec->title, loadPixmap(rec->type==1?"showpubl.png":"shownote.png"), rec->parent, rec->sibling);
00099             else
00100                 i=new NoteTreeItem(notesview, LitUrl("lit://note/note?no="+QString().number(rec->no)), rec->title, loadPixmap(rec->type==1?"showpubl.png":"shownote.png"), rec->parent, rec->sibling);
00101             i->setDragEnabled(rec->type==0);
00102             addItem(n, rec->no, i);
00103             n.remove(rec);
00104         }
00105     }
00106 }
00107 
00108 
00109 LitUrl NoteOverviewForm::url() {
00110     if(!notesview->currentItem()) return LitUrl();
00111     NoteTreeItem *i=dynamic_cast<NoteTreeItem*>(notesview->currentItem());
00112     Q_ASSERT(i);
00113     return i->url();
00114 }
00115 
00116 
00117 void NoteOverviewForm::open(bool newwin) {
00118     NoteTreeItem *i=dynamic_cast<NoteTreeItem*>(notesview->currentItem());
00119     Q_ASSERT(i);
00120     qApp->postEvent(topLevelWidget(), new UrlEvent(i->url(), newwin));
00121 }
00122 
00123 void NoteOverviewForm::slotSelected(QListViewItem *i) {
00124     open(false);
00125 }
00126 
00127 void NoteOverviewForm::slotOpen() {
00128     open(false);
00129 }
00130 
00131 void NoteOverviewForm::slotNewWindow() {
00132     open(true);
00133 }
00134 
00135 void NoteOverviewForm::slotNewItem() {
00136     NoteTreeItem *i=dynamic_cast<NoteTreeItem*>(notesview->currentItem());
00137     Q_ASSERT(i);
00138     QSqlQuery q("select create_toplevel_note(no) from "+i->url().fileName()+" where "+i->url().query());
00139    q.first();
00140    qApp->postEvent(topLevelWidget(), new UrlEvent(LitUrl("lit://note/note?no="+q.value(0).toString()), false));
00141 }
00142 
00143 
00144 void NoteOverviewForm::slotPopupMenu(QListViewItem *item, const QPoint& p, int c) {
00145     notesview->setCurrentItem(item);
00146     pop.popup(QCursor::pos());
00147 }

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