1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-03-20 02:07:23 +01:00

* ObjectEditor.cpp (changed): see #2335 "GUI switches between data

files upon closing editor panel". If user opened two data files in
the GUI and was in the process of editing objects in one of them,
the GUI would flip to the other file under certin circumstances.
This commit is contained in:
Vadim Kurland 2011-04-08 16:14:16 -07:00
parent 25f1ecb9e3
commit 1359e7bd2c
12 changed files with 70 additions and 61 deletions

View File

@ -1,3 +1,10 @@
2011-04-08 vadim <vadim@netcitadel.com>
* ObjectEditor.cpp (changed): see #2335 "GUI switches between data
files upon closing editor panel". If user opened two data files in
the GUI and was in the process of editing objects in one of them,
the GUI would flip to the other file under certin circumstances.
2011-04-07 vadim <vadim@netcitadel.com>
* PIXImporterNat.cpp (buildDNATRule): resolved several problems

View File

@ -94,6 +94,8 @@ FWCmdChange::~FWCmdChange()
void FWCmdChange::undo()
{
if (fwbdebug) qDebug() << "FWCmdChange::undo()";
FWObject* obj = getObject();
try
{
@ -108,6 +110,8 @@ void FWCmdChange::undo()
void FWCmdChange::redo()
{
if (fwbdebug) qDebug() << "FWCmdChange::redo()";
FWObject* obj = getObject();
try
{

View File

@ -452,6 +452,8 @@ void FWWindow::showSub(ProjectPanel *pp)
sub->setAttribute(Qt::WA_DeleteOnClose);
m_mainWindow->m_space->addSubWindow(sub);
connect( sub, SIGNAL(aboutToActivate()), pp, SLOT(aboutToActivate()));
if (fwbdebug)
qDebug() << "Show subwindow maximized: " << windows_maximized;
@ -1111,8 +1113,8 @@ QStringList FWWindow::getListOfOpenedFiles()
void FWWindow::activatePreviousSubWindow()
{
if (fwbdebug) qDebug() << "FWWindow::activatePreviousSubWindow()";
m_mainWindow->m_space->setActiveSubWindow(previous_subwindow);
//previous_subwindow->raise();
}
@ -1129,39 +1131,23 @@ void FWWindow::subWindowActivated(QMdiSubWindow *subwindow)
if (subwindow==NULL) return;
if (fwbdebug)
qDebug() << "FWWindow::subWindowActivated subwindow=" << subwindow
qDebug() << "FWWindow::subWindowActivated"
<< "subwindow=" << subwindow
<< "(" << subwindow->windowTitle() << ")"
<< "previous_subwindow=" << previous_subwindow
<< " "
<< subwindow->windowTitle()
<< "("
<< QString((previous_subwindow) ? previous_subwindow->windowTitle() : "")
<< ")"
<< "isMaximized()=" << subwindow->isMaximized();
if (previous_subwindow == subwindow) return;
// if (isEditorVisible() && !oe->validateAndSave())
// {
// // editor has unsaved data and user clicked "Continue editing"
// // Roll back switch of subwindows
// if (fwbdebug)
// qDebug() << "Activating previous subwindow "
// << previous_subwindow
// << " "
// << previous_subwindow->windowTitle();
// QTimer::singleShot(0, this, SLOT(activatePreviousSubWindow()));
// return;
// }
previous_subwindow = subwindow;
ProjectPanel *pp = dynamic_cast<ProjectPanel*>(subwindow->widget());
if (pp)
{
QCoreApplication::postEvent(mw, new updateGUIStateEvent());
//prepareFileMenu();
//prepareRulesMenu();
//updateGlobalToolbar();
pp->setActive();
if (isEditorVisible()) openEditor(pp->getSelectedObject());
}
@ -1371,6 +1357,9 @@ bool FWWindow::event(QEvent *event)
event->accept();
return true;
}
//if (fwbdebug) qDebug() << this << "event:" << event;
return QMainWindow::event(event);
}
@ -1379,8 +1368,11 @@ void FWWindow::selectActiveSubWindow(/*const QString & text*/)
QObject * sender_ = sender ();
QAction * act = (QAction*) sender_ ;
QString text = act->text();
if (text=="[Noname]")
text="";
if (text=="[Noname]") text="";
if (fwbdebug) qDebug() << "FWWindow::selectActiveSubWindow()"
<< "text=" << text;
for (int i = 0 ; i < windowsTitles.size();i++)
{
if (windowsTitles[i]==text)

View File

@ -147,7 +147,7 @@ public:
public slots:
void selectActiveSubWindow (/*const QString & text*/);
void subWindowActivated(QMdiSubWindow*);
void editorPanelTabChanged(int);
void minimize();

View File

@ -256,6 +256,9 @@ void NetworkDialog::applyChanges()
if (!cmd->getOldState()->cmp(new_state, true))
{
if (fwbdebug)
qDebug() << "Pushing FWCmdChange to undo stack";
if (obj->isReadOnly()) return;
m_project->undoStack->push(cmd.release());
}

View File

@ -358,7 +358,8 @@ void ObjectEditor::changed()
{
QWidget *s = dynamic_cast<QWidget*>(sender());
if (fwbdebug)
qDebug() << "ObjectEditor::changed() from " << s;
qDebug() << "ObjectEditor::changed() from " << s
<< "isVisible()=" << s->isVisible();
if (!validate())
{
@ -368,11 +369,34 @@ void ObjectEditor::changed()
}
emit applyChanges_sign();
if (!s->isVisible())
{
/*
* Pass focus to the ProjectPanel that is active at the moment
* to avoid switch described in #2335. Do this only if editor
* panel is invisible because we get changed() signal in other
* cases too, such as when user uses Tab to switch between
* input fields or clicks outside the editor.
*/
ProjectPanel *pp = mw->activeProject();
if (fwbdebug)
qDebug() << "ObjectEditor::changed() pass focus to active ProjectPanel"
<< "pp=" << pp;
if (pp) pp->setFocus(Qt::OtherFocusReason);
}
if (fwbdebug) qDebug() << "ObjectEditor::changed() done ";
}
bool ObjectEditor::validate()
{
if (fwbdebug) qDebug() << "ObjectEditor::validate()";
if (fwbdebug)
qDebug() << "ObjectEditor::validate()"
<< "isVisible()=" << getCurrentObjectDialog()->isVisible();
bool isgood = true;
emit validate_sign( &isgood );
return isgood;

View File

@ -65,6 +65,8 @@ void ObjectEditorDockWidget::closeEvent(QCloseEvent *event)
}
event->accept();
if (fwbdebug) qDebug() << "ObjectEditorDockWidget::closeEvent() done";
}
void ObjectEditorDockWidget::topLevelChanged(bool topLevel)

View File

@ -801,8 +801,6 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
bool &newMenuItem,
bool &inDeletedObjects)
{
if (fwbdebug) qDebug("ObjectManipulator::getMenuState");
inDeletedObjects = false;
if (m_project->db() == NULL)
@ -826,12 +824,8 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
FWObject *del_obj_library =
m_project->db()->findInIndex( FWObjectDatabase::DELETED_OBJECTS_ID);
if (fwbdebug) qDebug() << "ObjectManipulator::getMenuState del_obj_library=" << del_obj_library;
FWObject *current_library = getCurrentLib();
if (fwbdebug) qDebug() << "ObjectManipulator::getMenuState current_library=" << current_library;
if (getCurrentObjectTree()==NULL) return;
// delete, cut and copy menu items will be enabled only if all
@ -844,12 +838,6 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
{
FWObject *obj= *i;
if (fwbdebug)
qDebug() << "ObjectManipulator::getMenuState"
<< "obj=" << obj
<< "root=" << obj->getRoot()
<< "current_library root=" << current_library->getRoot();
QString object_path = obj->getPath(true).c_str();
if (parent == NULL) parent = obj->getParent();
@ -942,7 +930,6 @@ void ObjectManipulator::getMenuState(bool haveMoveTargets,
newMenuItem = false;
}
if (fwbdebug) qDebug("ObjectManipulator::getMenuState done");
}
bool ObjectManipulator::isCurrentObjectLockable()
@ -1366,11 +1353,6 @@ FWObject* ObjectManipulator::getCurrentLib()
FWObject *lib = libs_model->getLibrary(idx);
if (fwbdebug)
{
qDebug("ObjectManipulator::getCurrentLib(): idx=%d lib=%p", idx, lib);
}
return lib;
}

View File

@ -158,6 +158,7 @@ ProjectPanel::ProjectPanel(QWidget *parent):
connect(m_panel->topSplitter, SIGNAL(splitterMoved(int,int)),
this, SLOT(splitterPositionChanged(int,int)));
}
ProjectPanel::~ProjectPanel()
@ -1024,6 +1025,11 @@ void ProjectPanel::redrawRuleSets()
reopenFirewall();
}
void ProjectPanel::aboutToActivate()
{
if (fwbdebug) qDebug() << "ProjectPanel::aboutToActivate " << this;
}
void ProjectPanel::showEvent(QShowEvent *ev)
{
if (fwbdebug) qDebug() << "ProjectPanel::showEvent " << this

View File

@ -294,6 +294,8 @@ public:
void updateObjectInTree();
void reloadTree();
void aboutToActivate();
#if QT_VERSION < 0x040500
void setTreeDockPosition();
#endif

View File

@ -440,6 +440,8 @@ bool ProjectPanel::event(QEvent *event)
return false;
}
//if (fwbdebug) qDebug() << this << "event:" << event;
return QWidget::event(event);
}

