]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinapplication.cpp
cleanup of unused forward declarations
[dolphin.git] / src / dolphinapplication.cpp
index cad182d6aee3bb9b0c543d868e2bf197079af38b..b426ec1b821b946e1a3011e58da8ddceaa888575 100644 (file)
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
 #include "dolphinapplication.h"
 #include "dolphinmainwindow.h"
+#include "metadataloader.h"
 
-DolphinApplication::DolphinApplication()
+#include <applicationadaptor.h>
+#include <kurl.h>
+#include <QDBusConnection>
+
+DolphinApplication::DolphinApplication() :
+    m_lastId(0)
 {
+    new ApplicationAdaptor(this);
+    QDBusConnection::sessionBus().registerObject("/dolphin/Application", this);
 }
 
-/*
- * cleanup what ever is left from the MainWindows
- */
 DolphinApplication::~DolphinApplication()
 {
-    while( m_mainWindows.count() != 0 )
+    // cleanup what ever is left from the MainWindows
+    while (m_mainWindows.count() != 0) {
         delete m_mainWindows.takeFirst();
+    }
 }
 
 DolphinApplication* DolphinApplication::app()
@@ -41,24 +48,41 @@ DolphinApplication* DolphinApplication::app()
 
 DolphinMainWindow* DolphinApplication::createMainWindow()
 {
-    DolphinMainWindow* mainwindow = new DolphinMainWindow;
-    mainwindow->init();
-    
-    m_mainWindows.append( mainwindow );
-    return mainwindow;
+    DolphinMainWindow* mainWindow = new DolphinMainWindow(m_lastId);
+    ++m_lastId;
+    mainWindow->init();
+
+    m_mainWindows.append(mainWindow);
+    return mainWindow;
 }
 
-void DolphinApplication::removeMainWindow( DolphinMainWindow *mainwindow )
+MetadataLoader* DolphinApplication::metadataLoader()
 {
-    m_mainWindows.removeAll( mainwindow );
+    static MetadataLoader loader;
+    return &loader;
+}
+
+int DolphinApplication::openWindow(const QString& url)
+{
+    DolphinMainWindow* win = createMainWindow();
+    if ((win->activeView() != 0) && !url.isEmpty()) {
+        win->activeView()->setUrl(KUrl(url));
+    }
+    win->show();
+    //TODO find how to raise a window (as if we've launched a new dolphin process)
+    return win->getId();
+}
+
+void DolphinApplication::removeMainWindow(DolphinMainWindow* mainWindow)
+{
+    m_mainWindows.removeAll(mainWindow);
 }
 
 void DolphinApplication::refreshMainWindows()
 {
-    for( int i = 0; i < m_mainWindows.count(); ++i ) {
+    for (int i = 0; i < m_mainWindows.count(); ++i) {
         m_mainWindows[i]->refreshViews();
     }
 }
 
 #include "dolphinapplication.moc"
-