Exemplo n.º 1
0
void TupItemManager::createFolder(const QString &name)
{
    if (name.isNull())
        folderName = tr("New folder %1").arg(foldersTotal);
    else
        folderName = name;

    QTreeWidgetItem *newFolder = new QTreeWidgetItem(this);
    newFolder->setFlags(newFolder->flags() | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
    newFolder->setIcon(0, QIcon(THEME_DIR + "icons/open.png"));
    newFolder->setText(1, folderName);
    newFolder->setText(2, "");

    newFolder->setFlags(newFolder->flags() | Qt::ItemIsEditable);

    foldersTotal++;

    m_currentFolder = newFolder;
    setCurrentItem(m_currentFolder);

    if (name.isNull()) {
        editItem(m_currentFolder, 1);
        emit itemCreated(newFolder);
    } 
}
Exemplo n.º 2
0
void KIOPasteTest::testPasteJob()
{
    QFETCH(QList<QUrl>, urls);
    QFETCH(bool, data);
    QFETCH(bool, cut);
    QFETCH(QString, expectedFileName);

    QMimeData mimeData;
    bool isDir = false;
    bool isFile = false;
    if (!urls.isEmpty()) {
        mimeData.setUrls(urls);
        QFileInfo fileInfo(urls.first().toLocalFile());
        isDir = fileInfo.isDir();
        isFile = fileInfo.isFile();
    }
    if (data) {
        mimeData.setText(QStringLiteral("Hello world"));
    }
    KIO::setClipboardDataCut(&mimeData, cut);

    QTemporaryDir destTempDir;
    QVERIFY(destTempDir.isValid());
    const QString destDir = destTempDir.path();
    KIO::Job *job = KIO::paste(&mimeData, QUrl::fromLocalFile(destDir), KIO::HideProgressInfo);
    QSignalSpy spy(job, SIGNAL(itemCreated(QUrl)));
    QVERIFY(spy.isValid());
    job->setUiDelegate(0);
    const bool expectedSuccess = !expectedFileName.isEmpty();
    QCOMPARE(job->exec(), expectedSuccess);
    if (expectedSuccess) {
        const QString destFile = destDir + '/' + expectedFileName;
        QVERIFY2(QFile::exists(destFile), qPrintable(expectedFileName));
        if (isDir) {
            QVERIFY(QFileInfo(destFile).isDir());
        } else {
            QVERIFY(QFileInfo(destFile).isFile());
            QFile file(destFile);
            QVERIFY(file.open(QIODevice::ReadOnly));
            QCOMPARE(QString(file.readAll()), QString("Hello world"));
        }
        if (cut) {
            QVERIFY(!QFile::exists(urls.first().toLocalFile()));
        } else {
            QVERIFY(QFile::exists(urls.first().toLocalFile()));
        }
        QCOMPARE(spy.count(), isFile || cut ? 1 : 2);
        QCOMPARE(spy.at(0).at(0).value<QUrl>().toLocalFile(), destFile);
    }
}
bool TreeView::qt_emit( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->signalOffset() ) {
    case 0: treeItemActivatedA((QPtrList<TreeViewItem>&)*((QPtrList<TreeViewItem>*)static_QUType_ptr.get(_o+1)),(unsigned int)(*((unsigned int*)static_QUType_ptr.get(_o+2)))); break;
    case 1: treeItemActivatedB((QPtrList<TreeViewItem>&)*((QPtrList<TreeViewItem>*)static_QUType_ptr.get(_o+1)),(unsigned int)(*((unsigned int*)static_QUType_ptr.get(_o+2)))); break;
    case 2: itemCreated((TreeViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 3: itemDeleteLater((TreeViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 4: itemPropChanged((TreeViewItem*)static_QUType_ptr.get(_o+1),(const QString&)static_QUType_QString.get(_o+2)); break;
    case 5: databaseItemCreated((DatabaseItem*)static_QUType_ptr.get(_o+1)); break;
    case 6: tableItemCreated((TableItem*)static_QUType_ptr.get(_o+1)); break;
    default:
	return QListView::qt_emit(_id,_o);
    }
    return TRUE;
}
Exemplo n.º 4
0
void EMainWindow::disconnectControls(EPainting *painting)
{
	if (!painting) return;
	Q_CHECK_PTR(painting);

	_objCreateGroup->setEnabled(false);

	QAction *openFileAction = _mainUi.actionOpen;
	QAction *saveFileAction = _mainUi.actionSave;
	QAction *exportAction = _mainUi.actionExport;

	// Соединения от MainWindow к EPainting
	Q_ASSERT(disconnect(openFileAction, SIGNAL(triggered()), painting, SLOT(openFile())));
	Q_ASSERT(disconnect(saveFileAction, SIGNAL(triggered()), painting, SLOT(saveFile())));
	Q_ASSERT(disconnect(exportAction, SIGNAL(triggered()), painting, SLOT(exportToSVG())));

	// Соединения от EPainting к MainWindow
	Q_ASSERT(disconnect(painting, SIGNAL(itemCreated()), this, SLOT(setSelectTool())));			//	сигнал перехода в режим "выбрать объект"
	Q_ASSERT(disconnect(painting, SIGNAL(nameChanged(QString)), this, SLOT(setCurrentTabName(QString))));
}