removing qtfe files from the tip, since qtfe is only ever destined to build on the MozillaClassic branch; approved=arnt@troll.no
This commit is contained in:
Родитель
abf0ef7f3d
Коммит
ff86c1b5d4
|
@ -1,32 +0,0 @@
|
|||
/* $Id: DialogPool.cpp,v 1.1 1998-09-25 18:01:25 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Kalle
|
||||
* Dalheimer. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "DialogPool.h"
|
||||
|
||||
#include "OpenDialog.h"
|
||||
#include "SaveAsDialog.h"
|
||||
#include "FindDialog.h"
|
||||
|
||||
DialogPool::~DialogPool()
|
||||
{
|
||||
delete opendialog;
|
||||
delete saveasdialog;
|
||||
delete finddialog;
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/* $Id: DialogPool.h,v 1.1 1998-09-25 18:01:25 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Kalle
|
||||
* Dalheimer. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _DIALOGPOOL_H
|
||||
#define _DIALOGPOOL_H
|
||||
|
||||
class OpenDialog;
|
||||
class SaveAsDialog;
|
||||
class FindDialog;
|
||||
|
||||
struct DialogPool
|
||||
{
|
||||
DialogPool() {
|
||||
opendialog = 0;
|
||||
saveasdialog = 0;
|
||||
finddialog = 0;
|
||||
}
|
||||
~DialogPool();
|
||||
|
||||
OpenDialog* opendialog;
|
||||
SaveAsDialog* saveasdialog;
|
||||
FindDialog* finddialog;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,253 +0,0 @@
|
|||
/* $Id: FindDialog.cpp,v 1.1 1998-09-25 18:01:25 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Kalle
|
||||
* Dalheimer. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include <client.h>
|
||||
#include <intl_csi.h>
|
||||
#include <xpgetstr.h>
|
||||
|
||||
#include "FindDialog.h"
|
||||
|
||||
#include "QtContext.h"
|
||||
#include "finding.h"
|
||||
|
||||
#include <qlayout.h>
|
||||
#include <qpushbt.h>
|
||||
#include <qchkbox.h>
|
||||
#include <qframe.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlined.h>
|
||||
#include <qtbuttonrow.h>
|
||||
#include <qmainwindow.h>
|
||||
|
||||
|
||||
unsigned char *
|
||||
fe_ConvertFromLocaleEncoding(int16 charset, unsigned char *str); // from locale.cpp
|
||||
|
||||
FindDialog::FindDialog( QtContext* cx, QWidget* parent,
|
||||
const char* name ) :
|
||||
QDialog( parent, name, false ),
|
||||
context( cx )
|
||||
{
|
||||
QVBoxLayout* vlayout = new QVBoxLayout( this );
|
||||
|
||||
QHBoxLayout* editlayout = new QHBoxLayout();
|
||||
vlayout->addLayout( editlayout );
|
||||
|
||||
QLabel* label = new QLabel( tr( "Find:" ), this );
|
||||
label->setFixedSize( label->sizeHint() );
|
||||
editlayout->addWidget( label );
|
||||
|
||||
edit = new QLineEdit( this );
|
||||
edit->setFixedHeight( edit->sizeHint().height() );
|
||||
edit->setFocus();
|
||||
editlayout->addWidget( edit, 1 );
|
||||
|
||||
QHBoxLayout* cblayout = new QHBoxLayout();
|
||||
vlayout->addLayout( cblayout );
|
||||
|
||||
sensitiveCB = new QCheckBox( tr( "Case Sensitive" ), this );
|
||||
sensitiveCB->setFixedSize( sensitiveCB->sizeHint() );
|
||||
cblayout->addWidget( sensitiveCB );
|
||||
|
||||
backwardsCB = new QCheckBox( tr( "Find Backwards" ), this );
|
||||
backwardsCB->setFixedSize( backwardsCB->sizeHint() );
|
||||
cblayout->addWidget( backwardsCB );
|
||||
|
||||
QFrame* line = new QFrame( this, "line", 0, true );
|
||||
line->setFrameStyle( QFrame::HLine | QFrame::Sunken );
|
||||
line->setFixedHeight( 12 ); // Arnt said so...
|
||||
vlayout->addWidget( line );
|
||||
|
||||
QtButtonRow* buttonrow = new QtButtonRow( this );
|
||||
|
||||
QPushButton* findPB = new QPushButton( tr( "Find" ), buttonrow );
|
||||
connect( findPB, SIGNAL( clicked() ),
|
||||
this, SLOT( find() ) );
|
||||
findPB->setDefault( true );
|
||||
|
||||
QPushButton* clearPB = new QPushButton( tr( "Clear" ), buttonrow );
|
||||
connect( clearPB, SIGNAL( clicked() ),
|
||||
this, SLOT( clear() ) );
|
||||
|
||||
QPushButton* closePB = new QPushButton( tr( "Close" ), buttonrow );
|
||||
connect( closePB, SIGNAL( clicked() ),
|
||||
this, SLOT( hide() ) );
|
||||
|
||||
vlayout->addWidget( buttonrow );
|
||||
vlayout->activate();
|
||||
resize( 1, 1 );
|
||||
}
|
||||
|
||||
|
||||
void FindDialog::refresh()
|
||||
{
|
||||
fe_FindData *find_data = &context->find_data;
|
||||
|
||||
find_data->context_to_find = context->mwContext();
|
||||
|
||||
char * tmp;
|
||||
|
||||
find_data->string = edit->text();
|
||||
INTL_CharSetInfo c;
|
||||
c = LO_GetDocumentCharacterSetInfo( context->mwContext() );
|
||||
tmp = (char *) fe_ConvertFromLocaleEncoding( INTL_GetCSIWinCSID(c),
|
||||
(unsigned char*)find_data->string.data() );
|
||||
if( tmp ) {
|
||||
find_data->string = tmp;
|
||||
} else {
|
||||
find_data->string = "";
|
||||
}
|
||||
|
||||
find_data->case_sensitive_p = sensitiveCB->isChecked();
|
||||
find_data->backward_p = backwardsCB->isChecked();
|
||||
/* For mail/news contexts, the Search in Header/Body is loaded into the
|
||||
fe_FindData in the valueChangeCallback */
|
||||
}
|
||||
|
||||
|
||||
void FindDialog::find()
|
||||
{
|
||||
fe_FindData* find_data = &context->find_data;
|
||||
|
||||
MWContext *context_to_find;
|
||||
QWidget* mainw;
|
||||
bool hasRetried = false;
|
||||
CL_Layer *layer;
|
||||
|
||||
XP_ASSERT(find_data);
|
||||
|
||||
mainw = context->topLevelWidget();
|
||||
|
||||
/* reload search parameters */
|
||||
refresh();
|
||||
|
||||
// Use the associated context unless there is one defined.
|
||||
context_to_find = context->mwContext();
|
||||
if( find_data->context_to_find )
|
||||
context_to_find = find_data->context_to_find;
|
||||
|
||||
if( find_data->string.isEmpty() ) {
|
||||
FE_Alert( context->mwContext(), tr( "Nothing to search for." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if( find_data->find_in_headers ) {
|
||||
XP_ASSERT( find_data->context->type == MWContextMail ||
|
||||
find_data->context->type == MWContextNews );
|
||||
if ( find_data->context->type == MWContextMail ||
|
||||
find_data->context->type == MWContextNews ) {
|
||||
int status = -1; /* ###tw Find needs to be hooked up in a brand
|
||||
new way now### */
|
||||
/*###tw int status = MSG_DoFind(fj->context, fj->string, fj->case_sensitive_p); */
|
||||
if (status < 0) {
|
||||
/* mainw could be the find_data->shell. If status < 0 (find failed)
|
||||
* backend will bring the find window down. So use the context to
|
||||
* display the error message here.
|
||||
*/
|
||||
FE_Alert( find_data->context, XP_GetString( status ) );
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* but I think you will want this in non-Gold too! */
|
||||
/* And with QtMozilla, you get it ... */
|
||||
/*
|
||||
* Start the search from the current selection location. Bug #29854.
|
||||
*/
|
||||
LO_GetSelectionEndpoints( context_to_find,
|
||||
&find_data->start_element,
|
||||
&find_data->end_element,
|
||||
&find_data->start_pos,
|
||||
&find_data->end_pos,
|
||||
&layer );
|
||||
AGAIN:
|
||||
|
||||
if( LO_FindText( context_to_find, find_data->string.data(),
|
||||
&find_data->start_element, &find_data->start_pos,
|
||||
&find_data->end_element, &find_data->end_pos,
|
||||
find_data->case_sensitive_p, !find_data->backward_p ) )
|
||||
{
|
||||
int32 x, y;
|
||||
LO_SelectText ( context_to_find,
|
||||
find_data->start_element, find_data->start_pos,
|
||||
find_data->end_element, find_data->end_pos,
|
||||
&x, &y);
|
||||
|
||||
/* If the found item is not visible on the screen, scroll to it.
|
||||
If we need to scroll, attempt to position the destination
|
||||
coordinate in the middle of the window.
|
||||
*/
|
||||
if (x >= CONTEXT_DATA (context_to_find)->documentXOffset() &&
|
||||
x <= (CONTEXT_DATA (context_to_find)->documentXOffset() +
|
||||
CONTEXT_DATA (context_to_find)->scrollWidth()))
|
||||
x = CONTEXT_DATA (context_to_find)->documentXOffset();
|
||||
else
|
||||
x = x - (CONTEXT_DATA (context_to_find)->scrollWidth() / 2);
|
||||
|
||||
if (y >= CONTEXT_DATA (context_to_find)->documentYOffset() &&
|
||||
y <= (CONTEXT_DATA (context_to_find)->documentYOffset() +
|
||||
CONTEXT_DATA (context_to_find)->scrollHeight()))
|
||||
y = CONTEXT_DATA (context_to_find)->documentYOffset();
|
||||
else
|
||||
y = y - (CONTEXT_DATA (context_to_find)->scrollHeight() / 2);
|
||||
|
||||
if (x + CONTEXT_DATA (context_to_find)->scrollWidth()
|
||||
> CONTEXT_DATA (context_to_find)->documentWidth())
|
||||
x = (CONTEXT_DATA (context_to_find)->documentWidth() -
|
||||
CONTEXT_DATA (context_to_find)->scrollWidth());
|
||||
|
||||
if (y + CONTEXT_DATA (context_to_find)->scrollHeight()
|
||||
> CONTEXT_DATA (context_to_find)->documentHeight())
|
||||
y = (CONTEXT_DATA (context_to_find)->documentHeight() -
|
||||
CONTEXT_DATA (context_to_find)->scrollHeight());
|
||||
|
||||
if (x < 0) x = 0;
|
||||
if (y < 0) y = 0;
|
||||
|
||||
if( context->topLevelWidget() )
|
||||
context->documentSetContentsPos( x, y );
|
||||
} else {
|
||||
if (hasRetried) {
|
||||
FE_Alert( context->mwContext(), tr( "Search string not found." ) );
|
||||
return;
|
||||
} else {
|
||||
if( FE_Confirm( context->mwContext(),
|
||||
( find_data->backward_p
|
||||
? tr( "Beginning of document reached; continue from end?" )
|
||||
: tr( "End of document reached; continue from beginning?" ) ) ) ) {
|
||||
find_data->start_element = 0;
|
||||
find_data->start_pos = 0;
|
||||
hasRetried = true;
|
||||
goto AGAIN;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void FindDialog::clear()
|
||||
{
|
||||
edit->setText( "" );
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/* $Id: FindDialog.h,v 1.1 1998-09-25 18:01:26 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Kalle
|
||||
* Dalheimer. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _FINDDIALOG_H
|
||||
#define _FINDDIALOG_H
|
||||
|
||||
#include <qdialog.h>
|
||||
|
||||
class QtContext;
|
||||
class QLineEdit;
|
||||
class QCheckBox;
|
||||
|
||||
class FindDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FindDialog( QtContext* cx, QWidget* parent,
|
||||
const char* name = 0 );
|
||||
|
||||
public slots:
|
||||
void find();
|
||||
|
||||
private slots:
|
||||
void clear();
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
|
||||
QtContext* context;
|
||||
QLineEdit* edit;
|
||||
QCheckBox* sensitiveCB;
|
||||
QCheckBox* backwardsCB;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,143 +0,0 @@
|
|||
/* $Id: OpenDialog.cpp,v 1.2 1998-09-25 23:30:38 cls%seawood.org Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Kalle
|
||||
* Dalheimer. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "OpenDialog.h"
|
||||
#include "QtBrowserContext.h"
|
||||
|
||||
#include <qfiledlg.h>
|
||||
#include <qpushbt.h>
|
||||
#include <qlayout.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlined.h>
|
||||
#include <qframe.h>
|
||||
#include <qtbuttonrow.h>
|
||||
|
||||
#define i18n( x ) x
|
||||
|
||||
OpenDialog::OpenDialog( QtBrowserContext* _context, QWidget* parent,
|
||||
const char* name ) :
|
||||
QDialog( parent, name, true ),
|
||||
context( _context )
|
||||
{
|
||||
QVBoxLayout* vlayout = new QVBoxLayout( this, 6 );
|
||||
|
||||
QLabel* label = new QLabel( i18n( "Enter the World Wide Web location (URL) or specify\n"
|
||||
"the local file you would like to open:" ), this );
|
||||
label->setFixedSize( label->sizeHint() );
|
||||
vlayout->addWidget( label );
|
||||
|
||||
QHBoxLayout* hlayout = new QHBoxLayout();
|
||||
vlayout->addLayout( hlayout );
|
||||
|
||||
edit = new QLineEdit( this );
|
||||
edit->setFixedHeight( edit->sizeHint().height() );
|
||||
edit->setFocus();
|
||||
hlayout->addWidget( edit );
|
||||
|
||||
QPushButton* choosePB = new QPushButton( i18n( "Choose &File..." ), this );
|
||||
choosePB->setFixedSize( choosePB->sizeHint() );
|
||||
connect( choosePB, SIGNAL( clicked() ),
|
||||
this, SLOT( chooseFile() ) );
|
||||
hlayout->addWidget( choosePB );
|
||||
|
||||
QFrame* line = new QFrame( this, "line", 0, true );
|
||||
line->setFrameStyle( QFrame::HLine | QFrame::Sunken );
|
||||
line->setFixedHeight( 12 ); // Arnt said so...
|
||||
vlayout->addWidget( line );
|
||||
|
||||
QtButtonRow* buttonrow = new QtButtonRow( this );
|
||||
|
||||
#ifdef MOZ_MAIL_NEWS
|
||||
QPushButton* openNavigatorPB = new QPushButton( i18n( "Open In &Navigator" ),
|
||||
buttonrow );
|
||||
#else
|
||||
QPushButton* openNavigatorPB = new QPushButton( i18n( "&OK" ),
|
||||
buttonrow );
|
||||
#endif
|
||||
openNavigatorPB->setFixedSize( openNavigatorPB->sizeHint() );
|
||||
connect( openNavigatorPB, SIGNAL( clicked() ),
|
||||
this, SLOT( openInNavigator() ) );
|
||||
connect( openNavigatorPB, SIGNAL( clicked() ),
|
||||
this, SLOT( accept() ) );
|
||||
#ifdef EDITOR
|
||||
QPushButton* openComposerPB = new QPushButton( i18n( "Open In &Composer" ),
|
||||
buttonrow );
|
||||
openComposerPB->setFixedSize( openComposerPB->sizeHint() );
|
||||
connect( openComposerPB, SIGNAL( clicked() ),
|
||||
this, SLOT( openInComposer() ) );
|
||||
connect( openComposerPB, SIGNAL( clicked() ),
|
||||
this, SLOT( accept() ) );
|
||||
#endif
|
||||
|
||||
QPushButton* clearPB = new QPushButton( i18n( "&Clear" ),
|
||||
buttonrow );
|
||||
clearPB->setFixedSize( clearPB->sizeHint() );
|
||||
connect( clearPB, SIGNAL( clicked() ),
|
||||
this, SLOT( clear() ) );
|
||||
|
||||
QPushButton* cancelPB = new QPushButton( i18n( "Close" ),
|
||||
buttonrow );
|
||||
cancelPB->setFixedSize( cancelPB->sizeHint() );
|
||||
connect( cancelPB, SIGNAL( clicked() ),
|
||||
this, SLOT( reject() ) );
|
||||
|
||||
#ifdef EDITOR
|
||||
if( context->mwContext()->type == MWContextEditor)
|
||||
openComposerPB->setDefault( true );
|
||||
else
|
||||
#endif
|
||||
openNavigatorPB->setDefault( true );
|
||||
|
||||
vlayout->addWidget( buttonrow );
|
||||
vlayout->activate();
|
||||
resize( 1, 1 );
|
||||
}
|
||||
|
||||
|
||||
void OpenDialog::chooseFile()
|
||||
{
|
||||
//#warning It would be nicer to have a correct caption. Kalle
|
||||
QString file = QFileDialog::getOpenFileName();
|
||||
if( !file.isEmpty() )
|
||||
edit->setText( file );
|
||||
}
|
||||
|
||||
void OpenDialog::openInComposer()
|
||||
{
|
||||
#ifdef EDITOR
|
||||
if( !strlen( edit->text() ) )
|
||||
return;
|
||||
|
||||
context->editorEdit( 0, edit->text() );
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenDialog::openInNavigator()
|
||||
{
|
||||
if( !strlen( edit->text() ) )
|
||||
return;
|
||||
|
||||
context->browserGetURL( edit->text() );
|
||||
}
|
||||
|
||||
void OpenDialog::clear()
|
||||
{
|
||||
edit->setText( "" );
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/* $Id: OpenDialog.h,v 1.2 1998-09-25 23:30:38 cls%seawood.org Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Kalle
|
||||
* Dalheimer. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _OPENDIALOG_H
|
||||
#define _OPENDIALOG_H
|
||||
|
||||
#include <qdialog.h>
|
||||
|
||||
class QtBrowserContext;
|
||||
class QLineEdit;
|
||||
|
||||
class OpenDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
OpenDialog( QtBrowserContext* context, QWidget* parent, const char* name = 0 );
|
||||
|
||||
private slots:
|
||||
void chooseFile();
|
||||
void openInComposer();
|
||||
void openInNavigator();
|
||||
void clear();
|
||||
|
||||
private:
|
||||
QLineEdit* edit;
|
||||
QtBrowserContext* context;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -1,75 +0,0 @@
|
|||
/* $Id: QtBookmarkButton.cpp,v 1.1 1998-09-25 18:01:27 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Eirik Eng.
|
||||
* Further developed by Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik
|
||||
* Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "QtBookmarkButton.h"
|
||||
#include "QtBookmarkMenu.h"
|
||||
#include "QtContext.h"
|
||||
#include "qtoolbar.h"
|
||||
|
||||
QtBookmarkButton::QtBookmarkButton( const QPixmap & pm, const char * textLabel,
|
||||
QtContext *context,
|
||||
QToolBar * parent, const char * name )
|
||||
: QToolButton( parent, name )
|
||||
{
|
||||
setPixmap( pm );
|
||||
setUsesBigPixmap( FALSE );
|
||||
setToggleButton( TRUE );
|
||||
setTextLabel( textLabel );
|
||||
|
||||
if ( context->inherits( "QtBrowserContext" ) )
|
||||
menu = new QtBookmarkMenu( (QtBrowserContext*)context );
|
||||
else
|
||||
menu = new QtBookmarkMenu();
|
||||
connect( this, SIGNAL(toggled(bool)), SLOT(beenToggled(bool)) );
|
||||
menu->installEventFilter( this );
|
||||
connect( menu, SIGNAL(destroyed()),
|
||||
this, SLOT(menuDied()) );
|
||||
}
|
||||
|
||||
QtBookmarkButton::~QtBookmarkButton()
|
||||
{
|
||||
delete menu;
|
||||
}
|
||||
|
||||
void QtBookmarkButton::beenToggled( bool up )
|
||||
{
|
||||
if ( up )
|
||||
menu->popup( mapToGlobal( rect().bottomLeft()));
|
||||
else
|
||||
menu->hide();
|
||||
}
|
||||
|
||||
|
||||
bool QtBookmarkButton::eventFilter( QObject *o, QEvent *e )
|
||||
{
|
||||
if ( o->inherits("QPopupMenu") && e->type() == Event_Hide )
|
||||
setOn( FALSE );
|
||||
if ( o->inherits("QLabel") && e->type() == Event_MouseButtonPress )
|
||||
toggle();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void QtBookmarkButton::menuDied()
|
||||
{
|
||||
menu = 0;
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/* $Id: QtBookmarkButton.h,v 1.1 1998-09-25 18:01:27 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Eirik Eng.
|
||||
* Further developed by Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik
|
||||
* Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef QTBOOKMARKBUTTON_H
|
||||
#define QTBOOKMARKBUTTON_H
|
||||
|
||||
#include "qtoolbutton.h"
|
||||
|
||||
class QtBookmarkMenu;
|
||||
class QtContext;
|
||||
|
||||
class QtBookmarkButton : public QToolButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtBookmarkButton( const QPixmap & pm, const char * textLabel,
|
||||
QtContext *context,
|
||||
QToolBar * parent, const char * name = 0 );
|
||||
~QtBookmarkButton();
|
||||
|
||||
public slots:
|
||||
void beenToggled( bool );
|
||||
void menuDied();
|
||||
|
||||
protected:
|
||||
bool eventFilter( QObject *o, QEvent *e );
|
||||
private:
|
||||
QtBookmarkMenu *menu;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -1,112 +0,0 @@
|
|||
/* $Id: QtBookmarkEditDialog.cpp,v 1.1 1998-09-25 18:01:27 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Eirik Eng.
|
||||
* Further developed by Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik
|
||||
* Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "QtBookmarkEditDialog.h"
|
||||
|
||||
#include <qtbuttonrow.h>
|
||||
#include <qchkbox.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlayout.h>
|
||||
#include <qpushbt.h>
|
||||
#include <qlined.h>
|
||||
#include <qmlined.h>
|
||||
|
||||
#include <qthbox.h>
|
||||
#include <qtgrid.h>
|
||||
#include "QtBookmarksContext.h"
|
||||
|
||||
#include "bkmks.h"
|
||||
|
||||
#define i18n(x) x
|
||||
|
||||
QtBookmarkEditDialog::QtBookmarkEditDialog( QtBookmarksContext* p,
|
||||
const char* wName ) :
|
||||
QtVBox( 0, wName )
|
||||
{
|
||||
parent = p;
|
||||
entry = 0;
|
||||
|
||||
QtGrid *g = new QtGrid( 2, QtGrid::Horizontal, this );
|
||||
|
||||
QLabel* nameLabel = new QLabel( i18n("Name:"), g );
|
||||
nameLabel->setAlignment( AlignRight );
|
||||
name = new QLineEdit( g );
|
||||
name->setFixedHeight( nameLabel->sizeHint().height() );
|
||||
|
||||
QLabel* locationLabel = new QLabel( i18n("Location:"), g );
|
||||
locationLabel->setAlignment( AlignRight );
|
||||
location = new QLineEdit( g );
|
||||
location->setFixedHeight( locationLabel->sizeHint().height() );
|
||||
|
||||
QLabel* descriptionLabel = new QLabel( i18n("Description:"), g );
|
||||
descriptionLabel->setAlignment( AlignRight | AlignVCenter );
|
||||
description = new QMultiLineEdit( g );
|
||||
description->setFixedVisibleLines( 5 );
|
||||
|
||||
QtButtonRow* buttonRow = new QtButtonRow( this );
|
||||
|
||||
QPushButton* okPB = new QPushButton( i18n("OK"), buttonRow );
|
||||
connect( okPB, SIGNAL( clicked() ), this, SLOT( okSlot() ) );
|
||||
QPushButton* cancelPB = new QPushButton( i18n( "Cancel" ), buttonRow );
|
||||
connect( cancelPB, SIGNAL( clicked() ), this, SLOT( cancelSlot() ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void QtBookmarkEditDialog::setEntry( BM_Entry *e )
|
||||
{
|
||||
save();
|
||||
entry = e;
|
||||
name ->setText( BM_GetName(entry) );
|
||||
location ->setText( BM_GetAddress(entry) );
|
||||
description->setText( BM_GetDescription(entry) );
|
||||
}
|
||||
|
||||
void QtBookmarkEditDialog::clear()
|
||||
{
|
||||
name->setText( "" );
|
||||
description->setText( "" );
|
||||
location->setText( "" );
|
||||
entry = 0;
|
||||
}
|
||||
|
||||
void QtBookmarkEditDialog::save()
|
||||
{
|
||||
if ( !entry )
|
||||
return;
|
||||
BM_SetName( parent->mwContext(), entry, name->text() );
|
||||
BM_SetAddress( parent->mwContext(), entry, location->text() );
|
||||
BM_SetDescription( parent->mwContext(), entry, description->text() );
|
||||
BM_SaveBookmarks( QtBookmarksContext::ptr()->mwContext(), 0 );
|
||||
}
|
||||
|
||||
void QtBookmarkEditDialog::okSlot()
|
||||
{
|
||||
save();
|
||||
emit okClicked();
|
||||
hide();
|
||||
}
|
||||
|
||||
void QtBookmarkEditDialog::cancelSlot()
|
||||
{
|
||||
clear();
|
||||
emit cancelClicked();
|
||||
hide();
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
/* $Id: QtBookmarkEditDialog.h,v 1.1 1998-09-25 18:01:27 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Eirik Eng.
|
||||
* Further developed by Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik
|
||||
* Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _QTBOOKMARKEDITDIALOG_H
|
||||
#define _QTBOOKMARKEDITDIALOG_H
|
||||
|
||||
#include <qtvbox.h>
|
||||
#include "bkmks.h"
|
||||
|
||||
class QLineEdit;
|
||||
class QMultiLineEdit;
|
||||
class QtBookmarksContext;
|
||||
|
||||
class QtBookmarkEditDialog : public QtVBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtBookmarkEditDialog( QtBookmarksContext* p, const char* wName = 0 );
|
||||
|
||||
void setEntry( BM_Entry* );
|
||||
BM_Entry *bmEntry() { return entry; }
|
||||
|
||||
void clear();
|
||||
void save();
|
||||
void invalidate();
|
||||
|
||||
signals:
|
||||
void okClicked();
|
||||
void cancelClicked();
|
||||
|
||||
private slots:
|
||||
void okSlot();
|
||||
void cancelSlot();
|
||||
|
||||
private:
|
||||
QLineEdit *name;
|
||||
QLineEdit *location;
|
||||
QMultiLineEdit *description;
|
||||
|
||||
BM_Entry *entry;
|
||||
QtBookmarksContext *parent;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,232 +0,0 @@
|
|||
/* $Id: QtBookmarkMenu.cpp,v 1.1 1998-09-25 18:01:27 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Eirik Eng.
|
||||
* Further developed by Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik
|
||||
* Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "QtBookmarkMenu.h"
|
||||
#include "QtBookmarksContext.h"
|
||||
#include "QtBrowserContext.h"
|
||||
#include "menus.h"
|
||||
#include <bkmks.h>
|
||||
#include <qpopmenu.h>
|
||||
#include <time.h>
|
||||
#include <qkeycode.h>
|
||||
#include <qptrdict.h>
|
||||
|
||||
#define i18n(txt) txt
|
||||
|
||||
class QtBMEntryDict : public QIntDict<void>
|
||||
{
|
||||
public:
|
||||
QtBMEntryDict( int size = 17 ) : QIntDict<void>(size) {}
|
||||
~QtBMEntryDict() {}
|
||||
void insert( long k, const BM_Entry *d )
|
||||
{ QIntDict<void>::insert( k,(void*)d); }
|
||||
void replace( long k, const BM_Entry *d )
|
||||
{ QIntDict<void>::replace( k,(void*)d); }
|
||||
BM_Entry *take( long k )
|
||||
{ return (BM_Entry*) QIntDict<void>::take(k); }
|
||||
BM_Entry *find( long k ) const
|
||||
{ return (BM_Entry*) QIntDict<void>::find(k); }
|
||||
BM_Entry *operator[]( long k ) const
|
||||
{ return (BM_Entry*) QIntDict<void>::operator[](k); }
|
||||
};
|
||||
|
||||
static QPtrDict<QtBookmarkMenu> menuDict;
|
||||
|
||||
QtBookmarkMenu::QtBookmarkMenu( QtBrowserContext *b,
|
||||
QWidget *p, const char *wName )
|
||||
: QPopupMenu( p, wName )
|
||||
{
|
||||
root = 0;
|
||||
browser = b;
|
||||
dirty = TRUE;
|
||||
entryDict = new QtBMEntryDict;
|
||||
menuDict.insert( this, this );
|
||||
connect( this, SIGNAL(highlighted(int)), SLOT(highlightedSlot(int)) );
|
||||
connect( this, SIGNAL(activated(int)), SLOT(activatedSlot(int)) );
|
||||
connect( this, SIGNAL(aboutToShow()), SLOT(beforeShow()) );
|
||||
}
|
||||
|
||||
QtBookmarkMenu::~QtBookmarkMenu()
|
||||
{
|
||||
delete entryDict;
|
||||
menuDict.remove( this );
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::insertGuide()
|
||||
{
|
||||
QPopupMenu *tmp = new QPopupMenu();
|
||||
insertItem( *getBMPixmap( QtBMFolderItem, FALSE ), "Guide", tmp );
|
||||
tmp->insertItem( "The &Internet", this, SLOT(guideI()) );
|
||||
tmp->insertItem( "&People", this, SLOT(guideP()) );
|
||||
tmp->insertItem( "&Yellow Pages", this, SLOT(guideY()) );
|
||||
tmp->insertItem( "What's &New", this, SLOT(guideN()) );
|
||||
tmp->insertItem( "What's &Cool", this, SLOT(guideC()) );
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::populate()
|
||||
{
|
||||
clear();
|
||||
if ( browser ) {
|
||||
insertItem( i18n( "&Add Bookmark" ), this, SLOT(cmdAddBookmark()),
|
||||
ALT + Key_K, MENU_BOOKMARK_ADD );
|
||||
setAccel( MENU_BOOKMARK_ADD, ALT+Key_K );
|
||||
}
|
||||
insertItem( i18n( "&Edit Bookmarks" ), QtBookmarksContext::ptr(),
|
||||
SLOT(cmdEditBookmarks()), ALT + Key_B, MENU_BOOKMARK_EDIT );
|
||||
int idCounter = MENU_BMF_BOOKMARKS_OFFSET;
|
||||
insertSeparator();
|
||||
insertGuide();
|
||||
insertItem( i18n( "Troll Tech" ), this, SLOT(trollTech()), idCounter++ );
|
||||
insertSeparator();
|
||||
idCounter++;
|
||||
populate( this, QtBookmarksContext::ptr()->rootEntry(), &idCounter);
|
||||
if ( width() > 250 )
|
||||
resize( 250, height() );
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::clear()
|
||||
{
|
||||
entryDict->clear();
|
||||
QPopupMenu::clear();
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::cmdAddBookmark()
|
||||
{
|
||||
if ( browser ) {
|
||||
BM_Entry* entry;
|
||||
MWContext *c = browser->mwContext();
|
||||
entry = BM_NewUrl( c->title ? c->title : c->url, c->url, 0, time(0) );
|
||||
|
||||
BM_Entry *tmp = BM_GetChildren(QtBookmarksContext::ptr()->rootEntry());
|
||||
BM_Entry *prev = 0;
|
||||
while( tmp ) {
|
||||
prev = tmp;
|
||||
tmp = BM_GetNext(tmp);
|
||||
}
|
||||
BM_InsertItemAfter( QtBookmarksContext::ptr()->mwContext(),prev,entry);
|
||||
BM_SaveBookmarks( QtBookmarksContext::ptr()->mwContext(), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::highlightedSlot( int id )
|
||||
{
|
||||
BM_Entry *entry = entryDict->find( id );
|
||||
if ( entry ) {
|
||||
const char *url = BM_GetAddress( entry );
|
||||
if ( browser )
|
||||
browser->setMessage( url );
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::activatedSlot( int id )
|
||||
{
|
||||
BM_Entry *entry = entryDict->find( id );
|
||||
if ( entry ) {
|
||||
const char *url = BM_GetAddress( entry );
|
||||
URL_Struct * urlStruct = NET_CreateURLStruct(url,NET_DONT_RELOAD);
|
||||
if ( browser )
|
||||
browser->getURL( urlStruct );
|
||||
else
|
||||
QtContext::makeNewWindow( urlStruct, 0, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::invalidate()
|
||||
{
|
||||
QPtrDictIterator<QtBookmarkMenu> it(menuDict);
|
||||
while( it.current() ) {
|
||||
it.current()->dirty = TRUE;
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::beforeShow()
|
||||
{
|
||||
if ( dirty ) {
|
||||
populate();
|
||||
dirty = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::goTo( const char *url)
|
||||
{
|
||||
URL_Struct * urlStruct = NET_CreateURLStruct( url, NET_DONT_RELOAD );
|
||||
if ( browser )
|
||||
browser->getURL( urlStruct );
|
||||
else
|
||||
QtContext::makeNewWindow( urlStruct, 0, 0, 0 );
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::trollTech()
|
||||
{
|
||||
goTo( "http://www.troll.no" );
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::guideI()
|
||||
{
|
||||
goTo( "http://guide.netscape.com/" );
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::guideP()
|
||||
{
|
||||
goTo( "http://guide.netscape.com/guide/people.html" );
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::guideY()
|
||||
{
|
||||
goTo( "http://guide.netscape.com/guide/yellow_pages.html" );
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::guideN()
|
||||
{
|
||||
goTo( "http://guide.netscape.com/guide/whats_new.html" );
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::guideC()
|
||||
{
|
||||
goTo( "http://guide.netscape.com/guide/whats_cool.html" );
|
||||
}
|
||||
|
||||
void QtBookmarkMenu::populate( QPopupMenu *popup, BM_Entry *entry,
|
||||
int *idCounter )
|
||||
{
|
||||
BM_Entry *child = BM_GetChildren( entry );
|
||||
|
||||
while( child ) {
|
||||
if ( BM_IsHeader( child ) ) {
|
||||
QPopupMenu *tmp = new QPopupMenu();
|
||||
connect( tmp, SIGNAL(highlighted(int)),
|
||||
SLOT(highlightedSlot(int)) );
|
||||
connect( tmp, SIGNAL(activated(int)),
|
||||
SLOT(activatedSlot(int)) );
|
||||
popup->insertItem( *getBMPixmap( QtBMFolderItem, FALSE ),
|
||||
BM_GetName(child), tmp );
|
||||
populate( tmp, child, idCounter );
|
||||
} else if ( BM_IsSeparator( child) ) {
|
||||
popup->insertSeparator();
|
||||
} else if ( BM_IsUrl( child ) ) {
|
||||
popup->insertItem( *getBMPixmap( QtBMBookmarkItem, FALSE ),
|
||||
BM_GetName(child), *idCounter );
|
||||
entryDict->insert( *idCounter, child );
|
||||
(*idCounter)++;
|
||||
}
|
||||
child = BM_GetNext( child );
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/* $Id: QtBookmarkMenu.h,v 1.1 1998-09-25 18:01:27 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Eirik Eng.
|
||||
* Further developed by Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik
|
||||
* Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _QTBOOKMARKMENU_H
|
||||
#define _QTBOOKMARKMENU_H
|
||||
|
||||
#include <qintdict.h>
|
||||
#include <qpopmenu.h>
|
||||
|
||||
#include "bkmks.h"
|
||||
|
||||
class QLineEdit;
|
||||
class QMultiLineEdit;
|
||||
class QtBrowserContext;
|
||||
class QtBMEntryDict;
|
||||
|
||||
class QtBookmarkMenu : public QPopupMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtBookmarkMenu( QtBrowserContext *b = 0,
|
||||
QWidget* p = 0, const char* wName = 0 );
|
||||
~QtBookmarkMenu();
|
||||
|
||||
static void invalidate();
|
||||
|
||||
public slots:
|
||||
void cmdAddBookmark();
|
||||
|
||||
private slots:
|
||||
void highlightedSlot( int );
|
||||
void activatedSlot( int );
|
||||
void beforeShow();
|
||||
void trollTech();
|
||||
void guideI();
|
||||
void guideP();
|
||||
void guideY();
|
||||
void guideN();
|
||||
void guideC();
|
||||
|
||||
private:
|
||||
void clear();
|
||||
void populate();
|
||||
void populate( QPopupMenu *, BM_Entry *, int *idCounter );
|
||||
void goTo( const char *url );
|
||||
void insertGuide();
|
||||
|
||||
BM_Entry *root;
|
||||
QtBrowserContext *browser;
|
||||
QtBMEntryDict *entryDict;
|
||||
bool dirty;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,842 +0,0 @@
|
|||
/* $Id: QtBookmarksContext.cpp,v 1.1 1998-09-25 18:01:27 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Eirik Eng.
|
||||
* Further developed by Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik
|
||||
* Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
This first approximation hack should be a good starting point. The
|
||||
QListView is very poorly synchronized with the BM api (bkmks.h), editing
|
||||
commands are therefore very poorly handled.
|
||||
|
||||
This should not be too hard to fix.
|
||||
|
||||
The bookmark file is also hardcoded to be the file
|
||||
".netscape/bookmarks.html" under the users home directory.
|
||||
*/
|
||||
|
||||
#include "QtBookmarksContext.h"
|
||||
#include "toolbars.h"
|
||||
#include "DialogPool.h"
|
||||
#include "bkmks.h"
|
||||
|
||||
#include <qmainwindow.h>
|
||||
#include <qmsgbox.h>
|
||||
#include <qtimer.h>
|
||||
#include <qscrollview.h>
|
||||
#include <qapp.h>
|
||||
#include <qlistview.h>
|
||||
#include <qdir.h>
|
||||
|
||||
#include "prefapi.h"
|
||||
#include "layers.h"
|
||||
#include "icons.h"
|
||||
#include "menus.h"
|
||||
#include "QtBrowserContext.h"
|
||||
#include "QtBookmarkEditDialog.h"
|
||||
#include "QtBookmarkMenu.h"
|
||||
|
||||
#define i18n(x) x
|
||||
|
||||
class Folder;
|
||||
|
||||
const int bmIconHeight = 16;
|
||||
|
||||
typedef struct QtBMClipboard {
|
||||
void *buffer;
|
||||
int32 length;
|
||||
};
|
||||
|
||||
class QtBMItem : public QListViewItem
|
||||
{
|
||||
public:
|
||||
QtBMItem( QListView * parent, BM_Entry *e );
|
||||
QtBMItem( Folder * parent, BM_Entry *e );
|
||||
|
||||
const char * text( int column ) const;
|
||||
void setup();
|
||||
virtual QtBMItemType type() = 0;
|
||||
|
||||
BM_Entry *bmEntry() { return entry; }
|
||||
virtual void paintCell( QPainter *, const QColorGroup&,
|
||||
int column, int width, int alignment );
|
||||
protected:
|
||||
BM_Entry *entry;
|
||||
Folder *p;
|
||||
};
|
||||
|
||||
class Folder: public QtBMItem
|
||||
{
|
||||
public:
|
||||
Folder( QListView * parent, BM_Entry *e );
|
||||
Folder( Folder * parent, BM_Entry *e );
|
||||
|
||||
const char * text( int column ) const;
|
||||
|
||||
void setOpen( bool );
|
||||
virtual QtBMItemType type() { return QtBMFolderItem; }
|
||||
|
||||
};
|
||||
|
||||
class Bookmark: public QtBMItem
|
||||
{
|
||||
public:
|
||||
Bookmark( Folder * parent, BM_Entry *e );
|
||||
|
||||
const char * text( int column ) const;
|
||||
virtual QtBMItemType type() { return QtBMBookmarkItem; }
|
||||
};
|
||||
|
||||
QtBMItem::QtBMItem( Folder * parent, BM_Entry *e )
|
||||
: QListViewItem( parent )
|
||||
{
|
||||
p = parent;
|
||||
entry = e;
|
||||
}
|
||||
|
||||
static const char *oneLine( const char *txt )
|
||||
{
|
||||
static QString tmp;
|
||||
|
||||
tmp = txt;
|
||||
int hit = tmp.find( "\n" );
|
||||
if ( hit )
|
||||
return tmp = tmp.left( hit );
|
||||
return tmp;
|
||||
}
|
||||
|
||||
QtBMItem::QtBMItem( QListView * parent, BM_Entry *e )
|
||||
: QListViewItem( parent )
|
||||
{
|
||||
p = 0;
|
||||
entry = e;
|
||||
}
|
||||
|
||||
QPixmap *getBMPixmap( QtBMItemType type, bool isOpen )
|
||||
{
|
||||
static Pixmap openFolder( "BM_FolderO" );
|
||||
static Pixmap closedFolder( "BM_Folder" );
|
||||
static Pixmap bookmark( "BM_Bookmark" );
|
||||
|
||||
if ( type == QtBMFolderItem ) {
|
||||
if ( isOpen )
|
||||
return &openFolder;
|
||||
else
|
||||
return &closedFolder;
|
||||
}
|
||||
return &bookmark;
|
||||
}
|
||||
|
||||
|
||||
void QtBMItem::paintCell( QPainter *p, const QColorGroup &cg,
|
||||
int column, int width, int /* alignment */ )
|
||||
{
|
||||
if ( column == 0 ) {
|
||||
p->fillRect( 0, 0, width, height(), cg.base() );
|
||||
|
||||
QPixmap *pm = getBMPixmap( type(), isOpen() );
|
||||
QListView *lv = listView();
|
||||
int xpos = lv ? lv->itemMargin() : 2;
|
||||
int ypos = (height() - pm->height())/2;
|
||||
p->drawPixmap( xpos, ypos, *pm );
|
||||
xpos += pm->width() + 2;
|
||||
|
||||
const char * t = text( column );
|
||||
if ( t ) {
|
||||
int marg = lv ? lv->itemMargin() : 2;
|
||||
|
||||
if ( isSelected() &&
|
||||
(column==0 || listView()->allColumnsShowFocus()) ) {
|
||||
if ( listView()->style() == WindowsStyle ) {
|
||||
p->fillRect( xpos - marg, 0, width - xpos + marg, height(),
|
||||
QApplication::winStyleHighlightColor());
|
||||
p->setPen( white ); // ###
|
||||
} else {
|
||||
p->fillRect( xpos - marg, 0, width - xpos
|
||||
+ marg, height(), cg.text() );
|
||||
p->setPen( cg.base() );
|
||||
}
|
||||
} else {
|
||||
p->setPen( cg.text() );
|
||||
}
|
||||
|
||||
p->drawText( xpos, 0, width - marg - xpos, height(),
|
||||
AlignLeft + AlignVCenter, t );
|
||||
}
|
||||
} else {
|
||||
QListViewItem::paintCell( p, cg, column, width, AlignLeft );
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Displays default column texts. Called when columns don't contain data
|
||||
*/
|
||||
const char * QtBMItem::text( int column ) const
|
||||
{
|
||||
return (column == 3) ? "-" : "---";
|
||||
}
|
||||
|
||||
void QtBMItem::setup()
|
||||
{
|
||||
if ( !p )
|
||||
setExpandable( TRUE );
|
||||
else
|
||||
setExpandable( BM_IsHeader(entry) && BM_GetChildren(entry) );
|
||||
setHeight( height() > bmIconHeight ? height() : bmIconHeight );
|
||||
QListViewItem::setup();
|
||||
}
|
||||
|
||||
Folder::Folder( Folder * parent, BM_Entry * e )
|
||||
: QtBMItem( parent, e )
|
||||
{
|
||||
}
|
||||
|
||||
Folder::Folder( QListView * parent, BM_Entry *e )
|
||||
: QtBMItem( parent, e )
|
||||
{
|
||||
}
|
||||
|
||||
void Folder::setOpen( bool o )
|
||||
{
|
||||
if ( o && childCount() == 0 ) {
|
||||
BM_Entry *child = BM_GetChildren( entry );
|
||||
|
||||
while( child ) {
|
||||
if ( BM_IsHeader( child ) ) {
|
||||
new Folder( this, child );
|
||||
} else {
|
||||
new Bookmark( this, child ); // Simplification ###
|
||||
}
|
||||
child = BM_GetNext( child );
|
||||
}
|
||||
}
|
||||
QListViewItem::setOpen( o );
|
||||
}
|
||||
|
||||
const char * Folder::text( int column ) const
|
||||
{
|
||||
switch( column ) {
|
||||
case 0 : return oneLine(BM_GetName(entry)); break;
|
||||
/* loc = fe_ConvertToLocaleEncoding(INTL_DefaultWinCharSetID(NULL),
|
||||
(unsigned char*)name); */
|
||||
case 3 : {
|
||||
const char *txt = oneLine(BM_PrettyAddedOnDate( entry ));
|
||||
return txt ? txt : "-";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return QtBMItem::text( column ); // Display default value
|
||||
}
|
||||
|
||||
|
||||
Bookmark::Bookmark( Folder * parent, BM_Entry * e )
|
||||
: QtBMItem( parent, e )
|
||||
{
|
||||
}
|
||||
|
||||
const char * Bookmark::text( int column ) const
|
||||
{
|
||||
const char *txt = 0;
|
||||
switch( column ) {
|
||||
case 0 : txt = oneLine(BM_GetName(entry)); break;
|
||||
/* loc = fe_ConvertToLocaleEncoding(INTL_DefaultWinCharSetID(NULL),
|
||||
(unsigned char*)name); */
|
||||
case 1 : txt = oneLine(BM_GetAddress( entry )); break;
|
||||
case 2 : txt = oneLine(BM_PrettyLastVisitedDate( entry )); break;
|
||||
case 3 : txt = oneLine(BM_PrettyAddedOnDate( entry )); break;
|
||||
};
|
||||
return txt ? txt : QtBMItem::text( column );
|
||||
}
|
||||
|
||||
static QtBookmarksContext *globalBookmarkPtr = 0;
|
||||
|
||||
static void cleanupGlobalBookmarkPtr()
|
||||
{
|
||||
delete globalBookmarkPtr;
|
||||
globalBookmarkPtr = 0;
|
||||
}
|
||||
|
||||
QtBookmarksContext* QtBookmarksContext::ptr()
|
||||
{
|
||||
if ( !globalBookmarkPtr ) {
|
||||
MWContext* context = XP_NewContext();
|
||||
/*
|
||||
context->type = chrome ? chrome->type
|
||||
: parent ? parent->type
|
||||
: MWContextBookmarks
|
||||
*/
|
||||
context->type = MWContextBookmarks;
|
||||
globalBookmarkPtr = new QtBookmarksContext( context );
|
||||
qAddPostRoutine( cleanupGlobalBookmarkPtr );
|
||||
}
|
||||
return globalBookmarkPtr;
|
||||
}
|
||||
|
||||
BM_Entry *QtBookmarksContext::rootEntry()
|
||||
{
|
||||
if ( !bmDataLoaded )
|
||||
loadBookmarks();
|
||||
return BM_GetRoot(mwContext());
|
||||
}
|
||||
|
||||
|
||||
|
||||
QtBookmarksContext::QtBookmarksContext( MWContext *cx )
|
||||
: QtContext(cx)
|
||||
{
|
||||
bookmarkWidget = 0;
|
||||
listView = 0;
|
||||
editDialog = 0;
|
||||
sortColumn = 0;
|
||||
sortAscending = TRUE;
|
||||
bmDataLoaded = FALSE;
|
||||
inBatch = FALSE;
|
||||
clip = new QtBMClipboard;
|
||||
if ( BM_InitializeBookmarksContext( cx ) < 0 ) {
|
||||
printf( "QtBookmarksContext::QtBookmarksContext: "
|
||||
"Cannot initialize bookmarks context.\n" );
|
||||
}
|
||||
BM_SetFEData( mwContext(), this );
|
||||
}
|
||||
|
||||
QtBookmarksContext::~QtBookmarksContext()
|
||||
{
|
||||
delete clip;
|
||||
}
|
||||
|
||||
QtBookmarksContext* QtBookmarksContext::qt( MWContext* c )
|
||||
{
|
||||
QtBookmarksContext *bm = (QtBookmarksContext*)BM_GetFEData( c );
|
||||
if ( !bm )
|
||||
debug("QtBookmarksContext::qt: NULL bookmark context data.");
|
||||
return bm;
|
||||
}
|
||||
|
||||
void QtBookmarksContext::createWidget()
|
||||
{
|
||||
if ( bookmarkWidget )
|
||||
return;
|
||||
if ( !loadBookmarks() ) {
|
||||
printf( "QtBookmarksContext::createWidget:"
|
||||
"Cannot load bookmarks.\n" );
|
||||
}
|
||||
bookmarkWidget = new QMainWindow( 0, "Main bookmark widget" );
|
||||
// use default geometry, etc. as if we are the main widget
|
||||
qApp->setMainWidget(bookmarkWidget);
|
||||
// but there isn't one - multiple browsers all equal.
|
||||
qApp->setMainWidget(0);
|
||||
populateMenuBar( bookmarkWidget->menuBar() );
|
||||
|
||||
listView = new QListView( bookmarkWidget, "Bookmark listview" );
|
||||
|
||||
listView->setRootIsDecorated( TRUE );
|
||||
listView->setFocusPolicy( QWidget::StrongFocus );
|
||||
listView->setSorting( -1 );
|
||||
listView->setCaption( i18n("QtMozilla Bookmarks") );
|
||||
listView->addColumn( i18n("Name"), 150 );
|
||||
listView->addColumn( i18n("Location"), 150 );
|
||||
listView->addColumn( i18n("Last Visited"), 100 );
|
||||
listView->addColumn( i18n("Created On"), 100 );
|
||||
bookmarkWidget->resize( 500, 600 );
|
||||
|
||||
connect( listView, SIGNAL(doubleClicked(QListViewItem*)),
|
||||
SLOT(activateItem(QListViewItem*)) );
|
||||
|
||||
connect( listView, SIGNAL(returnPressed(QListViewItem*)),
|
||||
SLOT(activateItem(QListViewItem*)) );
|
||||
|
||||
connect( listView, SIGNAL(selectionChanged(QListViewItem*)),
|
||||
SLOT(newSelected(QListViewItem*)) );
|
||||
|
||||
connect( listView,
|
||||
SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)),
|
||||
SLOT(rightClick(QListViewItem*,const QPoint&,int)) );
|
||||
|
||||
Folder *root = new Folder( listView, BM_GetRoot(mwContext()) );
|
||||
root->setOpen( TRUE );
|
||||
|
||||
bookmarkWidget->setCentralWidget( listView );
|
||||
bookmarkWidget->show();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::invalidateListView()
|
||||
{
|
||||
if ( listView ) {
|
||||
listView->clear();
|
||||
Folder *root = new Folder( listView, BM_GetRoot(mwContext()) );
|
||||
root->setOpen( TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarksContext::createEditDialog()
|
||||
{
|
||||
if ( editDialog )
|
||||
return;
|
||||
editDialog = new QtBookmarkEditDialog( this );
|
||||
editDialog->setFixedWidth( 400 );
|
||||
editDialog->show();
|
||||
}
|
||||
|
||||
bool QtBookmarksContext::loadBookmarks( const char *fName )
|
||||
{
|
||||
QString url(512); // XFE uses 512 here.
|
||||
XP_StatStruct st;
|
||||
int result;
|
||||
QString fileName = fName;
|
||||
if ( fileName.isNull() ) {
|
||||
char *buf;
|
||||
if ( PREF_CopyCharPref( "browser.bookmark_file", &buf ) == PREF_OK ) {
|
||||
fileName = buf;
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
#if defined(XP_UNIX)
|
||||
if ( fileName.isNull() ) { //### should get this from backend instead
|
||||
QDir d = QDir::home();
|
||||
fileName = d.filePath( ".netscape/bookmarks.html" );
|
||||
}
|
||||
#endif
|
||||
result = XP_Stat( fileName, &st, xpBookmarks);
|
||||
|
||||
if (result == -1 && errno == ENOENT && !fileName.isEmpty() ) {
|
||||
printf ("Since the bookmarks file does not exist, "
|
||||
"try to copy the default one, eh, well, not implemented.\n");
|
||||
/* char *defaultBM = fe_getDefaultBookmarks();
|
||||
|
||||
if (defaultBM) {
|
||||
copyBookmarksFile(filename, defaultBM);
|
||||
XP_FREE(defaultBM);
|
||||
}*/
|
||||
return FALSE;
|
||||
}
|
||||
url.sprintf( "file:%s", (const char *) fileName );
|
||||
|
||||
BM_ReadBookmarksFromDisk( mwContext(), fileName.data(), url);
|
||||
bmDataLoaded = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdEditBookmarks()
|
||||
{
|
||||
createWidget();
|
||||
bookmarkWidget->show();
|
||||
bookmarkWidget->raise();
|
||||
}
|
||||
|
||||
|
||||
void QtBookmarksContext::editNewEntry( BM_Entry *newEntry )
|
||||
{
|
||||
createEditDialog();
|
||||
BM_Entry *entry = currentEntry();
|
||||
if ( !entry )
|
||||
entry = rootEntry();
|
||||
BM_InsertItemAfter( mwContext(), entry, newEntry);
|
||||
|
||||
editDialog->show();
|
||||
editDialog->raise();
|
||||
editDialog->setEntry( newEntry );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdNewBookmark()
|
||||
{
|
||||
createWidget();
|
||||
editNewEntry( BM_NewUrl( "", "", 0, 0 ) );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdNewFolder()
|
||||
{
|
||||
createWidget();
|
||||
editNewEntry( BM_NewHeader( "" ) );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdNewSeparator()
|
||||
{
|
||||
createWidget();
|
||||
BM_ObeyCommand( mwContext(), BM_Cmd_InsertSeparator );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdOpenBookmarkFile()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdImport()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdSaveAs()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdOpenSelected()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdOpenAddToToolbar()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdClose()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdExit()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
|
||||
void QtBookmarksContext::cmdUndo()
|
||||
{
|
||||
createWidget();
|
||||
if ( bmSelectHighlighted() )
|
||||
BM_ObeyCommand( mwContext(), BM_Cmd_Undo );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdRedo()
|
||||
{
|
||||
createWidget();
|
||||
if ( bmSelectHighlighted() )
|
||||
BM_ObeyCommand( mwContext(), BM_Cmd_Redo );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdCut()
|
||||
{
|
||||
createWidget();
|
||||
if ( bmSelectHighlighted() )
|
||||
BM_ObeyCommand( mwContext(), BM_Cmd_Cut );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdCopy()
|
||||
{
|
||||
createWidget();
|
||||
if ( bmSelectHighlighted() )
|
||||
BM_ObeyCommand( mwContext(), BM_Cmd_Copy );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdPaste()
|
||||
{
|
||||
createWidget();
|
||||
if ( bmSelectHighlighted() )
|
||||
BM_ObeyCommand( mwContext(), BM_Cmd_Paste );
|
||||
}
|
||||
|
||||
|
||||
BM_Entry *QtBookmarksContext::currentEntry()
|
||||
{
|
||||
createWidget();
|
||||
QtBMItem * current = (QtBMItem*)listView->currentItem();
|
||||
return current ? current->bmEntry() : 0;
|
||||
}
|
||||
|
||||
bool QtBookmarksContext::bmSelectHighlighted()
|
||||
{
|
||||
BM_Entry *entry = currentEntry();
|
||||
if ( entry ) {
|
||||
BM_SelectItem( mwContext(), entry, FALSE, FALSE, TRUE );
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdDelete()
|
||||
{
|
||||
createWidget();
|
||||
if ( bmSelectHighlighted() )
|
||||
BM_ObeyCommand( mwContext(), BM_Cmd_Delete );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdSelectAll()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdFindInObject()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdFindAgain()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdSearch()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdSearchAddress()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdBookmarkProperties()
|
||||
{
|
||||
createWidget();
|
||||
QtBMItem * current = (QtBMItem*)listView->currentItem();
|
||||
if ( current ) {
|
||||
createEditDialog();
|
||||
editDialog->setEntry( current->bmEntry() );
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarksContext::changeSorting( int column, bool ascending )
|
||||
{
|
||||
createWidget();
|
||||
sortColumn = column;
|
||||
sortAscending = ascending;
|
||||
listView->setSorting( sortColumn, sortAscending );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdSortByTitle()
|
||||
{
|
||||
changeSorting( 0, sortAscending );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdSortByLocation()
|
||||
{
|
||||
changeSorting( 1, sortAscending );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdSortByDateLastVisited()
|
||||
{
|
||||
changeSorting( 2, sortAscending );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdSortByDateCreated()
|
||||
{
|
||||
changeSorting( 3, sortAscending );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdSortAscending()
|
||||
{
|
||||
changeSorting( sortColumn, TRUE );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdSortDescending()
|
||||
{
|
||||
changeSorting( sortColumn, FALSE );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdBookmarkUp()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdBookmarkDown()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdBookmarkWhatsNew()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdSetToolbarFolder()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdSetNewBookmarkFolder()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::cmdSetBookmarkMenuFolder()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
/*************** Implementation of BMFE_ funcs start here: ***************/
|
||||
|
||||
void QtBookmarksContext::refreshCells ( int32 /*first*/, int32 /*last*/, bool /*now*/)
|
||||
{
|
||||
if ( listView )
|
||||
listView->triggerUpdate(); // Not worth the trouble to search
|
||||
}
|
||||
|
||||
void QtBookmarksContext::syncDisplay ()
|
||||
{
|
||||
refreshCells( 1, BM_LAST_CELL, TRUE );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::measureEntry ( BM_Entry* entry,
|
||||
uint32* width, uint32* height)
|
||||
{
|
||||
}
|
||||
|
||||
void QtBookmarksContext::setClipContents ( void* buffer, int32 length)
|
||||
{
|
||||
freeClipContents();
|
||||
|
||||
clip->buffer = XP_ALLOC(length);
|
||||
XP_MEMCPY(clip->buffer, buffer, length);
|
||||
clip->length = length;
|
||||
}
|
||||
|
||||
void *QtBookmarksContext::getClipContents ( int32* length)
|
||||
{
|
||||
if (length)
|
||||
*length = clip->length;
|
||||
|
||||
return (clip->buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QtBookmarksContext::freeClipContents ()
|
||||
{
|
||||
if (clip->buffer)
|
||||
XP_FREE(clip->buffer);
|
||||
|
||||
clip->buffer = NULL;
|
||||
clip->length = 0;
|
||||
}
|
||||
|
||||
void QtBookmarksContext::openBookmarksWindow ()
|
||||
{
|
||||
createEditDialog();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::editItem ( BM_Entry* entry)
|
||||
{
|
||||
createEditDialog();
|
||||
editDialog->show();
|
||||
editDialog->raise();
|
||||
editDialog->setEntry( entry );
|
||||
}
|
||||
|
||||
void QtBookmarksContext::entryGoingAway ( BM_Entry* entry)
|
||||
{
|
||||
if ( editDialog && entry == editDialog->bmEntry() ) {
|
||||
editDialog->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarksContext::gotoBookmark (
|
||||
const char* url, const char* target)
|
||||
{
|
||||
QtContext::makeNewWindow( NET_CreateURLStruct(url,NET_DONT_RELOAD),0,0,0);
|
||||
}
|
||||
|
||||
/*
|
||||
void reuseBrowser( MWContext *context, URL_Struct *url )
|
||||
{
|
||||
if (!context) {
|
||||
QtContext::makeNewWindow( url, 0, 0, 0 );
|
||||
return;
|
||||
}
|
||||
// otherwise, just get any other Browser context
|
||||
XP_List *context_list = XP_GetGlobalContextList();
|
||||
int n_context_list = XP_ListCount(context_list);
|
||||
for (i = 1; i <= n_context_list; i++) {
|
||||
MWContext * compContext = (MWContext *)XP_ListGetObjectNum(context_list, i);
|
||||
if (compContext->type == MWContextBrowser &&
|
||||
!compContext->is_grid_cell
|
||||
&& !CONTEXT_DATA(compContext)->hasCustomChrome
|
||||
&& compContext->pHelpInfo == NULL
|
||||
&& !(context->name != NULL && // don't use view source either
|
||||
XP_STRNCMP(context->name, "view-source", 11) == 0)) {
|
||||
FE_RaiseWindow(compContext);
|
||||
return compContext;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
void *QtBookmarksContext::openFindWindow ( BM_FindInfo* findInfo)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QtBookmarksContext::scrollIntoView ( BM_Entry* entry)
|
||||
{
|
||||
}
|
||||
|
||||
void QtBookmarksContext::bookmarkMenuInvalid ()
|
||||
{
|
||||
QtBookmarkMenu::invalidate();
|
||||
// invalidateListView();
|
||||
}
|
||||
|
||||
void QtBookmarksContext::updateWhatsChanged (
|
||||
const char* url, /* If NULL, just display
|
||||
"Checking..." */
|
||||
int32 done, int32 total,
|
||||
const char* totaltime)
|
||||
{
|
||||
}
|
||||
|
||||
void QtBookmarksContext::finishedWhatsChanged ( int32 totalchecked,
|
||||
int32 numreached, int32 numchanged)
|
||||
{
|
||||
}
|
||||
|
||||
void QtBookmarksContext::startBatch ()
|
||||
{
|
||||
inBatch = TRUE;
|
||||
}
|
||||
|
||||
void QtBookmarksContext::endBatch ()
|
||||
{
|
||||
inBatch = FALSE;
|
||||
}
|
||||
|
||||
/*************** Implementation of BMFE_ funcs ends here: ***************/
|
||||
|
||||
void QtBookmarksContext::activateItem( QListViewItem *i )
|
||||
{
|
||||
QtBMItem *bmItem = (QtBMItem*)i;
|
||||
switch( bmItem->type() ) {
|
||||
case QtBMFolderItem:
|
||||
break;
|
||||
case QtBMBookmarkItem:
|
||||
BM_GotoBookmark( mwContext(), bmItem->bmEntry() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarksContext::rightClick( QListViewItem *i, const QPoint &p, int )
|
||||
{
|
||||
QPopupMenu pop;
|
||||
pop.insertItem( "Edit bookmark" );
|
||||
|
||||
if ( pop.exec(p) != -1 ) {
|
||||
QtBMItem *bmItem = (QtBMItem*)i;
|
||||
editItem( bmItem->bmEntry() );
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarksContext::newSelected( QListViewItem *i )
|
||||
{
|
||||
if ( editDialog && editDialog->isVisible() ) {
|
||||
QtBMItem *bmItem = (QtBMItem*)i;
|
||||
if ( bmItem )
|
||||
editDialog->setEntry( bmItem->bmEntry() );
|
||||
}
|
||||
}
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
/* $Id: QtBookmarksContext.h,v 1.1 1998-09-25 18:01:28 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Eirik Eng.
|
||||
* Further developed by Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik
|
||||
* Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef QTBOOKMARKSCONTEXT_H
|
||||
#define QTBOOKMARKSCONTEXT_H
|
||||
|
||||
#include "QtContext.h"
|
||||
#include <qpopmenu.h>
|
||||
#include <qmainwindow.h>
|
||||
|
||||
class QMainWindow;
|
||||
class QListView;
|
||||
class QListViewItem;
|
||||
|
||||
class QtBrowserContext;
|
||||
struct QtBMClipboard;
|
||||
struct QtBookmarkEditDialog;
|
||||
struct BM_FindInfo;
|
||||
|
||||
class QtBookmarksContext : public QtContext {
|
||||
/* A Bookmark window */
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~QtBookmarksContext();
|
||||
|
||||
static QtBookmarksContext *qt( MWContext *c );
|
||||
|
||||
static QtBookmarksContext *ptr();
|
||||
BM_Entry *rootEntry();
|
||||
|
||||
public slots:
|
||||
void cmdEditBookmarks();
|
||||
|
||||
void cmdNewBookmark();
|
||||
void cmdNewFolder();
|
||||
void cmdNewSeparator();
|
||||
void cmdOpenBookmarkFile();
|
||||
void cmdImport();
|
||||
void cmdSaveAs();
|
||||
void cmdOpenSelected();
|
||||
void cmdOpenAddToToolbar();
|
||||
void cmdClose();
|
||||
void cmdExit();
|
||||
|
||||
void cmdUndo();
|
||||
void cmdRedo();
|
||||
void cmdCut();
|
||||
void cmdCopy();
|
||||
void cmdPaste();
|
||||
void cmdDelete();
|
||||
void cmdSelectAll();
|
||||
void cmdFindInObject();
|
||||
void cmdFindAgain();
|
||||
void cmdSearch();
|
||||
void cmdSearchAddress();
|
||||
void cmdBookmarkProperties();
|
||||
|
||||
void cmdSortByTitle();
|
||||
void cmdSortByLocation();
|
||||
void cmdSortByDateLastVisited();
|
||||
void cmdSortByDateCreated();
|
||||
void cmdSortAscending();
|
||||
void cmdSortDescending();
|
||||
void cmdBookmarkUp();
|
||||
void cmdBookmarkDown();
|
||||
void cmdBookmarkWhatsNew();
|
||||
void cmdSetToolbarFolder();
|
||||
void cmdSetNewBookmarkFolder();
|
||||
void cmdSetBookmarkMenuFolder();
|
||||
|
||||
public:
|
||||
// ***** BMFE_ funcs:
|
||||
|
||||
void refreshCells ( int32 first, int32 last, bool now );
|
||||
void syncDisplay ();
|
||||
void measureEntry ( BM_Entry* entry, uint32* width, uint32* height );
|
||||
void setClipContents ( void* buffer, int32 length );
|
||||
void* getClipContents ( int32* length );
|
||||
void freeClipContents ();
|
||||
void openBookmarksWindow ();
|
||||
void editItem ( BM_Entry* entry );
|
||||
void entryGoingAway ( BM_Entry* entry );
|
||||
void gotoBookmark ( const char* url, const char* target );
|
||||
void* openFindWindow ( BM_FindInfo* findInfo );
|
||||
void scrollIntoView ( BM_Entry* entry );
|
||||
void bookmarkMenuInvalid ();
|
||||
void updateWhatsChanged ( const char* url, int32 done, int32 total,
|
||||
const char* totaltime );
|
||||
void finishedWhatsChanged ( int32 totalchecked,
|
||||
int32 numreached, int32 numchanged );
|
||||
void startBatch ();
|
||||
void endBatch ();
|
||||
|
||||
// ***** End BMFE_ funcs:
|
||||
|
||||
private slots:
|
||||
void activateItem( QListViewItem * );
|
||||
void rightClick( QListViewItem *, const QPoint &, int );
|
||||
void newSelected( QListViewItem * );
|
||||
|
||||
private:
|
||||
QtBookmarksContext( MWContext * );
|
||||
|
||||
void changeSorting( int column, bool ascending );
|
||||
void createWidget();
|
||||
void invalidateListView();
|
||||
void createEditDialog();
|
||||
void initBMData();
|
||||
bool loadBookmarks( const char *fileName = 0 );
|
||||
BM_Entry *currentEntry();
|
||||
bool bmSelectHighlighted();
|
||||
void editNewEntry( BM_Entry* );
|
||||
|
||||
// this method is not implemented in QtBrowserContext.cpp, but in
|
||||
// menus.cpp
|
||||
void populateMenuBar( QMenuBar* );
|
||||
|
||||
QListView *listView;
|
||||
QMainWindow *bookmarkWidget;
|
||||
QtBookmarkEditDialog *editDialog;
|
||||
QtBMClipboard *clip;
|
||||
int sortColumn;
|
||||
bool sortAscending;
|
||||
bool bmDataLoaded;
|
||||
bool inBatch;
|
||||
};
|
||||
|
||||
enum QtBMItemType { QtBMFolderItem, QtBMBookmarkItem };
|
||||
|
||||
QPixmap *getBMPixmap( QtBMItemType type, bool isOpen );
|
||||
|
||||
#endif
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,208 +0,0 @@
|
|||
/* $Id: QtBrowserContext.h,v 1.2 1998-10-20 02:40:45 cls%seawood.org Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. Portions
|
||||
* created by Warwick Allison, Kalle Dalheimer, Eirik Eng, Matthias
|
||||
* Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav Tvete are
|
||||
* Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _QTBROWSERCONTEXT
|
||||
#define _QTBROWSERCONTEXT
|
||||
|
||||
#include "QtContext.h"
|
||||
|
||||
#include <qprinter.h>
|
||||
|
||||
class QMainWindow;
|
||||
class QMenuBar;
|
||||
class QtBrowserScrollView;
|
||||
class Toolbars;
|
||||
class ContextMenu;
|
||||
class QtFormElement;
|
||||
|
||||
class QtBrowserContext : public QtContext {
|
||||
/* A web browser window */
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtBrowserContext(MWContext*, Chrome *, QWidget* parent, const char* name=0, WFlags f=0,
|
||||
int _scrolling_policy = LO_SCROLL_AUTO, int _bw = 0);
|
||||
|
||||
virtual ~QtBrowserContext();
|
||||
|
||||
virtual QWidget *contentWidget() const;
|
||||
virtual QWidget *topLevelWidget() const;
|
||||
|
||||
virtual int documentWidth() const;
|
||||
virtual int documentHeight() const;
|
||||
virtual int scrollWidth() const;
|
||||
virtual int scrollHeight() const;
|
||||
virtual int visibleWidth() const;
|
||||
virtual int visibleHeight() const;
|
||||
|
||||
void setRefreshURLTimer(uint32 secs, char *url);
|
||||
void killRefreshURLTimer();
|
||||
|
||||
void setBackgroundColor(uint8 red, uint8 green, uint8 blue);
|
||||
|
||||
virtual bool securityDialog(int state, char *prefs_toggle);
|
||||
virtual void setDocTitle(char *title);
|
||||
virtual void setDocDimension(int iLocation, int32 iWidth, int32 iLength);
|
||||
virtual void setDocPosition(int iLocation, int32 x, int32 y);
|
||||
|
||||
virtual int documentXOffset() const;
|
||||
virtual int documentYOffset() const;
|
||||
virtual void documentSetContentsPos( int x, int y );
|
||||
|
||||
virtual void setLoadImagesButtonEnabled( bool );
|
||||
virtual void setStopButtonEnabled( bool );
|
||||
|
||||
virtual int enableBackButton();
|
||||
virtual int enableForwardButton();
|
||||
virtual int disableBackButton();
|
||||
virtual int disableForwardButton();
|
||||
|
||||
virtual void displayFormElement(int iLocation,
|
||||
LO_FormElementStruct *form);
|
||||
virtual void getFormElementValue(LO_FormElementStruct *form,
|
||||
bool delete_p, bool submit_p);
|
||||
|
||||
public slots:
|
||||
virtual void cmdOpenBrowser();
|
||||
virtual void cmdComposeMessage();
|
||||
virtual void cmdNewBlank();
|
||||
virtual void cmdNewTemplate();
|
||||
virtual void cmdNewWizard();
|
||||
virtual void cmdOpenPage();
|
||||
virtual void cmdSaveAs();
|
||||
virtual void cmdSaveFrameAs();
|
||||
virtual void cmdSendPage();
|
||||
virtual void cmdSendLink();
|
||||
virtual void cmdEditFrame();
|
||||
virtual void cmdEditPage();
|
||||
virtual void cmdUploadFile();
|
||||
virtual void cmdPrint();
|
||||
virtual void cmdClose();
|
||||
virtual void cmdUndo();
|
||||
virtual void cmdRedo();
|
||||
virtual void cmdCut();
|
||||
virtual void cmdCopy();
|
||||
virtual void cmdPaste();
|
||||
virtual void cmdSelectAll();
|
||||
virtual void cmdFindInObject();
|
||||
virtual void cmdFindAgain();
|
||||
virtual void cmdSearch();
|
||||
virtual void cmdSearchAddress();
|
||||
virtual void cmdEditPreferences();
|
||||
virtual void cmdToggleNavigationToolbar();
|
||||
virtual void cmdToggleLocationToolbar();
|
||||
virtual void cmdTogglePersonalToolbar();
|
||||
virtual void cmdIncreaseFont();
|
||||
virtual void cmdDecreaseFont();
|
||||
virtual void cmdReload();
|
||||
virtual void cmdSuperReload();
|
||||
virtual void cmdShowImages();
|
||||
virtual void cmdRefresh();
|
||||
virtual void cmdStopLoading();
|
||||
virtual void cmdViewPageSource();
|
||||
virtual void cmdViewPageInfo();
|
||||
virtual void cmdPageServices();
|
||||
virtual void cmdBack();
|
||||
virtual void cmdForward();
|
||||
virtual void cmdHome();
|
||||
virtual void cmdOpenNavCenter();
|
||||
virtual void cmdOpenOrBringUpBrowser();
|
||||
virtual void cmdOpenInbox();
|
||||
virtual void cmdOpenNewsgroups();
|
||||
virtual void cmdOpenEditor();
|
||||
virtual void cmdOpenConference();
|
||||
virtual void cmdCalendar();
|
||||
virtual void cmdHostOnDemand();
|
||||
virtual void cmdNetcaster();
|
||||
virtual void cmdToggleTaskbarShowing();
|
||||
virtual void cmdOpenFolders();
|
||||
virtual void cmdOpenAddressBook();
|
||||
virtual void cmdOpenHistory();
|
||||
virtual void cmdJavaConsole();
|
||||
virtual void cmdViewSecurity();
|
||||
virtual void cmdAboutNetscape();
|
||||
virtual void cmdAboutMozilla();
|
||||
virtual void cmdAboutQt();
|
||||
virtual void cmdGuide();
|
||||
|
||||
virtual void cmdSecurityDialog1();
|
||||
virtual void cmdSecurityDialog2();
|
||||
virtual void cmdSecurityDialog3();
|
||||
virtual void cmdSecurityDialog4();
|
||||
virtual void cmdSecurityDialog5();
|
||||
virtual void cmdSecurityDialog6();
|
||||
virtual void cmdSecurityDialog7();
|
||||
|
||||
virtual void setMessage( const char *message, int timeout = 3000 );
|
||||
virtual int getURL(URL_Struct *url);
|
||||
|
||||
// these were fe_* functions
|
||||
void browserGetURL( const char* address );
|
||||
void editorEdit( Chrome*, const char* address );
|
||||
|
||||
void scrollUp();
|
||||
void scrollDown();
|
||||
void pageUp();
|
||||
void pageDown();
|
||||
|
||||
protected:
|
||||
virtual QPainter* makePainter();
|
||||
|
||||
virtual bool handleLayerEvent(CL_Layer *layer,
|
||||
CL_Event *layer_event);
|
||||
bool initImageCallbacks();
|
||||
virtual void setupToolbarSignals();
|
||||
|
||||
|
||||
private slots:
|
||||
void refreshURLNow();
|
||||
void viewMoved(int x, int y);
|
||||
void contextMenuDied();
|
||||
|
||||
private:
|
||||
bool eventFilter( QObject *o, QEvent *e );
|
||||
|
||||
// this method is not implemented in QtBrowserContext.cpp, but in
|
||||
// menus.cpp
|
||||
void populateMenuBar( QMenuBar* );
|
||||
|
||||
// This method is not implemented in QtBrowserContext.cpp, but in
|
||||
// printing.cpp
|
||||
void print( URL_Struct* url, bool print_to_file, const char* filename );
|
||||
|
||||
QMainWindow *browserWidget;
|
||||
QtBrowserScrollView *scrollView;
|
||||
QTimer *refreshURLTimer;
|
||||
QString refreshURL;
|
||||
QPrinter printer;
|
||||
Toolbars * toolbars;
|
||||
|
||||
QString currentMessage;
|
||||
QTimer * messageFlickerTimer;
|
||||
ContextMenu * contextMenu;
|
||||
|
||||
// for forms
|
||||
void moveSubWidget( QWidget* w, int x, int y );
|
||||
void showSubWidget( QWidget* w, bool );
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,652 +0,0 @@
|
|||
/* $Id: QtContext.h,v 1.2 1998-10-20 02:40:45 cls%seawood.org Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. Portions
|
||||
* created by Warwick Allison, Kalle Dalheimer, Eirik Eng, Matthias
|
||||
* Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav Tvete are
|
||||
* Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _QTCONTEXT
|
||||
#define _QTCONTEXT
|
||||
|
||||
#include <client.h>
|
||||
#include <fe_proto.h>
|
||||
#include <xp_file.h>
|
||||
#include <qwidget.h>
|
||||
#include "finding.h"
|
||||
|
||||
struct DialogPool;
|
||||
class QMenuBar;
|
||||
|
||||
|
||||
#if defined(XP_UNIX)
|
||||
#define CONTEXT_DATA(context) ((QtContext*)((context)->fe.data))
|
||||
#elif defined(XP_WIN)
|
||||
#define CONTEXT_DATA(context) ((QtContext*)((context)->fe.cx))
|
||||
#endif
|
||||
|
||||
|
||||
class QtContext : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static QtContext* qt( MWContext* c ) { return CONTEXT_DATA(c); }
|
||||
|
||||
virtual ~QtContext();
|
||||
|
||||
// Below are used by the FE_* functions.
|
||||
|
||||
// MANY of them should be moved wholly into QtBrowserContext
|
||||
|
||||
virtual bool securityDialog(int state, char *prefs_toggle);
|
||||
|
||||
void setPasswordEnabled(bool usePW);
|
||||
|
||||
void setPasswordAskPrefs(int askPW, int timeout);
|
||||
|
||||
void setCipherPrefs(char *cipher);
|
||||
|
||||
void alert(const char *message);
|
||||
virtual bool confirm( const char* message );
|
||||
static bool confirm( QtContext* cx, const char* message );
|
||||
void message(const char* message);
|
||||
|
||||
char * promptMessageSubject();
|
||||
|
||||
void rememberPopPassword(const char *password);
|
||||
|
||||
int promptForFileName(const char *prompt_string,
|
||||
const char *default_path,
|
||||
bool file_must_exist_p,
|
||||
bool directories_allowed_p,
|
||||
ReadFileNameCallbackFunction fn,
|
||||
void *closure);
|
||||
|
||||
char * prompt(const char *message, const char *deflt);
|
||||
|
||||
char * promptWithCaption(const char *caption,
|
||||
const char *message, const char *deflt);
|
||||
|
||||
char * promptPassword(const char *message);
|
||||
|
||||
static MWContext * makeNewWindow(URL_Struct *url=0,
|
||||
char *window_name=0,
|
||||
Chrome *chrome=0,
|
||||
MWContext *parent=0);
|
||||
|
||||
virtual void setRefreshURLTimer(uint32 secs, char *url);
|
||||
virtual void killRefreshURLTimer() {};
|
||||
|
||||
void connectToRemoteHost(int url_type, char *hostname,
|
||||
char *port, char *username);
|
||||
|
||||
int32 getContextID();
|
||||
|
||||
void createEmbedWindow(NPEmbeddedApp *app);
|
||||
|
||||
void saveEmbedWindow(NPEmbeddedApp *app);
|
||||
|
||||
void restoreEmbedWindow(NPEmbeddedApp *app);
|
||||
|
||||
void destroyEmbedWindow(NPEmbeddedApp *app);
|
||||
|
||||
void setDrawable(CL_Drawable *drawable);
|
||||
|
||||
void progress(const char * message);
|
||||
|
||||
void setCallNetlibAllTheTime();
|
||||
|
||||
void clearCallNetlibAllTheTime();
|
||||
|
||||
void graphProgressInit(URL_Struct * ,
|
||||
int32 content_length);
|
||||
|
||||
void graphProgressDestroy(URL_Struct * ,
|
||||
int32 content_length,
|
||||
int32 total_bytes_read);
|
||||
|
||||
void graphProgress(URL_Struct * ,
|
||||
int32 ,
|
||||
int32 bytes_since_last_time,
|
||||
int32 );
|
||||
|
||||
int fileSortMethod();
|
||||
|
||||
void layoutNewDocument(URL_Struct *url,
|
||||
int32 *iWidth, int32 *iHeight,
|
||||
int32 *mWidth, int32 *mHeight);
|
||||
|
||||
virtual void setDocTitle(char *title);
|
||||
|
||||
void finishedLayout();
|
||||
|
||||
void beginPreSection();
|
||||
|
||||
void endPreSection();
|
||||
|
||||
char * translateISOText(int charset, char *ISO_Text);
|
||||
|
||||
void getTextInfo(LO_TextStruct *text,
|
||||
LO_TextInfo *text_info);
|
||||
|
||||
void getTextFrame(LO_TextStruct *text, int32 start,
|
||||
int32 end, XP_Rect *frame);
|
||||
|
||||
void getEmbedSize(LO_EmbedStruct *embed_struct,
|
||||
NET_ReloadMethod force_reload);
|
||||
|
||||
void getJavaAppSize(LO_JavaAppStruct *java_struct,
|
||||
NET_ReloadMethod reloadMethod);
|
||||
|
||||
void getFormElementInfo(LO_FormElementStruct *form);
|
||||
|
||||
virtual void getFormElementValue(LO_FormElementStruct *form,
|
||||
bool delete_p, bool submit_p);
|
||||
|
||||
void resetFormElement(LO_FormElementStruct *form);
|
||||
|
||||
void setFormElementToggle(LO_FormElementStruct *form,
|
||||
bool state);
|
||||
|
||||
void freeEmbedElement(LO_EmbedStruct *embed_struct);
|
||||
|
||||
void freeJavaAppElement(struct LJAppletData *appletData);
|
||||
|
||||
void hideJavaAppElement(struct LJAppletData *appletData);
|
||||
|
||||
void freeEdgeElement(LO_EdgeStruct *edge);
|
||||
|
||||
void formTextIsSubmit(LO_FormElementStruct *form);
|
||||
|
||||
void setProgressBarPercent(int32 percent);
|
||||
|
||||
virtual void setBackgroundColor(uint8 red, uint8 green, uint8 blue);
|
||||
|
||||
void displaySubtext(int iLocation,
|
||||
LO_TextStruct *text, int start_pos, int end_pos,
|
||||
bool need_bg);
|
||||
|
||||
void displayText(int iLocation, LO_TextStruct *text,
|
||||
bool need_bg);
|
||||
|
||||
void displayEmbed(int iLocation, LO_EmbedStruct *embed_struct);
|
||||
|
||||
void displayJavaApp(int iLocation, LO_JavaAppStruct *java_struct);
|
||||
|
||||
void displayEdge(int loc, LO_EdgeStruct *edge);
|
||||
|
||||
void displayTable(int loc, LO_TableStruct *ts);
|
||||
|
||||
void displayCell(int loc, LO_CellStruct *cell);
|
||||
|
||||
void displaySubDoc(int loc, LO_SubDocStruct *sd);
|
||||
|
||||
void displayLineFeed(int iLocation, LO_LinefeedStruct *line_feed, bool need_bg);
|
||||
|
||||
void displayHR(int iLocation, LO_HorizRuleStruct *hr);
|
||||
|
||||
void displayBullet(int iLocation, LO_BulletStruct *bullet);
|
||||
|
||||
virtual void displayFormElement(int iLocation,
|
||||
LO_FormElementStruct *form);
|
||||
|
||||
void displayBorder(int iLocation, int x, int y, int width,
|
||||
int height, int bw, LO_Color *color, LO_LineStyle style);
|
||||
|
||||
void displayFeedback(int iLocation, LO_Element *element);
|
||||
|
||||
void eraseBackground(int iLocation, int32 x, int32 y,
|
||||
uint32 width, uint32 height, LO_Color *bg);
|
||||
|
||||
void clearView(int which);
|
||||
|
||||
virtual void setDocDimension(int iLocation, int32 iWidth, int32 iLength);
|
||||
|
||||
virtual void setDocPosition(int iLocation, int32 x, int32 y);
|
||||
|
||||
void getDocPosition(int iLocation, int32 *iX, int32 *iY); // NOT virtual
|
||||
|
||||
void enableClicking();
|
||||
|
||||
void drawJavaApp(int iLocation, LO_JavaAppStruct *java_struct);
|
||||
|
||||
void allConnectionsComplete();
|
||||
|
||||
void releaseTextAttrFeData(LO_TextAttr *attr);
|
||||
|
||||
void freeFormElement(LO_FormElementData *form_data);
|
||||
|
||||
virtual int enableBackButton();
|
||||
|
||||
virtual int enableForwardButton();
|
||||
|
||||
virtual int disableBackButton();
|
||||
|
||||
virtual int disableForwardButton();
|
||||
|
||||
void updateStopState();
|
||||
|
||||
void * freeGridWindow(bool save_history);
|
||||
|
||||
void restructureGridWindow(int32 x, int32 y,
|
||||
int32 width, int32 height);
|
||||
|
||||
void getFullWindowSize(int32 *width, int32 *height);
|
||||
|
||||
void getEdgeMinSize(int32 *size_p);
|
||||
|
||||
void loadGridCellFromHistory(void *hist,
|
||||
NET_ReloadMethod force_reload);
|
||||
|
||||
void shiftImage(LO_ImageStruct *lo_image);
|
||||
|
||||
void scrollDocTo(int iLocation, int32 x, int32 y);
|
||||
|
||||
void scrollDocBy(int iLocation, int32 deltax, int32 deltay);
|
||||
|
||||
void backCommand();
|
||||
|
||||
void forwardCommand();
|
||||
|
||||
void homeCommand();
|
||||
|
||||
void printCommand();
|
||||
|
||||
void getWindowOffset(int32 *sx, int32 *sy);
|
||||
|
||||
void getScreenSize(int32 *sx, int32 *sy);
|
||||
|
||||
void getAvailScreenRect(int32 *sx, int32 *sy, int32 *left, int32 *top);
|
||||
|
||||
void getPixelAndColorDepth(int32 *pixelDepth,
|
||||
int32 *colorDepth);
|
||||
|
||||
void setWindowLoading(URL_Struct *url,
|
||||
Net_GetUrlExitFunc **exit_func_p);
|
||||
|
||||
void raiseWindow();
|
||||
|
||||
void destroyWindow();
|
||||
|
||||
void getDocAndWindowPosition(int32 *pX, int32 *pY,
|
||||
int32 *pWidth, int32 *pHeight );
|
||||
|
||||
void displayTextCaret(int iLocation, LO_TextStruct* text,
|
||||
int char_offset);
|
||||
|
||||
void displayImageCaret(LO_ImageStruct* image,
|
||||
ED_CaretObjectPosition caretPos);
|
||||
|
||||
void displayGenericCaret(LO_Any * image,
|
||||
ED_CaretObjectPosition caretPos );
|
||||
|
||||
bool getCaretPosition(LO_Position* where,
|
||||
int32* caretX, int32* caretYLow, int32* caretYHigh
|
||||
);
|
||||
|
||||
void destroyCaret();
|
||||
|
||||
void showCaret();
|
||||
|
||||
void documentChanged(int32 p_y, int32 p_height);
|
||||
|
||||
void setNewDocumentProperties();
|
||||
|
||||
void imageLoadDialog();
|
||||
|
||||
void imageLoadDialogDestroy();
|
||||
|
||||
void saveDialogCreate(int nfiles, ED_SaveDialogType saveType);
|
||||
|
||||
void saveDialogSetFilename(char* filename);
|
||||
|
||||
void finishedSave(int status,
|
||||
char *pDestURL, int iFileNumber);
|
||||
|
||||
void saveDialogDestroy(int status, char* file_url);
|
||||
|
||||
bool saveErrorContinueDialog(char* filename,
|
||||
ED_FileError error);
|
||||
|
||||
void clearBackgroundImage();
|
||||
|
||||
void editorDocumentLoaded();
|
||||
|
||||
void displayAddRowOrColBorder(XP_Rect *pRect,
|
||||
bool bErase);
|
||||
|
||||
void displayEntireTableOrCell(LO_Element* pLoElement);
|
||||
|
||||
void focusInputElement(LO_Element *element);
|
||||
|
||||
void blurInputElement(LO_Element *element);
|
||||
|
||||
void selectInputElement(LO_Element *element);
|
||||
|
||||
void changeInputElement(LO_Element *element);
|
||||
|
||||
void submitInputElement(LO_Element *element);
|
||||
|
||||
void clickInputElement(LO_Element *xref);
|
||||
|
||||
virtual bool handleLayerEvent(CL_Layer *layer,
|
||||
CL_Event *layer_event);
|
||||
|
||||
bool handleEmbedEvent(LO_EmbedStruct *embed,
|
||||
CL_Event *event);
|
||||
|
||||
void updateChrome(Chrome *chrome);
|
||||
|
||||
void queryChrome(Chrome * chrome);
|
||||
|
||||
MWContext * makeGridWindow(void *hist_list, void *history,
|
||||
int x, int y, int width, int height,
|
||||
char *url_str, char *window_name, int scrolling,
|
||||
NET_ReloadMethod force_reload, bool no_edge);
|
||||
|
||||
void clearDNSSelect(int socket);
|
||||
|
||||
void setReadSelect(int fd);
|
||||
|
||||
void clearReadSelect(int fd);
|
||||
|
||||
void setConnectSelect(int fd);
|
||||
|
||||
void clearConnectSelect(int fd);
|
||||
|
||||
void setFileReadSelect(int fd);
|
||||
|
||||
void clearFileReadSelect(int fd);
|
||||
|
||||
char* getTempFileFor(const char* fname,
|
||||
XP_FileType ftype, XP_FileType* rettype);
|
||||
|
||||
virtual int getURL( URL_Struct *url );
|
||||
|
||||
// Below are used by the Qt FE, not by the FE_* functions.
|
||||
|
||||
// return a QFont* for a given Netscape TextStruct.
|
||||
// This will use a cached result if possible
|
||||
QFont getFont(LO_TextAttr *text);
|
||||
|
||||
virtual void perror( const char* message );
|
||||
|
||||
virtual void urlDone(URL_Struct *, int) { }
|
||||
|
||||
virtual QWidget* contentWidget() const { return 0; }
|
||||
virtual QWidget *topLevelWidget() const { return 0; }
|
||||
|
||||
virtual int documentWidth() const {return 0; }
|
||||
virtual int documentHeight() const {return 0; }
|
||||
virtual void documentSetContentsPos( int, int ) {}
|
||||
virtual int scrollWidth() const { return 0; }
|
||||
virtual int scrollHeight() const { return 0; }
|
||||
virtual int visibleWidth() const {return 0; }
|
||||
virtual int visibleHeight() const {return 0; }
|
||||
|
||||
void updateRect(int x, int y, int w, int h);
|
||||
|
||||
MWContext* mwContext() const { return context; }
|
||||
|
||||
void setTransparentPixel( const QColor & );
|
||||
|
||||
virtual int documentXOffset() const;
|
||||
virtual int documentYOffset() const;
|
||||
|
||||
void clearPainter();
|
||||
QPainter* painter() const
|
||||
{ if (internal_painter) return internal_painter;
|
||||
else return forcePainter(); }
|
||||
|
||||
|
||||
void setDrawableOrigin(int x_origin, int yorigin);
|
||||
int getXOrigin() { return internal_x_origin; }
|
||||
int getYOrigin() { return internal_y_origin; }
|
||||
|
||||
bool isGridParent( MWContext* ) const;
|
||||
int getSynchronousURL ( QWidget* widget_to_grab,
|
||||
const char *title,
|
||||
URL_Struct *url,
|
||||
int output_format,
|
||||
void *call_data );
|
||||
int getSecondaryURL( URL_Struct *url_struct,
|
||||
int output_format,
|
||||
void *call_data, bool skip_get_url );
|
||||
void saveURL ( URL_Struct *url );
|
||||
|
||||
DialogPool* dialogPool() const { return dialogpool; }
|
||||
|
||||
public slots:
|
||||
void cmdQuit();
|
||||
|
||||
signals:
|
||||
void messengerMessage(const char*, int);
|
||||
void messengerMessageClear();
|
||||
void progressStarting( int );
|
||||
void progressMade( int );
|
||||
void progressMade();
|
||||
void progressFinished();
|
||||
void progressReport( const char * );
|
||||
void canStop( bool );
|
||||
void urlChanged( const char * );
|
||||
|
||||
protected:
|
||||
QtContext( MWContext* );
|
||||
virtual QPainter* makePainter();
|
||||
|
||||
// re-call document[XY]Offset and
|
||||
void adjustCompositorSize();
|
||||
void adjustCompositorPosition();
|
||||
|
||||
// access the context-specific variable via this pointer
|
||||
DialogPool* dialogpool;
|
||||
|
||||
virtual void setupToolbarSignals(){};
|
||||
int bw;
|
||||
int scrolling_policy; // LO_SCROLL_YES, ..NO, .. AUTO, ... NEVER
|
||||
|
||||
private:
|
||||
QPainter* forcePainter() const;
|
||||
QPainter* internal_painter;
|
||||
|
||||
// for drawing.cpp ---------------------
|
||||
|
||||
QColorGroup colorGroup(const QColor&);
|
||||
|
||||
void displayTableBorder(LO_TableStruct *ts, QRect r, int bw);
|
||||
|
||||
int internal_x_origin;
|
||||
int internal_y_origin;
|
||||
// end drawing.cpp ---------------------
|
||||
|
||||
CL_Compositor* createCompositor(MWContext* context);
|
||||
MWContext* context;
|
||||
|
||||
public:
|
||||
// stuff for the threading or whatever
|
||||
int dont_free_context_memory;
|
||||
QWidget* synchronous_url_dialog;
|
||||
int synchronous_url_exit_status;
|
||||
unsigned char delete_response;
|
||||
bool destroyed;
|
||||
bool looping_images_p; /* TRUE if images are looping. */
|
||||
int active_url_count;
|
||||
bool clicking_blocked;
|
||||
bool have_tried_progress;
|
||||
|
||||
fe_FindData find_data;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class QtMailContext : public QtContext {
|
||||
/* A mail reader window */
|
||||
public:
|
||||
QtMailContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtNewsContext : public QtContext {
|
||||
/* A news reader window */
|
||||
public:
|
||||
QtNewsContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtMailMsgContext : public QtContext {
|
||||
/* A window to display a mail msg */
|
||||
public:
|
||||
QtMailMsgContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtNewsMsgContext : public QtContext {
|
||||
/* A window to display a news msg */
|
||||
public:
|
||||
QtNewsMsgContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtMessageCompositionContext : public QtContext {
|
||||
/* A news-or-mail message editing window */
|
||||
public:
|
||||
QtMessageCompositionContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtSaveToDiskContext : public QtContext {
|
||||
/* The placeholder window for a download */
|
||||
public:
|
||||
QtSaveToDiskContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtTextContext : public QtContext {
|
||||
/* non-window context for text conversion */
|
||||
public:
|
||||
QtTextContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtPostScriptContext : public QtContext {
|
||||
/* non-window context for PS conversion */
|
||||
public:
|
||||
QtPostScriptContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtBiffContext : public QtContext {
|
||||
/* non-window context for background mail notification */
|
||||
public:
|
||||
QtBiffContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtJavaContext : public QtContext {
|
||||
/* non-window context for Java */
|
||||
public:
|
||||
QtJavaContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtAddressBookContext : public QtContext {
|
||||
/* Context for the addressbook */
|
||||
public:
|
||||
QtAddressBookContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtOleNetworkContext : public QtContext {
|
||||
/* non-window context for the OLE network1 object */
|
||||
public:
|
||||
QtOleNetworkContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtPrintContext : public QtContext {
|
||||
/* non-window context for printing */
|
||||
public:
|
||||
QtPrintContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtDialogContext : public QtContext {
|
||||
/* non-browsing dialogs. view-source/security */
|
||||
public:
|
||||
QtDialogContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtMetaFileContext : public QtContext {
|
||||
/* non-window context for Windows metafile support */
|
||||
public:
|
||||
QtMetaFileContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtEditorContext : public QtContext {
|
||||
/* An Editor Window */
|
||||
public:
|
||||
QtEditorContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtSearchContext : public QtContext {
|
||||
/* a window for modeless search dialog */
|
||||
public:
|
||||
QtSearchContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtSearchLdapContext : public QtContext {
|
||||
/* a window for modeless LDAP search dialog */
|
||||
public:
|
||||
QtSearchLdapContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtHTMLHelpContext : public QtContext {
|
||||
/* HTML Help context to load map files */
|
||||
public:
|
||||
QtHTMLHelpContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtMailFiltersContext : public QtContext {
|
||||
/* Mail filters context */
|
||||
public:
|
||||
QtMailFiltersContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
|
||||
class QtMailNewsProgressContext : public QtContext {
|
||||
/* a progress pane for mail/news URLs */
|
||||
public:
|
||||
QtMailNewsProgressContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtPaneContext : public QtContext {
|
||||
/* Misc browser pane/window in weird parts of the UI, eg. navigation center */
|
||||
public:
|
||||
QtPaneContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtRDFSlaveContext : public QtContext {
|
||||
/* Slave context for RDF network loads */
|
||||
public:
|
||||
QtRDFSlaveContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtProgressModuleContext : public QtContext {
|
||||
/* Progress module (PW_ functions) */
|
||||
public:
|
||||
QtProgressModuleContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
class QtIconContext : public QtContext {
|
||||
/* Context for loading images as icons */
|
||||
public:
|
||||
QtIconContext(MWContext* cx) : QtContext(cx) { }
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
void url_exit(URL_Struct *url, int status, MWContext *context);
|
||||
void imageGroupObserver(XP_Observable observable, XP_ObservableMsg message,
|
||||
void *message_data, void *closure);
|
||||
|
||||
}
|
||||
#endif
|
|
@ -1,38 +0,0 @@
|
|||
/* $Id: QtEventPusher.h,v 1.1 1998-09-25 18:01:29 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. Portions
|
||||
* created by Warwick Allison, Kalle Dalheimer, Eirik Eng, Matthias
|
||||
* Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav Tvete are
|
||||
* Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef QTEVENTPUSHER_H
|
||||
#define QTEVENTPUSHER_H
|
||||
|
||||
|
||||
#include <qobject.h>
|
||||
|
||||
class QtEventPusher : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtEventPusher(int fd);
|
||||
private slots:
|
||||
void push(int);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -1,575 +0,0 @@
|
|||
/*-*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* $Id: QtHistoryContext.cpp,v 1.1 1998-09-25 18:01:29 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* First version of this file written 1998 by Jonas Utterstrom
|
||||
* <mailto:jonas.utterstrom@vittran.norrnod.se>
|
||||
*/
|
||||
|
||||
|
||||
#include "QtHistoryContext.h"
|
||||
#include "DialogPool.h"
|
||||
|
||||
#include <qmainwindow.h>
|
||||
#include <qmsgbox.h>
|
||||
#include <qtimer.h>
|
||||
#include <qscrollview.h>
|
||||
#include <qapp.h>
|
||||
#include <qlistview.h>
|
||||
#include <qdir.h>
|
||||
#include <qaccel.h>
|
||||
#include <qmenubar.h>
|
||||
|
||||
|
||||
#include "prefapi.h"
|
||||
#include "layers.h"
|
||||
#include "icons.h"
|
||||
#include "menus.h"
|
||||
#include "QtBrowserContext.h"
|
||||
#include "histlistview.h"
|
||||
#include <xplocale.h>
|
||||
|
||||
#define i18n(x) x
|
||||
|
||||
static const int TITLE = 0;
|
||||
static const int LOCATION = 1;
|
||||
static const int LASTVISITED = 2;
|
||||
static const int FIRSTVISITED = 3;
|
||||
static const int EXPIRES = 4;
|
||||
static const int VISITCOUNT = 5;
|
||||
|
||||
|
||||
//
|
||||
// HistoryItem
|
||||
//
|
||||
|
||||
class HistoryViewItem : public QListViewItem
|
||||
{
|
||||
public:
|
||||
HistoryViewItem(QListView* parent);
|
||||
virtual const char* key(int, bool) const;
|
||||
};
|
||||
|
||||
HistoryViewItem::HistoryViewItem(QListView* parent)
|
||||
: QListViewItem(parent)
|
||||
{
|
||||
}
|
||||
|
||||
const char* HistoryViewItem::key(int column, bool ascending) const
|
||||
{
|
||||
char *exitc;
|
||||
const char* currc;
|
||||
static char buffer[1024]; // warning, overflow possible
|
||||
int count;
|
||||
const char* ret = text(column);
|
||||
|
||||
if (ret==0)
|
||||
return 0; // hmm, no string in column, maybe is something wrong
|
||||
|
||||
switch (column)
|
||||
{
|
||||
case TITLE:
|
||||
// Convert title to downcase letters to get correct sorting
|
||||
currc = ret;
|
||||
ret = exitc = buffer;
|
||||
while ((*currc)!='\0')
|
||||
*exitc++ = tolower(*currc++);
|
||||
break;
|
||||
case VISITCOUNT:
|
||||
// Insert padding zeros to get correct sorting in the visit count column
|
||||
count = strtol(ret, &exitc, 10);
|
||||
if ((*exitc)=='\0')
|
||||
{
|
||||
sprintf(buffer, "%09d\n", count);
|
||||
ret = buffer;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//
|
||||
// QtHistoryContext
|
||||
//
|
||||
|
||||
static QtHistoryContext *gpHistory = 0;
|
||||
|
||||
static void cleanupHistory()
|
||||
{
|
||||
delete gpHistory;
|
||||
gpHistory = 0;
|
||||
}
|
||||
|
||||
|
||||
QtHistoryContext* QtHistoryContext::ptr()
|
||||
{
|
||||
if ( !gpHistory )
|
||||
{
|
||||
MWContext* context = XP_NewContext();
|
||||
context->type = MWContextHistory;
|
||||
gpHistory = new QtHistoryContext(context);
|
||||
qAddPostRoutine(cleanupHistory);
|
||||
}
|
||||
return gpHistory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QtHistoryContext::QtHistoryContext(MWContext *cx)
|
||||
: QtContext(cx)
|
||||
{
|
||||
historyWidget = 0;
|
||||
listView = 0;
|
||||
sortColumn = LASTVISITED;
|
||||
sortAscending = TRUE;
|
||||
m_histCursor = 0;
|
||||
}
|
||||
|
||||
QtHistoryContext::~QtHistoryContext()
|
||||
{
|
||||
GH_ReleaseContext(m_histCursor, TRUE);
|
||||
}
|
||||
|
||||
QtHistoryContext* QtHistoryContext::qt( MWContext* c )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QtHistoryContext::createWidget()
|
||||
{
|
||||
if ( historyWidget )
|
||||
return;
|
||||
historyWidget = new QMainWindow( 0, "Main History widget" );
|
||||
// use default geometry, etc. as if we are the main widget
|
||||
qApp->setMainWidget(historyWidget);
|
||||
// but there isn't one - multiple browsers all equal.
|
||||
qApp->setMainWidget(0);
|
||||
populateMenuBar(historyWidget->menuBar());
|
||||
|
||||
listView = new HistoryListView( historyWidget, "History listview");
|
||||
|
||||
listView->setAllColumnsShowFocus(TRUE);
|
||||
listView->setSorting( -1 );
|
||||
listView->setCaption( i18n("History") );
|
||||
listView->addColumn( i18n("Name"), 150 );
|
||||
listView->addColumn( i18n("Location"), 150 );
|
||||
listView->addColumn( i18n("Last Visited"), 100 );
|
||||
listView->addColumn( i18n("First Visited"), 100 );
|
||||
listView->addColumn( i18n("Expires"), 100 );
|
||||
listView->addColumn( i18n("Visit Count"), 100 );
|
||||
historyWidget->resize( 600, 600 );
|
||||
|
||||
// connections
|
||||
connect(listView, SIGNAL(doubleClicked(QListViewItem*)),
|
||||
SLOT(activateItem(QListViewItem*)) );
|
||||
|
||||
connect(listView, SIGNAL(returnPressed(QListViewItem*)),
|
||||
SLOT(activateItem(QListViewItem*)) );
|
||||
|
||||
connect(listView, SIGNAL(selectionChanged(QListViewItem*)),
|
||||
SLOT(newSelected(QListViewItem*)) );
|
||||
|
||||
connect(listView,
|
||||
SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)),
|
||||
SLOT(rightClick(QListViewItem*,const QPoint&,int)) );
|
||||
|
||||
connect(listView,
|
||||
SIGNAL(sortColumnChanged(int, bool)),
|
||||
SLOT(sortColumnChanged(int, bool)));
|
||||
|
||||
|
||||
historyWidget->setCentralWidget( listView );
|
||||
}
|
||||
|
||||
void QtHistoryContext::sortColumnChanged(int column, bool ascending)
|
||||
{
|
||||
QMenuBar *menuBar = historyWidget->menuBar();
|
||||
|
||||
menuBar->setItemChecked(MENU_HIST_VIEW_SORTBYTITLE, column==TITLE);
|
||||
menuBar->setItemChecked(MENU_HIST_VIEW_SORTBYLOCATION, column==LOCATION);
|
||||
menuBar->setItemChecked(MENU_HIST_VIEW_SORTBYDATEFIRSTVISITED, column==FIRSTVISITED);
|
||||
menuBar->setItemChecked(MENU_HIST_VIEW_SORTBYDATELASTVISITED, column==LASTVISITED);
|
||||
menuBar->setItemChecked(MENU_HIST_VIEW_EXPIRATIONDATE, column==EXPIRES);
|
||||
menuBar->setItemChecked(MENU_HIST_VIEW_VISITCOUNT, column==VISITCOUNT);
|
||||
|
||||
menuBar->setItemChecked(MENU_HIST_VIEW_SORTASCENDING, ascending);
|
||||
menuBar->setItemChecked(MENU_HIST_VIEW_SORTDESCENDING, !ascending);
|
||||
|
||||
sortColumn = column;
|
||||
sortAscending = ascending;
|
||||
}
|
||||
|
||||
void QtHistoryContext::invalidateListView()
|
||||
{
|
||||
if (listView)
|
||||
listView->clear();
|
||||
}
|
||||
|
||||
|
||||
#define BUF_SIZ 1024
|
||||
|
||||
void QtHistoryContext::cmdOpenBrowser()
|
||||
{
|
||||
int bufsiz = BUF_SIZ;
|
||||
char buf[ BUF_SIZ ];
|
||||
URL_Struct *url;
|
||||
|
||||
if( PREF_GetCharPref( "browser.startup.homepage", buf, &bufsiz ) < 0 || !strlen(buf) )
|
||||
{
|
||||
clearView(0);
|
||||
alert(tr("No home document specified."));
|
||||
return;
|
||||
}
|
||||
url = NET_CreateURLStruct (buf, NET_DONT_RELOAD);
|
||||
QtContext::makeNewWindow( url,0,0,0);
|
||||
}
|
||||
|
||||
|
||||
void QtHistoryContext::cmdComposeMessage()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdNewBlank()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdNewTemplate()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdNewWizard()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdAddBookmark()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdSaveAs()
|
||||
{
|
||||
GH_FileSaveAsHTML(m_histCursor, mwContext());
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdGotoPage()
|
||||
{
|
||||
activateItem(listView->currentItem());
|
||||
}
|
||||
|
||||
|
||||
void QtHistoryContext::cmdOpenSelected()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdOpenAddToToolbar()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdClose()
|
||||
{
|
||||
close(TRUE);
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdExit()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void QtHistoryContext::cmdUndo()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdRedo()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdCut()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdCopy()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdPaste()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void QtHistoryContext::cmdDelete()
|
||||
{
|
||||
createWidget();
|
||||
}
|
||||
|
||||
|
||||
void QtHistoryContext::changeSorting( int column, bool ascending)
|
||||
{
|
||||
listView->setSorting(column, ascending);
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdSortByTitle()
|
||||
{
|
||||
changeSorting(TITLE, sortAscending );
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdSortByLocation()
|
||||
{
|
||||
changeSorting(LOCATION, sortAscending);
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdSortByDateLastVisited()
|
||||
{
|
||||
changeSorting(LASTVISITED, sortAscending);
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdSortByDateFirstVisited()
|
||||
{
|
||||
changeSorting(FIRSTVISITED, sortAscending);
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdSortByExpirationDate()
|
||||
{
|
||||
changeSorting(EXPIRES, sortAscending);
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdSortByVisitCount()
|
||||
{
|
||||
changeSorting(VISITCOUNT, sortAscending);
|
||||
}
|
||||
|
||||
|
||||
void QtHistoryContext::cmdSortAscending()
|
||||
{
|
||||
changeSorting(sortColumn, true);
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdSortDescending()
|
||||
{
|
||||
changeSorting(sortColumn, false);
|
||||
}
|
||||
|
||||
|
||||
void QtHistoryContext::cmdAboutMozilla()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdAboutQt()
|
||||
{
|
||||
QMessageBox::aboutQt( 0 );
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdOpenHistory()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdAddToToolbar()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void QtHistoryContext::cmdOpenNavCenter()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdOpenOrBringUpBrowser()
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::cmdOpenEditor()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QtHistoryContext::gotoEntry(const char* url, const char* target)
|
||||
{
|
||||
QtContext::makeNewWindow( NET_CreateURLStruct(url,NET_DONT_RELOAD),0,0,0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QtHistoryContext::activateItem( QListViewItem *i )
|
||||
{
|
||||
const char *url = i->text(LOCATION);
|
||||
QtContext::makeNewWindow( NET_CreateURLStruct(url, NET_DONT_RELOAD), 0, 0, 0);
|
||||
}
|
||||
|
||||
void QtHistoryContext::rightClick(QListViewItem *i, const QPoint &p, int)
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::newSelected( QListViewItem *i )
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryContext::show()
|
||||
{
|
||||
createWidget();
|
||||
refreshHistory();
|
||||
changeSorting(sortColumn, sortAscending);
|
||||
historyWidget->show();
|
||||
historyWidget->raise();
|
||||
}
|
||||
|
||||
gh_SortColumn QtHistoryContext::togh_SortColumn(int column) const
|
||||
{
|
||||
gh_SortColumn ret;
|
||||
switch (column)
|
||||
{
|
||||
case TITLE:
|
||||
ret = eGH_NameSort;
|
||||
break;
|
||||
case LOCATION:
|
||||
ret = eGH_LocationSort;
|
||||
break;
|
||||
case FIRSTVISITED:
|
||||
ret = eGH_FirstDateSort;
|
||||
break;
|
||||
case LASTVISITED:
|
||||
case EXPIRES:
|
||||
ret = eGH_LastDateSort;
|
||||
break;
|
||||
case VISITCOUNT:
|
||||
ret = eGH_VisitCountSort;
|
||||
break;
|
||||
default:
|
||||
ret = eGH_NoSort;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void QtHistoryContext::refreshHistory()
|
||||
{
|
||||
int totalLines;
|
||||
gh_SortColumn sortCol = togh_SortColumn(sortColumn);
|
||||
|
||||
if (m_histCursor!=0)
|
||||
GH_ReleaseContext(m_histCursor, TRUE);
|
||||
m_histCursor = GH_GetContext(sortCol, 0,
|
||||
&QtHistoryContext::notifyHistory,
|
||||
0, this );
|
||||
|
||||
XP_ASSERT(m_histCursor);
|
||||
totalLines = GH_GetNumRecords(m_histCursor);
|
||||
refreshCells(0, totalLines);
|
||||
}
|
||||
|
||||
int QtHistoryContext::notifyHistory(gh_NotifyMsg *msg)
|
||||
{
|
||||
QtHistoryContext *obj = (QtHistoryContext*)msg->pUserData;
|
||||
obj->refreshHistory();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void QtHistoryContext::setHistoryRow(QListViewItem *item, gh_HistEntry *gh_entry)
|
||||
{
|
||||
setColumnText(item, TITLE, gh_entry);
|
||||
setColumnText(item, LOCATION, gh_entry);
|
||||
setColumnText(item, LASTVISITED, gh_entry);
|
||||
setColumnText(item, FIRSTVISITED, gh_entry);
|
||||
setColumnText(item, EXPIRES, gh_entry);
|
||||
setColumnText(item, VISITCOUNT, gh_entry);
|
||||
}
|
||||
|
||||
|
||||
void QtHistoryContext::refreshCells(int first, int last)
|
||||
{
|
||||
int ix;
|
||||
gh_HistEntry* gh_entry;
|
||||
QListViewItem *current = listView->firstChild();
|
||||
|
||||
// Find first index
|
||||
for (ix = 0; ix<first; ix++)
|
||||
{
|
||||
if (current==0)
|
||||
return; // something is fishy
|
||||
current = current->nextSibling();
|
||||
}
|
||||
|
||||
// Update history values
|
||||
for (ix = first; ix<last; ix++)
|
||||
{
|
||||
gh_entry = GH_GetRecord(m_histCursor, ix);
|
||||
if (current==0) break;
|
||||
if (gh_entry!=0)
|
||||
{
|
||||
setHistoryRow(current, gh_entry);
|
||||
current = current->nextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
// Insert new entries if there wasn't enough rows
|
||||
for (; ix<last; ix++)
|
||||
{
|
||||
gh_entry = GH_GetRecord(m_histCursor, ix);
|
||||
if (gh_entry!=0)
|
||||
{
|
||||
current = new HistoryViewItem(listView);
|
||||
setHistoryRow(current, gh_entry);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void QtHistoryContext::setColumnText(QListViewItem *item, int col, gh_HistEntry *e)
|
||||
{
|
||||
static char tmp_buf[1024];
|
||||
const char *coltext = tmp_buf;
|
||||
struct tm* timetm;
|
||||
if (e==0 || item==0) return; // missing arguments, return
|
||||
switch (col)
|
||||
{
|
||||
case TITLE:
|
||||
coltext = e->pszName;
|
||||
break;
|
||||
case LOCATION:
|
||||
coltext = e->address;
|
||||
break;
|
||||
case FIRSTVISITED:
|
||||
if (e->first_accessed==0) break; // no access, skip
|
||||
timetm = localtime(&(e->first_accessed));
|
||||
FE_StrfTime(mwContext(), tmp_buf, 1024,
|
||||
XP_DATE_TIME_FORMAT, timetm);
|
||||
break;
|
||||
case LASTVISITED:
|
||||
if (e->last_accessed==0) break; // no last access, skip
|
||||
timetm = localtime(&(e->last_accessed));
|
||||
FE_StrfTime(mwContext(), tmp_buf, 1024,
|
||||
XP_DATE_TIME_FORMAT, timetm);
|
||||
break;
|
||||
case EXPIRES:
|
||||
{
|
||||
int32 expireDays;
|
||||
time_t expireSecs;
|
||||
|
||||
if (e->last_accessed==0) break; // no last access, skip
|
||||
PREF_GetIntPref("browser.link_expiration",&expireDays);
|
||||
expireSecs = e->last_accessed;
|
||||
expireSecs += expireDays*60*60*24;
|
||||
timetm = localtime(&expireSecs);
|
||||
FE_StrfTime(mwContext(), tmp_buf, 1024,
|
||||
XP_DATE_TIME_FORMAT, timetm);
|
||||
break;
|
||||
}
|
||||
case VISITCOUNT:
|
||||
if (e->iCount==0) break; // no count, skip
|
||||
sprintf(tmp_buf, "%d", e->iCount);
|
||||
break;
|
||||
default:
|
||||
// something is fishy
|
||||
XP_ASSERT(0);
|
||||
};
|
||||
item->setText(col, coltext);
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
/* $Id: QtHistoryContext.h,v 1.1 1998-09-25 18:01:29 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef QTHISTORYCONTEXT_H
|
||||
#define QTHISTORYCONTEXT_H
|
||||
|
||||
#include "QtContext.h"
|
||||
#include <qpopmenu.h>
|
||||
#include <qmainwindow.h>
|
||||
|
||||
class QMainWindow;
|
||||
class QListView;
|
||||
class QListViewItem;
|
||||
class QtBrowserContext;
|
||||
class HistoryListView;
|
||||
|
||||
class QtHistoryContext : public QtContext {
|
||||
/* A History window */
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtHistoryContext( MWContext * );
|
||||
virtual ~QtHistoryContext();
|
||||
|
||||
static QtHistoryContext *qt( MWContext *c );
|
||||
static QtHistoryContext *ptr();
|
||||
|
||||
void show();
|
||||
|
||||
public slots:
|
||||
|
||||
void cmdOpenBrowser();
|
||||
void cmdComposeMessage();
|
||||
void cmdNewBlank();
|
||||
void cmdNewTemplate();
|
||||
void cmdNewWizard();
|
||||
void cmdAddBookmark();
|
||||
|
||||
|
||||
|
||||
void cmdSaveAs();
|
||||
void cmdGotoPage();
|
||||
void cmdOpenSelected();
|
||||
void cmdOpenAddToToolbar();
|
||||
void cmdClose();
|
||||
void cmdExit();
|
||||
|
||||
void cmdUndo();
|
||||
void cmdRedo();
|
||||
void cmdCut();
|
||||
void cmdCopy();
|
||||
void cmdPaste();
|
||||
void cmdDelete();
|
||||
|
||||
void cmdSortByTitle();
|
||||
void cmdSortByLocation();
|
||||
void cmdSortByDateLastVisited();
|
||||
void cmdSortByDateFirstVisited();
|
||||
void cmdSortByExpirationDate();
|
||||
void cmdSortByVisitCount();
|
||||
void cmdSortAscending();
|
||||
void cmdSortDescending();
|
||||
|
||||
void cmdAboutMozilla();
|
||||
void cmdAboutQt();
|
||||
void cmdOpenHistory();
|
||||
void cmdAddToToolbar();
|
||||
void cmdOpenNavCenter();
|
||||
void cmdOpenOrBringUpBrowser();
|
||||
void cmdOpenEditor();
|
||||
|
||||
|
||||
private slots:
|
||||
void activateItem( QListViewItem * );
|
||||
void rightClick( QListViewItem *, const QPoint &, int );
|
||||
void newSelected( QListViewItem * );
|
||||
void sortColumnChanged(int column, bool ascending);
|
||||
|
||||
private:
|
||||
|
||||
void changeSorting( int column, bool ascending);
|
||||
void createWidget();
|
||||
void invalidateListView();
|
||||
void gotoEntry (const char* url, const char* target);
|
||||
static int notifyHistory(gh_NotifyMsg *msg);
|
||||
void populateMenuBar(QMenuBar* menuBar); // implemented in menu.cpp
|
||||
void refreshHistory();
|
||||
void refreshCells(int first, int last);
|
||||
gh_SortColumn togh_SortColumn(int column) const;
|
||||
void setColumnText(QListViewItem *item, int col, gh_HistEntry *e);
|
||||
void setHistoryRow(QListViewItem *item, gh_HistEntry *gh_entry);
|
||||
|
||||
|
||||
HistoryListView *listView;
|
||||
QMainWindow *historyWidget;
|
||||
int sortColumn;
|
||||
bool sortAscending;
|
||||
bool inBatch;
|
||||
GHHANDLE m_histCursor;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -1,961 +0,0 @@
|
|||
/* $Id: QtPrefs.cpp,v 1.1 1998-09-25 18:01:29 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Paul Olav
|
||||
* Tvete. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "QtPrefs.h"
|
||||
#include "QtContext.h"
|
||||
|
||||
|
||||
#include <qpainter.h>
|
||||
#include <qapp.h>
|
||||
#include <qlabel.h>
|
||||
#include <qchkbox.h>
|
||||
#include <qradiobt.h>
|
||||
#include <qlined.h>
|
||||
#include <qlistview.h>
|
||||
#include <qlistbox.h>
|
||||
#include <qcombo.h>
|
||||
#include <qwidgetstack.h>
|
||||
#include <qtvbox.h>
|
||||
#include <qthbox.h>
|
||||
#include <qtgrid.h>
|
||||
#include <qpushbt.h>
|
||||
#include <qtlabelled.h>
|
||||
#include <qtbuttonrow.h>
|
||||
#include <qlayout.h>
|
||||
#include <qbttngrp.h>
|
||||
#include <qvalidator.h>
|
||||
|
||||
#include "prefapi.h"
|
||||
|
||||
|
||||
/*
|
||||
The QtPrefItem classes connect Qt widgets to Mozilla preferences
|
||||
(PREF_Get*Pref() and friends, defined in prefapi.h).
|
||||
|
||||
Create your widget, feed it into the appropriate QtPrefItem constructor,
|
||||
and the rest should happen automatically
|
||||
|
||||
Note that QtEnumPrefItem needs several radio buttons. They are
|
||||
not given in the constructor, but specified with addRadioButton().
|
||||
*/
|
||||
|
||||
|
||||
|
||||
QtPrefItem::QtPrefItem( const char* k, QtPreferences *parent )
|
||||
:QObject( parent ), mykey( k )
|
||||
{
|
||||
parent->add(this);
|
||||
}
|
||||
|
||||
|
||||
QtIntPrefItem::QtIntPrefItem( const char*k, QLineEdit *l, QtPreferences *p )
|
||||
:QtPrefItem( k, p ), lined(l)
|
||||
{
|
||||
if ( !l ) {
|
||||
warning( "QtIntPrefItem without lined" );
|
||||
return;
|
||||
}
|
||||
QIntValidator *v = new QIntValidator( l );
|
||||
l->setValidator( v );
|
||||
read();
|
||||
}
|
||||
//setSpinBox
|
||||
int QtIntPrefItem::value() const
|
||||
{
|
||||
return lined ? QString(lined->text()).toInt() : 0;
|
||||
}
|
||||
|
||||
|
||||
void QtIntPrefItem::setValue( int val )
|
||||
{
|
||||
QString s;
|
||||
s.setNum( val );
|
||||
lined->setText( s );
|
||||
}
|
||||
|
||||
|
||||
void QtIntPrefItem::save()
|
||||
{
|
||||
int status;
|
||||
status = PREF_SetIntPref( key(), value() );
|
||||
}
|
||||
|
||||
void QtIntPrefItem::read()
|
||||
{
|
||||
int32 newVal = 0;
|
||||
int status;
|
||||
status = PREF_GetIntPref( key(), &newVal );
|
||||
setValue( (int)newVal );
|
||||
}
|
||||
|
||||
|
||||
|
||||
QtBoolPrefItem::QtBoolPrefItem( const char*k, QCheckBox *c, QtPreferences *p )
|
||||
:QtPrefItem( k, p ), chkbx(c)
|
||||
{
|
||||
read();
|
||||
}
|
||||
//setSpinBox
|
||||
bool QtBoolPrefItem::value() const
|
||||
{
|
||||
return chkbx ? chkbx->isChecked() : FALSE;
|
||||
}
|
||||
|
||||
void QtBoolPrefItem::setValue( bool b )
|
||||
{
|
||||
chkbx->setChecked( b );
|
||||
}
|
||||
|
||||
void QtBoolPrefItem::save()
|
||||
{
|
||||
int status;
|
||||
status = PREF_SetBoolPref( key(), value() );
|
||||
}
|
||||
|
||||
void QtBoolPrefItem::read()
|
||||
{
|
||||
XP_Bool newVal = FALSE;
|
||||
int status;
|
||||
status = PREF_GetBoolPref( key(), &newVal );
|
||||
setValue( newVal );
|
||||
}
|
||||
|
||||
|
||||
|
||||
QtCharPrefItem::QtCharPrefItem( const char*k, QLineEdit *l, QtPreferences *p )
|
||||
:QtPrefItem( k, p ), lined(l)
|
||||
{
|
||||
read();
|
||||
}
|
||||
//setSpinBox
|
||||
const char *QtCharPrefItem::value() const
|
||||
{
|
||||
return lined ? lined->text() : 0;
|
||||
}
|
||||
|
||||
void QtCharPrefItem::save()
|
||||
{
|
||||
int status;
|
||||
status = PREF_SetCharPref( key(), value() );
|
||||
}
|
||||
|
||||
void QtCharPrefItem::read()
|
||||
{
|
||||
int len = 333; //#########
|
||||
char buf[333]; //######
|
||||
buf[0]=0;
|
||||
int status;
|
||||
status = PREF_GetCharPref( key(), buf, &len );
|
||||
setValue( buf );
|
||||
}
|
||||
|
||||
void QtCharPrefItem::setValue( const char *txt )
|
||||
{
|
||||
lined->setText( txt );
|
||||
}
|
||||
|
||||
|
||||
|
||||
QtEnumPrefItem::QtEnumPrefItem( const char*k, QtPreferences *p )
|
||||
:QtPrefItem( k, p ), currentVal(0)
|
||||
{
|
||||
btngrp = new QButtonGroup;
|
||||
btngrp->setExclusive( TRUE );
|
||||
connect( btngrp, SIGNAL(clicked(int)),
|
||||
this, SLOT(setCurrent(int)) );
|
||||
read();
|
||||
}
|
||||
|
||||
void QtEnumPrefItem::addRadioButton( QRadioButton *btn, int val )
|
||||
{
|
||||
btngrp->insert( btn, val );
|
||||
btngrp->setButton( currentVal ); // the read() may already have happened
|
||||
}
|
||||
|
||||
int QtEnumPrefItem::value() const
|
||||
{
|
||||
return currentVal;
|
||||
}
|
||||
|
||||
void QtEnumPrefItem::setValue( int val )
|
||||
{
|
||||
currentVal = val;
|
||||
btngrp->setButton( val );
|
||||
}
|
||||
|
||||
void QtEnumPrefItem::setCurrent( int val )
|
||||
{
|
||||
currentVal = val;
|
||||
}
|
||||
|
||||
|
||||
void QtEnumPrefItem::save()
|
||||
{
|
||||
int status;
|
||||
status = PREF_SetIntPref( key(), value() );
|
||||
}
|
||||
void QtEnumPrefItem::read()
|
||||
{
|
||||
int32 newVal = 0;
|
||||
int status;
|
||||
status = PREF_GetIntPref( key(), &newVal );
|
||||
setValue( (int)newVal );
|
||||
}
|
||||
|
||||
|
||||
|
||||
class StrongHeading : public QtHBox {
|
||||
public:
|
||||
StrongHeading(const char* label, const char* desc, QWidget* parent=0, const char* name=0) :
|
||||
QtHBox(parent, name)
|
||||
{
|
||||
QLabel* l = new QLabel(label, this);
|
||||
QLabel* d = new QLabel(desc, this);
|
||||
QPalette p = palette();
|
||||
QColorGroup n = palette().normal();
|
||||
QColorGroup g(n.background(), n.foreground(), n.light(), n.dark(),
|
||||
n.mid(), n.background(), n.base());
|
||||
p.setNormal( g );
|
||||
setPalette(p);
|
||||
l->setPalette(p);
|
||||
d->setPalette(p);
|
||||
l->setMargin(3);
|
||||
d->setMargin(2);
|
||||
|
||||
QFont bold = *QApplication::font();
|
||||
bold.setBold(TRUE);
|
||||
bold.setPointSize(bold.pointSize()+2);
|
||||
l->setFont( bold );
|
||||
|
||||
l->setFixedSize(l->sizeHint());
|
||||
}
|
||||
};
|
||||
|
||||
inline static QWidget *fix( QWidget *w )
|
||||
{
|
||||
w->setFixedSize( w->sizeHint() );
|
||||
return w;
|
||||
}
|
||||
|
||||
static QWidget* advanced( QtPreferences *prf )
|
||||
{
|
||||
QtVBox *vbox = new QtVBox;
|
||||
QtVBox *page = vbox;
|
||||
new StrongHeading( "Advanced",
|
||||
"Change preferences that affect the entire product",
|
||||
vbox );
|
||||
|
||||
QtVBox *box;
|
||||
|
||||
QtLabelled *frame = new QtLabelled( vbox );
|
||||
box = new QtVBox( frame );
|
||||
QCheckBox *cb;
|
||||
cb = new QCheckBox( "&Automatically load images and other data types\n"
|
||||
"(Otherwise, click the Images"
|
||||
" button to load when needed)", box );
|
||||
new QtBoolPrefItem( "general.always_load_images", cb, prf );
|
||||
#ifdef JAVA
|
||||
cb = new QCheckBox( "Enable &Java", box );
|
||||
#endif
|
||||
cb = new QCheckBox( "Enable Ja&vaScript", box );
|
||||
new QtBoolPrefItem( "javascript.enabled", cb, prf);
|
||||
cb = new QCheckBox( "Enable &Style Sheets", box );
|
||||
new QtBoolPrefItem( "browser.enable_style_sheets", cb, prf);
|
||||
#if 0
|
||||
cb = new QCheckBox( "Enable Auto&Install", box );
|
||||
cb = new QCheckBox( "Send email address as anonymous &FTP password", box );
|
||||
#endif
|
||||
|
||||
box = new QtVBox( new QtLabelled( "Cookies", vbox ) );
|
||||
QtEnumPrefItem *cookie
|
||||
= new QtEnumPrefItem( "network.cookie.cookieBehavior", prf );
|
||||
cookie->addRadioButton( new QRadioButton( "Accept all &cookies", box ),
|
||||
NET_Accept );
|
||||
cookie->addRadioButton( new QRadioButton(
|
||||
"&Only accept cookies originating from the same server as\n"
|
||||
"the page being viewed", box ), NET_DontAcceptForeign );
|
||||
cookie->addRadioButton( new QRadioButton(
|
||||
"&Do not accept or send cookies", box ),
|
||||
NET_DontUse);
|
||||
new QtBoolPrefItem( "network.cookie.warnAboutCookies",
|
||||
new QCheckBox( "&Warn me before accepting a cookie", box ),
|
||||
prf );
|
||||
page->addStretch();
|
||||
return vbox;
|
||||
}
|
||||
/*
|
||||
class DummyCategory : public QLabel {
|
||||
public:
|
||||
DummyCategory( const char * s = 0 ) :
|
||||
QLabel(s?s:"Dummy")
|
||||
{
|
||||
setMinimumSize(100,100);
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
static QWidget *fontPage( QtPreferences *prf )
|
||||
{
|
||||
QtVBox *page = new QtVBox;
|
||||
|
||||
new StrongHeading( "Fonts", "Change the fonts in your display" , page );
|
||||
QtLabelled *frame = new QtLabelled( "Fonts and Encodings", page );
|
||||
QtVBox *box;
|
||||
#if 0
|
||||
box = new QtVBox( frame );
|
||||
QtHBox *hbox = new QtHBox( box );
|
||||
new QLabel( "For the Encoding", hbox );
|
||||
QComboBox *combo = new QComboBox( FALSE, hbox );
|
||||
combo->insertItem( "Western (iso-8859-1)" );
|
||||
|
||||
hbox = new QtHBox( box );
|
||||
new QLabel( "Variable Width Font", hbox );
|
||||
combo = new QComboBox( FALSE, hbox );
|
||||
combo->insertItem( "Times (Adobe)" );
|
||||
new QLabel( "Size:", hbox );
|
||||
combo = new QComboBox( FALSE, hbox );
|
||||
combo->insertItem( "12.0" );
|
||||
|
||||
|
||||
hbox = new QtHBox( box );
|
||||
new QLabel( "Fixed Width Font", hbox );
|
||||
combo = new QComboBox( FALSE, hbox );
|
||||
combo->insertItem( "Courier (Adobe)" );
|
||||
new QLabel( "Size:", hbox );
|
||||
combo = new QComboBox( FALSE, hbox );
|
||||
combo->insertItem( "10.0" );
|
||||
#else
|
||||
new QLabel( "Sorry, not implemented", frame );
|
||||
#endif
|
||||
|
||||
frame = new QtLabelled( page );
|
||||
box = new QtVBox( frame );
|
||||
new QLabel( "Sometimes a document will provide its own fonts." );
|
||||
|
||||
QtEnumPrefItem *docfonts
|
||||
= new QtEnumPrefItem( "browser.use_document_fonts", prf );
|
||||
docfonts->addRadioButton( new QRadioButton( "Use my default fonts, overriding document-specified fonts", box ), DOC_FONTS_NEVER );
|
||||
docfonts->addRadioButton( new QRadioButton( "Use document-specified fonts, but disable Dynamic Fonts", box ), DOC_FONTS_QUICK );
|
||||
docfonts->addRadioButton( new QRadioButton( "Use document-specified fonts, including Dynamic Fonts", box ), DOC_FONTS_ALWAYS );
|
||||
|
||||
page->addStretch();
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
static QWidget *colorPage( QtPreferences *prf )
|
||||
{
|
||||
QtVBox *page = new QtVBox;
|
||||
|
||||
new StrongHeading( "Colors", "Change the colors in your display" , page );
|
||||
|
||||
QtLabelled *frame;
|
||||
QtVBox *box;
|
||||
#if 0
|
||||
QtHBox *topbox = new QtHBox( page );
|
||||
|
||||
frame = new QtLabelled( "Colors", topbox );
|
||||
QtGrid *grid = new QtGrid( 3, frame );
|
||||
new QLabel( "Text:", grid );
|
||||
new QPushButton( "dummy", grid );
|
||||
new QWidget(grid); //### grid->skip();
|
||||
new QLabel( "Background:", grid );
|
||||
new QPushButton( "dummy", grid );
|
||||
new QWidget(grid); //### grid->skip();
|
||||
new QWidget(grid); //### grid->skip();
|
||||
new QWidget(grid); //### grid->skip();
|
||||
new QPushButton( "Use Default", grid );
|
||||
|
||||
frame = new QtLabelled( "Links", topbox );
|
||||
box = new QtVBox( frame );
|
||||
grid = new QtGrid( 2, box );
|
||||
new QLabel( "Unvisited Links:", grid );
|
||||
new QPushButton( "dummy", grid );
|
||||
new QLabel( "Visited Links:", grid );
|
||||
new QPushButton( "dummy", grid );
|
||||
new QCheckBox( "Underline links", box );
|
||||
|
||||
#else
|
||||
new QLabel( "Sorry, not implemented", page );
|
||||
#endif
|
||||
|
||||
frame = new QtLabelled( page );
|
||||
box = new QtVBox( frame );
|
||||
|
||||
new QLabel( "Sometimes a document will provide its own colors and background", box );
|
||||
new QtBoolPrefItem( "browser.use_document_colors",
|
||||
new QCheckBox( "Always use my colors, overriding document", box ),
|
||||
prf);
|
||||
|
||||
page->addStretch();
|
||||
return page;
|
||||
}
|
||||
|
||||
static QWidget *appsPage( QtPreferences *prf )
|
||||
{
|
||||
QtVBox *page = new QtVBox;
|
||||
|
||||
new StrongHeading( "Applications",
|
||||
"Specify helper applications for different file types",
|
||||
page );
|
||||
#if 0
|
||||
QtLabelled *frame = new QtLabelled( page );
|
||||
QtVBox *box = new QtVBox( frame );
|
||||
QListView *lv = new QListView( box );
|
||||
lv->addColumn( "Description", 250 );
|
||||
lv->addColumn( "Handled By", 200 );
|
||||
new QListViewItem( lv, "GIF Image", "Netscape" );
|
||||
new QListViewItem( lv, "Hypertext Markup Language", "Netscape" );
|
||||
new QListViewItem( lv, "Plain text", "Netscape" );
|
||||
new QListViewItem( lv, "Perl Program", "Unknown:Prompt User" );
|
||||
new QListViewItem( lv, "Lkjsfdlkdsjgf", "Unknown:Prompt User" );
|
||||
new QListViewItem( lv, "Asdfafsafs", "Unknown:Prompt User" );
|
||||
new QListViewItem( lv, "Xzcmnv", "Unknown:Prompt User" );
|
||||
new QListViewItem( lv, "Aqwreqrpoierw", "Unknown:Prompt User" );
|
||||
new QListViewItem( lv, "mnzxcewewq", "Unknown:Prompt User" );
|
||||
new QListViewItem( lv, "Oiuycxsxc Xocuy", "Unknown:Prompt User" );
|
||||
new QListViewItem( lv, "JPG Image", "Netscape" );
|
||||
new QListViewItem( lv, "XBM Image", "Netscape" );
|
||||
|
||||
QtButtonRow *br = new QtButtonRow( box );
|
||||
new QPushButton( "New...", br );
|
||||
new QPushButton( "Edit...", br );
|
||||
new QPushButton( "Delete", br );
|
||||
|
||||
QtHBox *hbox = new QtHBox( box );
|
||||
new QLabel( "Download files to:", hbox );
|
||||
new QLineEdit( hbox );
|
||||
new QPushButton( "Choose...", hbox );
|
||||
#else
|
||||
new QLabel( "Sorry, not implemented", page );
|
||||
#endif
|
||||
|
||||
page->addStretch();
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
static QWidget *appearPage( QtPreferences *prf )
|
||||
{
|
||||
QtVBox *page = new QtVBox;
|
||||
|
||||
new StrongHeading( "Appearance",
|
||||
"Change the appearance of the display" , page );
|
||||
QtLabelled *frame;
|
||||
QtVBox *box;
|
||||
#if 0 //### since only navigator is currently implemented
|
||||
frame = new QtLabelled( "On startup, launch", page );
|
||||
box = new QtVBox( frame );
|
||||
new QCheckBox( "&Navigator", box );
|
||||
new QCheckBox( "&Messenger Mailbox", box );
|
||||
new QCheckBox( "Collabra &Discussions", box );
|
||||
new QCheckBox( "Page &Composer", box );
|
||||
new QCheckBox( "N&etcaster", box );
|
||||
#endif
|
||||
frame = new QtLabelled( "Show Toolbar As", page );
|
||||
box = new QtVBox( frame );
|
||||
QtEnumPrefItem *toolb
|
||||
= new QtEnumPrefItem( "browser.chrome.toolbar_style", prf );
|
||||
toolb->addRadioButton( new QRadioButton( "&Pictures and Text", box ),
|
||||
BROWSER_TOOLBAR_ICONS_AND_TEXT );
|
||||
toolb->addRadioButton( new QRadioButton( "Pictures &Only", box ),
|
||||
BROWSER_TOOLBAR_ICONS_ONLY );
|
||||
toolb->addRadioButton( new QRadioButton( "&Text Only", box ),
|
||||
BROWSER_TOOLBAR_TEXT_ONLY );
|
||||
page->addStretch();
|
||||
return page;
|
||||
}
|
||||
|
||||
static QWidget *navigatorPage( QtPreferences *prf )
|
||||
{
|
||||
QtVBox *page = new QtVBox;
|
||||
|
||||
new StrongHeading( "Navigator", "Specify the home page location",
|
||||
page );
|
||||
QtLabelled *frame = new QtLabelled( "Browser starts with", page );
|
||||
QtVBox *box = new QtVBox( frame );
|
||||
QtEnumPrefItem *startup
|
||||
= new QtEnumPrefItem( "browser.startup.page", prf );
|
||||
startup->addRadioButton( new QRadioButton( "Blank page", box ),
|
||||
BROWSER_STARTUP_BLANK );
|
||||
startup->addRadioButton( new QRadioButton( "Home page", box ),
|
||||
BROWSER_STARTUP_HOME );
|
||||
startup->addRadioButton( new QRadioButton( "Last page visited", box ),
|
||||
BROWSER_STARTUP_LAST );
|
||||
|
||||
frame = new QtLabelled( "Home Page", page );
|
||||
box = new QtVBox( frame );
|
||||
new QLabel( "Clicking the Home button will take you to this page",
|
||||
box );
|
||||
QtHBox *hbox = new QtHBox( box );
|
||||
new QLabel( "Location:", hbox );
|
||||
QLineEdit *home = new QLineEdit( hbox );
|
||||
new QtCharPrefItem( "browser.startup.homepage", home, prf );
|
||||
hbox = new QtHBox( box );
|
||||
new QPushButton( "Use Current Page" );
|
||||
new QPushButton ( "Choose" );
|
||||
|
||||
frame = new QtLabelled( "History", page );
|
||||
hbox = new QtHBox( frame );
|
||||
new QLabel( "History expires after", hbox );
|
||||
new QtIntPrefItem( "browser.link_expiration", new QLineEdit( hbox ), prf );
|
||||
new QLabel( "days", hbox );
|
||||
new QPushButton( "Clear History", hbox );
|
||||
|
||||
page->addStretch();
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
pref("browser.cache.disk_cache_size", 7680);
|
||||
pref("browser.cache.memory_cache_size", 1024);
|
||||
pref("browser.cache.disk_cache_ssl", false);
|
||||
pref("browser.cache.check_doc_frequency", 0);
|
||||
localDefPref("browser.cache.directory", "");
|
||||
localDefPref("browser.cache.wfe.directory", null);
|
||||
*/
|
||||
|
||||
static QWidget *cachePage( QtPreferences *prf )
|
||||
{
|
||||
QtVBox *page = new QtVBox;
|
||||
|
||||
new StrongHeading( "Cache", "Designate the size of the cache",
|
||||
page );
|
||||
QtLabelled *frame = new QtLabelled( 0, page );
|
||||
QtVBox *box = new QtVBox( frame );
|
||||
|
||||
new QLabel( "The cache is used to keep local copies of frequently accessed docu-\n\
|
||||
ments and thus reduce time connected to the network. The Reload\n\
|
||||
button will always compare the cache document to the network\n\
|
||||
document and show the most recent one. To load pages and images\n\
|
||||
from the network instead of the cache, press the Shift key and click\n\
|
||||
the reload button.", box );
|
||||
|
||||
QtHBox *hbox = new QtHBox( box );
|
||||
new QLabel( "Disk cache:", hbox );
|
||||
new QtIntPrefItem( "browser.cache.disk_cache_size",
|
||||
new QLineEdit( hbox ), prf );
|
||||
new QPushButton( "Clear Disk Cache", hbox );
|
||||
|
||||
hbox = new QtHBox( box );
|
||||
new QLabel( "Memory cache:", hbox );
|
||||
new QtIntPrefItem( "browser.cache.memory_cache_size",
|
||||
new QLineEdit( hbox ), prf );
|
||||
new QPushButton( "Clear Memory Cache", hbox );
|
||||
|
||||
hbox = new QtHBox( box );
|
||||
new QLabel( "Cache Folder:", hbox );
|
||||
new QtCharPrefItem( "browser.cache.directory",
|
||||
new QLineEdit( hbox ), prf );
|
||||
new QPushButton( "Choose...", hbox );
|
||||
|
||||
new QLabel( "Document in cache is compared to document on network", box );
|
||||
// QtVBox *box = new QtVBox( frame );
|
||||
|
||||
QtEnumPrefItem *freq
|
||||
= new QtEnumPrefItem( "browser.cache.check_doc_frequency", prf );
|
||||
//#### These numbers are not defined in prefs.h
|
||||
freq->addRadioButton( new QRadioButton( "Every time", box ), 1 );
|
||||
freq->addRadioButton( new QRadioButton( "Once per session", box ), 0 );
|
||||
freq->addRadioButton( new QRadioButton( "Never", box ), 2 );
|
||||
|
||||
page->addStretch();
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
|
||||
class QtLayDlg : public QDialog
|
||||
{
|
||||
public:
|
||||
QtLayDlg( QWidget *parent = 0, const char *name = 0 );
|
||||
QtVBox *mainBox() { return vbox; }
|
||||
private:
|
||||
QtVBox *vbox;
|
||||
};
|
||||
|
||||
|
||||
QtLayDlg::QtLayDlg( QWidget *parent, const char *name )
|
||||
:QDialog( parent, name, TRUE )
|
||||
{
|
||||
QVBoxLayout *gm = new QVBoxLayout( this, 5 );
|
||||
vbox = new QtVBox( this );
|
||||
gm->addWidget( vbox );
|
||||
|
||||
QHBoxLayout *btn = new QHBoxLayout;
|
||||
gm->addLayout( btn );
|
||||
QPushButton *ok = new QPushButton( "OK", this );
|
||||
ok->setDefault(TRUE);
|
||||
btn->addWidget( ok );
|
||||
|
||||
btn->addStretch();
|
||||
|
||||
QPushButton *cancel = new QPushButton( "Cancel", this );
|
||||
cancel->setAutoDefault(TRUE);
|
||||
btn->addWidget( cancel );
|
||||
|
||||
QSize s = ok->sizeHint();
|
||||
s = s.expandedTo( cancel->sizeHint() );
|
||||
ok->setFixedSize( s );
|
||||
cancel->setFixedSize( s );
|
||||
//###use QtButtonRow when it supports addStretch
|
||||
|
||||
connect( ok, SIGNAL(clicked()), SLOT(accept()) );
|
||||
connect( cancel, SIGNAL(clicked()), SLOT(reject()) );
|
||||
}
|
||||
|
||||
|
||||
static QtLayDlg *manProxyDlg( QtPreferences *prf )
|
||||
{
|
||||
|
||||
QtLayDlg *dlg = new QtLayDlg( prf );
|
||||
|
||||
QtVBox *page = dlg->mainBox();
|
||||
|
||||
new QLabel(
|
||||
"You may configure a proxy and port number for each of the internet\n"
|
||||
"protocols that Mozilla supports.", page );
|
||||
|
||||
QtGrid *grid = new QtGrid( 4, QtGrid::Horizontal, page );
|
||||
|
||||
new QLabel( "FTP Proxy", grid );
|
||||
new QtCharPrefItem( "network.proxy.ftp", new QLineEdit( grid ), prf );
|
||||
new QLabel( "Port:", grid );
|
||||
new QtIntPrefItem( "network.proxy.ftp_port", new QLineEdit( grid ), prf );
|
||||
|
||||
new QLabel( "Gopher Proxy", grid );
|
||||
new QtCharPrefItem( "network.proxy.gopher", new QLineEdit( grid ), prf );
|
||||
new QLabel( "Port:", grid );
|
||||
new QtIntPrefItem( "network.proxy.gopher_port", new QLineEdit( grid ), prf );
|
||||
|
||||
new QLabel( "HTTP Proxy", grid );
|
||||
new QtCharPrefItem( "network.proxy.http", new QLineEdit( grid ), prf );
|
||||
new QLabel( "Port:", grid );
|
||||
new QtIntPrefItem( "network.proxy.http_port", new QLineEdit( grid ), prf );
|
||||
|
||||
new QLabel( "Security Proxy", grid );
|
||||
new QtCharPrefItem( "network.proxy.ssl", new QLineEdit( grid ), prf );
|
||||
new QLabel( "Port:", grid );
|
||||
new QtIntPrefItem( "network.proxy.ssl_port", new QLineEdit( grid ), prf );
|
||||
|
||||
new QLabel( "WAIS Proxy", grid );
|
||||
new QtCharPrefItem( "network.proxy.wais", new QLineEdit( grid ), prf );
|
||||
new QLabel( "Port:", grid );
|
||||
new QtIntPrefItem( "network.proxy.wais_port", new QLineEdit( grid ), prf );
|
||||
|
||||
|
||||
/*
|
||||
94:localDefPref("browser.socksfile_location", "");
|
||||
166:pref("network.hosts.socks_conf", "");
|
||||
*/
|
||||
|
||||
new QLabel(
|
||||
"You may provide a list of domains that Mozilla should access directly,\n"
|
||||
"rather than via the proxy:", page );
|
||||
|
||||
grid = new QtGrid( 4, QtGrid::Horizontal, page );
|
||||
|
||||
new QLabel( "No Proxy for:", grid );
|
||||
new QtCharPrefItem( "network.proxy.no_proxies_on", new QLineEdit( grid ), prf );
|
||||
new QWidget; //#skip
|
||||
new QWidget; //#skip
|
||||
|
||||
new QLabel( "SOCKS Host:", grid );
|
||||
new QtCharPrefItem( "network.hosts.socks_server", new QLineEdit( grid ), prf );
|
||||
new QLabel( "Port:", grid );
|
||||
new QtIntPrefItem( "network.hosts.socks_serverport", new QLineEdit( grid ), prf );
|
||||
|
||||
#if 0
|
||||
QtButtonRow *bottom = new QtButtonRow( page );
|
||||
new QPushButton( "OK", bottom );
|
||||
//############### bottom->addStretch();
|
||||
new QPushButton( "Cancel", bottom );
|
||||
#endif
|
||||
|
||||
// page->pack();
|
||||
// dlg->resize(0,0);
|
||||
dlg->setCaption( "QtMozilla: View Manual Proxy Configuration" );
|
||||
|
||||
dlg->hide();
|
||||
|
||||
return dlg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static QWidget *proxyPage( QtPreferences *prf )
|
||||
{
|
||||
QtVBox *page = new QtVBox;
|
||||
|
||||
new StrongHeading( "Proxies", "Configure proxies to access the Internet",
|
||||
page );
|
||||
QtLabelled *frame = new QtLabelled( 0, page );
|
||||
QtVBox *box = new QtVBox( frame );
|
||||
|
||||
new QLabel( "A network proxy is used to provide additional security between your\n\
|
||||
computer and the Internet (usually along with a firewall) and/or to\n\
|
||||
increase performance between networks by reducing redundant traffic\n\
|
||||
via caching. Your system administrator can provide you with proper\n\
|
||||
proxy settings.", box );
|
||||
|
||||
|
||||
QtEnumPrefItem *prox = new QtEnumPrefItem( "network.proxy.type", prf );
|
||||
QRadioButton *rb;
|
||||
rb = new QRadioButton( "Direct connection to the internet", box );
|
||||
prox->addRadioButton( rb, PROXY_STYLE_NONE );
|
||||
|
||||
QtHBox *hbox = new QtHBox( box );
|
||||
rb = new QRadioButton( "Manual proxy configuration", hbox );
|
||||
prox->addRadioButton( rb,PROXY_STYLE_MANUAL );
|
||||
QPushButton * manBut = new QPushButton( "View...", hbox );
|
||||
QObject::connect( manBut, SIGNAL(clicked()),
|
||||
prf, SLOT(manualProxyPage()) );
|
||||
QObject::connect( rb, SIGNAL(toggled(bool)),
|
||||
manBut, SLOT(setEnabled(bool)) );
|
||||
manBut->setEnabled( rb->isOn() );
|
||||
|
||||
rb = new QRadioButton( "Automatic proxy configuration", box );
|
||||
prox->addRadioButton( rb, PROXY_STYLE_AUTOMATIC );
|
||||
|
||||
hbox = new QtHBox( box );
|
||||
new QLabel( "Configuration location (URL)", hbox );
|
||||
new QtCharPrefItem( "network.proxy.autoconfig_url", //###???
|
||||
new QLineEdit( hbox ), prf );
|
||||
new QPushButton( "&Reload", box );
|
||||
|
||||
page->addStretch();
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static QWidget *identityPage( QtPreferences *prf )
|
||||
{
|
||||
QtVBox *page = new QtVBox;
|
||||
|
||||
new StrongHeading( "Identity",
|
||||
"Set your name, email address, and signature file",
|
||||
page );
|
||||
QtLabelled *frame = new QtLabelled( 0, page );
|
||||
QtVBox *box = new QtVBox( frame );
|
||||
|
||||
new QLabel( "The information below is needed before you can send mail. If you do\n\
|
||||
not know the information requested, please contact your system\n\
|
||||
administrator or Internet Service Provider.", box );
|
||||
|
||||
new QLabel( "Your name:", box );
|
||||
new QtCharPrefItem( "mail.identity.username", new QLineEdit(box), prf );
|
||||
|
||||
new QLabel( "Email Address:", box );
|
||||
new QtCharPrefItem( "mail.identity.useremail", new QLineEdit(box), prf );
|
||||
|
||||
new QLabel( "Organization:", box );
|
||||
new QtCharPrefItem( "mail.identity.organization",
|
||||
new QLineEdit(box), prf );
|
||||
|
||||
page->addStretch();
|
||||
return page;
|
||||
}
|
||||
|
||||
static QWidget *languagePage( QtPreferences *prf )
|
||||
{
|
||||
QtVBox *page = new QtVBox;
|
||||
|
||||
new StrongHeading( "Languages",
|
||||
"View web pages in different languages",
|
||||
page );
|
||||
#if 0
|
||||
QtLabelled *frame = new QtLabelled( 0, page );
|
||||
QtVBox *box = new QtVBox( frame );
|
||||
new QLabel( "Choose in order of preference the language(s) in which you prefer to\n\
|
||||
view web pages. Web pages are sometimes available in serveral\n\
|
||||
languages. Navigator presents the pages in the available language\n\
|
||||
you most prefer.", box );
|
||||
#else
|
||||
new QLabel( "Sorry, not implemented", page );
|
||||
#endif
|
||||
page->addStretch();
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
QtPreferences::QtPreferences(QWidget* parent, const char* name, int f) :
|
||||
QDialog(parent, name, TRUE, f)
|
||||
{
|
||||
prefs = new QList<QtPrefItem>;
|
||||
|
||||
QGridLayout* grid = new QGridLayout(this,1,1,5);
|
||||
QtVBox* vbox = new QtVBox(this);
|
||||
grid->addWidget(vbox,0,0);
|
||||
grid->activate();
|
||||
|
||||
QtHBox* hbox = new QtHBox(vbox);
|
||||
QListView* selector = new QListView(hbox);
|
||||
categories = new QWidgetStack(hbox);
|
||||
QtButtonRow* buttons = new QtButtonRow(vbox);
|
||||
QPushButton* ok = new QPushButton("OK",buttons);
|
||||
QPushButton* cancel = new QPushButton("Cancel",buttons);
|
||||
|
||||
ok->setDefault(TRUE);
|
||||
connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
connect(ok, SIGNAL(clicked()), this, SLOT(apply()));
|
||||
connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
|
||||
connect(cancel, SIGNAL(clicked()), this, SLOT(cancel()));
|
||||
|
||||
QFontMetrics fm=fontMetrics();
|
||||
int w = fm.width("New Page Colors ")+selector->treeStepSize()*2;
|
||||
selector->addColumn( "Category", w );
|
||||
selector->setMaximumWidth( w );
|
||||
#if 0 //workaround for list view behaviour
|
||||
QListViewItem *selRoot = new QListViewItem( selector );
|
||||
selRoot->setOpen( TRUE );
|
||||
#else
|
||||
selector->setRootIsDecorated( TRUE );
|
||||
QListView *selRoot = selector;
|
||||
#endif
|
||||
selector->setFocusPolicy( QWidget::StrongFocus );
|
||||
QtPrefPageItem *group;
|
||||
|
||||
add(group = new QtPrefPageItem(selRoot, "Appearance"),
|
||||
appearPage( this ) );
|
||||
add(new QtPrefPageItem(group, "Font"), fontPage( this ) );
|
||||
add(new QtPrefPageItem(group, "Colors"), colorPage( this ) );
|
||||
add(group = new QtPrefPageItem(selRoot, "Navigator"),
|
||||
navigatorPage( this ) );
|
||||
add(new QtPrefPageItem(group, "Languages"), languagePage( this ) );
|
||||
add(new QtPrefPageItem(group, "Applications"), appsPage( this ) );
|
||||
add(new QtPrefPageItem(selRoot, "Identity"), identityPage( this ) );
|
||||
|
||||
add(group = new QtPrefPageItem(selRoot, "Advanced"), advanced( this ));
|
||||
add(new QtPrefPageItem(group, "Cache"), cachePage( this ) );
|
||||
add(new QtPrefPageItem(group, "Proxies"), proxyPage( this ) );
|
||||
|
||||
|
||||
// add(new QtPrefPageItem(group, "Disk Space"), new DummyCategory);
|
||||
// add(group = new QtPrefPageItem(selRoot, "Mail & Groups"), new DummyCategory);
|
||||
// add(new QtPrefPageItem(group, "Messages"), new DummyCategory);
|
||||
// add(new QtPrefPageItem(group, "Mail Server"), new DummyCategory);
|
||||
// add(new QtPrefPageItem(group, "Groups Server"), new DummyCategory);
|
||||
// add(new QtPrefPageItem(group, "Directory"), new DummyCategory);
|
||||
// add(group = new QtPrefPageItem(selRoot, "Composer"), new DummyCategory);
|
||||
// add(new QtPrefPageItem(group, "New Page Colors"), new DummyCategory);
|
||||
// add(new QtPrefPageItem(group, "Publish"), new DummyCategory);
|
||||
|
||||
setCaption("QtMozilla: Preferences");
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Starts the manual proxy configuration dialog
|
||||
*/
|
||||
|
||||
void QtPreferences::manualProxyPage()
|
||||
{
|
||||
static QDialog *dlg = 0;
|
||||
if ( !dlg )
|
||||
dlg = manProxyDlg( this );
|
||||
dlg->show();
|
||||
}
|
||||
|
||||
|
||||
void QtPreferences::add( QtPrefPageItem* item, QWidget* stack_item)
|
||||
{
|
||||
categories->addWidget(stack_item, item->id());
|
||||
connect( item, SIGNAL(activated(int)), categories, SLOT(raiseWidget(int)) );
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Adds a new preferences item to the list of those who has to be
|
||||
saved when the OK button is pressed
|
||||
*/
|
||||
|
||||
void QtPreferences::add( QtPrefItem *pr )
|
||||
{
|
||||
prefs->append( pr );
|
||||
}
|
||||
|
||||
void QtPreferences::apply()
|
||||
{
|
||||
QListIterator<QtPrefItem> it( *prefs );
|
||||
QtPrefItem *pr;
|
||||
while ( (pr = it.current() ) ) {
|
||||
++it;
|
||||
pr->save();
|
||||
}
|
||||
}
|
||||
|
||||
void QtPreferences::cancel()
|
||||
{
|
||||
//readPrefs(); //### is this the right behaviour?
|
||||
//we need to reset the stuff so it is correct the next time the
|
||||
//dialog pops up, but that should be done just before show()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void QtPreferences::readPrefs()
|
||||
{
|
||||
QListIterator<QtPrefItem> it( *prefs );
|
||||
QtPrefItem *pr;
|
||||
while ( (pr = it.current() ) ) {
|
||||
++it;
|
||||
pr->read();
|
||||
}
|
||||
}
|
||||
|
||||
QtPrefPageItem::QtPrefPageItem( QListView* view, const char* label ) :
|
||||
QListViewItem( view, label, 0 ),
|
||||
i(next_id++)
|
||||
{
|
||||
setExpandable(TRUE);
|
||||
}
|
||||
|
||||
QtPrefPageItem::QtPrefPageItem( QListViewItem* group, const char* label ) :
|
||||
QListViewItem( group, label, 0 ),
|
||||
i(next_id++)
|
||||
{
|
||||
setExpandable(FALSE);
|
||||
}
|
||||
|
||||
void QtPrefPageItem::activate()
|
||||
{
|
||||
emit activated(i);
|
||||
}
|
||||
|
||||
int QtPrefPageItem::next_id = 0;
|
||||
|
||||
|
||||
/*!
|
||||
Edits prefs
|
||||
*/
|
||||
|
||||
void QtPrefs::editPreferences( QtContext *cntxt )
|
||||
{
|
||||
static QtPreferences *prf = 0;
|
||||
if ( !prf )
|
||||
prf = new QtPreferences( cntxt->topLevelWidget() );
|
||||
prf->show();
|
||||
prf->raise();
|
||||
}
|
|
@ -1,219 +0,0 @@
|
|||
/* $Id: QtPrefs.h,v 1.1 1998-09-25 18:01:30 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Paul Olav
|
||||
* Tvete. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _QTPREFS
|
||||
#define _QTPREFS
|
||||
|
||||
#include <qdialog.h>
|
||||
#include <qlistview.h>
|
||||
#include <qlist.h>
|
||||
|
||||
class QWidgetStack;
|
||||
class QtPrefPageItem;
|
||||
|
||||
class QLineEdit;
|
||||
class QRadioButton;
|
||||
class QButtonGroup;
|
||||
class QCheckBox;
|
||||
|
||||
class QtContext;
|
||||
|
||||
class QtPreferences;
|
||||
|
||||
/*
|
||||
From xfe/prefs.h; there must be a platform-independent
|
||||
definition somewhere(???###)
|
||||
*/
|
||||
/* prefs version */
|
||||
|
||||
#define PREFS_CURRENT_VERSION "1.0"
|
||||
|
||||
/* browser startup page */
|
||||
#define BROWSER_STARTUP_BLANK 0
|
||||
#define BROWSER_STARTUP_HOME 1
|
||||
#define BROWSER_STARTUP_LAST 2
|
||||
|
||||
/* mail server type */
|
||||
#define MAIL_SERVER_POP3 0
|
||||
#define MAIL_SERVER_IMAP 1
|
||||
#define MAIL_SERVER_MOVEMAIL 2
|
||||
#define MAIL_SERVER_INBOX 3
|
||||
|
||||
/* toolbar style */
|
||||
#define BROWSER_TOOLBAR_ICONS_ONLY 0
|
||||
#define BROWSER_TOOLBAR_TEXT_ONLY 1
|
||||
#define BROWSER_TOOLBAR_ICONS_AND_TEXT 2
|
||||
|
||||
/* news keep method */
|
||||
#define KEEP_ALL_NEWS 0
|
||||
#define KEEP_NEWS_BY_AGE 1
|
||||
#define KEEP_NEWS_BY_COUNT 2
|
||||
|
||||
/* offline startup mode */
|
||||
#define OFFLINE_STARTUP_ONLINE 0
|
||||
#define OFFLINE_STARTUP_OFFLINE 1
|
||||
#define OFFLINE_STARTUP_ASKME 2
|
||||
|
||||
/* offline news download increments */
|
||||
#define OFFLINE_NEWS_DL_ALL 0
|
||||
#define OFFLINE_NEWS_DL_UNREAD_ONLY 1
|
||||
|
||||
/* offline news download increments */
|
||||
#define OFFLINE_NEWS_DL_YESTERDAY 0
|
||||
#define OFFLINE_NEWS_DL_1_WK_AGO 1
|
||||
#define OFFLINE_NEWS_DL_2_WKS_AGO 2
|
||||
#define OFFLINE_NEWS_DL_1_MONTH_AGO 3
|
||||
#define OFFLINE_NEWS_DL_6_MONTHS_AGO 4
|
||||
#define OFFLINE_NEWS_DL_1_YEAR_AGO 5
|
||||
|
||||
/* use document fonts */
|
||||
#define DOC_FONTS_NEVER 0
|
||||
#define DOC_FONTS_QUICK 1
|
||||
#define DOC_FONTS_ALWAYS 2
|
||||
|
||||
/* help file sites */
|
||||
#define HELPFILE_SITE_NETSCAPE 0
|
||||
#define HELPFILE_SITE_INSTALLED 1
|
||||
#define HELPFILE_SITE_CUSTOM 2
|
||||
|
||||
/* default link expiration for 'never expired' option */
|
||||
#define LINK_NEVER_EXPIRE_DAYS 180
|
||||
|
||||
/* default mail html action */
|
||||
#define HTML_ACTION_ASK 0
|
||||
#define HTML_ACTION_TEXT 1
|
||||
#define HTML_ACTION_HTML 2
|
||||
#define HTML_ACTION_BOTH 3
|
||||
|
||||
|
||||
|
||||
|
||||
class QtPrefItem : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtPrefItem( const char *k, QtPreferences *parent = 0 );
|
||||
virtual void save() = 0;
|
||||
virtual void read() = 0;
|
||||
const char *key() { return mykey; }
|
||||
bool isModified() const { return modified; }
|
||||
protected slots:
|
||||
void setModified( bool b = TRUE ) { modified = b; }
|
||||
private:
|
||||
QString mykey;
|
||||
bool modified;
|
||||
};
|
||||
|
||||
class QtIntPrefItem : public QtPrefItem {
|
||||
public:
|
||||
QtIntPrefItem( const char*, QLineEdit*, QtPreferences *parent = 0 );
|
||||
//setSpinBox
|
||||
int value() const;
|
||||
void setValue( int );
|
||||
void save();
|
||||
void read();
|
||||
private:
|
||||
QLineEdit *lined;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class QtCharPrefItem : public QtPrefItem {
|
||||
public:
|
||||
QtCharPrefItem( const char*, QLineEdit*, QtPreferences *parent = 0 );
|
||||
//QSpinBox
|
||||
const char *value() const;
|
||||
void setValue( const char* );
|
||||
void save();
|
||||
void read();
|
||||
private:
|
||||
QLineEdit *lined;
|
||||
};
|
||||
|
||||
|
||||
class QtBoolPrefItem : public QtPrefItem {
|
||||
public:
|
||||
QtBoolPrefItem( const char*, QCheckBox*, QtPreferences *parent = 0 );
|
||||
bool value() const;
|
||||
void setValue( bool );
|
||||
void save();
|
||||
void read();
|
||||
private:
|
||||
QCheckBox *chkbx;
|
||||
};
|
||||
|
||||
class QtEnumPrefItem : public QtPrefItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtEnumPrefItem( const char*, QtPreferences *parent = 0 );
|
||||
void addRadioButton( QRadioButton*, int val );
|
||||
int value() const;
|
||||
void setValue( int );
|
||||
void save();
|
||||
void read();
|
||||
private slots:
|
||||
void setCurrent( int );
|
||||
private:
|
||||
QButtonGroup *btngrp;
|
||||
int currentVal;
|
||||
};
|
||||
|
||||
|
||||
class QtPreferences : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtPreferences(QWidget* parent=0, const char* name=0, int f=0);
|
||||
|
||||
void add( QtPrefItem* );
|
||||
void readPrefs();
|
||||
public slots:
|
||||
void apply();
|
||||
void cancel();
|
||||
private slots:
|
||||
void manualProxyPage();
|
||||
private:
|
||||
void add( QtPrefPageItem*, QWidget*);
|
||||
QWidgetStack* categories;
|
||||
QList<QtPrefItem> *prefs;
|
||||
};
|
||||
|
||||
class QtPrefPageItem : public QObject, public QListViewItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtPrefPageItem( QListView* view, const char* label );
|
||||
QtPrefPageItem( QListViewItem* group, const char* label );
|
||||
int id() const { return i; }
|
||||
|
||||
signals:
|
||||
void activated(int id);
|
||||
|
||||
protected:
|
||||
void activate();
|
||||
|
||||
private:
|
||||
int i;
|
||||
static int next_id;
|
||||
};
|
||||
|
||||
class QtPrefs {
|
||||
public:
|
||||
static void editPreferences( QtContext * );
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,95 +0,0 @@
|
|||
/* $Id: SaveAsDialog.cpp,v 1.1 1998-09-25 18:01:30 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Kalle
|
||||
* Dalheimer. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "SaveAsDialog.h"
|
||||
#include "QtContext.h"
|
||||
|
||||
#include <qlabel.h>
|
||||
#include <qpushbt.h>
|
||||
#include <qradiobt.h>
|
||||
#include <qtbuttonrow.h>
|
||||
#include <qbttngrp.h>
|
||||
|
||||
SaveAsDialog::SaveAsDialog( QtContext* cx, QWidget* parent,
|
||||
const char* name ) :
|
||||
QFileDialog( parent, name, true ),
|
||||
context( cx )
|
||||
{
|
||||
QLabel* label = new QLabel( tr( "Save As" ), this );
|
||||
|
||||
QButtonGroup* bg = new QButtonGroup( this );
|
||||
bg->hide();
|
||||
QtButtonRow* br = new QtButtonRow( this );
|
||||
textRB = new QRadioButton( tr( "Text" ), br );
|
||||
bg->insert( textRB );
|
||||
sourceRB = new QRadioButton( tr( "Source" ), br );
|
||||
bg->insert( sourceRB );
|
||||
postscriptRB = new QRadioButton( tr( "PostScript" ), br );
|
||||
bg->insert( postscriptRB );
|
||||
|
||||
textRB->setChecked( false );
|
||||
sourceRB->setChecked( true );
|
||||
postscriptRB->setChecked( false );
|
||||
|
||||
// connect
|
||||
connect( bg, SIGNAL(clicked(int)), SLOT(radioClicked(int)) );
|
||||
|
||||
addWidgets( label, br, 0 );
|
||||
|
||||
setCaption( tr( "Save As" ) );
|
||||
}
|
||||
|
||||
|
||||
SaveAsDialog::SaveAsTypes SaveAsDialog::type() const
|
||||
{
|
||||
if( textRB->isChecked() )
|
||||
return Text;
|
||||
else if( sourceRB->isChecked() )
|
||||
return Source;
|
||||
else
|
||||
return PostScript;
|
||||
}
|
||||
|
||||
void SaveAsDialog::radioClicked(int id)
|
||||
{
|
||||
int index;
|
||||
static const char* extensions[] = {
|
||||
".txt",
|
||||
".html",
|
||||
".ps"
|
||||
};
|
||||
QString path;
|
||||
QString selstr = selectedFile();
|
||||
if (!selstr.isNull() && !selstr.isEmpty())
|
||||
{
|
||||
index = selstr.findRev('/');
|
||||
if (index!=-1)
|
||||
{
|
||||
QString path = selstr.left(index);
|
||||
if (strcmp(path, dirPath())!=0)
|
||||
setDir(path);
|
||||
selstr.remove(0, index+1);
|
||||
}
|
||||
index = selstr.findRev('.');
|
||||
if (index!=-1)
|
||||
selstr.replace(index, selstr.length()-index, extensions[id]);
|
||||
setSelection(selstr);
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/* $Id: SaveAsDialog.h,v 1.1 1998-09-25 18:01:30 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Kalle
|
||||
* Dalheimer. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _SAVEASDIALOG_H
|
||||
#define _SAVEASDIALOG_H
|
||||
|
||||
#include <qfiledlg.h>
|
||||
|
||||
class QtContext;
|
||||
class QRadioButton;
|
||||
|
||||
class SaveAsDialog : public QFileDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum SaveAsTypes { Text, Source, PostScript };
|
||||
|
||||
SaveAsDialog( QtContext* cx, QWidget* parent, const char* name = 0 );
|
||||
|
||||
SaveAsTypes type() const;
|
||||
|
||||
private slots:
|
||||
void radioClicked(int);
|
||||
private:
|
||||
QtContext* context;
|
||||
QRadioButton* textRB;
|
||||
QRadioButton* sourceRB;
|
||||
QRadioButton* postscriptRB;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -1,161 +0,0 @@
|
|||
/* $Id: SecurityDialog.cpp,v 1.1 1998-09-25 18:01:30 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Kalle
|
||||
* Dalheimer. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "SecurityDialog.h"
|
||||
|
||||
#include <qtbuttonrow.h>
|
||||
#include <qchkbox.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlayout.h>
|
||||
#include <qpushbt.h>
|
||||
|
||||
#include <fe_proto.h>
|
||||
|
||||
#define i18n(x) x
|
||||
|
||||
SecurityDialog::SecurityDialog( int state, char* prefs_toggle,
|
||||
QWidget* parent, const char* name ) :
|
||||
QDialog( parent, name, true )
|
||||
{
|
||||
char* prefs = prefs_toggle;
|
||||
|
||||
QVBoxLayout* vlayout = new QVBoxLayout( this );
|
||||
|
||||
QLabel* label = new QLabel( this );
|
||||
Bool cancel_p = true;
|
||||
Bool cancel_default_p = false;
|
||||
|
||||
vlayout->addWidget( label, 2 );
|
||||
|
||||
if( prefs_toggle ) {
|
||||
QCheckBox* prefsCB = new QCheckBox( i18n( "Show this Alert Next Time" ),
|
||||
this );
|
||||
prefsCB->adjustSize();
|
||||
vlayout->addWidget( prefsCB );
|
||||
connect( prefsCB, SIGNAL( toggled( bool ) ),
|
||||
this, SLOT( prefsCBToggled( bool ) ) );
|
||||
}
|
||||
|
||||
QtButtonRow* buttonRow = new QtButtonRow( this );
|
||||
vlayout->addWidget( buttonRow );
|
||||
|
||||
QPushButton* continuePB = new QPushButton( buttonRow );
|
||||
connect( continuePB, SIGNAL( clicked() ),
|
||||
this, SLOT( accept() ) );
|
||||
QPushButton* cancelPB = new QPushButton( buttonRow );
|
||||
connect( cancelPB, SIGNAL( clicked() ),
|
||||
this, SLOT( reject() ) );
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case SD_INSECURE_POST_FROM_SECURE_DOC:
|
||||
label->setText( i18n( "Warning! Although this document is secure, any information you\n"
|
||||
"submit is insecure and could be observed by a third party while\n"
|
||||
"in transit. If you are submitting passwords, credit card numbers,\n"
|
||||
"or other information you would like to keep private, it would be\n"
|
||||
"safer for you to cancel the submission." ) );
|
||||
continuePB->setText( i18n( "Confirm Submission" ) );
|
||||
cancelPB->setText( i18n( "Cancel Submission" ) );
|
||||
cancel_p = true;
|
||||
cancel_default_p = true;
|
||||
break;
|
||||
case SD_INSECURE_POST_FROM_INSECURE_DOC:
|
||||
label->setText( i18n( "The information you submit is insecure and could be observed by\n"
|
||||
"a third party while in transit. If you are submitting passwords,\n"
|
||||
"credit card numbers, or other information you would like to keep\n"
|
||||
"private, it would be safer for you to cancel the submission." ) );
|
||||
continuePB->setText( i18n( "Confirm Submission" ) );
|
||||
cancelPB->setText( i18n( "Cancel Submission" ) );
|
||||
cancel_p = true;
|
||||
break;
|
||||
case SD_ENTERING_SECURE_SPACE:
|
||||
label->setText( i18n( "You have requested a secure document. The document and any information\n"
|
||||
"you send back are encrypted for privacy while in transit.\n"
|
||||
"For more information on security choose Page Info from the View menu." ) );
|
||||
continuePB->setText( i18n( "Confirm Loading" ) );
|
||||
cancelPB->setText( i18n( "Cancel Loading" ) );
|
||||
cancel_p = false;
|
||||
break;
|
||||
case SD_LEAVING_SECURE_SPACE:
|
||||
label->setText( i18n( "You have requested an insecure document. The document and any information\n"
|
||||
"you send back could be observed by a third party while in transit.\n"
|
||||
"For more information on security choose Page Info from the View menu." ) );
|
||||
|
||||
continuePB->setText( i18n( "Confirm Loading" ) );
|
||||
cancelPB->setText( i18n( "Cancel Loading" ) );
|
||||
cancel_p = true;
|
||||
break;
|
||||
case SD_INSECURE_DOCS_WITHIN_SECURE_DOCS_NOT_SHOWN:
|
||||
label->setText( i18n( "You have requested a secure document that contains some insecure "
|
||||
"information.\n\n"
|
||||
"The insecure information will not be shown.\n"
|
||||
"For more information on security choose Page Info from the View menu." ) );
|
||||
continuePB->setText( i18n( "OK" ) );
|
||||
cancel_p = false;
|
||||
break;
|
||||
case SD_REDIRECTION_TO_INSECURE_DOC:
|
||||
label->setText( i18n( "Warning! You have requested an insecure document that was\n"
|
||||
"originally designated a secure document (the location has been\n"
|
||||
"redirected from a secure to an insecure document). The document\n"
|
||||
"and any information you send back could be observed by a third\n"
|
||||
"party while in transit." ) );
|
||||
continuePB->setText( i18n( "Confirm Loading" ) );
|
||||
cancelPB->setText( i18n( "Cancel Loading" ) );
|
||||
cancel_p = true;
|
||||
break;
|
||||
case SD_REDIRECTION_TO_SECURE_SITE:
|
||||
label->setText( i18n( "Warning! Your connection has been redirected to a different\n"
|
||||
"site. You may not be connected to the site that you originally\n"
|
||||
"tried to reach." ) );
|
||||
continuePB->setText( i18n( "Confirm Loading" ) );
|
||||
cancelPB->setText( i18n( "Cancel Loading" ) );
|
||||
cancel_p = true;
|
||||
break;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
label->adjustSize();
|
||||
continuePB->adjustSize();
|
||||
|
||||
// bad hack (even in QtMozilla - sigh...)
|
||||
if( !cancel_p )
|
||||
delete cancelPB;
|
||||
else {
|
||||
cancelPB->adjustSize();
|
||||
if( cancel_default_p )
|
||||
cancelPB->setDefault( true );
|
||||
}
|
||||
|
||||
#ifndef NO_HELP
|
||||
QPushButton* helpPB = new QPushButton( i18n( "&Help" ), buttonRow );
|
||||
helpPB->adjustSize();
|
||||
#endif
|
||||
|
||||
vlayout->activate();
|
||||
|
||||
resize( 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
void SecurityDialog::prefsCBToggled( bool value )
|
||||
{
|
||||
*prefs = value;
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
/* $Id: SecurityDialog.h,v 1.1 1998-09-25 18:01:30 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Kalle
|
||||
* Dalheimer. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _SECURITYDIALOG_H
|
||||
#define _SECURITYDIALOG_H
|
||||
|
||||
#include <qdialog.h>
|
||||
#include <xp_core.h>
|
||||
|
||||
class SecurityDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SecurityDialog( int state, char* prefs_toggle,
|
||||
QWidget* parent, const char* name = 0 );
|
||||
char prefsToggleState() const { return *prefs; }
|
||||
|
||||
private slots:
|
||||
void prefsCBToggled( bool );
|
||||
|
||||
private:
|
||||
char* prefs;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,31 +0,0 @@
|
|||
/* $Id: callback.cpp,v 1.1 1998-09-25 18:01:32 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. Portions
|
||||
* created by Warwick Allison, Kalle Dalheimer, Eirik Eng, Matthias
|
||||
* Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav Tvete are
|
||||
* Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "callback.h"
|
||||
|
||||
RCSTAG("$Id: callback.cpp,v 1.1 1998-09-25 18:01:32 ramiro%netscape.com Exp $");
|
||||
|
||||
void Callback::doIt()
|
||||
{
|
||||
if ( c )
|
||||
c();
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/* $Id: callback.h,v 1.1 1998-09-25 18:01:32 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. Portions
|
||||
* created by Warwick Allison, Kalle Dalheimer, Eirik Eng, Matthias
|
||||
* Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav Tvete are
|
||||
* Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef CALLBACK_H
|
||||
#define CALLBACK_H
|
||||
|
||||
#include <qobject.h>
|
||||
|
||||
|
||||
class Callback: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef void (*Function)();
|
||||
|
||||
Callback( QObject *parent, Function callback )
|
||||
: QObject( parent, 0 ), c(callback) {}
|
||||
|
||||
public slots:
|
||||
void doIt();
|
||||
|
||||
private:
|
||||
Function c;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -1,172 +0,0 @@
|
|||
/* $Id: contextmenu.cpp,v 1.1 1998-09-25 18:01:32 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Arnt
|
||||
* Gulbrandsen. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "contextmenu.h"
|
||||
|
||||
#include <qapp.h>
|
||||
#include <qclipbrd.h>
|
||||
#include <qkeycode.h>
|
||||
#include <qstring.h>
|
||||
#include <qmsgbox.h>
|
||||
#include <shist.h>
|
||||
|
||||
#include "QtBrowserContext.h"
|
||||
|
||||
|
||||
RCSTAG("$Id: contextmenu.cpp,v 1.1 1998-09-25 18:01:32 ramiro%netscape.com Exp $");
|
||||
|
||||
|
||||
|
||||
ContextMenu::ContextMenu( QtBrowserContext * parent, const QPoint & pos,
|
||||
const char * linkToURL, const char * imageURL )
|
||||
: QPopupMenu( 0 ),
|
||||
context( parent ),
|
||||
linkTo( linkToURL ),
|
||||
image (imageURL )
|
||||
{
|
||||
move( pos );
|
||||
|
||||
connect( parent, SIGNAL(destroyed()),
|
||||
this, SLOT(goAway()) );
|
||||
|
||||
insert( Back, "&Back", context, SLOT(cmdBack()), CTRL+Key_Left );
|
||||
setItemEnabled( Back, SHIST_CanGoBack( context->mwContext() ) );
|
||||
insert( Forward, "&Forward", context, SLOT(cmdForward()), CTRL+Key_Right );
|
||||
setItemEnabled( Forward, SHIST_CanGoForward( context->mwContext() ) );
|
||||
insert( Reload, "&Reload", context, SLOT(cmdReload()) );
|
||||
|
||||
if ( !linkTo.isEmpty() ) {
|
||||
insertSeparator();
|
||||
insert( OpenLinkWindow, "&Open Link in New Window",
|
||||
this, SLOT(openLinkWindow()) );
|
||||
}
|
||||
|
||||
insertSeparator();
|
||||
insert( ViewSource, "View Page So&urce",
|
||||
context, SLOT(cmdViewPageSource()) );
|
||||
insert( ViewInfo, "&View Page Info",
|
||||
context, SLOT(cmdViewPageInfo()) );
|
||||
if ( !image.isEmpty() )
|
||||
insert( ViewImage, "View I&mage", this, SLOT(viewImage()) );
|
||||
|
||||
insertSeparator();
|
||||
insert( AddBookmark, "&Add Bookmark",
|
||||
context, SLOT(cmdAddBookmark()), CTRL+Key_K );
|
||||
insert( SendPage, "Sen&d Page", this, SLOT(sendPage()) );
|
||||
|
||||
if ( !image.isEmpty() || !linkTo.isEmpty() ) {
|
||||
insertSeparator();
|
||||
if ( !image.isEmpty() )
|
||||
insert( SaveImageAs, "Save Image As...",
|
||||
this, SLOT(saveImageAs()) );
|
||||
if ( !linkTo.isEmpty() ) {
|
||||
insert( SaveLink, "&Save Link As...",
|
||||
this, SLOT( saveLinkAs() ) );
|
||||
}
|
||||
// #warning Background is missing. Kalle.
|
||||
if ( !linkTo.isEmpty() )
|
||||
insert( CopyLinkLocation, "Cop&y Link Location", this,
|
||||
SLOT(copyLinkLocation()) );
|
||||
if ( !image.isEmpty() )
|
||||
insert( CopyImageLocation, "Cop&y Image Location",
|
||||
this, SLOT(copyImageLocation()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ContextMenu::~ContextMenu()
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
|
||||
void ContextMenu::goAway()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
void ContextMenu::insert( int id, const char * text,
|
||||
QObject * receiver, const char * slot,
|
||||
int accel )
|
||||
{
|
||||
insertItem( text, id );
|
||||
connectItem( id, receiver, slot );
|
||||
if ( accel )
|
||||
setAccel( accel, id );
|
||||
}
|
||||
|
||||
|
||||
void ContextMenu::openLinkWindow()
|
||||
{
|
||||
context->browserGetURL( linkTo );
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
void ContextMenu::sendPage()
|
||||
{
|
||||
(void) QMessageBox::information( 0, "QtMozilla",
|
||||
"Congratulations!\n\n"
|
||||
"You found the e*ter e*g!\n",
|
||||
"OK", "Find Others" );
|
||||
/* looking here doesn't help :) */
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
void ContextMenu::viewImage()
|
||||
{
|
||||
context->browserGetURL( image );
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
void ContextMenu::saveLinkAs()
|
||||
{
|
||||
if( linkTo.isEmpty() )
|
||||
context->alert( tr( "Not over a link." ) );
|
||||
else
|
||||
context->saveURL( NET_CreateURLStruct( linkTo, NET_DONT_RELOAD ) );
|
||||
delete this;
|
||||
}
|
||||
|
||||
void ContextMenu::saveImageAs()
|
||||
{
|
||||
if( image.isEmpty() )
|
||||
context->alert( tr( "Not over an image." ) );
|
||||
else
|
||||
context->saveURL( NET_CreateURLStruct( image, NET_DONT_RELOAD ) );
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
void ContextMenu::copyLinkLocation()
|
||||
{
|
||||
QApplication::clipboard()->setText( linkTo.data() );
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
void ContextMenu::copyImageLocation()
|
||||
{
|
||||
QApplication::clipboard()->setText( image.data() );
|
||||
delete this;
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
/* $Id: contextmenu.h,v 1.1 1998-09-25 18:01:32 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Arnt
|
||||
* Gulbrandsen. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef CONTEXTMENU_H
|
||||
#define CONTEXTMENU_H
|
||||
|
||||
#include <qpopmenu.h>
|
||||
#include <qstring.h>
|
||||
|
||||
|
||||
class QtBrowserContext;
|
||||
|
||||
class ContextMenu: public QPopupMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum MenuItem { Back = 1, Forward, Reload,
|
||||
OpenLinkWindow,
|
||||
ViewSource, ViewInfo, ViewImage,
|
||||
AddBookmark, SendPage,
|
||||
SaveLink, SaveImageAs,
|
||||
CopyLinkLocation, CopyImageLocation };
|
||||
|
||||
ContextMenu( QtBrowserContext * context, const QPoint & pos,
|
||||
const char * linkToURL, const char * imageURL );
|
||||
~ContextMenu();
|
||||
|
||||
public slots:
|
||||
void goAway();
|
||||
|
||||
private slots:
|
||||
void openLinkWindow();
|
||||
|
||||
void sendPage();
|
||||
|
||||
void viewImage();
|
||||
|
||||
void saveLinkAs();
|
||||
void saveImageAs();
|
||||
void copyLinkLocation();
|
||||
void copyImageLocation();
|
||||
|
||||
private:
|
||||
void insert( int id, const char * text,
|
||||
QObject * receiver, const char * slot, int accel=0 );
|
||||
|
||||
QtBrowserContext * context;
|
||||
QString linkTo, image;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,28 +0,0 @@
|
|||
/* $Id: contexts.h,v 1.1 1998-09-25 18:01:32 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. Portions
|
||||
* created by Warwick Allison, Kalle Dalheimer, Eirik Eng, Matthias
|
||||
* Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav Tvete are
|
||||
* Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
// this struct can be casted to QtContext...
|
||||
typedef struct
|
||||
{
|
||||
void * nothing;
|
||||
|
||||
} fe_ContextData;
|
|
@ -1,25 +0,0 @@
|
|||
/* $Id: dialogs.cpp,v 1.1 1998-09-25 18:01:32 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. Portions
|
||||
* created by Warwick Allison, Kalle Dalheimer, Eirik Eng, Matthias
|
||||
* Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav Tvete are
|
||||
* Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include <fe_proto.h>
|
||||
#include "qglobal.h"
|
||||
#include "qtfe.h"
|
|
@ -1,109 +0,0 @@
|
|||
/* $Id: dirview.cpp,v 1.1 1998-09-25 18:01:32 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. Portions
|
||||
* created by Warwick Allison, Kalle Dalheimer, Eirik Eng, Matthias
|
||||
* Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav Tvete are
|
||||
* Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "dirview.h"
|
||||
#include <qdir.h>
|
||||
#include <qfile.h>
|
||||
#include <qfileinf.h>
|
||||
|
||||
RCSTAG("$Id: dirview.cpp,v 1.1 1998-09-25 18:01:32 ramiro%netscape.com Exp $");
|
||||
|
||||
|
||||
Directory::Directory( Directory * parent, const char * filename )
|
||||
: QListViewItem( parent ), f(filename )
|
||||
{
|
||||
p = parent;
|
||||
readable = TRUE;
|
||||
}
|
||||
|
||||
|
||||
Directory::Directory( QListView * parent )
|
||||
: QListViewItem( parent ), f("/")
|
||||
{
|
||||
p = 0;
|
||||
readable = TRUE;
|
||||
}
|
||||
|
||||
|
||||
void Directory::setOpen( bool o )
|
||||
{
|
||||
if ( o && !childCount() ) {
|
||||
QString s( fullName() );
|
||||
QDir thisDir( s );
|
||||
if ( !thisDir.isReadable() ) {
|
||||
readable = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
const QFileInfoList * files = thisDir.entryInfoList();
|
||||
if ( files ) {
|
||||
QFileInfoListIterator it( *files );
|
||||
QFileInfo * f;
|
||||
while( (f=it.current()) != 0 ) {
|
||||
++it;
|
||||
if ( f->fileName() == "." || f->fileName() == ".." )
|
||||
; // nothing
|
||||
else if ( f->isSymLink() )
|
||||
new QListViewItem( this, (const char *)f->fileName(),
|
||||
"Symbolic Link", 0 );
|
||||
else if ( f->isDir() )
|
||||
new Directory( this, f->fileName() );
|
||||
else
|
||||
new QListViewItem( this, (const char *)f->fileName(),
|
||||
f->isFile() ? "File" : "Special", 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
QListViewItem::setOpen( o );
|
||||
}
|
||||
|
||||
|
||||
void Directory::setup()
|
||||
{
|
||||
setExpandable( TRUE );
|
||||
QListViewItem::setup();
|
||||
}
|
||||
|
||||
|
||||
QString Directory::fullName()
|
||||
{
|
||||
QString s;
|
||||
if ( p ) {
|
||||
s = p->fullName();
|
||||
s.append( f.name() );
|
||||
s.append( "/" );
|
||||
} else {
|
||||
s = "/";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
const char * Directory::text( int column ) const
|
||||
{
|
||||
if ( column == 0 )
|
||||
return f.name();
|
||||
else if ( readable )
|
||||
return "Directory";
|
||||
else
|
||||
return "Unreadable Directory";
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
/* $Id: dirview.h,v 1.1 1998-09-25 18:01:33 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. Portions
|
||||
* created by Warwick Allison, Kalle Dalheimer, Eirik Eng, Matthias
|
||||
* Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav Tvete are
|
||||
* Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef DIRVIEW_H
|
||||
#define DIRVIEW_H
|
||||
|
||||
#include <qlistview.h>
|
||||
#include <qstring.h>
|
||||
#include <qfile.h>
|
||||
|
||||
class Directory: public QListViewItem
|
||||
{
|
||||
public:
|
||||
Directory( QListView * parent );
|
||||
Directory( Directory * parent, const char * filename );
|
||||
|
||||
const char * text( int column ) const;
|
||||
|
||||
QString fullName();
|
||||
|
||||
void setOpen( bool );
|
||||
void setup();
|
||||
|
||||
private:
|
||||
QFile f;
|
||||
Directory * p;
|
||||
bool readable;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -1,77 +0,0 @@
|
|||
/* $Id: doclayout.cpp,v 1.1 1998-09-25 18:01:33 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. Portions
|
||||
* created by Warwick Allison, Kalle Dalheimer, Eirik Eng, Matthias
|
||||
* Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav Tvete are
|
||||
* Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "QtContext.h"
|
||||
#include "shist.h"
|
||||
|
||||
|
||||
static void useArgs( const char *fn, ... )
|
||||
{
|
||||
if (0&&fn) printf( "%s\n", fn );
|
||||
}
|
||||
|
||||
/* From ./lay.c: */
|
||||
void QtContext::layoutNewDocument(URL_Struct *url,
|
||||
int32 *iWidth, int32 *iHeight,
|
||||
int32 *mWidth, int32 *mHeight)
|
||||
{
|
||||
*iWidth = visibleWidth();
|
||||
*iHeight = visibleHeight();
|
||||
|
||||
// crazy defaults...... inspired by the xfe
|
||||
if (mwContext()->is_grid_cell){
|
||||
*mWidth = 7;
|
||||
*mHeight = 4;
|
||||
} else {
|
||||
*mWidth = 8;
|
||||
*mHeight = 8;
|
||||
}
|
||||
|
||||
// fprintf( stderr, "QTFE_LayoutNewDocument %p, %dx%d, %d,%d \n",
|
||||
// url, *iWidth, *iHeight, *mWidth, *mHeight );
|
||||
|
||||
SHIST_AddDocument( context, SHIST_CreateHistoryEntry( url, "" ) );
|
||||
}
|
||||
|
||||
/* From ./lay.c: */
|
||||
void QtContext::setDocTitle(char *title)
|
||||
{
|
||||
useArgs( "QTFE_SetDocTitle %s \n", title );
|
||||
}
|
||||
|
||||
/* From ./lay.c: */
|
||||
void QtContext::finishedLayout()
|
||||
{
|
||||
useArgs( "QTFE_FinishedLayout \n" );
|
||||
}
|
||||
|
||||
/* From ./lay.c: */
|
||||
void QtContext::beginPreSection()
|
||||
{
|
||||
useArgs( "QTFE_BeginPreSection \n" );
|
||||
}
|
||||
|
||||
/* From ./lay.c: */
|
||||
void QtContext::endPreSection()
|
||||
{
|
||||
useArgs( "QTFE_EndPreSection \n" );
|
||||
}
|
|
@ -1,496 +0,0 @@
|
|||
/* $Id: drawing.cpp,v 1.1 1998-09-25 18:01:33 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. Portions
|
||||
* created by Warwick Allison, Kalle Dalheimer, Eirik Eng, Matthias
|
||||
* Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav Tvete are
|
||||
* Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "libi18n.h"
|
||||
#include "QtContext.h"
|
||||
#include <qpainter.h>
|
||||
#include <qdrawutl.h>
|
||||
|
||||
|
||||
/* Taken from the xfe implementation. */
|
||||
|
||||
char *
|
||||
QtContext::translateISOText(int charset, char *ISO_Text)
|
||||
{
|
||||
unsigned char *s;
|
||||
|
||||
/* charsets such as Shift-JIS contain 0240's that are valid */
|
||||
if (INTL_CharSetType(charset) != SINGLEBYTE)
|
||||
return ISO_Text;
|
||||
|
||||
/* When is encountered, display a normal space character instead.
|
||||
This is necessary because the MIT fonts are messed up, and have a
|
||||
zero-width character for nobreakspace, so we need to print it as a
|
||||
normal space instead. */
|
||||
if (ISO_Text)
|
||||
for (s = (unsigned char *) ISO_Text; *s; s++)
|
||||
if (*s == 0240) *s = ' ';
|
||||
|
||||
return ISO_Text;
|
||||
}
|
||||
|
||||
|
||||
static QFont getFontWithFamily( const char *fam, int pts, int wgt, bool ita )
|
||||
{
|
||||
QString familyList = fam;
|
||||
QString token;
|
||||
QString realFamily;
|
||||
|
||||
QFont returnFont( "times", pts, wgt, ita );
|
||||
|
||||
// debug( "Font family list: %s", fam );
|
||||
int pos;
|
||||
do {
|
||||
pos = familyList.find( "," );
|
||||
if ( pos != -1 ) {
|
||||
token = familyList.left( pos );
|
||||
familyList.remove( 0, pos + 1 );
|
||||
} else {
|
||||
token = familyList;
|
||||
}
|
||||
token = token.stripWhiteSpace();
|
||||
if ( token[0] == '"' )
|
||||
token.remove( 0, 1 );
|
||||
int len = token.length();
|
||||
if ( token[len - 1] == '"' )
|
||||
token.remove( len - 1, 1 );
|
||||
returnFont.setFamily( token );
|
||||
// fi.setFont( returnFont ); Should chech if font family is available
|
||||
// debug( "Font family chosen: %s", token.data() );
|
||||
return returnFont;
|
||||
} while (pos != -1 );
|
||||
returnFont.setFamily( "times" );
|
||||
return returnFont;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// return a QFont* for a given Netscape TextStruct.
|
||||
// This will use a cached result if possible
|
||||
QFont QtContext::getFont(LO_TextAttr *text_attr)
|
||||
{
|
||||
if (text_attr->FE_Data){
|
||||
return *((QFont*) (text_attr->FE_Data));
|
||||
}
|
||||
|
||||
const char* fam;
|
||||
int pts, wgt;
|
||||
bool ita;
|
||||
|
||||
if (!text_attr->font_face){
|
||||
fam= (text_attr->fontmask & LO_FONT_FIXED) ? "courier" : "times";
|
||||
}
|
||||
else
|
||||
fam=text_attr->font_face;
|
||||
|
||||
wgt=text_attr->font_weight;
|
||||
ita=text_attr->fontmask & LO_FONT_ITALIC;
|
||||
|
||||
//#warning Matthias TODO implement charsets
|
||||
// result->setCharSet(text_attr->charset);
|
||||
pts = int(text_attr->point_size);
|
||||
if ( pts <= 0) {
|
||||
int size3 = 12;
|
||||
switch ( text_attr->size ) {
|
||||
case 1:
|
||||
pts = 8;
|
||||
break;
|
||||
case 2:
|
||||
pts = 10;
|
||||
break;
|
||||
case 3:
|
||||
pts = 12;
|
||||
break;
|
||||
case 4:
|
||||
pts = 14;
|
||||
break;
|
||||
case 5:
|
||||
pts = 18;
|
||||
break;
|
||||
case 6:
|
||||
pts = 24;
|
||||
break;
|
||||
default:
|
||||
pts = (text_attr->size-6)*4+24;
|
||||
}
|
||||
pts = pts * size3 / 12;
|
||||
}
|
||||
|
||||
QFont result = getFontWithFamily(fam, pts, wgt, ita);
|
||||
|
||||
if (!wgt) result.setBold(text_attr->fontmask & LO_FONT_BOLD);
|
||||
result.setStrikeOut(text_attr->attrmask & LO_ATTR_STRIKEOUT);
|
||||
result.setUnderline(text_attr->attrmask & LO_ATTR_UNDERLINE);
|
||||
return result;
|
||||
}
|
||||
|
||||
void QtContext::releaseTextAttrFeData(LO_TextAttr *attr){
|
||||
if (attr->FE_Data){
|
||||
delete (QFont*) (attr->FE_Data);
|
||||
attr->FE_Data = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void QtContext::displaySubtext( int /* iLocation */,
|
||||
LO_TextStruct *text, int start_pos, int end_pos,
|
||||
bool )
|
||||
{
|
||||
LO_TextAttr *text_attr = text->text_attr;
|
||||
QFont font = getFont(text_attr);
|
||||
QColor fg(text_attr->fg.red,
|
||||
text_attr->fg.green,
|
||||
text_attr->fg.blue);
|
||||
QColor bg(text_attr->bg.red,
|
||||
text_attr->bg.green,
|
||||
text_attr->bg.blue);
|
||||
|
||||
|
||||
painter()->setPen(fg);
|
||||
painter()->setFont(font);
|
||||
QColor obg = painter()->backgroundColor();
|
||||
|
||||
bool selected_p = false;
|
||||
|
||||
QFontMetrics fm = painter()->fontMetrics();
|
||||
|
||||
/* this check is inspired by the fxe. not too sure but it cannot really harm....
|
||||
*/
|
||||
if ((text->ele_attrmask & LO_ELE_SELECTED) &&
|
||||
(start_pos >= text->sel_start) && (end_pos-1 <= text->sel_end))
|
||||
selected_p = true;
|
||||
|
||||
/* use black and white for selections
|
||||
*/
|
||||
if (selected_p){
|
||||
painter()->setBackgroundMode(OpaqueMode);
|
||||
painter()->setBackgroundColor(black);
|
||||
painter()->setPen(white);
|
||||
}
|
||||
else if (text->text_attr->no_background){
|
||||
painter()->setPen(fg);
|
||||
}
|
||||
else {
|
||||
painter()->setBackgroundMode(OpaqueMode);
|
||||
painter()->setBackgroundColor(bg);
|
||||
painter()->setPen(fg);
|
||||
}
|
||||
|
||||
/* do the drawing */
|
||||
painter()->drawText(text->x - documentXOffset(),
|
||||
text->y + text->y_offset + fm.ascent() - documentYOffset(),
|
||||
(char*) (text->text + start_pos),
|
||||
end_pos - start_pos);
|
||||
|
||||
/* reset the background mode of the qpainter
|
||||
*/
|
||||
painter()->setBackgroundColor(TransparentMode);
|
||||
painter()->setBackgroundColor(obg);
|
||||
}
|
||||
|
||||
void QtContext::clearPainter()
|
||||
{
|
||||
if (internal_painter && internal_painter->isActive())
|
||||
internal_painter->end();
|
||||
if (internal_painter) delete internal_painter;
|
||||
internal_painter = 0;
|
||||
}
|
||||
|
||||
int QtContext::documentXOffset() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int QtContext::documentYOffset() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QtContext::displayText (int iLocation, LO_TextStruct *text, bool){
|
||||
displaySubtext(iLocation, text, 0, text->text_len, false);
|
||||
}
|
||||
|
||||
void QtContext::getTextInfo(LO_TextStruct *text, LO_TextInfo *text_info){
|
||||
#if defined(XP_WINDAUGE)
|
||||
QFontMetrics fontMetrics(QFont("helvetica", 12)); // EE ###getFont(text->text_attr));
|
||||
#else
|
||||
QFontMetrics fontMetrics(getFont(text->text_attr));
|
||||
#endif
|
||||
text_info->max_width = fontMetrics.width((char*)text->text, text->text_len);
|
||||
text_info->ascent = fontMetrics.ascent();
|
||||
text_info->descent = fontMetrics.descent();
|
||||
text_info->lbearing = fontMetrics.minLeftBearing();
|
||||
text_info->rbearing = fontMetrics.minRightBearing();
|
||||
}
|
||||
|
||||
|
||||
void QtContext::getTextFrame(LO_TextStruct *text, int32 start,
|
||||
int32 end, XP_Rect *frame)
|
||||
{
|
||||
QFontMetrics fontMetrics(getFont(text->text_attr));
|
||||
frame->left = text->x + text->x_offset;
|
||||
frame->top = text->y + text->y_offset;
|
||||
frame->right = frame->left + fontMetrics.width( (char*)text->text+start,
|
||||
end-start );
|
||||
frame->bottom = frame->top + fontMetrics.lineSpacing();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void QtContext::displayTable(int loc, LO_TableStruct *ts){
|
||||
|
||||
|
||||
// fe_Drawable *fe_drawable = CONTEXT_DATA (context)->drawable;
|
||||
|
||||
// long x = ts->x + ts->x_offset - CONTEXT_DATA (context)->document_x +
|
||||
// fe_drawable->x_origin;
|
||||
// long y = ts->y + ts->y_offset - CONTEXT_DATA (context)->document_y +
|
||||
// fe_drawable->y_origin;
|
||||
|
||||
// if ((x > 0 && x > CONTEXT_DATA (context)->scrolled_width) ||
|
||||
// (y > 0 && y > CONTEXT_DATA (context)->scrolled_height) ||
|
||||
// (x + ts->width < 0) ||
|
||||
// (y + ts->line_height< 0))
|
||||
// return;
|
||||
|
||||
|
||||
// painter()->drawText(text->x - documentXOffset(),
|
||||
// text->y + text->y_offset + fm.ascent() - documentYOffset(),
|
||||
// (char*) (text->text + start_pos),
|
||||
// end_pos - start_pos);
|
||||
|
||||
long x = ts->x + ts->x_offset - documentXOffset() + getXOrigin();
|
||||
long y = ts->y + ts->y_offset - documentYOffset() + getYOrigin();
|
||||
|
||||
bool hasBorder = (ts->border_top_width > 0 || ts->border_right_width > 0
|
||||
|| ts->border_bottom_width > 0 || ts->border_left_width > 0);
|
||||
|
||||
QRect table_rect(x,y,ts->width,ts->height);
|
||||
|
||||
|
||||
if (hasBorder)
|
||||
{
|
||||
int w = ts->border_top_width;
|
||||
displayTableBorder(ts, table_rect, w );
|
||||
}
|
||||
}
|
||||
|
||||
QColorGroup QtContext::colorGroup(const QColor& col)
|
||||
{
|
||||
QColor topsh = col.light();
|
||||
QColor botsh = col.dark();
|
||||
int h,s,v;
|
||||
col.hsv(&h,&s,&v);
|
||||
if ( v > 200 ) {
|
||||
topsh.setHsv(h,s,200);
|
||||
} else if ( v < 90 ) {
|
||||
topsh.setHsv(h,s,90);
|
||||
botsh.setHsv(h,s,60);
|
||||
}
|
||||
|
||||
return QColorGroup(col,
|
||||
contentWidget()->colorGroup().background(),
|
||||
topsh,
|
||||
botsh,
|
||||
col,
|
||||
contentWidget()->colorGroup().text(),
|
||||
col);
|
||||
}
|
||||
|
||||
void QtContext::displayTableBorder(LO_TableStruct *ts,
|
||||
QRect r, int bw)
|
||||
{
|
||||
|
||||
if (!contentWidget())
|
||||
return;
|
||||
|
||||
QColor col (ts->border_color.red,
|
||||
ts->border_color.green,
|
||||
ts->border_color.blue);
|
||||
|
||||
QColorGroup g = colorGroup( col );
|
||||
|
||||
switch (ts->border_style)
|
||||
{
|
||||
case BORDER_NONE:
|
||||
break;
|
||||
|
||||
case BORDER_DOTTED:
|
||||
case BORDER_DASHED:
|
||||
case BORDER_SOLID:
|
||||
qDrawPlainRect(painter(), r, col, bw);
|
||||
break;
|
||||
|
||||
case BORDER_DOUBLE:
|
||||
{
|
||||
int ws = (bw+1)/3;
|
||||
qDrawPlainRect(painter(), r, col, ws);
|
||||
qDrawPlainRect(painter(), QRect(r.x()+bw-ws, r.y()+bw-ws,
|
||||
r.width()- 2*(bw-ws),
|
||||
r.height()- 2*(bw-ws)),
|
||||
col, ws);
|
||||
}
|
||||
break;
|
||||
|
||||
case BORDER_GROOVE:
|
||||
if (bw<2) bw = 2;
|
||||
qDrawShadeRect(painter(), r, g, true, 1, bw-2);
|
||||
break;
|
||||
|
||||
case BORDER_RIDGE:
|
||||
if (bw<2) bw = 2;
|
||||
qDrawShadeRect(painter(), r, g, false, 1, bw-2);
|
||||
break;
|
||||
|
||||
case BORDER_INSET:
|
||||
qDrawShadePanel(painter(), r, g, true, bw);
|
||||
break;
|
||||
|
||||
case BORDER_OUTSET:
|
||||
qDrawShadePanel(painter(), r, g, false, bw);
|
||||
break;
|
||||
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QtContext::displayBorder(int iLocation, int x, int y, int width,
|
||||
int height, int bw, LO_Color *color, LO_LineStyle style)
|
||||
{
|
||||
// debug( "QTFE_DisplayBorder %d, %d, %d, %d, %d, %d, %p, %d",
|
||||
// iLocation, x, y, width,
|
||||
// height, bw, color, (int)style);
|
||||
|
||||
if (bw <= 0)
|
||||
return;
|
||||
|
||||
QColor col (color->red,
|
||||
color->green,
|
||||
color->blue);
|
||||
|
||||
QColorGroup g = colorGroup( col );
|
||||
|
||||
QRect r(x - documentXOffset() + getXOrigin(),
|
||||
y - documentYOffset() + getYOrigin(),
|
||||
width,
|
||||
height);
|
||||
switch (style){
|
||||
case LO_SOLID:
|
||||
qDrawPlainRect(painter(), r, col, bw);
|
||||
break;
|
||||
case LO_BEVEL:
|
||||
if (bw<2)
|
||||
bw = 2;
|
||||
qDrawShadeRect(painter(), r, g, false, 1, bw-2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* From ./lay.c: */
|
||||
void QtContext::displayCell(int loc, LO_CellStruct *cell)
|
||||
{
|
||||
int bw = cell->border_width;
|
||||
if (bw <= 0)
|
||||
return;
|
||||
|
||||
QRect r(cell->x + cell->x_offset - documentXOffset() + getXOrigin(),
|
||||
cell->y + cell->y_offset - documentYOffset() + getYOrigin(),
|
||||
cell->width,
|
||||
cell->height);
|
||||
qDrawShadePanel(painter(), r,
|
||||
contentWidget()->colorGroup(),
|
||||
true, bw);
|
||||
|
||||
}
|
||||
|
||||
/* From ./lay.c: */
|
||||
void QtContext::eraseBackground(int iLocation, int32 x, int32 y,
|
||||
uint32 width, uint32 height, LO_Color *bg)
|
||||
{
|
||||
QColor col (bg->red,
|
||||
bg->green,
|
||||
bg->blue);
|
||||
QRect r(x - documentXOffset(),
|
||||
y - documentYOffset(),
|
||||
width,
|
||||
height);
|
||||
|
||||
painter()->fillRect(r, col);
|
||||
}
|
||||
|
||||
/* From ./lay.c: */
|
||||
void QtContext::displayHR(int iLocation, LO_HorizRuleStruct *hr)
|
||||
{
|
||||
QPoint p1( hr->x + hr->x_offset - documentXOffset() + getXOrigin(),
|
||||
hr->y + hr->y_offset - documentYOffset() + getYOrigin() );
|
||||
QPoint p2 = p1 + QPoint(hr->width,0);
|
||||
if ( hr->ele_attrmask & LO_ELE_SHADED ) {
|
||||
qDrawShadeLine(painter(), p1, p2, contentWidget()->colorGroup(),
|
||||
hr->height, 1);
|
||||
} else {
|
||||
QColor hrCol = painter()->pen().color(); //#####???
|
||||
painter()->setPen( QPen( hrCol, hr->height) );
|
||||
painter()->drawLine( p1, p2 );
|
||||
}
|
||||
// debug( "QTFE_DisplayHR %d, %p", iLocation, hr);
|
||||
}
|
||||
|
||||
/* From ./lay.c: */
|
||||
void QtContext::displayBullet(int iLocation, LO_BulletStruct *bul)
|
||||
{
|
||||
|
||||
//The front end should only ever see
|
||||
//bullets of type BULLET_ROUND and BULLET_SQUARE
|
||||
|
||||
QCOORD x = bul->x + bul->x_offset - documentXOffset() + getXOrigin();
|
||||
QCOORD y = bul->y + bul->y_offset - documentYOffset() + getYOrigin();
|
||||
QCOORD w = bul->bullet_size;
|
||||
|
||||
|
||||
LO_TextAttr *text_attr = bul->text_attr;
|
||||
QColor fg(text_attr->fg.red,
|
||||
text_attr->fg.green,
|
||||
text_attr->fg.blue);
|
||||
QColor bg(text_attr->bg.red,
|
||||
text_attr->bg.green,
|
||||
text_attr->bg.blue);
|
||||
|
||||
if ( bul->bullet_type == BULLET_SQUARE ) {
|
||||
painter()->fillRect( x, y, w, w, fg );
|
||||
} else {
|
||||
if ( bul->bullet_type != BULLET_ROUND
|
||||
&& bul->bullet_type != BULLET_BASIC )
|
||||
warning( "QtContext::displayBullet unknown type %d",
|
||||
bul->bullet_type);
|
||||
painter()->setBrush( fg );
|
||||
painter()->setPen( fg );
|
||||
painter()->drawEllipse( x, y, w, w);
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/* $Id: finding.h,v 1.1 1998-09-25 18:01:33 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. Portions
|
||||
* created by Warwick Allison, Kalle Dalheimer, Eirik Eng, Matthias
|
||||
* Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav Tvete are
|
||||
* Copyright (C) 1998 Warwick Allison, Kalle Dalheimer, Eirik Eng,
|
||||
* Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and Paul Olav
|
||||
* Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _FINDING_H
|
||||
#define _FINDING_H
|
||||
|
||||
#include <structs.h>
|
||||
#include <ntypes.h>
|
||||
class QWidget;
|
||||
|
||||
#define FE_FIND_FOUND 0
|
||||
#define FE_FIND_NOTFOUND 1
|
||||
#define FE_FIND_CANCEL 2
|
||||
#define FE_FIND_HEADER_FOUND 3
|
||||
#define FE_FIND_HEADER_NOTFOUND 4
|
||||
#define FE_FIND_NOSTRING 5
|
||||
|
||||
|
||||
typedef struct fe_FindData
|
||||
{
|
||||
MWContext *context;
|
||||
MWContext *context_to_find; /* used for which frame cell to find in. */
|
||||
bool find_in_headers;
|
||||
bool case_sensitive_p, backward_p;
|
||||
QString string;
|
||||
QWidget* shell;
|
||||
LO_Element *start_element, *end_element;
|
||||
int32 start_pos, end_pos;
|
||||
|
||||
fe_FindData()
|
||||
{
|
||||
context_to_find = 0;
|
||||
find_in_headers = false;
|
||||
case_sensitive_p = false;
|
||||
backward_p = false;
|
||||
start_element = end_element = 0;
|
||||
start_pos = end_pos = 0;
|
||||
}
|
||||
} fe_FindData;
|
||||
|
||||
#endif
|
1293
cmd/qtfe/forms.cpp
1293
cmd/qtfe/forms.cpp
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,31 +0,0 @@
|
|||
/*-*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* $Id: histlistview.cpp,v 1.1 1998-09-25 18:01:34 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* First version of this file written 1998 by Jonas Utterstrom
|
||||
* <mailto:jonas.utterstrom@vittran.norrnod.se>
|
||||
*/
|
||||
|
||||
#include "histlistview.h"
|
||||
|
||||
HistoryListView::HistoryListView(QWidget *parent, const char* title)
|
||||
: QListView(parent, title)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void HistoryListView::setSorting(int column, bool increasing)
|
||||
{
|
||||
QListView::setSorting(column, increasing);
|
||||
emit sortColumnChanged(column, increasing);
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
/*-*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* $Id: histlistview.h,v 1.1 1998-09-25 18:01:34 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* First version of this file written 1998 by Jonas Utterstrom
|
||||
* <mailto:jonas.utterstrom@vittran.norrnod.se>
|
||||
*/
|
||||
|
||||
#ifndef _HIST_LISTVIEW_H_
|
||||
#define _HIST_LISTVIEW_H_
|
||||
|
||||
#include <qlistview.h>
|
||||
|
||||
class HistoryListView : public QListView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HistoryListView(QWidget *parent, const char* title);
|
||||
virtual void setSorting(int column, bool increasing = true);
|
||||
|
||||
signals:
|
||||
void sortColumnChanged(int, bool);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,327 +0,0 @@
|
|||
/* $Id: icons.cpp,v 1.1 1998-09-25 18:01:34 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Arnt
|
||||
* Gulbrandsen. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "icons.h"
|
||||
|
||||
#include <qapp.h>
|
||||
#include <qdict.h>
|
||||
#include <qregexp.h>
|
||||
|
||||
#include "il_icons.h"
|
||||
|
||||
RCSTAG("$Id: icons.cpp,v 1.1 1998-09-25 18:01:34 ramiro%netscape.com Exp $");
|
||||
|
||||
// generated file with heaps of icons
|
||||
#include "icon-pixmaps.inc"
|
||||
|
||||
/*
|
||||
Extracted wisdom of the ancients, mapping IL_ constants to file names.
|
||||
|
||||
This is generated from xfe/icons.c by a quick-and-dirty Perl
|
||||
script and massaged by hand. We put this in the source code
|
||||
since we do not want to depend on xfe/ files.
|
||||
*/
|
||||
static struct {
|
||||
unsigned int code;
|
||||
const char *name;
|
||||
} icon_map_vec[] = {
|
||||
{IL_IMAGE_DELAYED, "IReplace"},
|
||||
{IL_IMAGE_NOT_FOUND, "IconUnknown"},
|
||||
{IL_IMAGE_BAD_DATA, "IBad"},
|
||||
{IL_IMAGE_EMBED, "IconUnknown"},
|
||||
{IL_IMAGE_INSECURE, "SEC_Replace"},
|
||||
#if 0
|
||||
{IL_ICON_DESKTOP_NAVIGATOR, "Desk_Navigator"},
|
||||
{IL_ICON_DESKTOP_MSGCENTER, "Desk_MsgCenter"},
|
||||
{IL_ICON_DESKTOP_ABOOK, "Desk_Address"},
|
||||
{IL_ICON_DESKTOP_BOOKMARK, "Desk_Bookmark"},
|
||||
{IL_ICON_DESKTOP_NOMAIL, "Desk_Messenger"},
|
||||
{IL_ICON_DESKTOP_YESMAIL, "Desk_NewMail"},
|
||||
{IL_ICON_DESKTOP_NEWS, "Desk_Collabra"},
|
||||
{IL_ICON_DESKTOP_MSGCOMPOSE, "Desk_MsgCompose"},
|
||||
{IL_ICON_DESKTOP_EDITOR, "Desk_Composer"},
|
||||
{IL_ICON_DESKTOP_COMMUNICATOR, "Desk_Communicator"},
|
||||
{IL_ICON_DESKTOP_HISTORY, "Desk_History"},
|
||||
{IL_ICON_DESKTOP_SEARCH, "Desk_Search"},
|
||||
{IL_ICON_DESKTOP_JAVACONSOLE, "Desk_JavaConsole"},
|
||||
#endif
|
||||
{IL_GOPHER_TEXT, "GText"},
|
||||
{IL_GOPHER_IMAGE, "GImage"},
|
||||
{IL_GOPHER_BINARY, "GBinary"},
|
||||
{IL_GOPHER_SOUND, "GAudio"},
|
||||
{IL_GOPHER_MOVIE, "GMovie"},
|
||||
{IL_GOPHER_FOLDER, "GFolder"},
|
||||
{IL_GOPHER_SEARCHABLE, "GFind"},
|
||||
{IL_GOPHER_TELNET, "GTelnet"},
|
||||
{IL_GOPHER_UNKNOWN, "GUnknown"},
|
||||
#if 0
|
||||
{IL_EDITOR_NEW, "ed_new"},
|
||||
{IL_EDITOR_NEW_GREY, "ed_new.i"},
|
||||
{IL_EDITOR_OPEN, "ed_open"},
|
||||
{IL_EDITOR_OPEN_GREY, "ed_open.i"},
|
||||
{IL_EDITOR_SAVE, "ed_save"},
|
||||
{IL_EDITOR_SAVE_GREY, "ed_save.i"},
|
||||
{IL_EDITOR_BROWSE, "ed_browse"},
|
||||
{IL_EDITOR_BROWSE_GREY, "ed_browse.i"},
|
||||
{IL_EDITOR_CUT, "ed_cut"},
|
||||
{IL_EDITOR_CUT_GREY, "ed_cut.i"},
|
||||
{IL_EDITOR_COPY, "ed_copy"},
|
||||
{IL_EDITOR_COPY_GREY, "ed_copy.i"},
|
||||
{IL_EDITOR_PASTE, "ed_paste"},
|
||||
{IL_EDITOR_PASTE_GREY, "ed_paste.i"},
|
||||
{IL_EDITOR_PRINT, "ed_print"},
|
||||
{IL_EDITOR_PRINT_GREY, "ed_print.i"},
|
||||
{IL_EDITOR_FIND, "ed_find"},
|
||||
{IL_EDITOR_FIND_GREY, "ed_find.i"},
|
||||
{IL_EDITOR_PUBLISH, "ed_publish"},
|
||||
{IL_EDITOR_PUBLISH_GREY, "ed_publish.i"},
|
||||
{IL_ICON_BACK_GREY, "TB_Back.i"},
|
||||
{IL_ICON_LOAD_GREY, "TB_LoadImages.i"},
|
||||
{IL_ICON_FWD_GREY, "TB_Forward.i"},
|
||||
{IL_ICON_STOP_GREY, "TB_Stop.i"},
|
||||
{IL_ALIGN4_RAISED, "ImgB2B_r"},
|
||||
{IL_ALIGN5_RAISED, "ImgB2D_r"},
|
||||
{IL_ALIGN3_RAISED, "ImgC2B_r"},
|
||||
{IL_ALIGN2_RAISED, "ImgC2C_r"},
|
||||
{IL_ALIGN7_RAISED, "ImgWL_r"},
|
||||
{IL_ALIGN6_RAISED, "ImgWR_r"},
|
||||
{IL_ALIGN1_RAISED, "ImgT2T_r"},
|
||||
{IL_EDITOR_NEW_PT, "ed_new_pt"},
|
||||
{IL_EDITOR_OPEN_PT, "ed_open_pt"},
|
||||
{IL_EDITOR_SAVE_PT, "ed_save_pt"},
|
||||
{IL_EDITOR_BROWSE_PT, "ed_browse_pt"},
|
||||
{IL_EDITOR_CUT_PT, "ed_cut_pt"},
|
||||
{IL_EDITOR_COPY_PT, "ed_copy_pt"},
|
||||
{IL_EDITOR_PASTE_PT, "ed_paste_pt"},
|
||||
{IL_EDITOR_PRINT_PT, "ed_print_pt"},
|
||||
{IL_EDITOR_FIND_PT, "ed_find_pt"},
|
||||
{IL_EDITOR_PUBLISH_PT, "ed_publish_pt"},
|
||||
{IL_EDITOR_NEW_PT_GREY, "ed_new_pt.i"},
|
||||
{IL_EDITOR_OPEN_PT_GREY, "ed_open_pt.i"},
|
||||
{IL_EDITOR_SAVE_PT_GREY, "ed_save_pt.i"},
|
||||
{IL_EDITOR_BROWSE_PT_GREY, "ed_browse_pt.i"},
|
||||
{IL_EDITOR_CUT_PT_GREY, "ed_cut_pt.i"},
|
||||
{IL_EDITOR_COPY_PT_GREY, "ed_copy_pt.i"},
|
||||
{IL_EDITOR_PASTE_PT_GREY, "ed_paste_pt.i"},
|
||||
{IL_EDITOR_PRINT_PT_GREY, "ed_print_pt.i"},
|
||||
{IL_EDITOR_FIND_PT_GREY, "ed_find_pt.i"},
|
||||
{IL_EDITOR_PUBLISH_PT_GREY, "ed_publish_pt.i"},
|
||||
{IL_ICON_BACK_GREY, "TB_Back.i"},
|
||||
{IL_ICON_LOAD_GREY, "TB_LoadImages.i"},
|
||||
{IL_ICON_FWD_GREY, "TB_Forward.i"},
|
||||
{IL_ICON_STOP_GREY, "TB_Stop.i"},
|
||||
{IL_EDITOR_BOLD, "ed_bold"},
|
||||
{IL_EDITOR_BULLET, "ed_bullet"},
|
||||
{IL_EDITOR_CENTER, "ed_center"},
|
||||
{IL_EDITOR_CLEAR, "ed_clear"},
|
||||
{IL_EDITOR_COLOR, "ed_color"},
|
||||
{IL_EDITOR_FIXED, "ed_fixed"},
|
||||
{IL_EDITOR_GROW, "ed_grow"},
|
||||
{IL_EDITOR_GROW_GREY, "ed_grow.i"},
|
||||
{IL_EDITOR_HRULE, "ed_hrule"},
|
||||
{IL_EDITOR_IMAGE, "ed.image"},
|
||||
{IL_EDITOR_INDENT, "ed.indent"},
|
||||
{IL_EDITOR_ITALIC, "ed.italic"},
|
||||
{IL_EDITOR_LEFT, "ed_left"},
|
||||
{IL_EDITOR_LINK, "ed_link"},
|
||||
{IL_EDITOR_NUMBER, "ed_number"},
|
||||
{IL_EDITOR_OUTDENT, "ed_outdent"},
|
||||
{IL_EDITOR_PROPS, "ed_props"},
|
||||
{IL_EDITOR_RIGHT, "ed_right"},
|
||||
{IL_EDITOR_SHRINK, "ed_shrink"},
|
||||
{IL_EDITOR_SHRINK_GREY, "ed_shrink.i"},
|
||||
{IL_EDITOR_TARGET, "ed_target"},
|
||||
{IL_EDITOR_TABLE, "ed_table"},
|
||||
#endif
|
||||
{IL_EDIT_UNSUPPORTED_TAG, "ed_tag"},
|
||||
{IL_EDIT_UNSUPPORTED_END_TAG, "ed_tage"},
|
||||
{IL_EDIT_FORM_ELEMENT, "ed_form"},
|
||||
{IL_EDIT_NAMED_ANCHOR, "ed_target"},
|
||||
{IL_SA_SIGNED, "A_Signed"},
|
||||
{IL_SA_ENCRYPTED, "A_Encrypt"},
|
||||
{IL_SA_NONENCRYPTED, "A_NoEncrypt"},
|
||||
{IL_SA_SIGNED_BAD, "A_SignBad"},
|
||||
{IL_SA_ENCRYPTED_BAD, "A_EncrypBad"},
|
||||
{IL_SMIME_ATTACHED, "M_Attach"},
|
||||
{IL_SMIME_SIGNED, "M_Signed"},
|
||||
{IL_SMIME_ENCRYPTED, "M_Encrypt"},
|
||||
{IL_SMIME_ENC_SIGNED, "M_SignEncyp"},
|
||||
{IL_SMIME_SIGNED_BAD, "M_SignBad"},
|
||||
{IL_SMIME_ENCRYPTED_BAD, "M_EncrypBad"},
|
||||
{IL_SMIME_ENC_SIGNED_BAD, "M_SgnEncypBad"},
|
||||
{IL_MSG_ATTACH, "M_ToggleAttach"},
|
||||
{0, 0 }
|
||||
};
|
||||
|
||||
|
||||
|
||||
static QDict<QIconSet> * icons = 0;
|
||||
static QDict<QPixmap> * pixmaps = 0;
|
||||
|
||||
static const char *map_il_to_filename[IL_MSG_LAST+1];
|
||||
|
||||
static void clean()
|
||||
{
|
||||
delete icons;
|
||||
icons = 0;
|
||||
delete pixmaps;
|
||||
pixmaps = 0;
|
||||
}
|
||||
|
||||
|
||||
static void make()
|
||||
{
|
||||
if ( !icons ) {
|
||||
qAddPostRoutine( clean );
|
||||
icons = new QDict<QIconSet>( 129 );
|
||||
icons->setAutoDelete( TRUE );
|
||||
pixmaps = new QDict<QPixmap>( 129 );
|
||||
pixmaps->setAutoDelete( TRUE );
|
||||
int i = 0;
|
||||
while ( icon_map_vec[i].name ) {
|
||||
map_il_to_filename[icon_map_vec[i].code] = icon_map_vec[i].name;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int look( const char * name )
|
||||
{
|
||||
int i = 0;
|
||||
QString tmp;
|
||||
tmp.sprintf( "/%s.gif$", name );
|
||||
QRegExp r( tmp );
|
||||
while( embed_vec[i].size && r.match( embed_vec[i].name ) < 0 )
|
||||
i++;
|
||||
if ( embed_vec[i].size )
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int find( const char * name )
|
||||
{
|
||||
int i = look( name );
|
||||
if ( i < 0 )
|
||||
fatal( "could not find icon/movie '%s'", name );
|
||||
return i;
|
||||
}
|
||||
|
||||
static QIconSet findIconSet( const char * name )
|
||||
{
|
||||
make();
|
||||
|
||||
QIconSet * s = icons->find( name );
|
||||
if ( s )
|
||||
return *s;
|
||||
|
||||
int i = find( name );
|
||||
QPixmap pm;
|
||||
pm.loadFromData( embed_vec[i].data, embed_vec[i].size );
|
||||
s = new QIconSet( pm, QIconSet::Large );
|
||||
|
||||
// .i
|
||||
QString add;
|
||||
add = name;
|
||||
add += ".i";
|
||||
i = find( add );
|
||||
pm.loadFromData( embed_vec[i].data, embed_vec[i].size );
|
||||
s->setPixmap( pm, QIconSet::Large, QIconSet::Disabled );
|
||||
|
||||
// .mo
|
||||
add = name;
|
||||
add += ".mo";
|
||||
i = find( add );
|
||||
pm.loadFromData( embed_vec[i].data, embed_vec[i].size );
|
||||
s->setPixmap( pm, QIconSet::Large, QIconSet::Active );
|
||||
|
||||
icons->insert( name, s );
|
||||
return *s;
|
||||
}
|
||||
|
||||
|
||||
Icon::Icon( const char * name )
|
||||
: QIconSet( findIconSet( name ) )
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
|
||||
static QPixmap findPixmap( const char * name )
|
||||
{
|
||||
make();
|
||||
|
||||
QPixmap * pm = pixmaps->find( name );
|
||||
if ( pm )
|
||||
return *pm;
|
||||
|
||||
int i = look( name );
|
||||
if ( i < 0 )
|
||||
i = look( "IconUnknown" );
|
||||
|
||||
|
||||
pm = new QPixmap();
|
||||
if ( i >= 0 )
|
||||
pm->loadFromData( embed_vec[i].data, embed_vec[i].size );
|
||||
else
|
||||
pm->fill( red );
|
||||
pixmaps->insert( name, pm );
|
||||
return *pm;
|
||||
}
|
||||
|
||||
static QPixmap findPixmap( int il_id )
|
||||
{
|
||||
make();
|
||||
const char *s = map_il_to_filename[il_id];
|
||||
if ( !s )
|
||||
s = "IconUnknown.gif";
|
||||
return findPixmap( s );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Pixmap::Pixmap( const char * name )
|
||||
: QPixmap( findPixmap( name ) )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Pixmap::Pixmap( int il_id )
|
||||
: QPixmap( findPixmap( il_id ) )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static QByteArray * findMovie( const char * name )
|
||||
{
|
||||
int i = find( name );
|
||||
QByteArray * a = new QByteArray();
|
||||
a->setRawData( (const char *)(embed_vec[i].data), embed_vec[i].size );
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
Movie::Movie( const char * name )
|
||||
: QMovie( *findMovie( name ) )
|
||||
{
|
||||
// nothing
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/* $Id: icons.h,v 1.1 1998-09-25 18:01:34 ramiro%netscape.com Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Arnt
|
||||
* Gulbrandsen. Further developed by Warwick Allison, Kalle Dalheimer,
|
||||
* Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard Nord and
|
||||
* Paul Olav Tvete. Copyright (C) 1998 Warwick Allison, Kalle
|
||||
* Dalheimer, Eirik Eng, Matthias Ettrich, Arnt Gulbrandsen, Haavard
|
||||
* Nord and Paul Olav Tvete. All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef ICONS_H
|
||||
#define ICONS_H
|
||||
|
||||
#include <qiconset.h>
|
||||
#include <qmovie.h>
|
||||
|
||||
|
||||
class Icon: public QIconSet
|
||||
{
|
||||
public:
|
||||
Icon( const char * );
|
||||
};
|
||||
|
||||
|
||||
class Pixmap: public QPixmap
|
||||
{
|
||||
public:
|
||||
Pixmap( const char * );
|
||||
Pixmap( int ); //jint???
|
||||
};
|
||||
|
||||
|
||||
class Movie: public QMovie
|
||||
{
|
||||
public:
|
||||
Movie( const char * );
|
||||
};
|
||||
|
||||
#endif
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче