Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
psemiletov committed Mar 28, 2016
1 parent 88cb71e commit 0cb7d8a
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 25 deletions.
10 changes: 4 additions & 6 deletions document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,13 @@ CDocument::~CDocument()
if (file_name.startsWith (holder->todo.dir_days))
holder->todo.load_dayfile();


QMainWindow *w = qobject_cast <QMainWindow *> (holder->parent_wnd);
w->setWindowTitle ("");

int i = holder->tab_widget->indexOf (tab_page);
if (i != -1)
holder->tab_widget->removeTab (i);


QMainWindow *w = qobject_cast <QMainWindow *> (holder->parent_wnd);

w->setWindowTitle ("");

}


Expand Down
44 changes: 44 additions & 0 deletions gui_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ this code is Public Domain
#include "utils.h"

#include <QDir>
#include <QFileInfoList>
#include <QFileInfo>

#include <QLabel>

#include <QPushButton>
#include <QMenu>
#include <QStringList>
#include <QAction>
#include <QListWidgetItem>

void create_menu_from_list (QObject *handler,
QMenu *menu,
Expand Down Expand Up @@ -170,3 +178,39 @@ QComboBox* new_combobox (QBoxLayout *layout,

return r;
}

/*
CTextListWindow::CTextListWindow (const QString &title, const QString &label_text): QDialog (0)
{
//setAttribute (Qt::WA_DeleteOnClose);
QVBoxLayout *lt = new QVBoxLayout;
QLabel *l = new QLabel (label_text);
list = new QListWidget (this);
lt->addWidget (l);
lt->addWidget (list);
QHBoxLayout *lt_h = new QHBoxLayout;
QPushButton *bt_apply = new QPushButton (tr ("OK"));
QPushButton *bt_exit = new QPushButton (tr ("Exit"));
connect (list, SIGNAL(itemActivated (QListWidgetItem *)), this, SLOT(accept()));
connect (bt_apply, SIGNAL(clicked()), this, SLOT(accept()));
connect (bt_exit, SIGNAL(clicked()), this, SLOT(reject()));
lt_h->addWidget (bt_apply);
lt_h->addWidget (bt_exit);
lt->addLayout (lt_h);
setLayout (lt);
setWindowTitle (title);
}
*/
13 changes: 13 additions & 0 deletions gui_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@
#include <QSpinBox>
#include <QComboBox>
#include <QBoxLayout>
#include <QDialog>
#include <QListWidget>
/*
class CTextListWindow: public QDialog
{
Q_OBJECT
public:
QListWidget *list;
CTextListWindow (const QString &title, const QString &label_text);
};
*/

void create_menu_from_list (QObject *handler,
QMenu *menu,
Expand Down
10 changes: 10 additions & 0 deletions manuals/en.html
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,16 @@ <h4>Scripts from the developer's point of view</h4>
The Cranberries</pre>


<p><b>Math &gt; Sum by last column</b> - sums values of each last column at the selection. For example, we can calculate simply text list:
</p>

<p>
Carrots 14<br>
Apples 45.8<br>
Oranges 11
</p>


<p><b>Math &gt; Evaluate</b> - calculates the expression that selected at the text. For example you can write 2+2, then select it and apply <b>Evaluate</b>. After such action you shall see the result at the logmemo. In your expression can may use the following operators: +, -, *, /, ^ (power), % (get percent value). The bracers are not supported. Here are some examples:</p>

<pre>2/3*123
Expand Down
62 changes: 53 additions & 9 deletions rvln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ started at 08 November 2007
#include <QImageWriter>
#include <QDesktopServices>
#include <QColorDialog>
#include <QTextCodec>
#include <QMimeData>

#include <QScrollArea>

Expand Down Expand Up @@ -775,7 +777,7 @@ rvln::rvln()

setAcceptDrops (true);

log->log (tr ("<b>TEA %1</b> by Peter Semiletov - [email protected]<br>site 1: http://semiletov.org/tea<br>site 2: http://tea.ourproject.org<br>read the Manual under the <i>Learn</i> tab!").arg (QString (VERSION_NUMBER)));
log->log (tr ("<b>TEA %1</b> by Peter Semiletov, [email protected]<br>site 1: http://semiletov.org/tea<br>site 2: http://tea.ourproject.org<br>site 3 (development): https://github.com/psemiletov/tea-qt<br>read the Manual under the <i>Learn</i> tab!").arg (QString (VERSION_NUMBER)));


QString icon_fname = ":/icons/tea-icon-v3-0" + settings->value ("icon_fname", "1").toString() + ".png";
Expand Down Expand Up @@ -1306,6 +1308,10 @@ void rvln::createMenus()
editMenu->addAction (copyAct);
editMenu->addAction (pasteAct);

add_to_menu (editMenu, tr ("Paste from charset"), SLOT(ed_paste_from_charset()));



editMenu->addSeparator();

add_to_menu (editMenu, tr ("Copy current file name"), SLOT(edit_copy_current_fname()));
Expand Down Expand Up @@ -1512,7 +1518,7 @@ void rvln::createMenus()
add_to_menu (tm, tr ("Binary to decimal"), SLOT(fn_binary_to_decimal()));
add_to_menu (tm, tr ("Flip bits (bitwise complement)"), SLOT(fn_number_flip_bits()));
add_to_menu (tm, tr ("Enumerate"), SLOT(fn_enum()));
add_to_menu (tm, tr ("Sum by last column"), SLOT(fn_sum_by_last_col()));
// add_to_menu (tm, tr ("Sum by last column"), SLOT(fn_sum_by_last_col()));



Expand Down Expand Up @@ -4672,10 +4678,6 @@ void CAboutWindow::closeEvent (QCloseEvent *event)
}


void CTextListWindow::closeEvent (QCloseEvent *event)
{
event->accept();
}


void CAboutWindow::update_image()
Expand Down Expand Up @@ -6064,7 +6066,13 @@ void rvln::file_reload()
}


