Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reverted hazardous changes been made recently

  • Loading branch information...
commit 31c034c80653f3f6dac821a7630186b443cc31ba 1 parent 7450f5f
mezomish authored
View
4 ChangeLog
@@ -1,7 +1,3 @@
-2010-08-12 :
-* Fixed: empty panel when closing the last tab
-* Fixed: empty second panel when running the app
-
2010-08-10 :
* Fixed: loosing selection when unindenting text
View
2  include/DocHandlerInt.h
@@ -44,7 +44,7 @@ class DocHandlerInt {
/**
* Opens a document with a given file name or activates it if it is already opened.
*/
- virtual void openDoc(const QString&, int panel = -1) = 0;
+ virtual void openDoc(const QString&) = 0;
/**
* Closes the document with a given file name.
View
47 src/app/JuffEd.cpp
@@ -384,35 +384,21 @@ void JuffEd::slotFileClose() {
if ( doc->isNull() )
return;
- if ( !MainSettings::get(MainSettings::ExitOnLastDocClosed)&& docCount() == 1 && Juff::isNoname(doc) && !doc->isModified() )
- return;
-
closeDocWithConfirmation(doc);
- if ( docCount() == 0 ) {
- if ( MainSettings::get(MainSettings::ExitOnLastDocClosed) )
- slotFileExit();
- else
- slotFileNew();
- }
+ if ( docCount() == 0 && MainSettings::get(MainSettings::ExitOnLastDocClosed) )
+ slotFileExit();
}
void JuffEd::slotFileCloseAll() {
LOGGER;
Juff::Document* doc = curDoc();
- if ( !MainSettings::get(MainSettings::ExitOnLastDocClosed) && docCount() == 1 && Juff::isNoname(doc) && !doc->isModified() )
- return;
-
while ( !doc->isNull() ) {
if ( !closeDocWithConfirmation(doc) )
break;
doc = curDoc();
}
- if ( MainSettings::get(MainSettings::ExitOnLastDocClosed) )
- slotFileExit();
- else
- slotFileNew();
}
void JuffEd::slotFileSaveAll() {
@@ -957,7 +943,7 @@ void JuffEd::onMessageReceived(const QString& msg) {
}
-Juff::Document* JuffEd::createDoc(const QString& fileName, int panel) {
+Juff::Document* JuffEd::createDoc(const QString& fileName) {
LOGGER;
Juff::Document* doc;
@@ -968,7 +954,7 @@ Juff::Document* JuffEd::createDoc(const QString& fileName, int panel) {
if ( !doc->isNull() ) {
initDoc(doc);
- viewer_->addDoc(doc, panel);
+ viewer_->addDoc(doc);
if ( prj_->name().isEmpty() )
prj_->addFile(doc->fileName());
updateGUI(doc);
@@ -1039,24 +1025,11 @@ Juff::Project* JuffEd::curPrj() const {
return prj_;
}
-void JuffEd::openDoc(const QString& fileName, int panel) {
+void JuffEd::openDoc(const QString& fileName) {
LOGGER;
- Juff::Document* doc = NULL;
- if ( !viewer_->activateDoc(fileName) ) {
- int curPanel = viewer_->currentPanel();
-
- // check if there is only one doc, if it's Noname and if it's unmodified
- if ( viewer_->docCount(curPanel) == 1 ) {
- doc = viewer_->docList(curPanel)[0];
- if ( doc->isModified() || !Juff::isNoname(doc) )
- doc = NULL;
- }
- createDoc(fileName, panel);
-
- if ( doc != NULL )
- closeDocWithConfirmation(doc);
- }
+ if ( !viewer_->activateDoc(fileName) )
+ createDoc(fileName);
}
void JuffEd::closeDoc(const QString& fileName) {
@@ -1326,10 +1299,8 @@ void JuffEd::loadProject() {
openDoc(file);
}
- if ( viewer_->docCount(0) == 0 )
- createDoc("", 0);
- if ( viewer_->docCount(1) == 0 )
- createDoc("", 1);
+ if ( docCount() == 0 )
+ slotFileNew();
}
QString JuffEd::openDialogDirectory() const {
View
4 src/app/JuffEd.h
@@ -53,7 +53,7 @@ Q_OBJECT
virtual Juff::Document* curDoc() const;
virtual Juff::Document* getDoc(const QString&) const;
virtual Juff::Project* curPrj() const;
- virtual void openDoc(const QString&, int panel = -1);
+ virtual void openDoc(const QString&);
virtual void closeDoc(const QString&);
virtual void saveDoc(const QString&);
virtual int docCount() const;
@@ -134,7 +134,7 @@ private slots:
* This methods opens or activates a doc with given file
* name or creates a new empty doc if \param fileName is empty.
*/
- Juff::Document* createDoc(const QString& fileName, int panel = -1);
+ Juff::Document* createDoc(const QString& fileName);
void createProject(const QString& fileName);
bool closeProject();
View
51 src/app/ui/DocViewer.cpp
@@ -83,16 +83,7 @@ DocViewer::DocViewer(Juff::DocHandlerInt* handler) : QWidget(), ctrlTabMenu_(thi
ctrlTabMenu_.installEventFilter(this);
}
-int DocViewer::currentPanel() const {
- if ( curTab_ == tab1_ )
- return 0;
- else if ( curTab_ == tab2_ )
- return 1;
- else
- return -1;
-}
-
-void DocViewer::addDoc(Juff::Document* doc, int panel) {
+void DocViewer::addDoc(Juff::Document* doc) {
LOGGER;
connect(doc, SIGNAL(modified(bool)), SLOT(onDocModified(bool)));
@@ -102,22 +93,12 @@ void DocViewer::addDoc(Juff::Document* doc, int panel) {
// same line below it.
connect(doc, SIGNAL(focused()), SLOT(onDocFocused()));
- switch ( panel ) {
- case 0 :
- addDoc(doc, tab1_);
- break;
- case 1 :
- addDoc(doc, tab2_);
- break;
- default:
- addDoc(doc, curTab_);
- }
+ addDoc(doc, curTab_);
// It's better to have it after adding to TabWidget to avoid
// emitting the signal 'docActivated()' during the document creation.
// connect(doc, SIGNAL(focused()), SLOT(onDocFocused()));
- docStack_.removeAll(doc);
docStack_.prepend(doc);
}
@@ -134,14 +115,14 @@ Juff::Document* DocViewer::currentDoc() const {
}
Juff::Document* DocViewer::document(const QString& fileName) const {
- QList<Juff::Document*> docs = docList(0);
+ QList<Juff::Document*> docs = docList(1);
foreach (Juff::Document* doc, docs) {
if ( doc->fileName() == fileName ) {
return doc;
}
}
- docs = docList(1);
+ docs = docList(2);
foreach (Juff::Document* doc, docs) {
if ( doc->fileName() == fileName ) {
return doc;
@@ -152,23 +133,18 @@ Juff::Document* DocViewer::document(const QString& fileName) const {
}
bool DocViewer::activateDoc(const QString& fileName) {
- QList<Juff::Document*> docs = docList(0);
+ QList<Juff::Document*> docs = docList(1);
foreach (Juff::Document* doc, docs) {
if ( doc->fileName() == fileName ) {
- if ( tab1_->width() == 0 ) {
- spl_->setSizes(QList<int>() << spl_->width() / 2 << spl_->width() / 2);
- }
tab1_->setCurrentWidget(doc);
doc->setFocus();
return true;
}
}
- docs = docList(1);
+ docs = docList(2);
foreach (Juff::Document* doc, docs) {
if ( doc->fileName() == fileName ) {
- if ( tab2_->width() == 0 )
- spl_->setSizes(QList<int>() << spl_->width() / 2 << spl_->width() / 2);
tab2_->setCurrentWidget(doc);
doc->setFocus();
return true;
@@ -181,11 +157,12 @@ bool DocViewer::activateDoc(const QString& fileName) {
int DocViewer::docCount(int panel) const {
switch (panel) {
case 0 :
- return tab1_->count();
+ return tab1_->count() + tab2_->count();
case 1 :
+ return tab1_->count();
+ case 2 :
return tab2_->count();
- default :
- return tab1_->count() + tab2_->count();
+ default: return 0;
}
}
@@ -193,7 +170,7 @@ QList<Juff::Document*> DocViewer::docList(int panel) const {
QList<Juff::Document*> list;
// 1st panel
- if ( panel == -1 || panel == 0 ) {
+ if ( panel == 0 || panel == 1 ) {
int n = tab1_->count();
for (int i = 0; i < n; ++i) {
Juff::Document* doc = qobject_cast<Juff::Document*>(tab1_->widget(i));
@@ -202,7 +179,7 @@ QList<Juff::Document*> DocViewer::docList(int panel) const {
}
}
// 2nd panel
- if ( panel == -1 || panel == 1 ) {
+ if ( panel == 0 || panel == 2 ) {
int n = tab2_->count();
for (int i = 0; i < n; ++i) {
Juff::Document* doc = qobject_cast<Juff::Document*>(tab2_->widget(i));
@@ -216,7 +193,7 @@ QList<Juff::Document*> DocViewer::docList(int panel) const {
QStringList DocViewer::docNamesList(int panel) const {
QStringList list;
// 1st panel
- if ( panel == -1 || panel == 0 ) {
+ if ( panel == 0 || panel == 1 ) {
int n = tab1_->count();
for (int i = 0; i < n; ++i) {
Juff::Document* doc = qobject_cast<Juff::Document*>(tab1_->widget(i));
@@ -225,7 +202,7 @@ QStringList DocViewer::docNamesList(int panel) const {
}
}
// 2nd panel
- if ( panel == -1 || panel == 1 ) {
+ if ( panel == 0 || panel == 2 ) {
int n = tab2_->count();
for (int i = 0; i < n; ++i) {
Juff::Document* doc = qobject_cast<Juff::Document*>(tab2_->widget(i));
View
28 src/app/ui/DocViewer.h
@@ -35,40 +35,38 @@ class DocViewer : public QWidget {
Q_OBJECT
public:
DocViewer(Juff::DocHandlerInt*);
- void addDoc(Juff::Document*, int panel = -1);
+ void addDoc(Juff::Document*);
void removeDoc(Juff::Document*);
Juff::Document* currentDoc() const;
Juff::Document* document(const QString&) const;
bool activateDoc(const QString&);
- int currentPanel() const;
-
/**
* Returns the number of documents opened at a specific panel or at both panels.
- * If \param panel == -1 then returns the number of ALL documents
- * If \param panel == 0 then returns the number of documents opened at the 1st panel
- * If \param panel == 1 then returns the number of documents opened at the 2nd panel
+ * If \param panel == 0 then returns the number of ALL documents
+ * If \param panel == 1 then returns the number of documents opened at the 1st panel
+ * If \param panel == 2 then returns the number of documents opened at the 2nd panel
* Otherwise returns 0
*/
- int docCount(int panel = -1) const;
+ int docCount(int panel = 0) const;
/**
* Returns the list of documents opened at a specific panel or at both panels.
- * If \param panel == -1 then returns ALL documents
- * If \param panel == 0 then returns documents opened at the 1st panel
- * If \param panel == 1 then returns documents opened at the 2nd panel
+ * If \param panel == 0 then returns ALL documents
+ * If \param panel == 1 then returns documents opened at the 1st panel
+ * If \param panel == 2 then returns documents opened at the 2nd panel
* Otherwise returns an empty list
*/
- QList<Juff::Document*> docList(int panel = -1) const;
+ QList<Juff::Document*> docList(int panel = 0) const;
/**
* Returns the list of document names opened at a specific panel or at both panels.
- * If \param panel == -1 then returns names of ALL documents
- * If \param panel == 0 then returns names of documents opened at the 1st panel
- * If \param panel == 1 then returns names of documents opened at the 2nd panel
+ * If \param panel == 0 then returns names of ALL documents
+ * If \param panel == 1 then returns names of documents opened at the 1st panel
+ * If \param panel == 2 then returns names of documents opened at the 2nd panel
* Otherwise returns an empty list
*/
- QStringList docNamesList(int panel = -1) const;
+ QStringList docNamesList(int panel = 0) const;
void applySettings();
View
12 src/app/ui/TabWidget.cpp
@@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Functions.h"
#include "IconManager.h"
#include "Log.h"
-#include "MainSettings.h"
#include "Project.h"
#include "TabBar.h"
@@ -171,12 +170,7 @@ void TabWidget::onTabCloseRequested(int index) {
QWidget* tab = widget(index);
Juff::Document* doc = qobject_cast<Juff::Document*>(tab);
if ( doc != 0 ) {
- if ( !MainSettings::get(MainSettings::ExitOnLastDocClosed) && count() == 1 && Juff::isNoname(doc) && !doc->isModified() ) {
- return;
- }
- else {
- handler_->closeDoc(doc->fileName());
- }
+ handler_->closeDoc(doc->fileName());
}
}
@@ -219,10 +213,8 @@ void TabWidget::tabRemoved(int) {
emit tabRemoved(this);
- if ( count() == 0 ) {
- handler_->openDoc("", selfIndex_);
+ if ( count() == 0 )
docListBtn_->hide();
- }
}
Please sign in to comment.
Something went wrong with that request. Please try again.