summaryrefslogtreecommitdiff
path: root/library/fileselector.cpp
Side-by-side diff
Diffstat (limited to 'library/fileselector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/fileselector.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/library/fileselector.cpp b/library/fileselector.cpp
index 382012f..7ff09b4 100644
--- a/library/fileselector.cpp
+++ b/library/fileselector.cpp
@@ -275,96 +275,97 @@ public:
If \a newVisible is TRUE, the widget has a button to allow the user
the create "new" documents; this is useful for applications that can
create and edit documents but not suitable for applications that
only provide viewing.
\a closeVisible is deprecated
\sa DocLnkSet::DocLnkSet()
*/
FileSelector::FileSelector( const QString &f, QWidget *parent, const char *name, bool newVisible, bool closeVisible )
: QVBox( parent, name ), filter( f )
{
setMargin( 0 );
setSpacing( 0 );
d = new FileSelectorPrivate();
d->newDocItem = 0;
d->showNew = newVisible;
d->catId = -2; // All files
d->toolbar = new QHBox( this );
d->toolbar->setBackgroundMode( PaletteButton ); // same colour as toolbars
d->toolbar->setSpacing( 0 );
d->toolbar->hide();
QWidget *spacer = new QWidget( d->toolbar );
spacer->setBackgroundMode( PaletteButton );
QToolButton *tb = new QToolButton( d->toolbar );
tb->setPixmap( Resource::loadPixmap( "close" ) );
connect( tb, SIGNAL( clicked() ), this, SIGNAL( closeMe() ) );
buttonClose = tb;
tb->setFixedSize( 18, 20 ); // tb->sizeHint() );
tb->setAutoRaise( TRUE );
QToolTip::add( tb, tr( "Close the File Selector" ) );
QPEMenuToolFocusManager::manager()->addWidget( tb );
view = new FileSelectorView( this, "fileview" );
QPEApplication::setStylusOperation( view->viewport(), QPEApplication::RightOnHold );
connect( view, SIGNAL( mouseButtonClicked( int, QListViewItem *, const QPoint &, int ) ),
this, SLOT( fileClicked( int, QListViewItem *, const QPoint &, int ) ) );
connect( view, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint &, int ) ),
this, SLOT( filePressed( int, QListViewItem *, const QPoint &, int ) ) );
connect( view, SIGNAL( returnPressed( QListViewItem * ) ),
this, SLOT( fileClicked( QListViewItem * ) ) );
QHBox *hb = new QHBox( this );
+
d->typeCombo = new TypeCombo( hb );
connect( d->typeCombo, SIGNAL(selected(const QString&)),
this, SLOT(typeSelected(const QString&)) );
QWhatsThis::add( d->typeCombo, tr("Show documents of this type") );
Categories c;
c.load(categoryFileName());
QArray<int> vl( 0 );
d->catSelect = new CategorySelect( hb );
d->catSelect->setRemoveCategoryEdit( TRUE );
d->catSelect->setCategories( vl, "Document View", tr("Document View") );
d->catSelect->setAllCategories( TRUE );
connect( d->catSelect, SIGNAL(signalSelected(int)), this, SLOT(catSelected(int)) );
QWhatsThis::add( d->catSelect, tr("Show documents in this category") );
setCloseVisible( closeVisible );
QCopChannel *channel = new QCopChannel( "QPE/Card", this );
connect( channel, SIGNAL(received(const QCString &, const QByteArray &)),
this, SLOT(cardMessage( const QCString &, const QByteArray &)) );
reread();
updateWhatsThis();
}
/*!
Destroys the widget.
*/
FileSelector::~FileSelector()
{
delete d;
}
/*!
Returns the number of files in the view. If this is zero, an editor
application might bypass the selector and immediately start with
a "new" document.
*/
int FileSelector::fileCount()
{
return d->files.children().count();;
}
/*!
Calling this function is the programmatic equivalent of the user
pressing the "new" button.
\sa newSelected(), closeMe()
@@ -451,96 +452,115 @@ const DocLnk *FileSelector::selected()
\a f is the document.
*/
/*!
\fn void FileSelector::newSelected( const DocLnk &f )
This signal is emitted when the user selects a "new" document.
\a f is a DocLnk for the document. You will need to set the type
of the document after copying it.
*/
/*!
\fn void FileSelector::closeMe()
This signal is emitted when the user no longer needs to view the widget.
*/
/*!
If \a b is TRUE a "new document" entry is visible; if \a b is FALSE
this entry is not visible and the user is unable to create new
documents from the dialog.
*/
void FileSelector::setNewVisible( bool b )
{
if ( d->showNew != b ) {
d->showNew = b;
updateView();
updateWhatsThis();
}
}
/*!
If \a b is TRUE a "close" or "no document" button is visible; if \a
b is FALSE this button is not visible and the user is unable to
leave the dialog without creating or selecting a document.
This function is deprecated.
*/
void FileSelector::setCloseVisible( bool b )
{
if ( b )
d->toolbar->show();
else
d->toolbar->hide();
}
/*!
+
+*/
+void FileSelector::setTypeComboVisible( bool b ) {
+ if ( b )
+ d->typeCombo->show();
+ else
+ d->typeCombo->hide();
+}
+/*!
+
+*/
+void FileSelector::setCategorySelectVisible( bool b ) {
+ if ( b )
+ d->catSelect->show();
+ else
+ d->catSelect->hide();
+}
+
+/*!
Rereads the list of documents.
*/
void FileSelector::reread()
{
d->files.clear();
Global::findDocuments(&d->files, filter);
d->typeCombo->reread( d->files, filter );
updateView();
}
void FileSelector::updateView()
{
FileSelectorItem *item = (FileSelectorItem *)view->selectedItem();
if ( item == d->newDocItem )
item = 0;
QString oldFile;
if ( item )
oldFile = item->file().file();
view->clear();
QListIterator<DocLnk> dit( d->files.children() );
for ( ; dit.current(); ++dit ) {
bool mimeMatch = FALSE;
if ( d->mimeFilters.count() ) {
QValueList<QRegExp>::Iterator it;
for ( it = d->mimeFilters.begin(); it != d->mimeFilters.end(); ++it ) {
if ( (*it).match((*dit)->type()) >= 0 ) {
mimeMatch = TRUE;
break;
}
}
} else {
mimeMatch = TRUE;
}
if ( mimeMatch &&
(d->catId == -2 || (*dit)->categories().contains(d->catId) ||
(d->catId == -1 && (*dit)->categories().isEmpty())) ) {
item = new FileSelectorItem( view, **dit );
if ( item->file().file() == oldFile )
view->setCurrentItem( item );
}
}
if ( d->showNew )
d->newDocItem = new NewDocItem( view, DocLnk() );
else
d->newDocItem = 0;
if ( !view->selectedItem() || view->childCount() == 1 ) {