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

filllinklistbox.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   filllinklistbox.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 "filllinklistbox.h"
00018 #include "linklistbox.h"
00019 #include <qthread.h>
00020 #include <qapplication.h>
00021 #include "linklistboxitem.h"
00022 #include <qsqlcursor.h>
00023 #include <qsqldatabase.h>
00024 #include "dbdata.h"
00025 #include "error.h"
00026 #include <qmessagebox.h>
00027 #include "threadfinishedevent.h"
00028 #include "threadlinkevent.h"
00029 
00030 QMutex filllinklistboxmutex;
00031 
00032 FillLinkListBox::FillLinkListBox(QObject *parent, QString name, LinkListBox *box, QString query, QString cmd, QPixmap pm, QListViewItem *parentitem):  parent(parent), name(name), box(box), query(query), cmd(cmd), pixm(pm), parentitem(parentitem) {   
00033 }
00034 
00035 FillLinkListBox::~FillLinkListBox() {
00036  }
00037 
00038 
00039 void FillLinkListBox::run() {
00040   while(filllinklistboxmutex.locked()) {
00041     //    qDebug("FillLinkListBox::run(): Locked - "+query);
00042     msleep(10);
00043   }
00044 
00045   QMutexLocker locker(&filllinklistboxmutex);
00046   //  qDebug("FillLinkListBox::run(): running - "+query);
00047   
00048   try {
00049         
00050     QSqlDatabase *conn=QSqlDatabase::database("threadConnection");
00051     QSqlQuery q(query, conn);
00052     if(!q.isActive()) 
00053       throw(Error(conn->lastError()));
00054         
00055     QSqlRecord r=conn->record(q);
00056     Q_ASSERT(r.position("no")!=-1);
00057     while(q.next()) {
00058       QString str;
00059       for(unsigned int i=0; i<r.count(); i++) 
00060         if(r.fieldName(i)!="no")         
00061           str+=q.value(i).toString()+" ";
00062             
00063       QApplication::postEvent(parent, new ThreadLinkEvent(box, str, LitUrl("lit://"+cmd+"?no="+q.value(r.position("no")).toString()), pixm, parentitem));
00064       
00065     }
00066     
00067   } catch(Error e) {
00068     qApp->lock();
00069     QMessageBox::warning(0L, "Error", e.message());
00070     qApp->unlock();
00071   }
00072   //  qDebug("FillLinkListBox::run(): return - "+query);  
00073 }

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