lib/SymbolDialog.cpp

Go to the documentation of this file.
00001 /*
00002  *  Qtstalker stock charter
00003  *
00004  *  Copyright (C) 2001-2007 Stefan S. Stratigakos
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00019  *  USA.
00020  */
00021 
00022 #include "SymbolDialog.h"
00023 
00024 SymbolDialog::SymbolDialog (QWidget *w,QString &bp,QString &dir,QString &filter,QFileDialog::Mode mode) :
00025                            QFileDialog (dir, filter, w, "SymbolDialog", TRUE)
00026 {
00027   basePath = bp;
00028   setMode(mode);
00029   connect(this, SIGNAL(dirEntered(const QString &)), this, SLOT(dirSelected(const QString &)));
00030   keyFlag = FALSE;
00031 }
00032 
00033 SymbolDialog::~SymbolDialog ()
00034 {
00035 }
00036 
00037 void SymbolDialog::dirSelected (const QString &d)
00038 {
00039   if (mode() == QFileDialog::DirectoryOnly)
00040   {
00041     blockSignals(TRUE);
00042     setDir(basePath);
00043     blockSignals(FALSE);
00044     return;
00045   }
00046   
00047   if (d.length() < basePath.length())
00048   {
00049     blockSignals(TRUE);
00050     setDir(basePath);
00051     blockSignals(FALSE);
00052   }
00053 }
00054 
00055 void SymbolDialog::setKeyFlag (bool d)
00056 {
00057   keyFlag = d;
00058 }
00059 
00060 void SymbolDialog::keyPressEvent (QKeyEvent *key)
00061 {
00062   if (keyFlag)
00063     emit signalKeyPressed (type, key->state(), key->key(), key->ascii(), key->text());
00064     
00065   doKeyPress(key);  
00066 }
00067 
00068 void SymbolDialog::doKeyPress (QKeyEvent *key)
00069 {
00070   key->accept();
00071   QFileDialog::keyPressEvent(key);
00072 }
00073 
00074 void SymbolDialog::setType (int d)
00075 {
00076   type = d;
00077 }
00078