summaryrefslogtreecommitdiffstats
path: root/koshell/koshell_shell.h
blob: cc1bbd4d0f128dd09125b577b0d48894fcf63de7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* This file is part of the KDE project
   Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
   Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
   Copyright (C) 2000-2005 David Faure <faure@kde.org>
   Copyright (C) 2005 Sven Lüppken <sven@kde.org>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/
#ifndef __koshell_window_h__
#define __koshell_window_h__

#include <KoMainWindow.h>
#include <KoQueryTrader.h>
#include <ktabwidget.h>
#include <tqptrlist.h>
#include <tqmap.h>
#include <tqtoolbutton.h>
#include <tqvaluelist.h>

#include "iconsidepane.h"

class TQVBox;
class TQIconView;
class TQIconViewItem;
class TQSplitter;
class KoDocumentEntry;
class KoView;
class KoShellGUIClient;

/////// class KoShellWindow ////////

class KoShellWindow : public KoMainWindow
{
  TQ_OBJECT
  

public:

  KoShellWindow();
  virtual ~KoShellWindow();

  virtual void setRootDocument( KoDocument *doc );
  /**
   * Update caption from document info - call when document info
   * (title in the about page) changes.
   */
  virtual void updateCaption();

  virtual TQString configFile() const;

  TDEAction *mnuSaveAll;
  TDEAction* partSpecificHelpAction;

protected slots:

  virtual void slotFileNew();
  virtual void slotFileClose();
  virtual void slotFileOpen();
  void saveAll();

  void showPartSpecificHelp();

  void slotSidebar_Part(int);
  void slotSidebar_Document(int);
  void tab_contextMenu(TQWidget * ,const TQPoint &);

  /**
    Used for showing or hiding the sidebar and the components-label.
  */
  void slotShowSidebar();
  /**
    This slot is called whenever the user clicks on a "component" in the sidebar. It loads a new
    document which can be edited with the chosen component.
    @param item The component the user clicked on
  */
  void slotSidebarItemClicked( TQIconViewItem *item );
  void slotKSLoadCompleted();
  void slotKSLoadCanceled (const TQString &);
  void slotNewDocumentName();
  /**
    This slot is called whenever the user clicks on a tab to change the document. It looks for the
    changed widget in the list of all pages and calls switchToPage with the iterator which points
    to the page corresponding to the widget.
    @param widget The current widget
  */
  void slotUpdatePart( TQWidget* widget );

private:

  struct Page
  {
    KoDocument *m_pDoc;
    KoView *m_pView;
    int m_id;
  };

  virtual bool queryClose();
  virtual bool openDocumentInternal( const KURL & url, KoDocument * newdoc = 0L );
  virtual void slotConfigureKeys();
  void closeDocument();
  void saveSettings();
  void switchToPage( TQValueList<Page>::Iterator it );


  TQValueList<Page> m_lstPages;
  TQValueList<Page>::Iterator m_activePage;

  IconSidePane *m_pSidebar;
  TQLabel *m_pComponentsLabel;
  TQSplitter *m_pLayout;
  KTabWidget *m_pFrame;
  TQToolButton *m_tabCloseButton;

  // Map of available parts (the int is the koolbar item id)
  TQMap<int,KoDocumentEntry> m_mapComponents;

  // Saved between openDocument and setRootDocument
  KoDocumentEntry m_documentEntry;

  KoShellGUIClient *m_client;
  void createShellGUI( bool create = true );

  int m_grpFile; //the ID number for the component group in the side bar
  int m_grpDocuments; //the ID number for the docuemnt group in the side bar
};

//////// class KoShellGUIClient //////////

class KoShellGUIClient : public KXMLGUIClient
{
public:
  KoShellGUIClient( KoShellWindow *window );
};

#endif // __koshell_window_h__