CTextListWindow::CTextListWindow (const QString &title, const QString &label_text)
void CTextListWnd::closeEvent (QCloseEvent *event)
{
event->accept();
}


CTextListWnd::CTextListWnd (const QString &title, const QString &label_text)
{
setAttribute (Qt::WA_DeleteOnClose);
QVBoxLayout *lt = new QVBoxLayout;
Expand All @@ -6091,7 +6099,7 @@ void rvln::file_reload_enc_itemDoubleClicked (QListWidgetItem *item)

void rvln::file_reload_enc()
{
CTextListWindow *w = new CTextListWindow (tr ("Reload with encoding"), tr ("Charset"));
CTextListWnd *w = new CTextListWnd (tr ("Reload with encoding"), tr ("Charset"));

if (sl_last_used_charsets.size () > 0)
w->list->addItems (sl_last_used_charsets + sl_charsets);
Expand Down Expand Up @@ -7331,7 +7339,7 @@ void rvln::search_in_files()

pb_status->hide();

CTextListWindow *w = new CTextListWindow (tr ("Search results"), tr ("Files"));
CTextListWnd *w = new CTextListWnd (tr ("Search results"), tr ("Files"));

w->list->addItems (lresult);

Expand Down Expand Up @@ -9371,3 +9379,39 @@ void rvln::fn_sum_by_last_col()


}

/*
void rvln::ed_paste_from_charset()
{
CTextListWindow w (tr ("Select"), tr ("Available effects"));

w.list->addItems (sl_charsets);

int result = w.exec();

if (result != QDialog::Accepted)
return;

//AFx *f = avail_fx->find_by_name (w.list->currentItem()->text());

QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData();

if (!mimeData->hasText())
{
qDebug() << "! text";
return;

}

// QString t = clipboard->text();

QTextCodec *codec = QTextCodec::codecForName (w.list->currentItem()->text().toLatin1());


QString s = codec->toUnicode (mimeData->data("text/plain"));

qDebug() << s.toUtf8().data();

}
*/
7 changes: 5 additions & 2 deletions rvln.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ public slots:
};


class CTextListWindow: public QWidget
class CTextListWnd: public QWidget
{
Q_OBJECT

public:

QListWidget *list;

CTextListWindow (const QString &title, const QString &label_text);
CTextListWnd (const QString &title, const QString &label_text);

protected:

Expand Down Expand Up @@ -496,6 +496,9 @@ main window callbacks

void ed_comment();

// void ed_paste_from_charset();


void set_as_storage_file();
void copy_to_storage_file();
void capture_clipboard_to_storage_file();
Expand Down
9 changes: 1 addition & 8 deletions tio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,16 @@ bool CTioABW::load (const QString &fname)

bool CTioODTSpecial::load (const QString &fname)
{
qDebug() << "CTioODTSpecial::load - start";

data.clear();

data.clear();

CZipper zipper;


if (! zipper.read_as_utf8 (fname, "content.xml"))
{
qDebug() << "cannot read content.xml";
return false;
}


QXmlStreamReader xml (zipper.string_data);

Expand Down Expand Up @@ -254,8 +250,6 @@ bool CTioODTSpecial::load (const QString &fname)

if (xml.hasError())
qDebug() << "xml parse error";

qDebug() << "CTioODTSpecial::load - end";

return true;
}
Expand Down Expand Up @@ -362,7 +356,6 @@ CCharsetMagic::CCharsetMagic()

if (fn == "KOI8-U")
koi8u = sl;


for (int i = 0; i < bsl.count(); i++)
sl->words.append (bsl[i]);
Expand Down

0 comments on commit 0cb7d8a

Please sign in to comment.