| Summary: | Order of editor tabs not retained as it was before closing | ||
|---|---|---|---|
| Product: | [Applications] kile | Reporter: | gero <gero> |
| Component: | general | Assignee: | Jeroen Wijnhout <spam> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | 1.8.1 | ||
| Target Milestone: | --- | ||
| Platform: | Ubuntu | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
gero
2006-04-19 13:23:59 UTC
SVN commit 637087 by mludwig:
- Re-open files in the correct order.
- Save the order in which project files were opened.
BUG: 125878
M +1 -1 TODO-2.0.txt
M +12 -10 kile/kile.cpp
M +79 -15 kile/kiledocmanager.cpp
M +11 -3 kile/kiledocmanager.h
M +9 -1 kile/kileproject.cpp
M +4 -0 kile/kileproject.h
M +22 -1 kile/kileviewmanager.cpp
M +3 -0 kile/kileviewmanager.h
--- trunk/extragear/office/kile/TODO-2.0.txt #637086:637087
@@ -3,7 +3,7 @@
- use kde standard for double/single mouse click in kfileselct.cpp [tbraun WORKSFORME]
- #112735 cmd. completion takes always precedence over bibtex compl
- #132143 autosave: get rid of annyoing copy dialog [CANTFIX as stated by mludwig]
- - #125878 Order of editor tabs not retained as it was before closing
+ - #125878 Order of editor tabs not retained as it was before closing [mludwig FIXED]
- #119554 file open error: use Log & Messages View instead of Messa...
- handle files included by multiple root docs in one project better (codecompletion, ...)
to inspect:
--- trunk/extragear/office/kile/kile/kile.cpp #637086:637087
@@ -1,8 +1,8 @@
-/***************************************************************************
+/****************************************************************************************
begin : sam jui 13 09:50:06 CEST 2002
- copyright : (C) 2003 by Jeroen Wijnhout
- email : Jeroen.Wijnhout@kdemail.net
- ***************************************************************************/
+ copyright : (C) 2003 by Jeroen Wijnhout (Jeroen.Wijnhout@kdemail.net)
+ (C) 2007 by Michel Ludwig (michel.ludwig@kdemail.net)
+ ****************************************************************************************/
/***************************************************************************
* *
@@ -745,7 +745,8 @@
for (uint i=0; i < m_listProjectsOpenOnStart.count(); ++i)
{
fi.setFile(m_listProjectsOpenOnStart[i]);
- if (fi.isReadable()) docManager()->projectOpen(KURL::fromPathOrURL(m_listProjectsOpenOnStart[i]), i, m_listProjectsOpenOnStart.count());
+ // don't open project files as they will be opened later in this method
+ if (fi.isReadable()) docManager()->projectOpen(KURL::fromPathOrURL(m_listProjectsOpenOnStart[i]), i, m_listProjectsOpenOnStart.count(), false);
}
for (uint i=0; i < m_listDocsOpenOnStart.count(); ++i)
@@ -990,6 +991,11 @@
m_listProjectsOpenOnStart.clear();
m_listDocsOpenOnStart.clear();
+ for (uint i=0; i < viewManager()->textViews().count(); ++i)
+ {
+ m_listDocsOpenOnStart.append(viewManager()->textView(i)->getDoc()->url().path());
+ }
+
kdDebug() << "#projects = " << docManager()->projects()->count() << endl;
for (uint i=0; i < docManager()->projects()->count(); ++i)
{
@@ -1001,11 +1007,7 @@
if (stage1)
{
- for (uint i=0; i < viewManager()->textViews().count(); ++i)
- {
- m_listDocsOpenOnStart.append(viewManager()->textView(i)->getDoc()->url().path());
- }
- stage2 =docManager()->fileCloseAll();
+ stage2 = docManager()->fileCloseAll();
}
return stage1 && stage2;
--- trunk/extragear/office/kile/kile/kiledocmanager.cpp #637086:637087
@@ -5,7 +5,7 @@
//
//
// Author: Jeroen Wijnhout <Jeroen.Wijnhout@kdemail.net>, (C) 2004
-// Michel Ludwig <michel.ludwig@kdemail.net>, (C) 2006
+// Michel Ludwig <michel.ludwig@kdemail.net>, (C) 2006, 2007
//
/***************************************************************************
@@ -484,7 +484,7 @@
return doc;
}
-Kate::View* Manager::loadItem(KileDocument::Type type, KileProjectItem *item, const QString & text)
+Kate::View* Manager::loadItem(KileDocument::Type type, KileProjectItem *item, const QString & text, bool openProjectItemViews)
{
Kate::View *view = 0L;
@@ -492,7 +492,7 @@
if ( item->type() != KileProjectItem::Image )
{
- view = loadText(type, QString::null, item->url(), item->encoding(), item->isOpen(), item->highlight(), text);
+ view = loadText(type, QString::null, item->url(), item->encoding(), openProjectItemViews && item->isOpen(), item->highlight(), text);
kdDebug() << "\tloadItem: docfor = " << docFor(item->url().path()) << endl;
TextInfo *docinfo = textInfoFor(item->url().path());
@@ -1196,7 +1196,7 @@
}
}
-void Manager::projectOpenItem(KileProjectItem *item)
+void Manager::projectOpenItem(KileProjectItem *item, bool openProjectItemViews)
{
kdDebug() << "==Kile::projectOpenItem==========================" << endl;
kdDebug() << "\titem:" << item->url().path() << endl;
@@ -1204,7 +1204,7 @@
if (m_ki->isOpen(item->url())) //remove item from projectview (this file was opened before as a normal file)
emit removeFromProjectView(item->url());
- Kate::View *view = loadItem(determineFileType(item->url()), item);
+ Kate::View *view = loadItem(determineFileType(item->url()), item, QString::null, openProjectItemViews);
if ( (!item->isOpen()) && (view == 0L) && (item->getInfo()) ) //doc shouldn't be displayed, trash the doc
trashDoc(item->getInfo());
@@ -1216,7 +1216,7 @@
item->setOpenState(true);
}
-KileProject* Manager::projectOpen(const KURL & url, int step, int max)
+KileProject* Manager::projectOpen(const KURL & url, int step, int max, bool openProjectItemViews)
{
kdDebug() << "==Kile::projectOpen==========================" << endl;
kdDebug() << "\tfilename: " << url.fileName() << endl;
@@ -1262,11 +1262,43 @@
project_steps *= step;
m_kpd->progressBar()->setValue(project_steps);
- for ( uint i=0; i < list->count(); ++i)
+ // open the project files in the correct order
+ QValueVector<KileProjectItem*> givenPositionVector(list->count(), NULL);
+ QValueList<KileProjectItem*> notCorrectlyOrderedList;
+ for(KileProjectItem *item = list->first(); item; item = list->next())
{
- projectOpenItem(list->at(i));
- m_kpd->progressBar()->setValue(i + project_steps);
+ int order = item->order();
+ if(!item->isOpen() || order < 0 || givenPositionVector[order] != NULL)
+ {
+ notCorrectlyOrderedList.push_back(item);
+ }
+ else
+ {
+ givenPositionVector[order] = item;
+ }
+ }
+
+ QValueList<KileProjectItem*> orderedList;
+ for(unsigned int i = 0; i < givenPositionVector.size(); ++i)
+ {
+ KileProjectItem *item = givenPositionVector[i];
+ if(item)
+ {
+ orderedList.push_back(item);
+ }
+ }
+ for(QValueList<KileProjectItem*>::iterator i = notCorrectlyOrderedList.begin(); i != notCorrectlyOrderedList.end(); ++i)
+ {
+ orderedList.push_back(*i);
+ }
+
+ unsigned int counter = 0;
+ for (QValueList<KileProjectItem*>::iterator i = orderedList.begin(); i != orderedList.end(); ++i)
+ {
+ projectOpenItem(*i, openProjectItemViews);
+ m_kpd->progressBar()->setValue(counter + project_steps);
kapp->processEvents();
+ ++counter;
}
kp->buildProjectTree();
@@ -1322,15 +1354,47 @@
if (project)
{
KileProjectItemList *list = project->items();
- Kate::Document *doc = 0L;
+ Kate::Document *doc = NULL;
+ KileProjectItem *item = NULL;
+ TextInfo *docinfo = NULL;
- KileProjectItem *item = 0L;
- TextInfo *docinfo = 0L;
+ // determine the order in which the project items are opened
+ QValueVector<KileProjectItem*> viewPositionVector(m_ki->viewManager()->getTabCount(), NULL);
+ for (KileProjectItemList::iterator i = list->begin(); i != list->end(); ++i)
+ {
+ docinfo = (*i)->getInfo();
+ if(docinfo)
+ {
+ doc = docinfo->getDoc();
+ if(doc)
+ {
+ Kate::View *view = m_ki->viewManager()->textView(doc);
+ if(view)
+ {
+ int position = m_ki->viewManager()->getIndexOf(view);
+ if(position >= 0 && position < viewPositionVector.size())
+ {
+ viewPositionVector[position] = *i;
+ }
+ }
+ }
+ }
+ }
+ int position = 0;
+ for(unsigned int i = 0; i < viewPositionVector.size(); ++i)
+ {
+ if(viewPositionVector[i] != NULL)
+ {
+ viewPositionVector[i]->setOrder(position);
+ ++position;
+ }
+ }
+
//update the open-state of the items
- for (uint i=0; i < list->count(); ++i)
+ for (KileProjectItemList::iterator i = list->begin(); i != list->end(); ++i)
{
- item = list->at(i);
- kdDebug() << "\tsetOpenState(" << item->url().path() << ") to " << m_ki->isOpen(item->url()) << endl;
+ item = *i;
+ kdDebug() << "\tsetOpenState(" << (*i)->url().path() << ") to " << m_ki->isOpen(item->url()) << endl;
item->setOpenState(m_ki->isOpen(item->url()));
docinfo = item->getInfo();
--- trunk/extragear/office/kile/kile/kiledocmanager.h #637086:637087
@@ -93,10 +93,18 @@
//projects
void projectNew();
KileProject* projectOpen();
- KileProject* projectOpen(const KURL&, int = 0, int = 1);
- void projectOpenItem(KileProjectItem *item);
+
+ /**
+ * @param openProjectItemViews Opens project files in the editor iff openProjectItemViews is set to 'true'.
+ **/
+ KileProject* projectOpen(const KURL&, int = 0, int = 1, bool openProjectItemViews = true);
/**
+ * @param openProjectItemViews Opens project files in the editor iff openProjectItemViews is set to 'true'.
+ **/
+ void projectOpenItem(KileProjectItem *item, bool openProjectItemViews = true);
+
+ /**
* Saves the state of the project, if @param project is zero, the active project is saved.
**/
void projectSave(KileProject * project = 0);
@@ -217,7 +225,7 @@
Kate::View* createDocumentWithText(const QString& text, KileDocument::Type type = KileDocument::Text, const QString& extension = QString::null, const KURL& baseDirectory = KURL());
Kate::View* loadText(KileDocument::Type type, const QString& name, const KURL &url, const QString & encoding = QString::null, bool create = true, const QString & highlight = QString::null, const QString &text = QString::null, int index = -1, const KURL& baseDirectory = KURL());
- Kate::View* loadItem(KileDocument::Type type, KileProjectItem *item, const QString & text = QString::null);
+ Kate::View* loadItem(KileDocument::Type type, KileProjectItem *item, const QString & text = QString::null, bool openProjectItemViews = true);
private:
QPtrList<TextInfo> m_textInfoList;
--- trunk/extragear/office/kile/kile/kileproject.cpp #637086:637087
@@ -47,7 +47,8 @@
m_parent(0L),
m_child(0L),
m_sibling(0L),
- m_nLine(0)
+ m_nLine(0),
+ m_order(-1)
{
m_highlight=m_encoding=QString::null;
m_bOpen = m_archive = true;
@@ -56,6 +57,11 @@
project->add(this);
}
+void KileProjectItem::setOrder(int i)
+{
+ m_order = i;
+}
+
void KileProjectItem::setParent(KileProjectItem * item)
{
m_parent = item;
@@ -365,6 +371,7 @@
item->setArchive(m_config->readBoolEntry("archive", true));
item->setLineNumber(m_config->readNumEntry("line", 0));
item->setColumnNumber(m_config->readNumEntry("column", 0));
+ item->setOrder(m_config->readNumEntry("order", -1));
item->changePath(groups[i].mid(5));
connect(item, SIGNAL(urlChanged(KileProjectItem*)), this, SLOT(itemRenamed(KileProjectItem*)) );
@@ -411,6 +418,7 @@
m_config->writeEntry("archive", item->archive());
m_config->writeEntry("line", item->lineNumber());
m_config->writeEntry("column", item->columnNumber());
+ m_config->writeEntry("order", item->order());
}
KileTool::setConfigName("QuickBuild", quickBuildConfig(), m_config);
--- trunk/extragear/office/kile/kile/kileproject.h #637086:637087
@@ -84,6 +84,9 @@
uint columnNumber() { return m_nColumn; }
void setColumnNumber(uint l) { m_nColumn = l; }
+ int order() const { return m_order; }
+ void setOrder(int i);
+
//project tree functions
void setParent(KileProjectItem * item);
@@ -121,6 +124,7 @@
KileDocument::TextInfo *m_docinfo;
KileProjectItem *m_parent, *m_child, *m_sibling;
uint m_nLine, m_nColumn;
+ int m_order;
};
class KileProjectItemList : public QPtrList<KileProjectItem>
--- trunk/extragear/office/kile/kile/kileviewmanager.cpp #637086:637087
@@ -5,7 +5,7 @@
//
//
// Author: Jeroen Wijnhout <Jeroen.Wijnhout@kdemail.net>, (C) 2004
-// Michel Ludwig <michel.ludwig@kdemail.net>, (C) 2006
+// Michel Ludwig <michel.ludwig@kdemail.net>, (C) 2006, 2007
/***************************************************************************
* *
@@ -221,6 +221,27 @@
return 0;
}
+Kate::View* Manager::textView(Kate::Document *doc)
+{
+ for(Kate::View *view = m_textViewList.first(); view; view = m_textViewList.next())
+ {
+ if(view->getDoc() == doc)
+ {
+ return view;
+ }
+ }
+ return NULL;
+}
+
+int Manager::getIndexOf(Kate::View* view) const
+{
+ return m_tabs->indexOf(view);
+}
+
+unsigned int Manager::getTabCount() const {
+ return m_tabs->count();
+}
+
Kate::View* Manager::switchToTextView(const KURL & url)
{
Kate::View *view = 0L;
--- trunk/extragear/office/kile/kile/kileviewmanager.h #637086:637087
@@ -62,6 +62,9 @@
Kate::View* currentTextView() const;
QPtrList<Kate::View>& textViews() {return m_textViewList;}
Kate::View* textView(int i) { return m_textViewList.at(i); }
+ Kate::View* textView(Kate::Document *doc);
+ int getIndexOf(Kate::View* view) const;
+ unsigned int getTabCount() const;
void createTabs(QWidget *);
Kate::View* createTextView(KileDocument::TextInfo *info, int index = -1);
Thank you, Michel! Cheers, gero. |