source: trunk/examples/addressbook/mainwindow.cpp

Last change on this file was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1/****************************************************************************
2** $Id: mainwindow.cpp 2 2005-11-16 15:49:26Z dmik $
3**
4** Copyright ( C ) 1992-2000 Trolltech AS. All rights reserved.
5**
6** This file is part of an example program for Qt. This example
7** program may be used, distributed and modified without limitation.
8**
9*****************************************************************************/
10
11#include "mainwindow.h"
12#include "centralwidget.h"
13
14#include <qtoolbar.h>
15#include <qtoolbutton.h>
16#include <qpopupmenu.h>
17#include <qmenubar.h>
18#include <qstatusbar.h>
19#include <qapplication.h>
20#include <qfiledialog.h>
21
22ABMainWindow::ABMainWindow()
23 : QMainWindow( 0, "example addressbook application" ),
24 filename( QString::null )
25{
26 setupMenuBar();
27 setupFileTools();
28 setupStatusBar();
29 setupCentralWidget();
30}
31
32
33ABMainWindow::~ABMainWindow()
34{
35}
36
37void ABMainWindow::setupMenuBar()
38{
39 QPopupMenu *file = new QPopupMenu( this );
40 menuBar()->insertItem( "&File", file );
41
42 file->insertItem( "New", this, SLOT( fileNew() ), CTRL + Key_N );
43 file->insertItem( QPixmap( "fileopen.xpm" ), "Open", this, SLOT( fileOpen() ), CTRL + Key_O );
44 file->insertSeparator();
45 file->insertItem( QPixmap( "filesave.xpm" ), "Save", this, SLOT( fileSave() ), CTRL + Key_S );
46 file->insertItem( "Save As...", this, SLOT( fileSaveAs() ) );
47 file->insertSeparator();
48 file->insertItem( QPixmap( "fileprint.xpm" ), "Print...", this, SLOT( filePrint() ), CTRL + Key_P );
49 file->insertSeparator();
50 file->insertItem( "Close", this, SLOT( closeWindow() ), CTRL + Key_W );
51 file->insertItem( "Quit", qApp, SLOT( quit() ), CTRL + Key_Q );
52}
53
54void ABMainWindow::setupFileTools()
55{
56 //fileTools = new QToolBar( this, "file operations" );
57}
58
59void ABMainWindow::setupStatusBar()
60{
61 //statusBar()->message( "Ready", 2000 );
62}
63
64void ABMainWindow::setupCentralWidget()
65{
66 view = new ABCentralWidget( this );
67 setCentralWidget( view );
68}
69
70void ABMainWindow::closeWindow()
71{
72 close();
73}
74
75void ABMainWindow::fileNew()
76{
77}
78
79void ABMainWindow::fileOpen()
80{
81 QString fn = QFileDialog::getOpenFileName( QString::null, QString::null, this );
82 if ( !fn.isEmpty() ) {
83 filename = fn;
84 view->load( filename );
85 }
86}
87
88void ABMainWindow::fileSave()
89{
90 if ( filename.isEmpty() ) {
91 fileSaveAs();
92 return;
93 }
94
95 view->save( filename );
96}
97
98void ABMainWindow::fileSaveAs()
99{
100 QString fn = QFileDialog::getSaveFileName( QString::null, QString::null, this );
101 if ( !fn.isEmpty() ) {
102 filename = fn;
103 fileSave();
104 }
105}
106
107void ABMainWindow::filePrint()
108{
109}
Note: See TracBrowser for help on using the repository browser.