View File

@ -77,11 +77,6 @@ bool ListOfLibrariesModel::insertRows(int row, int count, const QModelIndex & pa
bool ListOfLibrariesModel::removeRows(int row, int count, const QModelIndex &parent)
{
if (fwbdebug)
qDebug() << "ListOfLibrariesModel::removeRows"
<< "row=" << row
<< "count=" << count;
int c = count;
while (c > 0)
{
@ -89,9 +84,6 @@ bool ListOfLibrariesModel::removeRows(int row, int count, const QModelIndex &par
c--;
}
if (fwbdebug)
qDebug() << "ListOfLibrariesModel::removeRows 2";
return QStringListModel::removeRows(row, count, parent);
}
@ -142,10 +134,6 @@ void ListOfLibrariesModel::sort(int column, Qt::SortOrder order)
QModelIndex ListOfLibrariesModel::getIdxForLib(FWObject* lib)
{
if (fwbdebug)
qDebug() << "ListOfLibrariesModel::getIdxForLib"
<< "lib=" << lib->getName().c_str();
for (int i=0; i<rowCount(); ++i)
{
QModelIndex idx = index(i, 0);
@ -154,7 +142,6 @@ QModelIndex ListOfLibrariesModel::getIdxForLib(FWObject* lib)
FWObject *l = getLibrary(idx);
if (l && l->getId() == lib->getId())
{
if (fwbdebug) qDebug() << "Index=" << i;
return idx;
}
}
@ -170,7 +157,6 @@ FWObject* ListOfLibrariesModel::getLibrary(QModelIndex idx)
FWObject* ListOfLibrariesModel::getLibrary(int row)
{
if (fwbdebug) qDebug() << "ListOfLibrariesModel::getLibrary row=" << row;
if (row < 0 || row >= items.size()) return NULL;
return items[row].lib;
}
@ -182,7 +168,6 @@ ObjectTreeView* ListOfLibrariesModel::getTreeWidget(QModelIndex idx)
ObjectTreeView* ListOfLibrariesModel::getTreeWidget(int row)
{
if (fwbdebug) qDebug() << "ListOfLibrariesModel::getTreeWidget row=" << row;
if (row < 0 || row >= items.size()) return NULL;
return items[row].tree;
}