Ejemplo n.º 1
0
void QDirEdit::acceptFiles(bool files, bool write) {
	_files = files;
	_writeFile = write;
	QDirModel* dirModel = qobject_cast<QDirModel*>(completer()->model());
	Q_ASSERT(dirModel);
	if (_files)
		dirModel->setFilter(
				QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
	else
		dirModel->setFilter(
				QDir::AllDirs               | QDir::NoDotAndDotDot);
}
Ejemplo n.º 2
0
void tst_QDirModel::task196768_sorting()
{
    //this task showed that the persistent model indexes got corrupted when sorting
    QString path = SRCDIR;

    QDirModel model;

    /* QDirModel has a bug if we show the content of the subdirectory inside a hidden directory
       and we don't add QDir::Hidden. But as QDirModel is deprecated, we decided not to fix it. */
    model.setFilter(QDir::AllEntries | QDir::Hidden | QDir::AllDirs);

    QTreeView view;
    QPersistentModelIndex index = model.index(path);
    view.setModel(&model);
    QModelIndex index2 = model.index(path);
    QCOMPARE(index.data(), index2.data());
    view.setRootIndex(index);
    index2 = model.index(path);
    QCOMPARE(index.data(), index2.data());
    view.setCurrentIndex(index);
    index2 = model.index(path);
    QCOMPARE(index.data(), index2.data());
    view.setSortingEnabled(true);
    index2 = model.index(path);

    QCOMPARE(index.data(), index2.data());
}
void AnnotationImagePaletteWidget::addPalette(const QString& path)
{
   QListView* pPalette = new QListView(this);
   pPalette->setWrapping(true);
   pPalette->setLayoutMode(QListView::Batched);
   pPalette->setBatchSize(10);
   pPalette->setMovement(QListView::Static);
   pPalette->setFlow(QListView::LeftToRight);
   pPalette->setIconSize(QSize(32, 32));
   pPalette->setViewMode(QListView::IconMode);
   pPalette->setDragEnabled(true);
   pPalette->setDragDropMode(QAbstractItemView::DragOnly);
   pPalette->setSelectionMode(QAbstractItemView::SingleSelection);
   pPalette->setResizeMode(QListView::Adjust);

   if (QFileInfo(path).isDir())
   {
      QDirModel* pModel = new PaletteModel(this);
      pModel->setFilter(QDir::Files | QDir::Readable);
      QStringList formats;
      QList<QByteArray> rawFormats = QImageReader::supportedImageFormats();
      foreach (const QByteArray& rawFormat, rawFormats)
      {
         formats << "*." + QString(rawFormat);
      }
QMathMLFileViewer::QMathMLFileViewer( QWidget *parent )
    : QDockWidget( tr("MathML Documents Explorer"), parent )
{
	m_iconSize = QSize(16, 16);
	m_isRecursiveSearch = true;

	m_currentDir.setPath( QDir::currentPath() );

	directoryComboBox = createComboBox( m_currentDir.absolutePath() );
	directoryComboBox->setMinimumWidth(150);
	QDirModel *dirModelCompleter = new QDirModel(this);
	dirModelCompleter->setFilter( QDir::AllDirs/*QDir::Dirs*/ );
	QCompleter *completer = new QCompleter( this );
    completer->setModel( dirModelCompleter );
    directoryComboBox->setCompleter( completer );
	connect(directoryComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(changeDir(const QString&)));

	QToolButton *btnBrowse = new QToolButton();
	btnBrowse->setIcon(QIcon(":/images/folderopen.png"));
	//btnBrowse->setIconSize( m_iconSize );
	btnBrowse->setToolTip(tr("Select a new folder"));
	connect(btnBrowse, SIGNAL(clicked()), this, SLOT(browse()));

	QToolButton *btnBrowseUp = new QToolButton();
	btnBrowseUp->setIcon(QIcon(":/images/up.png"));
	//btnBrowseUp->setIconSize( m_iconSize );
	btnBrowseUp->setToolTip(tr("Navagate one level up"));
	connect(btnBrowseUp, SIGNAL(clicked()), this, SLOT(browseUp()));

	QHBoxLayout *dirLayout = new QHBoxLayout();
	dirLayout->addWidget(directoryComboBox);
	dirLayout->addWidget(btnBrowseUp);
	dirLayout->addWidget(btnBrowse);
	dirLayout->addStretch(1);

	createFilesTree();
	createFilesTable();
	foundMessage = new QLabel(tr("No search results"));

	QHBoxLayout *toolLayout = setupToolLayout();
    QVBoxLayout *mainLayout = new QVBoxLayout();
    mainLayout->addLayout(toolLayout);
    mainLayout->addLayout(dirLayout);
    mainLayout->addWidget(m_dirTree);
    mainLayout->addWidget(filesTable);
	mainLayout->addWidget(foundMessage);

	QDialog *centralDlg = new QDialog();
	centralDlg->setModal( false );
	centralDlg->setLayout( mainLayout );
	setWidget( centralDlg );
}
QTreeView *StManagerStudyListComp::createDirectoryTreeView ()
{
  QTreeView *directoryTree = new QTreeView;

  QDirModel *model = new QDirModel();
  model->setFilter( QDir::Dirs | QDir::NoDotAndDotDot | QDir::Drives );

  directoryTree->setModel( model );
  directoryTree->setColumnWidth( 0, 150 );
  // hide size and type in filesystem tree view
  directoryTree->setColumnHidden( 1, true );
  directoryTree->setColumnHidden( 2, true );

  return directoryTree;
}
Ejemplo n.º 6
0
ExportForm::ExportForm(QWidget* parent, ScribusDoc* doc, int size, int quality, QString type)
	: QDialog(parent, 0), m_doc(doc), m_PageCount(doc->DocPages.count())
{
	setupUi(this);
	setModal(true);
	prefs = PrefsManager::instance()->prefsFile->getPluginContext("pixmapexport");

	QDirModel * dirModel = new QDirModel(this);
	dirModel->setFilter(QDir::AllDirs);
	outputDirectory->setCompleter(new QCompleter(dirModel, this));
	
	outputDirectory->setText( QDir::convertSeparators(prefs->get("wdir", QDir::currentPath())) );
	QList<QByteArray> imgs = QImageWriter::supportedImageFormats();
	for (int a = 0; a < imgs.count(); a++)
	{
		bitmapType->addItem(imgs[a]);
	}
	setCurrentComboItem(bitmapType, type.toLower());
	qualityBox->setValue(quality);
	qualityBox->setWrapping(true);
	
	DPIBox->setValue(size);
	enlargementBox->setValue(size);
	onePageRadio->setChecked( true );
 	pageNrButton->setIcon(loadIcon("ellipsis.png"));
	rangeVal->setEnabled(false);
	pageNrButton->setEnabled(false);

	languageChange();
	readConfig();
	computeSize();
	
	connect(outputDirectoryButton, SIGNAL(clicked()), this, SLOT(OutputDirectoryButton_pressed()));
	connect(intervalPagesRadio, SIGNAL(clicked()), this, SLOT(IntervalPagesRadio_stateChanged()));
	connect(allPagesRadio, SIGNAL(clicked()), this, SLOT(AllPagesRadio_stateChanged()));
	connect(onePageRadio, SIGNAL(clicked()), this, SLOT(OnePageRadio_stateChanged()));
	connect(enlargementBox, SIGNAL(valueChanged(int)), this, SLOT(computeSize()));
	connect(DPIBox, SIGNAL(valueChanged(int)), this, SLOT(computeSize()));
	connect(pageNrButton, SIGNAL(clicked()), this, SLOT(createPageNumberRange()));
}