Beispiel #1
0
// Add a new tag to the tree
void NTagView::addRequested() {
    TagProperties dialog;
    QList<QTreeWidgetItem*> items = selectedItems();

    dialog.setLid(0);

    dialog.exec();
    if (!dialog.okPressed)
        return;

    TagTable table(global.db);
    NTagViewItem *newWidget = new NTagViewItem();
    QString name = dialog.name.text().trimmed();
    qint32 lid = table.findByName(name, accountFilter);
    newWidget->setData(NAME_POSITION, Qt::DisplayRole, name);
    newWidget->setData(NAME_POSITION, Qt::UserRole, lid);
    root->addChild(newWidget);
    this->sortItems(NAME_POSITION, Qt::AscendingOrder);
    resetSize();
    this->sortByColumn(NAME_POSITION);

    // Now add it to the datastore
    dataStore.insert(lid, newWidget);
    emit(tagAdded(lid));
}
Beispiel #2
0
Client::Client(ContactModel *contactModel, QObject *parent) :
QObject(parent),m_trackInterval(5),
m_authentificated(0), m_trackingPermitted(Settings::getInstance().getPermission()),
m_isHavingOwnChannel(true), m_contactModel(contactModel)
{
  m_timer = new QTimer(this);
  connect(m_timer, SIGNAL(timeout()), SLOT(track()));

  m_additionalTimer = new QTimer(this);
  connect(m_additionalTimer, SIGNAL(timeout()),SLOT(getTagsRequest()));

  m_loginQuery = new LoginQuery(this);
  connect(m_loginQuery, SIGNAL(connected()), SLOT(onAuthentificated()));
  connect(m_loginQuery, SIGNAL(errorOccured(QString)), SLOT(onError(QString)));
  connect(m_loginQuery, SIGNAL(errorOccured(int)),SLOT(onError(int)));

  m_RegisterUserQuery = new RegisterUserQuery(this);
  connect(m_RegisterUserQuery, SIGNAL(connected()), SLOT(onRegistered()));
  connect(m_RegisterUserQuery, SIGNAL(errorOccured(int)),SLOT(onError(int)));

  m_netManager = new QNetworkConfigurationManager(this);

  m_history = new MarksHistory(this);
  connect(m_history,SIGNAL(isFull()),SLOT(onHistoryFull()));
  m_history->setHistoryLimit(Settings::getInstance().getTimeInterval()/m_trackInterval);

  m_addNewMarkQuery = new WriteTagQuery(this);
  connect(m_addNewMarkQuery,SIGNAL(tagAdded()),SLOT(onMarkAdded()));
  //  connect(m_addNewMarkQuery, SIGNAL(errorOccured(QString)), SIGNAL(error(QString)));

  m_applyChannelQuery = new ApplyChannelQuery(this);
  connect(m_applyChannelQuery, SIGNAL(channelAdded(QSharedPointer<Channel>)),SLOT(subscribeToOwnChannel()));
  connect(m_applyChannelQuery, SIGNAL(errorOccured(int)), SLOT(onError(int)));

  m_subscribeChannelQuery = new SubscribeChannelQuery(this);
  connect(m_subscribeChannelQuery,SIGNAL(channelSubscribed(QSharedPointer<Channel>)),SLOT(onChannelSubscribed(QSharedPointer<Channel>)));
  connect(m_subscribeChannelQuery, SIGNAL(errorOccured(int)), SLOT(onError(int)));

  m_subscibedChannelsQuery = new SubscribedChannelsQuery(this);
  //connect(m_subscibedChannelsQuery,SIGNAL(responseReceived()),SLOT(constructContactModel()));
  connect(m_subscibedChannelsQuery,SIGNAL(errorOccured(int)), SLOT(onError(int)));

  m_loadTagsQuery = new LoadTagsQuery(this);
  connect(m_loadTagsQuery, SIGNAL(tagsReceived()), SLOT(onGetTags()));
  connect(m_loadTagsQuery,SIGNAL(errorOccured(int)), SLOT(onError(int)));

  m_unsubscribeChannelQuery = new UnsubscribeChannelQuery(this);
  connect(m_unsubscribeChannelQuery, SIGNAL(channelUnsubscribed()),SLOT(onChannelUnsubscribed()));
  connect(m_unsubscribeChannelQuery,SIGNAL(errorOccured(int)), SLOT(onError(int)));

  qDebug()<<Settings::getInstance().getLogin();
  qDebug()<<Settings::getInstance().getPassword();

  if (Settings::getInstance().isHavingAuthData())
    auth(Settings::getInstance().getLogin(),Settings::getInstance().getPassword());

}
Beispiel #3
0
void TagListWidget::newTagRequested()
{
    QString tag = QInputDialog::getText(this, tr("New Label"), tr("Label name:"));
    if (tag.isEmpty()) {
        return;
    }
    if (m_ignoredFlags.contains(tag.toLower())) {
        QMessageBox::warning(this, tr("Invalid tag value"),
                             tr("Tag name %1 is a reserved name which cannot be manipulated this way.").arg(tag));
        return;
    }

    emit tagAdded(tag);
}
TagsFilterModel::TagsFilterModel(TagFilter* filter, QObject* parent) :
    ListFilterModel(parent),
    filter_(filter)
{
    connect(filter_,
            SIGNAL(tagAdded(QString,TagFilter::Action)),
            SLOT(updateFilter()));

    connect(filter_,
            SIGNAL(tagRemoved(QString)),
            SLOT(updateFilter()));

    connect(filter_,
            SIGNAL(filterEmpty()),
            SLOT(updateFilter()));
}
Beispiel #5
0
void GeneratorDaemon::onConnected()
{
  m_isConnected = true;
  if(m_tagQuery == NULL)
  {
    QSharedPointer<DataMark> mark(new JsonDataMark(0,0,0,"part of route "+m_channelName,
      "generated by generator:)","unknown",QDateTime::currentDateTime()));
    QSharedPointer<Channel> channel(new JsonChannel(m_channelName,"dummy channel"));
    mark->setChannel(channel);
    mark->setUser(m_loginQuery->getUser());
    qDebug() << "try to create WriteTagQuery";
    m_tagQuery = new WriteTagQuery(mark,this);
    qDebug() << m_tagQuery;
    connect(m_tagQuery, SIGNAL(tagAdded()), SLOT(onTagAdded()));
    connect(m_tagQuery, SIGNAL(errorOccured(QString)), SLOT(onError(QString)));
  }
}
// Disabled because Baloo does not work like Nepomuk: it does not create tags
// independently of files.
void SemanticInfoBackEndTest::testTagForLabel()
{
    QSignalSpy spy(mBackEnd, SIGNAL(tagAdded(SemanticInfoTag,QString)));

    TagSet oldAllTags = mBackEnd->allTags();
    QString label = "testTagForLabel-" + KRandom::randomString(5);
    SemanticInfoTag tag1 = mBackEnd->tagForLabel(label);
    QVERIFY(!tag1.isEmpty());
    QVERIFY(!oldAllTags.contains(tag1));
    QVERIFY(mBackEnd->allTags().contains(tag1));

    // This is a new tag, we should receive a signal
    QCOMPARE(spy.count(), 1);

    SemanticInfoTag tag2 = mBackEnd->tagForLabel(label);
    QCOMPARE(tag1, tag2);
    // This is not a new tag, we should not receive a signal
    QCOMPARE(spy.count(), 1);

    QString label2 = mBackEnd->labelForTag(tag2);
    QCOMPARE(label, label2);
}
Beispiel #7
0
void TrackingService::startTracking(QString name, QString password, QString authToken, QString serverUrl)
{
    qDebug() << "startTracking url: " << serverUrl;

    m_period = m_settings.getTrackingPeriod() * 60;

    if (m_writeTagQuery != 0)
        m_writeTagQuery->deleteLater();

    m_writeTagQuery = new WriteTagQuery(this);
    m_writeTagQuery->setTag(m_dataMark);
    connect(m_writeTagQuery, SIGNAL(tagAdded()), this, SLOT(onMarkSent()));
    connect(m_writeTagQuery, SIGNAL(errorOccured(QString)), this, SLOT(onError(QString)));

    m_user = QSharedPointer<JsonUser>(new JsonUser(name, password, authToken));
    m_channel = QSharedPointer<Channel>(new Channel(name, name + "'s channel", ""));
    m_dataMark->setUser(m_user);
    m_dataMark->setChannel(m_channel);
    m_writeTagQuery->setUrl(serverUrl);

    sendMark();
}
TagFilterWidget::TagFilterWidget(TagFilter* filter, QWidget* parent) :
	QWidget(parent),
	filter_(filter),
	rows_(1)
{
	int fontHeight = qMin(fontMetrics().height(), 24);
	baseSize_ = fontHeight + 8;
	setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
	resize(100, baseSize_);

	resetButton_ = new QToolButton(this);
	resetButton_->setToolTip("Reset");
	resetButton_->setIcon(QIcon(":/close-8.png"));
	resetButton_->setAutoRaise(true);

	connect(resetButton_,
			SIGNAL(clicked(bool)),
			filter_,
			SLOT(reset()));

	connect(filter_,
			SIGNAL(tagAdded(QString,TagFilter::Action)),
			SLOT(onTagAdded(QString,TagFilter::Action)));

	connect(filter_,
			SIGNAL(tagChanged(QString,TagFilter::Action)),
			SLOT(onTagChanged(QString,TagFilter::Action)));

	connect(filter_,
			SIGNAL(tagRemoved(QString)),
			SLOT(onTagRemoved(QString)));

	connect(filter_,
			SIGNAL(filterEmpty()),
			SLOT(onFilterEmpty()));

	updateLayout();
}
Beispiel #9
0
void SearchForm::setupUi()
{
	storageModel_ = qApp->recordsModel();

	tagFilter_ = new TagFilter(this);

	connect(tagFilter_,
			SIGNAL(tagAdded(QString,TagFilter::Action)),
			SLOT(handleFilterTagAdded()));

	connect(tagFilter_,
			SIGNAL(filterEmpty()),
			SLOT(handleFilterEmpty()));

	tagsFilterModel_ = new TagsFilterModel(tagFilter_);
	tagsFilterModel_->setSourceModel(storageModel_);
	tagsFilterModel_->setRootIndex(storageModel_->index(RecordsModel::kTagsRoot, 0));

	tagsSortModel_ = new ListSortModel;
	tagsSortModel_->setSourceModel(tagsFilterModel_);

	recordsFilterModel_ = new RecordsFilterModel(tagFilter_);
	recordsFilterModel_->setSourceModel(storageModel_);

	recordsFilterModel_->setRootIndex(
				storageModel_->index(RecordsModel::kRecordsRoot, 0));

	recordsSortModel_ = new ListSortModel;
	recordsSortModel_->setSourceModel(recordsFilterModel_);

	createRecordButton_ = new QToolButton;
	createRecordButton_->setIcon(QIcon(":/create_record-32.png"));
	createRecordButton_->setIconSize(QSize(20, 20));
	createRecordButton_->setToolTip(tr("Create new record"));
	createRecordButton_->setFocusPolicy(Qt::NoFocus);
	createRecordButton_->setAutoRaise(true);

	connect(createRecordButton_,
			SIGNAL(clicked(bool)),
			SIGNAL(recordCreated()));

	openRecordButton_ = new QToolButton;
	openRecordButton_->setIcon(QIcon(":/edit-32.png"));
	openRecordButton_->setIconSize(QSize(20, 20));
	openRecordButton_->setToolTip(tr("Open selected record"));
	openRecordButton_->setFocusPolicy(Qt::NoFocus);
	openRecordButton_->setAutoRaise(true);

	connect(openRecordButton_,
			SIGNAL(clicked(bool)),
			SLOT(handleRecordOpen()));

	removeRecordButton_ = new QToolButton;
	removeRecordButton_->setIcon(QIcon(":/delete-32.png"));
	removeRecordButton_->setIconSize(QSize(20, 20));
	removeRecordButton_->setToolTip(tr("Delete selected record"));
	removeRecordButton_->setFocusPolicy(Qt::NoFocus);
	removeRecordButton_->setAutoRaise(true);

	exportButton_ = new QToolButton;
	exportButton_->setIcon(QIcon(":/export-32.png"));
	exportButton_->setIconSize(QSize(20, 20));
	exportButton_->setToolTip(tr("Export records to file"));
	exportButton_->setFocusPolicy(Qt::NoFocus);
	exportButton_->setAutoRaise(true);

	importButton_ = new QToolButton;
	importButton_->setIcon(QIcon(":/import-32.png"));
	importButton_->setIconSize(QSize(20, 20));
	importButton_->setToolTip(tr("Import records from file"));
	importButton_->setFocusPolicy(Qt::NoFocus);
	importButton_->setAutoRaise(true);

	toggleFilterButton_ = new QToolButton;
	toggleFilterButton_->setIcon(QIcon(":/unite-20.png"));
	toggleFilterButton_->setIconSize(QSize(20, 20));
	toggleFilterButton_->setToolTip(tr("Toggle tag filter mode (unite / intersect)"));
	toggleFilterButton_->setFocusPolicy(Qt::NoFocus);
	toggleFilterButton_->setAutoRaise(true);

	connect(toggleFilterButton_,
			SIGNAL(clicked(bool)),
			SLOT(toggleFilterMode()));

	QFrame* separator1 = new QFrame;
	separator1->setFrameShape(QFrame::VLine);
	separator1->setFixedWidth(10);

	QFrame* separator2 = new QFrame;
	separator2->setFrameShape(QFrame::VLine);
	separator2->setFixedWidth(10);

	QFrame* separator3 = new QFrame;
	separator3->setFrameShape(QFrame::VLine);
	separator3->setFixedWidth(10);

	QLabel* label = new QLabel("Filter: ");

	searchEdit_ = new LineEdit;
	searchEdit_->setMinimumHeight(22);
	searchEdit_->setPlaceholderText("Enter search terms here...");
	searchEdit_->setButtonEnabled(true);
	searchEdit_->setButtonStyle(LineEdit::kAutoRaise);
	searchEdit_->setButtonToolTip("Clear");
	searchEdit_->setButtonIcon(QIcon(":/close-8.png"));
	searchEdit_->setIcon(QIcon(":/search-32.png"));

	QHBoxLayout* toolbarLayout = new QHBoxLayout;
	toolbarLayout->setContentsMargins(1, 0, 1, 0);
	toolbarLayout->setSpacing(1);
	toolbarLayout->addWidget(createRecordButton_);
	toolbarLayout->addWidget(openRecordButton_);
	toolbarLayout->addWidget(removeRecordButton_);
	toolbarLayout->addWidget(separator1);
	toolbarLayout->addWidget(exportButton_);
	toolbarLayout->addWidget(importButton_);
	toolbarLayout->addWidget(separator2);
	toolbarLayout->addWidget(toggleFilterButton_);
	toolbarLayout->addWidget(separator3);
	toolbarLayout->addWidget(label);
	toolbarLayout->addWidget(searchEdit_);

	tagFilterWidget_ = new TagFilterWidget(tagFilter_);

	filterFrame_ = new AnimatedFrame;
	filterFrame_->setWidget(tagFilterWidget_, true);
	filterFrame_->setEffects(AnimatedFrame::kSlide);
	filterFrame_->setEdge(AnimatedFrame::kNorth);
	filterFrame_->setAnimationDuration(150);

	tagsView_ = new TreeView;
	tagsView_->setRootIsDecorated(false);
	tagsView_->setModel(tagsSortModel_);
	tagsView_->setSortingEnabled(true);
	tagsView_->sortByColumn(0, Qt::AscendingOrder);

	connect(tagsView_,
			SIGNAL(clicked(QModelIndex,Qt::MouseButton)),
			SLOT(handleTagClick(QModelIndex,Qt::MouseButton)));

	recordsView_ = new TreeView;
	recordsView_->setRootIsDecorated(false);
	recordsView_->setModel(recordsSortModel_);
	recordsView_->setSortingEnabled(true);
	recordsView_->sortByColumn(0, Qt::AscendingOrder);
	recordsView_->setVerticalScrollMode(TreeView::ScrollPerPixel);

	QHeaderView* header = recordsView_->header();
	header->setStretchLastSection(false);
	header->setSectionResizeMode(0, QHeaderView::Stretch);
	header->setSectionResizeMode(1, QHeaderView::ResizeToContents);

	connect(recordsView_->selectionModel(),
			SIGNAL(currentChanged(QModelIndex,QModelIndex)),
			SLOT(handleRecordChanged(QModelIndex)));

	connect(recordsView_,
			SIGNAL(doubleClicked(QModelIndex)),
			SLOT(handleRecordOpen()));

	recordView_ = new QTextEdit;

	recordsSplitter_ = new QSplitter(Qt::Vertical);
	recordsSplitter_->addWidget(recordsView_);
	recordsSplitter_->addWidget(recordView_);
	int size = recordsSplitter_->width();
	recordsSplitter_->setSizes(QList<int>() << size * 0.35 << size * 0.65);

	splitter_ = new QSplitter(Qt::Horizontal);
	splitter_->addWidget(tagsView_);
	splitter_->addWidget(recordsSplitter_);
	size = splitter_->width();
	splitter_->setSizes(QList<int>() << size * 0.35 << size * 0.65);

	QVBoxLayout* layout = new QVBoxLayout;
	layout->setContentsMargins(0, 0, 0, 0);
	layout->setSpacing(4);
	layout->addLayout(toolbarLayout);
	layout->addWidget(filterFrame_);
	layout->addWidget(splitter_);

	setLayout(layout);

	handleRecordChanged(QModelIndex());
}
Beispiel #10
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    EdamProtocol *edam = EdamProtocol::GetInstance();

    ui->setupUi(this);

    pdfCache * pdf = new pdfCache(this);

    CustomNetworkAccessManager *nm = new CustomNetworkAccessManager(ui->editor->page()->networkAccessManager(), this, pdf);
    edam->setCNAM(nm);
    ui->editor->page()->setNetworkAccessManager(nm);

    Speller::setSettings(new DBSpellSettings(this, ui->editor));

    ui->editor->setContextMenuPolicy(Qt::CustomContextMenu);
    ui->editor->load(QUrl("qrc:///html/noteajax.html"));

    jsB = new jsBridge(this, pdf);
    jsB->setWebView(ui->editor);
    enmlWritter = new enml2(this);

    connect(ui->editor->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(addJSObject()));

    loaded = false;
    editingEnabled = false;


    tagsActions = new QActionGroup(this);
    newTag = new TagLabel(this);
    newTag->hide();
    ui->tagsBar->addWidget(newTag);

    appIcon = QIcon(":img/hippo64.png");

    trayIcon = NULL;

    bool sysTrayEnabled = sql::readSyncStatus("systemTray", true).toBool();

    if (QSystemTrayIcon::isSystemTrayAvailable() && sysTrayEnabled)
        enableSystemTrayIcon(true);

    connect(edam, SIGNAL(AuthenticateFailed()), this, SLOT(authentificationFailed()));
    connect(edam, SIGNAL(syncFinished()), this, SLOT(syncFinished()));
    connect(edam, SIGNAL(syncStarted(int)), this, SLOT(syncStarted(int)));
    connect(edam, SIGNAL(noteGuidChanged(QString,QString)), this, SLOT(changeNoteGuid(QString,QString)));
    connect(ui->notebooks, SIGNAL(itemSelectionChanged()), this, SLOT(switchNotebook()));
    connect(ui->tags, SIGNAL(itemSelectionChanged()), this, SLOT(switchTag()));
    connect(ui->tags, SIGNAL(tagAdded(QString,QString)), this, SLOT(addTag(QString,QString)));
    connect(ui->tags, SIGNAL(tagsUpdated()), this, SLOT(updateTagsToolBar()));
    connect(ui->tags, SIGNAL(tagsUpdated()), this, SLOT(switchTag()));
    connect(ui->NotesList, SIGNAL(noteSwitched()), this, SLOT(switchNote()));
    connect(ui->action_Abaut, SIGNAL(triggered()), this, SLOT(loadAboutInfo()));
    connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(closeWindow()));
    connect(ui->actionNew_Note, SIGNAL(triggered()), this, SLOT(newNote()));
    connect(ui->actionSync, SIGNAL(triggered()), this, SLOT(sync()));
    connect(ui->noteTitle, SIGNAL(textEdited(QString)), this, SLOT(noteTitleChange(QString)));
    connect(ui->actionAccount_info, SIGNAL(triggered()), this, SLOT(showUserInfo()));
    connect(ui->editor->page(), SIGNAL(linkClicked(QUrl)), this, SLOT(openURL(QUrl)));
    connect(ui->editor->page(), SIGNAL(microFocusChanged()), this, SLOT(updateEditButtonsState()));
    connect(ui->editor, SIGNAL(selectionChanged()), this, SLOT(updateSelectionButtonsState()));
    connect(ui->editor->page(), SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequested(QNetworkRequest)));
    connect(ui->editor, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(editorContextMenuRequested(QPoint)));
    connect(ui->editor, SIGNAL(fileInserted(QString)), this, SLOT(insertFile(QString)));
    connect(ui->notebooks, SIGNAL(noteMoved(QString,QString)), this, SLOT(moveNote(QString,QString)));
    connect(ui->notebooks, SIGNAL(noteDeleted(QString)), this, SLOT(deleteNote(QString)));
    connect(ui->notebooks, SIGNAL(noteRestored(QString,QString)), this, SLOT(restoreNote(QString,QString)));
    connect(ui->NotesList, SIGNAL(noteDeleted(QString)), this, SLOT(deleteNote(QString)));
    connect(ui->NotesList, SIGNAL(noteRestored(QString)), this, SLOT(restoreNote(QString)));
    connect(ui->NotesList, SIGNAL(noteCreated()), this, SLOT(newNote()));
    connect(ui->NotesList, SIGNAL(reloaded()), this, SLOT(updateCurrentNoteName()));
    connect(ui->editButton, SIGNAL(toggled(bool)), this, SLOT(setEditable(bool)));
    connect(ui->actionDelete_Note, SIGNAL(triggered()), this, SLOT(deleteNote()));
    connect(ui->toolBox, SIGNAL(currentChanged(int)), this, SLOT(changeTab(int)));
    connect(ui->editor->page(), SIGNAL(linkHovered(QString,QString,QString)), this, SLOT(linkHovered(QString,QString,QString)));
    connect(jsB, SIGNAL(hintMessage(QString,int)), ui->statusbar, SLOT(showMessage(QString,int)));
    connect(jsB, SIGNAL(noteChanged(QString)), this, SLOT(updateTagsToolBar(QString)));
    connect(jsB, SIGNAL(activeNoteSelectionChanged(bool)), ui->actionDelete_Note, SLOT(setEnabled(bool)));
    connect(jsB, SIGNAL(activeNoteSelectionChanged(bool)), ui->editButton, SLOT(setEnabled(bool)));
    connect(jsB, SIGNAL(editingStarted(bool)), ui->editButton, SLOT(setChecked(bool)));
    connect(jsB, SIGNAL(titleUpdated(QString,QString)), this, SLOT(updateNoteTitle(QString,QString)));
    connect(jsB, SIGNAL(conflictAdded(qint64,QString,bool)), this, SLOT(addConflict(qint64,QString,bool)));
    connect(jsB, SIGNAL(noteSelectionChanged(bool)), ui->actionNote_Info, SLOT(setEnabled(bool)));
    connect(jsB, SIGNAL(noteSelectionChanged(bool)), ui->actionExport, SLOT(setEnabled(bool)));
    connect(jsB, SIGNAL(noteSelectionChanged(bool)), ui->actionPrint, SLOT(setEnabled(bool)));
    connect(ui->editor, SIGNAL(tagUpdated(QString,bool)), this, SLOT(updateTag(QString,bool)));
    connect(tagsActions, SIGNAL(triggered(QAction*)), this, SLOT(tagClicked(QAction*)));
    connect(newTag, SIGNAL(tagCreated(QString)), this, SLOT(createTag(QString)));
    connect(ui->actionKeep_only_this_Version, SIGNAL(triggered()), this, SLOT(keepThisVersion()));
    connect(ui->actionNote_Info, SIGNAL(triggered()), this, SLOT(showNoteInfo()));
    connect(ui->actionExport, SIGNAL(triggered()), this, SLOT(exportNote()));
    connect(ui->actionPrint, SIGNAL(triggered()), this, SLOT(print()));
    connect(this, SIGNAL(titleChanged(QString,QString)), jsB, SIGNAL(titleChanged(QString,QString)));


    setWindowIcon(appIcon);
    setWindowTitle("Hippo Notes");

    setTabOrder(ui->noteTitle, ui->editor);

    ui->notebooks->setSortingEnabled(true);
    ui->notebooks->sortByColumn(0, Qt::AscendingOrder);
    ui->editBar->setVisible(false);

    ui->mainToolBar->addAction(ui->actionNew_Note);
    ui->mainToolBar->addAction(ui->actionSync);

    QFontComboBox *font = new QFontComboBox(this);
    font->setDisabled(true);
    font->setFontFilters(QFontComboBox::ScalableFonts);
    font->setEditable(false);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), font, SLOT(setEnabled(bool)));
    connect(this, SIGNAL(updateFont(QFont)), font, SLOT(setCurrentFont(QFont)));
    connect(font, SIGNAL(activated(QString)), this, SLOT(changeFont(QString)));
    ui->editBar->addWidget(font);

    QComboBox *fontSize = new QComboBox(this);
    fontSize->setDisabled(true);
    fontSize->setEditable(false);
    for (int i = 1; i <= 7; i++)
        fontSize->addItem(QString::number(i));
    connect(this, SIGNAL(editButtonsStateChanged(bool)), fontSize, SLOT(setEnabled(bool)));
    connect(this, SIGNAL(updateFontSize(int)), fontSize, SLOT(setCurrentIndex(int)));
    connect(fontSize, SIGNAL(activated(QString)), this, SLOT(changeFontSize(QString)));
    ui->editBar->addWidget(fontSize);

    QAction *boldIco = ui->editor->pageAction(QWebPage::ToggleBold);
    boldIco->setIcon(QIcon::fromTheme("format-text-bold"));
    ui->editBar->addAction(boldIco);

    QAction *italicIco = ui->editor->pageAction(QWebPage::ToggleItalic);
    italicIco->setIcon(QIcon::fromTheme("format-text-italic"));
    ui->editBar->addAction(italicIco);

    QAction *underlineIco = ui->editor->pageAction(QWebPage::ToggleUnderline);
    underlineIco->setIcon(QIcon::fromTheme("format-text-underline"));
    ui->editBar->addAction(underlineIco);

    QAction *strikethroughIco = ui->editor->pageAction(QWebPage::ToggleStrikethrough);
    strikethroughIco->setIcon(QIcon::fromTheme("format-text-strikethrough"));
    ui->editBar->addAction(strikethroughIco);

    ui->editBar->addSeparator();

    QAction *undoIco = ui->editor->pageAction(QWebPage::Undo);
    undoIco->setIcon(QIcon::fromTheme("edit-undo"));
    undoIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Z));
    ui->editBar->addAction(undoIco);
    ui->menu_Edit->addAction(undoIco);

    QAction *redoIco = ui->editor->pageAction(QWebPage::Redo);
    redoIco->setIcon(QIcon::fromTheme("edit-redo"));
    redoIco->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z));
    ui->editBar->addAction(redoIco);
    ui->menu_Edit->addAction(redoIco);

    ui->editBar->addSeparator();

    QAction *rformatIco = ui->editor->pageAction(QWebPage::RemoveFormat);
    rformatIco->setIcon(QIcon::fromTheme("edit-clear"));
    ui->editBar->addAction(rformatIco);

    ui->editBar->addSeparator();

    QAction *leftIco = ui->editor->pageAction(QWebPage::AlignLeft);
    leftIco->setIcon(QIcon::fromTheme("format-justify-left"));
    ui->editBar->addAction(leftIco);

    QAction *centerIco = ui->editor->pageAction(QWebPage::AlignCenter);
    centerIco->setIcon(QIcon::fromTheme("format-justify-center"));
    ui->editBar->addAction(centerIco);

    QAction *rightIco = ui->editor->pageAction(QWebPage::AlignRight);
    rightIco->setIcon(QIcon::fromTheme("format-justify-right"));
    ui->editBar->addAction(rightIco);

    QAction *fillIco = ui->editor->pageAction(QWebPage::AlignJustified);
    fillIco->setIcon(QIcon::fromTheme("format-justify-fill"));
    ui->editBar->addAction(fillIco);

    ui->editBar->addSeparator();

    QAction *indentIco = ui->editor->pageAction(QWebPage::Indent);
    indentIco->setIcon(QIcon::fromTheme("format-indent-more"));
    ui->editBar->addAction(indentIco);

    QAction *outdentIco = ui->editor->pageAction(QWebPage::Outdent);
    outdentIco->setIcon(QIcon::fromTheme("format-indent-less"));
    ui->editBar->addAction(outdentIco);

    QAction *superscriptIco = ui->editor->pageAction(QWebPage::ToggleSuperscript);
    superscriptIco->setIcon(QIcon::fromTheme("format-text-superscript"));
    ui->editBar->addAction(superscriptIco);

    QAction *subscriptIco = ui->editor->pageAction(QWebPage::ToggleSubscript);
    subscriptIco->setIcon(QIcon::fromTheme("format-text-subscript"));
    ui->editBar->addAction(subscriptIco);

    QAction *unorderedIco = ui->editor->pageAction(QWebPage::InsertUnorderedList);
    unorderedIco->setIcon(QIcon::fromTheme("format-list-unordered"));
    ui->editBar->addAction(unorderedIco);

    QAction *orderedIco = ui->editor->pageAction(QWebPage::InsertOrderedList);
    orderedIco->setIcon(QIcon::fromTheme("format-list-ordered"));
    ui->editBar->addAction(orderedIco);

    QAction *lineIco = new QAction("Insert horizontal line", this);
    lineIco->setIcon(QIcon::fromTheme("insert-horizontal-rule"));
    lineIco->setDisabled(true);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), lineIco, SLOT(setEnabled(bool)));
    connect(lineIco, SIGNAL(triggered()), this, SLOT(insertHorizontalLine()));
    ui->editBar->addAction(lineIco);

    ui->menu_Edit->addSeparator();

    QAction *cutIco = ui->editor->pageAction(QWebPage::Cut);
    cutIco->setIcon(QIcon::fromTheme("edit-cut"));
    cutIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_X));
    ui->menu_Edit->addAction(cutIco);

    QAction *copyIco = ui->editor->pageAction(QWebPage::Copy);
    copyIco->setIcon(QIcon::fromTheme("edit-copy"));
    copyIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
    ui->menu_Edit->addAction(copyIco);

    QAction *pasteIco = ui->editor->pageAction(QWebPage::Paste);
    pasteIco->setIcon(QIcon::fromTheme("edit-paste"));
    pasteIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V));
    ui->menu_Edit->addAction(pasteIco);

    QAction *pasteSpecialIco = ui->editor->pageAction(QWebPage::PasteAndMatchStyle);
    pasteSpecialIco->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V));
    ui->menu_Edit->addAction(pasteSpecialIco);

    ui->menu_Edit->addSeparator();

    QAction *insertUrlIco = new QAction("Create link", this);
    insertUrlIco->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
    insertUrlIco->setDisabled(true);
    insertUrlIco->setIcon(QIcon::fromTheme("insert-link"));
    connect(this, SIGNAL(selectionButtonsStateChanged(bool)), insertUrlIco, SLOT(setDisabled(bool)));
    connect(insertUrlIco, SIGNAL(triggered()), this, SLOT(insertUrl()));
    ui->menu_Edit->addAction(insertUrlIco);

    QAction *todoIco = new QAction("Insert To-do Checkbox", this);
    todoIco->setIcon(QIcon::fromTheme("checkbox"));
    todoIco->setDisabled(true);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), todoIco, SLOT(setEnabled(bool)));
    connect(todoIco, SIGNAL(triggered()), jsB, SIGNAL(insertToDo()));
    ui->menu_Edit->addAction(todoIco);

    QAction *insertImage = new QAction("Insert Image", this);
    insertImage->setIcon(QIcon::fromTheme("insert-image"));
    insertImage->setDisabled(true);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), insertImage, SLOT(setEnabled(bool)));
    connect(insertImage, SIGNAL(triggered()), this, SLOT(insertImg()));
    ui->menu_Edit->addAction(insertImage);

    QAction *insertFile = new QAction("Insert File", this);
    insertFile->setDisabled(true);
    connect(this, SIGNAL(editButtonsStateChanged(bool)), insertFile, SLOT(setEnabled(bool)));
    connect(insertFile, SIGNAL(triggered()), this, SLOT(insertFile()));
    ui->menu_Edit->addAction(insertFile);

    QAction *encryptIco = new QAction("Encrypt Selected Text...", this);
    encryptIco->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_X));
    encryptIco->setDisabled(true);
    encryptIco->setIcon(QIcon::fromTheme("document-edit-encrypt"));
    connect(this, SIGNAL(selectionButtonsStateChanged(bool)), encryptIco, SLOT(setDisabled(bool)));
    connect(encryptIco, SIGNAL(triggered()), jsB, SIGNAL(encryptText()));
    ui->menu_Edit->addAction(encryptIco);

    ui->menu_Edit->addSeparator();

    QAction *options = new QAction("&Options...", this);
    options->setIcon(QIcon::fromTheme("preferences-other"));
    connect(options, SIGNAL(triggered()), this, SLOT(showOptions()));
    ui->menu_Edit->addAction(options);


    clearConflictBar();
    connect(jsB, SIGNAL(showConflict()), ui->conflictBar, SLOT(show()));
    connect(jsB, SIGNAL(showConflict()), ui->conflictBarBottom, SLOT(show()));

    conflictsGroup = new QActionGroup(this);
    connect(conflictsGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeNoteVersion(QAction*)));

    searchIndex = new SearchIndex(this);
    connect(ui->searchButton, SIGNAL(clicked()), this, SLOT(search()));
    connect(edam, SIGNAL(syncFinished()), searchIndex, SLOT(buildSearchIndex()));
    connect(jsB, SIGNAL(noteUpdated(QString)), searchIndex, SLOT(updateNoteIndex(QString)));
    connect(edam, SIGNAL(noteUpdated(QString)), searchIndex, SLOT(dropNoteIndex(QString)));
    connect(ui->searchInput, SIGNAL(returnPressed()), this, SLOT(search()));

    QByteArray mainWindowGeometry = sql::readSyncStatus("mainWindowGeometry").toString().toLatin1();
    if (!mainWindowGeometry.isEmpty())
        restoreGeometry(QByteArray::fromBase64(mainWindowGeometry));

    QByteArray mainWidgetsSplitterState = sql::readSyncStatus("mainWidgetsSplitterState").toString().toLatin1();
    if (!mainWidgetsSplitterState.isEmpty())
        ui->mainWidgetsSplitter->restoreState(QByteArray::fromBase64(mainWidgetsSplitterState));

    //showWindow();
    edam->init();
}
Beispiel #11
0
MessageView::MessageView(QWidget *parent, QSettings *settings): QWidget(parent), m_settings(settings)
{
    QPalette pal = palette();
    pal.setColor(backgroundRole(), palette().color(QPalette::Active, QPalette::Base));
    pal.setColor(foregroundRole(), palette().color(QPalette::Active, QPalette::Text));
    setPalette(pal);
    setAutoFillBackground(true);
    setFocusPolicy(Qt::StrongFocus); // not by the wheel
    netAccess = new Imap::Network::MsgPartNetAccessManager(this);
    connect(netAccess, SIGNAL(requestingExternal(QUrl)), this, SLOT(externalsRequested(QUrl)));
    factory = new PartWidgetFactory(netAccess, this);

    emptyView = new EmbeddedWebView(this, new QNetworkAccessManager(this));
    emptyView->setFixedSize(450,300);
    QMetaObject::invokeMethod(emptyView, "handlePageLoadFinished", Qt::QueuedConnection);
    emptyView->setPage(new UserAgentWebPage(emptyView));
    emptyView->installEventFilter(this);
    emptyView->setAutoFillBackground(false);

    viewer = emptyView;

    //BEGIN create header section

    headerSection = new QWidget(this);

    // we create a dummy header, pass it through the style and the use it's color roles so we
    // know what headers in general look like in the system
    QHeaderView helpingHeader(Qt::Horizontal);
    helpingHeader.ensurePolished();
    pal = headerSection->palette();
    pal.setColor(headerSection->backgroundRole(), palette().color(QPalette::Active, helpingHeader.backgroundRole()));
    pal.setColor(headerSection->foregroundRole(), palette().color(QPalette::Active, helpingHeader.foregroundRole()));
    headerSection->setPalette(pal);
    headerSection->setAutoFillBackground(true);

    // the actual mail header
    m_envelope = new EnvelopeView(headerSection, this);

    // the tag bar
    tags = new TagListWidget(headerSection);
    tags->setBackgroundRole(helpingHeader.backgroundRole());
    tags->setForegroundRole(helpingHeader.foregroundRole());
    tags->hide();
    connect(tags, SIGNAL(tagAdded(QString)), this, SLOT(newLabelAction(QString)));
    connect(tags, SIGNAL(tagRemoved(QString)), this, SLOT(deleteLabelAction(QString)));

    // whether we allow to load external elements
    externalElements = new ExternalElementsWidget(this);
    externalElements->hide();
    connect(externalElements, SIGNAL(loadingEnabled()), this, SLOT(externalsEnabled()));

    // layout the header
    layout = new QVBoxLayout(headerSection);
    layout->addWidget(m_envelope, 1);
    layout->addWidget(tags, 3);
    layout->addWidget(externalElements, 1);

    //END create header section

    //BEGIN layout the message

    layout = new QVBoxLayout(this);
    layout->setSpacing(0);
    layout->setContentsMargins(0,0,0,0);

    layout->addWidget(headerSection, 1);

    headerSection->hide();

    // put the actual messages into an extra horizontal view
    // this allows us easy usage of the trailing stretch and also to indent the message a bit
    QHBoxLayout *hLayout = new QHBoxLayout;
    hLayout->setContentsMargins(6,6,6,0);
    hLayout->addWidget(viewer);
    static_cast<QVBoxLayout*>(layout)->addLayout(hLayout, 1);
    // add a strong stretch to squeeze header and message to the top
    // possibly passing a large stretch factor to the message could be enough...
    layout->addStretch(1000);

    //END layout the message

    // make the layout used to add messages our new horizontal layout
    layout = hLayout;

    markAsReadTimer = new QTimer(this);
    markAsReadTimer->setSingleShot(true);
    connect(markAsReadTimer, SIGNAL(timeout()), this, SLOT(markAsRead()));

    m_loadingSpinner = new Spinner(this);
    m_loadingSpinner->setText(tr("Fetching\nMessage"));
    m_loadingSpinner->setType(Spinner::Sun);
}