[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdevelop/src
From:       Alexander Dymo <cloudtemple () mksat ! net>
Date:       2005-04-10 21:27:18
Message-ID: 20050410212718.A6B89495 () office ! kde ! org
[Download RAW message or body]

CVS commit by dymo: 

Implemented window menu and made raiseView() capable of raising part views (this solve already \
opened part activation problems).


  M +93 -6     simplemainwindow.cpp   1.4
  M +6 -0      simplemainwindow.h   1.4


--- kdevelop/src/simplemainwindow.cpp  #1.3:1.4
@@ -77,4 +77,5 @@ void SimpleMainWindow::init()
     
     m_mainWindowShare->init();
+    setupWindowMenu();
     menuBar()->setEnabled( false );
 
@@ -161,11 +162,15 @@ void SimpleMainWindow::setViewAvailable(
 void SimpleMainWindow::raiseView(QWidget *view)
 {
-    DDockWindow *dock;
     if (m_docks.contains(view))
-        dock = toolWindow(m_docks[view]);
-    else
-        return;
-    
+    {
+        DDockWindow *dock = toolWindow(m_docks[view]);
     dock->raiseWidget(view);
+    }
+    else if (m_widgets.contains(view))
+    {
+        for (QValueList<DTabWidget*>::const_iterator it = m_tabs.begin(); it != m_tabs.end(); \
++it) +            if ((*it)->indexOf(view) != -1)
+                (*it)->showPage(view);
+    }
 }
 
@@ -425,3 +430,85 @@ bool SimpleMainWindow::queryExit()
 }
 
+void SimpleMainWindow::setupWindowMenu()
+{
+    // get the xmlgui created one instead
+    m_windowMenu = static_cast<QPopupMenu*>(main()->child("window", "KPopupMenu"));
+
+    if (!m_windowMenu)
+    {
+        kdDebug(9000) << "Couldn't find the XMLGUI window menu. Creating new." << endl;
+
+        m_windowMenu = new QPopupMenu(main(), "window");
+        menuBar()->insertItem(i18n("&Window"), m_windowMenu);
+    }
+
+    actionCollection()->action("file_close")->plug(m_windowMenu);
+    actionCollection()->action("file_close_all")->plug(m_windowMenu);
+    actionCollection()->action("file_closeother")->plug(m_windowMenu);
+
+    QObject::connect(m_windowMenu, SIGNAL(activated(int)), this, SLOT(openURL(int)));
+    QObject::connect(m_windowMenu, SIGNAL(aboutToShow()), this, SLOT(fillWindowMenu()));
+}
+
+void SimpleMainWindow::openURL(int w)
+{
+    QValueList<QPair<int, KURL> >::ConstIterator it = m_windowList.begin();
+    while (it != m_windowList.end())
+    {
+        if ((*it).first == w)
+        {
+            KURL url((*it).second);
+            if (!url.isEmpty())
+            {
+                PartController::getInstance()->editDocument(url);
+                return;
+            }
+        }
+        ++it;
+    }
+}
+
+void SimpleMainWindow::fillWindowMenu()
+{
+    // clear menu
+    QValueList< QPair< int, KURL > >::ConstIterator it = m_windowList.begin();
+    while (it != m_windowList.end())
+    {
+        m_windowMenu->removeItem( (*it).first );
+        ++it;
+    }
+
+    int temp = 0;
+
+    QMap<QString, KURL> map;
+    QStringList string_list;
+    KURL::List list = PartController::getInstance()->openURLs();
+    KURL::List::Iterator itt = list.begin();
+    while (itt != list.end())
+    {
+        map[(*itt).fileName()] = *itt;
+        string_list.append((*itt).fileName());
+        ++itt;
+    }
+    string_list.sort();
+
+    list.clear();
+    for(uint i = 0; i != string_list.size(); ++i)
+        list.append(map[string_list[i]]);
+
+    itt = list.begin();
+    int i = 0;
+
+    if (list.count() > 0)
+        m_windowList << qMakePair(m_windowMenu->insertSeparator(), KURL());
+    
+    while (itt != list.end())
+    {
+        temp = m_windowMenu->insertItem( i < 10 ? QString("&%1 \
%2").arg(i).arg((*itt).fileName()) : (*itt).fileName() ); +        m_windowList << \
qMakePair(temp, *itt); +        ++i;
+        ++itt;
+    }
+}
+
 #include "simplemainwindow.moc"

--- kdevelop/src/simplemainwindow.h  #1.3:1.4
@@ -27,4 +27,5 @@
 
 class KAction;
+class QPopupMenu;
 class MainWindowShare;
 
@@ -77,8 +78,11 @@ private slots:
     void slotNewToolbarConfig();
     void raiseEditor();
+    void openURL(int w);
+    void fillWindowMenu();
 
 private:
     void createFramework();
     void createActions();
+    void setupWindowMenu();
     
     MainWindowShare *m_mainWindowShare;
@@ -87,4 +91,6 @@ private:
     QMap<QWidget*, DDockWindow::Position> m_docks;
     KAction *m_raiseEditor;
+    QPopupMenu *m_windowMenu;
+    QValueList<QPair<int, KURL> > m_windowList;
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic