1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-03-23 19:57:21 +01:00

using native dialog for fileOpen

This commit is contained in:
Vadim Kurland 2008-06-23 19:04:13 +00:00
parent ea1b115cf9
commit b7b9f9b94b
8 changed files with 22 additions and 180 deletions

View File

@ -1 +1 @@
#define BUILD_NUM 301
#define BUILD_NUM 10

View File

@ -42,8 +42,6 @@
#include "listOfLibraries.h"
#include "ObjConflictResolutionDialog.h"
#include "RuleSetView.h"
#include "RCSFileDialog.h"
#include "RCSFilePreview.h"
#include "ObjectEditor.h"
#include "execDialog.h"
#include "PrefsDialog.h"

View File

@ -42,7 +42,6 @@
#include "listOfLibraries.h"
#include "ObjConflictResolutionDialog.h"
#include "RuleSetView.h"
#include "RCSFileDialog.h"
#include "RCSFilePreview.h"
#include "ObjectEditor.h"
#include "execDialog.h"
@ -679,7 +678,8 @@ QString ProjectPanel::getDestDir(const QString &fname)
}
QString ProjectPanel::chooseNewFileName(const QString &fname,
bool checkPresence,const QString &title)
bool checkPresence,
const QString &title)
{
QString destdir = getDestDir(fname);
@ -766,13 +766,22 @@ bool ProjectPanel::fileOpen()
{
if (fwbdebug) qDebug("ProjectPanel::fileOpen(): start");
RCSFileDialog fd(this, 0, true);
QString dir;
dir=st->getWDir();
if (dir.isEmpty()) dir=st->getOpenFileDir();
if (dir.isEmpty()) dir=userDataDir.c_str();
QString fileName = QFileDialog::getOpenFileName(
mainW,
tr("Open File"),
dir,
tr("FWB files (*.fwb *.fwl *.xml);;All Files (*)"));
if (fileName.isEmpty()) return false;
RCSFilePreview fp(this);
if ( fd.exec() != QDialog::Accepted )
return false;
bool hasRCS = fp.showFileRLog( fd.selectedFiles()[0] );
bool hasRCS = fp.showFileRLog(fileName);
if ( (!hasRCS) || (fp.exec() == QDialog::Accepted) )
{
@ -782,10 +791,10 @@ bool ProjectPanel::fileOpen()
//try to get simple rcs instance from RCS preview
RCS *rcs = fp.getSelectedRev();
//if (by some matter) preview cannot give RCS,
//if preview cannot give RCS,
//get a new RCS from file dialog
if (rcs==NULL)
rcs = fd.getSelectedRev();
rcs = new RCS(fileName);
//if RCS isn't still formed, it's an error
if (rcs==NULL)
@ -932,8 +941,9 @@ void ProjectPanel::fileSaveAs()
rcs = new RCS("");
QString nfn=chooseNewFileName(oldFileName,true,
tr("Choose name and location for the file"));
QString nfn = chooseNewFileName(
oldFileName, true,
tr("Choose name and location for the file"));
if (!nfn.isEmpty())
{

View File

@ -1,110 +0,0 @@
/*
Firewall Builder
Copyright (C) 2003 NetCitadel, LLC
Author: Vadim Kurland vadim@fwbuilder.org
$Id: RCSFileDialog.cpp,v 1.16 2006/10/22 00:09:08 vkurland Exp $
This program is free software which we release under the GNU General Public
License. You may redistribute and/or modify this program under the terms
of that license as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To get a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "fwbuilder_ph.h"
#include "config.h"
#include "global.h"
#include "FWBSettings.h"
#include "RCSFileDialog.h"
#include "RCSFilePreview.h"
#include "RCS.h"
#include <qsplitter.h>
#include <iostream>
using namespace std;
RCSFileDialog::RCSFileDialog( const QString& dirName, const QString& filter,
QWidget* parent, const char* name, bool )
: QFileDialog( parent, name, dirName, filter )
{
if (fwbdebug) qDebug("RCSFileDialog: constructor 1");
QStringList qsl;
qsl << "Firewall Builder 4 (2) files (*.fwb)"
<< "Firewall Builder 4 (2) library files (*.fwl)"
<< "Old Firewall Builder files (*.xml)";
setFilters(qsl);
setFileMode( QFileDialog::ExistingFile );
resize( QSize(700, 350) );
QString dir;
dir=st->getWDir();
if (dir.isEmpty()) dir=st->getOpenFileDir();
if (!dir.isEmpty()) setDirectory( dir );
if (fwbdebug) qDebug("RCSFileDialog: checkpoint 1");
/*************************************/
if (fwbdebug) qDebug("RCSFileDialog: constructor done");
}
RCSFileDialog::RCSFileDialog( QWidget* parent, const char* , bool )
: QFileDialog(parent, "Open file")// name
{
if (fwbdebug) qDebug("RCSFileDialog: constructor 2");
QStringList qsl;
qsl << "Firewall Builder 4 (2) files (*.fwb)"
<< "Firewall Builder 4 (2) library files (*.fwl)"
<< "Old Firewall Builder files (*.xml)";
setFilters(qsl);
resize( QSize(700, 350) );
QString dir;
dir=st->getWDir();
if (dir.isEmpty()) dir=st->getOpenFileDir();
if (dir.isEmpty()) dir=userDataDir.c_str();
if (!dir.isEmpty()) setDirectory( dir );
if (fwbdebug) qDebug("RCSFileDialog: constructor done");
}
void RCSFileDialog::accept()
{
st->setOpenFileDir( directory().absolutePath() );
QFileDialog::accept();
}
RCS* RCSFileDialog::getSelectedRev()
{
/*RCS *preview_rcs = preview->getSelectedRev();
if (preview_rcs!=NULL && preview_rcs->getFileName()==selectedFile())
return preview_rcs; */
RCS *rcs = new RCS(selectedFiles()[0]);
return rcs;
}

View File

@ -1,52 +0,0 @@
/*
Firewall Builder
Copyright (C) 2003 NetCitadel, LLC
Author: Vadim Kurland vadim@fwbuilder.org
$Id: RCSFileDialog.h,v 1.3 2006/10/17 06:09:25 vkurland Exp $
This program is free software which we release under the GNU General Public
License. You may redistribute and/or modify this program under the terms
of that license as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To get a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __RCSFILEDIALOG_H_
#define __RCSFILEDIALOG_H_
#include "RCS.h"
#include <qfiledialog.h>
#include <qlistview.h>
class RCSFileDialog : public QFileDialog {
Q_OBJECT
public:
RCSFileDialog( const QString& dirName, const QString& filter = QString::null,
QWidget* parent=0, const char* name=0, bool modal = FALSE );
RCSFileDialog( QWidget* parent=0, const char* name=0, bool modal = FALSE );
RCS* getSelectedRev();
protected slots:
virtual void accept();
};
#endif

View File

@ -30,7 +30,6 @@
#include <RCS.h>
#include <RCSFilePreview.h>
#include <RCSFileDialog.h>
#include "fwbuilder/libfwbuilder-config.h"
#include "fwbuilder/FWException.h"

View File

@ -34,7 +34,6 @@
#include <map>
class RCSFileDialog;
class RCSViewItem : public QTreeWidgetItem {

View File

@ -43,7 +43,6 @@ HEADERS += ../../config.h \
FWBSettings.h \
FWBTree.h \
RCS.h \
RCSFileDialog.h \
RCSFilePreview.h \
FWObjectClipboard.h \
platforms.h \
@ -157,7 +156,6 @@ SOURCES += ProjectPanel.cpp \
FWBSettings.cpp \
FWBTree.cpp \
RCS.cpp \
RCSFileDialog.cpp \
RCSFilePreview.cpp \
FWObjectClipboard.cpp \
platforms.cpp \